]> git.saurik.com Git - wxWidgets.git/blame - src/stc/stc.cpp
Merged wxPython 2.2.2 over to the main branch
[wxWidgets.git] / src / stc / stc.cpp
CommitLineData
9ce192d4
RD
1////////////////////////////////////////////////////////////////////////////
2// Name: stc.cpp
3// Purpose: A wxWindows implementation of Scintilla. This class is the
4// one meant to be used directly by wx applications. It does not
5// derive directly from the Scintilla classes, but instead
6// delegates most things to the real Scintilla class.
7// This allows the use of Scintilla without polluting the
f6bcfd97 8// namespace with all the classes and identifiers from Scintilla.
9ce192d4
RD
9//
10// Author: Robin Dunn
11//
12// Created: 13-Jan-2000
13// RCS-ID: $Id$
14// Copyright: (c) 2000 by Total Control Software
15// Licence: wxWindows license
16/////////////////////////////////////////////////////////////////////////////
17
f6bcfd97
BP
18#include <ctype.h>
19
9ce192d4
RD
20#include "wx/stc/stc.h"
21#include "ScintillaWX.h"
22
23#include <wx/tokenzr.h>
24
f6bcfd97
BP
25// The following code forces a reference to all of the Scintilla lexers.
26// If we don't do something like this, then the linker tends to "optimize"
27// them away. (eric@sourcegear.com)
28
4370573a 29int wxForceScintillaLexers(void)
f6bcfd97
BP
30{
31 extern LexerModule lmCPP;
32 extern LexerModule lmHTML;
33 extern LexerModule lmXML;
34 extern LexerModule lmProps;
35 extern LexerModule lmErrorList;
36 extern LexerModule lmMake;
37 extern LexerModule lmBatch;
38 extern LexerModule lmPerl;
39 extern LexerModule lmPython;
40 extern LexerModule lmSQL;
41 extern LexerModule lmVB;
42
43 if (
44 &lmCPP
45 && &lmHTML
46 && &lmXML
47 && &lmProps
48 && &lmErrorList
49 && &lmMake
50 && &lmBatch
51 && &lmPerl
52 && &lmPython
53 && &lmSQL
54 && &lmVB
55 )
56 {
57 return 1;
58 }
4370573a
RD
59 else
60 {
61 return 0;
62 }
f6bcfd97
BP
63}
64
9ce192d4
RD
65//----------------------------------------------------------------------
66
67const wxChar* wxSTCNameStr = "stcwindow";
68
69BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
70 EVT_PAINT (wxStyledTextCtrl::OnPaint)
71 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin)
72 EVT_SIZE (wxStyledTextCtrl::OnSize)
73 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
74 EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
75 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
76 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
77 EVT_CHAR (wxStyledTextCtrl::OnChar)
f6bcfd97 78 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
9ce192d4
RD
79 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
80 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus)
81 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
82 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
83 EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu)
f6bcfd97 84 EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox)
9ce192d4
RD
85END_EVENT_TABLE()
86
f6bcfd97
BP
87
88IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
89IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
90
9ce192d4
RD
91//----------------------------------------------------------------------
92// Constructor and Destructor
93
94wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
95 wxWindowID id,
96 const wxPoint& pos,
97 const wxSize& size,
98 long style,
99 const wxString& name) :
100 wxControl(parent, id, pos, size,
101 style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS,
102 wxDefaultValidator, name)
103{
104 m_swx = new ScintillaWX(this);
9ce192d4 105 m_stopWatch.Start();
9ce192d4
RD
106}
107
108
109wxStyledTextCtrl::~wxStyledTextCtrl() {
110 delete m_swx;
9ce192d4
RD
111}
112
113
114//----------------------------------------------------------------------
115
f6bcfd97 116long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) {
9ce192d4
RD
117
118 return m_swx->WndProc(msg, wp, lp);
119}
120
121
4370573a 122#define MAKELONG(a, b) ((a) | ((b) << 16))
9ce192d4
RD
123
124
4370573a
RD
125static long wxColourAsLong(const wxColour& co) {
126 return (((long)co.Blue() << 16) |
127 ((long)co.Green() << 8) |
128 ((long)co.Red()));
9ce192d4
RD
129}
130
4370573a
RD
131static wxColour wxColourFromLong(long c) {
132 wxColour clr;
133 clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff);
134 return clr;
9ce192d4
RD
135}
136
137
4370573a
RD
138static wxColour wxColourFromSpec(const wxString& spec) {
139 // spec should be #RRGGBB
140 char* junk;
141 int red = strtol(spec.Mid(1,2), &junk, 16);
142 int green = strtol(spec.Mid(3,2), &junk, 16);
143 int blue = strtol(spec.Mid(5,2), &junk, 16);
144 return wxColour(red, green, blue);
9ce192d4
RD
145}
146
147
4370573a
RD
148//----------------------------------------------------------------------
149// BEGIN generated section. The following code is automatically generated
150// by gen_iface.py from the contents of Scintilla.iface. Do not edit
151// this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
9ce192d4
RD
152
153
4370573a 154// Add text to the document
9ce192d4 155void wxStyledTextCtrl::AddText(const wxString& text) {
4370573a 156 SendMsg(2001, text.Len(), (long)text.c_str());
9ce192d4
RD
157}
158
4370573a 159// Add array of cells to document
9ce192d4 160void wxStyledTextCtrl::AddStyledText(const wxString& text) {
4370573a 161 SendMsg(2002, text.Len(), (long)text.c_str());
9ce192d4
RD
162}
163
4370573a 164// Insert string at a position
9ce192d4 165void wxStyledTextCtrl::InsertText(int pos, const wxString& text) {
4370573a 166 SendMsg(2003, pos, (long)text.c_str());
9ce192d4
RD
167}
168
4370573a 169// Delete all text in the document
9ce192d4 170void wxStyledTextCtrl::ClearAll() {
4370573a 171 SendMsg(2004, 0, 0);
9ce192d4
RD
172}
173
4370573a
RD
174// Set all style bytes to 0, remove all folding information
175void wxStyledTextCtrl::ClearDocumentStyle() {
176 SendMsg(2005, 0, 0);
9ce192d4
RD
177}
178
4370573a
RD
179// The number of characters in the document
180int wxStyledTextCtrl::GetLength() {
181 return SendMsg(2006, 0, 0);
9ce192d4
RD
182}
183
4370573a
RD
184// Returns the character byte at the position
185int wxStyledTextCtrl::GetCharAt(int pos) {
186 return SendMsg(2007, pos, 0);
9ce192d4
RD
187}
188
4370573a
RD
189// Returns the position of the caret
190int wxStyledTextCtrl::GetCurrentPos() {
191 return SendMsg(2008, 0, 0);
9ce192d4
RD
192}
193
4370573a
RD
194// Returns the position of the opposite end of the selection to the caret
195int wxStyledTextCtrl::GetAnchor() {
196 return SendMsg(2009, 0, 0);
9ce192d4
RD
197}
198
4370573a
RD
199// Returns the style byte at the position
200int wxStyledTextCtrl::GetStyleAt(int pos) {
201 return SendMsg(2010, pos, 0);
9ce192d4
RD
202}
203
4370573a 204// Redoes the next action on the undo history
9ce192d4 205void wxStyledTextCtrl::Redo() {
4370573a 206 SendMsg(2011, 0, 0);
9ce192d4
RD
207}
208
4370573a
RD
209// Choose between collecting actions into the undo
210// history and discarding them.
211void wxStyledTextCtrl::SetUndoCollection(bool collectUndo) {
212 SendMsg(2012, collectUndo, 0);
9ce192d4
RD
213}
214
4370573a
RD
215// Select all the text in the document.
216void wxStyledTextCtrl::SelectAll() {
217 SendMsg(2013, 0, 0);
9ce192d4
RD
218}
219
4370573a
RD
220// Remember the current position in the undo history as the position
221// at which the document was saved.
222void wxStyledTextCtrl::SetSavePoint() {
223 SendMsg(2014, 0, 0);
9ce192d4
RD
224}
225
4370573a
RD
226// Retrieve a buffer of cells.
227wxString wxStyledTextCtrl::GetStyledText(int startPos, int endPos) {
228 wxString text;
229 int len = endPos - startPos;
230 TextRange tr;
231 tr.lpstrText = text.GetWriteBuf(len*2+1);
232 tr.chrg.cpMin = startPos;
233 tr.chrg.cpMax = endPos;
234 SendMsg(2015, 0, (long)&tr);
235 text.UngetWriteBuf(len*2);
236 return text;
9ce192d4
RD
237}
238
4370573a
RD
239// Are there any redoable actions in the undo history.
240bool wxStyledTextCtrl::CanRedo() {
241 return SendMsg(2016, 0, 0) != 0;
9ce192d4
RD
242}
243
4370573a
RD
244// Retrieve the line number at which a particular marker is located
245int wxStyledTextCtrl::MarkerLineFromHandle(int handle) {
246 return SendMsg(2017, handle, 0);
9ce192d4
RD
247}
248
4370573a
RD
249// Delete a marker.
250void wxStyledTextCtrl::MarkerDeleteHandle(int handle) {
251 SendMsg(2018, handle, 0);
9ce192d4
RD
252}
253
4370573a
RD
254// Is undo history being collected?
255bool wxStyledTextCtrl::GetUndoCollection() {
256 return SendMsg(2019, 0, 0) != 0;
9ce192d4
RD
257}
258
4370573a
RD
259// Are white space characters currently visible?
260// Returns one of SCWS_* constants.
261int wxStyledTextCtrl::GetViewWhiteSpace() {
262 return SendMsg(2020, 0, 0);
9ce192d4
RD
263}
264
4370573a
RD
265// Make white space characters invisible, always visible or visible outside indentation.
266void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS) {
267 SendMsg(2021, viewWS, 0);
9ce192d4
RD
268}
269
4370573a 270// Find the position from a point within the window.
9ce192d4 271int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) {
4370573a 272 return SendMsg(2022, pt.x, pt.y);
9ce192d4
RD
273}
274
4370573a
RD
275// Set caret to start of a line and ensure it is visible.
276void wxStyledTextCtrl::GotoLine(int line) {
277 SendMsg(2024, line, 0);
9ce192d4
RD
278}
279
4370573a 280// Set caret to a position and ensure it is visible.
9ce192d4 281void wxStyledTextCtrl::GotoPos(int pos) {
4370573a 282 SendMsg(2025, pos, 0);
9ce192d4
RD
283}
284
4370573a
RD
285// Set the selection anchor to a position. The anchor is the opposite
286// end of the selection from the caret.
287void wxStyledTextCtrl::SetAnchor(int posAnchor) {
288 SendMsg(2026, posAnchor, 0);
9ce192d4
RD
289}
290
4370573a
RD
291// Retrieve the text of the line containing the caret.
292// Returns the index of the caret on the line.
293wxString wxStyledTextCtrl::GetCurLine(int* linePos) {
294 wxString text;
295 int len = LineLength(GetCurrentLine());
296 char* buf = text.GetWriteBuf(len+1);
9ce192d4 297
4370573a
RD
298 int pos = SendMsg(2027, len, (long)buf);
299 text.UngetWriteBuf();
300 if (linePos) *linePos = pos;
9ce192d4 301
4370573a 302 return text;
9ce192d4
RD
303}
304
4370573a
RD
305// Retrieve the position of the last correctly styled character.
306int wxStyledTextCtrl::GetEndStyled() {
307 return SendMsg(2028, 0, 0);
9ce192d4
RD
308}
309
4370573a
RD
310// Convert all line endings in the document to use the current mode.
311void wxStyledTextCtrl::ConvertEOLs() {
312 SendMsg(2029, 0, 0);
9ce192d4
RD
313}
314
4370573a
RD
315// Retrieve the current end of line mode - one of CRLF, CR, or LF.
316int wxStyledTextCtrl::GetEOLMode() {
317 return SendMsg(2030, 0, 0);
9ce192d4
RD
318}
319
4370573a
RD
320// Set the current end of line mode.
321void wxStyledTextCtrl::SetEOLMode(int eolMode) {
322 SendMsg(2031, eolMode, 0);
9ce192d4
RD
323}
324
4370573a
RD
325// Set the current styling position to pos and the styling mask to mask.
326// The styling mask can be used to protect some bits in each styling byte from
327// modification.
328void wxStyledTextCtrl::StartStyling(int pos, int mask) {
329 SendMsg(2032, pos, mask);
9ce192d4
RD
330}
331
4370573a
RD
332// Change style from current styling position for length characters to a style
333// and move the current styling position to after this newly styled segment.
334void wxStyledTextCtrl::SetStyling(int length, int style) {
335 SendMsg(2033, length, style);
f6bcfd97
BP
336}
337
4370573a
RD
338// Is drawing done first into a buffer or direct to the screen.
339bool wxStyledTextCtrl::GetBufferedDraw() {
340 return SendMsg(2034, 0, 0) != 0;
f6bcfd97
BP
341}
342
4370573a
RD
343// If drawing is buffered then each line of text is drawn into a bitmap buffer
344// before drawing it to the screen to avoid flicker.
345void wxStyledTextCtrl::SetBufferedDraw(bool buffered) {
346 SendMsg(2035, buffered, 0);
f6bcfd97
BP
347}
348
4370573a
RD
349// Change the visible size of a tab to be a multiple of the width of a space
350// character.
351void wxStyledTextCtrl::SetTabWidth(int tabWidth) {
352 SendMsg(2036, tabWidth, 0);
f6bcfd97
BP
353}
354
4370573a
RD
355// Retrieve the visible size of a tab.
356int wxStyledTextCtrl::GetTabWidth() {
357 return SendMsg(2121, 0, 0);
9ce192d4
RD
358}
359
4370573a
RD
360// Set the code page used to interpret the bytes of the document as characters.
361// The SC_CP_UTF8 value can be used to enter Unicode mode.
362void wxStyledTextCtrl::SetCodePage(int codePage) {
363 SendMsg(2037, codePage, 0);
9ce192d4
RD
364}
365
4370573a
RD
366// Set the symbol used for a particular marker number,
367// and optionally the for and background colours.
368void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
369 const wxColour& foreground,
370 const wxColour& background) {
9ce192d4 371
4370573a
RD
372 SendMsg(2040, markerNumber, markerSymbol);
373 if (foreground.Ok())
374 MarkerSetForeground(markerNumber, foreground);
375 if (background.Ok())
376 MarkerSetBackground(markerNumber, background);
9ce192d4
RD
377}
378
4370573a
RD
379// Set the foreground colour used for a particular marker number.
380void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore) {
381 SendMsg(2041, markerNumber, wxColourAsLong(fore));
9ce192d4
RD
382}
383
4370573a
RD
384// Set the background colour used for a particular marker number.
385void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back) {
386 SendMsg(2042, markerNumber, wxColourAsLong(back));
9ce192d4
RD
387}
388
4370573a
RD
389// Add a marker to a line.
390void wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) {
391 SendMsg(2043, line, markerNumber);
9ce192d4
RD
392}
393
4370573a
RD
394// Delete a marker from a line
395void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber) {
396 SendMsg(2044, line, markerNumber);
9ce192d4
RD
397}
398
4370573a
RD
399// Delete all markers with a particular number from all lines
400void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber) {
401 SendMsg(2045, markerNumber, 0);
9ce192d4
RD
402}
403
4370573a
RD
404// Get a bit mask of all the markers set on a line.
405int wxStyledTextCtrl::MarkerGet(int line) {
406 return SendMsg(2046, line, 0);
9ce192d4
RD
407}
408
4370573a
RD
409// Find the next line after lineStart that includes a marker in mask.
410int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask) {
411 return SendMsg(2047, lineStart, markerMask);
9ce192d4
RD
412}
413
4370573a
RD
414// Find the previous line before lineStart that includes a marker in mask.
415int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask) {
416 return SendMsg(2048, lineStart, markerMask);
9ce192d4
RD
417}
418
4370573a
RD
419// Set a margin to be either numeric or symbolic.
420void wxStyledTextCtrl::SetMarginType(int margin, int marginType) {
421 SendMsg(2240, margin, marginType);
9ce192d4
RD
422}
423
4370573a
RD
424// Retrieve the type of a margin.
425int wxStyledTextCtrl::GetMarginType(int margin) {
426 return SendMsg(2241, margin, 0);
9ce192d4
RD
427}
428
4370573a
RD
429// Set the width of a margin to a width expressed in pixels.
430void wxStyledTextCtrl::SetMarginWidth(int margin, int pixelWidth) {
431 SendMsg(2242, margin, pixelWidth);
9ce192d4
RD
432}
433
4370573a
RD
434// Retrieve the width of a margin in pixels.
435int wxStyledTextCtrl::GetMarginWidth(int margin) {
436 return SendMsg(2243, margin, 0);
f6bcfd97
BP
437}
438
4370573a
RD
439// Set a mask that determines which markers are displayed in a margin.
440void wxStyledTextCtrl::SetMarginMask(int margin, int mask) {
441 SendMsg(2244, margin, mask);
f6bcfd97
BP
442}
443
4370573a
RD
444// Retrieve the marker mask of a margin.
445int wxStyledTextCtrl::GetMarginMask(int margin) {
446 return SendMsg(2245, margin, 0);
9ce192d4
RD
447}
448
4370573a
RD
449// Make a margin sensitive or insensitive to mouse clicks.
450void wxStyledTextCtrl::SetMarginSensitive(int margin, bool sensitive) {
451 SendMsg(2246, margin, sensitive);
9ce192d4
RD
452}
453
4370573a
RD
454// Retrieve the mouse click sensitivity of a margin.
455bool wxStyledTextCtrl::GetMarginSensitive(int margin) {
456 return SendMsg(2247, margin, 0) != 0;
9ce192d4
RD
457}
458
4370573a 459// Clear all the styles and make equivalent to the global default style.
9ce192d4 460void wxStyledTextCtrl::StyleClearAll() {
4370573a 461 SendMsg(2050, 0, 0);
9ce192d4
RD
462}
463
4370573a
RD
464// Set the foreground colour of a style.
465void wxStyledTextCtrl::StyleSetForeground(int style, const wxColour& fore) {
466 SendMsg(2051, style, wxColourAsLong(fore));
9ce192d4
RD
467}
468
4370573a
RD
469// Set the background colour of a style.
470void wxStyledTextCtrl::StyleSetBackground(int style, const wxColour& back) {
471 SendMsg(2052, style, wxColourAsLong(back));
9ce192d4
RD
472}
473
4370573a
RD
474// Set a style to be bold or not.
475void wxStyledTextCtrl::StyleSetBold(int style, bool bold) {
476 SendMsg(2053, style, bold);
9ce192d4
RD
477}
478
4370573a
RD
479// Set a style to be italic or not.
480void wxStyledTextCtrl::StyleSetItalic(int style, bool italic) {
481 SendMsg(2054, style, italic);
9ce192d4
RD
482}
483
4370573a
RD
484// Set the size of characters of a style.
485void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints) {
486 SendMsg(2055, style, sizePoints);
9ce192d4
RD
487}
488
4370573a
RD
489// Set the font of a style.
490void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) {
491 SendMsg(2056, style, (long)fontName.c_str());
9ce192d4
RD
492}
493
4370573a
RD
494// Set a style to have its end of line filled or not.
495void wxStyledTextCtrl::StyleSetEOLFilled(int style, bool filled) {
496 SendMsg(2057, style, filled);
9ce192d4
RD
497}
498
4370573a
RD
499// Reset the default style to its state at startup
500void wxStyledTextCtrl::StyleResetDefault() {
501 SendMsg(2058, 0, 0);
9ce192d4
RD
502}
503
4370573a
RD
504// Set a style to be underlined or not.
505void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline) {
506 SendMsg(2059, style, underline);
9ce192d4
RD
507}
508
4370573a
RD
509// Set the foreground colour of the selection and whether to use this setting.
510void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) {
511 SendMsg(2067, useSetting, wxColourAsLong(fore));
9ce192d4
RD
512}
513
4370573a
RD
514// Set the background colour of the selection and whether to use this setting.
515void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back) {
516 SendMsg(2068, useSetting, wxColourAsLong(back));
9ce192d4
RD
517}
518
4370573a
RD
519// Set the foreground colour of the caret.
520void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore) {
521 SendMsg(2069, wxColourAsLong(fore), 0);
9ce192d4
RD
522}
523
4370573a
RD
524// When key+modifier combination km is pressed perform msg.
525void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) {
526 SendMsg(2070, MAKELONG(key, modifiers), cmd);
9ce192d4
RD
527}
528
4370573a
RD
529// When key+modifier combination km do nothing.
530void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) {
531 SendMsg(2071, MAKELONG(key, modifiers));
9ce192d4
RD
532}
533
4370573a
RD
534// Drop all key mappings.
535void wxStyledTextCtrl::CmdKeyClearAll() {
536 SendMsg(2072, 0, 0);
537}
9ce192d4 538
4370573a
RD
539// Set the styles for a segment of the document.
540void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) {
541 SendMsg(2073, length, (long)styleBytes);
9ce192d4
RD
542}
543
4370573a
RD
544// Set a style to be visible or not.
545void wxStyledTextCtrl::StyleSetVisible(int style, bool visible) {
546 SendMsg(2074, style, visible);
547}
9ce192d4 548
4370573a 549// Get the time in milliseconds that the caret is on and off.
9ce192d4 550int wxStyledTextCtrl::GetCaretPeriod() {
4370573a 551 return SendMsg(2075, 0, 0);
9ce192d4
RD
552}
553
4370573a
RD
554// Get the time in milliseconds that the caret is on and off. 0 = steady on.
555void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) {
556 SendMsg(2076, periodMilliseconds, 0);
557}
9ce192d4 558
4370573a
RD
559// Set the set of characters making up words for when moving or selecting
560// by word.
561void wxStyledTextCtrl::SetWordChars(const wxString& characters) {
562 SendMsg(2077, 0, (long)characters.c_str());
9ce192d4
RD
563}
564
4370573a
RD
565// Start a sequence of actions that is undone and redone as a unit.
566// May be nested.
567void wxStyledTextCtrl::BeginUndoAction() {
568 SendMsg(2078, 0, 0);
569}
9ce192d4 570
4370573a
RD
571// End a sequence of actions that is undone and redone as a unit.
572void wxStyledTextCtrl::EndUndoAction() {
573 SendMsg(2079, 0, 0);
574}
9ce192d4 575
4370573a
RD
576// Set an indicator to plain, squiggle or TT.
577void wxStyledTextCtrl::IndicatorSetStyle(int indic, int style) {
578 SendMsg(2080, indic, style);
579}
9ce192d4 580
4370573a
RD
581// Retrieve the style of an indicator.
582int wxStyledTextCtrl::IndicatorGetStyle(int indic) {
583 return SendMsg(2081, indic, 0);
584}
9ce192d4 585
4370573a
RD
586// Set the foreground colour of an indicator.
587void wxStyledTextCtrl::IndicatorSetForeground(int indic, const wxColour& fore) {
588 SendMsg(2082, indic, wxColourAsLong(fore));
9ce192d4
RD
589}
590
4370573a
RD
591// Retrieve the foreground colour of an indicator.
592wxColour wxStyledTextCtrl::IndicatorGetForeground(int indic) {
593 long c = SendMsg(2083, indic, 0);
594 return wxColourFromLong(c);
595}
9ce192d4 596
4370573a
RD
597// Divide each styling byte into lexical class bits (default:5) and indicator
598// bits (default:3). If a lexer requires more than 32 lexical states, then this
599// is used to expand the possible states.
600void wxStyledTextCtrl::SetStyleBits(int bits) {
601 SendMsg(2090, bits, 0);
9ce192d4
RD
602}
603
4370573a
RD
604// Retrieve number of bits in style bytes used to hold the lexical state.
605int wxStyledTextCtrl::GetStyleBits() {
606 return SendMsg(2091, 0, 0);
607}
9ce192d4 608
4370573a
RD
609// Used to hold extra styling information for each line.
610void wxStyledTextCtrl::SetLineState(int line, int state) {
611 SendMsg(2092, line, state);
f6bcfd97
BP
612}
613
4370573a
RD
614// Retrieve the extra styling information for a line.
615int wxStyledTextCtrl::GetLineState(int line) {
616 return SendMsg(2093, line, 0);
617}
f6bcfd97 618
4370573a
RD
619// Retrieve the last line number that has line state.
620int wxStyledTextCtrl::GetMaxLineState() {
621 return SendMsg(2094, 0, 0);
f6bcfd97
BP
622}
623
4370573a
RD
624// Display a auto-completion list.
625// The lenEntered parameter indicates how many characters before
626// the caret should be used to provide context.
627void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) {
628 SendMsg(2100, lenEntered, (long)itemList.c_str());
629}
f6bcfd97 630
4370573a
RD
631// Remove the auto-completion list from the screen.
632void wxStyledTextCtrl::AutoCompCancel() {
633 SendMsg(2101, 0, 0);
f6bcfd97
BP
634}
635
4370573a
RD
636// Is there an auto-completion list visible?
637bool wxStyledTextCtrl::AutoCompActive() {
638 return SendMsg(2102, 0, 0) != 0;
639}
f6bcfd97 640
4370573a
RD
641// Retrieve the position of the caret when the auto-completion list was
642// displayed.
643int wxStyledTextCtrl::AutoCompPosStart() {
644 return SendMsg(2103, 0, 0);
f6bcfd97
BP
645}
646
4370573a
RD
647// User has selected an item so remove the list and insert the selection.
648void wxStyledTextCtrl::AutoCompComplete() {
649 SendMsg(2104, 0, 0);
650}
f6bcfd97 651
4370573a
RD
652// Define a set of character that when typed cancel the auto-completion list.
653void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) {
654 SendMsg(2105, 0, (long)characterSet.c_str());
f6bcfd97
BP
655}
656
4370573a
RD
657// Change the separator character in the string setting up an auto-completion
658// list. Default is space but can be changed if items contain space.
659void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter) {
660 SendMsg(2106, separatorCharacter, 0);
661}
f6bcfd97 662
4370573a
RD
663// Retrieve the auto-completion list separator character.
664int wxStyledTextCtrl::AutoCompGetSeparator() {
665 return SendMsg(2107, 0, 0);
9ce192d4
RD
666}
667
4370573a
RD
668// Select the item in the auto-completion list that starts with a string.
669void wxStyledTextCtrl::AutoCompSelect(const wxString& text) {
670 SendMsg(2108, 0, (long)text.c_str());
671}
9ce192d4 672
4370573a
RD
673// Should the auto-completion list be cancelled if the user backspaces to a
674// position before where the box was created.
675void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel) {
676 SendMsg(2110, cancel, 0);
f6bcfd97
BP
677}
678
4370573a
RD
679// Retrieve whether auto-completion cancelled by backspacing before start.
680bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
681 return SendMsg(2111, 0, 0) != 0;
682}
f6bcfd97 683
4370573a
RD
684// Define a set of character that when typed fills up the selected word.
685void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) {
686 SendMsg(2112, 0, (long)characterSet.c_str());
687}
9ce192d4 688
4370573a
RD
689// Should a single item auto-completion list automatically choose the item.
690void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle) {
691 SendMsg(2113, chooseSingle, 0);
692}
9ce192d4 693
4370573a
RD
694// Retrieve whether a single item auto-completion list automatically choose the item.
695bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
696 return SendMsg(2114, 0, 0) != 0;
9ce192d4
RD
697}
698
4370573a
RD
699// Set whether case is significant when performing auto-completion searches.
700void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase) {
701 SendMsg(2115, ignoreCase, 0);
702}
9ce192d4 703
4370573a
RD
704// Retrieve state of ignore case flag.
705bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
706 return SendMsg(2116, 0, 0) != 0;
9ce192d4
RD
707}
708
4370573a
RD
709// Set the number of spaces used for one level of indentation.
710void wxStyledTextCtrl::SetIndent(int indentSize) {
711 SendMsg(2122, indentSize, 0);
712}
9ce192d4 713
4370573a
RD
714// Retrieve indentation size.
715int wxStyledTextCtrl::GetIndent() {
716 return SendMsg(2123, 0, 0);
9ce192d4
RD
717}
718
4370573a
RD
719// Indentation will only use space characters if useTabs is false, otherwise
720// it will use a combination of tabs and spaces.
721void wxStyledTextCtrl::SetUseTabs(bool useTabs) {
722 SendMsg(2124, useTabs, 0);
723}
9ce192d4 724
4370573a
RD
725// Retrieve whether tabs will be used in indentation.
726bool wxStyledTextCtrl::GetUseTabs() {
727 return SendMsg(2125, 0, 0) != 0;
728}
9ce192d4 729
4370573a
RD
730// Change the indentation of a line to a number of columns.
731void wxStyledTextCtrl::SetLineIndentation(int line, int indentSize) {
732 SendMsg(2126, line, indentSize);
733}
9ce192d4 734
4370573a
RD
735// Retrieve the number of columns that a line is indented.
736int wxStyledTextCtrl::GetLineIndentation(int line) {
737 return SendMsg(2127, line, 0);
9ce192d4
RD
738}
739
4370573a
RD
740// Retrieve the position before the first non indentation character on a line.
741int wxStyledTextCtrl::GetLineIndentPosition(int line) {
742 return SendMsg(2128, line, 0);
743}
9ce192d4 744
4370573a
RD
745// Retrieve the column number of a position, taking tab width into account.
746int wxStyledTextCtrl::GetColumn(int pos) {
747 return SendMsg(2129, pos, 0);
9ce192d4
RD
748}
749
4370573a
RD
750// Show or hide the horizontal scroll bar.
751void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show) {
752 SendMsg(2130, show, 0);
753}
9ce192d4 754
4370573a
RD
755// Is the horizontal scroll bar visible?
756bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
757 return SendMsg(2131, 0, 0) != 0;
9ce192d4
RD
758}
759
4370573a
RD
760// Show or hide indentation guides.
761void wxStyledTextCtrl::SetIndentationGuides(bool show) {
762 SendMsg(2132, show, 0);
763}
9ce192d4 764
4370573a
RD
765// Are the indentation guides visible?
766bool wxStyledTextCtrl::GetIndentationGuides() {
767 return SendMsg(2133, 0, 0) != 0;
9ce192d4
RD
768}
769
4370573a
RD
770// Set the highlighted indentation guide column.
771// 0 = no highlighted guide.
772void wxStyledTextCtrl::SetHighlightGuide(int column) {
773 SendMsg(2134, column, 0);
774}
9ce192d4 775
4370573a
RD
776// Get the highlighted indentation guide column.
777int wxStyledTextCtrl::GetHighlightGuide() {
778 return SendMsg(2135, 0, 0);
9ce192d4
RD
779}
780
4370573a
RD
781// Get the position after the last visible characters on a line.
782int wxStyledTextCtrl::GetLineEndPosition(int line) {
783 return SendMsg(2136, line, 0);
784}
9ce192d4 785
4370573a
RD
786// Get the code page used to interpret the bytes of the document as characters.
787int wxStyledTextCtrl::GetCodePage() {
788 return SendMsg(2137, 0, 0);
9ce192d4
RD
789}
790
4370573a
RD
791// Get the foreground colour of the caret.
792wxColour wxStyledTextCtrl::GetCaretForeground() {
793 long c = SendMsg(2138, 0, 0);
794 return wxColourFromLong(c);
795}
9ce192d4 796
4370573a
RD
797// In read-only mode?
798bool wxStyledTextCtrl::GetReadOnly() {
799 return SendMsg(2140, 0, 0) != 0;
9ce192d4
RD
800}
801
4370573a
RD
802// Sets the position of the caret.
803void wxStyledTextCtrl::SetCurrentPos(int pos) {
804 SendMsg(2141, pos, 0);
805}
9ce192d4 806
4370573a
RD
807// Sets the position that starts the selection - this becomes the anchor.
808void wxStyledTextCtrl::SetSelectionStart(int pos) {
809 SendMsg(2142, pos, 0);
9ce192d4
RD
810}
811
4370573a
RD
812// Returns the position at the start of the selection.
813int wxStyledTextCtrl::GetSelectionStart() {
814 return SendMsg(2143, 0, 0);
815}
9ce192d4 816
4370573a
RD
817// Sets the position that ends the selection - this becomes the currentPosition.
818void wxStyledTextCtrl::SetSelectionEnd(int pos) {
819 SendMsg(2144, pos, 0);
9ce192d4
RD
820}
821
4370573a
RD
822// Returns the position at the end of the selection.
823int wxStyledTextCtrl::GetSelectionEnd() {
824 return SendMsg(2145, 0, 0);
825}
9ce192d4 826
4370573a
RD
827// Sets the print magnification added to the point size of each style for printing.
828void wxStyledTextCtrl::SetPrintMagnification(int magnification) {
829 SendMsg(2146, magnification, 0);
9ce192d4
RD
830}
831
4370573a
RD
832// Returns the print magnification.
833int wxStyledTextCtrl::GetPrintMagnification() {
834 return SendMsg(2147, 0, 0);
835}
9ce192d4 836
4370573a
RD
837// Modify colours when printing for clearer printed text.
838void wxStyledTextCtrl::SetPrintColourMode(int mode) {
839 SendMsg(2148, mode, 0);
9ce192d4
RD
840}
841
4370573a
RD
842// Returns the print colour mode.
843int wxStyledTextCtrl::GetPrintColourMode() {
844 return SendMsg(2149, 0, 0);
845}
9ce192d4 846
4370573a
RD
847// Find some text in the document.
848int wxStyledTextCtrl::FindText(int minPos, int maxPos,
849 const wxString& text,
850 bool caseSensitive, bool wholeWord) {
851 TextToFind ft;
852 int flags = 0;
853
854 flags |= caseSensitive ? SCFIND_MATCHCASE : 0;
855 flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
856 ft.chrg.cpMin = minPos;
857 ft.chrg.cpMax = maxPos;
858 ft.lpstrText = (char*)text.c_str();
859
860 return SendMsg(2150, flags, (long)&ft);
861}
862
863// On Windows will draw the document into a display context such as a printer.
864 int wxStyledTextCtrl::FormatRange(bool doDraw,
865 int startPos,
866 int endPos,
867 wxDC* draw,
868 wxDC* target, // Why does it use two? Can they be the same?
869 wxRect renderRect,
870 wxRect pageRect) {
871 RangeToFormat fr;
872
873 fr.hdc = draw;
874 fr.hdcTarget = target;
875 fr.rc.top = renderRect.GetTop();
876 fr.rc.left = renderRect.GetLeft();
877 fr.rc.right = renderRect.GetRight();
878 fr.rc.bottom = renderRect.GetBottom();
879 fr.rcPage.top = pageRect.GetTop();
880 fr.rcPage.left = pageRect.GetLeft();
881 fr.rcPage.right = pageRect.GetRight();
882 fr.rcPage.bottom = pageRect.GetBottom();
883 fr.chrg.cpMin = startPos;
884 fr.chrg.cpMax = endPos;
885
886 return SendMsg(2151, doDraw, (long)&fr);
887}
888
889// Retrieve the line at the top of the display.
890int wxStyledTextCtrl::GetFirstVisibleLine() {
891 return SendMsg(2152, 0, 0);
9ce192d4
RD
892}
893
4370573a
RD
894// Retrieve the contents of a line.
895wxString wxStyledTextCtrl::GetLine(int line) {
896 wxString text;
897 int len = LineLength(line);
898 char* buf = text.GetWriteBuf(len+1);
9ce192d4 899
4370573a
RD
900 int pos = SendMsg(2153, line, (long)buf);
901 text.UngetWriteBuf();
9ce192d4 902
4370573a
RD
903 return text;
904}
905
906// Returns the number of lines in the document. There is always at least one.
907int wxStyledTextCtrl::GetLineCount() {
908 return SendMsg(2154, 0, 0);
909}
9ce192d4 910
4370573a
RD
911// Sets the size in pixels of the left margin.
912void wxStyledTextCtrl::SetMarginLeft(int width) {
913 SendMsg(2155, 0, width);
914}
9ce192d4 915
4370573a
RD
916// Returns the size in pixels of the left margin.
917int wxStyledTextCtrl::GetMarginLeft() {
918 return SendMsg(2156, 0, 0);
9ce192d4
RD
919}
920
4370573a
RD
921// Sets the size in pixels of the right margin.
922void wxStyledTextCtrl::SetMarginRight(int width) {
923 SendMsg(2157, 0, width);
924}
9ce192d4 925
4370573a
RD
926// Returns the size in pixels of the right margin.
927int wxStyledTextCtrl::GetMarginRight() {
928 return SendMsg(2158, 0, 0);
9ce192d4
RD
929}
930
4370573a
RD
931// Is the document different from when it was last saved?
932bool wxStyledTextCtrl::GetModify() {
933 return SendMsg(2159, 0, 0) != 0;
934}
9ce192d4 935
4370573a
RD
936// Select a range of text.
937void wxStyledTextCtrl::SetSelection(int start, int end) {
938 SendMsg(2160, start, end);
9ce192d4
RD
939}
940
4370573a
RD
941// Retrieve the selected text.
942wxString wxStyledTextCtrl::GetSelectedText() {
943 wxString text;
944 int start;
945 int end;
9ce192d4 946
4370573a
RD
947 GetSelection(&start, &end);
948 int len = end - start;
949 char* buff = text.GetWriteBuf(len+1);
9ce192d4 950
4370573a
RD
951 SendMsg(2161, 0, (long)buff);
952 text.UngetWriteBuf();
953 return text;
954}
9ce192d4 955
4370573a
RD
956// Retrieve a range of text.
957wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) {
958 wxString text;
959 int len = endPos - startPos;
960 char* buff = text.GetWriteBuf(len+1);
961 TextRange tr;
962 tr.lpstrText = buff;
963 tr.chrg.cpMin = startPos;
964 tr.chrg.cpMax = endPos;
9ce192d4 965
4370573a
RD
966 SendMsg(2162, 0, (long)&tr);
967 text.UngetWriteBuf();
968 return text;
9ce192d4
RD
969}
970
4370573a
RD
971// Draw the selection in normal style or with selection highlighted.
972void wxStyledTextCtrl::HideSelection(bool normal) {
973 SendMsg(2163, normal, 0);
974}
9ce192d4 975
4370573a
RD
976// Retrieve the line containing a position.
977int wxStyledTextCtrl::LineFromPosition(int pos) {
978 return SendMsg(2166, pos, 0);
9ce192d4
RD
979}
980
4370573a
RD
981// Retrieve the position at the start of a line.
982int wxStyledTextCtrl::PositionFromLine(int line) {
983 return SendMsg(2167, line, 0);
984}
9ce192d4 985
4370573a
RD
986// Scroll horizontally and vertically.
987void wxStyledTextCtrl::LineScroll(int columns, int lines) {
988 SendMsg(2168, columns, lines);
9ce192d4
RD
989}
990
4370573a
RD
991// Ensure the caret is visible.
992void wxStyledTextCtrl::EnsureCaretVisible() {
993 SendMsg(2169, 0, 0);
994}
9ce192d4 995
4370573a
RD
996// Replace the selected text with the argument text.
997void wxStyledTextCtrl::ReplaceSelection(const wxString& text) {
998 SendMsg(2170, 0, (long)text.c_str());
9ce192d4
RD
999}
1000
4370573a
RD
1001// Set to read only or read write.
1002void wxStyledTextCtrl::SetReadOnly(bool readOnly) {
1003 SendMsg(2171, readOnly, 0);
1004}
9ce192d4 1005
4370573a
RD
1006// Will a paste succeed?
1007bool wxStyledTextCtrl::CanPaste() {
1008 return SendMsg(2173, 0, 0) != 0;
9ce192d4
RD
1009}
1010
4370573a
RD
1011// Are there any undoable actions in the undo history.
1012bool wxStyledTextCtrl::CanUndo() {
1013 return SendMsg(2174, 0, 0) != 0;
1014}
9ce192d4 1015
4370573a
RD
1016// Delete the undo history.
1017void wxStyledTextCtrl::EmptyUndoBuffer() {
1018 SendMsg(2175, 0, 0);
9ce192d4
RD
1019}
1020
4370573a
RD
1021// Undo one action in the undo history.
1022void wxStyledTextCtrl::Undo() {
1023 SendMsg(2176, 0, 0);
1024}
9ce192d4 1025
4370573a
RD
1026// Cut the selection to the clipboard.
1027void wxStyledTextCtrl::Cut() {
1028 SendMsg(2177, 0, 0);
f6bcfd97
BP
1029}
1030
4370573a
RD
1031// Copy the selection to the clipboard.
1032void wxStyledTextCtrl::Copy() {
1033 SendMsg(2178, 0, 0);
1034}
f6bcfd97 1035
4370573a
RD
1036// Paste the contents of the clipboard into the document replacing the selection.
1037void wxStyledTextCtrl::Paste() {
1038 SendMsg(2179, 0, 0);
f6bcfd97
BP
1039}
1040
4370573a
RD
1041// Clear the selection.
1042void wxStyledTextCtrl::Clear() {
1043 SendMsg(2180, 0, 0);
1044}
f6bcfd97 1045
4370573a
RD
1046// Replace the contents of the document with the argument text.
1047void wxStyledTextCtrl::SetText(const wxString& text) {
1048 SendMsg(2181, 0, (long)text.c_str());
f6bcfd97
BP
1049}
1050
4370573a
RD
1051// Retrieve all the text in the document.
1052wxString wxStyledTextCtrl::GetText() {
1053 wxString text;
1054 int len = GetTextLength();
1055 char* buff = text.GetWriteBuf(len+1);
f6bcfd97 1056
4370573a
RD
1057 SendMsg(2182, len, (long)buff);
1058 buff[len] = 0;
1059 text.UngetWriteBuf();
1060 return text;
1061}
9ce192d4 1062
4370573a
RD
1063// Retrieve the number of characters in the document.
1064int wxStyledTextCtrl::GetTextLength() {
1065 return SendMsg(2183, 0, 0);
9ce192d4
RD
1066}
1067
4370573a
RD
1068// Set to overtype (true) or insert mode
1069void wxStyledTextCtrl::SetOvertype(bool overtype) {
1070 SendMsg(2186, overtype, 0);
1071}
9ce192d4 1072
4370573a
RD
1073// Returns true if overtype mode is active otherwise false is returned.
1074bool wxStyledTextCtrl::GetOvertype() {
1075 return SendMsg(2187, 0, 0) != 0;
9ce192d4
RD
1076}
1077
4370573a
RD
1078// Show a call tip containing a definition near position pos.
1079void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) {
1080 SendMsg(2200, pos, (long)definition.c_str());
1081}
9ce192d4 1082
4370573a
RD
1083// Remove the call tip from the screen.
1084void wxStyledTextCtrl::CallTipCancel() {
1085 SendMsg(2201, 0, 0);
9ce192d4
RD
1086}
1087
4370573a
RD
1088// Is there an active call tip?
1089bool wxStyledTextCtrl::CallTipActive() {
1090 return SendMsg(2202, 0, 0) != 0;
1091}
9ce192d4 1092
4370573a 1093// Retrieve the position where the caret was before displaying the call tip.
9ce192d4 1094int wxStyledTextCtrl::CallTipPosAtStart() {
4370573a 1095 return SendMsg(2203, 0, 0);
9ce192d4
RD
1096}
1097
4370573a 1098// Highlight a segment of the definition.
9ce192d4 1099void wxStyledTextCtrl::CallTipSetHighlight(int start, int end) {
4370573a 1100 SendMsg(2204, start, end);
9ce192d4
RD
1101}
1102
4370573a
RD
1103// Set the background colour for the call tip.
1104void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back) {
1105 SendMsg(2205, wxColourAsLong(back), 0);
1106}
9ce192d4 1107
4370573a
RD
1108// Find the display line of a document line taking hidden lines into account.
1109int wxStyledTextCtrl::VisibleFromDocLine(int line) {
1110 return SendMsg(2220, line, 0);
9ce192d4
RD
1111}
1112
4370573a
RD
1113// Find the document line of a display line taking hidden lines into account.
1114int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay) {
1115 return SendMsg(2221, lineDisplay, 0);
1116}
9ce192d4 1117
4370573a
RD
1118// Set the fold level of a line.
1119// This encodes an integer level along with flags indicating whether the
1120// line is a header and whether it is effectively white space.
1121void wxStyledTextCtrl::SetFoldLevel(int line, int level) {
1122 SendMsg(2222, line, level);
1123}
9ce192d4 1124
4370573a
RD
1125// Retrieve the fold level of a line.
1126int wxStyledTextCtrl::GetFoldLevel(int line) {
1127 return SendMsg(2223, line, 0);
1128}
d134f170 1129
4370573a
RD
1130// Find the last child line of a header line.
1131int wxStyledTextCtrl::GetLastChild(int line, int level) {
1132 return SendMsg(2224, line, level);
9ce192d4
RD
1133}
1134
4370573a
RD
1135// Find the parent line of a child line.
1136int wxStyledTextCtrl::GetFoldParent(int line) {
1137 return SendMsg(2225, line, 0);
1138}
9ce192d4 1139
4370573a
RD
1140// Make a range of lines visible.
1141void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd) {
1142 SendMsg(2226, lineStart, lineEnd);
9ce192d4
RD
1143}
1144
4370573a
RD
1145// Make a range of lines invisible.
1146void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd) {
1147 SendMsg(2227, lineStart, lineEnd);
1148}
9ce192d4 1149
4370573a
RD
1150// Is a line visible?
1151bool wxStyledTextCtrl::GetLineVisible(int line) {
1152 return SendMsg(2228, line, 0) != 0;
9ce192d4
RD
1153}
1154
4370573a
RD
1155// Show the children of a header line.
1156void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded) {
1157 SendMsg(2229, line, expanded);
1158}
9ce192d4 1159
4370573a
RD
1160// Is a header line expanded?
1161bool wxStyledTextCtrl::GetFoldExpanded(int line) {
1162 return SendMsg(2230, line, 0) != 0;
9ce192d4
RD
1163}
1164
4370573a
RD
1165// Switch a header line between expanded and contracted.
1166void wxStyledTextCtrl::ToggleFold(int line) {
1167 SendMsg(2231, line, 0);
1168}
9ce192d4 1169
4370573a
RD
1170// Ensure a particular line is visible by expanding any header line hiding it.
1171void wxStyledTextCtrl::EnsureVisible(int line) {
1172 SendMsg(2232, line, 0);
1173}
9ce192d4 1174
4370573a
RD
1175// Set some debugging options for folding
1176void wxStyledTextCtrl::SetFoldFlags(int flags) {
1177 SendMsg(2233, flags, 0);
9ce192d4
RD
1178}
1179
4370573a
RD
1180// How many characters are on a line, not including end of line characters.
1181int wxStyledTextCtrl::LineLength(int line) {
1182 return SendMsg(2350, line, 0);
1183}
9ce192d4 1184
4370573a
RD
1185// Highlight the characters at two positions.
1186void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2) {
1187 SendMsg(2351, pos1, pos2);
1188}
9ce192d4 1189
4370573a
RD
1190// Highlight the character at a position indicating there is no matching brace.
1191void wxStyledTextCtrl::BraceBadLight(int pos) {
1192 SendMsg(2352, pos, 0);
9ce192d4
RD
1193}
1194
4370573a
RD
1195// Find the position of a matching brace or INVALID_POSITION if no match.
1196int wxStyledTextCtrl::BraceMatch(int pos) {
1197 return SendMsg(2353, pos, 0);
1198}
9ce192d4 1199
4370573a
RD
1200// Are the end of line characters visible.
1201bool wxStyledTextCtrl::GetViewEOL() {
1202 return SendMsg(2355, 0, 0) != 0;
9ce192d4
RD
1203}
1204
4370573a
RD
1205// Make the end of line characters visible or invisible
1206void wxStyledTextCtrl::SetViewEOL(bool visible) {
1207 SendMsg(2356, visible, 0);
1208}
9ce192d4 1209
4370573a
RD
1210// Retrieve a pointer to the document object.
1211void* wxStyledTextCtrl::GetDocPointer() {
1212 return (void*)SendMsg(2357);
1213}
67003d1a 1214
4370573a
RD
1215// Change the document object used.
1216void wxStyledTextCtrl::SetDocPointer(void* docPointer) {
1217 SendMsg(2358, (long)docPointer);
67003d1a
RD
1218}
1219
4370573a
RD
1220// Set which document modification events are sent to the container.
1221void wxStyledTextCtrl::SetModEventMask(int mask) {
1222 SendMsg(2359, mask, 0);
1223}
67003d1a 1224
4370573a
RD
1225// Retrieve the column number which text should be kept within.
1226int wxStyledTextCtrl::GetEdgeColumn() {
1227 return SendMsg(2360, 0, 0);
67003d1a
RD
1228}
1229
4370573a
RD
1230// Set the column number of the edge.
1231// If text goes past the edge then it is highlighted.
1232void wxStyledTextCtrl::SetEdgeColumn(int column) {
1233 SendMsg(2361, column, 0);
1234}
67003d1a 1235
4370573a
RD
1236// Retrieve the edge highlight mode.
1237int wxStyledTextCtrl::GetEdgeMode() {
1238 return SendMsg(2362, 0, 0);
67003d1a
RD
1239}
1240
4370573a
RD
1241// The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
1242// goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
1243void wxStyledTextCtrl::SetEdgeMode(int mode) {
1244 SendMsg(2363, mode, 0);
1245}
67003d1a 1246
4370573a
RD
1247// Retrieve the colour used in edge indication.
1248wxColour wxStyledTextCtrl::GetEdgeColour() {
1249 long c = SendMsg(2364, 0, 0);
1250 return wxColourFromLong(c);
67003d1a
RD
1251}
1252
4370573a
RD
1253// Change the colour used in edge indication.
1254void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour) {
1255 SendMsg(2365, wxColourAsLong(edgeColour), 0);
1256}
67003d1a 1257
4370573a
RD
1258// Sets the current caret position to be the search anchor.
1259void wxStyledTextCtrl::SearchAnchor() {
1260 SendMsg(2366, 0, 0);
67003d1a
RD
1261}
1262
4370573a
RD
1263// Find some text starting at the search anchor.
1264int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) {
1265 return SendMsg(2367, flags, (long)text.c_str());
1266}
67003d1a 1267
4370573a
RD
1268// Find some text starting at the search anchor and moving backwards.
1269int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) {
1270 return SendMsg(2368, flags, (long)text.c_str());
67003d1a
RD
1271}
1272
4370573a
RD
1273// Set the way the line the caret is on is kept visible.
1274void wxStyledTextCtrl::SetCaretPolicy(int caretPolicy, int caretSlop) {
1275 SendMsg(2369, caretPolicy, caretSlop);
1276}
67003d1a 1277
4370573a
RD
1278// Retrieves the number of lines completely visible.
1279int wxStyledTextCtrl::LinesOnScreen() {
1280 return SendMsg(2370, 0, 0);
67003d1a
RD
1281}
1282
4370573a
RD
1283// Set whether a pop up menu is displayed automatically when the user presses
1284// the wrong mouse button.
1285void wxStyledTextCtrl::UsePopUp(bool allowPopUp) {
1286 SendMsg(2371, allowPopUp, 0);
1287}
67003d1a 1288
4370573a
RD
1289// Is the selection a rectangular. The alternative is the more common stream selection.
1290bool wxStyledTextCtrl::SelectionIsRectangle() {
1291 return SendMsg(2372, 0, 0) != 0;
67003d1a
RD
1292}
1293
4370573a
RD
1294// Set the zoom level. This number of points is added to the size of all fonts.
1295// It may be positive to magnify or negative to reduce.
1296void wxStyledTextCtrl::SetZoom(int zoom) {
1297 SendMsg(2373, zoom, 0);
1298}
67003d1a 1299
4370573a
RD
1300// Retrieve the zoom level.
1301int wxStyledTextCtrl::GetZoom() {
1302 return SendMsg(2374, 0, 0);
67003d1a
RD
1303}
1304
4370573a
RD
1305// Create a new document object.
1306// Starts with reference count of 1 and not selected into editor.
1307void* wxStyledTextCtrl::CreateDocument() {
1308 return (void*)SendMsg(2375);
1309}
67003d1a 1310
4370573a
RD
1311// Extend life of document.
1312void wxStyledTextCtrl::AddRefDocument(void* docPointer) {
1313 SendMsg(2376, (long)docPointer);
67003d1a
RD
1314}
1315
4370573a
RD
1316// Release a reference to the document, deleting document if it fades to black.
1317void wxStyledTextCtrl::ReleaseDocument(void* docPointer) {
1318 SendMsg(2377, (long)docPointer);
1319}
67003d1a 1320
4370573a
RD
1321// Get which document modification events are sent to the container.
1322int wxStyledTextCtrl::GetModEventMask() {
1323 return SendMsg(2378, 0, 0);
67003d1a
RD
1324}
1325
4370573a
RD
1326// Start notifying the container of all key presses and commands.
1327void wxStyledTextCtrl::StartRecord() {
1328 SendMsg(3001, 0, 0);
1329}
67003d1a 1330
4370573a
RD
1331// Stop notifying the container of all key presses and commands.
1332void wxStyledTextCtrl::StopRecord() {
1333 SendMsg(3002, 0, 0);
67003d1a
RD
1334}
1335
4370573a
RD
1336// Set the lexing language of the document.
1337void wxStyledTextCtrl::SetLexer(int lexer) {
1338 SendMsg(4001, lexer, 0);
1339}
67003d1a 1340
4370573a
RD
1341// Retrieve the lexing language of the document.
1342int wxStyledTextCtrl::GetLexer() {
1343 return SendMsg(4002, 0, 0);
67003d1a
RD
1344}
1345
4370573a
RD
1346// Colourise a segment of the document using the current lexing language.
1347void wxStyledTextCtrl::Colourise(int start, int end) {
1348 SendMsg(4003, start, end);
1349}
67003d1a 1350
4370573a
RD
1351// Set up a value that may be used by a lexer for some optional feature.
1352void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) {
1353 SendMsg(4004, (long)key.c_str(), (long)value.c_str());
f6bcfd97
BP
1354}
1355
4370573a
RD
1356// Set up the key words used by the lexer.
1357void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) {
1358 SendMsg(4005, keywordSet, (long)keyWords.c_str());
1359}
f6bcfd97 1360
4370573a 1361// END of generated section
f6bcfd97 1362//----------------------------------------------------------------------
f6bcfd97
BP
1363
1364
4370573a
RD
1365// Returns the line number of the line with the caret.
1366int wxStyledTextCtrl::GetCurrentLine() {
1367 int line = LineFromPosition(GetCurrentPos());
1368 return line;
f6bcfd97
BP
1369}
1370
1371
4370573a
RD
1372// Extract style settings from a spec-string which is composed of one or
1373// more of the following comma separated elements:
1374//
1375// bold turns on bold
1376// italic turns on italics
1377// fore:#RRGGBB sets the foreground colour
1378// back:#RRGGBB sets the background colour
1379// face:[facename] sets the font face name to use
1380// size:[num] sets the font size in points
1381// eol turns on eol filling
1382// underline turns on underlining
1383//
1384void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
1385
1386 wxStringTokenizer tkz(spec, ",");
1387 while (tkz.HasMoreTokens()) {
1388 wxString token = tkz.GetNextToken();
f6bcfd97 1389
4370573a
RD
1390 wxString option = token.BeforeFirst(':');
1391 wxString val = token.AfterFirst(':');
f6bcfd97 1392
4370573a
RD
1393 if (option == "bold")
1394 StyleSetBold(styleNum, true);
f6bcfd97 1395
4370573a
RD
1396 else if (option == "italic")
1397 StyleSetItalic(styleNum, true);
9ce192d4 1398
4370573a
RD
1399 else if (option == "underline")
1400 StyleSetUnderline(styleNum, true);
9ce192d4 1401
4370573a
RD
1402 else if (option == "eol")
1403 StyleSetEOLFilled(styleNum, true);
9ce192d4 1404
4370573a
RD
1405 else if (option == "size") {
1406 long points;
1407 if (val.ToLong(&points))
1408 StyleSetSize(styleNum, points);
1409 }
9ce192d4 1410
4370573a
RD
1411 else if (option == "face")
1412 StyleSetFaceName(styleNum, val);
9ce192d4 1413
4370573a
RD
1414 else if (option == "fore")
1415 StyleSetForeground(styleNum, wxColourFromSpec(val));
9ce192d4 1416
4370573a
RD
1417 else if (option == "back")
1418 StyleSetBackground(styleNum, wxColourFromSpec(val));
1419 }
9ce192d4
RD
1420}
1421
1422
4370573a
RD
1423// Set style size, face, bold, italic, and underline attributes from
1424// a wxFont's attributes.
1425void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
1426 int size = font.GetPointSize();
1427 wxString faceName = font.GetFaceName();
1428 bool bold = font.GetWeight() == wxBOLD;
1429 bool italic = font.GetStyle() != wxNORMAL;
1430 bool under = font.GetUnderlined();
9ce192d4 1431
4370573a
RD
1432 // TODO: add encoding/charset mapping
1433 StyleSetFontAttr(styleNum, size, faceName, bold, italic, under);
9ce192d4
RD
1434}
1435
4370573a
RD
1436// Set all font style attributes at once.
1437void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
1438 const wxString& faceName,
1439 bool bold, bool italic,
1440 bool underline) {
1441 StyleSetSize(styleNum, size);
1442 StyleSetFaceName(styleNum, faceName);
1443 StyleSetBold(styleNum, bold);
1444 StyleSetItalic(styleNum, italic);
1445 StyleSetUnderline(styleNum, underline);
9ce192d4 1446
4370573a 1447 // TODO: add encoding/charset mapping
9ce192d4
RD
1448}
1449
1450
4370573a
RD
1451// Perform one of the operations defined by the wxSTC_CMD_* constants.
1452void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
1453 SendMsg(cmd);
9ce192d4
RD
1454}
1455
1456
4370573a
RD
1457// Set the left and right margin in the edit area, measured in pixels.
1458void wxStyledTextCtrl::SetMargins(int left, int right) {
1459 SetMarginLeft(left);
1460 SetMarginRight(right);
9ce192d4
RD
1461}
1462
1463
4370573a
RD
1464// Retrieve the start and end positions of the current selection.
1465void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) {
1466 if (startPos != NULL)
1467 *startPos = SendMsg(SCI_GETSELECTIONSTART);
1468 if (endPos != NULL)
1469 *endPos = SendMsg(SCI_GETSELECTIONEND);
9ce192d4
RD
1470}
1471
1472
4370573a
RD
1473// Retrieve the point in the window where a position is displayed.
1474wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
1475 int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
1476 int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
1477 return wxPoint(x, y);
f6bcfd97
BP
1478}
1479
1480
f6bcfd97 1481
9ce192d4
RD
1482//----------------------------------------------------------------------
1483// Event handlers
1484
1485void wxStyledTextCtrl::OnPaint(wxPaintEvent& evt) {
1486 wxPaintDC dc(this);
1487 wxRegion region = GetUpdateRegion();
1488
1489 m_swx->DoPaint(&dc, region.GetBox());
1490}
1491
1492void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) {
1493 if (evt.GetOrientation() == wxHORIZONTAL)
1494 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
1495 else
1496 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
1497}
1498
1499void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) {
1500 wxSize sz = GetClientSize();
1501 m_swx->DoSize(sz.x, sz.y);
1502}
1503
1504void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
1505 wxPoint pt = evt.GetPosition();
1506 m_swx->DoButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
1507 evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
1508}
1509
1510void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
1511 wxPoint pt = evt.GetPosition();
1512 m_swx->DoButtonMove(Point(pt.x, pt.y));
1513}
1514
1515void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
1516 wxPoint pt = evt.GetPosition();
1517 m_swx->DoButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
1518 evt.ControlDown());
1519}
1520
1521
1522void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
1523 wxPoint pt = evt.GetPosition();
1524 m_swx->DoContextMenu(Point(pt.x, pt.y));
1525}
1526
1527void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
9ce192d4
RD
1528 long key = evt.KeyCode();
1529 if ((key > WXK_ESCAPE) &&
1530 (key != WXK_DELETE) && (key < 255) &&
1531 !evt.ControlDown() && !evt.AltDown()) {
1532
1533 m_swx->DoAddChar(key);
9ce192d4
RD
1534 }
1535 else {
f6bcfd97 1536 evt.Skip();
9ce192d4 1537 }
f6bcfd97
BP
1538}
1539
1540void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
1541 long key = evt.KeyCode();
1542 key = toupper(key);
1543 int processed = m_swx->DoKeyDown(key, evt.ShiftDown(),
1544 evt.ControlDown(), evt.AltDown());
9ce192d4
RD
1545 if (! processed)
1546 evt.Skip();
1547}
1548
1549void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
1550 m_swx->DoLoseFocus();
1551}
1552
1553void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
1554 m_swx->DoGainFocus();
1555}
1556
1557void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& evt) {
1558 m_swx->DoSysColourChange();
1559}
1560
1561void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& evt) {
1562 // do nothing to help avoid flashing
1563}
1564
1565
1566
1567void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
1568 m_swx->DoCommand(evt.GetId());
1569}
1570
1571
f6bcfd97
BP
1572void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) {
1573 m_swx->DoOnListBox();
1574}
1575
1576
9ce192d4
RD
1577//----------------------------------------------------------------------
1578// Turn notifications from Scintilla into events
1579
f6bcfd97 1580
9ce192d4
RD
1581void wxStyledTextCtrl::NotifyChange() {
1582 wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId());
1583 GetEventHandler()->ProcessEvent(evt);
1584}
1585
1586void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
1587 SCNotification& scn = *_scn;
1588 int eventType = 0;
1589 switch (scn.nmhdr.code) {
1590 case SCN_STYLENEEDED:
1591 eventType = wxEVT_STC_STYLENEEDED;
1592 break;
1593 case SCN_CHARADDED:
1594 eventType = wxEVT_STC_CHARADDED;
1595 break;
1596 case SCN_UPDATEUI:
1597 eventType = wxEVT_STC_UPDATEUI;
1598 break;
1599 case SCN_SAVEPOINTREACHED:
1600 eventType = wxEVT_STC_SAVEPOINTREACHED;
1601 break;
1602 case SCN_SAVEPOINTLEFT:
1603 eventType = wxEVT_STC_SAVEPOINTLEFT;
1604 break;
1605 case SCN_MODIFYATTEMPTRO:
1606 eventType = wxEVT_STC_ROMODIFYATTEMPT;
1607 break;
1608 case SCN_DOUBLECLICK:
1609 eventType = wxEVT_STC_DOUBLECLICK;
1610 break;
1611 case SCN_MODIFIED:
1612 eventType = wxEVT_STC_MODIFIED;
1613 break;
1614 case SCN_KEY:
1615 eventType = wxEVT_STC_KEY;
1616 break;
1617 case SCN_MACRORECORD:
1618 eventType = wxEVT_STC_MACRORECORD;
1619 break;
1620 case SCN_MARGINCLICK:
1621 eventType = wxEVT_STC_MARGINCLICK;
1622 break;
1623 case SCN_NEEDSHOWN:
1624 eventType = wxEVT_STC_NEEDSHOWN;
1625 break;
4370573a
RD
1626 case SCN_POSCHANGED:
1627 eventType = wxEVT_STC_POSCHANGED;
1628 break;
9ce192d4
RD
1629 }
1630 if (eventType) {
1631 wxStyledTextEvent evt(eventType, GetId());
1632 evt.SetPosition(scn.position);
1633 evt.SetKey(scn.ch);
1634 evt.SetModifiers(scn.modifiers);
1635 if (eventType == wxEVT_STC_MODIFIED) {
1636 evt.SetModificationType(scn.modificationType);
f6bcfd97
BP
1637 if (scn.text)
1638 evt.SetText(wxString(scn.text, scn.length));
9ce192d4
RD
1639 evt.SetLength(scn.length);
1640 evt.SetLinesAdded(scn.linesAdded);
1641 evt.SetLine(scn.line);
1642 evt.SetFoldLevelNow(scn.foldLevelNow);
1643 evt.SetFoldLevelPrev(scn.foldLevelPrev);
1644 }
1645 if (eventType == wxEVT_STC_MARGINCLICK)
1646 evt.SetMargin(scn.margin);
1647 if (eventType == wxEVT_STC_MACRORECORD) {
1648 evt.SetMessage(scn.message);
1649 evt.SetWParam(scn.wParam);
1650 evt.SetLParam(scn.lParam);
1651 }
1652
1653 GetEventHandler()->ProcessEvent(evt);
1654 }
1655}
1656
1657
1658
1659//----------------------------------------------------------------------
1660//----------------------------------------------------------------------
1661//----------------------------------------------------------------------
1662
1663wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
1664 : wxCommandEvent(commandType, id)
1665{
1666 m_position = 0;
1667 m_key = 0;
1668 m_modifiers = 0;
1669 m_modificationType = 0;
1670 m_length = 0;
1671 m_linesAdded = 0;
1672 m_line = 0;
1673 m_foldLevelNow = 0;
1674 m_foldLevelPrev = 0;
1675 m_margin = 0;
1676 m_message = 0;
1677 m_wParam = 0;
1678 m_lParam = 0;
1679
1680
1681}
1682
1683bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
1684bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; }
1685bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; }
1686
1687void wxStyledTextEvent::CopyObject(wxObject& obj) const {
1688 wxCommandEvent::CopyObject(obj);
1689
1690 wxStyledTextEvent* o = (wxStyledTextEvent*)&obj;
1691 o->m_position = m_position;
1692 o->m_key = m_key;
1693 o->m_modifiers = m_modifiers;
1694 o->m_modificationType = m_modificationType;
1695 o->m_text = m_text;
1696 o->m_length = m_length;
1697 o->m_linesAdded = m_linesAdded;
1698 o->m_line = m_line;
1699 o->m_foldLevelNow = m_foldLevelNow;
1700 o->m_foldLevelPrev = m_foldLevelPrev;
1701
1702 o->m_margin = m_margin;
1703
1704 o->m_message = m_message;
1705 o->m_wParam = m_wParam;
1706 o->m_lParam = m_lParam;
1707
1708
1709
1710}
1711
1712//----------------------------------------------------------------------
1713//----------------------------------------------------------------------
1714