1 ////////////////////////////////////////////////////////////////////////////
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
8 // namespace with all the classes and identifiers from Scintilla.
12 // Created: 13-Jan-2000
14 // Copyright: (c) 2000 by Total Control Software
15 // Licence: wxWindows license
16 /////////////////////////////////////////////////////////////////////////////
20 #include "wx/stc/stc.h"
21 #include "ScintillaWX.h"
23 #include <wx/tokenzr.h>
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)
29 int wxForceScintillaLexers(void)
31 extern LexerModule lmAda
;
32 extern LexerModule lmAVE
;
33 extern LexerModule lmConf
;
34 extern LexerModule lmCPP
;
35 extern LexerModule lmNncrontab
;
36 extern LexerModule lmEiffel
;
37 extern LexerModule lmHTML
;
38 extern LexerModule lmLISP
;
39 extern LexerModule lmLua
;
40 extern LexerModule lmBatch
; // In LexOthers.cxx
41 extern LexerModule lmPascal
;
42 extern LexerModule lmPerl
;
43 extern LexerModule lmPython
;
44 extern LexerModule lmRuby
;
45 extern LexerModule lmSQL
;
46 extern LexerModule lmVB
;
73 //----------------------------------------------------------------------
75 const wxChar
* wxSTCNameStr
= "stcwindow";
77 DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE
)
78 DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED
)
79 DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED
)
80 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED
)
81 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT
)
82 DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT
)
83 DEFINE_EVENT_TYPE( wxEVT_STC_KEY
)
84 DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK
)
85 DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI
)
86 DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED
)
87 DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD
)
88 DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK
)
89 DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN
)
90 DEFINE_EVENT_TYPE( wxEVT_STC_POSCHANGED
)
91 DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED
)
92 DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION
)
93 DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED
)
94 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART
)
95 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND
)
96 DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG
)
97 DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER
)
98 DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP
)
101 BEGIN_EVENT_TABLE(wxStyledTextCtrl
, wxControl
)
102 EVT_PAINT (wxStyledTextCtrl::OnPaint
)
103 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin
)
104 EVT_SIZE (wxStyledTextCtrl::OnSize
)
105 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown
)
107 // Let Scintilla see the double click as a second click
108 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown
)
110 EVT_MOTION (wxStyledTextCtrl::OnMouseMove
)
111 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp
)
112 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu
)
113 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel
)
114 EVT_CHAR (wxStyledTextCtrl::OnChar
)
115 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown
)
116 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus
)
117 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus
)
118 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged
)
119 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground
)
120 EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu
)
121 EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox
)
125 IMPLEMENT_CLASS(wxStyledTextCtrl
, wxControl
)
126 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent
, wxCommandEvent
)
128 //----------------------------------------------------------------------
129 // Constructor and Destructor
131 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow
*parent
,
136 const wxString
& name
) :
137 wxControl(parent
, id
, pos
, size
,
138 style
| wxVSCROLL
| wxHSCROLL
| wxWANTS_CHARS
| wxCLIP_CHILDREN
,
139 wxDefaultValidator
, name
)
141 m_swx
= new ScintillaWX(this);
143 m_lastKeyDownConsumed
= FALSE
;
147 wxStyledTextCtrl::~wxStyledTextCtrl() {
152 //----------------------------------------------------------------------
154 long wxStyledTextCtrl::SendMsg(int msg
, long wp
, long lp
) {
156 return m_swx
->WndProc(msg
, wp
, lp
);
164 #define MAKELONG(a, b) ((a) | ((b) << 16))
167 static long wxColourAsLong(const wxColour
& co
) {
168 return (((long)co
.Blue() << 16) |
169 ((long)co
.Green() << 8) |
173 static wxColour
wxColourFromLong(long c
) {
175 clr
.Set(c
& 0xff, (c
>> 8) & 0xff, (c
>> 16) & 0xff);
180 static wxColour
wxColourFromSpec(const wxString
& spec
) {
181 // spec should be #RRGGBB
183 int red
= strtol(spec
.Mid(1,2), &junk
, 16);
184 int green
= strtol(spec
.Mid(3,2), &junk
, 16);
185 int blue
= strtol(spec
.Mid(5,2), &junk
, 16);
186 return wxColour(red
, green
, blue
);
190 //----------------------------------------------------------------------
191 // BEGIN generated section. The following code is automatically generated
192 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
193 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
196 // Add text to the document
197 void wxStyledTextCtrl::AddText(const wxString
& text
) {
198 SendMsg(2001, text
.Len(), (long)text
.c_str());
201 // Add array of cells to document
202 void wxStyledTextCtrl::AddStyledText(const wxString
& text
) {
203 SendMsg(2002, text
.Len(), (long)text
.c_str());
206 // Insert string at a position
207 void wxStyledTextCtrl::InsertText(int pos
, const wxString
& text
) {
208 SendMsg(2003, pos
, (long)text
.c_str());
211 // Delete all text in the document
212 void wxStyledTextCtrl::ClearAll() {
216 // Set all style bytes to 0, remove all folding information
217 void wxStyledTextCtrl::ClearDocumentStyle() {
221 // The number of characters in the document
222 int wxStyledTextCtrl::GetLength() {
223 return SendMsg(2006, 0, 0);
226 // Returns the character byte at the position
227 int wxStyledTextCtrl::GetCharAt(int pos
) {
228 return SendMsg(2007, pos
, 0);
231 // Returns the position of the caret
232 int wxStyledTextCtrl::GetCurrentPos() {
233 return SendMsg(2008, 0, 0);
236 // Returns the position of the opposite end of the selection to the caret
237 int wxStyledTextCtrl::GetAnchor() {
238 return SendMsg(2009, 0, 0);
241 // Returns the style byte at the position
242 int wxStyledTextCtrl::GetStyleAt(int pos
) {
243 return SendMsg(2010, pos
, 0);
246 // Redoes the next action on the undo history
247 void wxStyledTextCtrl::Redo() {
251 // Choose between collecting actions into the undo
252 // history and discarding them.
253 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo
) {
254 SendMsg(2012, collectUndo
, 0);
257 // Select all the text in the document.
258 void wxStyledTextCtrl::SelectAll() {
262 // Remember the current position in the undo history as the position
263 // at which the document was saved.
264 void wxStyledTextCtrl::SetSavePoint() {
268 // Retrieve a buffer of cells.
269 wxString
wxStyledTextCtrl::GetStyledText(int startPos
, int endPos
) {
271 int len
= endPos
- startPos
;
274 tr
.lpstrText
= text
.GetWriteBuf(len
*2);
275 tr
.chrg
.cpMin
= startPos
;
276 tr
.chrg
.cpMax
= endPos
;
277 SendMsg(2015, 0, (long)&tr
);
278 text
.UngetWriteBuf(len
*2);
282 // Are there any redoable actions in the undo history.
283 bool wxStyledTextCtrl::CanRedo() {
284 return SendMsg(2016, 0, 0) != 0;
287 // Retrieve the line number at which a particular marker is located
288 int wxStyledTextCtrl::MarkerLineFromHandle(int handle
) {
289 return SendMsg(2017, handle
, 0);
293 void wxStyledTextCtrl::MarkerDeleteHandle(int handle
) {
294 SendMsg(2018, handle
, 0);
297 // Is undo history being collected?
298 bool wxStyledTextCtrl::GetUndoCollection() {
299 return SendMsg(2019, 0, 0) != 0;
302 // Are white space characters currently visible?
303 // Returns one of SCWS_* constants.
304 int wxStyledTextCtrl::GetViewWhiteSpace() {
305 return SendMsg(2020, 0, 0);
308 // Make white space characters invisible, always visible or visible outside indentation.
309 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS
) {
310 SendMsg(2021, viewWS
, 0);
313 // Find the position from a point within the window.
314 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt
) {
315 return SendMsg(2022, pt
.x
, pt
.y
);
318 // Find the position from a point within the window but return
319 // INVALID_POSITION if not close to text.
320 int wxStyledTextCtrl::PositionFromPointClose(int x
, int y
) {
321 return SendMsg(2023, x
, y
);
324 // Set caret to start of a line and ensure it is visible.
325 void wxStyledTextCtrl::GotoLine(int line
) {
326 SendMsg(2024, line
, 0);
329 // Set caret to a position and ensure it is visible.
330 void wxStyledTextCtrl::GotoPos(int pos
) {
331 SendMsg(2025, pos
, 0);
334 // Set the selection anchor to a position. The anchor is the opposite
335 // end of the selection from the caret.
336 void wxStyledTextCtrl::SetAnchor(int posAnchor
) {
337 SendMsg(2026, posAnchor
, 0);
340 // Retrieve the text of the line containing the caret.
341 // Returns the index of the caret on the line.
342 wxString
wxStyledTextCtrl::GetCurLine(int* linePos
) {
344 int len
= LineLength(GetCurrentLine());
346 if (linePos
) *linePos
= 0;
349 // Need an extra byte because SCI_GETCURLINE writes a null to the string
350 char* buf
= text
.GetWriteBuf(len
+1);
352 int pos
= SendMsg(2027, len
+1, (long)buf
);
353 text
.UngetWriteBuf(len
);
354 if (linePos
) *linePos
= pos
;
359 // Retrieve the position of the last correctly styled character.
360 int wxStyledTextCtrl::GetEndStyled() {
361 return SendMsg(2028, 0, 0);
364 // Convert all line endings in the document to one mode.
365 void wxStyledTextCtrl::ConvertEOLs(int eolMode
) {
366 SendMsg(2029, eolMode
, 0);
369 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
370 int wxStyledTextCtrl::GetEOLMode() {
371 return SendMsg(2030, 0, 0);
374 // Set the current end of line mode.
375 void wxStyledTextCtrl::SetEOLMode(int eolMode
) {
376 SendMsg(2031, eolMode
, 0);
379 // Set the current styling position to pos and the styling mask to mask.
380 // The styling mask can be used to protect some bits in each styling byte from
382 void wxStyledTextCtrl::StartStyling(int pos
, int mask
) {
383 SendMsg(2032, pos
, mask
);
386 // Change style from current styling position for length characters to a style
387 // and move the current styling position to after this newly styled segment.
388 void wxStyledTextCtrl::SetStyling(int length
, int style
) {
389 SendMsg(2033, length
, style
);
392 // Is drawing done first into a buffer or direct to the screen.
393 bool wxStyledTextCtrl::GetBufferedDraw() {
394 return SendMsg(2034, 0, 0) != 0;
397 // If drawing is buffered then each line of text is drawn into a bitmap buffer
398 // before drawing it to the screen to avoid flicker.
399 void wxStyledTextCtrl::SetBufferedDraw(bool buffered
) {
400 SendMsg(2035, buffered
, 0);
403 // Change the visible size of a tab to be a multiple of the width of a space
405 void wxStyledTextCtrl::SetTabWidth(int tabWidth
) {
406 SendMsg(2036, tabWidth
, 0);
409 // Retrieve the visible size of a tab.
410 int wxStyledTextCtrl::GetTabWidth() {
411 return SendMsg(2121, 0, 0);
414 // Set the code page used to interpret the bytes of the document as characters.
415 // The SC_CP_UTF8 value can be used to enter Unicode mode.
416 void wxStyledTextCtrl::SetCodePage(int codePage
) {
417 SendMsg(2037, codePage
, 0);
420 // Set the symbol used for a particular marker number,
421 // and optionally the for and background colours.
422 void wxStyledTextCtrl::MarkerDefine(int markerNumber
, int markerSymbol
,
423 const wxColour
& foreground
,
424 const wxColour
& background
) {
426 SendMsg(2040, markerNumber
, markerSymbol
);
428 MarkerSetForeground(markerNumber
, foreground
);
430 MarkerSetBackground(markerNumber
, background
);
433 // Set the foreground colour used for a particular marker number.
434 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber
, const wxColour
& fore
) {
435 SendMsg(2041, markerNumber
, wxColourAsLong(fore
));
438 // Set the background colour used for a particular marker number.
439 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber
, const wxColour
& back
) {
440 SendMsg(2042, markerNumber
, wxColourAsLong(back
));
443 // Add a marker to a line.
444 void wxStyledTextCtrl::MarkerAdd(int line
, int markerNumber
) {
445 SendMsg(2043, line
, markerNumber
);
448 // Delete a marker from a line
449 void wxStyledTextCtrl::MarkerDelete(int line
, int markerNumber
) {
450 SendMsg(2044, line
, markerNumber
);
453 // Delete all markers with a particular number from all lines
454 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber
) {
455 SendMsg(2045, markerNumber
, 0);
458 // Get a bit mask of all the markers set on a line.
459 int wxStyledTextCtrl::MarkerGet(int line
) {
460 return SendMsg(2046, line
, 0);
463 // Find the next line after lineStart that includes a marker in mask.
464 int wxStyledTextCtrl::MarkerNext(int lineStart
, int markerMask
) {
465 return SendMsg(2047, lineStart
, markerMask
);
468 // Find the previous line before lineStart that includes a marker in mask.
469 int wxStyledTextCtrl::MarkerPrevious(int lineStart
, int markerMask
) {
470 return SendMsg(2048, lineStart
, markerMask
);
473 // Set a margin to be either numeric or symbolic.
474 void wxStyledTextCtrl::SetMarginType(int margin
, int marginType
) {
475 SendMsg(2240, margin
, marginType
);
478 // Retrieve the type of a margin.
479 int wxStyledTextCtrl::GetMarginType(int margin
) {
480 return SendMsg(2241, margin
, 0);
483 // Set the width of a margin to a width expressed in pixels.
484 void wxStyledTextCtrl::SetMarginWidth(int margin
, int pixelWidth
) {
485 SendMsg(2242, margin
, pixelWidth
);
488 // Retrieve the width of a margin in pixels.
489 int wxStyledTextCtrl::GetMarginWidth(int margin
) {
490 return SendMsg(2243, margin
, 0);
493 // Set a mask that determines which markers are displayed in a margin.
494 void wxStyledTextCtrl::SetMarginMask(int margin
, int mask
) {
495 SendMsg(2244, margin
, mask
);
498 // Retrieve the marker mask of a margin.
499 int wxStyledTextCtrl::GetMarginMask(int margin
) {
500 return SendMsg(2245, margin
, 0);
503 // Make a margin sensitive or insensitive to mouse clicks.
504 void wxStyledTextCtrl::SetMarginSensitive(int margin
, bool sensitive
) {
505 SendMsg(2246, margin
, sensitive
);
508 // Retrieve the mouse click sensitivity of a margin.
509 bool wxStyledTextCtrl::GetMarginSensitive(int margin
) {
510 return SendMsg(2247, margin
, 0) != 0;
513 // Clear all the styles and make equivalent to the global default style.
514 void wxStyledTextCtrl::StyleClearAll() {
518 // Set the foreground colour of a style.
519 void wxStyledTextCtrl::StyleSetForeground(int style
, const wxColour
& fore
) {
520 SendMsg(2051, style
, wxColourAsLong(fore
));
523 // Set the background colour of a style.
524 void wxStyledTextCtrl::StyleSetBackground(int style
, const wxColour
& back
) {
525 SendMsg(2052, style
, wxColourAsLong(back
));
528 // Set a style to be bold or not.
529 void wxStyledTextCtrl::StyleSetBold(int style
, bool bold
) {
530 SendMsg(2053, style
, bold
);
533 // Set a style to be italic or not.
534 void wxStyledTextCtrl::StyleSetItalic(int style
, bool italic
) {
535 SendMsg(2054, style
, italic
);
538 // Set the size of characters of a style.
539 void wxStyledTextCtrl::StyleSetSize(int style
, int sizePoints
) {
540 SendMsg(2055, style
, sizePoints
);
543 // Set the font of a style.
544 void wxStyledTextCtrl::StyleSetFaceName(int style
, const wxString
& fontName
) {
545 SendMsg(2056, style
, (long)fontName
.c_str());
548 // Set a style to have its end of line filled or not.
549 void wxStyledTextCtrl::StyleSetEOLFilled(int style
, bool filled
) {
550 SendMsg(2057, style
, filled
);
553 // Reset the default style to its state at startup
554 void wxStyledTextCtrl::StyleResetDefault() {
558 // Set a style to be underlined or not.
559 void wxStyledTextCtrl::StyleSetUnderline(int style
, bool underline
) {
560 SendMsg(2059, style
, underline
);
563 // Set a style to be mixed case, or to force upper or lower case.
564 void wxStyledTextCtrl::StyleSetCase(int style
, int caseForce
) {
565 SendMsg(2060, style
, caseForce
);
568 // Set the foreground colour of the selection and whether to use this setting.
569 void wxStyledTextCtrl::SetSelForeground(bool useSetting
, const wxColour
& fore
) {
570 SendMsg(2067, useSetting
, wxColourAsLong(fore
));
573 // Set the background colour of the selection and whether to use this setting.
574 void wxStyledTextCtrl::SetSelBackground(bool useSetting
, const wxColour
& back
) {
575 SendMsg(2068, useSetting
, wxColourAsLong(back
));
578 // Set the foreground colour of the caret.
579 void wxStyledTextCtrl::SetCaretForeground(const wxColour
& fore
) {
580 SendMsg(2069, wxColourAsLong(fore
), 0);
583 // When key+modifier combination km is pressed perform msg.
584 void wxStyledTextCtrl::CmdKeyAssign(int key
, int modifiers
, int cmd
) {
585 SendMsg(2070, MAKELONG(key
, modifiers
), cmd
);
588 // When key+modifier combination km do nothing.
589 void wxStyledTextCtrl::CmdKeyClear(int key
, int modifiers
) {
590 SendMsg(2071, MAKELONG(key
, modifiers
));
593 // Drop all key mappings.
594 void wxStyledTextCtrl::CmdKeyClearAll() {
598 // Set the styles for a segment of the document.
599 void wxStyledTextCtrl::SetStyleBytes(int length
, char* styleBytes
) {
600 SendMsg(2073, length
, (long)styleBytes
);
603 // Set a style to be visible or not.
604 void wxStyledTextCtrl::StyleSetVisible(int style
, bool visible
) {
605 SendMsg(2074, style
, visible
);
608 // Get the time in milliseconds that the caret is on and off.
609 int wxStyledTextCtrl::GetCaretPeriod() {
610 return SendMsg(2075, 0, 0);
613 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
614 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds
) {
615 SendMsg(2076, periodMilliseconds
, 0);
618 // Set the set of characters making up words for when moving or selecting
620 void wxStyledTextCtrl::SetWordChars(const wxString
& characters
) {
621 SendMsg(2077, 0, (long)characters
.c_str());
624 // Start a sequence of actions that is undone and redone as a unit.
626 void wxStyledTextCtrl::BeginUndoAction() {
630 // End a sequence of actions that is undone and redone as a unit.
631 void wxStyledTextCtrl::EndUndoAction() {
635 // Set an indicator to plain, squiggle or TT.
636 void wxStyledTextCtrl::IndicatorSetStyle(int indic
, int style
) {
637 SendMsg(2080, indic
, style
);
640 // Retrieve the style of an indicator.
641 int wxStyledTextCtrl::IndicatorGetStyle(int indic
) {
642 return SendMsg(2081, indic
, 0);
645 // Set the foreground colour of an indicator.
646 void wxStyledTextCtrl::IndicatorSetForeground(int indic
, const wxColour
& fore
) {
647 SendMsg(2082, indic
, wxColourAsLong(fore
));
650 // Retrieve the foreground colour of an indicator.
651 wxColour
wxStyledTextCtrl::IndicatorGetForeground(int indic
) {
652 long c
= SendMsg(2083, indic
, 0);
653 return wxColourFromLong(c
);
656 // Divide each styling byte into lexical class bits (default:5) and indicator
657 // bits (default:3). If a lexer requires more than 32 lexical states, then this
658 // is used to expand the possible states.
659 void wxStyledTextCtrl::SetStyleBits(int bits
) {
660 SendMsg(2090, bits
, 0);
663 // Retrieve number of bits in style bytes used to hold the lexical state.
664 int wxStyledTextCtrl::GetStyleBits() {
665 return SendMsg(2091, 0, 0);
668 // Used to hold extra styling information for each line.
669 void wxStyledTextCtrl::SetLineState(int line
, int state
) {
670 SendMsg(2092, line
, state
);
673 // Retrieve the extra styling information for a line.
674 int wxStyledTextCtrl::GetLineState(int line
) {
675 return SendMsg(2093, line
, 0);
678 // Retrieve the last line number that has line state.
679 int wxStyledTextCtrl::GetMaxLineState() {
680 return SendMsg(2094, 0, 0);
683 // Is the background of the line containing the caret in a different colour?
684 bool wxStyledTextCtrl::GetCaretLineVisible() {
685 return SendMsg(2095, 0, 0) != 0;
688 // Display the background of the line containing the caret in a different colour.
689 void wxStyledTextCtrl::SetCaretLineVisible(bool show
) {
690 SendMsg(2096, show
, 0);
693 // Get the colour of the background of the line containing the caret.
694 wxColour
wxStyledTextCtrl::GetCaretLineBack() {
695 long c
= SendMsg(2097, 0, 0);
696 return wxColourFromLong(c
);
699 // Set the colour of the background of the line containing the caret.
700 void wxStyledTextCtrl::SetCaretLineBack(const wxColour
& back
) {
701 SendMsg(2098, wxColourAsLong(back
), 0);
704 // Display a auto-completion list.
705 // The lenEntered parameter indicates how many characters before
706 // the caret should be used to provide context.
707 void wxStyledTextCtrl::AutoCompShow(int lenEntered
, const wxString
& itemList
) {
708 SendMsg(2100, lenEntered
, (long)itemList
.c_str());
711 // Remove the auto-completion list from the screen.
712 void wxStyledTextCtrl::AutoCompCancel() {
716 // Is there an auto-completion list visible?
717 bool wxStyledTextCtrl::AutoCompActive() {
718 return SendMsg(2102, 0, 0) != 0;
721 // Retrieve the position of the caret when the auto-completion list was
723 int wxStyledTextCtrl::AutoCompPosStart() {
724 return SendMsg(2103, 0, 0);
727 // User has selected an item so remove the list and insert the selection.
728 void wxStyledTextCtrl::AutoCompComplete() {
732 // Define a set of character that when typed cancel the auto-completion list.
733 void wxStyledTextCtrl::AutoCompStops(const wxString
& characterSet
) {
734 SendMsg(2105, 0, (long)characterSet
.c_str());
737 // Change the separator character in the string setting up an auto-completion
738 // list. Default is space but can be changed if items contain space.
739 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter
) {
740 SendMsg(2106, separatorCharacter
, 0);
743 // Retrieve the auto-completion list separator character.
744 int wxStyledTextCtrl::AutoCompGetSeparator() {
745 return SendMsg(2107, 0, 0);
748 // Select the item in the auto-completion list that starts with a string.
749 void wxStyledTextCtrl::AutoCompSelect(const wxString
& text
) {
750 SendMsg(2108, 0, (long)text
.c_str());
753 // Should the auto-completion list be cancelled if the user backspaces to a
754 // position before where the box was created.
755 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel
) {
756 SendMsg(2110, cancel
, 0);
759 // Retrieve whether auto-completion cancelled by backspacing before start.
760 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
761 return SendMsg(2111, 0, 0) != 0;
764 // Define a set of character that when typed fills up the selected word.
765 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString
& characterSet
) {
766 SendMsg(2112, 0, (long)characterSet
.c_str());
769 // Should a single item auto-completion list automatically choose the item.
770 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle
) {
771 SendMsg(2113, chooseSingle
, 0);
774 // Retrieve whether a single item auto-completion list automatically choose the item.
775 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
776 return SendMsg(2114, 0, 0) != 0;
779 // Set whether case is significant when performing auto-completion searches.
780 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase
) {
781 SendMsg(2115, ignoreCase
, 0);
784 // Retrieve state of ignore case flag.
785 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
786 return SendMsg(2116, 0, 0) != 0;
789 // Display a list of strings and send notification when user chooses one.
790 void wxStyledTextCtrl::UserListShow(int listType
, const wxString
& itemList
) {
791 SendMsg(2117, listType
, (long)itemList
.c_str());
794 // Set whether or not autocompletion is hidden automatically when nothing matches
795 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide
) {
796 SendMsg(2118, autoHide
, 0);
799 // Retrieve whether or not autocompletion is hidden automatically when nothing matches
800 bool wxStyledTextCtrl::AutoCompGetAutoHide() {
801 return SendMsg(2119, 0, 0) != 0;
804 // Set the number of spaces used for one level of indentation.
805 void wxStyledTextCtrl::SetIndent(int indentSize
) {
806 SendMsg(2122, indentSize
, 0);
809 // Retrieve indentation size.
810 int wxStyledTextCtrl::GetIndent() {
811 return SendMsg(2123, 0, 0);
814 // Indentation will only use space characters if useTabs is false, otherwise
815 // it will use a combination of tabs and spaces.
816 void wxStyledTextCtrl::SetUseTabs(bool useTabs
) {
817 SendMsg(2124, useTabs
, 0);
820 // Retrieve whether tabs will be used in indentation.
821 bool wxStyledTextCtrl::GetUseTabs() {
822 return SendMsg(2125, 0, 0) != 0;
825 // Change the indentation of a line to a number of columns.
826 void wxStyledTextCtrl::SetLineIndentation(int line
, int indentSize
) {
827 SendMsg(2126, line
, indentSize
);
830 // Retrieve the number of columns that a line is indented.
831 int wxStyledTextCtrl::GetLineIndentation(int line
) {
832 return SendMsg(2127, line
, 0);
835 // Retrieve the position before the first non indentation character on a line.
836 int wxStyledTextCtrl::GetLineIndentPosition(int line
) {
837 return SendMsg(2128, line
, 0);
840 // Retrieve the column number of a position, taking tab width into account.
841 int wxStyledTextCtrl::GetColumn(int pos
) {
842 return SendMsg(2129, pos
, 0);
845 // Show or hide the horizontal scroll bar.
846 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show
) {
847 SendMsg(2130, show
, 0);
850 // Is the horizontal scroll bar visible?
851 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
852 return SendMsg(2131, 0, 0) != 0;
855 // Show or hide indentation guides.
856 void wxStyledTextCtrl::SetIndentationGuides(bool show
) {
857 SendMsg(2132, show
, 0);
860 // Are the indentation guides visible?
861 bool wxStyledTextCtrl::GetIndentationGuides() {
862 return SendMsg(2133, 0, 0) != 0;
865 // Set the highlighted indentation guide column.
866 // 0 = no highlighted guide.
867 void wxStyledTextCtrl::SetHighlightGuide(int column
) {
868 SendMsg(2134, column
, 0);
871 // Get the highlighted indentation guide column.
872 int wxStyledTextCtrl::GetHighlightGuide() {
873 return SendMsg(2135, 0, 0);
876 // Get the position after the last visible characters on a line.
877 int wxStyledTextCtrl::GetLineEndPosition(int line
) {
878 return SendMsg(2136, line
, 0);
881 // Get the code page used to interpret the bytes of the document as characters.
882 int wxStyledTextCtrl::GetCodePage() {
883 return SendMsg(2137, 0, 0);
886 // Get the foreground colour of the caret.
887 wxColour
wxStyledTextCtrl::GetCaretForeground() {
888 long c
= SendMsg(2138, 0, 0);
889 return wxColourFromLong(c
);
892 // In read-only mode?
893 bool wxStyledTextCtrl::GetReadOnly() {
894 return SendMsg(2140, 0, 0) != 0;
897 // Sets the position of the caret.
898 void wxStyledTextCtrl::SetCurrentPos(int pos
) {
899 SendMsg(2141, pos
, 0);
902 // Sets the position that starts the selection - this becomes the anchor.
903 void wxStyledTextCtrl::SetSelectionStart(int pos
) {
904 SendMsg(2142, pos
, 0);
907 // Returns the position at the start of the selection.
908 int wxStyledTextCtrl::GetSelectionStart() {
909 return SendMsg(2143, 0, 0);
912 // Sets the position that ends the selection - this becomes the currentPosition.
913 void wxStyledTextCtrl::SetSelectionEnd(int pos
) {
914 SendMsg(2144, pos
, 0);
917 // Returns the position at the end of the selection.
918 int wxStyledTextCtrl::GetSelectionEnd() {
919 return SendMsg(2145, 0, 0);
922 // Sets the print magnification added to the point size of each style for printing.
923 void wxStyledTextCtrl::SetPrintMagnification(int magnification
) {
924 SendMsg(2146, magnification
, 0);
927 // Returns the print magnification.
928 int wxStyledTextCtrl::GetPrintMagnification() {
929 return SendMsg(2147, 0, 0);
932 // Modify colours when printing for clearer printed text.
933 void wxStyledTextCtrl::SetPrintColourMode(int mode
) {
934 SendMsg(2148, mode
, 0);
937 // Returns the print colour mode.
938 int wxStyledTextCtrl::GetPrintColourMode() {
939 return SendMsg(2149, 0, 0);
942 // Find some text in the document.
943 int wxStyledTextCtrl::FindText(int minPos
, int maxPos
,
944 const wxString
& text
,
945 bool caseSensitive
, bool wholeWord
) {
949 flags
|= caseSensitive
? SCFIND_MATCHCASE
: 0;
950 flags
|= wholeWord
? SCFIND_WHOLEWORD
: 0;
951 ft
.chrg
.cpMin
= minPos
;
952 ft
.chrg
.cpMax
= maxPos
;
953 ft
.lpstrText
= (char*)text
.c_str();
955 return SendMsg(2150, flags
, (long)&ft
);
958 // On Windows will draw the document into a display context such as a printer.
959 int wxStyledTextCtrl::FormatRange(bool doDraw
,
963 wxDC
* target
, // Why does it use two? Can they be the same?
969 fr
.hdcTarget
= target
;
970 fr
.rc
.top
= renderRect
.GetTop();
971 fr
.rc
.left
= renderRect
.GetLeft();
972 fr
.rc
.right
= renderRect
.GetRight();
973 fr
.rc
.bottom
= renderRect
.GetBottom();
974 fr
.rcPage
.top
= pageRect
.GetTop();
975 fr
.rcPage
.left
= pageRect
.GetLeft();
976 fr
.rcPage
.right
= pageRect
.GetRight();
977 fr
.rcPage
.bottom
= pageRect
.GetBottom();
978 fr
.chrg
.cpMin
= startPos
;
979 fr
.chrg
.cpMax
= endPos
;
981 return SendMsg(2151, doDraw
, (long)&fr
);
984 // Retrieve the line at the top of the display.
985 int wxStyledTextCtrl::GetFirstVisibleLine() {
986 return SendMsg(2152, 0, 0);
989 // Retrieve the contents of a line.
990 wxString
wxStyledTextCtrl::GetLine(int line
) {
992 int len
= LineLength(line
);
994 char* buf
= text
.GetWriteBuf(len
);
996 int pos
= SendMsg(2153, line
, (long)buf
);
997 text
.UngetWriteBuf(len
);
1002 // Returns the number of lines in the document. There is always at least one.
1003 int wxStyledTextCtrl::GetLineCount() {
1004 return SendMsg(2154, 0, 0);
1007 // Sets the size in pixels of the left margin.
1008 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth
) {
1009 SendMsg(2155, 0, pixelWidth
);
1012 // Returns the size in pixels of the left margin.
1013 int wxStyledTextCtrl::GetMarginLeft() {
1014 return SendMsg(2156, 0, 0);
1017 // Sets the size in pixels of the right margin.
1018 void wxStyledTextCtrl::SetMarginRight(int pixelWidth
) {
1019 SendMsg(2157, 0, pixelWidth
);
1022 // Returns the size in pixels of the right margin.
1023 int wxStyledTextCtrl::GetMarginRight() {
1024 return SendMsg(2158, 0, 0);
1027 // Is the document different from when it was last saved?
1028 bool wxStyledTextCtrl::GetModify() {
1029 return SendMsg(2159, 0, 0) != 0;
1032 // Select a range of text.
1033 void wxStyledTextCtrl::SetSelection(int start
, int end
) {
1034 SendMsg(2160, start
, end
);
1037 // Retrieve the selected text.
1038 wxString
wxStyledTextCtrl::GetSelectedText() {
1043 GetSelection(&start
, &end
);
1044 int len
= end
- start
;
1045 if (!len
) return "";
1046 char* buff
= text
.GetWriteBuf(len
);
1048 SendMsg(2161, 0, (long)buff
);
1049 text
.UngetWriteBuf(len
);
1053 // Retrieve a range of text.
1054 wxString
wxStyledTextCtrl::GetTextRange(int startPos
, int endPos
) {
1056 int len
= endPos
- startPos
;
1057 if (!len
) return "";
1058 char* buff
= text
.GetWriteBuf(len
);
1060 tr
.lpstrText
= buff
;
1061 tr
.chrg
.cpMin
= startPos
;
1062 tr
.chrg
.cpMax
= endPos
;
1064 SendMsg(2162, 0, (long)&tr
);
1065 text
.UngetWriteBuf(len
);
1069 // Draw the selection in normal style or with selection highlighted.
1070 void wxStyledTextCtrl::HideSelection(bool normal
) {
1071 SendMsg(2163, normal
, 0);
1074 // Retrieve the line containing a position.
1075 int wxStyledTextCtrl::LineFromPosition(int pos
) {
1076 return SendMsg(2166, pos
, 0);
1079 // Retrieve the position at the start of a line.
1080 int wxStyledTextCtrl::PositionFromLine(int line
) {
1081 return SendMsg(2167, line
, 0);
1084 // Scroll horizontally and vertically.
1085 void wxStyledTextCtrl::LineScroll(int columns
, int lines
) {
1086 SendMsg(2168, columns
, lines
);
1089 // Ensure the caret is visible.
1090 void wxStyledTextCtrl::EnsureCaretVisible() {
1091 SendMsg(2169, 0, 0);
1094 // Replace the selected text with the argument text.
1095 void wxStyledTextCtrl::ReplaceSelection(const wxString
& text
) {
1096 SendMsg(2170, 0, (long)text
.c_str());
1099 // Set to read only or read write.
1100 void wxStyledTextCtrl::SetReadOnly(bool readOnly
) {
1101 SendMsg(2171, readOnly
, 0);
1104 // Will a paste succeed?
1105 bool wxStyledTextCtrl::CanPaste() {
1106 return SendMsg(2173, 0, 0) != 0;
1109 // Are there any undoable actions in the undo history.
1110 bool wxStyledTextCtrl::CanUndo() {
1111 return SendMsg(2174, 0, 0) != 0;
1114 // Delete the undo history.
1115 void wxStyledTextCtrl::EmptyUndoBuffer() {
1116 SendMsg(2175, 0, 0);
1119 // Undo one action in the undo history.
1120 void wxStyledTextCtrl::Undo() {
1121 SendMsg(2176, 0, 0);
1124 // Cut the selection to the clipboard.
1125 void wxStyledTextCtrl::Cut() {
1126 SendMsg(2177, 0, 0);
1129 // Copy the selection to the clipboard.
1130 void wxStyledTextCtrl::Copy() {
1131 SendMsg(2178, 0, 0);
1134 // Paste the contents of the clipboard into the document replacing the selection.
1135 void wxStyledTextCtrl::Paste() {
1136 SendMsg(2179, 0, 0);
1139 // Clear the selection.
1140 void wxStyledTextCtrl::Clear() {
1141 SendMsg(2180, 0, 0);
1144 // Replace the contents of the document with the argument text.
1145 void wxStyledTextCtrl::SetText(const wxString
& text
) {
1146 SendMsg(2181, 0, (long)text
.c_str());
1149 // Retrieve all the text in the document.
1150 wxString
wxStyledTextCtrl::GetText() {
1152 int len
= GetTextLength();
1153 char* buff
= text
.GetWriteBuf(len
+1); // leave room for the null...
1155 SendMsg(2182, len
+1, (long)buff
);
1156 text
.UngetWriteBuf(len
);
1160 // Retrieve the number of characters in the document.
1161 int wxStyledTextCtrl::GetTextLength() {
1162 return SendMsg(2183, 0, 0);
1165 // Set to overtype (true) or insert mode
1166 void wxStyledTextCtrl::SetOvertype(bool overtype
) {
1167 SendMsg(2186, overtype
, 0);
1170 // Returns true if overtype mode is active otherwise false is returned.
1171 bool wxStyledTextCtrl::GetOvertype() {
1172 return SendMsg(2187, 0, 0) != 0;
1175 // Set the width of the insert mode caret
1176 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth
) {
1177 SendMsg(2188, pixelWidth
, 0);
1180 // Returns the width of the insert mode caret
1181 int wxStyledTextCtrl::GetCaretWidth() {
1182 return SendMsg(2189, 0, 0);
1185 // Sets the position that starts the target which is used for updating the
1186 // document without affecting the scroll position.
1187 void wxStyledTextCtrl::SetTargetStart(int pos
) {
1188 SendMsg(2190, pos
, 0);
1191 // Get the position that starts the target.
1192 int wxStyledTextCtrl::GetTargetStart() {
1193 return SendMsg(2191, 0, 0);
1196 // Sets the position that ends the target which is used for updating the
1197 // document without affecting the scroll position.
1198 void wxStyledTextCtrl::SetTargetEnd(int pos
) {
1199 SendMsg(2192, pos
, 0);
1202 // Get the position that ends the target.
1203 int wxStyledTextCtrl::GetTargetEnd() {
1204 return SendMsg(2193, 0, 0);
1207 // Replace the target text with the argument text.
1208 // Text is counted so it can contain nulls.
1209 // Returns the length of the replacement text.
1211 int wxStyledTextCtrl::ReplaceTarget(const wxString
& text
) {
1212 return SendMsg(2194, text
.Len(), (long)text
.c_str());
1216 // Replace the target text with the argument text after \d processing.
1217 // Text is counted so it can contain nulls.
1218 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1219 // matched in the last search operation which were surrounded by \( and \).
1220 // Returns the length of the replacement text including any change
1221 // caused by processing the \d patterns.
1223 int wxStyledTextCtrl::ReplaceTargetRE(const wxString
& text
) {
1224 return SendMsg(2195, text
.Len(), (long)text
.c_str());
1228 // Search for a counted string in the target and set the target to the found
1229 // range. Text is counted so it can contain nulls.
1230 // Returns length of range or -1 for failure in which case target is not moved.
1232 int wxStyledTextCtrl::SearchInTarget(const wxString
& text
) {
1233 return SendMsg(2197, text
.Len(), (long)text
.c_str());
1237 // Set the search flags used by SearchInTarget
1238 void wxStyledTextCtrl::SetSearchFlags(int flags
) {
1239 SendMsg(2198, flags
, 0);
1242 // Get the search flags used by SearchInTarget
1243 int wxStyledTextCtrl::GetSearchFlags() {
1244 return SendMsg(2199, 0, 0);
1247 // Show a call tip containing a definition near position pos.
1248 void wxStyledTextCtrl::CallTipShow(int pos
, const wxString
& definition
) {
1249 SendMsg(2200, pos
, (long)definition
.c_str());
1252 // Remove the call tip from the screen.
1253 void wxStyledTextCtrl::CallTipCancel() {
1254 SendMsg(2201, 0, 0);
1257 // Is there an active call tip?
1258 bool wxStyledTextCtrl::CallTipActive() {
1259 return SendMsg(2202, 0, 0) != 0;
1262 // Retrieve the position where the caret was before displaying the call tip.
1263 int wxStyledTextCtrl::CallTipPosAtStart() {
1264 return SendMsg(2203, 0, 0);
1267 // Highlight a segment of the definition.
1268 void wxStyledTextCtrl::CallTipSetHighlight(int start
, int end
) {
1269 SendMsg(2204, start
, end
);
1272 // Set the background colour for the call tip.
1273 void wxStyledTextCtrl::CallTipSetBackground(const wxColour
& back
) {
1274 SendMsg(2205, wxColourAsLong(back
), 0);
1277 // Find the display line of a document line taking hidden lines into account.
1278 int wxStyledTextCtrl::VisibleFromDocLine(int line
) {
1279 return SendMsg(2220, line
, 0);
1282 // Find the document line of a display line taking hidden lines into account.
1283 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay
) {
1284 return SendMsg(2221, lineDisplay
, 0);
1287 // Set the fold level of a line.
1288 // This encodes an integer level along with flags indicating whether the
1289 // line is a header and whether it is effectively white space.
1290 void wxStyledTextCtrl::SetFoldLevel(int line
, int level
) {
1291 SendMsg(2222, line
, level
);
1294 // Retrieve the fold level of a line.
1295 int wxStyledTextCtrl::GetFoldLevel(int line
) {
1296 return SendMsg(2223, line
, 0);
1299 // Find the last child line of a header line.
1300 int wxStyledTextCtrl::GetLastChild(int line
, int level
) {
1301 return SendMsg(2224, line
, level
);
1304 // Find the parent line of a child line.
1305 int wxStyledTextCtrl::GetFoldParent(int line
) {
1306 return SendMsg(2225, line
, 0);
1309 // Make a range of lines visible.
1310 void wxStyledTextCtrl::ShowLines(int lineStart
, int lineEnd
) {
1311 SendMsg(2226, lineStart
, lineEnd
);
1314 // Make a range of lines invisible.
1315 void wxStyledTextCtrl::HideLines(int lineStart
, int lineEnd
) {
1316 SendMsg(2227, lineStart
, lineEnd
);
1319 // Is a line visible?
1320 bool wxStyledTextCtrl::GetLineVisible(int line
) {
1321 return SendMsg(2228, line
, 0) != 0;
1324 // Show the children of a header line.
1325 void wxStyledTextCtrl::SetFoldExpanded(int line
, bool expanded
) {
1326 SendMsg(2229, line
, expanded
);
1329 // Is a header line expanded?
1330 bool wxStyledTextCtrl::GetFoldExpanded(int line
) {
1331 return SendMsg(2230, line
, 0) != 0;
1334 // Switch a header line between expanded and contracted.
1335 void wxStyledTextCtrl::ToggleFold(int line
) {
1336 SendMsg(2231, line
, 0);
1339 // Ensure a particular line is visible by expanding any header line hiding it.
1340 void wxStyledTextCtrl::EnsureVisible(int line
) {
1341 SendMsg(2232, line
, 0);
1344 // Set some debugging options for folding
1345 void wxStyledTextCtrl::SetFoldFlags(int flags
) {
1346 SendMsg(2233, flags
, 0);
1349 // Ensure a particular line is visible by expanding any header line hiding it.
1350 // Use the currently set visibility policy to determine which range to display.
1351 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line
) {
1352 SendMsg(2234, line
, 0);
1355 // Sets whether a tab pressed when caret is within indentation indents
1356 void wxStyledTextCtrl::SetTabIndents(bool tabIndents
) {
1357 SendMsg(2260, tabIndents
, 0);
1360 // Does a tab pressed when caret is within indentation indent?
1361 bool wxStyledTextCtrl::GetTabIndents() {
1362 return SendMsg(2261, 0, 0) != 0;
1365 // Sets whether a backspace pressed when caret is within indentation unindents
1366 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents
) {
1367 SendMsg(2262, bsUnIndents
, 0);
1370 // Does a backspace pressed when caret is within indentation unindent?
1371 bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1372 return SendMsg(2263, 0, 0) != 0;
1375 // Sets the time the mouse must sit still to generate a mouse dwell event
1376 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds
) {
1377 SendMsg(2264, periodMilliseconds
, 0);
1380 // Retrieve the time the mouse must sit still to generate a mouse dwell event
1381 int wxStyledTextCtrl::GetMouseDwellTime() {
1382 return SendMsg(2265, 0, 0);
1385 // Move the caret inside current view if it's not there already
1386 void wxStyledTextCtrl::MoveCaretInsideView() {
1387 SendMsg(2401, 0, 0);
1390 // How many characters are on a line, not including end of line characters.
1391 int wxStyledTextCtrl::LineLength(int line
) {
1392 return SendMsg(2350, line
, 0);
1395 // Highlight the characters at two positions.
1396 void wxStyledTextCtrl::BraceHighlight(int pos1
, int pos2
) {
1397 SendMsg(2351, pos1
, pos2
);
1400 // Highlight the character at a position indicating there is no matching brace.
1401 void wxStyledTextCtrl::BraceBadLight(int pos
) {
1402 SendMsg(2352, pos
, 0);
1405 // Find the position of a matching brace or INVALID_POSITION if no match.
1406 int wxStyledTextCtrl::BraceMatch(int pos
) {
1407 return SendMsg(2353, pos
, 0);
1410 // Are the end of line characters visible.
1411 bool wxStyledTextCtrl::GetViewEOL() {
1412 return SendMsg(2355, 0, 0) != 0;
1415 // Make the end of line characters visible or invisible
1416 void wxStyledTextCtrl::SetViewEOL(bool visible
) {
1417 SendMsg(2356, visible
, 0);
1420 // Retrieve a pointer to the document object.
1421 void* wxStyledTextCtrl::GetDocPointer() {
1422 return (void*)SendMsg(2357);
1425 // Change the document object used.
1426 void wxStyledTextCtrl::SetDocPointer(void* docPointer
) {
1427 SendMsg(2358, 0, (long)docPointer
);
1430 // Set which document modification events are sent to the container.
1431 void wxStyledTextCtrl::SetModEventMask(int mask
) {
1432 SendMsg(2359, mask
, 0);
1435 // Retrieve the column number which text should be kept within.
1436 int wxStyledTextCtrl::GetEdgeColumn() {
1437 return SendMsg(2360, 0, 0);
1440 // Set the column number of the edge.
1441 // If text goes past the edge then it is highlighted.
1442 void wxStyledTextCtrl::SetEdgeColumn(int column
) {
1443 SendMsg(2361, column
, 0);
1446 // Retrieve the edge highlight mode.
1447 int wxStyledTextCtrl::GetEdgeMode() {
1448 return SendMsg(2362, 0, 0);
1451 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
1452 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
1453 void wxStyledTextCtrl::SetEdgeMode(int mode
) {
1454 SendMsg(2363, mode
, 0);
1457 // Retrieve the colour used in edge indication.
1458 wxColour
wxStyledTextCtrl::GetEdgeColour() {
1459 long c
= SendMsg(2364, 0, 0);
1460 return wxColourFromLong(c
);
1463 // Change the colour used in edge indication.
1464 void wxStyledTextCtrl::SetEdgeColour(const wxColour
& edgeColour
) {
1465 SendMsg(2365, wxColourAsLong(edgeColour
), 0);
1468 // Sets the current caret position to be the search anchor.
1469 void wxStyledTextCtrl::SearchAnchor() {
1470 SendMsg(2366, 0, 0);
1473 // Find some text starting at the search anchor.
1474 // Does not ensure the selection is visible.
1475 int wxStyledTextCtrl::SearchNext(int flags
, const wxString
& text
) {
1476 return SendMsg(2367, flags
, (long)text
.c_str());
1479 // Find some text starting at the search anchor and moving backwards.
1480 // Does not ensure the selection is visible.
1481 int wxStyledTextCtrl::SearchPrev(int flags
, const wxString
& text
) {
1482 return SendMsg(2368, flags
, (long)text
.c_str());
1485 // Set the way the line the caret is on is kept visible.
1486 void wxStyledTextCtrl::SetCaretPolicy(int caretPolicy
, int caretSlop
) {
1487 SendMsg(2369, caretPolicy
, caretSlop
);
1490 // Retrieves the number of lines completely visible.
1491 int wxStyledTextCtrl::LinesOnScreen() {
1492 return SendMsg(2370, 0, 0);
1495 // Set whether a pop up menu is displayed automatically when the user presses
1496 // the wrong mouse button.
1497 void wxStyledTextCtrl::UsePopUp(bool allowPopUp
) {
1498 SendMsg(2371, allowPopUp
, 0);
1501 // Is the selection a rectangular. The alternative is the more common stream selection.
1502 bool wxStyledTextCtrl::SelectionIsRectangle() {
1503 return SendMsg(2372, 0, 0) != 0;
1506 // Set the zoom level. This number of points is added to the size of all fonts.
1507 // It may be positive to magnify or negative to reduce.
1508 void wxStyledTextCtrl::SetZoom(int zoom
) {
1509 SendMsg(2373, zoom
, 0);
1512 // Retrieve the zoom level.
1513 int wxStyledTextCtrl::GetZoom() {
1514 return SendMsg(2374, 0, 0);
1517 // Create a new document object.
1518 // Starts with reference count of 1 and not selected into editor.
1519 void* wxStyledTextCtrl::CreateDocument() {
1520 return (void*)SendMsg(2375);
1523 // Extend life of document.
1524 void wxStyledTextCtrl::AddRefDocument(void* docPointer
) {
1525 SendMsg(2376, (long)docPointer
);
1528 // Release a reference to the document, deleting document if it fades to black.
1529 void wxStyledTextCtrl::ReleaseDocument(void* docPointer
) {
1530 SendMsg(2377, (long)docPointer
);
1533 // Get which document modification events are sent to the container.
1534 int wxStyledTextCtrl::GetModEventMask() {
1535 return SendMsg(2378, 0, 0);
1538 // Change internal focus flag
1539 void wxStyledTextCtrl::SetSTCFocus(bool focus
) {
1540 SendMsg(2380, focus
, 0);
1543 // Get internal focus flag
1544 bool wxStyledTextCtrl::GetSTCFocus() {
1545 return SendMsg(2381, 0, 0) != 0;
1548 // Change error status - 0 = OK
1549 void wxStyledTextCtrl::SetStatus(int statusCode
) {
1550 SendMsg(2382, statusCode
, 0);
1554 int wxStyledTextCtrl::GetStatus() {
1555 return SendMsg(2383, 0, 0);
1558 // Set whether the mouse is captured when its button is pressed
1559 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures
) {
1560 SendMsg(2384, captures
, 0);
1563 // Get whether mouse gets captured
1564 bool wxStyledTextCtrl::GetMouseDownCaptures() {
1565 return SendMsg(2385, 0, 0) != 0;
1568 // Sets the cursor to one of the SC_CURSOR* values
1569 void wxStyledTextCtrl::SetCursor(int cursorType
) {
1570 SendMsg(2386, cursorType
, 0);
1574 int wxStyledTextCtrl::GetCursor() {
1575 return SendMsg(2387, 0, 0);
1578 // Move to the previous change in capitalistion
1579 void wxStyledTextCtrl::WordPartLeft() {
1580 SendMsg(2390, 0, 0);
1583 // Move to the previous change in capitalistion extending selection to new caret position.
1584 void wxStyledTextCtrl::WordPartLeftExtend() {
1585 SendMsg(2391, 0, 0);
1588 // Move to the change next in capitalistion
1589 void wxStyledTextCtrl::WordPartRight() {
1590 SendMsg(2392, 0, 0);
1593 // Move to the next change in capitalistion extending selection to new caret position.
1594 void wxStyledTextCtrl::WordPartRightExtend() {
1595 SendMsg(2393, 0, 0);
1598 // Set the way the display area is determined when a particular line is to be moved to.
1599 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy
, int visibleSlop
) {
1600 SendMsg(2394, visiblePolicy
, visibleSlop
);
1603 // Delete back from the current position to the start of the line
1604 void wxStyledTextCtrl::DelLineLeft() {
1605 SendMsg(2395, 0, 0);
1608 // Delete forwards from the current position to the end of the line
1609 void wxStyledTextCtrl::DelLineRight() {
1610 SendMsg(2396, 0, 0);
1613 // Start notifying the container of all key presses and commands.
1614 void wxStyledTextCtrl::StartRecord() {
1615 SendMsg(3001, 0, 0);
1618 // Stop notifying the container of all key presses and commands.
1619 void wxStyledTextCtrl::StopRecord() {
1620 SendMsg(3002, 0, 0);
1623 // Set the lexing language of the document.
1624 void wxStyledTextCtrl::SetLexer(int lexer
) {
1625 SendMsg(4001, lexer
, 0);
1628 // Retrieve the lexing language of the document.
1629 int wxStyledTextCtrl::GetLexer() {
1630 return SendMsg(4002, 0, 0);
1633 // Colourise a segment of the document using the current lexing language.
1634 void wxStyledTextCtrl::Colourise(int start
, int end
) {
1635 SendMsg(4003, start
, end
);
1638 // Set up a value that may be used by a lexer for some optional feature.
1639 void wxStyledTextCtrl::SetProperty(const wxString
& key
, const wxString
& value
) {
1640 SendMsg(4004, (long)key
.c_str(), (long)value
.c_str());
1643 // Set up the key words used by the lexer.
1644 void wxStyledTextCtrl::SetKeyWords(int keywordSet
, const wxString
& keyWords
) {
1645 SendMsg(4005, keywordSet
, (long)keyWords
.c_str());
1648 // Set the lexing language of the document based on string name.
1649 void wxStyledTextCtrl::SetLexerLanguage(const wxString
& language
) {
1650 SendMsg(4006, 0, (long)language
.c_str());
1653 // END of generated section
1654 //----------------------------------------------------------------------
1657 // Returns the line number of the line with the caret.
1658 int wxStyledTextCtrl::GetCurrentLine() {
1659 int line
= LineFromPosition(GetCurrentPos());
1664 // Extract style settings from a spec-string which is composed of one or
1665 // more of the following comma separated elements:
1667 // bold turns on bold
1668 // italic turns on italics
1669 // fore:#RRGGBB sets the foreground colour
1670 // back:#RRGGBB sets the background colour
1671 // face:[facename] sets the font face name to use
1672 // size:[num] sets the font size in points
1673 // eol turns on eol filling
1674 // underline turns on underlining
1676 void wxStyledTextCtrl::StyleSetSpec(int styleNum
, const wxString
& spec
) {
1678 wxStringTokenizer
tkz(spec
, ",");
1679 while (tkz
.HasMoreTokens()) {
1680 wxString token
= tkz
.GetNextToken();
1682 wxString option
= token
.BeforeFirst(':');
1683 wxString val
= token
.AfterFirst(':');
1685 if (option
== "bold")
1686 StyleSetBold(styleNum
, true);
1688 else if (option
== "italic")
1689 StyleSetItalic(styleNum
, true);
1691 else if (option
== "underline")
1692 StyleSetUnderline(styleNum
, true);
1694 else if (option
== "eol")
1695 StyleSetEOLFilled(styleNum
, true);
1697 else if (option
== "size") {
1699 if (val
.ToLong(&points
))
1700 StyleSetSize(styleNum
, points
);
1703 else if (option
== "face")
1704 StyleSetFaceName(styleNum
, val
);
1706 else if (option
== "fore")
1707 StyleSetForeground(styleNum
, wxColourFromSpec(val
));
1709 else if (option
== "back")
1710 StyleSetBackground(styleNum
, wxColourFromSpec(val
));
1715 // Set style size, face, bold, italic, and underline attributes from
1716 // a wxFont's attributes.
1717 void wxStyledTextCtrl::StyleSetFont(int styleNum
, wxFont
& font
) {
1718 int size
= font
.GetPointSize();
1719 wxString faceName
= font
.GetFaceName();
1720 bool bold
= font
.GetWeight() == wxBOLD
;
1721 bool italic
= font
.GetStyle() != wxNORMAL
;
1722 bool under
= font
.GetUnderlined();
1724 // TODO: add encoding/charset mapping
1725 StyleSetFontAttr(styleNum
, size
, faceName
, bold
, italic
, under
);
1728 // Set all font style attributes at once.
1729 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum
, int size
,
1730 const wxString
& faceName
,
1731 bool bold
, bool italic
,
1733 StyleSetSize(styleNum
, size
);
1734 StyleSetFaceName(styleNum
, faceName
);
1735 StyleSetBold(styleNum
, bold
);
1736 StyleSetItalic(styleNum
, italic
);
1737 StyleSetUnderline(styleNum
, underline
);
1739 // TODO: add encoding/charset mapping
1743 // Perform one of the operations defined by the wxSTC_CMD_* constants.
1744 void wxStyledTextCtrl::CmdKeyExecute(int cmd
) {
1749 // Set the left and right margin in the edit area, measured in pixels.
1750 void wxStyledTextCtrl::SetMargins(int left
, int right
) {
1751 SetMarginLeft(left
);
1752 SetMarginRight(right
);
1756 // Retrieve the start and end positions of the current selection.
1757 void wxStyledTextCtrl::GetSelection(int* startPos
, int* endPos
) {
1758 if (startPos
!= NULL
)
1759 *startPos
= SendMsg(SCI_GETSELECTIONSTART
);
1761 *endPos
= SendMsg(SCI_GETSELECTIONEND
);
1765 // Retrieve the point in the window where a position is displayed.
1766 wxPoint
wxStyledTextCtrl::PointFromPosition(int pos
) {
1767 int x
= SendMsg(SCI_POINTXFROMPOSITION
, 0, pos
);
1768 int y
= SendMsg(SCI_POINTYFROMPOSITION
, 0, pos
);
1769 return wxPoint(x
, y
);
1772 // Scroll enough to make the given line visible
1773 void wxStyledTextCtrl::ScrollToLine(int line
) {
1774 m_swx
->DoScrollToLine(line
);
1778 // Scroll enough to make the given column visible
1779 void wxStyledTextCtrl::ScrollToColumn(int column
) {
1780 m_swx
->DoScrollToColumn(column
);
1785 //----------------------------------------------------------------------
1788 void wxStyledTextCtrl::OnPaint(wxPaintEvent
& evt
) {
1790 wxRegion region
= GetUpdateRegion();
1792 m_swx
->DoPaint(&dc
, region
.GetBox());
1795 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent
& evt
) {
1796 if (evt
.GetOrientation() == wxHORIZONTAL
)
1797 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
1799 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
1802 void wxStyledTextCtrl::OnSize(wxSizeEvent
& evt
) {
1803 wxSize sz
= GetClientSize();
1804 m_swx
->DoSize(sz
.x
, sz
.y
);
1807 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent
& evt
) {
1808 wxPoint pt
= evt
.GetPosition();
1809 m_swx
->DoButtonDown(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
1810 evt
.ShiftDown(), evt
.ControlDown(), evt
.AltDown());
1813 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent
& evt
) {
1814 wxPoint pt
= evt
.GetPosition();
1815 m_swx
->DoButtonMove(Point(pt
.x
, pt
.y
));
1818 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent
& evt
) {
1819 wxPoint pt
= evt
.GetPosition();
1820 m_swx
->DoButtonUp(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
1825 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent
& evt
) {
1826 wxPoint pt
= evt
.GetPosition();
1827 ScreenToClient(&pt
.x
, &pt
.y
);
1828 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
1832 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent
& evt
) {
1833 m_swx
->DoMouseWheel(evt
.GetWheelRotation(),
1834 evt
.GetWheelDelta(),
1835 evt
.GetLinesPerAction(),
1840 void wxStyledTextCtrl::OnChar(wxKeyEvent
& evt
) {
1841 long key
= evt
.KeyCode();
1843 // printf("OnChar key:%d consumed:%d ctrl:%d alt:%d\n",
1844 // key, m_lastKeyDownConsumed, evt.ControlDown(), evt.AltDown());
1847 // \|@#¬[]{}?£$~ ã,õ,Ã,Õ, ñ, Ñ
1849 // On (some?) non-US keyboards the AltGr key is required to enter some
1850 // common characters. It comes to us as both Alt and Ctrl down so we need
1851 // to let the char through in that case, otherwise if only ctrl or only
1852 // alt let's skip it.
1853 bool ctrl
= evt
.ControlDown();
1854 bool alt
= evt
.AltDown();
1855 bool skip
= (ctrl
|| alt
&& ! (ctrl
&& alt
));
1857 if (key
<= 0xff && !iscntrl(key
) && !m_lastKeyDownConsumed
&& !skip
) {
1858 m_swx
->DoAddChar(key
);
1865 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent
& evt
) {
1866 long key
= evt
.KeyCode();
1867 bool shift
= evt
.ShiftDown(),
1868 ctrl
= evt
.ControlDown(),
1869 alt
= evt
.AltDown();
1871 int processed
= m_swx
->DoKeyDown(key
, shift
, ctrl
, alt
, &m_lastKeyDownConsumed
);
1873 // printf("key: %d shift: %d ctrl: %d alt: %d processed: %d consumed: %d\n",
1874 // key, shift, ctrl, alt, processed, m_lastKeyDownConsumed);
1876 if (!processed
&& !m_lastKeyDownConsumed
)
1881 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent
& evt
) {
1882 m_swx
->DoLoseFocus();
1886 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent
& evt
) {
1887 m_swx
->DoGainFocus();
1891 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent
& evt
) {
1892 m_swx
->DoSysColourChange();
1896 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent
& evt
) {
1897 // do nothing to help avoid flashing
1902 void wxStyledTextCtrl::OnMenu(wxCommandEvent
& evt
) {
1903 m_swx
->DoCommand(evt
.GetId());
1907 void wxStyledTextCtrl::OnListBox(wxCommandEvent
& evt
) {
1908 m_swx
->DoOnListBox();
1912 //----------------------------------------------------------------------
1913 // Turn notifications from Scintilla into events
1916 void wxStyledTextCtrl::NotifyChange() {
1917 wxStyledTextEvent
evt(wxEVT_STC_CHANGE
, GetId());
1918 evt
.SetEventObject(this);
1919 GetEventHandler()->ProcessEvent(evt
);
1922 void wxStyledTextCtrl::NotifyParent(SCNotification
* _scn
) {
1923 SCNotification
& scn
= *_scn
;
1924 wxStyledTextEvent
evt(0, GetId());
1926 evt
.SetEventObject(this);
1927 evt
.SetPosition(scn
.position
);
1929 evt
.SetModifiers(scn
.modifiers
);
1931 switch (scn
.nmhdr
.code
) {
1932 case SCN_STYLENEEDED
:
1933 evt
.SetEventType(wxEVT_STC_STYLENEEDED
);
1937 evt
.SetEventType(wxEVT_STC_CHARADDED
);
1940 case SCN_SAVEPOINTREACHED
:
1941 evt
.SetEventType(wxEVT_STC_SAVEPOINTREACHED
);
1944 case SCN_SAVEPOINTLEFT
:
1945 evt
.SetEventType(wxEVT_STC_SAVEPOINTLEFT
);
1948 case SCN_MODIFYATTEMPTRO
:
1949 evt
.SetEventType(wxEVT_STC_ROMODIFYATTEMPT
);
1953 evt
.SetEventType(wxEVT_STC_KEY
);
1956 case SCN_DOUBLECLICK
:
1957 evt
.SetEventType(wxEVT_STC_DOUBLECLICK
);
1961 evt
.SetEventType(wxEVT_STC_UPDATEUI
);
1965 evt
.SetEventType(wxEVT_STC_MODIFIED
);
1966 evt
.SetModificationType(scn
.modificationType
);
1968 evt
.SetText(wxString(scn
.text
, scn
.length
));
1969 evt
.SetLength(scn
.length
);
1970 evt
.SetLinesAdded(scn
.linesAdded
);
1971 evt
.SetLine(scn
.line
);
1972 evt
.SetFoldLevelNow(scn
.foldLevelNow
);
1973 evt
.SetFoldLevelPrev(scn
.foldLevelPrev
);
1976 case SCN_MACRORECORD
:
1977 evt
.SetEventType(wxEVT_STC_MACRORECORD
);
1978 evt
.SetMessage(scn
.message
);
1979 evt
.SetWParam(scn
.wParam
);
1980 evt
.SetLParam(scn
.lParam
);
1983 case SCN_MARGINCLICK
:
1984 evt
.SetEventType(wxEVT_STC_MARGINCLICK
);
1985 evt
.SetMargin(scn
.margin
);
1989 evt
.SetEventType(wxEVT_STC_NEEDSHOWN
);
1990 evt
.SetLength(scn
.length
);
1993 case SCN_POSCHANGED
:
1994 evt
.SetEventType(wxEVT_STC_POSCHANGED
);
1998 evt
.SetEventType(wxEVT_STC_PAINTED
);
2001 case SCN_USERLISTSELECTION
:
2002 evt
.SetEventType(wxEVT_STC_USERLISTSELECTION
);
2003 evt
.SetListType(scn
.listType
);
2004 evt
.SetText(scn
.text
);
2007 case SCN_URIDROPPED
:
2008 evt
.SetEventType(wxEVT_STC_URIDROPPED
);
2009 evt
.SetText(scn
.text
);
2012 case SCN_DWELLSTART
:
2013 evt
.SetEventType(wxEVT_STC_DWELLSTART
);
2019 evt
.SetEventType(wxEVT_STC_DWELLEND
);
2028 GetEventHandler()->ProcessEvent(evt
);
2032 //----------------------------------------------------------------------
2033 //----------------------------------------------------------------------
2034 //----------------------------------------------------------------------
2036 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType
, int id
)
2037 : wxCommandEvent(commandType
, id
)
2042 m_modificationType
= 0;
2047 m_foldLevelPrev
= 0;
2055 m_dragAllowMove
= FALSE
;
2056 m_dragResult
= wxDragNone
;
2059 bool wxStyledTextEvent::GetShift() const { return (m_modifiers
& SCI_SHIFT
) != 0; }
2060 bool wxStyledTextEvent::GetControl() const { return (m_modifiers
& SCI_CTRL
) != 0; }
2061 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers
& SCI_ALT
) != 0; }
2063 void wxStyledTextEvent::CopyObject(wxObject
& obj
) const {
2064 wxCommandEvent::CopyObject(obj
);
2066 wxStyledTextEvent
* o
= (wxStyledTextEvent
*)&obj
;
2067 o
->m_position
= m_position
;
2069 o
->m_modifiers
= m_modifiers
;
2070 o
->m_modificationType
= m_modificationType
;
2072 o
->m_length
= m_length
;
2073 o
->m_linesAdded
= m_linesAdded
;
2075 o
->m_foldLevelNow
= m_foldLevelNow
;
2076 o
->m_foldLevelPrev
= m_foldLevelPrev
;
2078 o
->m_margin
= m_margin
;
2080 o
->m_message
= m_message
;
2081 o
->m_wParam
= m_wParam
;
2082 o
->m_lParam
= m_lParam
;
2084 o
->m_listType
= m_listType
;
2088 o
->m_dragText
= m_dragText
;
2089 o
->m_dragAllowMove
=m_dragAllowMove
;
2090 o
->m_dragResult
= m_dragResult
;
2093 //----------------------------------------------------------------------
2094 //----------------------------------------------------------------------