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 if (endPos
< startPos
) {
284 int len
= endPos
- startPos
;
287 tr
.lpstrText
= text
.GetWriteBuf(len
*2);
288 tr
.chrg
.cpMin
= startPos
;
289 tr
.chrg
.cpMax
= endPos
;
290 SendMsg(2015, 0, (long)&tr
);
291 text
.UngetWriteBuf(len
*2);
295 // Are there any redoable actions in the undo history.
296 bool wxStyledTextCtrl::CanRedo() {
297 return SendMsg(2016, 0, 0) != 0;
300 // Retrieve the line number at which a particular marker is located
301 int wxStyledTextCtrl::MarkerLineFromHandle(int handle
) {
302 return SendMsg(2017, handle
, 0);
306 void wxStyledTextCtrl::MarkerDeleteHandle(int handle
) {
307 SendMsg(2018, handle
, 0);
310 // Is undo history being collected?
311 bool wxStyledTextCtrl::GetUndoCollection() {
312 return SendMsg(2019, 0, 0) != 0;
315 // Are white space characters currently visible?
316 // Returns one of SCWS_* constants.
317 int wxStyledTextCtrl::GetViewWhiteSpace() {
318 return SendMsg(2020, 0, 0);
321 // Make white space characters invisible, always visible or visible outside indentation.
322 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS
) {
323 SendMsg(2021, viewWS
, 0);
326 // Find the position from a point within the window.
327 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt
) {
328 return SendMsg(2022, pt
.x
, pt
.y
);
331 // Find the position from a point within the window but return
332 // INVALID_POSITION if not close to text.
333 int wxStyledTextCtrl::PositionFromPointClose(int x
, int y
) {
334 return SendMsg(2023, x
, y
);
337 // Set caret to start of a line and ensure it is visible.
338 void wxStyledTextCtrl::GotoLine(int line
) {
339 SendMsg(2024, line
, 0);
342 // Set caret to a position and ensure it is visible.
343 void wxStyledTextCtrl::GotoPos(int pos
) {
344 SendMsg(2025, pos
, 0);
347 // Set the selection anchor to a position. The anchor is the opposite
348 // end of the selection from the caret.
349 void wxStyledTextCtrl::SetAnchor(int posAnchor
) {
350 SendMsg(2026, posAnchor
, 0);
353 // Retrieve the text of the line containing the caret.
354 // Returns the index of the caret on the line.
355 wxString
wxStyledTextCtrl::GetCurLine(int* linePos
) {
357 int len
= LineLength(GetCurrentLine());
359 if (linePos
) *linePos
= 0;
362 // Need an extra byte because SCI_GETCURLINE writes a null to the string
363 char* buf
= text
.GetWriteBuf(len
+1);
365 int pos
= SendMsg(2027, len
+1, (long)buf
);
366 text
.UngetWriteBuf(len
);
367 if (linePos
) *linePos
= pos
;
372 // Retrieve the position of the last correctly styled character.
373 int wxStyledTextCtrl::GetEndStyled() {
374 return SendMsg(2028, 0, 0);
377 // Convert all line endings in the document to one mode.
378 void wxStyledTextCtrl::ConvertEOLs(int eolMode
) {
379 SendMsg(2029, eolMode
, 0);
382 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
383 int wxStyledTextCtrl::GetEOLMode() {
384 return SendMsg(2030, 0, 0);
387 // Set the current end of line mode.
388 void wxStyledTextCtrl::SetEOLMode(int eolMode
) {
389 SendMsg(2031, eolMode
, 0);
392 // Set the current styling position to pos and the styling mask to mask.
393 // The styling mask can be used to protect some bits in each styling byte from
395 void wxStyledTextCtrl::StartStyling(int pos
, int mask
) {
396 SendMsg(2032, pos
, mask
);
399 // Change style from current styling position for length characters to a style
400 // and move the current styling position to after this newly styled segment.
401 void wxStyledTextCtrl::SetStyling(int length
, int style
) {
402 SendMsg(2033, length
, style
);
405 // Is drawing done first into a buffer or direct to the screen.
406 bool wxStyledTextCtrl::GetBufferedDraw() {
407 return SendMsg(2034, 0, 0) != 0;
410 // If drawing is buffered then each line of text is drawn into a bitmap buffer
411 // before drawing it to the screen to avoid flicker.
412 void wxStyledTextCtrl::SetBufferedDraw(bool buffered
) {
413 SendMsg(2035, buffered
, 0);
416 // Change the visible size of a tab to be a multiple of the width of a space
418 void wxStyledTextCtrl::SetTabWidth(int tabWidth
) {
419 SendMsg(2036, tabWidth
, 0);
422 // Retrieve the visible size of a tab.
423 int wxStyledTextCtrl::GetTabWidth() {
424 return SendMsg(2121, 0, 0);
427 // Set the code page used to interpret the bytes of the document as characters.
428 // The SC_CP_UTF8 value can be used to enter Unicode mode.
429 void wxStyledTextCtrl::SetCodePage(int codePage
) {
430 SendMsg(2037, codePage
, 0);
433 // Set the symbol used for a particular marker number,
434 // and optionally the for and background colours.
435 void wxStyledTextCtrl::MarkerDefine(int markerNumber
, int markerSymbol
,
436 const wxColour
& foreground
,
437 const wxColour
& background
) {
439 SendMsg(2040, markerNumber
, markerSymbol
);
441 MarkerSetForeground(markerNumber
, foreground
);
443 MarkerSetBackground(markerNumber
, background
);
446 // Set the foreground colour used for a particular marker number.
447 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber
, const wxColour
& fore
) {
448 SendMsg(2041, markerNumber
, wxColourAsLong(fore
));
451 // Set the background colour used for a particular marker number.
452 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber
, const wxColour
& back
) {
453 SendMsg(2042, markerNumber
, wxColourAsLong(back
));
456 // Add a marker to a line.
457 void wxStyledTextCtrl::MarkerAdd(int line
, int markerNumber
) {
458 SendMsg(2043, line
, markerNumber
);
461 // Delete a marker from a line
462 void wxStyledTextCtrl::MarkerDelete(int line
, int markerNumber
) {
463 SendMsg(2044, line
, markerNumber
);
466 // Delete all markers with a particular number from all lines
467 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber
) {
468 SendMsg(2045, markerNumber
, 0);
471 // Get a bit mask of all the markers set on a line.
472 int wxStyledTextCtrl::MarkerGet(int line
) {
473 return SendMsg(2046, line
, 0);
476 // Find the next line after lineStart that includes a marker in mask.
477 int wxStyledTextCtrl::MarkerNext(int lineStart
, int markerMask
) {
478 return SendMsg(2047, lineStart
, markerMask
);
481 // Find the previous line before lineStart that includes a marker in mask.
482 int wxStyledTextCtrl::MarkerPrevious(int lineStart
, int markerMask
) {
483 return SendMsg(2048, lineStart
, markerMask
);
486 // Set a margin to be either numeric or symbolic.
487 void wxStyledTextCtrl::SetMarginType(int margin
, int marginType
) {
488 SendMsg(2240, margin
, marginType
);
491 // Retrieve the type of a margin.
492 int wxStyledTextCtrl::GetMarginType(int margin
) {
493 return SendMsg(2241, margin
, 0);
496 // Set the width of a margin to a width expressed in pixels.
497 void wxStyledTextCtrl::SetMarginWidth(int margin
, int pixelWidth
) {
498 SendMsg(2242, margin
, pixelWidth
);
501 // Retrieve the width of a margin in pixels.
502 int wxStyledTextCtrl::GetMarginWidth(int margin
) {
503 return SendMsg(2243, margin
, 0);
506 // Set a mask that determines which markers are displayed in a margin.
507 void wxStyledTextCtrl::SetMarginMask(int margin
, int mask
) {
508 SendMsg(2244, margin
, mask
);
511 // Retrieve the marker mask of a margin.
512 int wxStyledTextCtrl::GetMarginMask(int margin
) {
513 return SendMsg(2245, margin
, 0);
516 // Make a margin sensitive or insensitive to mouse clicks.
517 void wxStyledTextCtrl::SetMarginSensitive(int margin
, bool sensitive
) {
518 SendMsg(2246, margin
, sensitive
);
521 // Retrieve the mouse click sensitivity of a margin.
522 bool wxStyledTextCtrl::GetMarginSensitive(int margin
) {
523 return SendMsg(2247, margin
, 0) != 0;
526 // Clear all the styles and make equivalent to the global default style.
527 void wxStyledTextCtrl::StyleClearAll() {
531 // Set the foreground colour of a style.
532 void wxStyledTextCtrl::StyleSetForeground(int style
, const wxColour
& fore
) {
533 SendMsg(2051, style
, wxColourAsLong(fore
));
536 // Set the background colour of a style.
537 void wxStyledTextCtrl::StyleSetBackground(int style
, const wxColour
& back
) {
538 SendMsg(2052, style
, wxColourAsLong(back
));
541 // Set a style to be bold or not.
542 void wxStyledTextCtrl::StyleSetBold(int style
, bool bold
) {
543 SendMsg(2053, style
, bold
);
546 // Set a style to be italic or not.
547 void wxStyledTextCtrl::StyleSetItalic(int style
, bool italic
) {
548 SendMsg(2054, style
, italic
);
551 // Set the size of characters of a style.
552 void wxStyledTextCtrl::StyleSetSize(int style
, int sizePoints
) {
553 SendMsg(2055, style
, sizePoints
);
556 // Set the font of a style.
557 void wxStyledTextCtrl::StyleSetFaceName(int style
, const wxString
& fontName
) {
558 SendMsg(2056, style
, (long)fontName
.c_str());
561 // Set a style to have its end of line filled or not.
562 void wxStyledTextCtrl::StyleSetEOLFilled(int style
, bool filled
) {
563 SendMsg(2057, style
, filled
);
566 // Reset the default style to its state at startup
567 void wxStyledTextCtrl::StyleResetDefault() {
571 // Set a style to be underlined or not.
572 void wxStyledTextCtrl::StyleSetUnderline(int style
, bool underline
) {
573 SendMsg(2059, style
, underline
);
576 // Set a style to be mixed case, or to force upper or lower case.
577 void wxStyledTextCtrl::StyleSetCase(int style
, int caseForce
) {
578 SendMsg(2060, style
, caseForce
);
581 // Set the foreground colour of the selection and whether to use this setting.
582 void wxStyledTextCtrl::SetSelForeground(bool useSetting
, const wxColour
& fore
) {
583 SendMsg(2067, useSetting
, wxColourAsLong(fore
));
586 // Set the background colour of the selection and whether to use this setting.
587 void wxStyledTextCtrl::SetSelBackground(bool useSetting
, const wxColour
& back
) {
588 SendMsg(2068, useSetting
, wxColourAsLong(back
));
591 // Set the foreground colour of the caret.
592 void wxStyledTextCtrl::SetCaretForeground(const wxColour
& fore
) {
593 SendMsg(2069, wxColourAsLong(fore
), 0);
596 // When key+modifier combination km is pressed perform msg.
597 void wxStyledTextCtrl::CmdKeyAssign(int key
, int modifiers
, int cmd
) {
598 SendMsg(2070, MAKELONG(key
, modifiers
), cmd
);
601 // When key+modifier combination km do nothing.
602 void wxStyledTextCtrl::CmdKeyClear(int key
, int modifiers
) {
603 SendMsg(2071, MAKELONG(key
, modifiers
));
606 // Drop all key mappings.
607 void wxStyledTextCtrl::CmdKeyClearAll() {
611 // Set the styles for a segment of the document.
612 void wxStyledTextCtrl::SetStyleBytes(int length
, char* styleBytes
) {
613 SendMsg(2073, length
, (long)styleBytes
);
616 // Set a style to be visible or not.
617 void wxStyledTextCtrl::StyleSetVisible(int style
, bool visible
) {
618 SendMsg(2074, style
, visible
);
621 // Get the time in milliseconds that the caret is on and off.
622 int wxStyledTextCtrl::GetCaretPeriod() {
623 return SendMsg(2075, 0, 0);
626 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
627 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds
) {
628 SendMsg(2076, periodMilliseconds
, 0);
631 // Set the set of characters making up words for when moving or selecting
633 void wxStyledTextCtrl::SetWordChars(const wxString
& characters
) {
634 SendMsg(2077, 0, (long)characters
.c_str());
637 // Start a sequence of actions that is undone and redone as a unit.
639 void wxStyledTextCtrl::BeginUndoAction() {
643 // End a sequence of actions that is undone and redone as a unit.
644 void wxStyledTextCtrl::EndUndoAction() {
648 // Set an indicator to plain, squiggle or TT.
649 void wxStyledTextCtrl::IndicatorSetStyle(int indic
, int style
) {
650 SendMsg(2080, indic
, style
);
653 // Retrieve the style of an indicator.
654 int wxStyledTextCtrl::IndicatorGetStyle(int indic
) {
655 return SendMsg(2081, indic
, 0);
658 // Set the foreground colour of an indicator.
659 void wxStyledTextCtrl::IndicatorSetForeground(int indic
, const wxColour
& fore
) {
660 SendMsg(2082, indic
, wxColourAsLong(fore
));
663 // Retrieve the foreground colour of an indicator.
664 wxColour
wxStyledTextCtrl::IndicatorGetForeground(int indic
) {
665 long c
= SendMsg(2083, indic
, 0);
666 return wxColourFromLong(c
);
669 // Divide each styling byte into lexical class bits (default:5) and indicator
670 // bits (default:3). If a lexer requires more than 32 lexical states, then this
671 // is used to expand the possible states.
672 void wxStyledTextCtrl::SetStyleBits(int bits
) {
673 SendMsg(2090, bits
, 0);
676 // Retrieve number of bits in style bytes used to hold the lexical state.
677 int wxStyledTextCtrl::GetStyleBits() {
678 return SendMsg(2091, 0, 0);
681 // Used to hold extra styling information for each line.
682 void wxStyledTextCtrl::SetLineState(int line
, int state
) {
683 SendMsg(2092, line
, state
);
686 // Retrieve the extra styling information for a line.
687 int wxStyledTextCtrl::GetLineState(int line
) {
688 return SendMsg(2093, line
, 0);
691 // Retrieve the last line number that has line state.
692 int wxStyledTextCtrl::GetMaxLineState() {
693 return SendMsg(2094, 0, 0);
696 // Is the background of the line containing the caret in a different colour?
697 bool wxStyledTextCtrl::GetCaretLineVisible() {
698 return SendMsg(2095, 0, 0) != 0;
701 // Display the background of the line containing the caret in a different colour.
702 void wxStyledTextCtrl::SetCaretLineVisible(bool show
) {
703 SendMsg(2096, show
, 0);
706 // Get the colour of the background of the line containing the caret.
707 wxColour
wxStyledTextCtrl::GetCaretLineBack() {
708 long c
= SendMsg(2097, 0, 0);
709 return wxColourFromLong(c
);
712 // Set the colour of the background of the line containing the caret.
713 void wxStyledTextCtrl::SetCaretLineBack(const wxColour
& back
) {
714 SendMsg(2098, wxColourAsLong(back
), 0);
717 // Display a auto-completion list.
718 // The lenEntered parameter indicates how many characters before
719 // the caret should be used to provide context.
720 void wxStyledTextCtrl::AutoCompShow(int lenEntered
, const wxString
& itemList
) {
721 SendMsg(2100, lenEntered
, (long)itemList
.c_str());
724 // Remove the auto-completion list from the screen.
725 void wxStyledTextCtrl::AutoCompCancel() {
729 // Is there an auto-completion list visible?
730 bool wxStyledTextCtrl::AutoCompActive() {
731 return SendMsg(2102, 0, 0) != 0;
734 // Retrieve the position of the caret when the auto-completion list was
736 int wxStyledTextCtrl::AutoCompPosStart() {
737 return SendMsg(2103, 0, 0);
740 // User has selected an item so remove the list and insert the selection.
741 void wxStyledTextCtrl::AutoCompComplete() {
745 // Define a set of character that when typed cancel the auto-completion list.
746 void wxStyledTextCtrl::AutoCompStops(const wxString
& characterSet
) {
747 SendMsg(2105, 0, (long)characterSet
.c_str());
750 // Change the separator character in the string setting up an auto-completion
751 // list. Default is space but can be changed if items contain space.
752 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter
) {
753 SendMsg(2106, separatorCharacter
, 0);
756 // Retrieve the auto-completion list separator character.
757 int wxStyledTextCtrl::AutoCompGetSeparator() {
758 return SendMsg(2107, 0, 0);
761 // Select the item in the auto-completion list that starts with a string.
762 void wxStyledTextCtrl::AutoCompSelect(const wxString
& text
) {
763 SendMsg(2108, 0, (long)text
.c_str());
766 // Should the auto-completion list be cancelled if the user backspaces to a
767 // position before where the box was created.
768 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel
) {
769 SendMsg(2110, cancel
, 0);
772 // Retrieve whether auto-completion cancelled by backspacing before start.
773 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
774 return SendMsg(2111, 0, 0) != 0;
777 // Define a set of character that when typed fills up the selected word.
778 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString
& characterSet
) {
779 SendMsg(2112, 0, (long)characterSet
.c_str());
782 // Should a single item auto-completion list automatically choose the item.
783 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle
) {
784 SendMsg(2113, chooseSingle
, 0);
787 // Retrieve whether a single item auto-completion list automatically choose the item.
788 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
789 return SendMsg(2114, 0, 0) != 0;
792 // Set whether case is significant when performing auto-completion searches.
793 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase
) {
794 SendMsg(2115, ignoreCase
, 0);
797 // Retrieve state of ignore case flag.
798 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
799 return SendMsg(2116, 0, 0) != 0;
802 // Display a list of strings and send notification when user chooses one.
803 void wxStyledTextCtrl::UserListShow(int listType
, const wxString
& itemList
) {
804 SendMsg(2117, listType
, (long)itemList
.c_str());
807 // Set whether or not autocompletion is hidden automatically when nothing matches
808 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide
) {
809 SendMsg(2118, autoHide
, 0);
812 // Retrieve whether or not autocompletion is hidden automatically when nothing matches
813 bool wxStyledTextCtrl::AutoCompGetAutoHide() {
814 return SendMsg(2119, 0, 0) != 0;
817 // Set the number of spaces used for one level of indentation.
818 void wxStyledTextCtrl::SetIndent(int indentSize
) {
819 SendMsg(2122, indentSize
, 0);
822 // Retrieve indentation size.
823 int wxStyledTextCtrl::GetIndent() {
824 return SendMsg(2123, 0, 0);
827 // Indentation will only use space characters if useTabs is false, otherwise
828 // it will use a combination of tabs and spaces.
829 void wxStyledTextCtrl::SetUseTabs(bool useTabs
) {
830 SendMsg(2124, useTabs
, 0);
833 // Retrieve whether tabs will be used in indentation.
834 bool wxStyledTextCtrl::GetUseTabs() {
835 return SendMsg(2125, 0, 0) != 0;
838 // Change the indentation of a line to a number of columns.
839 void wxStyledTextCtrl::SetLineIndentation(int line
, int indentSize
) {
840 SendMsg(2126, line
, indentSize
);
843 // Retrieve the number of columns that a line is indented.
844 int wxStyledTextCtrl::GetLineIndentation(int line
) {
845 return SendMsg(2127, line
, 0);
848 // Retrieve the position before the first non indentation character on a line.
849 int wxStyledTextCtrl::GetLineIndentPosition(int line
) {
850 return SendMsg(2128, line
, 0);
853 // Retrieve the column number of a position, taking tab width into account.
854 int wxStyledTextCtrl::GetColumn(int pos
) {
855 return SendMsg(2129, pos
, 0);
858 // Show or hide the horizontal scroll bar.
859 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show
) {
860 SendMsg(2130, show
, 0);
863 // Is the horizontal scroll bar visible?
864 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
865 return SendMsg(2131, 0, 0) != 0;
868 // Show or hide indentation guides.
869 void wxStyledTextCtrl::SetIndentationGuides(bool show
) {
870 SendMsg(2132, show
, 0);
873 // Are the indentation guides visible?
874 bool wxStyledTextCtrl::GetIndentationGuides() {
875 return SendMsg(2133, 0, 0) != 0;
878 // Set the highlighted indentation guide column.
879 // 0 = no highlighted guide.
880 void wxStyledTextCtrl::SetHighlightGuide(int column
) {
881 SendMsg(2134, column
, 0);
884 // Get the highlighted indentation guide column.
885 int wxStyledTextCtrl::GetHighlightGuide() {
886 return SendMsg(2135, 0, 0);
889 // Get the position after the last visible characters on a line.
890 int wxStyledTextCtrl::GetLineEndPosition(int line
) {
891 return SendMsg(2136, line
, 0);
894 // Get the code page used to interpret the bytes of the document as characters.
895 int wxStyledTextCtrl::GetCodePage() {
896 return SendMsg(2137, 0, 0);
899 // Get the foreground colour of the caret.
900 wxColour
wxStyledTextCtrl::GetCaretForeground() {
901 long c
= SendMsg(2138, 0, 0);
902 return wxColourFromLong(c
);
905 // In read-only mode?
906 bool wxStyledTextCtrl::GetReadOnly() {
907 return SendMsg(2140, 0, 0) != 0;
910 // Sets the position of the caret.
911 void wxStyledTextCtrl::SetCurrentPos(int pos
) {
912 SendMsg(2141, pos
, 0);
915 // Sets the position that starts the selection - this becomes the anchor.
916 void wxStyledTextCtrl::SetSelectionStart(int pos
) {
917 SendMsg(2142, pos
, 0);
920 // Returns the position at the start of the selection.
921 int wxStyledTextCtrl::GetSelectionStart() {
922 return SendMsg(2143, 0, 0);
925 // Sets the position that ends the selection - this becomes the currentPosition.
926 void wxStyledTextCtrl::SetSelectionEnd(int pos
) {
927 SendMsg(2144, pos
, 0);
930 // Returns the position at the end of the selection.
931 int wxStyledTextCtrl::GetSelectionEnd() {
932 return SendMsg(2145, 0, 0);
935 // Sets the print magnification added to the point size of each style for printing.
936 void wxStyledTextCtrl::SetPrintMagnification(int magnification
) {
937 SendMsg(2146, magnification
, 0);
940 // Returns the print magnification.
941 int wxStyledTextCtrl::GetPrintMagnification() {
942 return SendMsg(2147, 0, 0);
945 // Modify colours when printing for clearer printed text.
946 void wxStyledTextCtrl::SetPrintColourMode(int mode
) {
947 SendMsg(2148, mode
, 0);
950 // Returns the print colour mode.
951 int wxStyledTextCtrl::GetPrintColourMode() {
952 return SendMsg(2149, 0, 0);
955 // Find some text in the document.
956 int wxStyledTextCtrl::FindText(int minPos
, int maxPos
,
957 const wxString
& text
,
958 bool caseSensitive
, bool wholeWord
) {
962 flags
|= caseSensitive
? SCFIND_MATCHCASE
: 0;
963 flags
|= wholeWord
? SCFIND_WHOLEWORD
: 0;
964 ft
.chrg
.cpMin
= minPos
;
965 ft
.chrg
.cpMax
= maxPos
;
966 ft
.lpstrText
= (char*)text
.c_str();
968 return SendMsg(2150, flags
, (long)&ft
);
971 // On Windows will draw the document into a display context such as a printer.
972 int wxStyledTextCtrl::FormatRange(bool doDraw
,
976 wxDC
* target
, // Why does it use two? Can they be the same?
981 if (endPos
< startPos
) {
987 fr
.hdcTarget
= target
;
988 fr
.rc
.top
= renderRect
.GetTop();
989 fr
.rc
.left
= renderRect
.GetLeft();
990 fr
.rc
.right
= renderRect
.GetRight();
991 fr
.rc
.bottom
= renderRect
.GetBottom();
992 fr
.rcPage
.top
= pageRect
.GetTop();
993 fr
.rcPage
.left
= pageRect
.GetLeft();
994 fr
.rcPage
.right
= pageRect
.GetRight();
995 fr
.rcPage
.bottom
= pageRect
.GetBottom();
996 fr
.chrg
.cpMin
= startPos
;
997 fr
.chrg
.cpMax
= endPos
;
999 return SendMsg(2151, doDraw
, (long)&fr
);
1002 // Retrieve the line at the top of the display.
1003 int wxStyledTextCtrl::GetFirstVisibleLine() {
1004 return SendMsg(2152, 0, 0);
1007 // Retrieve the contents of a line.
1008 wxString
wxStyledTextCtrl::GetLine(int line
) {
1010 int len
= LineLength(line
);
1011 if (!len
) return "";
1012 char* buf
= text
.GetWriteBuf(len
);
1014 int pos
= SendMsg(2153, line
, (long)buf
);
1015 text
.UngetWriteBuf(len
);
1020 // Returns the number of lines in the document. There is always at least one.
1021 int wxStyledTextCtrl::GetLineCount() {
1022 return SendMsg(2154, 0, 0);
1025 // Sets the size in pixels of the left margin.
1026 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth
) {
1027 SendMsg(2155, 0, pixelWidth
);
1030 // Returns the size in pixels of the left margin.
1031 int wxStyledTextCtrl::GetMarginLeft() {
1032 return SendMsg(2156, 0, 0);
1035 // Sets the size in pixels of the right margin.
1036 void wxStyledTextCtrl::SetMarginRight(int pixelWidth
) {
1037 SendMsg(2157, 0, pixelWidth
);
1040 // Returns the size in pixels of the right margin.
1041 int wxStyledTextCtrl::GetMarginRight() {
1042 return SendMsg(2158, 0, 0);
1045 // Is the document different from when it was last saved?
1046 bool wxStyledTextCtrl::GetModify() {
1047 return SendMsg(2159, 0, 0) != 0;
1050 // Select a range of text.
1051 void wxStyledTextCtrl::SetSelection(int start
, int end
) {
1052 SendMsg(2160, start
, end
);
1055 // Retrieve the selected text.
1056 wxString
wxStyledTextCtrl::GetSelectedText() {
1061 GetSelection(&start
, &end
);
1062 int len
= end
- start
;
1063 if (!len
) return "";
1064 char* buff
= text
.GetWriteBuf(len
);
1066 SendMsg(2161, 0, (long)buff
);
1067 text
.UngetWriteBuf(len
);
1071 // Retrieve a range of text.
1072 wxString
wxStyledTextCtrl::GetTextRange(int startPos
, int endPos
) {
1074 if (endPos
< startPos
) {
1075 int temp
= startPos
;
1079 int len
= endPos
- startPos
;
1080 if (!len
) return "";
1081 char* buff
= text
.GetWriteBuf(len
);
1083 tr
.lpstrText
= buff
;
1084 tr
.chrg
.cpMin
= startPos
;
1085 tr
.chrg
.cpMax
= endPos
;
1087 SendMsg(2162, 0, (long)&tr
);
1088 text
.UngetWriteBuf(len
);
1092 // Draw the selection in normal style or with selection highlighted.
1093 void wxStyledTextCtrl::HideSelection(bool normal
) {
1094 SendMsg(2163, normal
, 0);
1097 // Retrieve the line containing a position.
1098 int wxStyledTextCtrl::LineFromPosition(int pos
) {
1099 return SendMsg(2166, pos
, 0);
1102 // Retrieve the position at the start of a line.
1103 int wxStyledTextCtrl::PositionFromLine(int line
) {
1104 return SendMsg(2167, line
, 0);
1107 // Scroll horizontally and vertically.
1108 void wxStyledTextCtrl::LineScroll(int columns
, int lines
) {
1109 SendMsg(2168, columns
, lines
);
1112 // Ensure the caret is visible.
1113 void wxStyledTextCtrl::EnsureCaretVisible() {
1114 SendMsg(2169, 0, 0);
1117 // Replace the selected text with the argument text.
1118 void wxStyledTextCtrl::ReplaceSelection(const wxString
& text
) {
1119 SendMsg(2170, 0, (long)text
.c_str());
1122 // Set to read only or read write.
1123 void wxStyledTextCtrl::SetReadOnly(bool readOnly
) {
1124 SendMsg(2171, readOnly
, 0);
1127 // Will a paste succeed?
1128 bool wxStyledTextCtrl::CanPaste() {
1129 return SendMsg(2173, 0, 0) != 0;
1132 // Are there any undoable actions in the undo history.
1133 bool wxStyledTextCtrl::CanUndo() {
1134 return SendMsg(2174, 0, 0) != 0;
1137 // Delete the undo history.
1138 void wxStyledTextCtrl::EmptyUndoBuffer() {
1139 SendMsg(2175, 0, 0);
1142 // Undo one action in the undo history.
1143 void wxStyledTextCtrl::Undo() {
1144 SendMsg(2176, 0, 0);
1147 // Cut the selection to the clipboard.
1148 void wxStyledTextCtrl::Cut() {
1149 SendMsg(2177, 0, 0);
1152 // Copy the selection to the clipboard.
1153 void wxStyledTextCtrl::Copy() {
1154 SendMsg(2178, 0, 0);
1157 // Paste the contents of the clipboard into the document replacing the selection.
1158 void wxStyledTextCtrl::Paste() {
1159 SendMsg(2179, 0, 0);
1162 // Clear the selection.
1163 void wxStyledTextCtrl::Clear() {
1164 SendMsg(2180, 0, 0);
1167 // Replace the contents of the document with the argument text.
1168 void wxStyledTextCtrl::SetText(const wxString
& text
) {
1169 SendMsg(2181, 0, (long)text
.c_str());
1172 // Retrieve all the text in the document.
1173 wxString
wxStyledTextCtrl::GetText() {
1175 int len
= GetTextLength();
1176 char* buff
= text
.GetWriteBuf(len
+1); // leave room for the null...
1178 SendMsg(2182, len
+1, (long)buff
);
1179 text
.UngetWriteBuf(len
);
1183 // Retrieve the number of characters in the document.
1184 int wxStyledTextCtrl::GetTextLength() {
1185 return SendMsg(2183, 0, 0);
1188 // Set to overtype (true) or insert mode
1189 void wxStyledTextCtrl::SetOvertype(bool overtype
) {
1190 SendMsg(2186, overtype
, 0);
1193 // Returns true if overtype mode is active otherwise false is returned.
1194 bool wxStyledTextCtrl::GetOvertype() {
1195 return SendMsg(2187, 0, 0) != 0;
1198 // Set the width of the insert mode caret
1199 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth
) {
1200 SendMsg(2188, pixelWidth
, 0);
1203 // Returns the width of the insert mode caret
1204 int wxStyledTextCtrl::GetCaretWidth() {
1205 return SendMsg(2189, 0, 0);
1208 // Sets the position that starts the target which is used for updating the
1209 // document without affecting the scroll position.
1210 void wxStyledTextCtrl::SetTargetStart(int pos
) {
1211 SendMsg(2190, pos
, 0);
1214 // Get the position that starts the target.
1215 int wxStyledTextCtrl::GetTargetStart() {
1216 return SendMsg(2191, 0, 0);
1219 // Sets the position that ends the target which is used for updating the
1220 // document without affecting the scroll position.
1221 void wxStyledTextCtrl::SetTargetEnd(int pos
) {
1222 SendMsg(2192, pos
, 0);
1225 // Get the position that ends the target.
1226 int wxStyledTextCtrl::GetTargetEnd() {
1227 return SendMsg(2193, 0, 0);
1230 // Replace the target text with the argument text.
1231 // Text is counted so it can contain nulls.
1232 // Returns the length of the replacement text.
1234 int wxStyledTextCtrl::ReplaceTarget(const wxString
& text
) {
1235 return SendMsg(2194, text
.Len(), (long)text
.c_str());
1239 // Replace the target text with the argument text after \d processing.
1240 // Text is counted so it can contain nulls.
1241 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1242 // matched in the last search operation which were surrounded by \( and \).
1243 // Returns the length of the replacement text including any change
1244 // caused by processing the \d patterns.
1246 int wxStyledTextCtrl::ReplaceTargetRE(const wxString
& text
) {
1247 return SendMsg(2195, text
.Len(), (long)text
.c_str());
1251 // Search for a counted string in the target and set the target to the found
1252 // range. Text is counted so it can contain nulls.
1253 // Returns length of range or -1 for failure in which case target is not moved.
1255 int wxStyledTextCtrl::SearchInTarget(const wxString
& text
) {
1256 return SendMsg(2197, text
.Len(), (long)text
.c_str());
1260 // Set the search flags used by SearchInTarget
1261 void wxStyledTextCtrl::SetSearchFlags(int flags
) {
1262 SendMsg(2198, flags
, 0);
1265 // Get the search flags used by SearchInTarget
1266 int wxStyledTextCtrl::GetSearchFlags() {
1267 return SendMsg(2199, 0, 0);
1270 // Show a call tip containing a definition near position pos.
1271 void wxStyledTextCtrl::CallTipShow(int pos
, const wxString
& definition
) {
1272 SendMsg(2200, pos
, (long)definition
.c_str());
1275 // Remove the call tip from the screen.
1276 void wxStyledTextCtrl::CallTipCancel() {
1277 SendMsg(2201, 0, 0);
1280 // Is there an active call tip?
1281 bool wxStyledTextCtrl::CallTipActive() {
1282 return SendMsg(2202, 0, 0) != 0;
1285 // Retrieve the position where the caret was before displaying the call tip.
1286 int wxStyledTextCtrl::CallTipPosAtStart() {
1287 return SendMsg(2203, 0, 0);
1290 // Highlight a segment of the definition.
1291 void wxStyledTextCtrl::CallTipSetHighlight(int start
, int end
) {
1292 SendMsg(2204, start
, end
);
1295 // Set the background colour for the call tip.
1296 void wxStyledTextCtrl::CallTipSetBackground(const wxColour
& back
) {
1297 SendMsg(2205, wxColourAsLong(back
), 0);
1300 // Find the display line of a document line taking hidden lines into account.
1301 int wxStyledTextCtrl::VisibleFromDocLine(int line
) {
1302 return SendMsg(2220, line
, 0);
1305 // Find the document line of a display line taking hidden lines into account.
1306 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay
) {
1307 return SendMsg(2221, lineDisplay
, 0);
1310 // Set the fold level of a line.
1311 // This encodes an integer level along with flags indicating whether the
1312 // line is a header and whether it is effectively white space.
1313 void wxStyledTextCtrl::SetFoldLevel(int line
, int level
) {
1314 SendMsg(2222, line
, level
);
1317 // Retrieve the fold level of a line.
1318 int wxStyledTextCtrl::GetFoldLevel(int line
) {
1319 return SendMsg(2223, line
, 0);
1322 // Find the last child line of a header line.
1323 int wxStyledTextCtrl::GetLastChild(int line
, int level
) {
1324 return SendMsg(2224, line
, level
);
1327 // Find the parent line of a child line.
1328 int wxStyledTextCtrl::GetFoldParent(int line
) {
1329 return SendMsg(2225, line
, 0);
1332 // Make a range of lines visible.
1333 void wxStyledTextCtrl::ShowLines(int lineStart
, int lineEnd
) {
1334 SendMsg(2226, lineStart
, lineEnd
);
1337 // Make a range of lines invisible.
1338 void wxStyledTextCtrl::HideLines(int lineStart
, int lineEnd
) {
1339 SendMsg(2227, lineStart
, lineEnd
);
1342 // Is a line visible?
1343 bool wxStyledTextCtrl::GetLineVisible(int line
) {
1344 return SendMsg(2228, line
, 0) != 0;
1347 // Show the children of a header line.
1348 void wxStyledTextCtrl::SetFoldExpanded(int line
, bool expanded
) {
1349 SendMsg(2229, line
, expanded
);
1352 // Is a header line expanded?
1353 bool wxStyledTextCtrl::GetFoldExpanded(int line
) {
1354 return SendMsg(2230, line
, 0) != 0;
1357 // Switch a header line between expanded and contracted.
1358 void wxStyledTextCtrl::ToggleFold(int line
) {
1359 SendMsg(2231, line
, 0);
1362 // Ensure a particular line is visible by expanding any header line hiding it.
1363 void wxStyledTextCtrl::EnsureVisible(int line
) {
1364 SendMsg(2232, line
, 0);
1367 // Set some debugging options for folding
1368 void wxStyledTextCtrl::SetFoldFlags(int flags
) {
1369 SendMsg(2233, flags
, 0);
1372 // Ensure a particular line is visible by expanding any header line hiding it.
1373 // Use the currently set visibility policy to determine which range to display.
1374 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line
) {
1375 SendMsg(2234, line
, 0);
1378 // Sets whether a tab pressed when caret is within indentation indents
1379 void wxStyledTextCtrl::SetTabIndents(bool tabIndents
) {
1380 SendMsg(2260, tabIndents
, 0);
1383 // Does a tab pressed when caret is within indentation indent?
1384 bool wxStyledTextCtrl::GetTabIndents() {
1385 return SendMsg(2261, 0, 0) != 0;
1388 // Sets whether a backspace pressed when caret is within indentation unindents
1389 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents
) {
1390 SendMsg(2262, bsUnIndents
, 0);
1393 // Does a backspace pressed when caret is within indentation unindent?
1394 bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1395 return SendMsg(2263, 0, 0) != 0;
1398 // Sets the time the mouse must sit still to generate a mouse dwell event
1399 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds
) {
1400 SendMsg(2264, periodMilliseconds
, 0);
1403 // Retrieve the time the mouse must sit still to generate a mouse dwell event
1404 int wxStyledTextCtrl::GetMouseDwellTime() {
1405 return SendMsg(2265, 0, 0);
1408 // Move the caret inside current view if it's not there already
1409 void wxStyledTextCtrl::MoveCaretInsideView() {
1410 SendMsg(2401, 0, 0);
1413 // How many characters are on a line, not including end of line characters.
1414 int wxStyledTextCtrl::LineLength(int line
) {
1415 return SendMsg(2350, line
, 0);
1418 // Highlight the characters at two positions.
1419 void wxStyledTextCtrl::BraceHighlight(int pos1
, int pos2
) {
1420 SendMsg(2351, pos1
, pos2
);
1423 // Highlight the character at a position indicating there is no matching brace.
1424 void wxStyledTextCtrl::BraceBadLight(int pos
) {
1425 SendMsg(2352, pos
, 0);
1428 // Find the position of a matching brace or INVALID_POSITION if no match.
1429 int wxStyledTextCtrl::BraceMatch(int pos
) {
1430 return SendMsg(2353, pos
, 0);
1433 // Are the end of line characters visible.
1434 bool wxStyledTextCtrl::GetViewEOL() {
1435 return SendMsg(2355, 0, 0) != 0;
1438 // Make the end of line characters visible or invisible
1439 void wxStyledTextCtrl::SetViewEOL(bool visible
) {
1440 SendMsg(2356, visible
, 0);
1443 // Retrieve a pointer to the document object.
1444 void* wxStyledTextCtrl::GetDocPointer() {
1445 return (void*)SendMsg(2357);
1448 // Change the document object used.
1449 void wxStyledTextCtrl::SetDocPointer(void* docPointer
) {
1450 SendMsg(2358, 0, (long)docPointer
);
1453 // Set which document modification events are sent to the container.
1454 void wxStyledTextCtrl::SetModEventMask(int mask
) {
1455 SendMsg(2359, mask
, 0);
1458 // Retrieve the column number which text should be kept within.
1459 int wxStyledTextCtrl::GetEdgeColumn() {
1460 return SendMsg(2360, 0, 0);
1463 // Set the column number of the edge.
1464 // If text goes past the edge then it is highlighted.
1465 void wxStyledTextCtrl::SetEdgeColumn(int column
) {
1466 SendMsg(2361, column
, 0);
1469 // Retrieve the edge highlight mode.
1470 int wxStyledTextCtrl::GetEdgeMode() {
1471 return SendMsg(2362, 0, 0);
1474 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
1475 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
1476 void wxStyledTextCtrl::SetEdgeMode(int mode
) {
1477 SendMsg(2363, mode
, 0);
1480 // Retrieve the colour used in edge indication.
1481 wxColour
wxStyledTextCtrl::GetEdgeColour() {
1482 long c
= SendMsg(2364, 0, 0);
1483 return wxColourFromLong(c
);
1486 // Change the colour used in edge indication.
1487 void wxStyledTextCtrl::SetEdgeColour(const wxColour
& edgeColour
) {
1488 SendMsg(2365, wxColourAsLong(edgeColour
), 0);
1491 // Sets the current caret position to be the search anchor.
1492 void wxStyledTextCtrl::SearchAnchor() {
1493 SendMsg(2366, 0, 0);
1496 // Find some text starting at the search anchor.
1497 // Does not ensure the selection is visible.
1498 int wxStyledTextCtrl::SearchNext(int flags
, const wxString
& text
) {
1499 return SendMsg(2367, flags
, (long)text
.c_str());
1502 // Find some text starting at the search anchor and moving backwards.
1503 // Does not ensure the selection is visible.
1504 int wxStyledTextCtrl::SearchPrev(int flags
, const wxString
& text
) {
1505 return SendMsg(2368, flags
, (long)text
.c_str());
1508 // Set the way the line the caret is on is kept visible.
1509 void wxStyledTextCtrl::SetCaretPolicy(int caretPolicy
, int caretSlop
) {
1510 SendMsg(2369, caretPolicy
, caretSlop
);
1513 // Retrieves the number of lines completely visible.
1514 int wxStyledTextCtrl::LinesOnScreen() {
1515 return SendMsg(2370, 0, 0);
1518 // Set whether a pop up menu is displayed automatically when the user presses
1519 // the wrong mouse button.
1520 void wxStyledTextCtrl::UsePopUp(bool allowPopUp
) {
1521 SendMsg(2371, allowPopUp
, 0);
1524 // Is the selection a rectangular. The alternative is the more common stream selection.
1525 bool wxStyledTextCtrl::SelectionIsRectangle() {
1526 return SendMsg(2372, 0, 0) != 0;
1529 // Set the zoom level. This number of points is added to the size of all fonts.
1530 // It may be positive to magnify or negative to reduce.
1531 void wxStyledTextCtrl::SetZoom(int zoom
) {
1532 SendMsg(2373, zoom
, 0);
1535 // Retrieve the zoom level.
1536 int wxStyledTextCtrl::GetZoom() {
1537 return SendMsg(2374, 0, 0);
1540 // Create a new document object.
1541 // Starts with reference count of 1 and not selected into editor.
1542 void* wxStyledTextCtrl::CreateDocument() {
1543 return (void*)SendMsg(2375);
1546 // Extend life of document.
1547 void wxStyledTextCtrl::AddRefDocument(void* docPointer
) {
1548 SendMsg(2376, (long)docPointer
);
1551 // Release a reference to the document, deleting document if it fades to black.
1552 void wxStyledTextCtrl::ReleaseDocument(void* docPointer
) {
1553 SendMsg(2377, (long)docPointer
);
1556 // Get which document modification events are sent to the container.
1557 int wxStyledTextCtrl::GetModEventMask() {
1558 return SendMsg(2378, 0, 0);
1561 // Change internal focus flag
1562 void wxStyledTextCtrl::SetSTCFocus(bool focus
) {
1563 SendMsg(2380, focus
, 0);
1566 // Get internal focus flag
1567 bool wxStyledTextCtrl::GetSTCFocus() {
1568 return SendMsg(2381, 0, 0) != 0;
1571 // Change error status - 0 = OK
1572 void wxStyledTextCtrl::SetStatus(int statusCode
) {
1573 SendMsg(2382, statusCode
, 0);
1577 int wxStyledTextCtrl::GetStatus() {
1578 return SendMsg(2383, 0, 0);
1581 // Set whether the mouse is captured when its button is pressed
1582 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures
) {
1583 SendMsg(2384, captures
, 0);
1586 // Get whether mouse gets captured
1587 bool wxStyledTextCtrl::GetMouseDownCaptures() {
1588 return SendMsg(2385, 0, 0) != 0;
1591 // Sets the cursor to one of the SC_CURSOR* values
1592 void wxStyledTextCtrl::SetCursor(int cursorType
) {
1593 SendMsg(2386, cursorType
, 0);
1597 int wxStyledTextCtrl::GetCursor() {
1598 return SendMsg(2387, 0, 0);
1601 // Move to the previous change in capitalistion
1602 void wxStyledTextCtrl::WordPartLeft() {
1603 SendMsg(2390, 0, 0);
1606 // Move to the previous change in capitalistion extending selection to new caret position.
1607 void wxStyledTextCtrl::WordPartLeftExtend() {
1608 SendMsg(2391, 0, 0);
1611 // Move to the change next in capitalistion
1612 void wxStyledTextCtrl::WordPartRight() {
1613 SendMsg(2392, 0, 0);
1616 // Move to the next change in capitalistion extending selection to new caret position.
1617 void wxStyledTextCtrl::WordPartRightExtend() {
1618 SendMsg(2393, 0, 0);
1621 // Set the way the display area is determined when a particular line is to be moved to.
1622 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy
, int visibleSlop
) {
1623 SendMsg(2394, visiblePolicy
, visibleSlop
);
1626 // Delete back from the current position to the start of the line
1627 void wxStyledTextCtrl::DelLineLeft() {
1628 SendMsg(2395, 0, 0);
1631 // Delete forwards from the current position to the end of the line
1632 void wxStyledTextCtrl::DelLineRight() {
1633 SendMsg(2396, 0, 0);
1636 // Start notifying the container of all key presses and commands.
1637 void wxStyledTextCtrl::StartRecord() {
1638 SendMsg(3001, 0, 0);
1641 // Stop notifying the container of all key presses and commands.
1642 void wxStyledTextCtrl::StopRecord() {
1643 SendMsg(3002, 0, 0);
1646 // Set the lexing language of the document.
1647 void wxStyledTextCtrl::SetLexer(int lexer
) {
1648 SendMsg(4001, lexer
, 0);
1651 // Retrieve the lexing language of the document.
1652 int wxStyledTextCtrl::GetLexer() {
1653 return SendMsg(4002, 0, 0);
1656 // Colourise a segment of the document using the current lexing language.
1657 void wxStyledTextCtrl::Colourise(int start
, int end
) {
1658 SendMsg(4003, start
, end
);
1661 // Set up a value that may be used by a lexer for some optional feature.
1662 void wxStyledTextCtrl::SetProperty(const wxString
& key
, const wxString
& value
) {
1663 SendMsg(4004, (long)key
.c_str(), (long)value
.c_str());
1666 // Set up the key words used by the lexer.
1667 void wxStyledTextCtrl::SetKeyWords(int keywordSet
, const wxString
& keyWords
) {
1668 SendMsg(4005, keywordSet
, (long)keyWords
.c_str());
1671 // Set the lexing language of the document based on string name.
1672 void wxStyledTextCtrl::SetLexerLanguage(const wxString
& language
) {
1673 SendMsg(4006, 0, (long)language
.c_str());
1676 // END of generated section
1677 //----------------------------------------------------------------------
1680 // Returns the line number of the line with the caret.
1681 int wxStyledTextCtrl::GetCurrentLine() {
1682 int line
= LineFromPosition(GetCurrentPos());
1687 // Extract style settings from a spec-string which is composed of one or
1688 // more of the following comma separated elements:
1690 // bold turns on bold
1691 // italic turns on italics
1692 // fore:#RRGGBB sets the foreground colour
1693 // back:#RRGGBB sets the background colour
1694 // face:[facename] sets the font face name to use
1695 // size:[num] sets the font size in points
1696 // eol turns on eol filling
1697 // underline turns on underlining
1699 void wxStyledTextCtrl::StyleSetSpec(int styleNum
, const wxString
& spec
) {
1701 wxStringTokenizer
tkz(spec
, ",");
1702 while (tkz
.HasMoreTokens()) {
1703 wxString token
= tkz
.GetNextToken();
1705 wxString option
= token
.BeforeFirst(':');
1706 wxString val
= token
.AfterFirst(':');
1708 if (option
== "bold")
1709 StyleSetBold(styleNum
, true);
1711 else if (option
== "italic")
1712 StyleSetItalic(styleNum
, true);
1714 else if (option
== "underline")
1715 StyleSetUnderline(styleNum
, true);
1717 else if (option
== "eol")
1718 StyleSetEOLFilled(styleNum
, true);
1720 else if (option
== "size") {
1722 if (val
.ToLong(&points
))
1723 StyleSetSize(styleNum
, points
);
1726 else if (option
== "face")
1727 StyleSetFaceName(styleNum
, val
);
1729 else if (option
== "fore")
1730 StyleSetForeground(styleNum
, wxColourFromSpec(val
));
1732 else if (option
== "back")
1733 StyleSetBackground(styleNum
, wxColourFromSpec(val
));
1738 // Set style size, face, bold, italic, and underline attributes from
1739 // a wxFont's attributes.
1740 void wxStyledTextCtrl::StyleSetFont(int styleNum
, wxFont
& font
) {
1741 int size
= font
.GetPointSize();
1742 wxString faceName
= font
.GetFaceName();
1743 bool bold
= font
.GetWeight() == wxBOLD
;
1744 bool italic
= font
.GetStyle() != wxNORMAL
;
1745 bool under
= font
.GetUnderlined();
1747 // TODO: add encoding/charset mapping
1748 StyleSetFontAttr(styleNum
, size
, faceName
, bold
, italic
, under
);
1751 // Set all font style attributes at once.
1752 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum
, int size
,
1753 const wxString
& faceName
,
1754 bool bold
, bool italic
,
1756 StyleSetSize(styleNum
, size
);
1757 StyleSetFaceName(styleNum
, faceName
);
1758 StyleSetBold(styleNum
, bold
);
1759 StyleSetItalic(styleNum
, italic
);
1760 StyleSetUnderline(styleNum
, underline
);
1762 // TODO: add encoding/charset mapping
1766 // Perform one of the operations defined by the wxSTC_CMD_* constants.
1767 void wxStyledTextCtrl::CmdKeyExecute(int cmd
) {
1772 // Set the left and right margin in the edit area, measured in pixels.
1773 void wxStyledTextCtrl::SetMargins(int left
, int right
) {
1774 SetMarginLeft(left
);
1775 SetMarginRight(right
);
1779 // Retrieve the start and end positions of the current selection.
1780 void wxStyledTextCtrl::GetSelection(int* startPos
, int* endPos
) {
1781 if (startPos
!= NULL
)
1782 *startPos
= SendMsg(SCI_GETSELECTIONSTART
);
1784 *endPos
= SendMsg(SCI_GETSELECTIONEND
);
1788 // Retrieve the point in the window where a position is displayed.
1789 wxPoint
wxStyledTextCtrl::PointFromPosition(int pos
) {
1790 int x
= SendMsg(SCI_POINTXFROMPOSITION
, 0, pos
);
1791 int y
= SendMsg(SCI_POINTYFROMPOSITION
, 0, pos
);
1792 return wxPoint(x
, y
);
1795 // Scroll enough to make the given line visible
1796 void wxStyledTextCtrl::ScrollToLine(int line
) {
1797 m_swx
->DoScrollToLine(line
);
1801 // Scroll enough to make the given column visible
1802 void wxStyledTextCtrl::ScrollToColumn(int column
) {
1803 m_swx
->DoScrollToColumn(column
);
1808 //----------------------------------------------------------------------
1811 void wxStyledTextCtrl::OnPaint(wxPaintEvent
& evt
) {
1813 wxRegion region
= GetUpdateRegion();
1815 m_swx
->DoPaint(&dc
, region
.GetBox());
1818 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent
& evt
) {
1819 if (evt
.GetOrientation() == wxHORIZONTAL
)
1820 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
1822 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
1825 void wxStyledTextCtrl::OnScroll(wxScrollEvent
& evt
) {
1826 wxScrollBar
* sb
= wxDynamicCast(evt
.GetEventObject(), wxScrollBar
);
1828 if (sb
->IsVertical())
1829 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
1831 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
1835 void wxStyledTextCtrl::OnSize(wxSizeEvent
& evt
) {
1836 wxSize sz
= GetClientSize();
1837 m_swx
->DoSize(sz
.x
, sz
.y
);
1840 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent
& evt
) {
1841 wxPoint pt
= evt
.GetPosition();
1842 m_swx
->DoButtonDown(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
1843 evt
.ShiftDown(), evt
.ControlDown(), evt
.AltDown());
1846 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent
& evt
) {
1847 wxPoint pt
= evt
.GetPosition();
1848 m_swx
->DoButtonMove(Point(pt
.x
, pt
.y
));
1851 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent
& evt
) {
1852 wxPoint pt
= evt
.GetPosition();
1853 m_swx
->DoButtonUp(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
1858 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent
& evt
) {
1859 wxPoint pt
= evt
.GetPosition();
1860 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
1864 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent
& evt
) {
1865 wxPoint pt
= evt
.GetPosition();
1866 ScreenToClient(&pt
.x
, &pt
.y
);
1867 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
1871 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent
& evt
) {
1872 m_swx
->DoMouseWheel(evt
.GetWheelRotation(),
1873 evt
.GetWheelDelta(),
1874 evt
.GetLinesPerAction(),
1879 void wxStyledTextCtrl::OnChar(wxKeyEvent
& evt
) {
1880 long key
= evt
.KeyCode();
1882 // printf("OnChar key:%d consumed:%d ctrl:%d alt:%d\n",
1883 // key, m_lastKeyDownConsumed, evt.ControlDown(), evt.AltDown());
1886 // \|@#¬[]{}?£$~ ã,õ,Ã,Õ, ñ, Ñ
1888 // On (some?) non-US keyboards the AltGr key is required to enter some
1889 // common characters. It comes to us as both Alt and Ctrl down so we need
1890 // to let the char through in that case, otherwise if only ctrl or only
1891 // alt let's skip it.
1892 bool ctrl
= evt
.ControlDown();
1893 bool alt
= evt
.AltDown();
1894 bool skip
= ((ctrl
|| alt
) && ! (ctrl
&& alt
));
1896 if (key
<= 0xff && key
>= 32 && !m_lastKeyDownConsumed
&& !skip
) {
1897 m_swx
->DoAddChar(key
);
1904 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent
& evt
) {
1905 long key
= evt
.KeyCode();
1906 bool shift
= evt
.ShiftDown(),
1907 ctrl
= evt
.ControlDown(),
1908 alt
= evt
.AltDown();
1910 int processed
= m_swx
->DoKeyDown(key
, shift
, ctrl
, alt
, &m_lastKeyDownConsumed
);
1912 // printf("key: %d shift: %d ctrl: %d alt: %d processed: %d consumed: %d\n",
1913 // key, shift, ctrl, alt, processed, m_lastKeyDownConsumed);
1915 if (!processed
&& !m_lastKeyDownConsumed
)
1920 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent
& evt
) {
1921 m_swx
->DoLoseFocus();
1925 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent
& evt
) {
1926 m_swx
->DoGainFocus();
1930 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent
& evt
) {
1931 m_swx
->DoSysColourChange();
1935 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent
& evt
) {
1936 // do nothing to help avoid flashing
1941 void wxStyledTextCtrl::OnMenu(wxCommandEvent
& evt
) {
1942 m_swx
->DoCommand(evt
.GetId());
1946 void wxStyledTextCtrl::OnListBox(wxCommandEvent
& evt
) {
1947 m_swx
->DoOnListBox();
1951 //----------------------------------------------------------------------
1952 // Turn notifications from Scintilla into events
1955 void wxStyledTextCtrl::NotifyChange() {
1956 wxStyledTextEvent
evt(wxEVT_STC_CHANGE
, GetId());
1957 evt
.SetEventObject(this);
1958 GetEventHandler()->ProcessEvent(evt
);
1961 void wxStyledTextCtrl::NotifyParent(SCNotification
* _scn
) {
1962 SCNotification
& scn
= *_scn
;
1963 wxStyledTextEvent
evt(0, GetId());
1965 evt
.SetEventObject(this);
1966 evt
.SetPosition(scn
.position
);
1968 evt
.SetModifiers(scn
.modifiers
);
1970 switch (scn
.nmhdr
.code
) {
1971 case SCN_STYLENEEDED
:
1972 evt
.SetEventType(wxEVT_STC_STYLENEEDED
);
1976 evt
.SetEventType(wxEVT_STC_CHARADDED
);
1979 case SCN_SAVEPOINTREACHED
:
1980 evt
.SetEventType(wxEVT_STC_SAVEPOINTREACHED
);
1983 case SCN_SAVEPOINTLEFT
:
1984 evt
.SetEventType(wxEVT_STC_SAVEPOINTLEFT
);
1987 case SCN_MODIFYATTEMPTRO
:
1988 evt
.SetEventType(wxEVT_STC_ROMODIFYATTEMPT
);
1992 evt
.SetEventType(wxEVT_STC_KEY
);
1995 case SCN_DOUBLECLICK
:
1996 evt
.SetEventType(wxEVT_STC_DOUBLECLICK
);
2000 evt
.SetEventType(wxEVT_STC_UPDATEUI
);
2004 evt
.SetEventType(wxEVT_STC_MODIFIED
);
2005 evt
.SetModificationType(scn
.modificationType
);
2007 evt
.SetText(wxString(scn
.text
, scn
.length
));
2008 evt
.SetLength(scn
.length
);
2009 evt
.SetLinesAdded(scn
.linesAdded
);
2010 evt
.SetLine(scn
.line
);
2011 evt
.SetFoldLevelNow(scn
.foldLevelNow
);
2012 evt
.SetFoldLevelPrev(scn
.foldLevelPrev
);
2015 case SCN_MACRORECORD
:
2016 evt
.SetEventType(wxEVT_STC_MACRORECORD
);
2017 evt
.SetMessage(scn
.message
);
2018 evt
.SetWParam(scn
.wParam
);
2019 evt
.SetLParam(scn
.lParam
);
2022 case SCN_MARGINCLICK
:
2023 evt
.SetEventType(wxEVT_STC_MARGINCLICK
);
2024 evt
.SetMargin(scn
.margin
);
2028 evt
.SetEventType(wxEVT_STC_NEEDSHOWN
);
2029 evt
.SetLength(scn
.length
);
2032 case SCN_POSCHANGED
:
2033 evt
.SetEventType(wxEVT_STC_POSCHANGED
);
2037 evt
.SetEventType(wxEVT_STC_PAINTED
);
2040 case SCN_USERLISTSELECTION
:
2041 evt
.SetEventType(wxEVT_STC_USERLISTSELECTION
);
2042 evt
.SetListType(scn
.listType
);
2043 evt
.SetText(scn
.text
);
2046 case SCN_URIDROPPED
:
2047 evt
.SetEventType(wxEVT_STC_URIDROPPED
);
2048 evt
.SetText(scn
.text
);
2051 case SCN_DWELLSTART
:
2052 evt
.SetEventType(wxEVT_STC_DWELLSTART
);
2058 evt
.SetEventType(wxEVT_STC_DWELLEND
);
2067 GetEventHandler()->ProcessEvent(evt
);
2071 //----------------------------------------------------------------------
2072 //----------------------------------------------------------------------
2073 //----------------------------------------------------------------------
2075 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType
, int id
)
2076 : wxCommandEvent(commandType
, id
)
2081 m_modificationType
= 0;
2086 m_foldLevelPrev
= 0;
2094 m_dragAllowMove
= FALSE
;
2095 m_dragResult
= wxDragNone
;
2098 bool wxStyledTextEvent::GetShift() const { return (m_modifiers
& SCI_SHIFT
) != 0; }
2099 bool wxStyledTextEvent::GetControl() const { return (m_modifiers
& SCI_CTRL
) != 0; }
2100 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers
& SCI_ALT
) != 0; }
2103 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent
& event
):
2104 wxCommandEvent(event
)
2106 m_position
= event
.m_position
;
2107 m_key
= event
.m_key
;
2108 m_modifiers
= event
.m_modifiers
;
2109 m_modificationType
= event
.m_modificationType
;
2110 m_text
= event
.m_text
;
2111 m_length
= event
.m_length
;
2112 m_linesAdded
= event
.m_linesAdded
;
2113 m_line
= event
.m_line
;
2114 m_foldLevelNow
= event
.m_foldLevelNow
;
2115 m_foldLevelPrev
= event
.m_foldLevelPrev
;
2117 m_margin
= event
.m_margin
;
2119 m_message
= event
.m_message
;
2120 m_wParam
= event
.m_wParam
;
2121 m_lParam
= event
.m_lParam
;
2123 m_listType
= event
.m_listType
;
2127 m_dragText
= event
.m_dragText
;
2128 m_dragAllowMove
=event
.m_dragAllowMove
;
2129 m_dragResult
= event
.m_dragResult
;
2132 //----------------------------------------------------------------------
2133 //----------------------------------------------------------------------