1 ////////////////////////////////////////////////////////////////////////////
3 // Purpose: A wxWidgets 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 /////////////////////////////////////////////////////////////////////////////
18 // For compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
27 #include "wx/stc/stc.h"
28 #include "wx/stc/private.h"
36 #include "wx/tokenzr.h"
37 #include "wx/mstream.h"
41 #include "ScintillaWX.h"
43 //----------------------------------------------------------------------
45 const wxChar
* wxSTCNameStr
= wxT("stcwindow");
51 #define MAKELONG(a, b) ((a) | ((b) << 16))
54 static long wxColourAsLong(const wxColour
& co
) {
55 return (((long)co
.Blue() << 16) |
56 ((long)co
.Green() << 8) |
60 static wxColour
wxColourFromLong(long c
) {
62 clr
.Set((unsigned char)(c
& 0xff),
63 (unsigned char)((c
>> 8) & 0xff),
64 (unsigned char)((c
>> 16) & 0xff));
69 static wxColour
wxColourFromSpec(const wxString
& spec
) {
70 // spec should be a colour name or "#RRGGBB"
71 if (spec
.GetChar(0) == wxT('#')) {
73 long red
, green
, blue
;
74 red
= green
= blue
= 0;
75 spec
.Mid(1,2).ToLong(&red
, 16);
76 spec
.Mid(3,2).ToLong(&green
, 16);
77 spec
.Mid(5,2).ToLong(&blue
, 16);
78 return wxColour((unsigned char)red
,
83 return wxColour(spec
);
86 //----------------------------------------------------------------------
88 DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE
)
89 DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED
)
90 DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED
)
91 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED
)
92 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT
)
93 DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT
)
94 DEFINE_EVENT_TYPE( wxEVT_STC_KEY
)
95 DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK
)
96 DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI
)
97 DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED
)
98 DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD
)
99 DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK
)
100 DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN
)
101 DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED
)
102 DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION
)
103 DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED
)
104 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART
)
105 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND
)
106 DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG
)
107 DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER
)
108 DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP
)
109 DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM
)
110 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK
)
111 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK
)
112 DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK
)
113 DEFINE_EVENT_TYPE( wxEVT_STC_AUTOCOMP_SELECTION
)
117 BEGIN_EVENT_TABLE(wxStyledTextCtrl
, wxControl
)
118 EVT_PAINT (wxStyledTextCtrl::OnPaint
)
119 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin
)
120 EVT_SCROLL (wxStyledTextCtrl::OnScroll
)
121 EVT_SIZE (wxStyledTextCtrl::OnSize
)
122 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown
)
123 // Let Scintilla see the double click as a second click
124 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown
)
125 EVT_MOTION (wxStyledTextCtrl::OnMouseMove
)
126 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp
)
127 #if defined(__WXGTK__) || defined(__WXMAC__)
128 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp
)
130 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu
)
132 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel
)
133 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp
)
134 EVT_CHAR (wxStyledTextCtrl::OnChar
)
135 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown
)
136 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus
)
137 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus
)
138 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged
)
139 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground
)
140 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu
)
141 EVT_LISTBOX_DCLICK (wxID_ANY
, wxStyledTextCtrl::OnListBox
)
145 IMPLEMENT_CLASS(wxStyledTextCtrl
, wxControl
)
146 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent
, wxCommandEvent
)
149 // forces the linking of the lexer modules
150 int Scintilla_LinkLexers();
153 //----------------------------------------------------------------------
154 // Constructor and Destructor
156 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow
*parent
,
161 const wxString
& name
)
164 Create(parent
, id
, pos
, size
, style
, name
);
168 bool wxStyledTextCtrl::Create(wxWindow
*parent
,
173 const wxString
& name
)
175 style
|= wxVSCROLL
| wxHSCROLL
;
176 if (!wxControl::Create(parent
, id
, pos
, size
,
177 style
| wxWANTS_CHARS
| wxCLIP_CHILDREN
,
178 wxDefaultValidator
, name
))
182 Scintilla_LinkLexers();
184 m_swx
= new ScintillaWX(this);
186 m_lastKeyDownConsumed
= false;
190 // Put Scintilla into unicode (UTF-8) mode
191 SetCodePage(wxSTC_CP_UTF8
);
194 SetInitialSize(size
);
196 // Reduces flicker on GTK+/X11
197 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
202 wxStyledTextCtrl::~wxStyledTextCtrl() {
207 //----------------------------------------------------------------------
209 long wxStyledTextCtrl::SendMsg(int msg
, long wp
, long lp
) {
211 return m_swx
->WndProc(msg
, wp
, lp
);
214 //----------------------------------------------------------------------
216 // Set the vertical scrollbar to use instead of the ont that's built-in.
217 void wxStyledTextCtrl::SetVScrollBar(wxScrollBar
* bar
) {
220 // ensure that the built-in scrollbar is not visible
221 SetScrollbar(wxVERTICAL
, 0, 0, 0);
226 // Set the horizontal scrollbar to use instead of the ont that's built-in.
227 void wxStyledTextCtrl::SetHScrollBar(wxScrollBar
* bar
) {
230 // ensure that the built-in scrollbar is not visible
231 SetScrollbar(wxHORIZONTAL
, 0, 0, 0);
235 //----------------------------------------------------------------------
236 // BEGIN generated section. The following code is automatically generated
237 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
238 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
241 // Add text to the document at current position.
242 void wxStyledTextCtrl::AddText(const wxString
& text
) {
243 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
244 SendMsg(2001, strlen(buf
), (long)(const char*)buf
);
247 // Add array of cells to document.
248 void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer
& data
) {
249 SendMsg(2002, data
.GetDataLen(), (long)data
.GetData());
252 // Insert string at a position.
253 void wxStyledTextCtrl::InsertText(int pos
, const wxString
& text
) {
254 SendMsg(2003, pos
, (long)(const char*)wx2stc(text
));
257 // Delete all text in the document.
258 void wxStyledTextCtrl::ClearAll() {
262 // Set all style bytes to 0, remove all folding information.
263 void wxStyledTextCtrl::ClearDocumentStyle() {
267 // Returns the number of characters in the document.
268 int wxStyledTextCtrl::GetLength() {
269 return SendMsg(2006, 0, 0);
272 // Returns the character byte at the position.
273 int wxStyledTextCtrl::GetCharAt(int pos
) {
274 return (unsigned char)SendMsg(2007, pos
, 0);
277 // Returns the position of the caret.
278 int wxStyledTextCtrl::GetCurrentPos() {
279 return SendMsg(2008, 0, 0);
282 // Returns the position of the opposite end of the selection to the caret.
283 int wxStyledTextCtrl::GetAnchor() {
284 return SendMsg(2009, 0, 0);
287 // Returns the style byte at the position.
288 int wxStyledTextCtrl::GetStyleAt(int pos
) {
289 return (unsigned char)SendMsg(2010, pos
, 0);
292 // Redoes the next action on the undo history.
293 void wxStyledTextCtrl::Redo() {
297 // Choose between collecting actions into the undo
298 // history and discarding them.
299 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo
) {
300 SendMsg(2012, collectUndo
, 0);
303 // Select all the text in the document.
304 void wxStyledTextCtrl::SelectAll() {
308 // Remember the current position in the undo history as the position
309 // at which the document was saved.
310 void wxStyledTextCtrl::SetSavePoint() {
314 // Retrieve a buffer of cells.
315 wxMemoryBuffer
wxStyledTextCtrl::GetStyledText(int startPos
, int endPos
) {
317 if (endPos
< startPos
) {
322 int len
= endPos
- startPos
;
323 if (!len
) return buf
;
325 tr
.lpstrText
= (char*)buf
.GetWriteBuf(len
*2+1);
326 tr
.chrg
.cpMin
= startPos
;
327 tr
.chrg
.cpMax
= endPos
;
328 len
= SendMsg(2015, 0, (long)&tr
);
329 buf
.UngetWriteBuf(len
);
333 // Are there any redoable actions in the undo history?
334 bool wxStyledTextCtrl::CanRedo() {
335 return SendMsg(2016, 0, 0) != 0;
338 // Retrieve the line number at which a particular marker is located.
339 int wxStyledTextCtrl::MarkerLineFromHandle(int handle
) {
340 return SendMsg(2017, handle
, 0);
344 void wxStyledTextCtrl::MarkerDeleteHandle(int handle
) {
345 SendMsg(2018, handle
, 0);
348 // Is undo history being collected?
349 bool wxStyledTextCtrl::GetUndoCollection() {
350 return SendMsg(2019, 0, 0) != 0;
353 // Are white space characters currently visible?
354 // Returns one of SCWS_* constants.
355 int wxStyledTextCtrl::GetViewWhiteSpace() {
356 return SendMsg(2020, 0, 0);
359 // Make white space characters invisible, always visible or visible outside indentation.
360 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS
) {
361 SendMsg(2021, viewWS
, 0);
364 // Find the position from a point within the window.
365 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt
) {
366 return SendMsg(2022, pt
.x
, pt
.y
);
369 // Find the position from a point within the window but return
370 // INVALID_POSITION if not close to text.
371 int wxStyledTextCtrl::PositionFromPointClose(int x
, int y
) {
372 return SendMsg(2023, x
, y
);
375 // Set caret to start of a line and ensure it is visible.
376 void wxStyledTextCtrl::GotoLine(int line
) {
377 SendMsg(2024, line
, 0);
380 // Set caret to a position and ensure it is visible.
381 void wxStyledTextCtrl::GotoPos(int pos
) {
382 SendMsg(2025, pos
, 0);
385 // Set the selection anchor to a position. The anchor is the opposite
386 // end of the selection from the caret.
387 void wxStyledTextCtrl::SetAnchor(int posAnchor
) {
388 SendMsg(2026, posAnchor
, 0);
391 // Retrieve the text of the line containing the caret.
392 // Returns the index of the caret on the line.
393 wxString
wxStyledTextCtrl::GetCurLine(int* linePos
) {
394 int len
= LineLength(GetCurrentLine());
396 if (linePos
) *linePos
= 0;
397 return wxEmptyString
;
400 wxMemoryBuffer
mbuf(len
+1);
401 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
403 int pos
= SendMsg(2027, len
+1, (long)buf
);
404 mbuf
.UngetWriteBuf(len
);
406 if (linePos
) *linePos
= pos
;
410 // Retrieve the position of the last correctly styled character.
411 int wxStyledTextCtrl::GetEndStyled() {
412 return SendMsg(2028, 0, 0);
415 // Convert all line endings in the document to one mode.
416 void wxStyledTextCtrl::ConvertEOLs(int eolMode
) {
417 SendMsg(2029, eolMode
, 0);
420 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
421 int wxStyledTextCtrl::GetEOLMode() {
422 return SendMsg(2030, 0, 0);
425 // Set the current end of line mode.
426 void wxStyledTextCtrl::SetEOLMode(int eolMode
) {
427 SendMsg(2031, eolMode
, 0);
430 // Set the current styling position to pos and the styling mask to mask.
431 // The styling mask can be used to protect some bits in each styling byte from modification.
432 void wxStyledTextCtrl::StartStyling(int pos
, int mask
) {
433 SendMsg(2032, pos
, mask
);
436 // Change style from current styling position for length characters to a style
437 // and move the current styling position to after this newly styled segment.
438 void wxStyledTextCtrl::SetStyling(int length
, int style
) {
439 SendMsg(2033, length
, style
);
442 // Is drawing done first into a buffer or direct to the screen?
443 bool wxStyledTextCtrl::GetBufferedDraw() {
444 return SendMsg(2034, 0, 0) != 0;
447 // If drawing is buffered then each line of text is drawn into a bitmap buffer
448 // before drawing it to the screen to avoid flicker.
449 void wxStyledTextCtrl::SetBufferedDraw(bool buffered
) {
450 SendMsg(2035, buffered
, 0);
453 // Change the visible size of a tab to be a multiple of the width of a space character.
454 void wxStyledTextCtrl::SetTabWidth(int tabWidth
) {
455 SendMsg(2036, tabWidth
, 0);
458 // Retrieve the visible size of a tab.
459 int wxStyledTextCtrl::GetTabWidth() {
460 return SendMsg(2121, 0, 0);
463 // Set the code page used to interpret the bytes of the document as characters.
464 void wxStyledTextCtrl::SetCodePage(int codePage
) {
466 wxASSERT_MSG(codePage
== wxSTC_CP_UTF8
,
467 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
469 wxASSERT_MSG(codePage
!= wxSTC_CP_UTF8
,
470 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
472 SendMsg(2037, codePage
);
475 // Set the symbol used for a particular marker number,
476 // and optionally the fore and background colours.
477 void wxStyledTextCtrl::MarkerDefine(int markerNumber
, int markerSymbol
,
478 const wxColour
& foreground
,
479 const wxColour
& background
) {
481 SendMsg(2040, markerNumber
, markerSymbol
);
483 MarkerSetForeground(markerNumber
, foreground
);
485 MarkerSetBackground(markerNumber
, background
);
488 // Set the foreground colour used for a particular marker number.
489 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber
, const wxColour
& fore
) {
490 SendMsg(2041, markerNumber
, wxColourAsLong(fore
));
493 // Set the background colour used for a particular marker number.
494 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber
, const wxColour
& back
) {
495 SendMsg(2042, markerNumber
, wxColourAsLong(back
));
498 // Add a marker to a line, returning an ID which can be used to find or delete the marker.
499 int wxStyledTextCtrl::MarkerAdd(int line
, int markerNumber
) {
500 return SendMsg(2043, line
, markerNumber
);
503 // Delete a marker from a line.
504 void wxStyledTextCtrl::MarkerDelete(int line
, int markerNumber
) {
505 SendMsg(2044, line
, markerNumber
);
508 // Delete all markers with a particular number from all lines.
509 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber
) {
510 SendMsg(2045, markerNumber
, 0);
513 // Get a bit mask of all the markers set on a line.
514 int wxStyledTextCtrl::MarkerGet(int line
) {
515 return SendMsg(2046, line
, 0);
518 // Find the next line after lineStart that includes a marker in mask.
519 int wxStyledTextCtrl::MarkerNext(int lineStart
, int markerMask
) {
520 return SendMsg(2047, lineStart
, markerMask
);
523 // Find the previous line before lineStart that includes a marker in mask.
524 int wxStyledTextCtrl::MarkerPrevious(int lineStart
, int markerMask
) {
525 return SendMsg(2048, lineStart
, markerMask
);
528 // Define a marker from a bitmap
529 void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber
, const wxBitmap
& bmp
) {
530 // convert bmp to a xpm in a string
531 wxMemoryOutputStream strm
;
532 wxImage img
= bmp
.ConvertToImage();
534 img
.ConvertAlphaToMask();
535 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
536 size_t len
= strm
.GetSize();
537 char* buff
= new char[len
+1];
538 strm
.CopyTo(buff
, len
);
540 SendMsg(2049, markerNumber
, (long)buff
);
545 // Add a set of markers to a line.
546 void wxStyledTextCtrl::MarkerAddSet(int line
, int set
) {
547 SendMsg(2466, line
, set
);
550 // Set the alpha used for a marker that is drawn in the text area, not the margin.
551 void wxStyledTextCtrl::MarkerSetAlpha(int markerNumber
, int alpha
) {
552 SendMsg(2476, markerNumber
, alpha
);
555 // Set a margin to be either numeric or symbolic.
556 void wxStyledTextCtrl::SetMarginType(int margin
, int marginType
) {
557 SendMsg(2240, margin
, marginType
);
560 // Retrieve the type of a margin.
561 int wxStyledTextCtrl::GetMarginType(int margin
) {
562 return SendMsg(2241, margin
, 0);
565 // Set the width of a margin to a width expressed in pixels.
566 void wxStyledTextCtrl::SetMarginWidth(int margin
, int pixelWidth
) {
567 SendMsg(2242, margin
, pixelWidth
);
570 // Retrieve the width of a margin in pixels.
571 int wxStyledTextCtrl::GetMarginWidth(int margin
) {
572 return SendMsg(2243, margin
, 0);
575 // Set a mask that determines which markers are displayed in a margin.
576 void wxStyledTextCtrl::SetMarginMask(int margin
, int mask
) {
577 SendMsg(2244, margin
, mask
);
580 // Retrieve the marker mask of a margin.
581 int wxStyledTextCtrl::GetMarginMask(int margin
) {
582 return SendMsg(2245, margin
, 0);
585 // Make a margin sensitive or insensitive to mouse clicks.
586 void wxStyledTextCtrl::SetMarginSensitive(int margin
, bool sensitive
) {
587 SendMsg(2246, margin
, sensitive
);
590 // Retrieve the mouse click sensitivity of a margin.
591 bool wxStyledTextCtrl::GetMarginSensitive(int margin
) {
592 return SendMsg(2247, margin
, 0) != 0;
595 // Clear all the styles and make equivalent to the global default style.
596 void wxStyledTextCtrl::StyleClearAll() {
600 // Set the foreground colour of a style.
601 void wxStyledTextCtrl::StyleSetForeground(int style
, const wxColour
& fore
) {
602 SendMsg(2051, style
, wxColourAsLong(fore
));
605 // Set the background colour of a style.
606 void wxStyledTextCtrl::StyleSetBackground(int style
, const wxColour
& back
) {
607 SendMsg(2052, style
, wxColourAsLong(back
));
610 // Set a style to be bold or not.
611 void wxStyledTextCtrl::StyleSetBold(int style
, bool bold
) {
612 SendMsg(2053, style
, bold
);
615 // Set a style to be italic or not.
616 void wxStyledTextCtrl::StyleSetItalic(int style
, bool italic
) {
617 SendMsg(2054, style
, italic
);
620 // Set the size of characters of a style.
621 void wxStyledTextCtrl::StyleSetSize(int style
, int sizePoints
) {
622 SendMsg(2055, style
, sizePoints
);
625 // Set the font of a style.
626 void wxStyledTextCtrl::StyleSetFaceName(int style
, const wxString
& fontName
) {
627 SendMsg(2056, style
, (long)(const char*)wx2stc(fontName
));
630 // Set a style to have its end of line filled or not.
631 void wxStyledTextCtrl::StyleSetEOLFilled(int style
, bool filled
) {
632 SendMsg(2057, style
, filled
);
635 // Reset the default style to its state at startup
636 void wxStyledTextCtrl::StyleResetDefault() {
640 // Set a style to be underlined or not.
641 void wxStyledTextCtrl::StyleSetUnderline(int style
, bool underline
) {
642 SendMsg(2059, style
, underline
);
645 // Set a style to be mixed case, or to force upper or lower case.
646 void wxStyledTextCtrl::StyleSetCase(int style
, int caseForce
) {
647 SendMsg(2060, style
, caseForce
);
650 // Set a style to be a hotspot or not.
651 void wxStyledTextCtrl::StyleSetHotSpot(int style
, bool hotspot
) {
652 SendMsg(2409, style
, hotspot
);
655 // Set the foreground colour of the selection and whether to use this setting.
656 void wxStyledTextCtrl::SetSelForeground(bool useSetting
, const wxColour
& fore
) {
657 SendMsg(2067, useSetting
, wxColourAsLong(fore
));
660 // Set the background colour of the selection and whether to use this setting.
661 void wxStyledTextCtrl::SetSelBackground(bool useSetting
, const wxColour
& back
) {
662 SendMsg(2068, useSetting
, wxColourAsLong(back
));
665 // Get the alpha of the selection.
666 int wxStyledTextCtrl::GetSelAlpha() {
667 return SendMsg(2477, 0, 0);
670 // Set the alpha of the selection.
671 void wxStyledTextCtrl::SetSelAlpha(int alpha
) {
672 SendMsg(2478, alpha
, 0);
675 // Set the foreground colour of the caret.
676 void wxStyledTextCtrl::SetCaretForeground(const wxColour
& fore
) {
677 SendMsg(2069, wxColourAsLong(fore
), 0);
680 // When key+modifier combination km is pressed perform msg.
681 void wxStyledTextCtrl::CmdKeyAssign(int key
, int modifiers
, int cmd
) {
682 SendMsg(2070, MAKELONG(key
, modifiers
), cmd
);
685 // When key+modifier combination km is pressed do nothing.
686 void wxStyledTextCtrl::CmdKeyClear(int key
, int modifiers
) {
687 SendMsg(2071, MAKELONG(key
, modifiers
));
690 // Drop all key mappings.
691 void wxStyledTextCtrl::CmdKeyClearAll() {
695 // Set the styles for a segment of the document.
696 void wxStyledTextCtrl::SetStyleBytes(int length
, char* styleBytes
) {
697 SendMsg(2073, length
, (long)styleBytes
);
700 // Set a style to be visible or not.
701 void wxStyledTextCtrl::StyleSetVisible(int style
, bool visible
) {
702 SendMsg(2074, style
, visible
);
705 // Get the time in milliseconds that the caret is on and off.
706 int wxStyledTextCtrl::GetCaretPeriod() {
707 return SendMsg(2075, 0, 0);
710 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
711 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds
) {
712 SendMsg(2076, periodMilliseconds
, 0);
715 // Set the set of characters making up words for when moving or selecting by word.
716 // First sets deaults like SetCharsDefault.
717 void wxStyledTextCtrl::SetWordChars(const wxString
& characters
) {
718 SendMsg(2077, 0, (long)(const char*)wx2stc(characters
));
721 // Start a sequence of actions that is undone and redone as a unit.
723 void wxStyledTextCtrl::BeginUndoAction() {
727 // End a sequence of actions that is undone and redone as a unit.
728 void wxStyledTextCtrl::EndUndoAction() {
732 // Set an indicator to plain, squiggle or TT.
733 void wxStyledTextCtrl::IndicatorSetStyle(int indic
, int style
) {
734 SendMsg(2080, indic
, style
);
737 // Retrieve the style of an indicator.
738 int wxStyledTextCtrl::IndicatorGetStyle(int indic
) {
739 return SendMsg(2081, indic
, 0);
742 // Set the foreground colour of an indicator.
743 void wxStyledTextCtrl::IndicatorSetForeground(int indic
, const wxColour
& fore
) {
744 SendMsg(2082, indic
, wxColourAsLong(fore
));
747 // Retrieve the foreground colour of an indicator.
748 wxColour
wxStyledTextCtrl::IndicatorGetForeground(int indic
) {
749 long c
= SendMsg(2083, indic
, 0);
750 return wxColourFromLong(c
);
753 // Set the foreground colour of all whitespace and whether to use this setting.
754 void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting
, const wxColour
& fore
) {
755 SendMsg(2084, useSetting
, wxColourAsLong(fore
));
758 // Set the background colour of all whitespace and whether to use this setting.
759 void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting
, const wxColour
& back
) {
760 SendMsg(2085, useSetting
, wxColourAsLong(back
));
763 // Divide each styling byte into lexical class bits (default: 5) and indicator
764 // bits (default: 3). If a lexer requires more than 32 lexical states, then this
765 // is used to expand the possible states.
766 void wxStyledTextCtrl::SetStyleBits(int bits
) {
767 SendMsg(2090, bits
, 0);
770 // Retrieve number of bits in style bytes used to hold the lexical state.
771 int wxStyledTextCtrl::GetStyleBits() {
772 return SendMsg(2091, 0, 0);
775 // Used to hold extra styling information for each line.
776 void wxStyledTextCtrl::SetLineState(int line
, int state
) {
777 SendMsg(2092, line
, state
);
780 // Retrieve the extra styling information for a line.
781 int wxStyledTextCtrl::GetLineState(int line
) {
782 return SendMsg(2093, line
, 0);
785 // Retrieve the last line number that has line state.
786 int wxStyledTextCtrl::GetMaxLineState() {
787 return SendMsg(2094, 0, 0);
790 // Is the background of the line containing the caret in a different colour?
791 bool wxStyledTextCtrl::GetCaretLineVisible() {
792 return SendMsg(2095, 0, 0) != 0;
795 // Display the background of the line containing the caret in a different colour.
796 void wxStyledTextCtrl::SetCaretLineVisible(bool show
) {
797 SendMsg(2096, show
, 0);
800 // Get the colour of the background of the line containing the caret.
801 wxColour
wxStyledTextCtrl::GetCaretLineBackground() {
802 long c
= SendMsg(2097, 0, 0);
803 return wxColourFromLong(c
);
806 // Set the colour of the background of the line containing the caret.
807 void wxStyledTextCtrl::SetCaretLineBackground(const wxColour
& back
) {
808 SendMsg(2098, wxColourAsLong(back
), 0);
811 // Set a style to be changeable or not (read only).
812 // Experimental feature, currently buggy.
813 void wxStyledTextCtrl::StyleSetChangeable(int style
, bool changeable
) {
814 SendMsg(2099, style
, changeable
);
817 // Display a auto-completion list.
818 // The lenEntered parameter indicates how many characters before
819 // the caret should be used to provide context.
820 void wxStyledTextCtrl::AutoCompShow(int lenEntered
, const wxString
& itemList
) {
821 SendMsg(2100, lenEntered
, (long)(const char*)wx2stc(itemList
));
824 // Remove the auto-completion list from the screen.
825 void wxStyledTextCtrl::AutoCompCancel() {
829 // Is there an auto-completion list visible?
830 bool wxStyledTextCtrl::AutoCompActive() {
831 return SendMsg(2102, 0, 0) != 0;
834 // Retrieve the position of the caret when the auto-completion list was displayed.
835 int wxStyledTextCtrl::AutoCompPosStart() {
836 return SendMsg(2103, 0, 0);
839 // User has selected an item so remove the list and insert the selection.
840 void wxStyledTextCtrl::AutoCompComplete() {
844 // Define a set of character that when typed cancel the auto-completion list.
845 void wxStyledTextCtrl::AutoCompStops(const wxString
& characterSet
) {
846 SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet
));
849 // Change the separator character in the string setting up an auto-completion list.
850 // Default is space but can be changed if items contain space.
851 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter
) {
852 SendMsg(2106, separatorCharacter
, 0);
855 // Retrieve the auto-completion list separator character.
856 int wxStyledTextCtrl::AutoCompGetSeparator() {
857 return SendMsg(2107, 0, 0);
860 // Select the item in the auto-completion list that starts with a string.
861 void wxStyledTextCtrl::AutoCompSelect(const wxString
& text
) {
862 SendMsg(2108, 0, (long)(const char*)wx2stc(text
));
865 // Should the auto-completion list be cancelled if the user backspaces to a
866 // position before where the box was created.
867 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel
) {
868 SendMsg(2110, cancel
, 0);
871 // Retrieve whether auto-completion cancelled by backspacing before start.
872 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
873 return SendMsg(2111, 0, 0) != 0;
876 // Define a set of characters that when typed will cause the autocompletion to
877 // choose the selected item.
878 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString
& characterSet
) {
879 SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet
));
882 // Should a single item auto-completion list automatically choose the item.
883 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle
) {
884 SendMsg(2113, chooseSingle
, 0);
887 // Retrieve whether a single item auto-completion list automatically choose the item.
888 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
889 return SendMsg(2114, 0, 0) != 0;
892 // Set whether case is significant when performing auto-completion searches.
893 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase
) {
894 SendMsg(2115, ignoreCase
, 0);
897 // Retrieve state of ignore case flag.
898 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
899 return SendMsg(2116, 0, 0) != 0;
902 // Display a list of strings and send notification when user chooses one.
903 void wxStyledTextCtrl::UserListShow(int listType
, const wxString
& itemList
) {
904 SendMsg(2117, listType
, (long)(const char*)wx2stc(itemList
));
907 // Set whether or not autocompletion is hidden automatically when nothing matches.
908 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide
) {
909 SendMsg(2118, autoHide
, 0);
912 // Retrieve whether or not autocompletion is hidden automatically when nothing matches.
913 bool wxStyledTextCtrl::AutoCompGetAutoHide() {
914 return SendMsg(2119, 0, 0) != 0;
917 // Set whether or not autocompletion deletes any word characters
918 // after the inserted text upon completion.
919 void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord
) {
920 SendMsg(2270, dropRestOfWord
, 0);
923 // Retrieve whether or not autocompletion deletes any word characters
924 // after the inserted text upon completion.
925 bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
926 return SendMsg(2271, 0, 0) != 0;
929 // Register an image for use in autocompletion lists.
930 void wxStyledTextCtrl::RegisterImage(int type
, const wxBitmap
& bmp
) {
931 // convert bmp to a xpm in a string
932 wxMemoryOutputStream strm
;
933 wxImage img
= bmp
.ConvertToImage();
935 img
.ConvertAlphaToMask();
936 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
937 size_t len
= strm
.GetSize();
938 char* buff
= new char[len
+1];
939 strm
.CopyTo(buff
, len
);
941 SendMsg(2405, type
, (long)buff
);
946 // Clear all the registered images.
947 void wxStyledTextCtrl::ClearRegisteredImages() {
951 // Retrieve the auto-completion list type-separator character.
952 int wxStyledTextCtrl::AutoCompGetTypeSeparator() {
953 return SendMsg(2285, 0, 0);
956 // Change the type-separator character in the string setting up an auto-completion list.
957 // Default is '?' but can be changed if items contain '?'.
958 void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter
) {
959 SendMsg(2286, separatorCharacter
, 0);
962 // Set the maximum width, in characters, of auto-completion and user lists.
963 // Set to 0 to autosize to fit longest item, which is the default.
964 void wxStyledTextCtrl::AutoCompSetMaxWidth(int characterCount
) {
965 SendMsg(2208, characterCount
, 0);
968 // Get the maximum width, in characters, of auto-completion and user lists.
969 int wxStyledTextCtrl::AutoCompGetMaxWidth() {
970 return SendMsg(2209, 0, 0);
973 // Set the maximum height, in rows, of auto-completion and user lists.
974 // The default is 5 rows.
975 void wxStyledTextCtrl::AutoCompSetMaxHeight(int rowCount
) {
976 SendMsg(2210, rowCount
, 0);
979 // Set the maximum height, in rows, of auto-completion and user lists.
980 int wxStyledTextCtrl::AutoCompGetMaxHeight() {
981 return SendMsg(2211, 0, 0);
984 // Set the number of spaces used for one level of indentation.
985 void wxStyledTextCtrl::SetIndent(int indentSize
) {
986 SendMsg(2122, indentSize
, 0);
989 // Retrieve indentation size.
990 int wxStyledTextCtrl::GetIndent() {
991 return SendMsg(2123, 0, 0);
994 // Indentation will only use space characters if useTabs is false, otherwise
995 // it will use a combination of tabs and spaces.
996 void wxStyledTextCtrl::SetUseTabs(bool useTabs
) {
997 SendMsg(2124, useTabs
, 0);
1000 // Retrieve whether tabs will be used in indentation.
1001 bool wxStyledTextCtrl::GetUseTabs() {
1002 return SendMsg(2125, 0, 0) != 0;
1005 // Change the indentation of a line to a number of columns.
1006 void wxStyledTextCtrl::SetLineIndentation(int line
, int indentSize
) {
1007 SendMsg(2126, line
, indentSize
);
1010 // Retrieve the number of columns that a line is indented.
1011 int wxStyledTextCtrl::GetLineIndentation(int line
) {
1012 return SendMsg(2127, line
, 0);
1015 // Retrieve the position before the first non indentation character on a line.
1016 int wxStyledTextCtrl::GetLineIndentPosition(int line
) {
1017 return SendMsg(2128, line
, 0);
1020 // Retrieve the column number of a position, taking tab width into account.
1021 int wxStyledTextCtrl::GetColumn(int pos
) {
1022 return SendMsg(2129, pos
, 0);
1025 // Show or hide the horizontal scroll bar.
1026 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show
) {
1027 SendMsg(2130, show
, 0);
1030 // Is the horizontal scroll bar visible?
1031 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
1032 return SendMsg(2131, 0, 0) != 0;
1035 // Show or hide indentation guides.
1036 void wxStyledTextCtrl::SetIndentationGuides(bool show
) {
1037 SendMsg(2132, show
, 0);
1040 // Are the indentation guides visible?
1041 bool wxStyledTextCtrl::GetIndentationGuides() {
1042 return SendMsg(2133, 0, 0) != 0;
1045 // Set the highlighted indentation guide column.
1046 // 0 = no highlighted guide.
1047 void wxStyledTextCtrl::SetHighlightGuide(int column
) {
1048 SendMsg(2134, column
, 0);
1051 // Get the highlighted indentation guide column.
1052 int wxStyledTextCtrl::GetHighlightGuide() {
1053 return SendMsg(2135, 0, 0);
1056 // Get the position after the last visible characters on a line.
1057 int wxStyledTextCtrl::GetLineEndPosition(int line
) {
1058 return SendMsg(2136, line
, 0);
1061 // Get the code page used to interpret the bytes of the document as characters.
1062 int wxStyledTextCtrl::GetCodePage() {
1063 return SendMsg(2137, 0, 0);
1066 // Get the foreground colour of the caret.
1067 wxColour
wxStyledTextCtrl::GetCaretForeground() {
1068 long c
= SendMsg(2138, 0, 0);
1069 return wxColourFromLong(c
);
1072 // In read-only mode?
1073 bool wxStyledTextCtrl::GetReadOnly() {
1074 return SendMsg(2140, 0, 0) != 0;
1077 // Sets the position of the caret.
1078 void wxStyledTextCtrl::SetCurrentPos(int pos
) {
1079 SendMsg(2141, pos
, 0);
1082 // Sets the position that starts the selection - this becomes the anchor.
1083 void wxStyledTextCtrl::SetSelectionStart(int pos
) {
1084 SendMsg(2142, pos
, 0);
1087 // Returns the position at the start of the selection.
1088 int wxStyledTextCtrl::GetSelectionStart() {
1089 return SendMsg(2143, 0, 0);
1092 // Sets the position that ends the selection - this becomes the currentPosition.
1093 void wxStyledTextCtrl::SetSelectionEnd(int pos
) {
1094 SendMsg(2144, pos
, 0);
1097 // Returns the position at the end of the selection.
1098 int wxStyledTextCtrl::GetSelectionEnd() {
1099 return SendMsg(2145, 0, 0);
1102 // Sets the print magnification added to the point size of each style for printing.
1103 void wxStyledTextCtrl::SetPrintMagnification(int magnification
) {
1104 SendMsg(2146, magnification
, 0);
1107 // Returns the print magnification.
1108 int wxStyledTextCtrl::GetPrintMagnification() {
1109 return SendMsg(2147, 0, 0);
1112 // Modify colours when printing for clearer printed text.
1113 void wxStyledTextCtrl::SetPrintColourMode(int mode
) {
1114 SendMsg(2148, mode
, 0);
1117 // Returns the print colour mode.
1118 int wxStyledTextCtrl::GetPrintColourMode() {
1119 return SendMsg(2149, 0, 0);
1122 // Find some text in the document.
1123 int wxStyledTextCtrl::FindText(int minPos
, int maxPos
,
1124 const wxString
& text
,
1127 ft
.chrg
.cpMin
= minPos
;
1128 ft
.chrg
.cpMax
= maxPos
;
1129 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1130 ft
.lpstrText
= (char*)(const char*)buf
;
1132 return SendMsg(2150, flags
, (long)&ft
);
1135 // On Windows, will draw the document into a display context such as a printer.
1136 int wxStyledTextCtrl::FormatRange(bool doDraw
,
1145 if (endPos
< startPos
) {
1146 int temp
= startPos
;
1151 fr
.hdcTarget
= target
;
1152 fr
.rc
.top
= renderRect
.GetTop();
1153 fr
.rc
.left
= renderRect
.GetLeft();
1154 fr
.rc
.right
= renderRect
.GetRight();
1155 fr
.rc
.bottom
= renderRect
.GetBottom();
1156 fr
.rcPage
.top
= pageRect
.GetTop();
1157 fr
.rcPage
.left
= pageRect
.GetLeft();
1158 fr
.rcPage
.right
= pageRect
.GetRight();
1159 fr
.rcPage
.bottom
= pageRect
.GetBottom();
1160 fr
.chrg
.cpMin
= startPos
;
1161 fr
.chrg
.cpMax
= endPos
;
1163 return SendMsg(2151, doDraw
, (long)&fr
);
1166 // Retrieve the display line at the top of the display.
1167 int wxStyledTextCtrl::GetFirstVisibleLine() {
1168 return SendMsg(2152, 0, 0);
1171 // Retrieve the contents of a line.
1172 wxString
wxStyledTextCtrl::GetLine(int line
) {
1173 int len
= LineLength(line
);
1174 if (!len
) return wxEmptyString
;
1176 wxMemoryBuffer
mbuf(len
+1);
1177 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1178 SendMsg(2153, line
, (long)buf
);
1179 mbuf
.UngetWriteBuf(len
);
1184 // Returns the number of lines in the document. There is always at least one.
1185 int wxStyledTextCtrl::GetLineCount() {
1186 return SendMsg(2154, 0, 0);
1189 // Sets the size in pixels of the left margin.
1190 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth
) {
1191 SendMsg(2155, 0, pixelWidth
);
1194 // Returns the size in pixels of the left margin.
1195 int wxStyledTextCtrl::GetMarginLeft() {
1196 return SendMsg(2156, 0, 0);
1199 // Sets the size in pixels of the right margin.
1200 void wxStyledTextCtrl::SetMarginRight(int pixelWidth
) {
1201 SendMsg(2157, 0, pixelWidth
);
1204 // Returns the size in pixels of the right margin.
1205 int wxStyledTextCtrl::GetMarginRight() {
1206 return SendMsg(2158, 0, 0);
1209 // Is the document different from when it was last saved?
1210 bool wxStyledTextCtrl::GetModify() {
1211 return SendMsg(2159, 0, 0) != 0;
1214 // Select a range of text.
1215 void wxStyledTextCtrl::SetSelection(int start
, int end
) {
1216 SendMsg(2160, start
, end
);
1219 // Retrieve the selected text.
1220 wxString
wxStyledTextCtrl::GetSelectedText() {
1224 GetSelection(&start
, &end
);
1225 int len
= end
- start
;
1226 if (!len
) return wxEmptyString
;
1228 wxMemoryBuffer
mbuf(len
+2);
1229 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1230 SendMsg(2161, 0, (long)buf
);
1231 mbuf
.UngetWriteBuf(len
);
1236 // Retrieve a range of text.
1237 wxString
wxStyledTextCtrl::GetTextRange(int startPos
, int endPos
) {
1238 if (endPos
< startPos
) {
1239 int temp
= startPos
;
1243 int len
= endPos
- startPos
;
1244 if (!len
) return wxEmptyString
;
1245 wxMemoryBuffer
mbuf(len
+1);
1246 char* buf
= (char*)mbuf
.GetWriteBuf(len
);
1249 tr
.chrg
.cpMin
= startPos
;
1250 tr
.chrg
.cpMax
= endPos
;
1251 SendMsg(2162, 0, (long)&tr
);
1252 mbuf
.UngetWriteBuf(len
);
1257 // Draw the selection in normal style or with selection highlighted.
1258 void wxStyledTextCtrl::HideSelection(bool normal
) {
1259 SendMsg(2163, normal
, 0);
1262 // Retrieve the line containing a position.
1263 int wxStyledTextCtrl::LineFromPosition(int pos
) {
1264 return SendMsg(2166, pos
, 0);
1267 // Retrieve the position at the start of a line.
1268 int wxStyledTextCtrl::PositionFromLine(int line
) {
1269 return SendMsg(2167, line
, 0);
1272 // Scroll horizontally and vertically.
1273 void wxStyledTextCtrl::LineScroll(int columns
, int lines
) {
1274 SendMsg(2168, columns
, lines
);
1277 // Ensure the caret is visible.
1278 void wxStyledTextCtrl::EnsureCaretVisible() {
1279 SendMsg(2169, 0, 0);
1282 // Replace the selected text with the argument text.
1283 void wxStyledTextCtrl::ReplaceSelection(const wxString
& text
) {
1284 SendMsg(2170, 0, (long)(const char*)wx2stc(text
));
1287 // Set to read only or read write.
1288 void wxStyledTextCtrl::SetReadOnly(bool readOnly
) {
1289 SendMsg(2171, readOnly
, 0);
1292 // Will a paste succeed?
1293 bool wxStyledTextCtrl::CanPaste() {
1294 return SendMsg(2173, 0, 0) != 0;
1297 // Are there any undoable actions in the undo history?
1298 bool wxStyledTextCtrl::CanUndo() {
1299 return SendMsg(2174, 0, 0) != 0;
1302 // Delete the undo history.
1303 void wxStyledTextCtrl::EmptyUndoBuffer() {
1304 SendMsg(2175, 0, 0);
1307 // Undo one action in the undo history.
1308 void wxStyledTextCtrl::Undo() {
1309 SendMsg(2176, 0, 0);
1312 // Cut the selection to the clipboard.
1313 void wxStyledTextCtrl::Cut() {
1314 SendMsg(2177, 0, 0);
1317 // Copy the selection to the clipboard.
1318 void wxStyledTextCtrl::Copy() {
1319 SendMsg(2178, 0, 0);
1322 // Paste the contents of the clipboard into the document replacing the selection.
1323 void wxStyledTextCtrl::Paste() {
1324 SendMsg(2179, 0, 0);
1327 // Clear the selection.
1328 void wxStyledTextCtrl::Clear() {
1329 SendMsg(2180, 0, 0);
1332 // Replace the contents of the document with the argument text.
1333 void wxStyledTextCtrl::SetText(const wxString
& text
) {
1334 SendMsg(2181, 0, (long)(const char*)wx2stc(text
));
1337 // Retrieve all the text in the document.
1338 wxString
wxStyledTextCtrl::GetText() {
1339 int len
= GetTextLength();
1340 wxMemoryBuffer
mbuf(len
+1); // leave room for the null...
1341 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1342 SendMsg(2182, len
+1, (long)buf
);
1343 mbuf
.UngetWriteBuf(len
);
1348 // Retrieve the number of characters in the document.
1349 int wxStyledTextCtrl::GetTextLength() {
1350 return SendMsg(2183, 0, 0);
1353 // Set to overtype (true) or insert mode.
1354 void wxStyledTextCtrl::SetOvertype(bool overtype
) {
1355 SendMsg(2186, overtype
, 0);
1358 // Returns true if overtype mode is active otherwise false is returned.
1359 bool wxStyledTextCtrl::GetOvertype() {
1360 return SendMsg(2187, 0, 0) != 0;
1363 // Set the width of the insert mode caret.
1364 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth
) {
1365 SendMsg(2188, pixelWidth
, 0);
1368 // Returns the width of the insert mode caret.
1369 int wxStyledTextCtrl::GetCaretWidth() {
1370 return SendMsg(2189, 0, 0);
1373 // Sets the position that starts the target which is used for updating the
1374 // document without affecting the scroll position.
1375 void wxStyledTextCtrl::SetTargetStart(int pos
) {
1376 SendMsg(2190, pos
, 0);
1379 // Get the position that starts the target.
1380 int wxStyledTextCtrl::GetTargetStart() {
1381 return SendMsg(2191, 0, 0);
1384 // Sets the position that ends the target which is used for updating the
1385 // document without affecting the scroll position.
1386 void wxStyledTextCtrl::SetTargetEnd(int pos
) {
1387 SendMsg(2192, pos
, 0);
1390 // Get the position that ends the target.
1391 int wxStyledTextCtrl::GetTargetEnd() {
1392 return SendMsg(2193, 0, 0);
1395 // Replace the target text with the argument text.
1396 // Text is counted so it can contain NULs.
1397 // Returns the length of the replacement text.
1399 int wxStyledTextCtrl::ReplaceTarget(const wxString
& text
) {
1400 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1401 return SendMsg(2194, strlen(buf
), (long)(const char*)buf
);
1404 // Replace the target text with the argument text after \d processing.
1405 // Text is counted so it can contain NULs.
1406 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1407 // matched in the last search operation which were surrounded by \( and \).
1408 // Returns the length of the replacement text including any change
1409 // caused by processing the \d patterns.
1411 int wxStyledTextCtrl::ReplaceTargetRE(const wxString
& text
) {
1412 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1413 return SendMsg(2195, strlen(buf
), (long)(const char*)buf
);
1416 // Search for a counted string in the target and set the target to the found
1417 // range. Text is counted so it can contain NULs.
1418 // Returns length of range or -1 for failure in which case target is not moved.
1420 int wxStyledTextCtrl::SearchInTarget(const wxString
& text
) {
1421 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1422 return SendMsg(2197, strlen(buf
), (long)(const char*)buf
);
1425 // Set the search flags used by SearchInTarget.
1426 void wxStyledTextCtrl::SetSearchFlags(int flags
) {
1427 SendMsg(2198, flags
, 0);
1430 // Get the search flags used by SearchInTarget.
1431 int wxStyledTextCtrl::GetSearchFlags() {
1432 return SendMsg(2199, 0, 0);
1435 // Show a call tip containing a definition near position pos.
1436 void wxStyledTextCtrl::CallTipShow(int pos
, const wxString
& definition
) {
1437 SendMsg(2200, pos
, (long)(const char*)wx2stc(definition
));
1440 // Remove the call tip from the screen.
1441 void wxStyledTextCtrl::CallTipCancel() {
1442 SendMsg(2201, 0, 0);
1445 // Is there an active call tip?
1446 bool wxStyledTextCtrl::CallTipActive() {
1447 return SendMsg(2202, 0, 0) != 0;
1450 // Retrieve the position where the caret was before displaying the call tip.
1451 int wxStyledTextCtrl::CallTipPosAtStart() {
1452 return SendMsg(2203, 0, 0);
1455 // Highlight a segment of the definition.
1456 void wxStyledTextCtrl::CallTipSetHighlight(int start
, int end
) {
1457 SendMsg(2204, start
, end
);
1460 // Set the background colour for the call tip.
1461 void wxStyledTextCtrl::CallTipSetBackground(const wxColour
& back
) {
1462 SendMsg(2205, wxColourAsLong(back
), 0);
1465 // Set the foreground colour for the call tip.
1466 void wxStyledTextCtrl::CallTipSetForeground(const wxColour
& fore
) {
1467 SendMsg(2206, wxColourAsLong(fore
), 0);
1470 // Set the foreground colour for the highlighted part of the call tip.
1471 void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour
& fore
) {
1472 SendMsg(2207, wxColourAsLong(fore
), 0);
1475 // Enable use of STYLE_CALLTIP and set call tip tab size in pixels.
1476 void wxStyledTextCtrl::CallTipUseStyle(int tabSize
) {
1477 SendMsg(2212, tabSize
, 0);
1480 // Find the display line of a document line taking hidden lines into account.
1481 int wxStyledTextCtrl::VisibleFromDocLine(int line
) {
1482 return SendMsg(2220, line
, 0);
1485 // Find the document line of a display line taking hidden lines into account.
1486 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay
) {
1487 return SendMsg(2221, lineDisplay
, 0);
1490 // The number of display lines needed to wrap a document line
1491 int wxStyledTextCtrl::WrapCount(int line
) {
1492 return SendMsg(2235, line
, 0);
1495 // Set the fold level of a line.
1496 // This encodes an integer level along with flags indicating whether the
1497 // line is a header and whether it is effectively white space.
1498 void wxStyledTextCtrl::SetFoldLevel(int line
, int level
) {
1499 SendMsg(2222, line
, level
);
1502 // Retrieve the fold level of a line.
1503 int wxStyledTextCtrl::GetFoldLevel(int line
) {
1504 return SendMsg(2223, line
, 0);
1507 // Find the last child line of a header line.
1508 int wxStyledTextCtrl::GetLastChild(int line
, int level
) {
1509 return SendMsg(2224, line
, level
);
1512 // Find the parent line of a child line.
1513 int wxStyledTextCtrl::GetFoldParent(int line
) {
1514 return SendMsg(2225, line
, 0);
1517 // Make a range of lines visible.
1518 void wxStyledTextCtrl::ShowLines(int lineStart
, int lineEnd
) {
1519 SendMsg(2226, lineStart
, lineEnd
);
1522 // Make a range of lines invisible.
1523 void wxStyledTextCtrl::HideLines(int lineStart
, int lineEnd
) {
1524 SendMsg(2227, lineStart
, lineEnd
);
1527 // Is a line visible?
1528 bool wxStyledTextCtrl::GetLineVisible(int line
) {
1529 return SendMsg(2228, line
, 0) != 0;
1532 // Show the children of a header line.
1533 void wxStyledTextCtrl::SetFoldExpanded(int line
, bool expanded
) {
1534 SendMsg(2229, line
, expanded
);
1537 // Is a header line expanded?
1538 bool wxStyledTextCtrl::GetFoldExpanded(int line
) {
1539 return SendMsg(2230, line
, 0) != 0;
1542 // Switch a header line between expanded and contracted.
1543 void wxStyledTextCtrl::ToggleFold(int line
) {
1544 SendMsg(2231, line
, 0);
1547 // Ensure a particular line is visible by expanding any header line hiding it.
1548 void wxStyledTextCtrl::EnsureVisible(int line
) {
1549 SendMsg(2232, line
, 0);
1552 // Set some style options for folding.
1553 void wxStyledTextCtrl::SetFoldFlags(int flags
) {
1554 SendMsg(2233, flags
, 0);
1557 // Ensure a particular line is visible by expanding any header line hiding it.
1558 // Use the currently set visibility policy to determine which range to display.
1559 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line
) {
1560 SendMsg(2234, line
, 0);
1563 // Sets whether a tab pressed when caret is within indentation indents.
1564 void wxStyledTextCtrl::SetTabIndents(bool tabIndents
) {
1565 SendMsg(2260, tabIndents
, 0);
1568 // Does a tab pressed when caret is within indentation indent?
1569 bool wxStyledTextCtrl::GetTabIndents() {
1570 return SendMsg(2261, 0, 0) != 0;
1573 // Sets whether a backspace pressed when caret is within indentation unindents.
1574 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents
) {
1575 SendMsg(2262, bsUnIndents
, 0);
1578 // Does a backspace pressed when caret is within indentation unindent?
1579 bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1580 return SendMsg(2263, 0, 0) != 0;
1583 // Sets the time the mouse must sit still to generate a mouse dwell event.
1584 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds
) {
1585 SendMsg(2264, periodMilliseconds
, 0);
1588 // Retrieve the time the mouse must sit still to generate a mouse dwell event.
1589 int wxStyledTextCtrl::GetMouseDwellTime() {
1590 return SendMsg(2265, 0, 0);
1593 // Get position of start of word.
1594 int wxStyledTextCtrl::WordStartPosition(int pos
, bool onlyWordCharacters
) {
1595 return SendMsg(2266, pos
, onlyWordCharacters
);
1598 // Get position of end of word.
1599 int wxStyledTextCtrl::WordEndPosition(int pos
, bool onlyWordCharacters
) {
1600 return SendMsg(2267, pos
, onlyWordCharacters
);
1603 // Sets whether text is word wrapped.
1604 void wxStyledTextCtrl::SetWrapMode(int mode
) {
1605 SendMsg(2268, mode
, 0);
1608 // Retrieve whether text is word wrapped.
1609 int wxStyledTextCtrl::GetWrapMode() {
1610 return SendMsg(2269, 0, 0);
1613 // Set the display mode of visual flags for wrapped lines.
1614 void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags
) {
1615 SendMsg(2460, wrapVisualFlags
, 0);
1618 // Retrive the display mode of visual flags for wrapped lines.
1619 int wxStyledTextCtrl::GetWrapVisualFlags() {
1620 return SendMsg(2461, 0, 0);
1623 // Set the location of visual flags for wrapped lines.
1624 void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation
) {
1625 SendMsg(2462, wrapVisualFlagsLocation
, 0);
1628 // Retrive the location of visual flags for wrapped lines.
1629 int wxStyledTextCtrl::GetWrapVisualFlagsLocation() {
1630 return SendMsg(2463, 0, 0);
1633 // Set the start indent for wrapped lines.
1634 void wxStyledTextCtrl::SetWrapStartIndent(int indent
) {
1635 SendMsg(2464, indent
, 0);
1638 // Retrive the start indent for wrapped lines.
1639 int wxStyledTextCtrl::GetWrapStartIndent() {
1640 return SendMsg(2465, 0, 0);
1643 // Sets the degree of caching of layout information.
1644 void wxStyledTextCtrl::SetLayoutCache(int mode
) {
1645 SendMsg(2272, mode
, 0);
1648 // Retrieve the degree of caching of layout information.
1649 int wxStyledTextCtrl::GetLayoutCache() {
1650 return SendMsg(2273, 0, 0);
1653 // Sets the document width assumed for scrolling.
1654 void wxStyledTextCtrl::SetScrollWidth(int pixelWidth
) {
1655 SendMsg(2274, pixelWidth
, 0);
1658 // Retrieve the document width assumed for scrolling.
1659 int wxStyledTextCtrl::GetScrollWidth() {
1660 return SendMsg(2275, 0, 0);
1663 // Measure the pixel width of some text in a particular style.
1664 // NUL terminated text argument.
1665 // Does not handle tab or control characters.
1666 int wxStyledTextCtrl::TextWidth(int style
, const wxString
& text
) {
1667 return SendMsg(2276, style
, (long)(const char*)wx2stc(text
));
1670 // Sets the scroll range so that maximum scroll position has
1671 // the last line at the bottom of the view (default).
1672 // Setting this to false allows scrolling one page below the last line.
1673 void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine
) {
1674 SendMsg(2277, endAtLastLine
, 0);
1677 // Retrieve whether the maximum scroll position has the last
1678 // line at the bottom of the view.
1679 bool wxStyledTextCtrl::GetEndAtLastLine() {
1680 return SendMsg(2278, 0, 0) != 0;
1683 // Retrieve the height of a particular line of text in pixels.
1684 int wxStyledTextCtrl::TextHeight(int line
) {
1685 return SendMsg(2279, line
, 0);
1688 // Show or hide the vertical scroll bar.
1689 void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show
) {
1690 SendMsg(2280, show
, 0);
1693 // Is the vertical scroll bar visible?
1694 bool wxStyledTextCtrl::GetUseVerticalScrollBar() {
1695 return SendMsg(2281, 0, 0) != 0;
1698 // Append a string to the end of the document without changing the selection.
1699 void wxStyledTextCtrl::AppendText(const wxString
& text
) {
1700 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1701 SendMsg(2282, strlen(buf
), (long)(const char*)buf
);
1704 // Is drawing done in two phases with backgrounds drawn before foregrounds?
1705 bool wxStyledTextCtrl::GetTwoPhaseDraw() {
1706 return SendMsg(2283, 0, 0) != 0;
1709 // In twoPhaseDraw mode, drawing is performed in two phases, first the background
1710 // and then the foreground. This avoids chopping off characters that overlap the next run.
1711 void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase
) {
1712 SendMsg(2284, twoPhase
, 0);
1715 // Make the target range start and end be the same as the selection range start and end.
1716 void wxStyledTextCtrl::TargetFromSelection() {
1717 SendMsg(2287, 0, 0);
1720 // Join the lines in the target.
1721 void wxStyledTextCtrl::LinesJoin() {
1722 SendMsg(2288, 0, 0);
1725 // Split the lines in the target into lines that are less wide than pixelWidth
1727 void wxStyledTextCtrl::LinesSplit(int pixelWidth
) {
1728 SendMsg(2289, pixelWidth
, 0);
1731 // Set the colours used as a chequerboard pattern in the fold margin
1732 void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting
, const wxColour
& back
) {
1733 SendMsg(2290, useSetting
, wxColourAsLong(back
));
1735 void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting
, const wxColour
& fore
) {
1736 SendMsg(2291, useSetting
, wxColourAsLong(fore
));
1739 // Move caret down one line.
1740 void wxStyledTextCtrl::LineDown() {
1741 SendMsg(2300, 0, 0);
1744 // Move caret down one line extending selection to new caret position.
1745 void wxStyledTextCtrl::LineDownExtend() {
1746 SendMsg(2301, 0, 0);
1749 // Move caret up one line.
1750 void wxStyledTextCtrl::LineUp() {
1751 SendMsg(2302, 0, 0);
1754 // Move caret up one line extending selection to new caret position.
1755 void wxStyledTextCtrl::LineUpExtend() {
1756 SendMsg(2303, 0, 0);
1759 // Move caret left one character.
1760 void wxStyledTextCtrl::CharLeft() {
1761 SendMsg(2304, 0, 0);
1764 // Move caret left one character extending selection to new caret position.
1765 void wxStyledTextCtrl::CharLeftExtend() {
1766 SendMsg(2305, 0, 0);
1769 // Move caret right one character.
1770 void wxStyledTextCtrl::CharRight() {
1771 SendMsg(2306, 0, 0);
1774 // Move caret right one character extending selection to new caret position.
1775 void wxStyledTextCtrl::CharRightExtend() {
1776 SendMsg(2307, 0, 0);
1779 // Move caret left one word.
1780 void wxStyledTextCtrl::WordLeft() {
1781 SendMsg(2308, 0, 0);
1784 // Move caret left one word extending selection to new caret position.
1785 void wxStyledTextCtrl::WordLeftExtend() {
1786 SendMsg(2309, 0, 0);
1789 // Move caret right one word.
1790 void wxStyledTextCtrl::WordRight() {
1791 SendMsg(2310, 0, 0);
1794 // Move caret right one word extending selection to new caret position.
1795 void wxStyledTextCtrl::WordRightExtend() {
1796 SendMsg(2311, 0, 0);
1799 // Move caret to first position on line.
1800 void wxStyledTextCtrl::Home() {
1801 SendMsg(2312, 0, 0);
1804 // Move caret to first position on line extending selection to new caret position.
1805 void wxStyledTextCtrl::HomeExtend() {
1806 SendMsg(2313, 0, 0);
1809 // Move caret to last position on line.
1810 void wxStyledTextCtrl::LineEnd() {
1811 SendMsg(2314, 0, 0);
1814 // Move caret to last position on line extending selection to new caret position.
1815 void wxStyledTextCtrl::LineEndExtend() {
1816 SendMsg(2315, 0, 0);
1819 // Move caret to first position in document.
1820 void wxStyledTextCtrl::DocumentStart() {
1821 SendMsg(2316, 0, 0);
1824 // Move caret to first position in document extending selection to new caret position.
1825 void wxStyledTextCtrl::DocumentStartExtend() {
1826 SendMsg(2317, 0, 0);
1829 // Move caret to last position in document.
1830 void wxStyledTextCtrl::DocumentEnd() {
1831 SendMsg(2318, 0, 0);
1834 // Move caret to last position in document extending selection to new caret position.
1835 void wxStyledTextCtrl::DocumentEndExtend() {
1836 SendMsg(2319, 0, 0);
1839 // Move caret one page up.
1840 void wxStyledTextCtrl::PageUp() {
1841 SendMsg(2320, 0, 0);
1844 // Move caret one page up extending selection to new caret position.
1845 void wxStyledTextCtrl::PageUpExtend() {
1846 SendMsg(2321, 0, 0);
1849 // Move caret one page down.
1850 void wxStyledTextCtrl::PageDown() {
1851 SendMsg(2322, 0, 0);
1854 // Move caret one page down extending selection to new caret position.
1855 void wxStyledTextCtrl::PageDownExtend() {
1856 SendMsg(2323, 0, 0);
1859 // Switch from insert to overtype mode or the reverse.
1860 void wxStyledTextCtrl::EditToggleOvertype() {
1861 SendMsg(2324, 0, 0);
1864 // Cancel any modes such as call tip or auto-completion list display.
1865 void wxStyledTextCtrl::Cancel() {
1866 SendMsg(2325, 0, 0);
1869 // Delete the selection or if no selection, the character before the caret.
1870 void wxStyledTextCtrl::DeleteBack() {
1871 SendMsg(2326, 0, 0);
1874 // If selection is empty or all on one line replace the selection with a tab character.
1875 // If more than one line selected, indent the lines.
1876 void wxStyledTextCtrl::Tab() {
1877 SendMsg(2327, 0, 0);
1880 // Dedent the selected lines.
1881 void wxStyledTextCtrl::BackTab() {
1882 SendMsg(2328, 0, 0);
1885 // Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
1886 void wxStyledTextCtrl::NewLine() {
1887 SendMsg(2329, 0, 0);
1890 // Insert a Form Feed character.
1891 void wxStyledTextCtrl::FormFeed() {
1892 SendMsg(2330, 0, 0);
1895 // Move caret to before first visible character on line.
1896 // If already there move to first character on line.
1897 void wxStyledTextCtrl::VCHome() {
1898 SendMsg(2331, 0, 0);
1901 // Like VCHome but extending selection to new caret position.
1902 void wxStyledTextCtrl::VCHomeExtend() {
1903 SendMsg(2332, 0, 0);
1906 // Magnify the displayed text by increasing the sizes by 1 point.
1907 void wxStyledTextCtrl::ZoomIn() {
1908 SendMsg(2333, 0, 0);
1911 // Make the displayed text smaller by decreasing the sizes by 1 point.
1912 void wxStyledTextCtrl::ZoomOut() {
1913 SendMsg(2334, 0, 0);
1916 // Delete the word to the left of the caret.
1917 void wxStyledTextCtrl::DelWordLeft() {
1918 SendMsg(2335, 0, 0);
1921 // Delete the word to the right of the caret.
1922 void wxStyledTextCtrl::DelWordRight() {
1923 SendMsg(2336, 0, 0);
1926 // Cut the line containing the caret.
1927 void wxStyledTextCtrl::LineCut() {
1928 SendMsg(2337, 0, 0);
1931 // Delete the line containing the caret.
1932 void wxStyledTextCtrl::LineDelete() {
1933 SendMsg(2338, 0, 0);
1936 // Switch the current line with the previous.
1937 void wxStyledTextCtrl::LineTranspose() {
1938 SendMsg(2339, 0, 0);
1941 // Duplicate the current line.
1942 void wxStyledTextCtrl::LineDuplicate() {
1943 SendMsg(2404, 0, 0);
1946 // Transform the selection to lower case.
1947 void wxStyledTextCtrl::LowerCase() {
1948 SendMsg(2340, 0, 0);
1951 // Transform the selection to upper case.
1952 void wxStyledTextCtrl::UpperCase() {
1953 SendMsg(2341, 0, 0);
1956 // Scroll the document down, keeping the caret visible.
1957 void wxStyledTextCtrl::LineScrollDown() {
1958 SendMsg(2342, 0, 0);
1961 // Scroll the document up, keeping the caret visible.
1962 void wxStyledTextCtrl::LineScrollUp() {
1963 SendMsg(2343, 0, 0);
1966 // Delete the selection or if no selection, the character before the caret.
1967 // Will not delete the character before at the start of a line.
1968 void wxStyledTextCtrl::DeleteBackNotLine() {
1969 SendMsg(2344, 0, 0);
1972 // Move caret to first position on display line.
1973 void wxStyledTextCtrl::HomeDisplay() {
1974 SendMsg(2345, 0, 0);
1977 // Move caret to first position on display line extending selection to
1978 // new caret position.
1979 void wxStyledTextCtrl::HomeDisplayExtend() {
1980 SendMsg(2346, 0, 0);
1983 // Move caret to last position on display line.
1984 void wxStyledTextCtrl::LineEndDisplay() {
1985 SendMsg(2347, 0, 0);
1988 // Move caret to last position on display line extending selection to new
1990 void wxStyledTextCtrl::LineEndDisplayExtend() {
1991 SendMsg(2348, 0, 0);
1994 // These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
1995 // except they behave differently when word-wrap is enabled:
1996 // They go first to the start / end of the display line, like (Home|LineEnd)Display
1997 // The difference is that, the cursor is already at the point, it goes on to the start
1998 // or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
1999 void wxStyledTextCtrl::HomeWrap() {
2000 SendMsg(2349, 0, 0);
2002 void wxStyledTextCtrl::HomeWrapExtend() {
2003 SendMsg(2450, 0, 0);
2005 void wxStyledTextCtrl::LineEndWrap() {
2006 SendMsg(2451, 0, 0);
2008 void wxStyledTextCtrl::LineEndWrapExtend() {
2009 SendMsg(2452, 0, 0);
2011 void wxStyledTextCtrl::VCHomeWrap() {
2012 SendMsg(2453, 0, 0);
2014 void wxStyledTextCtrl::VCHomeWrapExtend() {
2015 SendMsg(2454, 0, 0);
2018 // Copy the line containing the caret.
2019 void wxStyledTextCtrl::LineCopy() {
2020 SendMsg(2455, 0, 0);
2023 // Move the caret inside current view if it's not there already.
2024 void wxStyledTextCtrl::MoveCaretInsideView() {
2025 SendMsg(2401, 0, 0);
2028 // How many characters are on a line, not including end of line characters?
2029 int wxStyledTextCtrl::LineLength(int line
) {
2030 return SendMsg(2350, line
, 0);
2033 // Highlight the characters at two positions.
2034 void wxStyledTextCtrl::BraceHighlight(int pos1
, int pos2
) {
2035 SendMsg(2351, pos1
, pos2
);
2038 // Highlight the character at a position indicating there is no matching brace.
2039 void wxStyledTextCtrl::BraceBadLight(int pos
) {
2040 SendMsg(2352, pos
, 0);
2043 // Find the position of a matching brace or INVALID_POSITION if no match.
2044 int wxStyledTextCtrl::BraceMatch(int pos
) {
2045 return SendMsg(2353, pos
, 0);
2048 // Are the end of line characters visible?
2049 bool wxStyledTextCtrl::GetViewEOL() {
2050 return SendMsg(2355, 0, 0) != 0;
2053 // Make the end of line characters visible or invisible.
2054 void wxStyledTextCtrl::SetViewEOL(bool visible
) {
2055 SendMsg(2356, visible
, 0);
2058 // Retrieve a pointer to the document object.
2059 void* wxStyledTextCtrl::GetDocPointer() {
2060 return (void*)SendMsg(2357);
2063 // Change the document object used.
2064 void wxStyledTextCtrl::SetDocPointer(void* docPointer
) {
2065 SendMsg(2358, 0, (long)docPointer
);
2068 // Set which document modification events are sent to the container.
2069 void wxStyledTextCtrl::SetModEventMask(int mask
) {
2070 SendMsg(2359, mask
, 0);
2073 // Retrieve the column number which text should be kept within.
2074 int wxStyledTextCtrl::GetEdgeColumn() {
2075 return SendMsg(2360, 0, 0);
2078 // Set the column number of the edge.
2079 // If text goes past the edge then it is highlighted.
2080 void wxStyledTextCtrl::SetEdgeColumn(int column
) {
2081 SendMsg(2361, column
, 0);
2084 // Retrieve the edge highlight mode.
2085 int wxStyledTextCtrl::GetEdgeMode() {
2086 return SendMsg(2362, 0, 0);
2089 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
2090 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
2091 void wxStyledTextCtrl::SetEdgeMode(int mode
) {
2092 SendMsg(2363, mode
, 0);
2095 // Retrieve the colour used in edge indication.
2096 wxColour
wxStyledTextCtrl::GetEdgeColour() {
2097 long c
= SendMsg(2364, 0, 0);
2098 return wxColourFromLong(c
);
2101 // Change the colour used in edge indication.
2102 void wxStyledTextCtrl::SetEdgeColour(const wxColour
& edgeColour
) {
2103 SendMsg(2365, wxColourAsLong(edgeColour
), 0);
2106 // Sets the current caret position to be the search anchor.
2107 void wxStyledTextCtrl::SearchAnchor() {
2108 SendMsg(2366, 0, 0);
2111 // Find some text starting at the search anchor.
2112 // Does not ensure the selection is visible.
2113 int wxStyledTextCtrl::SearchNext(int flags
, const wxString
& text
) {
2114 return SendMsg(2367, flags
, (long)(const char*)wx2stc(text
));
2117 // Find some text starting at the search anchor and moving backwards.
2118 // Does not ensure the selection is visible.
2119 int wxStyledTextCtrl::SearchPrev(int flags
, const wxString
& text
) {
2120 return SendMsg(2368, flags
, (long)(const char*)wx2stc(text
));
2123 // Retrieves the number of lines completely visible.
2124 int wxStyledTextCtrl::LinesOnScreen() {
2125 return SendMsg(2370, 0, 0);
2128 // Set whether a pop up menu is displayed automatically when the user presses
2129 // the wrong mouse button.
2130 void wxStyledTextCtrl::UsePopUp(bool allowPopUp
) {
2131 SendMsg(2371, allowPopUp
, 0);
2134 // Is the selection rectangular? The alternative is the more common stream selection.
2135 bool wxStyledTextCtrl::SelectionIsRectangle() {
2136 return SendMsg(2372, 0, 0) != 0;
2139 // Set the zoom level. This number of points is added to the size of all fonts.
2140 // It may be positive to magnify or negative to reduce.
2141 void wxStyledTextCtrl::SetZoom(int zoom
) {
2142 SendMsg(2373, zoom
, 0);
2145 // Retrieve the zoom level.
2146 int wxStyledTextCtrl::GetZoom() {
2147 return SendMsg(2374, 0, 0);
2150 // Create a new document object.
2151 // Starts with reference count of 1 and not selected into editor.
2152 void* wxStyledTextCtrl::CreateDocument() {
2153 return (void*)SendMsg(2375);
2156 // Extend life of document.
2157 void wxStyledTextCtrl::AddRefDocument(void* docPointer
) {
2158 SendMsg(2376, 0, (long)docPointer
);
2161 // Release a reference to the document, deleting document if it fades to black.
2162 void wxStyledTextCtrl::ReleaseDocument(void* docPointer
) {
2163 SendMsg(2377, 0, (long)docPointer
);
2166 // Get which document modification events are sent to the container.
2167 int wxStyledTextCtrl::GetModEventMask() {
2168 return SendMsg(2378, 0, 0);
2171 // Change internal focus flag.
2172 void wxStyledTextCtrl::SetSTCFocus(bool focus
) {
2173 SendMsg(2380, focus
, 0);
2176 // Get internal focus flag.
2177 bool wxStyledTextCtrl::GetSTCFocus() {
2178 return SendMsg(2381, 0, 0) != 0;
2181 // Change error status - 0 = OK.
2182 void wxStyledTextCtrl::SetStatus(int statusCode
) {
2183 SendMsg(2382, statusCode
, 0);
2186 // Get error status.
2187 int wxStyledTextCtrl::GetStatus() {
2188 return SendMsg(2383, 0, 0);
2191 // Set whether the mouse is captured when its button is pressed.
2192 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures
) {
2193 SendMsg(2384, captures
, 0);
2196 // Get whether mouse gets captured.
2197 bool wxStyledTextCtrl::GetMouseDownCaptures() {
2198 return SendMsg(2385, 0, 0) != 0;
2201 // Sets the cursor to one of the SC_CURSOR* values.
2202 void wxStyledTextCtrl::SetSTCCursor(int cursorType
) {
2203 SendMsg(2386, cursorType
, 0);
2207 int wxStyledTextCtrl::GetSTCCursor() {
2208 return SendMsg(2387, 0, 0);
2211 // Change the way control characters are displayed:
2212 // If symbol is < 32, keep the drawn way, else, use the given character.
2213 void wxStyledTextCtrl::SetControlCharSymbol(int symbol
) {
2214 SendMsg(2388, symbol
, 0);
2217 // Get the way control characters are displayed.
2218 int wxStyledTextCtrl::GetControlCharSymbol() {
2219 return SendMsg(2389, 0, 0);
2222 // Move to the previous change in capitalisation.
2223 void wxStyledTextCtrl::WordPartLeft() {
2224 SendMsg(2390, 0, 0);
2227 // Move to the previous change in capitalisation extending selection
2228 // to new caret position.
2229 void wxStyledTextCtrl::WordPartLeftExtend() {
2230 SendMsg(2391, 0, 0);
2233 // Move to the change next in capitalisation.
2234 void wxStyledTextCtrl::WordPartRight() {
2235 SendMsg(2392, 0, 0);
2238 // Move to the next change in capitalisation extending selection
2239 // to new caret position.
2240 void wxStyledTextCtrl::WordPartRightExtend() {
2241 SendMsg(2393, 0, 0);
2244 // Set the way the display area is determined when a particular line
2245 // is to be moved to by Find, FindNext, GotoLine, etc.
2246 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy
, int visibleSlop
) {
2247 SendMsg(2394, visiblePolicy
, visibleSlop
);
2250 // Delete back from the current position to the start of the line.
2251 void wxStyledTextCtrl::DelLineLeft() {
2252 SendMsg(2395, 0, 0);
2255 // Delete forwards from the current position to the end of the line.
2256 void wxStyledTextCtrl::DelLineRight() {
2257 SendMsg(2396, 0, 0);
2260 // Get and Set the xOffset (ie, horizonal scroll position).
2261 void wxStyledTextCtrl::SetXOffset(int newOffset
) {
2262 SendMsg(2397, newOffset
, 0);
2264 int wxStyledTextCtrl::GetXOffset() {
2265 return SendMsg(2398, 0, 0);
2268 // Set the last x chosen value to be the caret x position.
2269 void wxStyledTextCtrl::ChooseCaretX() {
2270 SendMsg(2399, 0, 0);
2273 // Set the way the caret is kept visible when going sideway.
2274 // The exclusion zone is given in pixels.
2275 void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy
, int caretSlop
) {
2276 SendMsg(2402, caretPolicy
, caretSlop
);
2279 // Set the way the line the caret is on is kept visible.
2280 // The exclusion zone is given in lines.
2281 void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy
, int caretSlop
) {
2282 SendMsg(2403, caretPolicy
, caretSlop
);
2285 // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
2286 void wxStyledTextCtrl::SetPrintWrapMode(int mode
) {
2287 SendMsg(2406, mode
, 0);
2290 // Is printing line wrapped?
2291 int wxStyledTextCtrl::GetPrintWrapMode() {
2292 return SendMsg(2407, 0, 0);
2295 // Set a fore colour for active hotspots.
2296 void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting
, const wxColour
& fore
) {
2297 SendMsg(2410, useSetting
, wxColourAsLong(fore
));
2300 // Set a back colour for active hotspots.
2301 void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting
, const wxColour
& back
) {
2302 SendMsg(2411, useSetting
, wxColourAsLong(back
));
2305 // Enable / Disable underlining active hotspots.
2306 void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline
) {
2307 SendMsg(2412, underline
, 0);
2310 // Limit hotspots to single line so hotspots on two lines don't merge.
2311 void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine
) {
2312 SendMsg(2421, singleLine
, 0);
2315 // Move caret between paragraphs (delimited by empty lines).
2316 void wxStyledTextCtrl::ParaDown() {
2317 SendMsg(2413, 0, 0);
2319 void wxStyledTextCtrl::ParaDownExtend() {
2320 SendMsg(2414, 0, 0);
2322 void wxStyledTextCtrl::ParaUp() {
2323 SendMsg(2415, 0, 0);
2325 void wxStyledTextCtrl::ParaUpExtend() {
2326 SendMsg(2416, 0, 0);
2329 // Given a valid document position, return the previous position taking code
2330 // page into account. Returns 0 if passed 0.
2331 int wxStyledTextCtrl::PositionBefore(int pos
) {
2332 return SendMsg(2417, pos
, 0);
2335 // Given a valid document position, return the next position taking code
2336 // page into account. Maximum value returned is the last position in the document.
2337 int wxStyledTextCtrl::PositionAfter(int pos
) {
2338 return SendMsg(2418, pos
, 0);
2341 // Copy a range of text to the clipboard. Positions are clipped into the document.
2342 void wxStyledTextCtrl::CopyRange(int start
, int end
) {
2343 SendMsg(2419, start
, end
);
2346 // Copy argument text to the clipboard.
2347 void wxStyledTextCtrl::CopyText(int length
, const wxString
& text
) {
2348 SendMsg(2420, length
, (long)(const char*)wx2stc(text
));
2351 // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or
2352 // by lines (SC_SEL_LINES).
2353 void wxStyledTextCtrl::SetSelectionMode(int mode
) {
2354 SendMsg(2422, mode
, 0);
2357 // Get the mode of the current selection.
2358 int wxStyledTextCtrl::GetSelectionMode() {
2359 return SendMsg(2423, 0, 0);
2362 // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
2363 int wxStyledTextCtrl::GetLineSelStartPosition(int line
) {
2364 return SendMsg(2424, line
, 0);
2367 // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
2368 int wxStyledTextCtrl::GetLineSelEndPosition(int line
) {
2369 return SendMsg(2425, line
, 0);
2372 // Move caret down one line, extending rectangular selection to new caret position.
2373 void wxStyledTextCtrl::LineDownRectExtend() {
2374 SendMsg(2426, 0, 0);
2377 // Move caret up one line, extending rectangular selection to new caret position.
2378 void wxStyledTextCtrl::LineUpRectExtend() {
2379 SendMsg(2427, 0, 0);
2382 // Move caret left one character, extending rectangular selection to new caret position.
2383 void wxStyledTextCtrl::CharLeftRectExtend() {
2384 SendMsg(2428, 0, 0);
2387 // Move caret right one character, extending rectangular selection to new caret position.
2388 void wxStyledTextCtrl::CharRightRectExtend() {
2389 SendMsg(2429, 0, 0);
2392 // Move caret to first position on line, extending rectangular selection to new caret position.
2393 void wxStyledTextCtrl::HomeRectExtend() {
2394 SendMsg(2430, 0, 0);
2397 // Move caret to before first visible character on line.
2398 // If already there move to first character on line.
2399 // In either case, extend rectangular selection to new caret position.
2400 void wxStyledTextCtrl::VCHomeRectExtend() {
2401 SendMsg(2431, 0, 0);
2404 // Move caret to last position on line, extending rectangular selection to new caret position.
2405 void wxStyledTextCtrl::LineEndRectExtend() {
2406 SendMsg(2432, 0, 0);
2409 // Move caret one page up, extending rectangular selection to new caret position.
2410 void wxStyledTextCtrl::PageUpRectExtend() {
2411 SendMsg(2433, 0, 0);
2414 // Move caret one page down, extending rectangular selection to new caret position.
2415 void wxStyledTextCtrl::PageDownRectExtend() {
2416 SendMsg(2434, 0, 0);
2419 // Move caret to top of page, or one page up if already at top of page.
2420 void wxStyledTextCtrl::StutteredPageUp() {
2421 SendMsg(2435, 0, 0);
2424 // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
2425 void wxStyledTextCtrl::StutteredPageUpExtend() {
2426 SendMsg(2436, 0, 0);
2429 // Move caret to bottom of page, or one page down if already at bottom of page.
2430 void wxStyledTextCtrl::StutteredPageDown() {
2431 SendMsg(2437, 0, 0);
2434 // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
2435 void wxStyledTextCtrl::StutteredPageDownExtend() {
2436 SendMsg(2438, 0, 0);
2439 // Move caret left one word, position cursor at end of word.
2440 void wxStyledTextCtrl::WordLeftEnd() {
2441 SendMsg(2439, 0, 0);
2444 // Move caret left one word, position cursor at end of word, extending selection to new caret position.
2445 void wxStyledTextCtrl::WordLeftEndExtend() {
2446 SendMsg(2440, 0, 0);
2449 // Move caret right one word, position cursor at end of word.
2450 void wxStyledTextCtrl::WordRightEnd() {
2451 SendMsg(2441, 0, 0);
2454 // Move caret right one word, position cursor at end of word, extending selection to new caret position.
2455 void wxStyledTextCtrl::WordRightEndExtend() {
2456 SendMsg(2442, 0, 0);
2459 // Set the set of characters making up whitespace for when moving or selecting by word.
2460 // Should be called after SetWordChars.
2461 void wxStyledTextCtrl::SetWhitespaceChars(const wxString
& characters
) {
2462 SendMsg(2443, 0, (long)(const char*)wx2stc(characters
));
2465 // Reset the set of characters for whitespace and word characters to the defaults.
2466 void wxStyledTextCtrl::SetCharsDefault() {
2467 SendMsg(2444, 0, 0);
2470 // Get currently selected item position in the auto-completion list
2471 int wxStyledTextCtrl::AutoCompGetCurrent() {
2472 return SendMsg(2445, 0, 0);
2475 // Enlarge the document to a particular size of text bytes.
2476 void wxStyledTextCtrl::Allocate(int bytes
) {
2477 SendMsg(2446, bytes
, 0);
2480 // Find the position of a column on a line taking into account tabs and
2481 // multi-byte characters. If beyond end of line, return line end position.
2482 int wxStyledTextCtrl::FindColumn(int line
, int column
) {
2483 return SendMsg(2456, line
, column
);
2486 // Can the caret preferred x position only be changed by explicit movement commands?
2487 bool wxStyledTextCtrl::GetCaretSticky() {
2488 return SendMsg(2457, 0, 0) != 0;
2491 // Stop the caret preferred x position changing when the user types.
2492 void wxStyledTextCtrl::SetCaretSticky(bool useCaretStickyBehaviour
) {
2493 SendMsg(2458, useCaretStickyBehaviour
, 0);
2496 // Switch between sticky and non-sticky: meant to be bound to a key.
2497 void wxStyledTextCtrl::ToggleCaretSticky() {
2498 SendMsg(2459, 0, 0);
2501 // Enable/Disable convert-on-paste for line endings
2502 void wxStyledTextCtrl::SetPasteConvertEndings(bool convert
) {
2503 SendMsg(2467, convert
, 0);
2506 // Get convert-on-paste setting
2507 bool wxStyledTextCtrl::GetPasteConvertEndings() {
2508 return SendMsg(2468, 0, 0) != 0;
2511 // Duplicate the selection. If selection empty duplicate the line containing the caret.
2512 void wxStyledTextCtrl::SelectionDuplicate() {
2513 SendMsg(2469, 0, 0);
2516 // Set background alpha of the caret line.
2517 void wxStyledTextCtrl::SetCaretLineBackAlpha(int alpha
) {
2518 SendMsg(2470, alpha
, 0);
2521 // Get the background alpha of the caret line.
2522 int wxStyledTextCtrl::GetCaretLineBackAlpha() {
2523 return SendMsg(2471, 0, 0);
2526 // Start notifying the container of all key presses and commands.
2527 void wxStyledTextCtrl::StartRecord() {
2528 SendMsg(3001, 0, 0);
2531 // Stop notifying the container of all key presses and commands.
2532 void wxStyledTextCtrl::StopRecord() {
2533 SendMsg(3002, 0, 0);
2536 // Set the lexing language of the document.
2537 void wxStyledTextCtrl::SetLexer(int lexer
) {
2538 SendMsg(4001, lexer
, 0);
2541 // Retrieve the lexing language of the document.
2542 int wxStyledTextCtrl::GetLexer() {
2543 return SendMsg(4002, 0, 0);
2546 // Colourise a segment of the document using the current lexing language.
2547 void wxStyledTextCtrl::Colourise(int start
, int end
) {
2548 SendMsg(4003, start
, end
);
2551 // Set up a value that may be used by a lexer for some optional feature.
2552 void wxStyledTextCtrl::SetProperty(const wxString
& key
, const wxString
& value
) {
2553 SendMsg(4004, (long)(const char*)wx2stc(key
), (long)(const char*)wx2stc(value
));
2556 // Set up the key words used by the lexer.
2557 void wxStyledTextCtrl::SetKeyWords(int keywordSet
, const wxString
& keyWords
) {
2558 SendMsg(4005, keywordSet
, (long)(const char*)wx2stc(keyWords
));
2561 // Set the lexing language of the document based on string name.
2562 void wxStyledTextCtrl::SetLexerLanguage(const wxString
& language
) {
2563 SendMsg(4006, 0, (long)(const char*)wx2stc(language
));
2566 // Retrieve a 'property' value previously set with SetProperty.
2567 wxString
wxStyledTextCtrl::GetProperty(const wxString
& key
) {
2568 int len
= SendMsg(SCI_GETPROPERTY
, (long)(const char*)wx2stc(key
), 0);
2569 if (!len
) return wxEmptyString
;
2571 wxMemoryBuffer
mbuf(len
+1);
2572 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
2573 SendMsg(4008, (long)(const char*)wx2stc(key
), (long)buf
);
2574 mbuf
.UngetWriteBuf(len
);
2579 // Retrieve a 'property' value previously set with SetProperty,
2580 // with '$()' variable replacement on returned buffer.
2581 wxString
wxStyledTextCtrl::GetPropertyExpanded(const wxString
& key
) {
2582 int len
= SendMsg(SCI_GETPROPERTYEXPANDED
, (long)(const char*)wx2stc(key
), 0);
2583 if (!len
) return wxEmptyString
;
2585 wxMemoryBuffer
mbuf(len
+1);
2586 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
2587 SendMsg(4009, (long)(const char*)wx2stc(key
), (long)buf
);
2588 mbuf
.UngetWriteBuf(len
);
2593 // Retrieve a 'property' value previously set with SetProperty,
2594 // interpreted as an int AFTER any '$()' variable replacement.
2595 int wxStyledTextCtrl::GetPropertyInt(const wxString
& key
) {
2596 return SendMsg(4010, (long)(const char*)wx2stc(key
), 0);
2599 // Retrieve the number of bits the current lexer needs for styling.
2600 int wxStyledTextCtrl::GetStyleBitsNeeded() {
2601 return SendMsg(4011, 0, 0);
2604 // END of generated section
2605 //----------------------------------------------------------------------
2608 // Returns the line number of the line with the caret.
2609 int wxStyledTextCtrl::GetCurrentLine() {
2610 int line
= LineFromPosition(GetCurrentPos());
2615 // Extract style settings from a spec-string which is composed of one or
2616 // more of the following comma separated elements:
2618 // bold turns on bold
2619 // italic turns on italics
2620 // fore:[name or #RRGGBB] sets the foreground colour
2621 // back:[name or #RRGGBB] sets the background colour
2622 // face:[facename] sets the font face name to use
2623 // size:[num] sets the font size in points
2624 // eol turns on eol filling
2625 // underline turns on underlining
2627 void wxStyledTextCtrl::StyleSetSpec(int styleNum
, const wxString
& spec
) {
2629 wxStringTokenizer
tkz(spec
, wxT(","));
2630 while (tkz
.HasMoreTokens()) {
2631 wxString token
= tkz
.GetNextToken();
2633 wxString option
= token
.BeforeFirst(':');
2634 wxString val
= token
.AfterFirst(':');
2636 if (option
== wxT("bold"))
2637 StyleSetBold(styleNum
, true);
2639 else if (option
== wxT("italic"))
2640 StyleSetItalic(styleNum
, true);
2642 else if (option
== wxT("underline"))
2643 StyleSetUnderline(styleNum
, true);
2645 else if (option
== wxT("eol"))
2646 StyleSetEOLFilled(styleNum
, true);
2648 else if (option
== wxT("size")) {
2650 if (val
.ToLong(&points
))
2651 StyleSetSize(styleNum
, points
);
2654 else if (option
== wxT("face"))
2655 StyleSetFaceName(styleNum
, val
);
2657 else if (option
== wxT("fore"))
2658 StyleSetForeground(styleNum
, wxColourFromSpec(val
));
2660 else if (option
== wxT("back"))
2661 StyleSetBackground(styleNum
, wxColourFromSpec(val
));
2666 // Set style size, face, bold, italic, and underline attributes from
2667 // a wxFont's attributes.
2668 void wxStyledTextCtrl::StyleSetFont(int styleNum
, wxFont
& font
) {
2670 // Ensure that the native font is initialized
2672 GetTextExtent(wxT("X"), &x
, &y
, NULL
, NULL
, &font
);
2674 int size
= font
.GetPointSize();
2675 wxString faceName
= font
.GetFaceName();
2676 bool bold
= font
.GetWeight() == wxBOLD
;
2677 bool italic
= font
.GetStyle() != wxNORMAL
;
2678 bool under
= font
.GetUnderlined();
2679 wxFontEncoding encoding
= font
.GetEncoding();
2681 StyleSetFontAttr(styleNum
, size
, faceName
, bold
, italic
, under
, encoding
);
2684 // Set all font style attributes at once.
2685 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum
, int size
,
2686 const wxString
& faceName
,
2687 bool bold
, bool italic
,
2689 wxFontEncoding encoding
) {
2690 StyleSetSize(styleNum
, size
);
2691 StyleSetFaceName(styleNum
, faceName
);
2692 StyleSetBold(styleNum
, bold
);
2693 StyleSetItalic(styleNum
, italic
);
2694 StyleSetUnderline(styleNum
, underline
);
2695 StyleSetFontEncoding(styleNum
, encoding
);
2699 // Set the character set of the font in a style. Converts the Scintilla
2700 // character set values to a wxFontEncoding.
2701 void wxStyledTextCtrl::StyleSetCharacterSet(int style
, int characterSet
)
2703 wxFontEncoding encoding
;
2705 // Translate the Scintilla characterSet to a wxFontEncoding
2706 switch (characterSet
) {
2708 case wxSTC_CHARSET_ANSI
:
2709 case wxSTC_CHARSET_DEFAULT
:
2710 encoding
= wxFONTENCODING_DEFAULT
;
2713 case wxSTC_CHARSET_BALTIC
:
2714 encoding
= wxFONTENCODING_ISO8859_13
;
2717 case wxSTC_CHARSET_CHINESEBIG5
:
2718 encoding
= wxFONTENCODING_CP950
;
2721 case wxSTC_CHARSET_EASTEUROPE
:
2722 encoding
= wxFONTENCODING_ISO8859_2
;
2725 case wxSTC_CHARSET_GB2312
:
2726 encoding
= wxFONTENCODING_CP936
;
2729 case wxSTC_CHARSET_GREEK
:
2730 encoding
= wxFONTENCODING_ISO8859_7
;
2733 case wxSTC_CHARSET_HANGUL
:
2734 encoding
= wxFONTENCODING_CP949
;
2737 case wxSTC_CHARSET_MAC
:
2738 encoding
= wxFONTENCODING_DEFAULT
;
2741 case wxSTC_CHARSET_OEM
:
2742 encoding
= wxFONTENCODING_DEFAULT
;
2745 case wxSTC_CHARSET_RUSSIAN
:
2746 encoding
= wxFONTENCODING_KOI8
;
2749 case wxSTC_CHARSET_SHIFTJIS
:
2750 encoding
= wxFONTENCODING_CP932
;
2753 case wxSTC_CHARSET_SYMBOL
:
2754 encoding
= wxFONTENCODING_DEFAULT
;
2757 case wxSTC_CHARSET_TURKISH
:
2758 encoding
= wxFONTENCODING_ISO8859_9
;
2761 case wxSTC_CHARSET_JOHAB
:
2762 encoding
= wxFONTENCODING_DEFAULT
;
2765 case wxSTC_CHARSET_HEBREW
:
2766 encoding
= wxFONTENCODING_ISO8859_8
;
2769 case wxSTC_CHARSET_ARABIC
:
2770 encoding
= wxFONTENCODING_ISO8859_6
;
2773 case wxSTC_CHARSET_VIETNAMESE
:
2774 encoding
= wxFONTENCODING_DEFAULT
;
2777 case wxSTC_CHARSET_THAI
:
2778 encoding
= wxFONTENCODING_ISO8859_11
;
2781 case wxSTC_CHARSET_CYRILLIC
:
2782 encoding
= wxFONTENCODING_ISO8859_5
;
2785 case wxSTC_CHARSET_8859_15
:
2786 encoding
= wxFONTENCODING_ISO8859_15
;;
2790 // We just have Scintilla track the wxFontEncoding for us. It gets used
2791 // in Font::Create in PlatWX.cpp. We add one to the value so that the
2792 // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
2793 // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
2794 // to wxFONENCODING_DEFAULT in Font::Create.
2795 SendMsg(SCI_STYLESETCHARACTERSET
, style
, encoding
+1);
2799 // Set the font encoding to be used by a style.
2800 void wxStyledTextCtrl::StyleSetFontEncoding(int style
, wxFontEncoding encoding
)
2802 SendMsg(SCI_STYLESETCHARACTERSET
, style
, encoding
+1);
2806 // Perform one of the operations defined by the wxSTC_CMD_* constants.
2807 void wxStyledTextCtrl::CmdKeyExecute(int cmd
) {
2812 // Set the left and right margin in the edit area, measured in pixels.
2813 void wxStyledTextCtrl::SetMargins(int left
, int right
) {
2814 SetMarginLeft(left
);
2815 SetMarginRight(right
);
2819 // Retrieve the start and end positions of the current selection.
2820 void wxStyledTextCtrl::GetSelection(int* startPos
, int* endPos
) {
2821 if (startPos
!= NULL
)
2822 *startPos
= SendMsg(SCI_GETSELECTIONSTART
);
2824 *endPos
= SendMsg(SCI_GETSELECTIONEND
);
2828 // Retrieve the point in the window where a position is displayed.
2829 wxPoint
wxStyledTextCtrl::PointFromPosition(int pos
) {
2830 int x
= SendMsg(SCI_POINTXFROMPOSITION
, 0, pos
);
2831 int y
= SendMsg(SCI_POINTYFROMPOSITION
, 0, pos
);
2832 return wxPoint(x
, y
);
2835 // Scroll enough to make the given line visible
2836 void wxStyledTextCtrl::ScrollToLine(int line
) {
2837 m_swx
->DoScrollToLine(line
);
2841 // Scroll enough to make the given column visible
2842 void wxStyledTextCtrl::ScrollToColumn(int column
) {
2843 m_swx
->DoScrollToColumn(column
);
2847 bool wxStyledTextCtrl::SaveFile(const wxString
& filename
)
2849 wxFile
file(filename
, wxFile::write
);
2851 if (!file
.IsOpened())
2854 bool success
= file
.Write(GetText(), *wxConvCurrent
);
2862 bool wxStyledTextCtrl::LoadFile(const wxString
& filename
)
2864 bool success
= false;
2865 wxFile
file(filename
, wxFile::read
);
2867 if (file
.IsOpened())
2870 // get the file size (assume it is not huge file...)
2871 ssize_t len
= (ssize_t
)file
.Length();
2876 wxMemoryBuffer
buffer(len
+1);
2877 success
= (file
.Read(buffer
.GetData(), len
) == len
);
2879 ((char*)buffer
.GetData())[len
] = 0;
2880 contents
= wxString(buffer
, *wxConvCurrent
, len
);
2884 success
= (file
.Read(wxStringBuffer(buffer
, len
), len
) == len
);
2891 success
= true; // empty file is ok
2893 success
= false; // len == wxInvalidOffset
2908 #if wxUSE_DRAG_AND_DROP
2909 wxDragResult
wxStyledTextCtrl::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
2910 return m_swx
->DoDragOver(x
, y
, def
);
2914 bool wxStyledTextCtrl::DoDropText(long x
, long y
, const wxString
& data
) {
2915 return m_swx
->DoDropText(x
, y
, data
);
2920 void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA
) {
2921 m_swx
->SetUseAntiAliasing(useAA
);
2924 bool wxStyledTextCtrl::GetUseAntiAliasing() {
2925 return m_swx
->GetUseAntiAliasing();
2932 void wxStyledTextCtrl::AddTextRaw(const char* text
)
2934 SendMsg(SCI_ADDTEXT
, strlen(text
), (long)text
);
2937 void wxStyledTextCtrl::InsertTextRaw(int pos
, const char* text
)
2939 SendMsg(SCI_INSERTTEXT
, pos
, (long)text
);
2942 wxCharBuffer
wxStyledTextCtrl::GetCurLineRaw(int* linePos
)
2944 int len
= LineLength(GetCurrentLine());
2946 if (linePos
) *linePos
= 0;
2951 wxCharBuffer
buf(len
);
2952 int pos
= SendMsg(SCI_GETCURLINE
, len
, (long)buf
.data());
2953 if (linePos
) *linePos
= pos
;
2957 wxCharBuffer
wxStyledTextCtrl::GetLineRaw(int line
)
2959 int len
= LineLength(line
);
2965 wxCharBuffer
buf(len
);
2966 SendMsg(SCI_GETLINE
, line
, (long)buf
.data());
2970 wxCharBuffer
wxStyledTextCtrl::GetSelectedTextRaw()
2975 GetSelection(&start
, &end
);
2976 int len
= end
- start
;
2982 wxCharBuffer
buf(len
);
2983 SendMsg(SCI_GETSELTEXT
, 0, (long)buf
.data());
2987 wxCharBuffer
wxStyledTextCtrl::GetTextRangeRaw(int startPos
, int endPos
)
2989 if (endPos
< startPos
) {
2990 int temp
= startPos
;
2994 int len
= endPos
- startPos
;
3000 wxCharBuffer
buf(len
);
3002 tr
.lpstrText
= buf
.data();
3003 tr
.chrg
.cpMin
= startPos
;
3004 tr
.chrg
.cpMax
= endPos
;
3005 SendMsg(SCI_GETTEXTRANGE
, 0, (long)&tr
);
3009 void wxStyledTextCtrl::SetTextRaw(const char* text
)
3011 SendMsg(SCI_SETTEXT
, 0, (long)text
);
3014 wxCharBuffer
wxStyledTextCtrl::GetTextRaw()
3016 int len
= GetTextLength();
3017 wxCharBuffer
buf(len
);
3018 SendMsg(SCI_GETTEXT
, len
, (long)buf
.data());
3022 void wxStyledTextCtrl::AppendTextRaw(const char* text
)
3024 SendMsg(SCI_APPENDTEXT
, strlen(text
), (long)text
);
3031 //----------------------------------------------------------------------
3034 void wxStyledTextCtrl::OnPaint(wxPaintEvent
& WXUNUSED(evt
)) {
3036 m_swx
->DoPaint(&dc
, GetUpdateRegion().GetBox());
3039 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent
& evt
) {
3040 if (evt
.GetOrientation() == wxHORIZONTAL
)
3041 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
3043 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
3046 void wxStyledTextCtrl::OnScroll(wxScrollEvent
& evt
) {
3047 wxScrollBar
* sb
= wxDynamicCast(evt
.GetEventObject(), wxScrollBar
);
3049 if (sb
->IsVertical())
3050 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
3052 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
3056 void wxStyledTextCtrl::OnSize(wxSizeEvent
& WXUNUSED(evt
)) {
3058 wxSize sz
= GetClientSize();
3059 m_swx
->DoSize(sz
.x
, sz
.y
);
3063 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent
& evt
) {
3065 wxPoint pt
= evt
.GetPosition();
3066 m_swx
->DoLeftButtonDown(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
3067 evt
.ShiftDown(), evt
.ControlDown(), evt
.AltDown());
3070 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent
& evt
) {
3071 wxPoint pt
= evt
.GetPosition();
3072 m_swx
->DoLeftButtonMove(Point(pt
.x
, pt
.y
));
3075 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent
& evt
) {
3076 wxPoint pt
= evt
.GetPosition();
3077 m_swx
->DoLeftButtonUp(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
3082 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent
& evt
) {
3083 wxPoint pt
= evt
.GetPosition();
3084 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
3088 void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent
& evt
) {
3089 wxPoint pt
= evt
.GetPosition();
3090 m_swx
->DoMiddleButtonUp(Point(pt
.x
, pt
.y
));
3093 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent
& evt
) {
3094 wxPoint pt
= evt
.GetPosition();
3095 ScreenToClient(&pt
.x
, &pt
.y
);
3097 Show context menu at event point if it's within the window,
3098 or at caret location if not
3100 wxHitTest ht
= this->HitTest(pt
);
3101 if (ht
!= wxHT_WINDOW_INSIDE
) {
3102 pt
= this->PointFromPosition(this->GetCurrentPos());
3104 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
3108 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent
& evt
) {
3109 m_swx
->DoMouseWheel(evt
.GetWheelRotation(),
3110 evt
.GetWheelDelta(),
3111 evt
.GetLinesPerAction(),
3113 evt
.IsPageScroll());
3117 void wxStyledTextCtrl::OnChar(wxKeyEvent
& evt
) {
3118 // On (some?) non-US PC keyboards the AltGr key is required to enter some
3119 // common characters. It comes to us as both Alt and Ctrl down so we need
3120 // to let the char through in that case, otherwise if only ctrl or only
3121 // alt let's skip it.
3122 bool ctrl
= evt
.ControlDown();
3124 // On the Mac the Alt key is just a modifier key (like Shift) so we need
3125 // to allow the char events to be processed when Alt is pressed.
3126 // TODO: Should we check MetaDown instead in this case?
3129 bool alt
= evt
.AltDown();
3131 bool skip
= ((ctrl
|| alt
) && ! (ctrl
&& alt
));
3134 // apparently if we don't do this, Unicode keys pressed after non-char
3135 // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989)
3136 if (m_lastKeyDownConsumed
&& evt
.GetUnicodeKey() > 255)
3137 m_lastKeyDownConsumed
= false;
3140 if (!m_lastKeyDownConsumed
&& !skip
) {
3142 int key
= evt
.GetUnicodeKey();
3145 // if the unicode key code is not really a unicode character (it may
3146 // be a function key or etc., the platforms appear to always give us a
3147 // small value in this case) then fallback to the ascii key code but
3148 // don't do anything for function keys or etc.
3150 key
= evt
.GetKeyCode();
3151 keyOk
= (key
<= 127);
3154 m_swx
->DoAddChar(key
);
3158 int key
= evt
.GetKeyCode();
3159 if (key
<= WXK_START
|| key
> WXK_COMMAND
) {
3160 m_swx
->DoAddChar(key
);
3170 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent
& evt
) {
3171 int processed
= m_swx
->DoKeyDown(evt
, &m_lastKeyDownConsumed
);
3172 if (!processed
&& !m_lastKeyDownConsumed
)
3177 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent
& evt
) {
3178 m_swx
->DoLoseFocus();
3183 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent
& evt
) {
3184 m_swx
->DoGainFocus();
3189 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent
& WXUNUSED(evt
)) {
3190 m_swx
->DoSysColourChange();
3194 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent
& WXUNUSED(evt
)) {
3195 // do nothing to help avoid flashing
3200 void wxStyledTextCtrl::OnMenu(wxCommandEvent
& evt
) {
3201 m_swx
->DoCommand(evt
.GetId());
3205 void wxStyledTextCtrl::OnListBox(wxCommandEvent
& WXUNUSED(evt
)) {
3206 m_swx
->DoOnListBox();
3210 void wxStyledTextCtrl::OnIdle(wxIdleEvent
& evt
) {
3211 m_swx
->DoOnIdle(evt
);
3215 wxSize
wxStyledTextCtrl::DoGetBestSize() const
3217 // What would be the best size for a wxSTC?
3218 // Just give a reasonable minimum until something else can be figured out.
3219 return wxSize(200,100);
3223 //----------------------------------------------------------------------
3224 // Turn notifications from Scintilla into events
3227 void wxStyledTextCtrl::NotifyChange() {
3228 wxStyledTextEvent
evt(wxEVT_STC_CHANGE
, GetId());
3229 evt
.SetEventObject(this);
3230 GetEventHandler()->ProcessEvent(evt
);
3234 static void SetEventText(wxStyledTextEvent
& evt
, const char* text
,
3238 evt
.SetText(stc2wx(text
, length
));
3242 void wxStyledTextCtrl::NotifyParent(SCNotification
* _scn
) {
3243 SCNotification
& scn
= *_scn
;
3244 wxStyledTextEvent
evt(0, GetId());
3246 evt
.SetEventObject(this);
3247 evt
.SetPosition(scn
.position
);
3249 evt
.SetModifiers(scn
.modifiers
);
3251 switch (scn
.nmhdr
.code
) {
3252 case SCN_STYLENEEDED
:
3253 evt
.SetEventType(wxEVT_STC_STYLENEEDED
);
3257 evt
.SetEventType(wxEVT_STC_CHARADDED
);
3260 case SCN_SAVEPOINTREACHED
:
3261 evt
.SetEventType(wxEVT_STC_SAVEPOINTREACHED
);
3264 case SCN_SAVEPOINTLEFT
:
3265 evt
.SetEventType(wxEVT_STC_SAVEPOINTLEFT
);
3268 case SCN_MODIFYATTEMPTRO
:
3269 evt
.SetEventType(wxEVT_STC_ROMODIFYATTEMPT
);
3273 evt
.SetEventType(wxEVT_STC_KEY
);
3276 case SCN_DOUBLECLICK
:
3277 evt
.SetEventType(wxEVT_STC_DOUBLECLICK
);
3281 evt
.SetEventType(wxEVT_STC_UPDATEUI
);
3285 evt
.SetEventType(wxEVT_STC_MODIFIED
);
3286 evt
.SetModificationType(scn
.modificationType
);
3287 SetEventText(evt
, scn
.text
, scn
.length
);
3288 evt
.SetLength(scn
.length
);
3289 evt
.SetLinesAdded(scn
.linesAdded
);
3290 evt
.SetLine(scn
.line
);
3291 evt
.SetFoldLevelNow(scn
.foldLevelNow
);
3292 evt
.SetFoldLevelPrev(scn
.foldLevelPrev
);
3295 case SCN_MACRORECORD
:
3296 evt
.SetEventType(wxEVT_STC_MACRORECORD
);
3297 evt
.SetMessage(scn
.message
);
3298 evt
.SetWParam(scn
.wParam
);
3299 evt
.SetLParam(scn
.lParam
);
3302 case SCN_MARGINCLICK
:
3303 evt
.SetEventType(wxEVT_STC_MARGINCLICK
);
3304 evt
.SetMargin(scn
.margin
);
3308 evt
.SetEventType(wxEVT_STC_NEEDSHOWN
);
3309 evt
.SetLength(scn
.length
);
3313 evt
.SetEventType(wxEVT_STC_PAINTED
);
3316 case SCN_AUTOCSELECTION
:
3317 evt
.SetEventType(wxEVT_STC_AUTOCOMP_SELECTION
);
3318 evt
.SetListType(scn
.listType
);
3319 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
3320 evt
.SetPosition(scn
.lParam
);
3323 case SCN_USERLISTSELECTION
:
3324 evt
.SetEventType(wxEVT_STC_USERLISTSELECTION
);
3325 evt
.SetListType(scn
.listType
);
3326 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
3327 evt
.SetPosition(scn
.lParam
);
3330 case SCN_URIDROPPED
:
3331 evt
.SetEventType(wxEVT_STC_URIDROPPED
);
3332 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
3335 case SCN_DWELLSTART
:
3336 evt
.SetEventType(wxEVT_STC_DWELLSTART
);
3342 evt
.SetEventType(wxEVT_STC_DWELLEND
);
3348 evt
.SetEventType(wxEVT_STC_ZOOM
);
3351 case SCN_HOTSPOTCLICK
:
3352 evt
.SetEventType(wxEVT_STC_HOTSPOT_CLICK
);
3355 case SCN_HOTSPOTDOUBLECLICK
:
3356 evt
.SetEventType(wxEVT_STC_HOTSPOT_DCLICK
);
3359 case SCN_CALLTIPCLICK
:
3360 evt
.SetEventType(wxEVT_STC_CALLTIP_CLICK
);
3367 GetEventHandler()->ProcessEvent(evt
);
3371 //----------------------------------------------------------------------
3372 //----------------------------------------------------------------------
3373 //----------------------------------------------------------------------
3375 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType
, int id
)
3376 : wxCommandEvent(commandType
, id
)
3381 m_modificationType
= 0;
3386 m_foldLevelPrev
= 0;
3394 m_dragAllowMove
= false;
3395 #if wxUSE_DRAG_AND_DROP
3396 m_dragResult
= wxDragNone
;
3400 bool wxStyledTextEvent::GetShift() const { return (m_modifiers
& SCI_SHIFT
) != 0; }
3401 bool wxStyledTextEvent::GetControl() const { return (m_modifiers
& SCI_CTRL
) != 0; }
3402 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers
& SCI_ALT
) != 0; }
3405 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent
& event
):
3406 wxCommandEvent(event
)
3408 m_position
= event
.m_position
;
3409 m_key
= event
.m_key
;
3410 m_modifiers
= event
.m_modifiers
;
3411 m_modificationType
= event
.m_modificationType
;
3412 m_text
= event
.m_text
;
3413 m_length
= event
.m_length
;
3414 m_linesAdded
= event
.m_linesAdded
;
3415 m_line
= event
.m_line
;
3416 m_foldLevelNow
= event
.m_foldLevelNow
;
3417 m_foldLevelPrev
= event
.m_foldLevelPrev
;
3419 m_margin
= event
.m_margin
;
3421 m_message
= event
.m_message
;
3422 m_wParam
= event
.m_wParam
;
3423 m_lParam
= event
.m_lParam
;
3425 m_listType
= event
.m_listType
;
3429 m_dragText
= event
.m_dragText
;
3430 m_dragAllowMove
=event
.m_dragAllowMove
;
3431 #if wxUSE_DRAG_AND_DROP
3432 m_dragResult
= event
.m_dragResult
;
3436 //----------------------------------------------------------------------
3437 //----------------------------------------------------------------------