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_SCROLL (wxStyledTextCtrl::OnScroll
)
105 EVT_SIZE (wxStyledTextCtrl::OnSize
)
106 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown
)
108 // Let Scintilla see the double click as a second click
109 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown
)
111 EVT_MOTION (wxStyledTextCtrl::OnMouseMove
)
112 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp
)
114 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp
)
116 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu
)
118 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel
)
119 EVT_CHAR (wxStyledTextCtrl::OnChar
)
120 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown
)
121 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus
)
122 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus
)
123 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged
)
124 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground
)
125 EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu
)
126 EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox
)
130 IMPLEMENT_CLASS(wxStyledTextCtrl
, wxControl
)
131 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent
, wxCommandEvent
)
133 //----------------------------------------------------------------------
134 // Constructor and Destructor
136 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow
*parent
,
141 const wxString
& name
) :
142 wxControl(parent
, id
, pos
, size
,
143 style
| wxVSCROLL
| wxHSCROLL
| wxWANTS_CHARS
| wxCLIP_CHILDREN
,
144 wxDefaultValidator
, name
)
146 wxForceScintillaLexers();
147 m_swx
= new ScintillaWX(this);
149 m_lastKeyDownConsumed
= FALSE
;
155 wxStyledTextCtrl::~wxStyledTextCtrl() {
160 //----------------------------------------------------------------------
162 long wxStyledTextCtrl::SendMsg(int msg
, long wp
, long lp
) {
164 return m_swx
->WndProc(msg
, wp
, lp
);
172 #define MAKELONG(a, b) ((a) | ((b) << 16))
175 static long wxColourAsLong(const wxColour
& co
) {
176 return (((long)co
.Blue() << 16) |
177 ((long)co
.Green() << 8) |
181 static wxColour
wxColourFromLong(long c
) {
183 clr
.Set(c
& 0xff, (c
>> 8) & 0xff, (c
>> 16) & 0xff);
188 static wxColour
wxColourFromSpec(const wxString
& spec
) {
189 // spec should be #RRGGBB
191 int red
= strtol(spec
.Mid(1,2), &junk
, 16);
192 int green
= strtol(spec
.Mid(3,2), &junk
, 16);
193 int blue
= strtol(spec
.Mid(5,2), &junk
, 16);
194 return wxColour(red
, green
, blue
);
198 //----------------------------------------------------------------------
199 // BEGIN generated section. The following code is automatically generated
200 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
201 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
204 // Add text to the document
205 void wxStyledTextCtrl::AddText(const wxString
& text
) {
206 SendMsg(2001, text
.Len(), (long)text
.c_str());
209 // Add array of cells to document
210 void wxStyledTextCtrl::AddStyledText(const wxString
& text
) {
211 SendMsg(2002, text
.Len(), (long)text
.c_str());
214 // Insert string at a position
215 void wxStyledTextCtrl::InsertText(int pos
, const wxString
& text
) {
216 SendMsg(2003, pos
, (long)text
.c_str());
219 // Delete all text in the document
220 void wxStyledTextCtrl::ClearAll() {
224 // Set all style bytes to 0, remove all folding information
225 void wxStyledTextCtrl::ClearDocumentStyle() {
229 // The number of characters in the document
230 int wxStyledTextCtrl::GetLength() {
231 return SendMsg(2006, 0, 0);
234 // Returns the character byte at the position
235 int wxStyledTextCtrl::GetCharAt(int pos
) {
236 return SendMsg(2007, pos
, 0);
239 // Returns the position of the caret
240 int wxStyledTextCtrl::GetCurrentPos() {
241 return SendMsg(2008, 0, 0);
244 // Returns the position of the opposite end of the selection to the caret
245 int wxStyledTextCtrl::GetAnchor() {
246 return SendMsg(2009, 0, 0);
249 // Returns the style byte at the position
250 int wxStyledTextCtrl::GetStyleAt(int pos
) {
251 return SendMsg(2010, pos
, 0);
254 // Redoes the next action on the undo history
255 void wxStyledTextCtrl::Redo() {
259 // Choose between collecting actions into the undo
260 // history and discarding them.
261 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo
) {
262 SendMsg(2012, collectUndo
, 0);
265 // Select all the text in the document.
266 void wxStyledTextCtrl::SelectAll() {
270 // Remember the current position in the undo history as the position
271 // at which the document was saved.
272 void wxStyledTextCtrl::SetSavePoint() {
276 // Retrieve a buffer of cells.
277 wxString
wxStyledTextCtrl::GetStyledText(int startPos
, int endPos
) {
279 int len
= endPos
- startPos
;
282 tr
.lpstrText
= text
.GetWriteBuf(len
*2);
283 tr
.chrg
.cpMin
= startPos
;
284 tr
.chrg
.cpMax
= endPos
;
285 SendMsg(2015, 0, (long)&tr
);
286 text
.UngetWriteBuf(len
*2);
290 // Are there any redoable actions in the undo history.
291 bool wxStyledTextCtrl::CanRedo() {
292 return SendMsg(2016, 0, 0) != 0;
295 // Retrieve the line number at which a particular marker is located
296 int wxStyledTextCtrl::MarkerLineFromHandle(int handle
) {
297 return SendMsg(2017, handle
, 0);
301 void wxStyledTextCtrl::MarkerDeleteHandle(int handle
) {
302 SendMsg(2018, handle
, 0);
305 // Is undo history being collected?
306 bool wxStyledTextCtrl::GetUndoCollection() {
307 return SendMsg(2019, 0, 0) != 0;
310 // Are white space characters currently visible?
311 // Returns one of SCWS_* constants.
312 int wxStyledTextCtrl::GetViewWhiteSpace() {
313 return SendMsg(2020, 0, 0);
316 // Make white space characters invisible, always visible or visible outside indentation.
317 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS
) {
318 SendMsg(2021, viewWS
, 0);
321 // Find the position from a point within the window.
322 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt
) {
323 return SendMsg(2022, pt
.x
, pt
.y
);
326 // Find the position from a point within the window but return
327 // INVALID_POSITION if not close to text.
328 int wxStyledTextCtrl::PositionFromPointClose(int x
, int y
) {
329 return SendMsg(2023, x
, y
);
332 // Set caret to start of a line and ensure it is visible.
333 void wxStyledTextCtrl::GotoLine(int line
) {
334 SendMsg(2024, line
, 0);
337 // Set caret to a position and ensure it is visible.
338 void wxStyledTextCtrl::GotoPos(int pos
) {
339 SendMsg(2025, pos
, 0);
342 // Set the selection anchor to a position. The anchor is the opposite
343 // end of the selection from the caret.
344 void wxStyledTextCtrl::SetAnchor(int posAnchor
) {
345 SendMsg(2026, posAnchor
, 0);
348 // Retrieve the text of the line containing the caret.
349 // Returns the index of the caret on the line.
350 wxString
wxStyledTextCtrl::GetCurLine(int* linePos
) {
352 int len
= LineLength(GetCurrentLine());
354 if (linePos
) *linePos
= 0;
357 // Need an extra byte because SCI_GETCURLINE writes a null to the string
358 char* buf
= text
.GetWriteBuf(len
+1);
360 int pos
= SendMsg(2027, len
+1, (long)buf
);
361 text
.UngetWriteBuf(len
);
362 if (linePos
) *linePos
= pos
;
367 // Retrieve the position of the last correctly styled character.
368 int wxStyledTextCtrl::GetEndStyled() {
369 return SendMsg(2028, 0, 0);
372 // Convert all line endings in the document to one mode.
373 void wxStyledTextCtrl::ConvertEOLs(int eolMode
) {
374 SendMsg(2029, eolMode
, 0);
377 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
378 int wxStyledTextCtrl::GetEOLMode() {
379 return SendMsg(2030, 0, 0);
382 // Set the current end of line mode.
383 void wxStyledTextCtrl::SetEOLMode(int eolMode
) {
384 SendMsg(2031, eolMode
, 0);
387 // Set the current styling position to pos and the styling mask to mask.
388 // The styling mask can be used to protect some bits in each styling byte from
390 void wxStyledTextCtrl::StartStyling(int pos
, int mask
) {
391 SendMsg(2032, pos
, mask
);
394 // Change style from current styling position for length characters to a style
395 // and move the current styling position to after this newly styled segment.
396 void wxStyledTextCtrl::SetStyling(int length
, int style
) {
397 SendMsg(2033, length
, style
);
400 // Is drawing done first into a buffer or direct to the screen.
401 bool wxStyledTextCtrl::GetBufferedDraw() {
402 return SendMsg(2034, 0, 0) != 0;
405 // If drawing is buffered then each line of text is drawn into a bitmap buffer
406 // before drawing it to the screen to avoid flicker.
407 void wxStyledTextCtrl::SetBufferedDraw(bool buffered
) {
408 SendMsg(2035, buffered
, 0);
411 // Change the visible size of a tab to be a multiple of the width of a space
413 void wxStyledTextCtrl::SetTabWidth(int tabWidth
) {
414 SendMsg(2036, tabWidth
, 0);
417 // Retrieve the visible size of a tab.
418 int wxStyledTextCtrl::GetTabWidth() {
419 return SendMsg(2121, 0, 0);
422 // Set the code page used to interpret the bytes of the document as characters.
423 // The SC_CP_UTF8 value can be used to enter Unicode mode.
424 void wxStyledTextCtrl::SetCodePage(int codePage
) {
425 SendMsg(2037, codePage
, 0);
428 // Set the symbol used for a particular marker number,
429 // and optionally the for and background colours.
430 void wxStyledTextCtrl::MarkerDefine(int markerNumber
, int markerSymbol
,
431 const wxColour
& foreground
,
432 const wxColour
& background
) {
434 SendMsg(2040, markerNumber
, markerSymbol
);
436 MarkerSetForeground(markerNumber
, foreground
);
438 MarkerSetBackground(markerNumber
, background
);
441 // Set the foreground colour used for a particular marker number.
442 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber
, const wxColour
& fore
) {
443 SendMsg(2041, markerNumber
, wxColourAsLong(fore
));
446 // Set the background colour used for a particular marker number.
447 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber
, const wxColour
& back
) {
448 SendMsg(2042, markerNumber
, wxColourAsLong(back
));
451 // Add a marker to a line.
452 void wxStyledTextCtrl::MarkerAdd(int line
, int markerNumber
) {
453 SendMsg(2043, line
, markerNumber
);
456 // Delete a marker from a line
457 void wxStyledTextCtrl::MarkerDelete(int line
, int markerNumber
) {
458 SendMsg(2044, line
, markerNumber
);
461 // Delete all markers with a particular number from all lines
462 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber
) {
463 SendMsg(2045, markerNumber
, 0);
466 // Get a bit mask of all the markers set on a line.
467 int wxStyledTextCtrl::MarkerGet(int line
) {
468 return SendMsg(2046, line
, 0);
471 // Find the next line after lineStart that includes a marker in mask.
472 int wxStyledTextCtrl::MarkerNext(int lineStart
, int markerMask
) {
473 return SendMsg(2047, lineStart
, markerMask
);
476 // Find the previous line before lineStart that includes a marker in mask.
477 int wxStyledTextCtrl::MarkerPrevious(int lineStart
, int markerMask
) {
478 return SendMsg(2048, lineStart
, markerMask
);
481 // Set a margin to be either numeric or symbolic.
482 void wxStyledTextCtrl::SetMarginType(int margin
, int marginType
) {
483 SendMsg(2240, margin
, marginType
);
486 // Retrieve the type of a margin.
487 int wxStyledTextCtrl::GetMarginType(int margin
) {
488 return SendMsg(2241, margin
, 0);
491 // Set the width of a margin to a width expressed in pixels.
492 void wxStyledTextCtrl::SetMarginWidth(int margin
, int pixelWidth
) {
493 SendMsg(2242, margin
, pixelWidth
);
496 // Retrieve the width of a margin in pixels.
497 int wxStyledTextCtrl::GetMarginWidth(int margin
) {
498 return SendMsg(2243, margin
, 0);
501 // Set a mask that determines which markers are displayed in a margin.
502 void wxStyledTextCtrl::SetMarginMask(int margin
, int mask
) {
503 SendMsg(2244, margin
, mask
);
506 // Retrieve the marker mask of a margin.
507 int wxStyledTextCtrl::GetMarginMask(int margin
) {
508 return SendMsg(2245, margin
, 0);
511 // Make a margin sensitive or insensitive to mouse clicks.
512 void wxStyledTextCtrl::SetMarginSensitive(int margin
, bool sensitive
) {
513 SendMsg(2246, margin
, sensitive
);
516 // Retrieve the mouse click sensitivity of a margin.
517 bool wxStyledTextCtrl::GetMarginSensitive(int margin
) {
518 return SendMsg(2247, margin
, 0) != 0;
521 // Clear all the styles and make equivalent to the global default style.
522 void wxStyledTextCtrl::StyleClearAll() {
526 // Set the foreground colour of a style.
527 void wxStyledTextCtrl::StyleSetForeground(int style
, const wxColour
& fore
) {
528 SendMsg(2051, style
, wxColourAsLong(fore
));
531 // Set the background colour of a style.
532 void wxStyledTextCtrl::StyleSetBackground(int style
, const wxColour
& back
) {
533 SendMsg(2052, style
, wxColourAsLong(back
));
536 // Set a style to be bold or not.
537 void wxStyledTextCtrl::StyleSetBold(int style
, bool bold
) {
538 SendMsg(2053, style
, bold
);
541 // Set a style to be italic or not.
542 void wxStyledTextCtrl::StyleSetItalic(int style
, bool italic
) {
543 SendMsg(2054, style
, italic
);
546 // Set the size of characters of a style.
547 void wxStyledTextCtrl::StyleSetSize(int style
, int sizePoints
) {
548 SendMsg(2055, style
, sizePoints
);
551 // Set the font of a style.
552 void wxStyledTextCtrl::StyleSetFaceName(int style
, const wxString
& fontName
) {
553 SendMsg(2056, style
, (long)fontName
.c_str());
556 // Set a style to have its end of line filled or not.
557 void wxStyledTextCtrl::StyleSetEOLFilled(int style
, bool filled
) {
558 SendMsg(2057, style
, filled
);
561 // Reset the default style to its state at startup
562 void wxStyledTextCtrl::StyleResetDefault() {
566 // Set a style to be underlined or not.
567 void wxStyledTextCtrl::StyleSetUnderline(int style
, bool underline
) {
568 SendMsg(2059, style
, underline
);
571 // Set a style to be mixed case, or to force upper or lower case.
572 void wxStyledTextCtrl::StyleSetCase(int style
, int caseForce
) {
573 SendMsg(2060, style
, caseForce
);
576 // Set the foreground colour of the selection and whether to use this setting.
577 void wxStyledTextCtrl::SetSelForeground(bool useSetting
, const wxColour
& fore
) {
578 SendMsg(2067, useSetting
, wxColourAsLong(fore
));
581 // Set the background colour of the selection and whether to use this setting.
582 void wxStyledTextCtrl::SetSelBackground(bool useSetting
, const wxColour
& back
) {
583 SendMsg(2068, useSetting
, wxColourAsLong(back
));
586 // Set the foreground colour of the caret.
587 void wxStyledTextCtrl::SetCaretForeground(const wxColour
& fore
) {
588 SendMsg(2069, wxColourAsLong(fore
), 0);
591 // When key+modifier combination km is pressed perform msg.
592 void wxStyledTextCtrl::CmdKeyAssign(int key
, int modifiers
, int cmd
) {
593 SendMsg(2070, MAKELONG(key
, modifiers
), cmd
);
596 // When key+modifier combination km do nothing.
597 void wxStyledTextCtrl::CmdKeyClear(int key
, int modifiers
) {
598 SendMsg(2071, MAKELONG(key
, modifiers
));
601 // Drop all key mappings.
602 void wxStyledTextCtrl::CmdKeyClearAll() {
606 // Set the styles for a segment of the document.
607 void wxStyledTextCtrl::SetStyleBytes(int length
, char* styleBytes
) {
608 SendMsg(2073, length
, (long)styleBytes
);
611 // Set a style to be visible or not.
612 void wxStyledTextCtrl::StyleSetVisible(int style
, bool visible
) {
613 SendMsg(2074, style
, visible
);
616 // Get the time in milliseconds that the caret is on and off.
617 int wxStyledTextCtrl::GetCaretPeriod() {
618 return SendMsg(2075, 0, 0);
621 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
622 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds
) {
623 SendMsg(2076, periodMilliseconds
, 0);
626 // Set the set of characters making up words for when moving or selecting
628 void wxStyledTextCtrl::SetWordChars(const wxString
& characters
) {
629 SendMsg(2077, 0, (long)characters
.c_str());
632 // Start a sequence of actions that is undone and redone as a unit.
634 void wxStyledTextCtrl::BeginUndoAction() {
638 // End a sequence of actions that is undone and redone as a unit.
639 void wxStyledTextCtrl::EndUndoAction() {
643 // Set an indicator to plain, squiggle or TT.
644 void wxStyledTextCtrl::IndicatorSetStyle(int indic
, int style
) {
645 SendMsg(2080, indic
, style
);
648 // Retrieve the style of an indicator.
649 int wxStyledTextCtrl::IndicatorGetStyle(int indic
) {
650 return SendMsg(2081, indic
, 0);
653 // Set the foreground colour of an indicator.
654 void wxStyledTextCtrl::IndicatorSetForeground(int indic
, const wxColour
& fore
) {
655 SendMsg(2082, indic
, wxColourAsLong(fore
));
658 // Retrieve the foreground colour of an indicator.
659 wxColour
wxStyledTextCtrl::IndicatorGetForeground(int indic
) {
660 long c
= SendMsg(2083, indic
, 0);
661 return wxColourFromLong(c
);
664 // Divide each styling byte into lexical class bits (default:5) and indicator
665 // bits (default:3). If a lexer requires more than 32 lexical states, then this
666 // is used to expand the possible states.
667 void wxStyledTextCtrl::SetStyleBits(int bits
) {
668 SendMsg(2090, bits
, 0);
671 // Retrieve number of bits in style bytes used to hold the lexical state.
672 int wxStyledTextCtrl::GetStyleBits() {
673 return SendMsg(2091, 0, 0);
676 // Used to hold extra styling information for each line.
677 void wxStyledTextCtrl::SetLineState(int line
, int state
) {
678 SendMsg(2092, line
, state
);
681 // Retrieve the extra styling information for a line.
682 int wxStyledTextCtrl::GetLineState(int line
) {
683 return SendMsg(2093, line
, 0);
686 // Retrieve the last line number that has line state.
687 int wxStyledTextCtrl::GetMaxLineState() {
688 return SendMsg(2094, 0, 0);
691 // Is the background of the line containing the caret in a different colour?
692 bool wxStyledTextCtrl::GetCaretLineVisible() {
693 return SendMsg(2095, 0, 0) != 0;
696 // Display the background of the line containing the caret in a different colour.
697 void wxStyledTextCtrl::SetCaretLineVisible(bool show
) {
698 SendMsg(2096, show
, 0);
701 // Get the colour of the background of the line containing the caret.
702 wxColour
wxStyledTextCtrl::GetCaretLineBack() {
703 long c
= SendMsg(2097, 0, 0);
704 return wxColourFromLong(c
);
707 // Set the colour of the background of the line containing the caret.
708 void wxStyledTextCtrl::SetCaretLineBack(const wxColour
& back
) {
709 SendMsg(2098, wxColourAsLong(back
), 0);
712 // Display a auto-completion list.
713 // The lenEntered parameter indicates how many characters before
714 // the caret should be used to provide context.
715 void wxStyledTextCtrl::AutoCompShow(int lenEntered
, const wxString
& itemList
) {
716 SendMsg(2100, lenEntered
, (long)itemList
.c_str());
719 // Remove the auto-completion list from the screen.
720 void wxStyledTextCtrl::AutoCompCancel() {
724 // Is there an auto-completion list visible?
725 bool wxStyledTextCtrl::AutoCompActive() {
726 return SendMsg(2102, 0, 0) != 0;
729 // Retrieve the position of the caret when the auto-completion list was
731 int wxStyledTextCtrl::AutoCompPosStart() {
732 return SendMsg(2103, 0, 0);
735 // User has selected an item so remove the list and insert the selection.
736 void wxStyledTextCtrl::AutoCompComplete() {
740 // Define a set of character that when typed cancel the auto-completion list.
741 void wxStyledTextCtrl::AutoCompStops(const wxString
& characterSet
) {
742 SendMsg(2105, 0, (long)characterSet
.c_str());
745 // Change the separator character in the string setting up an auto-completion
746 // list. Default is space but can be changed if items contain space.
747 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter
) {
748 SendMsg(2106, separatorCharacter
, 0);
751 // Retrieve the auto-completion list separator character.
752 int wxStyledTextCtrl::AutoCompGetSeparator() {
753 return SendMsg(2107, 0, 0);
756 // Select the item in the auto-completion list that starts with a string.
757 void wxStyledTextCtrl::AutoCompSelect(const wxString
& text
) {
758 SendMsg(2108, 0, (long)text
.c_str());
761 // Should the auto-completion list be cancelled if the user backspaces to a
762 // position before where the box was created.
763 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel
) {
764 SendMsg(2110, cancel
, 0);
767 // Retrieve whether auto-completion cancelled by backspacing before start.
768 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
769 return SendMsg(2111, 0, 0) != 0;
772 // Define a set of character that when typed fills up the selected word.
773 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString
& characterSet
) {
774 SendMsg(2112, 0, (long)characterSet
.c_str());
777 // Should a single item auto-completion list automatically choose the item.
778 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle
) {
779 SendMsg(2113, chooseSingle
, 0);
782 // Retrieve whether a single item auto-completion list automatically choose the item.
783 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
784 return SendMsg(2114, 0, 0) != 0;
787 // Set whether case is significant when performing auto-completion searches.
788 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase
) {
789 SendMsg(2115, ignoreCase
, 0);
792 // Retrieve state of ignore case flag.
793 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
794 return SendMsg(2116, 0, 0) != 0;
797 // Display a list of strings and send notification when user chooses one.
798 void wxStyledTextCtrl::UserListShow(int listType
, const wxString
& itemList
) {
799 SendMsg(2117, listType
, (long)itemList
.c_str());
802 // Set whether or not autocompletion is hidden automatically when nothing matches
803 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide
) {
804 SendMsg(2118, autoHide
, 0);
807 // Retrieve whether or not autocompletion is hidden automatically when nothing matches
808 bool wxStyledTextCtrl::AutoCompGetAutoHide() {
809 return SendMsg(2119, 0, 0) != 0;
812 // Set the number of spaces used for one level of indentation.
813 void wxStyledTextCtrl::SetIndent(int indentSize
) {
814 SendMsg(2122, indentSize
, 0);
817 // Retrieve indentation size.
818 int wxStyledTextCtrl::GetIndent() {
819 return SendMsg(2123, 0, 0);
822 // Indentation will only use space characters if useTabs is false, otherwise
823 // it will use a combination of tabs and spaces.
824 void wxStyledTextCtrl::SetUseTabs(bool useTabs
) {
825 SendMsg(2124, useTabs
, 0);
828 // Retrieve whether tabs will be used in indentation.
829 bool wxStyledTextCtrl::GetUseTabs() {
830 return SendMsg(2125, 0, 0) != 0;
833 // Change the indentation of a line to a number of columns.
834 void wxStyledTextCtrl::SetLineIndentation(int line
, int indentSize
) {
835 SendMsg(2126, line
, indentSize
);
838 // Retrieve the number of columns that a line is indented.
839 int wxStyledTextCtrl::GetLineIndentation(int line
) {
840 return SendMsg(2127, line
, 0);
843 // Retrieve the position before the first non indentation character on a line.
844 int wxStyledTextCtrl::GetLineIndentPosition(int line
) {
845 return SendMsg(2128, line
, 0);
848 // Retrieve the column number of a position, taking tab width into account.
849 int wxStyledTextCtrl::GetColumn(int pos
) {
850 return SendMsg(2129, pos
, 0);
853 // Show or hide the horizontal scroll bar.
854 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show
) {
855 SendMsg(2130, show
, 0);
858 // Is the horizontal scroll bar visible?
859 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
860 return SendMsg(2131, 0, 0) != 0;
863 // Show or hide indentation guides.
864 void wxStyledTextCtrl::SetIndentationGuides(bool show
) {
865 SendMsg(2132, show
, 0);
868 // Are the indentation guides visible?
869 bool wxStyledTextCtrl::GetIndentationGuides() {
870 return SendMsg(2133, 0, 0) != 0;
873 // Set the highlighted indentation guide column.
874 // 0 = no highlighted guide.
875 void wxStyledTextCtrl::SetHighlightGuide(int column
) {
876 SendMsg(2134, column
, 0);
879 // Get the highlighted indentation guide column.
880 int wxStyledTextCtrl::GetHighlightGuide() {
881 return SendMsg(2135, 0, 0);
884 // Get the position after the last visible characters on a line.
885 int wxStyledTextCtrl::GetLineEndPosition(int line
) {
886 return SendMsg(2136, line
, 0);
889 // Get the code page used to interpret the bytes of the document as characters.
890 int wxStyledTextCtrl::GetCodePage() {
891 return SendMsg(2137, 0, 0);
894 // Get the foreground colour of the caret.
895 wxColour
wxStyledTextCtrl::GetCaretForeground() {
896 long c
= SendMsg(2138, 0, 0);
897 return wxColourFromLong(c
);
900 // In read-only mode?
901 bool wxStyledTextCtrl::GetReadOnly() {
902 return SendMsg(2140, 0, 0) != 0;
905 // Sets the position of the caret.
906 void wxStyledTextCtrl::SetCurrentPos(int pos
) {
907 SendMsg(2141, pos
, 0);
910 // Sets the position that starts the selection - this becomes the anchor.
911 void wxStyledTextCtrl::SetSelectionStart(int pos
) {
912 SendMsg(2142, pos
, 0);
915 // Returns the position at the start of the selection.
916 int wxStyledTextCtrl::GetSelectionStart() {
917 return SendMsg(2143, 0, 0);
920 // Sets the position that ends the selection - this becomes the currentPosition.
921 void wxStyledTextCtrl::SetSelectionEnd(int pos
) {
922 SendMsg(2144, pos
, 0);
925 // Returns the position at the end of the selection.
926 int wxStyledTextCtrl::GetSelectionEnd() {
927 return SendMsg(2145, 0, 0);
930 // Sets the print magnification added to the point size of each style for printing.
931 void wxStyledTextCtrl::SetPrintMagnification(int magnification
) {
932 SendMsg(2146, magnification
, 0);
935 // Returns the print magnification.
936 int wxStyledTextCtrl::GetPrintMagnification() {
937 return SendMsg(2147, 0, 0);
940 // Modify colours when printing for clearer printed text.
941 void wxStyledTextCtrl::SetPrintColourMode(int mode
) {
942 SendMsg(2148, mode
, 0);
945 // Returns the print colour mode.
946 int wxStyledTextCtrl::GetPrintColourMode() {
947 return SendMsg(2149, 0, 0);
950 // Find some text in the document.
951 int wxStyledTextCtrl::FindText(int minPos
, int maxPos
,
952 const wxString
& text
,
953 bool caseSensitive
, bool wholeWord
) {
957 flags
|= caseSensitive
? SCFIND_MATCHCASE
: 0;
958 flags
|= wholeWord
? SCFIND_WHOLEWORD
: 0;
959 ft
.chrg
.cpMin
= minPos
;
960 ft
.chrg
.cpMax
= maxPos
;
961 ft
.lpstrText
= (char*)text
.c_str();
963 return SendMsg(2150, flags
, (long)&ft
);
966 // On Windows will draw the document into a display context such as a printer.
967 int wxStyledTextCtrl::FormatRange(bool doDraw
,
971 wxDC
* target
, // Why does it use two? Can they be the same?
977 fr
.hdcTarget
= target
;
978 fr
.rc
.top
= renderRect
.GetTop();
979 fr
.rc
.left
= renderRect
.GetLeft();
980 fr
.rc
.right
= renderRect
.GetRight();
981 fr
.rc
.bottom
= renderRect
.GetBottom();
982 fr
.rcPage
.top
= pageRect
.GetTop();
983 fr
.rcPage
.left
= pageRect
.GetLeft();
984 fr
.rcPage
.right
= pageRect
.GetRight();
985 fr
.rcPage
.bottom
= pageRect
.GetBottom();
986 fr
.chrg
.cpMin
= startPos
;
987 fr
.chrg
.cpMax
= endPos
;
989 return SendMsg(2151, doDraw
, (long)&fr
);
992 // Retrieve the line at the top of the display.
993 int wxStyledTextCtrl::GetFirstVisibleLine() {
994 return SendMsg(2152, 0, 0);
997 // Retrieve the contents of a line.
998 wxString
wxStyledTextCtrl::GetLine(int line
) {
1000 int len
= LineLength(line
);
1001 if (!len
) return "";
1002 char* buf
= text
.GetWriteBuf(len
);
1004 int pos
= SendMsg(2153, line
, (long)buf
);
1005 text
.UngetWriteBuf(len
);
1010 // Returns the number of lines in the document. There is always at least one.
1011 int wxStyledTextCtrl::GetLineCount() {
1012 return SendMsg(2154, 0, 0);
1015 // Sets the size in pixels of the left margin.
1016 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth
) {
1017 SendMsg(2155, 0, pixelWidth
);
1020 // Returns the size in pixels of the left margin.
1021 int wxStyledTextCtrl::GetMarginLeft() {
1022 return SendMsg(2156, 0, 0);
1025 // Sets the size in pixels of the right margin.
1026 void wxStyledTextCtrl::SetMarginRight(int pixelWidth
) {
1027 SendMsg(2157, 0, pixelWidth
);
1030 // Returns the size in pixels of the right margin.
1031 int wxStyledTextCtrl::GetMarginRight() {
1032 return SendMsg(2158, 0, 0);
1035 // Is the document different from when it was last saved?
1036 bool wxStyledTextCtrl::GetModify() {
1037 return SendMsg(2159, 0, 0) != 0;
1040 // Select a range of text.
1041 void wxStyledTextCtrl::SetSelection(int start
, int end
) {
1042 SendMsg(2160, start
, end
);
1045 // Retrieve the selected text.
1046 wxString
wxStyledTextCtrl::GetSelectedText() {
1051 GetSelection(&start
, &end
);
1052 int len
= end
- start
;
1053 if (!len
) return "";
1054 char* buff
= text
.GetWriteBuf(len
);
1056 SendMsg(2161, 0, (long)buff
);
1057 text
.UngetWriteBuf(len
);
1061 // Retrieve a range of text.
1062 wxString
wxStyledTextCtrl::GetTextRange(int startPos
, int endPos
) {
1064 int len
= endPos
- startPos
;
1065 if (!len
) return "";
1066 char* buff
= text
.GetWriteBuf(len
);
1068 tr
.lpstrText
= buff
;
1069 tr
.chrg
.cpMin
= startPos
;
1070 tr
.chrg
.cpMax
= endPos
;
1072 SendMsg(2162, 0, (long)&tr
);
1073 text
.UngetWriteBuf(len
);
1077 // Draw the selection in normal style or with selection highlighted.
1078 void wxStyledTextCtrl::HideSelection(bool normal
) {
1079 SendMsg(2163, normal
, 0);
1082 // Retrieve the line containing a position.
1083 int wxStyledTextCtrl::LineFromPosition(int pos
) {
1084 return SendMsg(2166, pos
, 0);
1087 // Retrieve the position at the start of a line.
1088 int wxStyledTextCtrl::PositionFromLine(int line
) {
1089 return SendMsg(2167, line
, 0);
1092 // Scroll horizontally and vertically.
1093 void wxStyledTextCtrl::LineScroll(int columns
, int lines
) {
1094 SendMsg(2168, columns
, lines
);
1097 // Ensure the caret is visible.
1098 void wxStyledTextCtrl::EnsureCaretVisible() {
1099 SendMsg(2169, 0, 0);
1102 // Replace the selected text with the argument text.
1103 void wxStyledTextCtrl::ReplaceSelection(const wxString
& text
) {
1104 SendMsg(2170, 0, (long)text
.c_str());
1107 // Set to read only or read write.
1108 void wxStyledTextCtrl::SetReadOnly(bool readOnly
) {
1109 SendMsg(2171, readOnly
, 0);
1112 // Will a paste succeed?
1113 bool wxStyledTextCtrl::CanPaste() {
1114 return SendMsg(2173, 0, 0) != 0;
1117 // Are there any undoable actions in the undo history.
1118 bool wxStyledTextCtrl::CanUndo() {
1119 return SendMsg(2174, 0, 0) != 0;
1122 // Delete the undo history.
1123 void wxStyledTextCtrl::EmptyUndoBuffer() {
1124 SendMsg(2175, 0, 0);
1127 // Undo one action in the undo history.
1128 void wxStyledTextCtrl::Undo() {
1129 SendMsg(2176, 0, 0);
1132 // Cut the selection to the clipboard.
1133 void wxStyledTextCtrl::Cut() {
1134 SendMsg(2177, 0, 0);
1137 // Copy the selection to the clipboard.
1138 void wxStyledTextCtrl::Copy() {
1139 SendMsg(2178, 0, 0);
1142 // Paste the contents of the clipboard into the document replacing the selection.
1143 void wxStyledTextCtrl::Paste() {
1144 SendMsg(2179, 0, 0);
1147 // Clear the selection.
1148 void wxStyledTextCtrl::Clear() {
1149 SendMsg(2180, 0, 0);
1152 // Replace the contents of the document with the argument text.
1153 void wxStyledTextCtrl::SetText(const wxString
& text
) {
1154 SendMsg(2181, 0, (long)text
.c_str());
1157 // Retrieve all the text in the document.
1158 wxString
wxStyledTextCtrl::GetText() {
1160 int len
= GetTextLength();
1161 char* buff
= text
.GetWriteBuf(len
+1); // leave room for the null...
1163 SendMsg(2182, len
+1, (long)buff
);
1164 text
.UngetWriteBuf(len
);
1168 // Retrieve the number of characters in the document.
1169 int wxStyledTextCtrl::GetTextLength() {
1170 return SendMsg(2183, 0, 0);
1173 // Set to overtype (true) or insert mode
1174 void wxStyledTextCtrl::SetOvertype(bool overtype
) {
1175 SendMsg(2186, overtype
, 0);
1178 // Returns true if overtype mode is active otherwise false is returned.
1179 bool wxStyledTextCtrl::GetOvertype() {
1180 return SendMsg(2187, 0, 0) != 0;
1183 // Set the width of the insert mode caret
1184 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth
) {
1185 SendMsg(2188, pixelWidth
, 0);
1188 // Returns the width of the insert mode caret
1189 int wxStyledTextCtrl::GetCaretWidth() {
1190 return SendMsg(2189, 0, 0);
1193 // Sets the position that starts the target which is used for updating the
1194 // document without affecting the scroll position.
1195 void wxStyledTextCtrl::SetTargetStart(int pos
) {
1196 SendMsg(2190, pos
, 0);
1199 // Get the position that starts the target.
1200 int wxStyledTextCtrl::GetTargetStart() {
1201 return SendMsg(2191, 0, 0);
1204 // Sets the position that ends the target which is used for updating the
1205 // document without affecting the scroll position.
1206 void wxStyledTextCtrl::SetTargetEnd(int pos
) {
1207 SendMsg(2192, pos
, 0);
1210 // Get the position that ends the target.
1211 int wxStyledTextCtrl::GetTargetEnd() {
1212 return SendMsg(2193, 0, 0);
1215 // Replace the target text with the argument text.
1216 // Text is counted so it can contain nulls.
1217 // Returns the length of the replacement text.
1219 int wxStyledTextCtrl::ReplaceTarget(const wxString
& text
) {
1220 return SendMsg(2194, text
.Len(), (long)text
.c_str());
1224 // Replace the target text with the argument text after \d processing.
1225 // Text is counted so it can contain nulls.
1226 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1227 // matched in the last search operation which were surrounded by \( and \).
1228 // Returns the length of the replacement text including any change
1229 // caused by processing the \d patterns.
1231 int wxStyledTextCtrl::ReplaceTargetRE(const wxString
& text
) {
1232 return SendMsg(2195, text
.Len(), (long)text
.c_str());
1236 // Search for a counted string in the target and set the target to the found
1237 // range. Text is counted so it can contain nulls.
1238 // Returns length of range or -1 for failure in which case target is not moved.
1240 int wxStyledTextCtrl::SearchInTarget(const wxString
& text
) {
1241 return SendMsg(2197, text
.Len(), (long)text
.c_str());
1245 // Set the search flags used by SearchInTarget
1246 void wxStyledTextCtrl::SetSearchFlags(int flags
) {
1247 SendMsg(2198, flags
, 0);
1250 // Get the search flags used by SearchInTarget
1251 int wxStyledTextCtrl::GetSearchFlags() {
1252 return SendMsg(2199, 0, 0);
1255 // Show a call tip containing a definition near position pos.
1256 void wxStyledTextCtrl::CallTipShow(int pos
, const wxString
& definition
) {
1257 SendMsg(2200, pos
, (long)definition
.c_str());
1260 // Remove the call tip from the screen.
1261 void wxStyledTextCtrl::CallTipCancel() {
1262 SendMsg(2201, 0, 0);
1265 // Is there an active call tip?
1266 bool wxStyledTextCtrl::CallTipActive() {
1267 return SendMsg(2202, 0, 0) != 0;
1270 // Retrieve the position where the caret was before displaying the call tip.
1271 int wxStyledTextCtrl::CallTipPosAtStart() {
1272 return SendMsg(2203, 0, 0);
1275 // Highlight a segment of the definition.
1276 void wxStyledTextCtrl::CallTipSetHighlight(int start
, int end
) {
1277 SendMsg(2204, start
, end
);
1280 // Set the background colour for the call tip.
1281 void wxStyledTextCtrl::CallTipSetBackground(const wxColour
& back
) {
1282 SendMsg(2205, wxColourAsLong(back
), 0);
1285 // Find the display line of a document line taking hidden lines into account.
1286 int wxStyledTextCtrl::VisibleFromDocLine(int line
) {
1287 return SendMsg(2220, line
, 0);
1290 // Find the document line of a display line taking hidden lines into account.
1291 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay
) {
1292 return SendMsg(2221, lineDisplay
, 0);
1295 // Set the fold level of a line.
1296 // This encodes an integer level along with flags indicating whether the
1297 // line is a header and whether it is effectively white space.
1298 void wxStyledTextCtrl::SetFoldLevel(int line
, int level
) {
1299 SendMsg(2222, line
, level
);
1302 // Retrieve the fold level of a line.
1303 int wxStyledTextCtrl::GetFoldLevel(int line
) {
1304 return SendMsg(2223, line
, 0);
1307 // Find the last child line of a header line.
1308 int wxStyledTextCtrl::GetLastChild(int line
, int level
) {
1309 return SendMsg(2224, line
, level
);
1312 // Find the parent line of a child line.
1313 int wxStyledTextCtrl::GetFoldParent(int line
) {
1314 return SendMsg(2225, line
, 0);
1317 // Make a range of lines visible.
1318 void wxStyledTextCtrl::ShowLines(int lineStart
, int lineEnd
) {
1319 SendMsg(2226, lineStart
, lineEnd
);
1322 // Make a range of lines invisible.
1323 void wxStyledTextCtrl::HideLines(int lineStart
, int lineEnd
) {
1324 SendMsg(2227, lineStart
, lineEnd
);
1327 // Is a line visible?
1328 bool wxStyledTextCtrl::GetLineVisible(int line
) {
1329 return SendMsg(2228, line
, 0) != 0;
1332 // Show the children of a header line.
1333 void wxStyledTextCtrl::SetFoldExpanded(int line
, bool expanded
) {
1334 SendMsg(2229, line
, expanded
);
1337 // Is a header line expanded?
1338 bool wxStyledTextCtrl::GetFoldExpanded(int line
) {
1339 return SendMsg(2230, line
, 0) != 0;
1342 // Switch a header line between expanded and contracted.
1343 void wxStyledTextCtrl::ToggleFold(int line
) {
1344 SendMsg(2231, line
, 0);
1347 // Ensure a particular line is visible by expanding any header line hiding it.
1348 void wxStyledTextCtrl::EnsureVisible(int line
) {
1349 SendMsg(2232, line
, 0);
1352 // Set some debugging options for folding
1353 void wxStyledTextCtrl::SetFoldFlags(int flags
) {
1354 SendMsg(2233, flags
, 0);
1357 // Ensure a particular line is visible by expanding any header line hiding it.
1358 // Use the currently set visibility policy to determine which range to display.
1359 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line
) {
1360 SendMsg(2234, line
, 0);
1363 // Sets whether a tab pressed when caret is within indentation indents
1364 void wxStyledTextCtrl::SetTabIndents(bool tabIndents
) {
1365 SendMsg(2260, tabIndents
, 0);
1368 // Does a tab pressed when caret is within indentation indent?
1369 bool wxStyledTextCtrl::GetTabIndents() {
1370 return SendMsg(2261, 0, 0) != 0;
1373 // Sets whether a backspace pressed when caret is within indentation unindents
1374 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents
) {
1375 SendMsg(2262, bsUnIndents
, 0);
1378 // Does a backspace pressed when caret is within indentation unindent?
1379 bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1380 return SendMsg(2263, 0, 0) != 0;
1383 // Sets the time the mouse must sit still to generate a mouse dwell event
1384 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds
) {
1385 SendMsg(2264, periodMilliseconds
, 0);
1388 // Retrieve the time the mouse must sit still to generate a mouse dwell event
1389 int wxStyledTextCtrl::GetMouseDwellTime() {
1390 return SendMsg(2265, 0, 0);
1393 // Move the caret inside current view if it's not there already
1394 void wxStyledTextCtrl::MoveCaretInsideView() {
1395 SendMsg(2401, 0, 0);
1398 // How many characters are on a line, not including end of line characters.
1399 int wxStyledTextCtrl::LineLength(int line
) {
1400 return SendMsg(2350, line
, 0);
1403 // Highlight the characters at two positions.
1404 void wxStyledTextCtrl::BraceHighlight(int pos1
, int pos2
) {
1405 SendMsg(2351, pos1
, pos2
);
1408 // Highlight the character at a position indicating there is no matching brace.
1409 void wxStyledTextCtrl::BraceBadLight(int pos
) {
1410 SendMsg(2352, pos
, 0);
1413 // Find the position of a matching brace or INVALID_POSITION if no match.
1414 int wxStyledTextCtrl::BraceMatch(int pos
) {
1415 return SendMsg(2353, pos
, 0);
1418 // Are the end of line characters visible.
1419 bool wxStyledTextCtrl::GetViewEOL() {
1420 return SendMsg(2355, 0, 0) != 0;
1423 // Make the end of line characters visible or invisible
1424 void wxStyledTextCtrl::SetViewEOL(bool visible
) {
1425 SendMsg(2356, visible
, 0);
1428 // Retrieve a pointer to the document object.
1429 void* wxStyledTextCtrl::GetDocPointer() {
1430 return (void*)SendMsg(2357);
1433 // Change the document object used.
1434 void wxStyledTextCtrl::SetDocPointer(void* docPointer
) {
1435 SendMsg(2358, 0, (long)docPointer
);
1438 // Set which document modification events are sent to the container.
1439 void wxStyledTextCtrl::SetModEventMask(int mask
) {
1440 SendMsg(2359, mask
, 0);
1443 // Retrieve the column number which text should be kept within.
1444 int wxStyledTextCtrl::GetEdgeColumn() {
1445 return SendMsg(2360, 0, 0);
1448 // Set the column number of the edge.
1449 // If text goes past the edge then it is highlighted.
1450 void wxStyledTextCtrl::SetEdgeColumn(int column
) {
1451 SendMsg(2361, column
, 0);
1454 // Retrieve the edge highlight mode.
1455 int wxStyledTextCtrl::GetEdgeMode() {
1456 return SendMsg(2362, 0, 0);
1459 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
1460 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
1461 void wxStyledTextCtrl::SetEdgeMode(int mode
) {
1462 SendMsg(2363, mode
, 0);
1465 // Retrieve the colour used in edge indication.
1466 wxColour
wxStyledTextCtrl::GetEdgeColour() {
1467 long c
= SendMsg(2364, 0, 0);
1468 return wxColourFromLong(c
);
1471 // Change the colour used in edge indication.
1472 void wxStyledTextCtrl::SetEdgeColour(const wxColour
& edgeColour
) {
1473 SendMsg(2365, wxColourAsLong(edgeColour
), 0);
1476 // Sets the current caret position to be the search anchor.
1477 void wxStyledTextCtrl::SearchAnchor() {
1478 SendMsg(2366, 0, 0);
1481 // Find some text starting at the search anchor.
1482 // Does not ensure the selection is visible.
1483 int wxStyledTextCtrl::SearchNext(int flags
, const wxString
& text
) {
1484 return SendMsg(2367, flags
, (long)text
.c_str());
1487 // Find some text starting at the search anchor and moving backwards.
1488 // Does not ensure the selection is visible.
1489 int wxStyledTextCtrl::SearchPrev(int flags
, const wxString
& text
) {
1490 return SendMsg(2368, flags
, (long)text
.c_str());
1493 // Set the way the line the caret is on is kept visible.
1494 void wxStyledTextCtrl::SetCaretPolicy(int caretPolicy
, int caretSlop
) {
1495 SendMsg(2369, caretPolicy
, caretSlop
);
1498 // Retrieves the number of lines completely visible.
1499 int wxStyledTextCtrl::LinesOnScreen() {
1500 return SendMsg(2370, 0, 0);
1503 // Set whether a pop up menu is displayed automatically when the user presses
1504 // the wrong mouse button.
1505 void wxStyledTextCtrl::UsePopUp(bool allowPopUp
) {
1506 SendMsg(2371, allowPopUp
, 0);
1509 // Is the selection a rectangular. The alternative is the more common stream selection.
1510 bool wxStyledTextCtrl::SelectionIsRectangle() {
1511 return SendMsg(2372, 0, 0) != 0;
1514 // Set the zoom level. This number of points is added to the size of all fonts.
1515 // It may be positive to magnify or negative to reduce.
1516 void wxStyledTextCtrl::SetZoom(int zoom
) {
1517 SendMsg(2373, zoom
, 0);
1520 // Retrieve the zoom level.
1521 int wxStyledTextCtrl::GetZoom() {
1522 return SendMsg(2374, 0, 0);
1525 // Create a new document object.
1526 // Starts with reference count of 1 and not selected into editor.
1527 void* wxStyledTextCtrl::CreateDocument() {
1528 return (void*)SendMsg(2375);
1531 // Extend life of document.
1532 void wxStyledTextCtrl::AddRefDocument(void* docPointer
) {
1533 SendMsg(2376, (long)docPointer
);
1536 // Release a reference to the document, deleting document if it fades to black.
1537 void wxStyledTextCtrl::ReleaseDocument(void* docPointer
) {
1538 SendMsg(2377, (long)docPointer
);
1541 // Get which document modification events are sent to the container.
1542 int wxStyledTextCtrl::GetModEventMask() {
1543 return SendMsg(2378, 0, 0);
1546 // Change internal focus flag
1547 void wxStyledTextCtrl::SetSTCFocus(bool focus
) {
1548 SendMsg(2380, focus
, 0);
1551 // Get internal focus flag
1552 bool wxStyledTextCtrl::GetSTCFocus() {
1553 return SendMsg(2381, 0, 0) != 0;
1556 // Change error status - 0 = OK
1557 void wxStyledTextCtrl::SetStatus(int statusCode
) {
1558 SendMsg(2382, statusCode
, 0);
1562 int wxStyledTextCtrl::GetStatus() {
1563 return SendMsg(2383, 0, 0);
1566 // Set whether the mouse is captured when its button is pressed
1567 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures
) {
1568 SendMsg(2384, captures
, 0);
1571 // Get whether mouse gets captured
1572 bool wxStyledTextCtrl::GetMouseDownCaptures() {
1573 return SendMsg(2385, 0, 0) != 0;
1576 // Sets the cursor to one of the SC_CURSOR* values
1577 void wxStyledTextCtrl::SetCursor(int cursorType
) {
1578 SendMsg(2386, cursorType
, 0);
1582 int wxStyledTextCtrl::GetCursor() {
1583 return SendMsg(2387, 0, 0);
1586 // Move to the previous change in capitalistion
1587 void wxStyledTextCtrl::WordPartLeft() {
1588 SendMsg(2390, 0, 0);
1591 // Move to the previous change in capitalistion extending selection to new caret position.
1592 void wxStyledTextCtrl::WordPartLeftExtend() {
1593 SendMsg(2391, 0, 0);
1596 // Move to the change next in capitalistion
1597 void wxStyledTextCtrl::WordPartRight() {
1598 SendMsg(2392, 0, 0);
1601 // Move to the next change in capitalistion extending selection to new caret position.
1602 void wxStyledTextCtrl::WordPartRightExtend() {
1603 SendMsg(2393, 0, 0);
1606 // Set the way the display area is determined when a particular line is to be moved to.
1607 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy
, int visibleSlop
) {
1608 SendMsg(2394, visiblePolicy
, visibleSlop
);
1611 // Delete back from the current position to the start of the line
1612 void wxStyledTextCtrl::DelLineLeft() {
1613 SendMsg(2395, 0, 0);
1616 // Delete forwards from the current position to the end of the line
1617 void wxStyledTextCtrl::DelLineRight() {
1618 SendMsg(2396, 0, 0);
1621 // Start notifying the container of all key presses and commands.
1622 void wxStyledTextCtrl::StartRecord() {
1623 SendMsg(3001, 0, 0);
1626 // Stop notifying the container of all key presses and commands.
1627 void wxStyledTextCtrl::StopRecord() {
1628 SendMsg(3002, 0, 0);
1631 // Set the lexing language of the document.
1632 void wxStyledTextCtrl::SetLexer(int lexer
) {
1633 SendMsg(4001, lexer
, 0);
1636 // Retrieve the lexing language of the document.
1637 int wxStyledTextCtrl::GetLexer() {
1638 return SendMsg(4002, 0, 0);
1641 // Colourise a segment of the document using the current lexing language.
1642 void wxStyledTextCtrl::Colourise(int start
, int end
) {
1643 SendMsg(4003, start
, end
);
1646 // Set up a value that may be used by a lexer for some optional feature.
1647 void wxStyledTextCtrl::SetProperty(const wxString
& key
, const wxString
& value
) {
1648 SendMsg(4004, (long)key
.c_str(), (long)value
.c_str());
1651 // Set up the key words used by the lexer.
1652 void wxStyledTextCtrl::SetKeyWords(int keywordSet
, const wxString
& keyWords
) {
1653 SendMsg(4005, keywordSet
, (long)keyWords
.c_str());
1656 // Set the lexing language of the document based on string name.
1657 void wxStyledTextCtrl::SetLexerLanguage(const wxString
& language
) {
1658 SendMsg(4006, 0, (long)language
.c_str());
1661 // END of generated section
1662 //----------------------------------------------------------------------
1665 // Returns the line number of the line with the caret.
1666 int wxStyledTextCtrl::GetCurrentLine() {
1667 int line
= LineFromPosition(GetCurrentPos());
1672 // Extract style settings from a spec-string which is composed of one or
1673 // more of the following comma separated elements:
1675 // bold turns on bold
1676 // italic turns on italics
1677 // fore:#RRGGBB sets the foreground colour
1678 // back:#RRGGBB sets the background colour
1679 // face:[facename] sets the font face name to use
1680 // size:[num] sets the font size in points
1681 // eol turns on eol filling
1682 // underline turns on underlining
1684 void wxStyledTextCtrl::StyleSetSpec(int styleNum
, const wxString
& spec
) {
1686 wxStringTokenizer
tkz(spec
, ",");
1687 while (tkz
.HasMoreTokens()) {
1688 wxString token
= tkz
.GetNextToken();
1690 wxString option
= token
.BeforeFirst(':');
1691 wxString val
= token
.AfterFirst(':');
1693 if (option
== "bold")
1694 StyleSetBold(styleNum
, true);
1696 else if (option
== "italic")
1697 StyleSetItalic(styleNum
, true);
1699 else if (option
== "underline")
1700 StyleSetUnderline(styleNum
, true);
1702 else if (option
== "eol")
1703 StyleSetEOLFilled(styleNum
, true);
1705 else if (option
== "size") {
1707 if (val
.ToLong(&points
))
1708 StyleSetSize(styleNum
, points
);
1711 else if (option
== "face")
1712 StyleSetFaceName(styleNum
, val
);
1714 else if (option
== "fore")
1715 StyleSetForeground(styleNum
, wxColourFromSpec(val
));
1717 else if (option
== "back")
1718 StyleSetBackground(styleNum
, wxColourFromSpec(val
));
1723 // Set style size, face, bold, italic, and underline attributes from
1724 // a wxFont's attributes.
1725 void wxStyledTextCtrl::StyleSetFont(int styleNum
, wxFont
& font
) {
1726 int size
= font
.GetPointSize();
1727 wxString faceName
= font
.GetFaceName();
1728 bool bold
= font
.GetWeight() == wxBOLD
;
1729 bool italic
= font
.GetStyle() != wxNORMAL
;
1730 bool under
= font
.GetUnderlined();
1732 // TODO: add encoding/charset mapping
1733 StyleSetFontAttr(styleNum
, size
, faceName
, bold
, italic
, under
);
1736 // Set all font style attributes at once.
1737 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum
, int size
,
1738 const wxString
& faceName
,
1739 bool bold
, bool italic
,
1741 StyleSetSize(styleNum
, size
);
1742 StyleSetFaceName(styleNum
, faceName
);
1743 StyleSetBold(styleNum
, bold
);
1744 StyleSetItalic(styleNum
, italic
);
1745 StyleSetUnderline(styleNum
, underline
);
1747 // TODO: add encoding/charset mapping
1751 // Perform one of the operations defined by the wxSTC_CMD_* constants.
1752 void wxStyledTextCtrl::CmdKeyExecute(int cmd
) {
1757 // Set the left and right margin in the edit area, measured in pixels.
1758 void wxStyledTextCtrl::SetMargins(int left
, int right
) {
1759 SetMarginLeft(left
);
1760 SetMarginRight(right
);
1764 // Retrieve the start and end positions of the current selection.
1765 void wxStyledTextCtrl::GetSelection(int* startPos
, int* endPos
) {
1766 if (startPos
!= NULL
)
1767 *startPos
= SendMsg(SCI_GETSELECTIONSTART
);
1769 *endPos
= SendMsg(SCI_GETSELECTIONEND
);
1773 // Retrieve the point in the window where a position is displayed.
1774 wxPoint
wxStyledTextCtrl::PointFromPosition(int pos
) {
1775 int x
= SendMsg(SCI_POINTXFROMPOSITION
, 0, pos
);
1776 int y
= SendMsg(SCI_POINTYFROMPOSITION
, 0, pos
);
1777 return wxPoint(x
, y
);
1780 // Scroll enough to make the given line visible
1781 void wxStyledTextCtrl::ScrollToLine(int line
) {
1782 m_swx
->DoScrollToLine(line
);
1786 // Scroll enough to make the given column visible
1787 void wxStyledTextCtrl::ScrollToColumn(int column
) {
1788 m_swx
->DoScrollToColumn(column
);
1793 //----------------------------------------------------------------------
1796 void wxStyledTextCtrl::OnPaint(wxPaintEvent
& evt
) {
1798 wxRegion region
= GetUpdateRegion();
1800 m_swx
->DoPaint(&dc
, region
.GetBox());
1803 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent
& evt
) {
1804 if (evt
.GetOrientation() == wxHORIZONTAL
)
1805 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
1807 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
1810 void wxStyledTextCtrl::OnScroll(wxScrollEvent
& evt
) {
1811 wxScrollBar
* sb
= wxDynamicCast(evt
.GetEventObject(), wxScrollBar
);
1813 if (sb
->IsVertical())
1814 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
1816 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
1820 void wxStyledTextCtrl::OnSize(wxSizeEvent
& evt
) {
1821 wxSize sz
= GetClientSize();
1822 m_swx
->DoSize(sz
.x
, sz
.y
);
1825 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent
& evt
) {
1826 wxPoint pt
= evt
.GetPosition();
1827 m_swx
->DoButtonDown(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
1828 evt
.ShiftDown(), evt
.ControlDown(), evt
.AltDown());
1831 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent
& evt
) {
1832 wxPoint pt
= evt
.GetPosition();
1833 m_swx
->DoButtonMove(Point(pt
.x
, pt
.y
));
1836 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent
& evt
) {
1837 wxPoint pt
= evt
.GetPosition();
1838 m_swx
->DoButtonUp(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
1843 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent
& evt
) {
1844 wxPoint pt
= evt
.GetPosition();
1845 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
1849 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent
& evt
) {
1850 wxPoint pt
= evt
.GetPosition();
1851 ScreenToClient(&pt
.x
, &pt
.y
);
1852 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
1856 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent
& evt
) {
1857 m_swx
->DoMouseWheel(evt
.GetWheelRotation(),
1858 evt
.GetWheelDelta(),
1859 evt
.GetLinesPerAction(),
1864 void wxStyledTextCtrl::OnChar(wxKeyEvent
& evt
) {
1865 long key
= evt
.KeyCode();
1867 // printf("OnChar key:%d consumed:%d ctrl:%d alt:%d\n",
1868 // key, m_lastKeyDownConsumed, evt.ControlDown(), evt.AltDown());
1871 // \|@#¬[]{}?£$~ ã,õ,Ã,Õ, ñ, Ñ
1873 // On (some?) non-US keyboards the AltGr key is required to enter some
1874 // common characters. It comes to us as both Alt and Ctrl down so we need
1875 // to let the char through in that case, otherwise if only ctrl or only
1876 // alt let's skip it.
1877 bool ctrl
= evt
.ControlDown();
1878 bool alt
= evt
.AltDown();
1879 bool skip
= ((ctrl
|| alt
) && ! (ctrl
&& alt
));
1881 if (key
<= 0xff && key
>= 32 && !m_lastKeyDownConsumed
&& !skip
) {
1882 m_swx
->DoAddChar(key
);
1889 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent
& evt
) {
1890 long key
= evt
.KeyCode();
1891 bool shift
= evt
.ShiftDown(),
1892 ctrl
= evt
.ControlDown(),
1893 alt
= evt
.AltDown();
1895 int processed
= m_swx
->DoKeyDown(key
, shift
, ctrl
, alt
, &m_lastKeyDownConsumed
);
1897 // printf("key: %d shift: %d ctrl: %d alt: %d processed: %d consumed: %d\n",
1898 // key, shift, ctrl, alt, processed, m_lastKeyDownConsumed);
1900 if (!processed
&& !m_lastKeyDownConsumed
)
1905 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent
& evt
) {
1906 m_swx
->DoLoseFocus();
1910 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent
& evt
) {
1911 m_swx
->DoGainFocus();
1915 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent
& evt
) {
1916 m_swx
->DoSysColourChange();
1920 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent
& evt
) {
1921 // do nothing to help avoid flashing
1926 void wxStyledTextCtrl::OnMenu(wxCommandEvent
& evt
) {
1927 m_swx
->DoCommand(evt
.GetId());
1931 void wxStyledTextCtrl::OnListBox(wxCommandEvent
& evt
) {
1932 m_swx
->DoOnListBox();
1936 //----------------------------------------------------------------------
1937 // Turn notifications from Scintilla into events
1940 void wxStyledTextCtrl::NotifyChange() {
1941 wxStyledTextEvent
evt(wxEVT_STC_CHANGE
, GetId());
1942 evt
.SetEventObject(this);
1943 GetEventHandler()->ProcessEvent(evt
);
1946 void wxStyledTextCtrl::NotifyParent(SCNotification
* _scn
) {
1947 SCNotification
& scn
= *_scn
;
1948 wxStyledTextEvent
evt(0, GetId());
1950 evt
.SetEventObject(this);
1951 evt
.SetPosition(scn
.position
);
1953 evt
.SetModifiers(scn
.modifiers
);
1955 switch (scn
.nmhdr
.code
) {
1956 case SCN_STYLENEEDED
:
1957 evt
.SetEventType(wxEVT_STC_STYLENEEDED
);
1961 evt
.SetEventType(wxEVT_STC_CHARADDED
);
1964 case SCN_SAVEPOINTREACHED
:
1965 evt
.SetEventType(wxEVT_STC_SAVEPOINTREACHED
);
1968 case SCN_SAVEPOINTLEFT
:
1969 evt
.SetEventType(wxEVT_STC_SAVEPOINTLEFT
);
1972 case SCN_MODIFYATTEMPTRO
:
1973 evt
.SetEventType(wxEVT_STC_ROMODIFYATTEMPT
);
1977 evt
.SetEventType(wxEVT_STC_KEY
);
1980 case SCN_DOUBLECLICK
:
1981 evt
.SetEventType(wxEVT_STC_DOUBLECLICK
);
1985 evt
.SetEventType(wxEVT_STC_UPDATEUI
);
1989 evt
.SetEventType(wxEVT_STC_MODIFIED
);
1990 evt
.SetModificationType(scn
.modificationType
);
1992 evt
.SetText(wxString(scn
.text
, scn
.length
));
1993 evt
.SetLength(scn
.length
);
1994 evt
.SetLinesAdded(scn
.linesAdded
);
1995 evt
.SetLine(scn
.line
);
1996 evt
.SetFoldLevelNow(scn
.foldLevelNow
);
1997 evt
.SetFoldLevelPrev(scn
.foldLevelPrev
);
2000 case SCN_MACRORECORD
:
2001 evt
.SetEventType(wxEVT_STC_MACRORECORD
);
2002 evt
.SetMessage(scn
.message
);
2003 evt
.SetWParam(scn
.wParam
);
2004 evt
.SetLParam(scn
.lParam
);
2007 case SCN_MARGINCLICK
:
2008 evt
.SetEventType(wxEVT_STC_MARGINCLICK
);
2009 evt
.SetMargin(scn
.margin
);
2013 evt
.SetEventType(wxEVT_STC_NEEDSHOWN
);
2014 evt
.SetLength(scn
.length
);
2017 case SCN_POSCHANGED
:
2018 evt
.SetEventType(wxEVT_STC_POSCHANGED
);
2022 evt
.SetEventType(wxEVT_STC_PAINTED
);
2025 case SCN_USERLISTSELECTION
:
2026 evt
.SetEventType(wxEVT_STC_USERLISTSELECTION
);
2027 evt
.SetListType(scn
.listType
);
2028 evt
.SetText(scn
.text
);
2031 case SCN_URIDROPPED
:
2032 evt
.SetEventType(wxEVT_STC_URIDROPPED
);
2033 evt
.SetText(scn
.text
);
2036 case SCN_DWELLSTART
:
2037 evt
.SetEventType(wxEVT_STC_DWELLSTART
);
2043 evt
.SetEventType(wxEVT_STC_DWELLEND
);
2052 GetEventHandler()->ProcessEvent(evt
);
2056 //----------------------------------------------------------------------
2057 //----------------------------------------------------------------------
2058 //----------------------------------------------------------------------
2060 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType
, int id
)
2061 : wxCommandEvent(commandType
, id
)
2066 m_modificationType
= 0;
2071 m_foldLevelPrev
= 0;
2079 m_dragAllowMove
= FALSE
;
2080 m_dragResult
= wxDragNone
;
2083 bool wxStyledTextEvent::GetShift() const { return (m_modifiers
& SCI_SHIFT
) != 0; }
2084 bool wxStyledTextEvent::GetControl() const { return (m_modifiers
& SCI_CTRL
) != 0; }
2085 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers
& SCI_ALT
) != 0; }
2088 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent
& event
):
2089 wxCommandEvent(event
)
2091 m_position
= event
.m_position
;
2092 m_key
= event
.m_key
;
2093 m_modifiers
= event
.m_modifiers
;
2094 m_modificationType
= event
.m_modificationType
;
2095 m_text
= event
.m_text
;
2096 m_length
= event
.m_length
;
2097 m_linesAdded
= event
.m_linesAdded
;
2098 m_line
= event
.m_line
;
2099 m_foldLevelNow
= event
.m_foldLevelNow
;
2100 m_foldLevelPrev
= event
.m_foldLevelPrev
;
2102 m_margin
= event
.m_margin
;
2104 m_message
= event
.m_message
;
2105 m_wParam
= event
.m_wParam
;
2106 m_lParam
= event
.m_lParam
;
2108 m_listType
= event
.m_listType
;
2112 m_dragText
= event
.m_dragText
;
2113 m_dragAllowMove
=event
.m_dragAllowMove
;
2114 m_dragResult
= event
.m_dragResult
;
2117 //----------------------------------------------------------------------
2118 //----------------------------------------------------------------------