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 /////////////////////////////////////////////////////////////////////////////
21 #include "wx/tokenzr.h"
22 #include "wx/mstream.h"
26 #include "wx/stc/stc.h"
27 #include "ScintillaWX.h"
29 //----------------------------------------------------------------------
31 const wxChar
* wxSTCNameStr
= wxT("stcwindow");
37 #define MAKELONG(a, b) ((a) | ((b) << 16))
40 static long wxColourAsLong(const wxColour
& co
) {
41 return (((long)co
.Blue() << 16) |
42 ((long)co
.Green() << 8) |
46 static wxColour
wxColourFromLong(long c
) {
48 clr
.Set((unsigned char)(c
& 0xff),
49 (unsigned char)((c
>> 8) & 0xff),
50 (unsigned char)((c
>> 16) & 0xff));
55 static wxColour
wxColourFromSpec(const wxString
& spec
) {
56 // spec should be a colour name or "#RRGGBB"
57 if (spec
.GetChar(0) == wxT('#')) {
59 long red
, green
, blue
;
60 red
= green
= blue
= 0;
61 spec
.Mid(1,2).ToLong(&red
, 16);
62 spec
.Mid(3,2).ToLong(&green
, 16);
63 spec
.Mid(5,2).ToLong(&blue
, 16);
64 return wxColour((unsigned char)red
,
69 return wxColour(spec
);
72 //----------------------------------------------------------------------
74 DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE
)
75 DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED
)
76 DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED
)
77 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED
)
78 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT
)
79 DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT
)
80 DEFINE_EVENT_TYPE( wxEVT_STC_KEY
)
81 DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK
)
82 DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI
)
83 DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED
)
84 DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD
)
85 DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK
)
86 DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN
)
87 DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED
)
88 DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION
)
89 DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED
)
90 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART
)
91 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND
)
92 DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG
)
93 DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER
)
94 DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP
)
95 DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM
)
96 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK
)
97 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK
)
98 DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK
)
99 DEFINE_EVENT_TYPE( wxEVT_STC_AUTOCOMP_SELECTION
)
103 BEGIN_EVENT_TABLE(wxStyledTextCtrl
, wxControl
)
104 EVT_PAINT (wxStyledTextCtrl::OnPaint
)
105 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin
)
106 EVT_SCROLL (wxStyledTextCtrl::OnScroll
)
107 EVT_SIZE (wxStyledTextCtrl::OnSize
)
108 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown
)
109 // Let Scintilla see the double click as a second click
110 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown
)
111 EVT_MOTION (wxStyledTextCtrl::OnMouseMove
)
112 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp
)
113 #if defined(__WXGTK__) || defined(__WXMAC__)
114 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp
)
116 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu
)
118 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel
)
119 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp
)
120 EVT_CHAR (wxStyledTextCtrl::OnChar
)
121 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown
)
122 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus
)
123 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus
)
124 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged
)
125 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground
)
126 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu
)
127 EVT_LISTBOX_DCLICK (wxID_ANY
, wxStyledTextCtrl::OnListBox
)
131 IMPLEMENT_CLASS(wxStyledTextCtrl
, wxControl
)
132 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent
, wxCommandEvent
)
135 // forces the linking of the lexer modules
136 int Scintilla_LinkLexers();
139 //----------------------------------------------------------------------
140 // Constructor and Destructor
142 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow
*parent
,
147 const wxString
& name
)
150 Create(parent
, id
, pos
, size
, style
, name
);
154 bool wxStyledTextCtrl::Create(wxWindow
*parent
,
159 const wxString
& name
)
161 style
|= wxVSCROLL
| wxHSCROLL
;
162 if (!wxControl::Create(parent
, id
, pos
, size
,
163 style
| wxWANTS_CHARS
| wxCLIP_CHILDREN
,
164 wxDefaultValidator
, name
))
168 Scintilla_LinkLexers();
170 m_swx
= new ScintillaWX(this);
172 m_lastKeyDownConsumed
= false;
176 // Put Scintilla into unicode (UTF-8) mode
177 SetCodePage(wxSTC_CP_UTF8
);
180 SetInitialSize(size
);
182 // Reduces flicker on GTK+/X11
183 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
188 wxStyledTextCtrl::~wxStyledTextCtrl() {
193 //----------------------------------------------------------------------
195 long wxStyledTextCtrl::SendMsg(int msg
, long wp
, long lp
) {
197 return m_swx
->WndProc(msg
, wp
, lp
);
200 //----------------------------------------------------------------------
202 // Set the vertical scrollbar to use instead of the ont that's built-in.
203 void wxStyledTextCtrl::SetVScrollBar(wxScrollBar
* bar
) {
206 // ensure that the built-in scrollbar is not visible
207 SetScrollbar(wxVERTICAL
, 0, 0, 0);
212 // Set the horizontal scrollbar to use instead of the ont that's built-in.
213 void wxStyledTextCtrl::SetHScrollBar(wxScrollBar
* bar
) {
216 // ensure that the built-in scrollbar is not visible
217 SetScrollbar(wxHORIZONTAL
, 0, 0, 0);
221 //----------------------------------------------------------------------
222 // BEGIN generated section. The following code is automatically generated
223 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
224 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
227 // Add text to the document at current position.
228 void wxStyledTextCtrl::AddText(const wxString
& text
) {
229 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
230 SendMsg(2001, strlen(buf
), (long)(const char*)buf
);
233 // Add array of cells to document.
234 void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer
& data
) {
235 SendMsg(2002, data
.GetDataLen(), (long)data
.GetData());
238 // Insert string at a position.
239 void wxStyledTextCtrl::InsertText(int pos
, const wxString
& text
) {
240 SendMsg(2003, pos
, (long)(const char*)wx2stc(text
));
243 // Delete all text in the document.
244 void wxStyledTextCtrl::ClearAll() {
248 // Set all style bytes to 0, remove all folding information.
249 void wxStyledTextCtrl::ClearDocumentStyle() {
253 // Returns the number of characters in the document.
254 int wxStyledTextCtrl::GetLength() {
255 return SendMsg(2006, 0, 0);
258 // Returns the character byte at the position.
259 int wxStyledTextCtrl::GetCharAt(int pos
) {
260 return (unsigned char)SendMsg(2007, pos
, 0);
263 // Returns the position of the caret.
264 int wxStyledTextCtrl::GetCurrentPos() {
265 return SendMsg(2008, 0, 0);
268 // Returns the position of the opposite end of the selection to the caret.
269 int wxStyledTextCtrl::GetAnchor() {
270 return SendMsg(2009, 0, 0);
273 // Returns the style byte at the position.
274 int wxStyledTextCtrl::GetStyleAt(int pos
) {
275 return (unsigned char)SendMsg(2010, pos
, 0);
278 // Redoes the next action on the undo history.
279 void wxStyledTextCtrl::Redo() {
283 // Choose between collecting actions into the undo
284 // history and discarding them.
285 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo
) {
286 SendMsg(2012, collectUndo
, 0);
289 // Select all the text in the document.
290 void wxStyledTextCtrl::SelectAll() {
294 // Remember the current position in the undo history as the position
295 // at which the document was saved.
296 void wxStyledTextCtrl::SetSavePoint() {
300 // Retrieve a buffer of cells.
301 wxMemoryBuffer
wxStyledTextCtrl::GetStyledText(int startPos
, int endPos
) {
303 if (endPos
< startPos
) {
308 int len
= endPos
- startPos
;
309 if (!len
) return buf
;
311 tr
.lpstrText
= (char*)buf
.GetWriteBuf(len
*2+1);
312 tr
.chrg
.cpMin
= startPos
;
313 tr
.chrg
.cpMax
= endPos
;
314 len
= SendMsg(2015, 0, (long)&tr
);
315 buf
.UngetWriteBuf(len
);
319 // Are there any redoable actions in the undo history?
320 bool wxStyledTextCtrl::CanRedo() {
321 return SendMsg(2016, 0, 0) != 0;
324 // Retrieve the line number at which a particular marker is located.
325 int wxStyledTextCtrl::MarkerLineFromHandle(int handle
) {
326 return SendMsg(2017, handle
, 0);
330 void wxStyledTextCtrl::MarkerDeleteHandle(int handle
) {
331 SendMsg(2018, handle
, 0);
334 // Is undo history being collected?
335 bool wxStyledTextCtrl::GetUndoCollection() {
336 return SendMsg(2019, 0, 0) != 0;
339 // Are white space characters currently visible?
340 // Returns one of SCWS_* constants.
341 int wxStyledTextCtrl::GetViewWhiteSpace() {
342 return SendMsg(2020, 0, 0);
345 // Make white space characters invisible, always visible or visible outside indentation.
346 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS
) {
347 SendMsg(2021, viewWS
, 0);
350 // Find the position from a point within the window.
351 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt
) {
352 return SendMsg(2022, pt
.x
, pt
.y
);
355 // Find the position from a point within the window but return
356 // INVALID_POSITION if not close to text.
357 int wxStyledTextCtrl::PositionFromPointClose(int x
, int y
) {
358 return SendMsg(2023, x
, y
);
361 // Set caret to start of a line and ensure it is visible.
362 void wxStyledTextCtrl::GotoLine(int line
) {
363 SendMsg(2024, line
, 0);
366 // Set caret to a position and ensure it is visible.
367 void wxStyledTextCtrl::GotoPos(int pos
) {
368 SendMsg(2025, pos
, 0);
371 // Set the selection anchor to a position. The anchor is the opposite
372 // end of the selection from the caret.
373 void wxStyledTextCtrl::SetAnchor(int posAnchor
) {
374 SendMsg(2026, posAnchor
, 0);
377 // Retrieve the text of the line containing the caret.
378 // Returns the index of the caret on the line.
379 wxString
wxStyledTextCtrl::GetCurLine(int* linePos
) {
380 int len
= LineLength(GetCurrentLine());
382 if (linePos
) *linePos
= 0;
383 return wxEmptyString
;
386 wxMemoryBuffer
mbuf(len
+1);
387 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
389 int pos
= SendMsg(2027, len
+1, (long)buf
);
390 mbuf
.UngetWriteBuf(len
);
392 if (linePos
) *linePos
= pos
;
396 // Retrieve the position of the last correctly styled character.
397 int wxStyledTextCtrl::GetEndStyled() {
398 return SendMsg(2028, 0, 0);
401 // Convert all line endings in the document to one mode.
402 void wxStyledTextCtrl::ConvertEOLs(int eolMode
) {
403 SendMsg(2029, eolMode
, 0);
406 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
407 int wxStyledTextCtrl::GetEOLMode() {
408 return SendMsg(2030, 0, 0);
411 // Set the current end of line mode.
412 void wxStyledTextCtrl::SetEOLMode(int eolMode
) {
413 SendMsg(2031, eolMode
, 0);
416 // Set the current styling position to pos and the styling mask to mask.
417 // The styling mask can be used to protect some bits in each styling byte from modification.
418 void wxStyledTextCtrl::StartStyling(int pos
, int mask
) {
419 SendMsg(2032, pos
, mask
);
422 // Change style from current styling position for length characters to a style
423 // and move the current styling position to after this newly styled segment.
424 void wxStyledTextCtrl::SetStyling(int length
, int style
) {
425 SendMsg(2033, length
, style
);
428 // Is drawing done first into a buffer or direct to the screen?
429 bool wxStyledTextCtrl::GetBufferedDraw() {
430 return SendMsg(2034, 0, 0) != 0;
433 // If drawing is buffered then each line of text is drawn into a bitmap buffer
434 // before drawing it to the screen to avoid flicker.
435 void wxStyledTextCtrl::SetBufferedDraw(bool buffered
) {
436 SendMsg(2035, buffered
, 0);
439 // Change the visible size of a tab to be a multiple of the width of a space character.
440 void wxStyledTextCtrl::SetTabWidth(int tabWidth
) {
441 SendMsg(2036, tabWidth
, 0);
444 // Retrieve the visible size of a tab.
445 int wxStyledTextCtrl::GetTabWidth() {
446 return SendMsg(2121, 0, 0);
449 // Set the code page used to interpret the bytes of the document as characters.
450 void wxStyledTextCtrl::SetCodePage(int codePage
) {
452 wxASSERT_MSG(codePage
== wxSTC_CP_UTF8
,
453 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
455 wxASSERT_MSG(codePage
!= wxSTC_CP_UTF8
,
456 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
458 SendMsg(2037, codePage
);
461 // Set the symbol used for a particular marker number,
462 // and optionally the fore and background colours.
463 void wxStyledTextCtrl::MarkerDefine(int markerNumber
, int markerSymbol
,
464 const wxColour
& foreground
,
465 const wxColour
& background
) {
467 SendMsg(2040, markerNumber
, markerSymbol
);
469 MarkerSetForeground(markerNumber
, foreground
);
471 MarkerSetBackground(markerNumber
, background
);
474 // Set the foreground colour used for a particular marker number.
475 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber
, const wxColour
& fore
) {
476 SendMsg(2041, markerNumber
, wxColourAsLong(fore
));
479 // Set the background colour used for a particular marker number.
480 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber
, const wxColour
& back
) {
481 SendMsg(2042, markerNumber
, wxColourAsLong(back
));
484 // Add a marker to a line, returning an ID which can be used to find or delete the marker.
485 int wxStyledTextCtrl::MarkerAdd(int line
, int markerNumber
) {
486 return SendMsg(2043, line
, markerNumber
);
489 // Delete a marker from a line.
490 void wxStyledTextCtrl::MarkerDelete(int line
, int markerNumber
) {
491 SendMsg(2044, line
, markerNumber
);
494 // Delete all markers with a particular number from all lines.
495 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber
) {
496 SendMsg(2045, markerNumber
, 0);
499 // Get a bit mask of all the markers set on a line.
500 int wxStyledTextCtrl::MarkerGet(int line
) {
501 return SendMsg(2046, line
, 0);
504 // Find the next line after lineStart that includes a marker in mask.
505 int wxStyledTextCtrl::MarkerNext(int lineStart
, int markerMask
) {
506 return SendMsg(2047, lineStart
, markerMask
);
509 // Find the previous line before lineStart that includes a marker in mask.
510 int wxStyledTextCtrl::MarkerPrevious(int lineStart
, int markerMask
) {
511 return SendMsg(2048, lineStart
, markerMask
);
514 // Define a marker from a bitmap
515 void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber
, const wxBitmap
& bmp
) {
516 // convert bmp to a xpm in a string
517 wxMemoryOutputStream strm
;
518 wxImage img
= bmp
.ConvertToImage();
520 img
.ConvertAlphaToMask();
521 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
522 size_t len
= strm
.GetSize();
523 char* buff
= new char[len
+1];
524 strm
.CopyTo(buff
, len
);
526 SendMsg(2049, markerNumber
, (long)buff
);
531 // Add a set of markers to a line.
532 void wxStyledTextCtrl::MarkerAddSet(int line
, int set
) {
533 SendMsg(2466, line
, set
);
536 // Set the alpha used for a marker that is drawn in the text area, not the margin.
537 void wxStyledTextCtrl::MarkerSetAlpha(int markerNumber
, int alpha
) {
538 SendMsg(2476, markerNumber
, alpha
);
541 // Set a margin to be either numeric or symbolic.
542 void wxStyledTextCtrl::SetMarginType(int margin
, int marginType
) {
543 SendMsg(2240, margin
, marginType
);
546 // Retrieve the type of a margin.
547 int wxStyledTextCtrl::GetMarginType(int margin
) {
548 return SendMsg(2241, margin
, 0);
551 // Set the width of a margin to a width expressed in pixels.
552 void wxStyledTextCtrl::SetMarginWidth(int margin
, int pixelWidth
) {
553 SendMsg(2242, margin
, pixelWidth
);
556 // Retrieve the width of a margin in pixels.
557 int wxStyledTextCtrl::GetMarginWidth(int margin
) {
558 return SendMsg(2243, margin
, 0);
561 // Set a mask that determines which markers are displayed in a margin.
562 void wxStyledTextCtrl::SetMarginMask(int margin
, int mask
) {
563 SendMsg(2244, margin
, mask
);
566 // Retrieve the marker mask of a margin.
567 int wxStyledTextCtrl::GetMarginMask(int margin
) {
568 return SendMsg(2245, margin
, 0);
571 // Make a margin sensitive or insensitive to mouse clicks.
572 void wxStyledTextCtrl::SetMarginSensitive(int margin
, bool sensitive
) {
573 SendMsg(2246, margin
, sensitive
);
576 // Retrieve the mouse click sensitivity of a margin.
577 bool wxStyledTextCtrl::GetMarginSensitive(int margin
) {
578 return SendMsg(2247, margin
, 0) != 0;
581 // Clear all the styles and make equivalent to the global default style.
582 void wxStyledTextCtrl::StyleClearAll() {
586 // Set the foreground colour of a style.
587 void wxStyledTextCtrl::StyleSetForeground(int style
, const wxColour
& fore
) {
588 SendMsg(2051, style
, wxColourAsLong(fore
));
591 // Set the background colour of a style.
592 void wxStyledTextCtrl::StyleSetBackground(int style
, const wxColour
& back
) {
593 SendMsg(2052, style
, wxColourAsLong(back
));
596 // Set a style to be bold or not.
597 void wxStyledTextCtrl::StyleSetBold(int style
, bool bold
) {
598 SendMsg(2053, style
, bold
);
601 // Set a style to be italic or not.
602 void wxStyledTextCtrl::StyleSetItalic(int style
, bool italic
) {
603 SendMsg(2054, style
, italic
);
606 // Set the size of characters of a style.
607 void wxStyledTextCtrl::StyleSetSize(int style
, int sizePoints
) {
608 SendMsg(2055, style
, sizePoints
);
611 // Set the font of a style.
612 void wxStyledTextCtrl::StyleSetFaceName(int style
, const wxString
& fontName
) {
613 SendMsg(2056, style
, (long)(const char*)wx2stc(fontName
));
616 // Set a style to have its end of line filled or not.
617 void wxStyledTextCtrl::StyleSetEOLFilled(int style
, bool filled
) {
618 SendMsg(2057, style
, filled
);
621 // Reset the default style to its state at startup
622 void wxStyledTextCtrl::StyleResetDefault() {
626 // Set a style to be underlined or not.
627 void wxStyledTextCtrl::StyleSetUnderline(int style
, bool underline
) {
628 SendMsg(2059, style
, underline
);
631 // Set a style to be mixed case, or to force upper or lower case.
632 void wxStyledTextCtrl::StyleSetCase(int style
, int caseForce
) {
633 SendMsg(2060, style
, caseForce
);
636 // Set a style to be a hotspot or not.
637 void wxStyledTextCtrl::StyleSetHotSpot(int style
, bool hotspot
) {
638 SendMsg(2409, style
, hotspot
);
641 // Set the foreground colour of the selection and whether to use this setting.
642 void wxStyledTextCtrl::SetSelForeground(bool useSetting
, const wxColour
& fore
) {
643 SendMsg(2067, useSetting
, wxColourAsLong(fore
));
646 // Set the background colour of the selection and whether to use this setting.
647 void wxStyledTextCtrl::SetSelBackground(bool useSetting
, const wxColour
& back
) {
648 SendMsg(2068, useSetting
, wxColourAsLong(back
));
651 // Get the alpha of the selection.
652 int wxStyledTextCtrl::GetSelAlpha() {
653 return SendMsg(2477, 0, 0);
656 // Set the alpha of the selection.
657 void wxStyledTextCtrl::SetSelAlpha(int alpha
) {
658 SendMsg(2478, alpha
, 0);
661 // Set the foreground colour of the caret.
662 void wxStyledTextCtrl::SetCaretForeground(const wxColour
& fore
) {
663 SendMsg(2069, wxColourAsLong(fore
), 0);
666 // When key+modifier combination km is pressed perform msg.
667 void wxStyledTextCtrl::CmdKeyAssign(int key
, int modifiers
, int cmd
) {
668 SendMsg(2070, MAKELONG(key
, modifiers
), cmd
);
671 // When key+modifier combination km is pressed do nothing.
672 void wxStyledTextCtrl::CmdKeyClear(int key
, int modifiers
) {
673 SendMsg(2071, MAKELONG(key
, modifiers
));
676 // Drop all key mappings.
677 void wxStyledTextCtrl::CmdKeyClearAll() {
681 // Set the styles for a segment of the document.
682 void wxStyledTextCtrl::SetStyleBytes(int length
, char* styleBytes
) {
683 SendMsg(2073, length
, (long)styleBytes
);
686 // Set a style to be visible or not.
687 void wxStyledTextCtrl::StyleSetVisible(int style
, bool visible
) {
688 SendMsg(2074, style
, visible
);
691 // Get the time in milliseconds that the caret is on and off.
692 int wxStyledTextCtrl::GetCaretPeriod() {
693 return SendMsg(2075, 0, 0);
696 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
697 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds
) {
698 SendMsg(2076, periodMilliseconds
, 0);
701 // Set the set of characters making up words for when moving or selecting by word.
702 // First sets deaults like SetCharsDefault.
703 void wxStyledTextCtrl::SetWordChars(const wxString
& characters
) {
704 SendMsg(2077, 0, (long)(const char*)wx2stc(characters
));
707 // Start a sequence of actions that is undone and redone as a unit.
709 void wxStyledTextCtrl::BeginUndoAction() {
713 // End a sequence of actions that is undone and redone as a unit.
714 void wxStyledTextCtrl::EndUndoAction() {
718 // Set an indicator to plain, squiggle or TT.
719 void wxStyledTextCtrl::IndicatorSetStyle(int indic
, int style
) {
720 SendMsg(2080, indic
, style
);
723 // Retrieve the style of an indicator.
724 int wxStyledTextCtrl::IndicatorGetStyle(int indic
) {
725 return SendMsg(2081, indic
, 0);
728 // Set the foreground colour of an indicator.
729 void wxStyledTextCtrl::IndicatorSetForeground(int indic
, const wxColour
& fore
) {
730 SendMsg(2082, indic
, wxColourAsLong(fore
));
733 // Retrieve the foreground colour of an indicator.
734 wxColour
wxStyledTextCtrl::IndicatorGetForeground(int indic
) {
735 long c
= SendMsg(2083, indic
, 0);
736 return wxColourFromLong(c
);
739 // Set the foreground colour of all whitespace and whether to use this setting.
740 void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting
, const wxColour
& fore
) {
741 SendMsg(2084, useSetting
, wxColourAsLong(fore
));
744 // Set the background colour of all whitespace and whether to use this setting.
745 void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting
, const wxColour
& back
) {
746 SendMsg(2085, useSetting
, wxColourAsLong(back
));
749 // Divide each styling byte into lexical class bits (default: 5) and indicator
750 // bits (default: 3). If a lexer requires more than 32 lexical states, then this
751 // is used to expand the possible states.
752 void wxStyledTextCtrl::SetStyleBits(int bits
) {
753 SendMsg(2090, bits
, 0);
756 // Retrieve number of bits in style bytes used to hold the lexical state.
757 int wxStyledTextCtrl::GetStyleBits() {
758 return SendMsg(2091, 0, 0);
761 // Used to hold extra styling information for each line.
762 void wxStyledTextCtrl::SetLineState(int line
, int state
) {
763 SendMsg(2092, line
, state
);
766 // Retrieve the extra styling information for a line.
767 int wxStyledTextCtrl::GetLineState(int line
) {
768 return SendMsg(2093, line
, 0);
771 // Retrieve the last line number that has line state.
772 int wxStyledTextCtrl::GetMaxLineState() {
773 return SendMsg(2094, 0, 0);
776 // Is the background of the line containing the caret in a different colour?
777 bool wxStyledTextCtrl::GetCaretLineVisible() {
778 return SendMsg(2095, 0, 0) != 0;
781 // Display the background of the line containing the caret in a different colour.
782 void wxStyledTextCtrl::SetCaretLineVisible(bool show
) {
783 SendMsg(2096, show
, 0);
786 // Get the colour of the background of the line containing the caret.
787 wxColour
wxStyledTextCtrl::GetCaretLineBackground() {
788 long c
= SendMsg(2097, 0, 0);
789 return wxColourFromLong(c
);
792 // Set the colour of the background of the line containing the caret.
793 void wxStyledTextCtrl::SetCaretLineBackground(const wxColour
& back
) {
794 SendMsg(2098, wxColourAsLong(back
), 0);
797 // Set a style to be changeable or not (read only).
798 // Experimental feature, currently buggy.
799 void wxStyledTextCtrl::StyleSetChangeable(int style
, bool changeable
) {
800 SendMsg(2099, style
, changeable
);
803 // Display a auto-completion list.
804 // The lenEntered parameter indicates how many characters before
805 // the caret should be used to provide context.
806 void wxStyledTextCtrl::AutoCompShow(int lenEntered
, const wxString
& itemList
) {
807 SendMsg(2100, lenEntered
, (long)(const char*)wx2stc(itemList
));
810 // Remove the auto-completion list from the screen.
811 void wxStyledTextCtrl::AutoCompCancel() {
815 // Is there an auto-completion list visible?
816 bool wxStyledTextCtrl::AutoCompActive() {
817 return SendMsg(2102, 0, 0) != 0;
820 // Retrieve the position of the caret when the auto-completion list was displayed.
821 int wxStyledTextCtrl::AutoCompPosStart() {
822 return SendMsg(2103, 0, 0);
825 // User has selected an item so remove the list and insert the selection.
826 void wxStyledTextCtrl::AutoCompComplete() {
830 // Define a set of character that when typed cancel the auto-completion list.
831 void wxStyledTextCtrl::AutoCompStops(const wxString
& characterSet
) {
832 SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet
));
835 // Change the separator character in the string setting up an auto-completion list.
836 // Default is space but can be changed if items contain space.
837 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter
) {
838 SendMsg(2106, separatorCharacter
, 0);
841 // Retrieve the auto-completion list separator character.
842 int wxStyledTextCtrl::AutoCompGetSeparator() {
843 return SendMsg(2107, 0, 0);
846 // Select the item in the auto-completion list that starts with a string.
847 void wxStyledTextCtrl::AutoCompSelect(const wxString
& text
) {
848 SendMsg(2108, 0, (long)(const char*)wx2stc(text
));
851 // Should the auto-completion list be cancelled if the user backspaces to a
852 // position before where the box was created.
853 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel
) {
854 SendMsg(2110, cancel
, 0);
857 // Retrieve whether auto-completion cancelled by backspacing before start.
858 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
859 return SendMsg(2111, 0, 0) != 0;
862 // Define a set of characters that when typed will cause the autocompletion to
863 // choose the selected item.
864 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString
& characterSet
) {
865 SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet
));
868 // Should a single item auto-completion list automatically choose the item.
869 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle
) {
870 SendMsg(2113, chooseSingle
, 0);
873 // Retrieve whether a single item auto-completion list automatically choose the item.
874 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
875 return SendMsg(2114, 0, 0) != 0;
878 // Set whether case is significant when performing auto-completion searches.
879 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase
) {
880 SendMsg(2115, ignoreCase
, 0);
883 // Retrieve state of ignore case flag.
884 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
885 return SendMsg(2116, 0, 0) != 0;
888 // Display a list of strings and send notification when user chooses one.
889 void wxStyledTextCtrl::UserListShow(int listType
, const wxString
& itemList
) {
890 SendMsg(2117, listType
, (long)(const char*)wx2stc(itemList
));
893 // Set whether or not autocompletion is hidden automatically when nothing matches.
894 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide
) {
895 SendMsg(2118, autoHide
, 0);
898 // Retrieve whether or not autocompletion is hidden automatically when nothing matches.
899 bool wxStyledTextCtrl::AutoCompGetAutoHide() {
900 return SendMsg(2119, 0, 0) != 0;
903 // Set whether or not autocompletion deletes any word characters
904 // after the inserted text upon completion.
905 void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord
) {
906 SendMsg(2270, dropRestOfWord
, 0);
909 // Retrieve whether or not autocompletion deletes any word characters
910 // after the inserted text upon completion.
911 bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
912 return SendMsg(2271, 0, 0) != 0;
915 // Register an image for use in autocompletion lists.
916 void wxStyledTextCtrl::RegisterImage(int type
, const wxBitmap
& bmp
) {
917 // convert bmp to a xpm in a string
918 wxMemoryOutputStream strm
;
919 wxImage img
= bmp
.ConvertToImage();
921 img
.ConvertAlphaToMask();
922 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
923 size_t len
= strm
.GetSize();
924 char* buff
= new char[len
+1];
925 strm
.CopyTo(buff
, len
);
927 SendMsg(2405, type
, (long)buff
);
932 // Clear all the registered images.
933 void wxStyledTextCtrl::ClearRegisteredImages() {
937 // Retrieve the auto-completion list type-separator character.
938 int wxStyledTextCtrl::AutoCompGetTypeSeparator() {
939 return SendMsg(2285, 0, 0);
942 // Change the type-separator character in the string setting up an auto-completion list.
943 // Default is '?' but can be changed if items contain '?'.
944 void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter
) {
945 SendMsg(2286, separatorCharacter
, 0);
948 // Set the maximum width, in characters, of auto-completion and user lists.
949 // Set to 0 to autosize to fit longest item, which is the default.
950 void wxStyledTextCtrl::AutoCompSetMaxWidth(int characterCount
) {
951 SendMsg(2208, characterCount
, 0);
954 // Get the maximum width, in characters, of auto-completion and user lists.
955 int wxStyledTextCtrl::AutoCompGetMaxWidth() {
956 return SendMsg(2209, 0, 0);
959 // Set the maximum height, in rows, of auto-completion and user lists.
960 // The default is 5 rows.
961 void wxStyledTextCtrl::AutoCompSetMaxHeight(int rowCount
) {
962 SendMsg(2210, rowCount
, 0);
965 // Set the maximum height, in rows, of auto-completion and user lists.
966 int wxStyledTextCtrl::AutoCompGetMaxHeight() {
967 return SendMsg(2211, 0, 0);
970 // Set the number of spaces used for one level of indentation.
971 void wxStyledTextCtrl::SetIndent(int indentSize
) {
972 SendMsg(2122, indentSize
, 0);
975 // Retrieve indentation size.
976 int wxStyledTextCtrl::GetIndent() {
977 return SendMsg(2123, 0, 0);
980 // Indentation will only use space characters if useTabs is false, otherwise
981 // it will use a combination of tabs and spaces.
982 void wxStyledTextCtrl::SetUseTabs(bool useTabs
) {
983 SendMsg(2124, useTabs
, 0);
986 // Retrieve whether tabs will be used in indentation.
987 bool wxStyledTextCtrl::GetUseTabs() {
988 return SendMsg(2125, 0, 0) != 0;
991 // Change the indentation of a line to a number of columns.
992 void wxStyledTextCtrl::SetLineIndentation(int line
, int indentSize
) {
993 SendMsg(2126, line
, indentSize
);
996 // Retrieve the number of columns that a line is indented.
997 int wxStyledTextCtrl::GetLineIndentation(int line
) {
998 return SendMsg(2127, line
, 0);
1001 // Retrieve the position before the first non indentation character on a line.
1002 int wxStyledTextCtrl::GetLineIndentPosition(int line
) {
1003 return SendMsg(2128, line
, 0);
1006 // Retrieve the column number of a position, taking tab width into account.
1007 int wxStyledTextCtrl::GetColumn(int pos
) {
1008 return SendMsg(2129, pos
, 0);
1011 // Show or hide the horizontal scroll bar.
1012 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show
) {
1013 SendMsg(2130, show
, 0);
1016 // Is the horizontal scroll bar visible?
1017 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
1018 return SendMsg(2131, 0, 0) != 0;
1021 // Show or hide indentation guides.
1022 void wxStyledTextCtrl::SetIndentationGuides(bool show
) {
1023 SendMsg(2132, show
, 0);
1026 // Are the indentation guides visible?
1027 bool wxStyledTextCtrl::GetIndentationGuides() {
1028 return SendMsg(2133, 0, 0) != 0;
1031 // Set the highlighted indentation guide column.
1032 // 0 = no highlighted guide.
1033 void wxStyledTextCtrl::SetHighlightGuide(int column
) {
1034 SendMsg(2134, column
, 0);
1037 // Get the highlighted indentation guide column.
1038 int wxStyledTextCtrl::GetHighlightGuide() {
1039 return SendMsg(2135, 0, 0);
1042 // Get the position after the last visible characters on a line.
1043 int wxStyledTextCtrl::GetLineEndPosition(int line
) {
1044 return SendMsg(2136, line
, 0);
1047 // Get the code page used to interpret the bytes of the document as characters.
1048 int wxStyledTextCtrl::GetCodePage() {
1049 return SendMsg(2137, 0, 0);
1052 // Get the foreground colour of the caret.
1053 wxColour
wxStyledTextCtrl::GetCaretForeground() {
1054 long c
= SendMsg(2138, 0, 0);
1055 return wxColourFromLong(c
);
1058 // In read-only mode?
1059 bool wxStyledTextCtrl::GetReadOnly() {
1060 return SendMsg(2140, 0, 0) != 0;
1063 // Sets the position of the caret.
1064 void wxStyledTextCtrl::SetCurrentPos(int pos
) {
1065 SendMsg(2141, pos
, 0);
1068 // Sets the position that starts the selection - this becomes the anchor.
1069 void wxStyledTextCtrl::SetSelectionStart(int pos
) {
1070 SendMsg(2142, pos
, 0);
1073 // Returns the position at the start of the selection.
1074 int wxStyledTextCtrl::GetSelectionStart() {
1075 return SendMsg(2143, 0, 0);
1078 // Sets the position that ends the selection - this becomes the currentPosition.
1079 void wxStyledTextCtrl::SetSelectionEnd(int pos
) {
1080 SendMsg(2144, pos
, 0);
1083 // Returns the position at the end of the selection.
1084 int wxStyledTextCtrl::GetSelectionEnd() {
1085 return SendMsg(2145, 0, 0);
1088 // Sets the print magnification added to the point size of each style for printing.
1089 void wxStyledTextCtrl::SetPrintMagnification(int magnification
) {
1090 SendMsg(2146, magnification
, 0);
1093 // Returns the print magnification.
1094 int wxStyledTextCtrl::GetPrintMagnification() {
1095 return SendMsg(2147, 0, 0);
1098 // Modify colours when printing for clearer printed text.
1099 void wxStyledTextCtrl::SetPrintColourMode(int mode
) {
1100 SendMsg(2148, mode
, 0);
1103 // Returns the print colour mode.
1104 int wxStyledTextCtrl::GetPrintColourMode() {
1105 return SendMsg(2149, 0, 0);
1108 // Find some text in the document.
1109 int wxStyledTextCtrl::FindText(int minPos
, int maxPos
,
1110 const wxString
& text
,
1113 ft
.chrg
.cpMin
= minPos
;
1114 ft
.chrg
.cpMax
= maxPos
;
1115 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1116 ft
.lpstrText
= (char*)(const char*)buf
;
1118 return SendMsg(2150, flags
, (long)&ft
);
1121 // On Windows, will draw the document into a display context such as a printer.
1122 int wxStyledTextCtrl::FormatRange(bool doDraw
,
1131 if (endPos
< startPos
) {
1132 int temp
= startPos
;
1137 fr
.hdcTarget
= target
;
1138 fr
.rc
.top
= renderRect
.GetTop();
1139 fr
.rc
.left
= renderRect
.GetLeft();
1140 fr
.rc
.right
= renderRect
.GetRight();
1141 fr
.rc
.bottom
= renderRect
.GetBottom();
1142 fr
.rcPage
.top
= pageRect
.GetTop();
1143 fr
.rcPage
.left
= pageRect
.GetLeft();
1144 fr
.rcPage
.right
= pageRect
.GetRight();
1145 fr
.rcPage
.bottom
= pageRect
.GetBottom();
1146 fr
.chrg
.cpMin
= startPos
;
1147 fr
.chrg
.cpMax
= endPos
;
1149 return SendMsg(2151, doDraw
, (long)&fr
);
1152 // Retrieve the display line at the top of the display.
1153 int wxStyledTextCtrl::GetFirstVisibleLine() {
1154 return SendMsg(2152, 0, 0);
1157 // Retrieve the contents of a line.
1158 wxString
wxStyledTextCtrl::GetLine(int line
) {
1159 int len
= LineLength(line
);
1160 if (!len
) return wxEmptyString
;
1162 wxMemoryBuffer
mbuf(len
+1);
1163 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1164 SendMsg(2153, line
, (long)buf
);
1165 mbuf
.UngetWriteBuf(len
);
1170 // Returns the number of lines in the document. There is always at least one.
1171 int wxStyledTextCtrl::GetLineCount() {
1172 return SendMsg(2154, 0, 0);
1175 // Sets the size in pixels of the left margin.
1176 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth
) {
1177 SendMsg(2155, 0, pixelWidth
);
1180 // Returns the size in pixels of the left margin.
1181 int wxStyledTextCtrl::GetMarginLeft() {
1182 return SendMsg(2156, 0, 0);
1185 // Sets the size in pixels of the right margin.
1186 void wxStyledTextCtrl::SetMarginRight(int pixelWidth
) {
1187 SendMsg(2157, 0, pixelWidth
);
1190 // Returns the size in pixels of the right margin.
1191 int wxStyledTextCtrl::GetMarginRight() {
1192 return SendMsg(2158, 0, 0);
1195 // Is the document different from when it was last saved?
1196 bool wxStyledTextCtrl::GetModify() {
1197 return SendMsg(2159, 0, 0) != 0;
1200 // Select a range of text.
1201 void wxStyledTextCtrl::SetSelection(int start
, int end
) {
1202 SendMsg(2160, start
, end
);
1205 // Retrieve the selected text.
1206 wxString
wxStyledTextCtrl::GetSelectedText() {
1210 GetSelection(&start
, &end
);
1211 int len
= end
- start
;
1212 if (!len
) return wxEmptyString
;
1214 wxMemoryBuffer
mbuf(len
+2);
1215 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1216 SendMsg(2161, 0, (long)buf
);
1217 mbuf
.UngetWriteBuf(len
);
1222 // Retrieve a range of text.
1223 wxString
wxStyledTextCtrl::GetTextRange(int startPos
, int endPos
) {
1224 if (endPos
< startPos
) {
1225 int temp
= startPos
;
1229 int len
= endPos
- startPos
;
1230 if (!len
) return wxEmptyString
;
1231 wxMemoryBuffer
mbuf(len
+1);
1232 char* buf
= (char*)mbuf
.GetWriteBuf(len
);
1235 tr
.chrg
.cpMin
= startPos
;
1236 tr
.chrg
.cpMax
= endPos
;
1237 SendMsg(2162, 0, (long)&tr
);
1238 mbuf
.UngetWriteBuf(len
);
1243 // Draw the selection in normal style or with selection highlighted.
1244 void wxStyledTextCtrl::HideSelection(bool normal
) {
1245 SendMsg(2163, normal
, 0);
1248 // Retrieve the line containing a position.
1249 int wxStyledTextCtrl::LineFromPosition(int pos
) {
1250 return SendMsg(2166, pos
, 0);
1253 // Retrieve the position at the start of a line.
1254 int wxStyledTextCtrl::PositionFromLine(int line
) {
1255 return SendMsg(2167, line
, 0);
1258 // Scroll horizontally and vertically.
1259 void wxStyledTextCtrl::LineScroll(int columns
, int lines
) {
1260 SendMsg(2168, columns
, lines
);
1263 // Ensure the caret is visible.
1264 void wxStyledTextCtrl::EnsureCaretVisible() {
1265 SendMsg(2169, 0, 0);
1268 // Replace the selected text with the argument text.
1269 void wxStyledTextCtrl::ReplaceSelection(const wxString
& text
) {
1270 SendMsg(2170, 0, (long)(const char*)wx2stc(text
));
1273 // Set to read only or read write.
1274 void wxStyledTextCtrl::SetReadOnly(bool readOnly
) {
1275 SendMsg(2171, readOnly
, 0);
1278 // Will a paste succeed?
1279 bool wxStyledTextCtrl::CanPaste() {
1280 return SendMsg(2173, 0, 0) != 0;
1283 // Are there any undoable actions in the undo history?
1284 bool wxStyledTextCtrl::CanUndo() {
1285 return SendMsg(2174, 0, 0) != 0;
1288 // Delete the undo history.
1289 void wxStyledTextCtrl::EmptyUndoBuffer() {
1290 SendMsg(2175, 0, 0);
1293 // Undo one action in the undo history.
1294 void wxStyledTextCtrl::Undo() {
1295 SendMsg(2176, 0, 0);
1298 // Cut the selection to the clipboard.
1299 void wxStyledTextCtrl::Cut() {
1300 SendMsg(2177, 0, 0);
1303 // Copy the selection to the clipboard.
1304 void wxStyledTextCtrl::Copy() {
1305 SendMsg(2178, 0, 0);
1308 // Paste the contents of the clipboard into the document replacing the selection.
1309 void wxStyledTextCtrl::Paste() {
1310 SendMsg(2179, 0, 0);
1313 // Clear the selection.
1314 void wxStyledTextCtrl::Clear() {
1315 SendMsg(2180, 0, 0);
1318 // Replace the contents of the document with the argument text.
1319 void wxStyledTextCtrl::SetText(const wxString
& text
) {
1320 SendMsg(2181, 0, (long)(const char*)wx2stc(text
));
1323 // Retrieve all the text in the document.
1324 wxString
wxStyledTextCtrl::GetText() {
1325 int len
= GetTextLength();
1326 wxMemoryBuffer
mbuf(len
+1); // leave room for the null...
1327 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1328 SendMsg(2182, len
+1, (long)buf
);
1329 mbuf
.UngetWriteBuf(len
);
1334 // Retrieve the number of characters in the document.
1335 int wxStyledTextCtrl::GetTextLength() {
1336 return SendMsg(2183, 0, 0);
1339 // Set to overtype (true) or insert mode.
1340 void wxStyledTextCtrl::SetOvertype(bool overtype
) {
1341 SendMsg(2186, overtype
, 0);
1344 // Returns true if overtype mode is active otherwise false is returned.
1345 bool wxStyledTextCtrl::GetOvertype() {
1346 return SendMsg(2187, 0, 0) != 0;
1349 // Set the width of the insert mode caret.
1350 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth
) {
1351 SendMsg(2188, pixelWidth
, 0);
1354 // Returns the width of the insert mode caret.
1355 int wxStyledTextCtrl::GetCaretWidth() {
1356 return SendMsg(2189, 0, 0);
1359 // Sets the position that starts the target which is used for updating the
1360 // document without affecting the scroll position.
1361 void wxStyledTextCtrl::SetTargetStart(int pos
) {
1362 SendMsg(2190, pos
, 0);
1365 // Get the position that starts the target.
1366 int wxStyledTextCtrl::GetTargetStart() {
1367 return SendMsg(2191, 0, 0);
1370 // Sets the position that ends the target which is used for updating the
1371 // document without affecting the scroll position.
1372 void wxStyledTextCtrl::SetTargetEnd(int pos
) {
1373 SendMsg(2192, pos
, 0);
1376 // Get the position that ends the target.
1377 int wxStyledTextCtrl::GetTargetEnd() {
1378 return SendMsg(2193, 0, 0);
1381 // Replace the target text with the argument text.
1382 // Text is counted so it can contain NULs.
1383 // Returns the length of the replacement text.
1385 int wxStyledTextCtrl::ReplaceTarget(const wxString
& text
) {
1386 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1387 return SendMsg(2194, strlen(buf
), (long)(const char*)buf
);
1390 // Replace the target text with the argument text after \d processing.
1391 // Text is counted so it can contain NULs.
1392 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1393 // matched in the last search operation which were surrounded by \( and \).
1394 // Returns the length of the replacement text including any change
1395 // caused by processing the \d patterns.
1397 int wxStyledTextCtrl::ReplaceTargetRE(const wxString
& text
) {
1398 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1399 return SendMsg(2195, strlen(buf
), (long)(const char*)buf
);
1402 // Search for a counted string in the target and set the target to the found
1403 // range. Text is counted so it can contain NULs.
1404 // Returns length of range or -1 for failure in which case target is not moved.
1406 int wxStyledTextCtrl::SearchInTarget(const wxString
& text
) {
1407 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1408 return SendMsg(2197, strlen(buf
), (long)(const char*)buf
);
1411 // Set the search flags used by SearchInTarget.
1412 void wxStyledTextCtrl::SetSearchFlags(int flags
) {
1413 SendMsg(2198, flags
, 0);
1416 // Get the search flags used by SearchInTarget.
1417 int wxStyledTextCtrl::GetSearchFlags() {
1418 return SendMsg(2199, 0, 0);
1421 // Show a call tip containing a definition near position pos.
1422 void wxStyledTextCtrl::CallTipShow(int pos
, const wxString
& definition
) {
1423 SendMsg(2200, pos
, (long)(const char*)wx2stc(definition
));
1426 // Remove the call tip from the screen.
1427 void wxStyledTextCtrl::CallTipCancel() {
1428 SendMsg(2201, 0, 0);
1431 // Is there an active call tip?
1432 bool wxStyledTextCtrl::CallTipActive() {
1433 return SendMsg(2202, 0, 0) != 0;
1436 // Retrieve the position where the caret was before displaying the call tip.
1437 int wxStyledTextCtrl::CallTipPosAtStart() {
1438 return SendMsg(2203, 0, 0);
1441 // Highlight a segment of the definition.
1442 void wxStyledTextCtrl::CallTipSetHighlight(int start
, int end
) {
1443 SendMsg(2204, start
, end
);
1446 // Set the background colour for the call tip.
1447 void wxStyledTextCtrl::CallTipSetBackground(const wxColour
& back
) {
1448 SendMsg(2205, wxColourAsLong(back
), 0);
1451 // Set the foreground colour for the call tip.
1452 void wxStyledTextCtrl::CallTipSetForeground(const wxColour
& fore
) {
1453 SendMsg(2206, wxColourAsLong(fore
), 0);
1456 // Set the foreground colour for the highlighted part of the call tip.
1457 void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour
& fore
) {
1458 SendMsg(2207, wxColourAsLong(fore
), 0);
1461 // Enable use of STYLE_CALLTIP and set call tip tab size in pixels.
1462 void wxStyledTextCtrl::CallTipUseStyle(int tabSize
) {
1463 SendMsg(2212, tabSize
, 0);
1466 // Find the display line of a document line taking hidden lines into account.
1467 int wxStyledTextCtrl::VisibleFromDocLine(int line
) {
1468 return SendMsg(2220, line
, 0);
1471 // Find the document line of a display line taking hidden lines into account.
1472 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay
) {
1473 return SendMsg(2221, lineDisplay
, 0);
1476 // The number of display lines needed to wrap a document line
1477 int wxStyledTextCtrl::WrapCount(int line
) {
1478 return SendMsg(2235, line
, 0);
1481 // Set the fold level of a line.
1482 // This encodes an integer level along with flags indicating whether the
1483 // line is a header and whether it is effectively white space.
1484 void wxStyledTextCtrl::SetFoldLevel(int line
, int level
) {
1485 SendMsg(2222, line
, level
);
1488 // Retrieve the fold level of a line.
1489 int wxStyledTextCtrl::GetFoldLevel(int line
) {
1490 return SendMsg(2223, line
, 0);
1493 // Find the last child line of a header line.
1494 int wxStyledTextCtrl::GetLastChild(int line
, int level
) {
1495 return SendMsg(2224, line
, level
);
1498 // Find the parent line of a child line.
1499 int wxStyledTextCtrl::GetFoldParent(int line
) {
1500 return SendMsg(2225, line
, 0);
1503 // Make a range of lines visible.
1504 void wxStyledTextCtrl::ShowLines(int lineStart
, int lineEnd
) {
1505 SendMsg(2226, lineStart
, lineEnd
);
1508 // Make a range of lines invisible.
1509 void wxStyledTextCtrl::HideLines(int lineStart
, int lineEnd
) {
1510 SendMsg(2227, lineStart
, lineEnd
);
1513 // Is a line visible?
1514 bool wxStyledTextCtrl::GetLineVisible(int line
) {
1515 return SendMsg(2228, line
, 0) != 0;
1518 // Show the children of a header line.
1519 void wxStyledTextCtrl::SetFoldExpanded(int line
, bool expanded
) {
1520 SendMsg(2229, line
, expanded
);
1523 // Is a header line expanded?
1524 bool wxStyledTextCtrl::GetFoldExpanded(int line
) {
1525 return SendMsg(2230, line
, 0) != 0;
1528 // Switch a header line between expanded and contracted.
1529 void wxStyledTextCtrl::ToggleFold(int line
) {
1530 SendMsg(2231, line
, 0);
1533 // Ensure a particular line is visible by expanding any header line hiding it.
1534 void wxStyledTextCtrl::EnsureVisible(int line
) {
1535 SendMsg(2232, line
, 0);
1538 // Set some style options for folding.
1539 void wxStyledTextCtrl::SetFoldFlags(int flags
) {
1540 SendMsg(2233, flags
, 0);
1543 // Ensure a particular line is visible by expanding any header line hiding it.
1544 // Use the currently set visibility policy to determine which range to display.
1545 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line
) {
1546 SendMsg(2234, line
, 0);
1549 // Sets whether a tab pressed when caret is within indentation indents.
1550 void wxStyledTextCtrl::SetTabIndents(bool tabIndents
) {
1551 SendMsg(2260, tabIndents
, 0);
1554 // Does a tab pressed when caret is within indentation indent?
1555 bool wxStyledTextCtrl::GetTabIndents() {
1556 return SendMsg(2261, 0, 0) != 0;
1559 // Sets whether a backspace pressed when caret is within indentation unindents.
1560 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents
) {
1561 SendMsg(2262, bsUnIndents
, 0);
1564 // Does a backspace pressed when caret is within indentation unindent?
1565 bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1566 return SendMsg(2263, 0, 0) != 0;
1569 // Sets the time the mouse must sit still to generate a mouse dwell event.
1570 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds
) {
1571 SendMsg(2264, periodMilliseconds
, 0);
1574 // Retrieve the time the mouse must sit still to generate a mouse dwell event.
1575 int wxStyledTextCtrl::GetMouseDwellTime() {
1576 return SendMsg(2265, 0, 0);
1579 // Get position of start of word.
1580 int wxStyledTextCtrl::WordStartPosition(int pos
, bool onlyWordCharacters
) {
1581 return SendMsg(2266, pos
, onlyWordCharacters
);
1584 // Get position of end of word.
1585 int wxStyledTextCtrl::WordEndPosition(int pos
, bool onlyWordCharacters
) {
1586 return SendMsg(2267, pos
, onlyWordCharacters
);
1589 // Sets whether text is word wrapped.
1590 void wxStyledTextCtrl::SetWrapMode(int mode
) {
1591 SendMsg(2268, mode
, 0);
1594 // Retrieve whether text is word wrapped.
1595 int wxStyledTextCtrl::GetWrapMode() {
1596 return SendMsg(2269, 0, 0);
1599 // Set the display mode of visual flags for wrapped lines.
1600 void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags
) {
1601 SendMsg(2460, wrapVisualFlags
, 0);
1604 // Retrive the display mode of visual flags for wrapped lines.
1605 int wxStyledTextCtrl::GetWrapVisualFlags() {
1606 return SendMsg(2461, 0, 0);
1609 // Set the location of visual flags for wrapped lines.
1610 void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation
) {
1611 SendMsg(2462, wrapVisualFlagsLocation
, 0);
1614 // Retrive the location of visual flags for wrapped lines.
1615 int wxStyledTextCtrl::GetWrapVisualFlagsLocation() {
1616 return SendMsg(2463, 0, 0);
1619 // Set the start indent for wrapped lines.
1620 void wxStyledTextCtrl::SetWrapStartIndent(int indent
) {
1621 SendMsg(2464, indent
, 0);
1624 // Retrive the start indent for wrapped lines.
1625 int wxStyledTextCtrl::GetWrapStartIndent() {
1626 return SendMsg(2465, 0, 0);
1629 // Sets the degree of caching of layout information.
1630 void wxStyledTextCtrl::SetLayoutCache(int mode
) {
1631 SendMsg(2272, mode
, 0);
1634 // Retrieve the degree of caching of layout information.
1635 int wxStyledTextCtrl::GetLayoutCache() {
1636 return SendMsg(2273, 0, 0);
1639 // Sets the document width assumed for scrolling.
1640 void wxStyledTextCtrl::SetScrollWidth(int pixelWidth
) {
1641 SendMsg(2274, pixelWidth
, 0);
1644 // Retrieve the document width assumed for scrolling.
1645 int wxStyledTextCtrl::GetScrollWidth() {
1646 return SendMsg(2275, 0, 0);
1649 // Measure the pixel width of some text in a particular style.
1650 // NUL terminated text argument.
1651 // Does not handle tab or control characters.
1652 int wxStyledTextCtrl::TextWidth(int style
, const wxString
& text
) {
1653 return SendMsg(2276, style
, (long)(const char*)wx2stc(text
));
1656 // Sets the scroll range so that maximum scroll position has
1657 // the last line at the bottom of the view (default).
1658 // Setting this to false allows scrolling one page below the last line.
1659 void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine
) {
1660 SendMsg(2277, endAtLastLine
, 0);
1663 // Retrieve whether the maximum scroll position has the last
1664 // line at the bottom of the view.
1665 bool wxStyledTextCtrl::GetEndAtLastLine() {
1666 return SendMsg(2278, 0, 0) != 0;
1669 // Retrieve the height of a particular line of text in pixels.
1670 int wxStyledTextCtrl::TextHeight(int line
) {
1671 return SendMsg(2279, line
, 0);
1674 // Show or hide the vertical scroll bar.
1675 void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show
) {
1676 SendMsg(2280, show
, 0);
1679 // Is the vertical scroll bar visible?
1680 bool wxStyledTextCtrl::GetUseVerticalScrollBar() {
1681 return SendMsg(2281, 0, 0) != 0;
1684 // Append a string to the end of the document without changing the selection.
1685 void wxStyledTextCtrl::AppendText(const wxString
& text
) {
1686 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1687 SendMsg(2282, strlen(buf
), (long)(const char*)buf
);
1690 // Is drawing done in two phases with backgrounds drawn before foregrounds?
1691 bool wxStyledTextCtrl::GetTwoPhaseDraw() {
1692 return SendMsg(2283, 0, 0) != 0;
1695 // In twoPhaseDraw mode, drawing is performed in two phases, first the background
1696 // and then the foreground. This avoids chopping off characters that overlap the next run.
1697 void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase
) {
1698 SendMsg(2284, twoPhase
, 0);
1701 // Make the target range start and end be the same as the selection range start and end.
1702 void wxStyledTextCtrl::TargetFromSelection() {
1703 SendMsg(2287, 0, 0);
1706 // Join the lines in the target.
1707 void wxStyledTextCtrl::LinesJoin() {
1708 SendMsg(2288, 0, 0);
1711 // Split the lines in the target into lines that are less wide than pixelWidth
1713 void wxStyledTextCtrl::LinesSplit(int pixelWidth
) {
1714 SendMsg(2289, pixelWidth
, 0);
1717 // Set the colours used as a chequerboard pattern in the fold margin
1718 void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting
, const wxColour
& back
) {
1719 SendMsg(2290, useSetting
, wxColourAsLong(back
));
1721 void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting
, const wxColour
& fore
) {
1722 SendMsg(2291, useSetting
, wxColourAsLong(fore
));
1725 // Move caret down one line.
1726 void wxStyledTextCtrl::LineDown() {
1727 SendMsg(2300, 0, 0);
1730 // Move caret down one line extending selection to new caret position.
1731 void wxStyledTextCtrl::LineDownExtend() {
1732 SendMsg(2301, 0, 0);
1735 // Move caret up one line.
1736 void wxStyledTextCtrl::LineUp() {
1737 SendMsg(2302, 0, 0);
1740 // Move caret up one line extending selection to new caret position.
1741 void wxStyledTextCtrl::LineUpExtend() {
1742 SendMsg(2303, 0, 0);
1745 // Move caret left one character.
1746 void wxStyledTextCtrl::CharLeft() {
1747 SendMsg(2304, 0, 0);
1750 // Move caret left one character extending selection to new caret position.
1751 void wxStyledTextCtrl::CharLeftExtend() {
1752 SendMsg(2305, 0, 0);
1755 // Move caret right one character.
1756 void wxStyledTextCtrl::CharRight() {
1757 SendMsg(2306, 0, 0);
1760 // Move caret right one character extending selection to new caret position.
1761 void wxStyledTextCtrl::CharRightExtend() {
1762 SendMsg(2307, 0, 0);
1765 // Move caret left one word.
1766 void wxStyledTextCtrl::WordLeft() {
1767 SendMsg(2308, 0, 0);
1770 // Move caret left one word extending selection to new caret position.
1771 void wxStyledTextCtrl::WordLeftExtend() {
1772 SendMsg(2309, 0, 0);
1775 // Move caret right one word.
1776 void wxStyledTextCtrl::WordRight() {
1777 SendMsg(2310, 0, 0);
1780 // Move caret right one word extending selection to new caret position.
1781 void wxStyledTextCtrl::WordRightExtend() {
1782 SendMsg(2311, 0, 0);
1785 // Move caret to first position on line.
1786 void wxStyledTextCtrl::Home() {
1787 SendMsg(2312, 0, 0);
1790 // Move caret to first position on line extending selection to new caret position.
1791 void wxStyledTextCtrl::HomeExtend() {
1792 SendMsg(2313, 0, 0);
1795 // Move caret to last position on line.
1796 void wxStyledTextCtrl::LineEnd() {
1797 SendMsg(2314, 0, 0);
1800 // Move caret to last position on line extending selection to new caret position.
1801 void wxStyledTextCtrl::LineEndExtend() {
1802 SendMsg(2315, 0, 0);
1805 // Move caret to first position in document.
1806 void wxStyledTextCtrl::DocumentStart() {
1807 SendMsg(2316, 0, 0);
1810 // Move caret to first position in document extending selection to new caret position.
1811 void wxStyledTextCtrl::DocumentStartExtend() {
1812 SendMsg(2317, 0, 0);
1815 // Move caret to last position in document.
1816 void wxStyledTextCtrl::DocumentEnd() {
1817 SendMsg(2318, 0, 0);
1820 // Move caret to last position in document extending selection to new caret position.
1821 void wxStyledTextCtrl::DocumentEndExtend() {
1822 SendMsg(2319, 0, 0);
1825 // Move caret one page up.
1826 void wxStyledTextCtrl::PageUp() {
1827 SendMsg(2320, 0, 0);
1830 // Move caret one page up extending selection to new caret position.
1831 void wxStyledTextCtrl::PageUpExtend() {
1832 SendMsg(2321, 0, 0);
1835 // Move caret one page down.
1836 void wxStyledTextCtrl::PageDown() {
1837 SendMsg(2322, 0, 0);
1840 // Move caret one page down extending selection to new caret position.
1841 void wxStyledTextCtrl::PageDownExtend() {
1842 SendMsg(2323, 0, 0);
1845 // Switch from insert to overtype mode or the reverse.
1846 void wxStyledTextCtrl::EditToggleOvertype() {
1847 SendMsg(2324, 0, 0);
1850 // Cancel any modes such as call tip or auto-completion list display.
1851 void wxStyledTextCtrl::Cancel() {
1852 SendMsg(2325, 0, 0);
1855 // Delete the selection or if no selection, the character before the caret.
1856 void wxStyledTextCtrl::DeleteBack() {
1857 SendMsg(2326, 0, 0);
1860 // If selection is empty or all on one line replace the selection with a tab character.
1861 // If more than one line selected, indent the lines.
1862 void wxStyledTextCtrl::Tab() {
1863 SendMsg(2327, 0, 0);
1866 // Dedent the selected lines.
1867 void wxStyledTextCtrl::BackTab() {
1868 SendMsg(2328, 0, 0);
1871 // Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
1872 void wxStyledTextCtrl::NewLine() {
1873 SendMsg(2329, 0, 0);
1876 // Insert a Form Feed character.
1877 void wxStyledTextCtrl::FormFeed() {
1878 SendMsg(2330, 0, 0);
1881 // Move caret to before first visible character on line.
1882 // If already there move to first character on line.
1883 void wxStyledTextCtrl::VCHome() {
1884 SendMsg(2331, 0, 0);
1887 // Like VCHome but extending selection to new caret position.
1888 void wxStyledTextCtrl::VCHomeExtend() {
1889 SendMsg(2332, 0, 0);
1892 // Magnify the displayed text by increasing the sizes by 1 point.
1893 void wxStyledTextCtrl::ZoomIn() {
1894 SendMsg(2333, 0, 0);
1897 // Make the displayed text smaller by decreasing the sizes by 1 point.
1898 void wxStyledTextCtrl::ZoomOut() {
1899 SendMsg(2334, 0, 0);
1902 // Delete the word to the left of the caret.
1903 void wxStyledTextCtrl::DelWordLeft() {
1904 SendMsg(2335, 0, 0);
1907 // Delete the word to the right of the caret.
1908 void wxStyledTextCtrl::DelWordRight() {
1909 SendMsg(2336, 0, 0);
1912 // Cut the line containing the caret.
1913 void wxStyledTextCtrl::LineCut() {
1914 SendMsg(2337, 0, 0);
1917 // Delete the line containing the caret.
1918 void wxStyledTextCtrl::LineDelete() {
1919 SendMsg(2338, 0, 0);
1922 // Switch the current line with the previous.
1923 void wxStyledTextCtrl::LineTranspose() {
1924 SendMsg(2339, 0, 0);
1927 // Duplicate the current line.
1928 void wxStyledTextCtrl::LineDuplicate() {
1929 SendMsg(2404, 0, 0);
1932 // Transform the selection to lower case.
1933 void wxStyledTextCtrl::LowerCase() {
1934 SendMsg(2340, 0, 0);
1937 // Transform the selection to upper case.
1938 void wxStyledTextCtrl::UpperCase() {
1939 SendMsg(2341, 0, 0);
1942 // Scroll the document down, keeping the caret visible.
1943 void wxStyledTextCtrl::LineScrollDown() {
1944 SendMsg(2342, 0, 0);
1947 // Scroll the document up, keeping the caret visible.
1948 void wxStyledTextCtrl::LineScrollUp() {
1949 SendMsg(2343, 0, 0);
1952 // Delete the selection or if no selection, the character before the caret.
1953 // Will not delete the character before at the start of a line.
1954 void wxStyledTextCtrl::DeleteBackNotLine() {
1955 SendMsg(2344, 0, 0);
1958 // Move caret to first position on display line.
1959 void wxStyledTextCtrl::HomeDisplay() {
1960 SendMsg(2345, 0, 0);
1963 // Move caret to first position on display line extending selection to
1964 // new caret position.
1965 void wxStyledTextCtrl::HomeDisplayExtend() {
1966 SendMsg(2346, 0, 0);
1969 // Move caret to last position on display line.
1970 void wxStyledTextCtrl::LineEndDisplay() {
1971 SendMsg(2347, 0, 0);
1974 // Move caret to last position on display line extending selection to new
1976 void wxStyledTextCtrl::LineEndDisplayExtend() {
1977 SendMsg(2348, 0, 0);
1980 // These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
1981 // except they behave differently when word-wrap is enabled:
1982 // They go first to the start / end of the display line, like (Home|LineEnd)Display
1983 // The difference is that, the cursor is already at the point, it goes on to the start
1984 // or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
1985 void wxStyledTextCtrl::HomeWrap() {
1986 SendMsg(2349, 0, 0);
1988 void wxStyledTextCtrl::HomeWrapExtend() {
1989 SendMsg(2450, 0, 0);
1991 void wxStyledTextCtrl::LineEndWrap() {
1992 SendMsg(2451, 0, 0);
1994 void wxStyledTextCtrl::LineEndWrapExtend() {
1995 SendMsg(2452, 0, 0);
1997 void wxStyledTextCtrl::VCHomeWrap() {
1998 SendMsg(2453, 0, 0);
2000 void wxStyledTextCtrl::VCHomeWrapExtend() {
2001 SendMsg(2454, 0, 0);
2004 // Copy the line containing the caret.
2005 void wxStyledTextCtrl::LineCopy() {
2006 SendMsg(2455, 0, 0);
2009 // Move the caret inside current view if it's not there already.
2010 void wxStyledTextCtrl::MoveCaretInsideView() {
2011 SendMsg(2401, 0, 0);
2014 // How many characters are on a line, not including end of line characters?
2015 int wxStyledTextCtrl::LineLength(int line
) {
2016 return SendMsg(2350, line
, 0);
2019 // Highlight the characters at two positions.
2020 void wxStyledTextCtrl::BraceHighlight(int pos1
, int pos2
) {
2021 SendMsg(2351, pos1
, pos2
);
2024 // Highlight the character at a position indicating there is no matching brace.
2025 void wxStyledTextCtrl::BraceBadLight(int pos
) {
2026 SendMsg(2352, pos
, 0);
2029 // Find the position of a matching brace or INVALID_POSITION if no match.
2030 int wxStyledTextCtrl::BraceMatch(int pos
) {
2031 return SendMsg(2353, pos
, 0);
2034 // Are the end of line characters visible?
2035 bool wxStyledTextCtrl::GetViewEOL() {
2036 return SendMsg(2355, 0, 0) != 0;
2039 // Make the end of line characters visible or invisible.
2040 void wxStyledTextCtrl::SetViewEOL(bool visible
) {
2041 SendMsg(2356, visible
, 0);
2044 // Retrieve a pointer to the document object.
2045 void* wxStyledTextCtrl::GetDocPointer() {
2046 return (void*)SendMsg(2357);
2049 // Change the document object used.
2050 void wxStyledTextCtrl::SetDocPointer(void* docPointer
) {
2051 SendMsg(2358, 0, (long)docPointer
);
2054 // Set which document modification events are sent to the container.
2055 void wxStyledTextCtrl::SetModEventMask(int mask
) {
2056 SendMsg(2359, mask
, 0);
2059 // Retrieve the column number which text should be kept within.
2060 int wxStyledTextCtrl::GetEdgeColumn() {
2061 return SendMsg(2360, 0, 0);
2064 // Set the column number of the edge.
2065 // If text goes past the edge then it is highlighted.
2066 void wxStyledTextCtrl::SetEdgeColumn(int column
) {
2067 SendMsg(2361, column
, 0);
2070 // Retrieve the edge highlight mode.
2071 int wxStyledTextCtrl::GetEdgeMode() {
2072 return SendMsg(2362, 0, 0);
2075 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
2076 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
2077 void wxStyledTextCtrl::SetEdgeMode(int mode
) {
2078 SendMsg(2363, mode
, 0);
2081 // Retrieve the colour used in edge indication.
2082 wxColour
wxStyledTextCtrl::GetEdgeColour() {
2083 long c
= SendMsg(2364, 0, 0);
2084 return wxColourFromLong(c
);
2087 // Change the colour used in edge indication.
2088 void wxStyledTextCtrl::SetEdgeColour(const wxColour
& edgeColour
) {
2089 SendMsg(2365, wxColourAsLong(edgeColour
), 0);
2092 // Sets the current caret position to be the search anchor.
2093 void wxStyledTextCtrl::SearchAnchor() {
2094 SendMsg(2366, 0, 0);
2097 // Find some text starting at the search anchor.
2098 // Does not ensure the selection is visible.
2099 int wxStyledTextCtrl::SearchNext(int flags
, const wxString
& text
) {
2100 return SendMsg(2367, flags
, (long)(const char*)wx2stc(text
));
2103 // Find some text starting at the search anchor and moving backwards.
2104 // Does not ensure the selection is visible.
2105 int wxStyledTextCtrl::SearchPrev(int flags
, const wxString
& text
) {
2106 return SendMsg(2368, flags
, (long)(const char*)wx2stc(text
));
2109 // Retrieves the number of lines completely visible.
2110 int wxStyledTextCtrl::LinesOnScreen() {
2111 return SendMsg(2370, 0, 0);
2114 // Set whether a pop up menu is displayed automatically when the user presses
2115 // the wrong mouse button.
2116 void wxStyledTextCtrl::UsePopUp(bool allowPopUp
) {
2117 SendMsg(2371, allowPopUp
, 0);
2120 // Is the selection rectangular? The alternative is the more common stream selection.
2121 bool wxStyledTextCtrl::SelectionIsRectangle() {
2122 return SendMsg(2372, 0, 0) != 0;
2125 // Set the zoom level. This number of points is added to the size of all fonts.
2126 // It may be positive to magnify or negative to reduce.
2127 void wxStyledTextCtrl::SetZoom(int zoom
) {
2128 SendMsg(2373, zoom
, 0);
2131 // Retrieve the zoom level.
2132 int wxStyledTextCtrl::GetZoom() {
2133 return SendMsg(2374, 0, 0);
2136 // Create a new document object.
2137 // Starts with reference count of 1 and not selected into editor.
2138 void* wxStyledTextCtrl::CreateDocument() {
2139 return (void*)SendMsg(2375);
2142 // Extend life of document.
2143 void wxStyledTextCtrl::AddRefDocument(void* docPointer
) {
2144 SendMsg(2376, 0, (long)docPointer
);
2147 // Release a reference to the document, deleting document if it fades to black.
2148 void wxStyledTextCtrl::ReleaseDocument(void* docPointer
) {
2149 SendMsg(2377, 0, (long)docPointer
);
2152 // Get which document modification events are sent to the container.
2153 int wxStyledTextCtrl::GetModEventMask() {
2154 return SendMsg(2378, 0, 0);
2157 // Change internal focus flag.
2158 void wxStyledTextCtrl::SetSTCFocus(bool focus
) {
2159 SendMsg(2380, focus
, 0);
2162 // Get internal focus flag.
2163 bool wxStyledTextCtrl::GetSTCFocus() {
2164 return SendMsg(2381, 0, 0) != 0;
2167 // Change error status - 0 = OK.
2168 void wxStyledTextCtrl::SetStatus(int statusCode
) {
2169 SendMsg(2382, statusCode
, 0);
2172 // Get error status.
2173 int wxStyledTextCtrl::GetStatus() {
2174 return SendMsg(2383, 0, 0);
2177 // Set whether the mouse is captured when its button is pressed.
2178 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures
) {
2179 SendMsg(2384, captures
, 0);
2182 // Get whether mouse gets captured.
2183 bool wxStyledTextCtrl::GetMouseDownCaptures() {
2184 return SendMsg(2385, 0, 0) != 0;
2187 // Sets the cursor to one of the SC_CURSOR* values.
2188 void wxStyledTextCtrl::SetSTCCursor(int cursorType
) {
2189 SendMsg(2386, cursorType
, 0);
2193 int wxStyledTextCtrl::GetSTCCursor() {
2194 return SendMsg(2387, 0, 0);
2197 // Change the way control characters are displayed:
2198 // If symbol is < 32, keep the drawn way, else, use the given character.
2199 void wxStyledTextCtrl::SetControlCharSymbol(int symbol
) {
2200 SendMsg(2388, symbol
, 0);
2203 // Get the way control characters are displayed.
2204 int wxStyledTextCtrl::GetControlCharSymbol() {
2205 return SendMsg(2389, 0, 0);
2208 // Move to the previous change in capitalisation.
2209 void wxStyledTextCtrl::WordPartLeft() {
2210 SendMsg(2390, 0, 0);
2213 // Move to the previous change in capitalisation extending selection
2214 // to new caret position.
2215 void wxStyledTextCtrl::WordPartLeftExtend() {
2216 SendMsg(2391, 0, 0);
2219 // Move to the change next in capitalisation.
2220 void wxStyledTextCtrl::WordPartRight() {
2221 SendMsg(2392, 0, 0);
2224 // Move to the next change in capitalisation extending selection
2225 // to new caret position.
2226 void wxStyledTextCtrl::WordPartRightExtend() {
2227 SendMsg(2393, 0, 0);
2230 // Set the way the display area is determined when a particular line
2231 // is to be moved to by Find, FindNext, GotoLine, etc.
2232 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy
, int visibleSlop
) {
2233 SendMsg(2394, visiblePolicy
, visibleSlop
);
2236 // Delete back from the current position to the start of the line.
2237 void wxStyledTextCtrl::DelLineLeft() {
2238 SendMsg(2395, 0, 0);
2241 // Delete forwards from the current position to the end of the line.
2242 void wxStyledTextCtrl::DelLineRight() {
2243 SendMsg(2396, 0, 0);
2246 // Get and Set the xOffset (ie, horizonal scroll position).
2247 void wxStyledTextCtrl::SetXOffset(int newOffset
) {
2248 SendMsg(2397, newOffset
, 0);
2250 int wxStyledTextCtrl::GetXOffset() {
2251 return SendMsg(2398, 0, 0);
2254 // Set the last x chosen value to be the caret x position.
2255 void wxStyledTextCtrl::ChooseCaretX() {
2256 SendMsg(2399, 0, 0);
2259 // Set the way the caret is kept visible when going sideway.
2260 // The exclusion zone is given in pixels.
2261 void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy
, int caretSlop
) {
2262 SendMsg(2402, caretPolicy
, caretSlop
);
2265 // Set the way the line the caret is on is kept visible.
2266 // The exclusion zone is given in lines.
2267 void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy
, int caretSlop
) {
2268 SendMsg(2403, caretPolicy
, caretSlop
);
2271 // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
2272 void wxStyledTextCtrl::SetPrintWrapMode(int mode
) {
2273 SendMsg(2406, mode
, 0);
2276 // Is printing line wrapped?
2277 int wxStyledTextCtrl::GetPrintWrapMode() {
2278 return SendMsg(2407, 0, 0);
2281 // Set a fore colour for active hotspots.
2282 void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting
, const wxColour
& fore
) {
2283 SendMsg(2410, useSetting
, wxColourAsLong(fore
));
2286 // Set a back colour for active hotspots.
2287 void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting
, const wxColour
& back
) {
2288 SendMsg(2411, useSetting
, wxColourAsLong(back
));
2291 // Enable / Disable underlining active hotspots.
2292 void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline
) {
2293 SendMsg(2412, underline
, 0);
2296 // Limit hotspots to single line so hotspots on two lines don't merge.
2297 void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine
) {
2298 SendMsg(2421, singleLine
, 0);
2301 // Move caret between paragraphs (delimited by empty lines).
2302 void wxStyledTextCtrl::ParaDown() {
2303 SendMsg(2413, 0, 0);
2305 void wxStyledTextCtrl::ParaDownExtend() {
2306 SendMsg(2414, 0, 0);
2308 void wxStyledTextCtrl::ParaUp() {
2309 SendMsg(2415, 0, 0);
2311 void wxStyledTextCtrl::ParaUpExtend() {
2312 SendMsg(2416, 0, 0);
2315 // Given a valid document position, return the previous position taking code
2316 // page into account. Returns 0 if passed 0.
2317 int wxStyledTextCtrl::PositionBefore(int pos
) {
2318 return SendMsg(2417, pos
, 0);
2321 // Given a valid document position, return the next position taking code
2322 // page into account. Maximum value returned is the last position in the document.
2323 int wxStyledTextCtrl::PositionAfter(int pos
) {
2324 return SendMsg(2418, pos
, 0);
2327 // Copy a range of text to the clipboard. Positions are clipped into the document.
2328 void wxStyledTextCtrl::CopyRange(int start
, int end
) {
2329 SendMsg(2419, start
, end
);
2332 // Copy argument text to the clipboard.
2333 void wxStyledTextCtrl::CopyText(int length
, const wxString
& text
) {
2334 SendMsg(2420, length
, (long)(const char*)wx2stc(text
));
2337 // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or
2338 // by lines (SC_SEL_LINES).
2339 void wxStyledTextCtrl::SetSelectionMode(int mode
) {
2340 SendMsg(2422, mode
, 0);
2343 // Get the mode of the current selection.
2344 int wxStyledTextCtrl::GetSelectionMode() {
2345 return SendMsg(2423, 0, 0);
2348 // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
2349 int wxStyledTextCtrl::GetLineSelStartPosition(int line
) {
2350 return SendMsg(2424, line
, 0);
2353 // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
2354 int wxStyledTextCtrl::GetLineSelEndPosition(int line
) {
2355 return SendMsg(2425, line
, 0);
2358 // Move caret down one line, extending rectangular selection to new caret position.
2359 void wxStyledTextCtrl::LineDownRectExtend() {
2360 SendMsg(2426, 0, 0);
2363 // Move caret up one line, extending rectangular selection to new caret position.
2364 void wxStyledTextCtrl::LineUpRectExtend() {
2365 SendMsg(2427, 0, 0);
2368 // Move caret left one character, extending rectangular selection to new caret position.
2369 void wxStyledTextCtrl::CharLeftRectExtend() {
2370 SendMsg(2428, 0, 0);
2373 // Move caret right one character, extending rectangular selection to new caret position.
2374 void wxStyledTextCtrl::CharRightRectExtend() {
2375 SendMsg(2429, 0, 0);
2378 // Move caret to first position on line, extending rectangular selection to new caret position.
2379 void wxStyledTextCtrl::HomeRectExtend() {
2380 SendMsg(2430, 0, 0);
2383 // Move caret to before first visible character on line.
2384 // If already there move to first character on line.
2385 // In either case, extend rectangular selection to new caret position.
2386 void wxStyledTextCtrl::VCHomeRectExtend() {
2387 SendMsg(2431, 0, 0);
2390 // Move caret to last position on line, extending rectangular selection to new caret position.
2391 void wxStyledTextCtrl::LineEndRectExtend() {
2392 SendMsg(2432, 0, 0);
2395 // Move caret one page up, extending rectangular selection to new caret position.
2396 void wxStyledTextCtrl::PageUpRectExtend() {
2397 SendMsg(2433, 0, 0);
2400 // Move caret one page down, extending rectangular selection to new caret position.
2401 void wxStyledTextCtrl::PageDownRectExtend() {
2402 SendMsg(2434, 0, 0);
2405 // Move caret to top of page, or one page up if already at top of page.
2406 void wxStyledTextCtrl::StutteredPageUp() {
2407 SendMsg(2435, 0, 0);
2410 // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
2411 void wxStyledTextCtrl::StutteredPageUpExtend() {
2412 SendMsg(2436, 0, 0);
2415 // Move caret to bottom of page, or one page down if already at bottom of page.
2416 void wxStyledTextCtrl::StutteredPageDown() {
2417 SendMsg(2437, 0, 0);
2420 // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
2421 void wxStyledTextCtrl::StutteredPageDownExtend() {
2422 SendMsg(2438, 0, 0);
2425 // Move caret left one word, position cursor at end of word.
2426 void wxStyledTextCtrl::WordLeftEnd() {
2427 SendMsg(2439, 0, 0);
2430 // Move caret left one word, position cursor at end of word, extending selection to new caret position.
2431 void wxStyledTextCtrl::WordLeftEndExtend() {
2432 SendMsg(2440, 0, 0);
2435 // Move caret right one word, position cursor at end of word.
2436 void wxStyledTextCtrl::WordRightEnd() {
2437 SendMsg(2441, 0, 0);
2440 // Move caret right one word, position cursor at end of word, extending selection to new caret position.
2441 void wxStyledTextCtrl::WordRightEndExtend() {
2442 SendMsg(2442, 0, 0);
2445 // Set the set of characters making up whitespace for when moving or selecting by word.
2446 // Should be called after SetWordChars.
2447 void wxStyledTextCtrl::SetWhitespaceChars(const wxString
& characters
) {
2448 SendMsg(2443, 0, (long)(const char*)wx2stc(characters
));
2451 // Reset the set of characters for whitespace and word characters to the defaults.
2452 void wxStyledTextCtrl::SetCharsDefault() {
2453 SendMsg(2444, 0, 0);
2456 // Get currently selected item position in the auto-completion list
2457 int wxStyledTextCtrl::AutoCompGetCurrent() {
2458 return SendMsg(2445, 0, 0);
2461 // Enlarge the document to a particular size of text bytes.
2462 void wxStyledTextCtrl::Allocate(int bytes
) {
2463 SendMsg(2446, bytes
, 0);
2466 // Find the position of a column on a line taking into account tabs and
2467 // multi-byte characters. If beyond end of line, return line end position.
2468 int wxStyledTextCtrl::FindColumn(int line
, int column
) {
2469 return SendMsg(2456, line
, column
);
2472 // Can the caret preferred x position only be changed by explicit movement commands?
2473 bool wxStyledTextCtrl::GetCaretSticky() {
2474 return SendMsg(2457, 0, 0) != 0;
2477 // Stop the caret preferred x position changing when the user types.
2478 void wxStyledTextCtrl::SetCaretSticky(bool useCaretStickyBehaviour
) {
2479 SendMsg(2458, useCaretStickyBehaviour
, 0);
2482 // Switch between sticky and non-sticky: meant to be bound to a key.
2483 void wxStyledTextCtrl::ToggleCaretSticky() {
2484 SendMsg(2459, 0, 0);
2487 // Enable/Disable convert-on-paste for line endings
2488 void wxStyledTextCtrl::SetPasteConvertEndings(bool convert
) {
2489 SendMsg(2467, convert
, 0);
2492 // Get convert-on-paste setting
2493 bool wxStyledTextCtrl::GetPasteConvertEndings() {
2494 return SendMsg(2468, 0, 0) != 0;
2497 // Duplicate the selection. If selection empty duplicate the line containing the caret.
2498 void wxStyledTextCtrl::SelectionDuplicate() {
2499 SendMsg(2469, 0, 0);
2502 // Set background alpha of the caret line.
2503 void wxStyledTextCtrl::SetCaretLineBackAlpha(int alpha
) {
2504 SendMsg(2470, alpha
, 0);
2507 // Get the background alpha of the caret line.
2508 int wxStyledTextCtrl::GetCaretLineBackAlpha() {
2509 return SendMsg(2471, 0, 0);
2512 // Start notifying the container of all key presses and commands.
2513 void wxStyledTextCtrl::StartRecord() {
2514 SendMsg(3001, 0, 0);
2517 // Stop notifying the container of all key presses and commands.
2518 void wxStyledTextCtrl::StopRecord() {
2519 SendMsg(3002, 0, 0);
2522 // Set the lexing language of the document.
2523 void wxStyledTextCtrl::SetLexer(int lexer
) {
2524 SendMsg(4001, lexer
, 0);
2527 // Retrieve the lexing language of the document.
2528 int wxStyledTextCtrl::GetLexer() {
2529 return SendMsg(4002, 0, 0);
2532 // Colourise a segment of the document using the current lexing language.
2533 void wxStyledTextCtrl::Colourise(int start
, int end
) {
2534 SendMsg(4003, start
, end
);
2537 // Set up a value that may be used by a lexer for some optional feature.
2538 void wxStyledTextCtrl::SetProperty(const wxString
& key
, const wxString
& value
) {
2539 SendMsg(4004, (long)(const char*)wx2stc(key
), (long)(const char*)wx2stc(value
));
2542 // Set up the key words used by the lexer.
2543 void wxStyledTextCtrl::SetKeyWords(int keywordSet
, const wxString
& keyWords
) {
2544 SendMsg(4005, keywordSet
, (long)(const char*)wx2stc(keyWords
));
2547 // Set the lexing language of the document based on string name.
2548 void wxStyledTextCtrl::SetLexerLanguage(const wxString
& language
) {
2549 SendMsg(4006, 0, (long)(const char*)wx2stc(language
));
2552 // Retrieve a 'property' value previously set with SetProperty.
2553 wxString
wxStyledTextCtrl::GetProperty(const wxString
& key
) {
2554 int len
= SendMsg(SCI_GETPROPERTY
, (long)(const char*)wx2stc(key
), (long)NULL
);
2555 if (!len
) return wxEmptyString
;
2557 wxMemoryBuffer
mbuf(len
+1);
2558 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
2559 SendMsg(4008, (long)(const char*)wx2stc(key
), (long)buf
);
2560 mbuf
.UngetWriteBuf(len
);
2565 // Retrieve a 'property' value previously set with SetProperty,
2566 // with '$()' variable replacement on returned buffer.
2567 wxString
wxStyledTextCtrl::GetPropertyExpanded(const wxString
& key
) {
2568 int len
= SendMsg(SCI_GETPROPERTYEXPANDED
, (long)(const char*)wx2stc(key
), (long)NULL
);
2569 if (!len
) return wxEmptyString
;
2571 wxMemoryBuffer
mbuf(len
+1);
2572 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
2573 SendMsg(4009, (long)(const char*)wx2stc(key
), (long)buf
);
2574 mbuf
.UngetWriteBuf(len
);
2579 // Retrieve a 'property' value previously set with SetProperty,
2580 // interpreted as an int AFTER any '$()' variable replacement.
2581 int wxStyledTextCtrl::GetPropertyInt(const wxString
& key
) {
2582 return SendMsg(4010, (long)(const char*)wx2stc(key
), 0);
2585 // Retrieve the number of bits the current lexer needs for styling.
2586 int wxStyledTextCtrl::GetStyleBitsNeeded() {
2587 return SendMsg(4011, 0, 0);
2590 // END of generated section
2591 //----------------------------------------------------------------------
2594 // Returns the line number of the line with the caret.
2595 int wxStyledTextCtrl::GetCurrentLine() {
2596 int line
= LineFromPosition(GetCurrentPos());
2601 // Extract style settings from a spec-string which is composed of one or
2602 // more of the following comma separated elements:
2604 // bold turns on bold
2605 // italic turns on italics
2606 // fore:[name or #RRGGBB] sets the foreground colour
2607 // back:[name or #RRGGBB] sets the background colour
2608 // face:[facename] sets the font face name to use
2609 // size:[num] sets the font size in points
2610 // eol turns on eol filling
2611 // underline turns on underlining
2613 void wxStyledTextCtrl::StyleSetSpec(int styleNum
, const wxString
& spec
) {
2615 wxStringTokenizer
tkz(spec
, wxT(","));
2616 while (tkz
.HasMoreTokens()) {
2617 wxString token
= tkz
.GetNextToken();
2619 wxString option
= token
.BeforeFirst(':');
2620 wxString val
= token
.AfterFirst(':');
2622 if (option
== wxT("bold"))
2623 StyleSetBold(styleNum
, true);
2625 else if (option
== wxT("italic"))
2626 StyleSetItalic(styleNum
, true);
2628 else if (option
== wxT("underline"))
2629 StyleSetUnderline(styleNum
, true);
2631 else if (option
== wxT("eol"))
2632 StyleSetEOLFilled(styleNum
, true);
2634 else if (option
== wxT("size")) {
2636 if (val
.ToLong(&points
))
2637 StyleSetSize(styleNum
, points
);
2640 else if (option
== wxT("face"))
2641 StyleSetFaceName(styleNum
, val
);
2643 else if (option
== wxT("fore"))
2644 StyleSetForeground(styleNum
, wxColourFromSpec(val
));
2646 else if (option
== wxT("back"))
2647 StyleSetBackground(styleNum
, wxColourFromSpec(val
));
2652 // Set style size, face, bold, italic, and underline attributes from
2653 // a wxFont's attributes.
2654 void wxStyledTextCtrl::StyleSetFont(int styleNum
, wxFont
& font
) {
2656 // Ensure that the native font is initialized
2658 GetTextExtent(wxT("X"), &x
, &y
, NULL
, NULL
, &font
);
2660 int size
= font
.GetPointSize();
2661 wxString faceName
= font
.GetFaceName();
2662 bool bold
= font
.GetWeight() == wxBOLD
;
2663 bool italic
= font
.GetStyle() != wxNORMAL
;
2664 bool under
= font
.GetUnderlined();
2665 wxFontEncoding encoding
= font
.GetEncoding();
2667 StyleSetFontAttr(styleNum
, size
, faceName
, bold
, italic
, under
, encoding
);
2670 // Set all font style attributes at once.
2671 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum
, int size
,
2672 const wxString
& faceName
,
2673 bool bold
, bool italic
,
2675 wxFontEncoding encoding
) {
2676 StyleSetSize(styleNum
, size
);
2677 StyleSetFaceName(styleNum
, faceName
);
2678 StyleSetBold(styleNum
, bold
);
2679 StyleSetItalic(styleNum
, italic
);
2680 StyleSetUnderline(styleNum
, underline
);
2681 StyleSetFontEncoding(styleNum
, encoding
);
2685 // Set the character set of the font in a style. Converts the Scintilla
2686 // character set values to a wxFontEncoding.
2687 void wxStyledTextCtrl::StyleSetCharacterSet(int style
, int characterSet
)
2689 wxFontEncoding encoding
;
2691 // Translate the Scintilla characterSet to a wxFontEncoding
2692 switch (characterSet
) {
2694 case wxSTC_CHARSET_ANSI
:
2695 case wxSTC_CHARSET_DEFAULT
:
2696 encoding
= wxFONTENCODING_DEFAULT
;
2699 case wxSTC_CHARSET_BALTIC
:
2700 encoding
= wxFONTENCODING_ISO8859_13
;
2703 case wxSTC_CHARSET_CHINESEBIG5
:
2704 encoding
= wxFONTENCODING_CP950
;
2707 case wxSTC_CHARSET_EASTEUROPE
:
2708 encoding
= wxFONTENCODING_ISO8859_2
;
2711 case wxSTC_CHARSET_GB2312
:
2712 encoding
= wxFONTENCODING_CP936
;
2715 case wxSTC_CHARSET_GREEK
:
2716 encoding
= wxFONTENCODING_ISO8859_7
;
2719 case wxSTC_CHARSET_HANGUL
:
2720 encoding
= wxFONTENCODING_CP949
;
2723 case wxSTC_CHARSET_MAC
:
2724 encoding
= wxFONTENCODING_DEFAULT
;
2727 case wxSTC_CHARSET_OEM
:
2728 encoding
= wxFONTENCODING_DEFAULT
;
2731 case wxSTC_CHARSET_RUSSIAN
:
2732 encoding
= wxFONTENCODING_KOI8
;
2735 case wxSTC_CHARSET_SHIFTJIS
:
2736 encoding
= wxFONTENCODING_CP932
;
2739 case wxSTC_CHARSET_SYMBOL
:
2740 encoding
= wxFONTENCODING_DEFAULT
;
2743 case wxSTC_CHARSET_TURKISH
:
2744 encoding
= wxFONTENCODING_ISO8859_9
;
2747 case wxSTC_CHARSET_JOHAB
:
2748 encoding
= wxFONTENCODING_DEFAULT
;
2751 case wxSTC_CHARSET_HEBREW
:
2752 encoding
= wxFONTENCODING_ISO8859_8
;
2755 case wxSTC_CHARSET_ARABIC
:
2756 encoding
= wxFONTENCODING_ISO8859_6
;
2759 case wxSTC_CHARSET_VIETNAMESE
:
2760 encoding
= wxFONTENCODING_DEFAULT
;
2763 case wxSTC_CHARSET_THAI
:
2764 encoding
= wxFONTENCODING_ISO8859_11
;
2767 case wxSTC_CHARSET_CYRILLIC
:
2768 encoding
= wxFONTENCODING_ISO8859_5
;
2771 case wxSTC_CHARSET_8859_15
:
2772 encoding
= wxFONTENCODING_ISO8859_15
;;
2776 // We just have Scintilla track the wxFontEncoding for us. It gets used
2777 // in Font::Create in PlatWX.cpp. We add one to the value so that the
2778 // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
2779 // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
2780 // to wxFONENCODING_DEFAULT in Font::Create.
2781 SendMsg(SCI_STYLESETCHARACTERSET
, style
, encoding
+1);
2785 // Set the font encoding to be used by a style.
2786 void wxStyledTextCtrl::StyleSetFontEncoding(int style
, wxFontEncoding encoding
)
2788 SendMsg(SCI_STYLESETCHARACTERSET
, style
, encoding
+1);
2792 // Perform one of the operations defined by the wxSTC_CMD_* constants.
2793 void wxStyledTextCtrl::CmdKeyExecute(int cmd
) {
2798 // Set the left and right margin in the edit area, measured in pixels.
2799 void wxStyledTextCtrl::SetMargins(int left
, int right
) {
2800 SetMarginLeft(left
);
2801 SetMarginRight(right
);
2805 // Retrieve the start and end positions of the current selection.
2806 void wxStyledTextCtrl::GetSelection(int* startPos
, int* endPos
) {
2807 if (startPos
!= NULL
)
2808 *startPos
= SendMsg(SCI_GETSELECTIONSTART
);
2810 *endPos
= SendMsg(SCI_GETSELECTIONEND
);
2814 // Retrieve the point in the window where a position is displayed.
2815 wxPoint
wxStyledTextCtrl::PointFromPosition(int pos
) {
2816 int x
= SendMsg(SCI_POINTXFROMPOSITION
, 0, pos
);
2817 int y
= SendMsg(SCI_POINTYFROMPOSITION
, 0, pos
);
2818 return wxPoint(x
, y
);
2821 // Scroll enough to make the given line visible
2822 void wxStyledTextCtrl::ScrollToLine(int line
) {
2823 m_swx
->DoScrollToLine(line
);
2827 // Scroll enough to make the given column visible
2828 void wxStyledTextCtrl::ScrollToColumn(int column
) {
2829 m_swx
->DoScrollToColumn(column
);
2833 bool wxStyledTextCtrl::SaveFile(const wxString
& filename
)
2835 wxFile
file(filename
, wxFile::write
);
2837 if (!file
.IsOpened())
2840 bool success
= file
.Write(GetText(), *wxConvCurrent
);
2848 bool wxStyledTextCtrl::LoadFile(const wxString
& filename
)
2850 bool success
= false;
2851 wxFile
file(filename
, wxFile::read
);
2853 if (file
.IsOpened())
2856 // get the file size (assume it is not huge file...)
2857 ssize_t len
= (ssize_t
)file
.Length();
2862 wxMemoryBuffer
buffer(len
+1);
2863 success
= (file
.Read(buffer
.GetData(), len
) == len
);
2865 ((char*)buffer
.GetData())[len
] = 0;
2866 contents
= wxString(buffer
, *wxConvCurrent
, len
);
2870 success
= (file
.Read(wxStringBuffer(buffer
, len
), len
) == len
);
2877 success
= true; // empty file is ok
2879 success
= false; // len == wxInvalidOffset
2894 #if wxUSE_DRAG_AND_DROP
2895 wxDragResult
wxStyledTextCtrl::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
2896 return m_swx
->DoDragOver(x
, y
, def
);
2900 bool wxStyledTextCtrl::DoDropText(long x
, long y
, const wxString
& data
) {
2901 return m_swx
->DoDropText(x
, y
, data
);
2906 void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA
) {
2907 m_swx
->SetUseAntiAliasing(useAA
);
2910 bool wxStyledTextCtrl::GetUseAntiAliasing() {
2911 return m_swx
->GetUseAntiAliasing();
2918 void wxStyledTextCtrl::AddTextRaw(const char* text
)
2920 SendMsg(SCI_ADDTEXT
, strlen(text
), (long)text
);
2923 void wxStyledTextCtrl::InsertTextRaw(int pos
, const char* text
)
2925 SendMsg(SCI_INSERTTEXT
, pos
, (long)text
);
2928 wxCharBuffer
wxStyledTextCtrl::GetCurLineRaw(int* linePos
)
2930 int len
= LineLength(GetCurrentLine());
2932 if (linePos
) *linePos
= 0;
2937 wxCharBuffer
buf(len
);
2938 int pos
= SendMsg(SCI_GETCURLINE
, len
, (long)buf
.data());
2939 if (linePos
) *linePos
= pos
;
2943 wxCharBuffer
wxStyledTextCtrl::GetLineRaw(int line
)
2945 int len
= LineLength(line
);
2951 wxCharBuffer
buf(len
);
2952 SendMsg(SCI_GETLINE
, line
, (long)buf
.data());
2956 wxCharBuffer
wxStyledTextCtrl::GetSelectedTextRaw()
2961 GetSelection(&start
, &end
);
2962 int len
= end
- start
;
2968 wxCharBuffer
buf(len
);
2969 SendMsg(SCI_GETSELTEXT
, 0, (long)buf
.data());
2973 wxCharBuffer
wxStyledTextCtrl::GetTextRangeRaw(int startPos
, int endPos
)
2975 if (endPos
< startPos
) {
2976 int temp
= startPos
;
2980 int len
= endPos
- startPos
;
2986 wxCharBuffer
buf(len
);
2988 tr
.lpstrText
= buf
.data();
2989 tr
.chrg
.cpMin
= startPos
;
2990 tr
.chrg
.cpMax
= endPos
;
2991 SendMsg(SCI_GETTEXTRANGE
, 0, (long)&tr
);
2995 void wxStyledTextCtrl::SetTextRaw(const char* text
)
2997 SendMsg(SCI_SETTEXT
, 0, (long)text
);
3000 wxCharBuffer
wxStyledTextCtrl::GetTextRaw()
3002 int len
= GetTextLength();
3003 wxCharBuffer
buf(len
);
3004 SendMsg(SCI_GETTEXT
, len
, (long)buf
.data());
3008 void wxStyledTextCtrl::AppendTextRaw(const char* text
)
3010 SendMsg(SCI_APPENDTEXT
, strlen(text
), (long)text
);
3017 //----------------------------------------------------------------------
3020 void wxStyledTextCtrl::OnPaint(wxPaintEvent
& WXUNUSED(evt
)) {
3022 m_swx
->DoPaint(&dc
, GetUpdateRegion().GetBox());
3025 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent
& evt
) {
3026 if (evt
.GetOrientation() == wxHORIZONTAL
)
3027 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
3029 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
3032 void wxStyledTextCtrl::OnScroll(wxScrollEvent
& evt
) {
3033 wxScrollBar
* sb
= wxDynamicCast(evt
.GetEventObject(), wxScrollBar
);
3035 if (sb
->IsVertical())
3036 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
3038 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
3042 void wxStyledTextCtrl::OnSize(wxSizeEvent
& WXUNUSED(evt
)) {
3044 wxSize sz
= GetClientSize();
3045 m_swx
->DoSize(sz
.x
, sz
.y
);
3049 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent
& evt
) {
3051 wxPoint pt
= evt
.GetPosition();
3052 m_swx
->DoLeftButtonDown(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
3053 evt
.ShiftDown(), evt
.ControlDown(), evt
.AltDown());
3056 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent
& evt
) {
3057 wxPoint pt
= evt
.GetPosition();
3058 m_swx
->DoLeftButtonMove(Point(pt
.x
, pt
.y
));
3061 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent
& evt
) {
3062 wxPoint pt
= evt
.GetPosition();
3063 m_swx
->DoLeftButtonUp(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
3068 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent
& evt
) {
3069 wxPoint pt
= evt
.GetPosition();
3070 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
3074 void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent
& evt
) {
3075 wxPoint pt
= evt
.GetPosition();
3076 m_swx
->DoMiddleButtonUp(Point(pt
.x
, pt
.y
));
3079 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent
& evt
) {
3080 wxPoint pt
= evt
.GetPosition();
3081 ScreenToClient(&pt
.x
, &pt
.y
);
3083 Show context menu at event point if it's within the window,
3084 or at caret location if not
3086 wxHitTest ht
= this->HitTest(pt
);
3087 if (ht
!= wxHT_WINDOW_INSIDE
) {
3088 pt
= this->PointFromPosition(this->GetCurrentPos());
3090 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
3094 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent
& evt
) {
3095 m_swx
->DoMouseWheel(evt
.GetWheelRotation(),
3096 evt
.GetWheelDelta(),
3097 evt
.GetLinesPerAction(),
3099 evt
.IsPageScroll());
3103 void wxStyledTextCtrl::OnChar(wxKeyEvent
& evt
) {
3104 // On (some?) non-US PC keyboards the AltGr key is required to enter some
3105 // common characters. It comes to us as both Alt and Ctrl down so we need
3106 // to let the char through in that case, otherwise if only ctrl or only
3107 // alt let's skip it.
3108 bool ctrl
= evt
.ControlDown();
3110 // On the Mac the Alt key is just a modifier key (like Shift) so we need
3111 // to allow the char events to be processed when Alt is pressed.
3112 // TODO: Should we check MetaDown instead in this case?
3115 bool alt
= evt
.AltDown();
3117 bool skip
= ((ctrl
|| alt
) && ! (ctrl
&& alt
));
3120 // apparently if we don't do this, Unicode keys pressed after non-char
3121 // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989)
3122 if (m_lastKeyDownConsumed
&& evt
.GetUnicodeKey() > 255)
3123 m_lastKeyDownConsumed
= false;
3126 if (!m_lastKeyDownConsumed
&& !skip
) {
3128 int key
= evt
.GetUnicodeKey();
3131 // if the unicode key code is not really a unicode character (it may
3132 // be a function key or etc., the platforms appear to always give us a
3133 // small value in this case) then fallback to the ascii key code but
3134 // don't do anything for function keys or etc.
3136 key
= evt
.GetKeyCode();
3137 keyOk
= (key
<= 127);
3140 m_swx
->DoAddChar(key
);
3144 int key
= evt
.GetKeyCode();
3145 if (key
<= WXK_START
|| key
> WXK_COMMAND
) {
3146 m_swx
->DoAddChar(key
);
3156 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent
& evt
) {
3157 int processed
= m_swx
->DoKeyDown(evt
, &m_lastKeyDownConsumed
);
3158 if (!processed
&& !m_lastKeyDownConsumed
)
3163 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent
& evt
) {
3164 m_swx
->DoLoseFocus();
3169 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent
& evt
) {
3170 m_swx
->DoGainFocus();
3175 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent
& WXUNUSED(evt
)) {
3176 m_swx
->DoSysColourChange();
3180 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent
& WXUNUSED(evt
)) {
3181 // do nothing to help avoid flashing
3186 void wxStyledTextCtrl::OnMenu(wxCommandEvent
& evt
) {
3187 m_swx
->DoCommand(evt
.GetId());
3191 void wxStyledTextCtrl::OnListBox(wxCommandEvent
& WXUNUSED(evt
)) {
3192 m_swx
->DoOnListBox();
3196 void wxStyledTextCtrl::OnIdle(wxIdleEvent
& evt
) {
3197 m_swx
->DoOnIdle(evt
);
3201 wxSize
wxStyledTextCtrl::DoGetBestSize() const
3203 // What would be the best size for a wxSTC?
3204 // Just give a reasonable minimum until something else can be figured out.
3205 return wxSize(200,100);
3209 //----------------------------------------------------------------------
3210 // Turn notifications from Scintilla into events
3213 void wxStyledTextCtrl::NotifyChange() {
3214 wxStyledTextEvent
evt(wxEVT_STC_CHANGE
, GetId());
3215 evt
.SetEventObject(this);
3216 GetEventHandler()->ProcessEvent(evt
);
3220 static void SetEventText(wxStyledTextEvent
& evt
, const char* text
,
3224 evt
.SetText(stc2wx(text
, length
));
3228 void wxStyledTextCtrl::NotifyParent(SCNotification
* _scn
) {
3229 SCNotification
& scn
= *_scn
;
3230 wxStyledTextEvent
evt(0, GetId());
3232 evt
.SetEventObject(this);
3233 evt
.SetPosition(scn
.position
);
3235 evt
.SetModifiers(scn
.modifiers
);
3237 switch (scn
.nmhdr
.code
) {
3238 case SCN_STYLENEEDED
:
3239 evt
.SetEventType(wxEVT_STC_STYLENEEDED
);
3243 evt
.SetEventType(wxEVT_STC_CHARADDED
);
3246 case SCN_SAVEPOINTREACHED
:
3247 evt
.SetEventType(wxEVT_STC_SAVEPOINTREACHED
);
3250 case SCN_SAVEPOINTLEFT
:
3251 evt
.SetEventType(wxEVT_STC_SAVEPOINTLEFT
);
3254 case SCN_MODIFYATTEMPTRO
:
3255 evt
.SetEventType(wxEVT_STC_ROMODIFYATTEMPT
);
3259 evt
.SetEventType(wxEVT_STC_KEY
);
3262 case SCN_DOUBLECLICK
:
3263 evt
.SetEventType(wxEVT_STC_DOUBLECLICK
);
3267 evt
.SetEventType(wxEVT_STC_UPDATEUI
);
3271 evt
.SetEventType(wxEVT_STC_MODIFIED
);
3272 evt
.SetModificationType(scn
.modificationType
);
3273 SetEventText(evt
, scn
.text
, scn
.length
);
3274 evt
.SetLength(scn
.length
);
3275 evt
.SetLinesAdded(scn
.linesAdded
);
3276 evt
.SetLine(scn
.line
);
3277 evt
.SetFoldLevelNow(scn
.foldLevelNow
);
3278 evt
.SetFoldLevelPrev(scn
.foldLevelPrev
);
3281 case SCN_MACRORECORD
:
3282 evt
.SetEventType(wxEVT_STC_MACRORECORD
);
3283 evt
.SetMessage(scn
.message
);
3284 evt
.SetWParam(scn
.wParam
);
3285 evt
.SetLParam(scn
.lParam
);
3288 case SCN_MARGINCLICK
:
3289 evt
.SetEventType(wxEVT_STC_MARGINCLICK
);
3290 evt
.SetMargin(scn
.margin
);
3294 evt
.SetEventType(wxEVT_STC_NEEDSHOWN
);
3295 evt
.SetLength(scn
.length
);
3299 evt
.SetEventType(wxEVT_STC_PAINTED
);
3302 case SCN_AUTOCSELECTION
:
3303 evt
.SetEventType(wxEVT_STC_AUTOCOMP_SELECTION
);
3304 evt
.SetListType(scn
.listType
);
3305 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
3306 evt
.SetPosition(scn
.lParam
);
3309 case SCN_USERLISTSELECTION
:
3310 evt
.SetEventType(wxEVT_STC_USERLISTSELECTION
);
3311 evt
.SetListType(scn
.listType
);
3312 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
3313 evt
.SetPosition(scn
.lParam
);
3316 case SCN_URIDROPPED
:
3317 evt
.SetEventType(wxEVT_STC_URIDROPPED
);
3318 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
3321 case SCN_DWELLSTART
:
3322 evt
.SetEventType(wxEVT_STC_DWELLSTART
);
3328 evt
.SetEventType(wxEVT_STC_DWELLEND
);
3334 evt
.SetEventType(wxEVT_STC_ZOOM
);
3337 case SCN_HOTSPOTCLICK
:
3338 evt
.SetEventType(wxEVT_STC_HOTSPOT_CLICK
);
3341 case SCN_HOTSPOTDOUBLECLICK
:
3342 evt
.SetEventType(wxEVT_STC_HOTSPOT_DCLICK
);
3345 case SCN_CALLTIPCLICK
:
3346 evt
.SetEventType(wxEVT_STC_CALLTIP_CLICK
);
3353 GetEventHandler()->ProcessEvent(evt
);
3357 //----------------------------------------------------------------------
3358 //----------------------------------------------------------------------
3359 //----------------------------------------------------------------------
3361 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType
, int id
)
3362 : wxCommandEvent(commandType
, id
)
3367 m_modificationType
= 0;
3372 m_foldLevelPrev
= 0;
3380 m_dragAllowMove
= false;
3381 #if wxUSE_DRAG_AND_DROP
3382 m_dragResult
= wxDragNone
;
3386 bool wxStyledTextEvent::GetShift() const { return (m_modifiers
& SCI_SHIFT
) != 0; }
3387 bool wxStyledTextEvent::GetControl() const { return (m_modifiers
& SCI_CTRL
) != 0; }
3388 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers
& SCI_ALT
) != 0; }
3391 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent
& event
):
3392 wxCommandEvent(event
)
3394 m_position
= event
.m_position
;
3395 m_key
= event
.m_key
;
3396 m_modifiers
= event
.m_modifiers
;
3397 m_modificationType
= event
.m_modificationType
;
3398 m_text
= event
.m_text
;
3399 m_length
= event
.m_length
;
3400 m_linesAdded
= event
.m_linesAdded
;
3401 m_line
= event
.m_line
;
3402 m_foldLevelNow
= event
.m_foldLevelNow
;
3403 m_foldLevelPrev
= event
.m_foldLevelPrev
;
3405 m_margin
= event
.m_margin
;
3407 m_message
= event
.m_message
;
3408 m_wParam
= event
.m_wParam
;
3409 m_lParam
= event
.m_lParam
;
3411 m_listType
= event
.m_listType
;
3415 m_dragText
= event
.m_dragText
;
3416 m_dragAllowMove
=event
.m_dragAllowMove
;
3417 #if wxUSE_DRAG_AND_DROP
3418 m_dragResult
= event
.m_dragResult
;
3422 //----------------------------------------------------------------------
3423 //----------------------------------------------------------------------