1 ////////////////////////////////////////////////////////////////////////////
3 // Purpose: A wxWidgets implementation of Scintilla. This class is the
4 // one meant to be used directly by wx applications. It does not
5 // derive directly from the Scintilla classes, but instead
6 // delegates most things to the real Scintilla class.
7 // This allows the use of Scintilla without polluting the
8 // namespace with all the classes and identifiers from Scintilla.
12 // Created: 13-Jan-2000
14 // Copyright: (c) 2000 by Total Control Software
15 // Licence: wxWindows license
16 /////////////////////////////////////////////////////////////////////////////
18 // For compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
32 #include "wx/tokenzr.h"
33 #include "wx/mstream.h"
37 #include "wx/stc/stc.h"
38 #include "ScintillaWX.h"
40 //----------------------------------------------------------------------
42 const wxChar
* wxSTCNameStr
= wxT("stcwindow");
48 #define MAKELONG(a, b) ((a) | ((b) << 16))
51 static long wxColourAsLong(const wxColour
& co
) {
52 return (((long)co
.Blue() << 16) |
53 ((long)co
.Green() << 8) |
57 static wxColour
wxColourFromLong(long c
) {
59 clr
.Set((unsigned char)(c
& 0xff),
60 (unsigned char)((c
>> 8) & 0xff),
61 (unsigned char)((c
>> 16) & 0xff));
66 static wxColour
wxColourFromSpec(const wxString
& spec
) {
67 // spec should be a colour name or "#RRGGBB"
68 if (spec
.GetChar(0) == wxT('#')) {
70 long red
, green
, blue
;
71 red
= green
= blue
= 0;
72 spec
.Mid(1,2).ToLong(&red
, 16);
73 spec
.Mid(3,2).ToLong(&green
, 16);
74 spec
.Mid(5,2).ToLong(&blue
, 16);
75 return wxColour((unsigned char)red
,
80 return wxColour(spec
);
83 //----------------------------------------------------------------------
85 DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE
)
86 DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED
)
87 DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED
)
88 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED
)
89 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT
)
90 DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT
)
91 DEFINE_EVENT_TYPE( wxEVT_STC_KEY
)
92 DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK
)
93 DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI
)
94 DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED
)
95 DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD
)
96 DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK
)
97 DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN
)
98 DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED
)
99 DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION
)
100 DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED
)
101 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART
)
102 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND
)
103 DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG
)
104 DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER
)
105 DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP
)
106 DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM
)
107 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK
)
108 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK
)
109 DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK
)
110 DEFINE_EVENT_TYPE( wxEVT_STC_AUTOCOMP_SELECTION
)
114 BEGIN_EVENT_TABLE(wxStyledTextCtrl
, wxControl
)
115 EVT_PAINT (wxStyledTextCtrl::OnPaint
)
116 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin
)
117 EVT_SCROLL (wxStyledTextCtrl::OnScroll
)
118 EVT_SIZE (wxStyledTextCtrl::OnSize
)
119 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown
)
120 // Let Scintilla see the double click as a second click
121 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown
)
122 EVT_MOTION (wxStyledTextCtrl::OnMouseMove
)
123 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp
)
124 #if defined(__WXGTK__) || defined(__WXMAC__)
125 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp
)
127 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu
)
129 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel
)
130 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp
)
131 EVT_CHAR (wxStyledTextCtrl::OnChar
)
132 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown
)
133 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus
)
134 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus
)
135 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged
)
136 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground
)
137 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu
)
138 EVT_LISTBOX_DCLICK (wxID_ANY
, wxStyledTextCtrl::OnListBox
)
142 IMPLEMENT_CLASS(wxStyledTextCtrl
, wxControl
)
143 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent
, wxCommandEvent
)
146 // forces the linking of the lexer modules
147 int Scintilla_LinkLexers();
150 //----------------------------------------------------------------------
151 // Constructor and Destructor
153 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow
*parent
,
158 const wxString
& name
)
161 Create(parent
, id
, pos
, size
, style
, name
);
165 bool wxStyledTextCtrl::Create(wxWindow
*parent
,
170 const wxString
& name
)
172 style
|= wxVSCROLL
| wxHSCROLL
;
173 if (!wxControl::Create(parent
, id
, pos
, size
,
174 style
| wxWANTS_CHARS
| wxCLIP_CHILDREN
,
175 wxDefaultValidator
, name
))
179 Scintilla_LinkLexers();
181 m_swx
= new ScintillaWX(this);
183 m_lastKeyDownConsumed
= false;
187 // Put Scintilla into unicode (UTF-8) mode
188 SetCodePage(wxSTC_CP_UTF8
);
191 SetInitialSize(size
);
193 // Reduces flicker on GTK+/X11
194 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
199 wxStyledTextCtrl::~wxStyledTextCtrl() {
204 //----------------------------------------------------------------------
206 long wxStyledTextCtrl::SendMsg(int msg
, long wp
, long lp
) {
208 return m_swx
->WndProc(msg
, wp
, lp
);
211 //----------------------------------------------------------------------
213 // Set the vertical scrollbar to use instead of the ont that's built-in.
214 void wxStyledTextCtrl::SetVScrollBar(wxScrollBar
* bar
) {
217 // ensure that the built-in scrollbar is not visible
218 SetScrollbar(wxVERTICAL
, 0, 0, 0);
223 // Set the horizontal scrollbar to use instead of the ont that's built-in.
224 void wxStyledTextCtrl::SetHScrollBar(wxScrollBar
* bar
) {
227 // ensure that the built-in scrollbar is not visible
228 SetScrollbar(wxHORIZONTAL
, 0, 0, 0);
232 //----------------------------------------------------------------------
233 // BEGIN generated section. The following code is automatically generated
234 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
235 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
238 // Add text to the document at current position.
239 void wxStyledTextCtrl::AddText(const wxString
& text
) {
240 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
241 SendMsg(2001, strlen(buf
), (long)(const char*)buf
);
244 // Add array of cells to document.
245 void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer
& data
) {
246 SendMsg(2002, data
.GetDataLen(), (long)data
.GetData());
249 // Insert string at a position.
250 void wxStyledTextCtrl::InsertText(int pos
, const wxString
& text
) {
251 SendMsg(2003, pos
, (long)(const char*)wx2stc(text
));
254 // Delete all text in the document.
255 void wxStyledTextCtrl::ClearAll() {
259 // Set all style bytes to 0, remove all folding information.
260 void wxStyledTextCtrl::ClearDocumentStyle() {
264 // Returns the number of characters in the document.
265 int wxStyledTextCtrl::GetLength() {
266 return SendMsg(2006, 0, 0);
269 // Returns the character byte at the position.
270 int wxStyledTextCtrl::GetCharAt(int pos
) {
271 return (unsigned char)SendMsg(2007, pos
, 0);
274 // Returns the position of the caret.
275 int wxStyledTextCtrl::GetCurrentPos() {
276 return SendMsg(2008, 0, 0);
279 // Returns the position of the opposite end of the selection to the caret.
280 int wxStyledTextCtrl::GetAnchor() {
281 return SendMsg(2009, 0, 0);
284 // Returns the style byte at the position.
285 int wxStyledTextCtrl::GetStyleAt(int pos
) {
286 return (unsigned char)SendMsg(2010, pos
, 0);
289 // Redoes the next action on the undo history.
290 void wxStyledTextCtrl::Redo() {
294 // Choose between collecting actions into the undo
295 // history and discarding them.
296 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo
) {
297 SendMsg(2012, collectUndo
, 0);
300 // Select all the text in the document.
301 void wxStyledTextCtrl::SelectAll() {
305 // Remember the current position in the undo history as the position
306 // at which the document was saved.
307 void wxStyledTextCtrl::SetSavePoint() {
311 // Retrieve a buffer of cells.
312 wxMemoryBuffer
wxStyledTextCtrl::GetStyledText(int startPos
, int endPos
) {
314 if (endPos
< startPos
) {
319 int len
= endPos
- startPos
;
320 if (!len
) return buf
;
322 tr
.lpstrText
= (char*)buf
.GetWriteBuf(len
*2+1);
323 tr
.chrg
.cpMin
= startPos
;
324 tr
.chrg
.cpMax
= endPos
;
325 len
= SendMsg(2015, 0, (long)&tr
);
326 buf
.UngetWriteBuf(len
);
330 // Are there any redoable actions in the undo history?
331 bool wxStyledTextCtrl::CanRedo() {
332 return SendMsg(2016, 0, 0) != 0;
335 // Retrieve the line number at which a particular marker is located.
336 int wxStyledTextCtrl::MarkerLineFromHandle(int handle
) {
337 return SendMsg(2017, handle
, 0);
341 void wxStyledTextCtrl::MarkerDeleteHandle(int handle
) {
342 SendMsg(2018, handle
, 0);
345 // Is undo history being collected?
346 bool wxStyledTextCtrl::GetUndoCollection() {
347 return SendMsg(2019, 0, 0) != 0;
350 // Are white space characters currently visible?
351 // Returns one of SCWS_* constants.
352 int wxStyledTextCtrl::GetViewWhiteSpace() {
353 return SendMsg(2020, 0, 0);
356 // Make white space characters invisible, always visible or visible outside indentation.
357 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS
) {
358 SendMsg(2021, viewWS
, 0);
361 // Find the position from a point within the window.
362 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt
) {
363 return SendMsg(2022, pt
.x
, pt
.y
);
366 // Find the position from a point within the window but return
367 // INVALID_POSITION if not close to text.
368 int wxStyledTextCtrl::PositionFromPointClose(int x
, int y
) {
369 return SendMsg(2023, x
, y
);
372 // Set caret to start of a line and ensure it is visible.
373 void wxStyledTextCtrl::GotoLine(int line
) {
374 SendMsg(2024, line
, 0);
377 // Set caret to a position and ensure it is visible.
378 void wxStyledTextCtrl::GotoPos(int pos
) {
379 SendMsg(2025, pos
, 0);
382 // Set the selection anchor to a position. The anchor is the opposite
383 // end of the selection from the caret.
384 void wxStyledTextCtrl::SetAnchor(int posAnchor
) {
385 SendMsg(2026, posAnchor
, 0);
388 // Retrieve the text of the line containing the caret.
389 // Returns the index of the caret on the line.
390 wxString
wxStyledTextCtrl::GetCurLine(int* linePos
) {
391 int len
= LineLength(GetCurrentLine());
393 if (linePos
) *linePos
= 0;
394 return wxEmptyString
;
397 wxMemoryBuffer
mbuf(len
+1);
398 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
400 int pos
= SendMsg(2027, len
+1, (long)buf
);
401 mbuf
.UngetWriteBuf(len
);
403 if (linePos
) *linePos
= pos
;
407 // Retrieve the position of the last correctly styled character.
408 int wxStyledTextCtrl::GetEndStyled() {
409 return SendMsg(2028, 0, 0);
412 // Convert all line endings in the document to one mode.
413 void wxStyledTextCtrl::ConvertEOLs(int eolMode
) {
414 SendMsg(2029, eolMode
, 0);
417 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
418 int wxStyledTextCtrl::GetEOLMode() {
419 return SendMsg(2030, 0, 0);
422 // Set the current end of line mode.
423 void wxStyledTextCtrl::SetEOLMode(int eolMode
) {
424 SendMsg(2031, eolMode
, 0);
427 // Set the current styling position to pos and the styling mask to mask.
428 // The styling mask can be used to protect some bits in each styling byte from modification.
429 void wxStyledTextCtrl::StartStyling(int pos
, int mask
) {
430 SendMsg(2032, pos
, mask
);
433 // Change style from current styling position for length characters to a style
434 // and move the current styling position to after this newly styled segment.
435 void wxStyledTextCtrl::SetStyling(int length
, int style
) {
436 SendMsg(2033, length
, style
);
439 // Is drawing done first into a buffer or direct to the screen?
440 bool wxStyledTextCtrl::GetBufferedDraw() {
441 return SendMsg(2034, 0, 0) != 0;
444 // If drawing is buffered then each line of text is drawn into a bitmap buffer
445 // before drawing it to the screen to avoid flicker.
446 void wxStyledTextCtrl::SetBufferedDraw(bool buffered
) {
447 SendMsg(2035, buffered
, 0);
450 // Change the visible size of a tab to be a multiple of the width of a space character.
451 void wxStyledTextCtrl::SetTabWidth(int tabWidth
) {
452 SendMsg(2036, tabWidth
, 0);
455 // Retrieve the visible size of a tab.
456 int wxStyledTextCtrl::GetTabWidth() {
457 return SendMsg(2121, 0, 0);
460 // Set the code page used to interpret the bytes of the document as characters.
461 void wxStyledTextCtrl::SetCodePage(int codePage
) {
463 wxASSERT_MSG(codePage
== wxSTC_CP_UTF8
,
464 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
466 wxASSERT_MSG(codePage
!= wxSTC_CP_UTF8
,
467 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
469 SendMsg(2037, codePage
);
472 // Set the symbol used for a particular marker number,
473 // and optionally the fore and background colours.
474 void wxStyledTextCtrl::MarkerDefine(int markerNumber
, int markerSymbol
,
475 const wxColour
& foreground
,
476 const wxColour
& background
) {
478 SendMsg(2040, markerNumber
, markerSymbol
);
480 MarkerSetForeground(markerNumber
, foreground
);
482 MarkerSetBackground(markerNumber
, background
);
485 // Set the foreground colour used for a particular marker number.
486 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber
, const wxColour
& fore
) {
487 SendMsg(2041, markerNumber
, wxColourAsLong(fore
));
490 // Set the background colour used for a particular marker number.
491 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber
, const wxColour
& back
) {
492 SendMsg(2042, markerNumber
, wxColourAsLong(back
));
495 // Add a marker to a line, returning an ID which can be used to find or delete the marker.
496 int wxStyledTextCtrl::MarkerAdd(int line
, int markerNumber
) {
497 return SendMsg(2043, line
, markerNumber
);
500 // Delete a marker from a line.
501 void wxStyledTextCtrl::MarkerDelete(int line
, int markerNumber
) {
502 SendMsg(2044, line
, markerNumber
);
505 // Delete all markers with a particular number from all lines.
506 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber
) {
507 SendMsg(2045, markerNumber
, 0);
510 // Get a bit mask of all the markers set on a line.
511 int wxStyledTextCtrl::MarkerGet(int line
) {
512 return SendMsg(2046, line
, 0);
515 // Find the next line after lineStart that includes a marker in mask.
516 int wxStyledTextCtrl::MarkerNext(int lineStart
, int markerMask
) {
517 return SendMsg(2047, lineStart
, markerMask
);
520 // Find the previous line before lineStart that includes a marker in mask.
521 int wxStyledTextCtrl::MarkerPrevious(int lineStart
, int markerMask
) {
522 return SendMsg(2048, lineStart
, markerMask
);
525 // Define a marker from a bitmap
526 void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber
, const wxBitmap
& bmp
) {
527 // convert bmp to a xpm in a string
528 wxMemoryOutputStream strm
;
529 wxImage img
= bmp
.ConvertToImage();
531 img
.ConvertAlphaToMask();
532 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
533 size_t len
= strm
.GetSize();
534 char* buff
= new char[len
+1];
535 strm
.CopyTo(buff
, len
);
537 SendMsg(2049, markerNumber
, (long)buff
);
542 // Add a set of markers to a line.
543 void wxStyledTextCtrl::MarkerAddSet(int line
, int set
) {
544 SendMsg(2466, line
, set
);
547 // Set the alpha used for a marker that is drawn in the text area, not the margin.
548 void wxStyledTextCtrl::MarkerSetAlpha(int markerNumber
, int alpha
) {
549 SendMsg(2476, markerNumber
, alpha
);
552 // Set a margin to be either numeric or symbolic.
553 void wxStyledTextCtrl::SetMarginType(int margin
, int marginType
) {
554 SendMsg(2240, margin
, marginType
);
557 // Retrieve the type of a margin.
558 int wxStyledTextCtrl::GetMarginType(int margin
) {
559 return SendMsg(2241, margin
, 0);
562 // Set the width of a margin to a width expressed in pixels.
563 void wxStyledTextCtrl::SetMarginWidth(int margin
, int pixelWidth
) {
564 SendMsg(2242, margin
, pixelWidth
);
567 // Retrieve the width of a margin in pixels.
568 int wxStyledTextCtrl::GetMarginWidth(int margin
) {
569 return SendMsg(2243, margin
, 0);
572 // Set a mask that determines which markers are displayed in a margin.
573 void wxStyledTextCtrl::SetMarginMask(int margin
, int mask
) {
574 SendMsg(2244, margin
, mask
);
577 // Retrieve the marker mask of a margin.
578 int wxStyledTextCtrl::GetMarginMask(int margin
) {
579 return SendMsg(2245, margin
, 0);
582 // Make a margin sensitive or insensitive to mouse clicks.
583 void wxStyledTextCtrl::SetMarginSensitive(int margin
, bool sensitive
) {
584 SendMsg(2246, margin
, sensitive
);
587 // Retrieve the mouse click sensitivity of a margin.
588 bool wxStyledTextCtrl::GetMarginSensitive(int margin
) {
589 return SendMsg(2247, margin
, 0) != 0;
592 // Clear all the styles and make equivalent to the global default style.
593 void wxStyledTextCtrl::StyleClearAll() {
597 // Set the foreground colour of a style.
598 void wxStyledTextCtrl::StyleSetForeground(int style
, const wxColour
& fore
) {
599 SendMsg(2051, style
, wxColourAsLong(fore
));
602 // Set the background colour of a style.
603 void wxStyledTextCtrl::StyleSetBackground(int style
, const wxColour
& back
) {
604 SendMsg(2052, style
, wxColourAsLong(back
));
607 // Set a style to be bold or not.
608 void wxStyledTextCtrl::StyleSetBold(int style
, bool bold
) {
609 SendMsg(2053, style
, bold
);
612 // Set a style to be italic or not.
613 void wxStyledTextCtrl::StyleSetItalic(int style
, bool italic
) {
614 SendMsg(2054, style
, italic
);
617 // Set the size of characters of a style.
618 void wxStyledTextCtrl::StyleSetSize(int style
, int sizePoints
) {
619 SendMsg(2055, style
, sizePoints
);
622 // Set the font of a style.
623 void wxStyledTextCtrl::StyleSetFaceName(int style
, const wxString
& fontName
) {
624 SendMsg(2056, style
, (long)(const char*)wx2stc(fontName
));
627 // Set a style to have its end of line filled or not.
628 void wxStyledTextCtrl::StyleSetEOLFilled(int style
, bool filled
) {
629 SendMsg(2057, style
, filled
);
632 // Reset the default style to its state at startup
633 void wxStyledTextCtrl::StyleResetDefault() {
637 // Set a style to be underlined or not.
638 void wxStyledTextCtrl::StyleSetUnderline(int style
, bool underline
) {
639 SendMsg(2059, style
, underline
);
642 // Set a style to be mixed case, or to force upper or lower case.
643 void wxStyledTextCtrl::StyleSetCase(int style
, int caseForce
) {
644 SendMsg(2060, style
, caseForce
);
647 // Set a style to be a hotspot or not.
648 void wxStyledTextCtrl::StyleSetHotSpot(int style
, bool hotspot
) {
649 SendMsg(2409, style
, hotspot
);
652 // Set the foreground colour of the selection and whether to use this setting.
653 void wxStyledTextCtrl::SetSelForeground(bool useSetting
, const wxColour
& fore
) {
654 SendMsg(2067, useSetting
, wxColourAsLong(fore
));
657 // Set the background colour of the selection and whether to use this setting.
658 void wxStyledTextCtrl::SetSelBackground(bool useSetting
, const wxColour
& back
) {
659 SendMsg(2068, useSetting
, wxColourAsLong(back
));
662 // Get the alpha of the selection.
663 int wxStyledTextCtrl::GetSelAlpha() {
664 return SendMsg(2477, 0, 0);
667 // Set the alpha of the selection.
668 void wxStyledTextCtrl::SetSelAlpha(int alpha
) {
669 SendMsg(2478, alpha
, 0);
672 // Set the foreground colour of the caret.
673 void wxStyledTextCtrl::SetCaretForeground(const wxColour
& fore
) {
674 SendMsg(2069, wxColourAsLong(fore
), 0);
677 // When key+modifier combination km is pressed perform msg.
678 void wxStyledTextCtrl::CmdKeyAssign(int key
, int modifiers
, int cmd
) {
679 SendMsg(2070, MAKELONG(key
, modifiers
), cmd
);
682 // When key+modifier combination km is pressed do nothing.
683 void wxStyledTextCtrl::CmdKeyClear(int key
, int modifiers
) {
684 SendMsg(2071, MAKELONG(key
, modifiers
));
687 // Drop all key mappings.
688 void wxStyledTextCtrl::CmdKeyClearAll() {
692 // Set the styles for a segment of the document.
693 void wxStyledTextCtrl::SetStyleBytes(int length
, char* styleBytes
) {
694 SendMsg(2073, length
, (long)styleBytes
);
697 // Set a style to be visible or not.
698 void wxStyledTextCtrl::StyleSetVisible(int style
, bool visible
) {
699 SendMsg(2074, style
, visible
);
702 // Get the time in milliseconds that the caret is on and off.
703 int wxStyledTextCtrl::GetCaretPeriod() {
704 return SendMsg(2075, 0, 0);
707 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
708 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds
) {
709 SendMsg(2076, periodMilliseconds
, 0);
712 // Set the set of characters making up words for when moving or selecting by word.
713 // First sets deaults like SetCharsDefault.
714 void wxStyledTextCtrl::SetWordChars(const wxString
& characters
) {
715 SendMsg(2077, 0, (long)(const char*)wx2stc(characters
));
718 // Start a sequence of actions that is undone and redone as a unit.
720 void wxStyledTextCtrl::BeginUndoAction() {
724 // End a sequence of actions that is undone and redone as a unit.
725 void wxStyledTextCtrl::EndUndoAction() {
729 // Set an indicator to plain, squiggle or TT.
730 void wxStyledTextCtrl::IndicatorSetStyle(int indic
, int style
) {
731 SendMsg(2080, indic
, style
);
734 // Retrieve the style of an indicator.
735 int wxStyledTextCtrl::IndicatorGetStyle(int indic
) {
736 return SendMsg(2081, indic
, 0);
739 // Set the foreground colour of an indicator.
740 void wxStyledTextCtrl::IndicatorSetForeground(int indic
, const wxColour
& fore
) {
741 SendMsg(2082, indic
, wxColourAsLong(fore
));
744 // Retrieve the foreground colour of an indicator.
745 wxColour
wxStyledTextCtrl::IndicatorGetForeground(int indic
) {
746 long c
= SendMsg(2083, indic
, 0);
747 return wxColourFromLong(c
);
750 // Set the foreground colour of all whitespace and whether to use this setting.
751 void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting
, const wxColour
& fore
) {
752 SendMsg(2084, useSetting
, wxColourAsLong(fore
));
755 // Set the background colour of all whitespace and whether to use this setting.
756 void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting
, const wxColour
& back
) {
757 SendMsg(2085, useSetting
, wxColourAsLong(back
));
760 // Divide each styling byte into lexical class bits (default: 5) and indicator
761 // bits (default: 3). If a lexer requires more than 32 lexical states, then this
762 // is used to expand the possible states.
763 void wxStyledTextCtrl::SetStyleBits(int bits
) {
764 SendMsg(2090, bits
, 0);
767 // Retrieve number of bits in style bytes used to hold the lexical state.
768 int wxStyledTextCtrl::GetStyleBits() {
769 return SendMsg(2091, 0, 0);
772 // Used to hold extra styling information for each line.
773 void wxStyledTextCtrl::SetLineState(int line
, int state
) {
774 SendMsg(2092, line
, state
);
777 // Retrieve the extra styling information for a line.
778 int wxStyledTextCtrl::GetLineState(int line
) {
779 return SendMsg(2093, line
, 0);
782 // Retrieve the last line number that has line state.
783 int wxStyledTextCtrl::GetMaxLineState() {
784 return SendMsg(2094, 0, 0);
787 // Is the background of the line containing the caret in a different colour?
788 bool wxStyledTextCtrl::GetCaretLineVisible() {
789 return SendMsg(2095, 0, 0) != 0;
792 // Display the background of the line containing the caret in a different colour.
793 void wxStyledTextCtrl::SetCaretLineVisible(bool show
) {
794 SendMsg(2096, show
, 0);
797 // Get the colour of the background of the line containing the caret.
798 wxColour
wxStyledTextCtrl::GetCaretLineBackground() {
799 long c
= SendMsg(2097, 0, 0);
800 return wxColourFromLong(c
);
803 // Set the colour of the background of the line containing the caret.
804 void wxStyledTextCtrl::SetCaretLineBackground(const wxColour
& back
) {
805 SendMsg(2098, wxColourAsLong(back
), 0);
808 // Set a style to be changeable or not (read only).
809 // Experimental feature, currently buggy.
810 void wxStyledTextCtrl::StyleSetChangeable(int style
, bool changeable
) {
811 SendMsg(2099, style
, changeable
);
814 // Display a auto-completion list.
815 // The lenEntered parameter indicates how many characters before
816 // the caret should be used to provide context.
817 void wxStyledTextCtrl::AutoCompShow(int lenEntered
, const wxString
& itemList
) {
818 SendMsg(2100, lenEntered
, (long)(const char*)wx2stc(itemList
));
821 // Remove the auto-completion list from the screen.
822 void wxStyledTextCtrl::AutoCompCancel() {
826 // Is there an auto-completion list visible?
827 bool wxStyledTextCtrl::AutoCompActive() {
828 return SendMsg(2102, 0, 0) != 0;
831 // Retrieve the position of the caret when the auto-completion list was displayed.
832 int wxStyledTextCtrl::AutoCompPosStart() {
833 return SendMsg(2103, 0, 0);
836 // User has selected an item so remove the list and insert the selection.
837 void wxStyledTextCtrl::AutoCompComplete() {
841 // Define a set of character that when typed cancel the auto-completion list.
842 void wxStyledTextCtrl::AutoCompStops(const wxString
& characterSet
) {
843 SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet
));
846 // Change the separator character in the string setting up an auto-completion list.
847 // Default is space but can be changed if items contain space.
848 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter
) {
849 SendMsg(2106, separatorCharacter
, 0);
852 // Retrieve the auto-completion list separator character.
853 int wxStyledTextCtrl::AutoCompGetSeparator() {
854 return SendMsg(2107, 0, 0);
857 // Select the item in the auto-completion list that starts with a string.
858 void wxStyledTextCtrl::AutoCompSelect(const wxString
& text
) {
859 SendMsg(2108, 0, (long)(const char*)wx2stc(text
));
862 // Should the auto-completion list be cancelled if the user backspaces to a
863 // position before where the box was created.
864 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel
) {
865 SendMsg(2110, cancel
, 0);
868 // Retrieve whether auto-completion cancelled by backspacing before start.
869 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
870 return SendMsg(2111, 0, 0) != 0;
873 // Define a set of characters that when typed will cause the autocompletion to
874 // choose the selected item.
875 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString
& characterSet
) {
876 SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet
));
879 // Should a single item auto-completion list automatically choose the item.
880 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle
) {
881 SendMsg(2113, chooseSingle
, 0);
884 // Retrieve whether a single item auto-completion list automatically choose the item.
885 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
886 return SendMsg(2114, 0, 0) != 0;
889 // Set whether case is significant when performing auto-completion searches.
890 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase
) {
891 SendMsg(2115, ignoreCase
, 0);
894 // Retrieve state of ignore case flag.
895 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
896 return SendMsg(2116, 0, 0) != 0;
899 // Display a list of strings and send notification when user chooses one.
900 void wxStyledTextCtrl::UserListShow(int listType
, const wxString
& itemList
) {
901 SendMsg(2117, listType
, (long)(const char*)wx2stc(itemList
));
904 // Set whether or not autocompletion is hidden automatically when nothing matches.
905 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide
) {
906 SendMsg(2118, autoHide
, 0);
909 // Retrieve whether or not autocompletion is hidden automatically when nothing matches.
910 bool wxStyledTextCtrl::AutoCompGetAutoHide() {
911 return SendMsg(2119, 0, 0) != 0;
914 // Set whether or not autocompletion deletes any word characters
915 // after the inserted text upon completion.
916 void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord
) {
917 SendMsg(2270, dropRestOfWord
, 0);
920 // Retrieve whether or not autocompletion deletes any word characters
921 // after the inserted text upon completion.
922 bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
923 return SendMsg(2271, 0, 0) != 0;
926 // Register an image for use in autocompletion lists.
927 void wxStyledTextCtrl::RegisterImage(int type
, const wxBitmap
& bmp
) {
928 // convert bmp to a xpm in a string
929 wxMemoryOutputStream strm
;
930 wxImage img
= bmp
.ConvertToImage();
932 img
.ConvertAlphaToMask();
933 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
934 size_t len
= strm
.GetSize();
935 char* buff
= new char[len
+1];
936 strm
.CopyTo(buff
, len
);
938 SendMsg(2405, type
, (long)buff
);
943 // Clear all the registered images.
944 void wxStyledTextCtrl::ClearRegisteredImages() {
948 // Retrieve the auto-completion list type-separator character.
949 int wxStyledTextCtrl::AutoCompGetTypeSeparator() {
950 return SendMsg(2285, 0, 0);
953 // Change the type-separator character in the string setting up an auto-completion list.
954 // Default is '?' but can be changed if items contain '?'.
955 void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter
) {
956 SendMsg(2286, separatorCharacter
, 0);
959 // Set the maximum width, in characters, of auto-completion and user lists.
960 // Set to 0 to autosize to fit longest item, which is the default.
961 void wxStyledTextCtrl::AutoCompSetMaxWidth(int characterCount
) {
962 SendMsg(2208, characterCount
, 0);
965 // Get the maximum width, in characters, of auto-completion and user lists.
966 int wxStyledTextCtrl::AutoCompGetMaxWidth() {
967 return SendMsg(2209, 0, 0);
970 // Set the maximum height, in rows, of auto-completion and user lists.
971 // The default is 5 rows.
972 void wxStyledTextCtrl::AutoCompSetMaxHeight(int rowCount
) {
973 SendMsg(2210, rowCount
, 0);
976 // Set the maximum height, in rows, of auto-completion and user lists.
977 int wxStyledTextCtrl::AutoCompGetMaxHeight() {
978 return SendMsg(2211, 0, 0);
981 // Set the number of spaces used for one level of indentation.
982 void wxStyledTextCtrl::SetIndent(int indentSize
) {
983 SendMsg(2122, indentSize
, 0);
986 // Retrieve indentation size.
987 int wxStyledTextCtrl::GetIndent() {
988 return SendMsg(2123, 0, 0);
991 // Indentation will only use space characters if useTabs is false, otherwise
992 // it will use a combination of tabs and spaces.
993 void wxStyledTextCtrl::SetUseTabs(bool useTabs
) {
994 SendMsg(2124, useTabs
, 0);
997 // Retrieve whether tabs will be used in indentation.
998 bool wxStyledTextCtrl::GetUseTabs() {
999 return SendMsg(2125, 0, 0) != 0;
1002 // Change the indentation of a line to a number of columns.
1003 void wxStyledTextCtrl::SetLineIndentation(int line
, int indentSize
) {
1004 SendMsg(2126, line
, indentSize
);
1007 // Retrieve the number of columns that a line is indented.
1008 int wxStyledTextCtrl::GetLineIndentation(int line
) {
1009 return SendMsg(2127, line
, 0);
1012 // Retrieve the position before the first non indentation character on a line.
1013 int wxStyledTextCtrl::GetLineIndentPosition(int line
) {
1014 return SendMsg(2128, line
, 0);
1017 // Retrieve the column number of a position, taking tab width into account.
1018 int wxStyledTextCtrl::GetColumn(int pos
) {
1019 return SendMsg(2129, pos
, 0);
1022 // Show or hide the horizontal scroll bar.
1023 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show
) {
1024 SendMsg(2130, show
, 0);
1027 // Is the horizontal scroll bar visible?
1028 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
1029 return SendMsg(2131, 0, 0) != 0;
1032 // Show or hide indentation guides.
1033 void wxStyledTextCtrl::SetIndentationGuides(bool show
) {
1034 SendMsg(2132, show
, 0);
1037 // Are the indentation guides visible?
1038 bool wxStyledTextCtrl::GetIndentationGuides() {
1039 return SendMsg(2133, 0, 0) != 0;
1042 // Set the highlighted indentation guide column.
1043 // 0 = no highlighted guide.
1044 void wxStyledTextCtrl::SetHighlightGuide(int column
) {
1045 SendMsg(2134, column
, 0);
1048 // Get the highlighted indentation guide column.
1049 int wxStyledTextCtrl::GetHighlightGuide() {
1050 return SendMsg(2135, 0, 0);
1053 // Get the position after the last visible characters on a line.
1054 int wxStyledTextCtrl::GetLineEndPosition(int line
) {
1055 return SendMsg(2136, line
, 0);
1058 // Get the code page used to interpret the bytes of the document as characters.
1059 int wxStyledTextCtrl::GetCodePage() {
1060 return SendMsg(2137, 0, 0);
1063 // Get the foreground colour of the caret.
1064 wxColour
wxStyledTextCtrl::GetCaretForeground() {
1065 long c
= SendMsg(2138, 0, 0);
1066 return wxColourFromLong(c
);
1069 // In read-only mode?
1070 bool wxStyledTextCtrl::GetReadOnly() {
1071 return SendMsg(2140, 0, 0) != 0;
1074 // Sets the position of the caret.
1075 void wxStyledTextCtrl::SetCurrentPos(int pos
) {
1076 SendMsg(2141, pos
, 0);
1079 // Sets the position that starts the selection - this becomes the anchor.
1080 void wxStyledTextCtrl::SetSelectionStart(int pos
) {
1081 SendMsg(2142, pos
, 0);
1084 // Returns the position at the start of the selection.
1085 int wxStyledTextCtrl::GetSelectionStart() {
1086 return SendMsg(2143, 0, 0);
1089 // Sets the position that ends the selection - this becomes the currentPosition.
1090 void wxStyledTextCtrl::SetSelectionEnd(int pos
) {
1091 SendMsg(2144, pos
, 0);
1094 // Returns the position at the end of the selection.
1095 int wxStyledTextCtrl::GetSelectionEnd() {
1096 return SendMsg(2145, 0, 0);
1099 // Sets the print magnification added to the point size of each style for printing.
1100 void wxStyledTextCtrl::SetPrintMagnification(int magnification
) {
1101 SendMsg(2146, magnification
, 0);
1104 // Returns the print magnification.
1105 int wxStyledTextCtrl::GetPrintMagnification() {
1106 return SendMsg(2147, 0, 0);
1109 // Modify colours when printing for clearer printed text.
1110 void wxStyledTextCtrl::SetPrintColourMode(int mode
) {
1111 SendMsg(2148, mode
, 0);
1114 // Returns the print colour mode.
1115 int wxStyledTextCtrl::GetPrintColourMode() {
1116 return SendMsg(2149, 0, 0);
1119 // Find some text in the document.
1120 int wxStyledTextCtrl::FindText(int minPos
, int maxPos
,
1121 const wxString
& text
,
1124 ft
.chrg
.cpMin
= minPos
;
1125 ft
.chrg
.cpMax
= maxPos
;
1126 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1127 ft
.lpstrText
= (char*)(const char*)buf
;
1129 return SendMsg(2150, flags
, (long)&ft
);
1132 // On Windows, will draw the document into a display context such as a printer.
1133 int wxStyledTextCtrl::FormatRange(bool doDraw
,
1142 if (endPos
< startPos
) {
1143 int temp
= startPos
;
1148 fr
.hdcTarget
= target
;
1149 fr
.rc
.top
= renderRect
.GetTop();
1150 fr
.rc
.left
= renderRect
.GetLeft();
1151 fr
.rc
.right
= renderRect
.GetRight();
1152 fr
.rc
.bottom
= renderRect
.GetBottom();
1153 fr
.rcPage
.top
= pageRect
.GetTop();
1154 fr
.rcPage
.left
= pageRect
.GetLeft();
1155 fr
.rcPage
.right
= pageRect
.GetRight();
1156 fr
.rcPage
.bottom
= pageRect
.GetBottom();
1157 fr
.chrg
.cpMin
= startPos
;
1158 fr
.chrg
.cpMax
= endPos
;
1160 return SendMsg(2151, doDraw
, (long)&fr
);
1163 // Retrieve the display line at the top of the display.
1164 int wxStyledTextCtrl::GetFirstVisibleLine() {
1165 return SendMsg(2152, 0, 0);
1168 // Retrieve the contents of a line.
1169 wxString
wxStyledTextCtrl::GetLine(int line
) {
1170 int len
= LineLength(line
);
1171 if (!len
) return wxEmptyString
;
1173 wxMemoryBuffer
mbuf(len
+1);
1174 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1175 SendMsg(2153, line
, (long)buf
);
1176 mbuf
.UngetWriteBuf(len
);
1181 // Returns the number of lines in the document. There is always at least one.
1182 int wxStyledTextCtrl::GetLineCount() {
1183 return SendMsg(2154, 0, 0);
1186 // Sets the size in pixels of the left margin.
1187 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth
) {
1188 SendMsg(2155, 0, pixelWidth
);
1191 // Returns the size in pixels of the left margin.
1192 int wxStyledTextCtrl::GetMarginLeft() {
1193 return SendMsg(2156, 0, 0);
1196 // Sets the size in pixels of the right margin.
1197 void wxStyledTextCtrl::SetMarginRight(int pixelWidth
) {
1198 SendMsg(2157, 0, pixelWidth
);
1201 // Returns the size in pixels of the right margin.
1202 int wxStyledTextCtrl::GetMarginRight() {
1203 return SendMsg(2158, 0, 0);
1206 // Is the document different from when it was last saved?
1207 bool wxStyledTextCtrl::GetModify() {
1208 return SendMsg(2159, 0, 0) != 0;
1211 // Select a range of text.
1212 void wxStyledTextCtrl::SetSelection(int start
, int end
) {
1213 SendMsg(2160, start
, end
);
1216 // Retrieve the selected text.
1217 wxString
wxStyledTextCtrl::GetSelectedText() {
1221 GetSelection(&start
, &end
);
1222 int len
= end
- start
;
1223 if (!len
) return wxEmptyString
;
1225 wxMemoryBuffer
mbuf(len
+2);
1226 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1227 SendMsg(2161, 0, (long)buf
);
1228 mbuf
.UngetWriteBuf(len
);
1233 // Retrieve a range of text.
1234 wxString
wxStyledTextCtrl::GetTextRange(int startPos
, int endPos
) {
1235 if (endPos
< startPos
) {
1236 int temp
= startPos
;
1240 int len
= endPos
- startPos
;
1241 if (!len
) return wxEmptyString
;
1242 wxMemoryBuffer
mbuf(len
+1);
1243 char* buf
= (char*)mbuf
.GetWriteBuf(len
);
1246 tr
.chrg
.cpMin
= startPos
;
1247 tr
.chrg
.cpMax
= endPos
;
1248 SendMsg(2162, 0, (long)&tr
);
1249 mbuf
.UngetWriteBuf(len
);
1254 // Draw the selection in normal style or with selection highlighted.
1255 void wxStyledTextCtrl::HideSelection(bool normal
) {
1256 SendMsg(2163, normal
, 0);
1259 // Retrieve the line containing a position.
1260 int wxStyledTextCtrl::LineFromPosition(int pos
) {
1261 return SendMsg(2166, pos
, 0);
1264 // Retrieve the position at the start of a line.
1265 int wxStyledTextCtrl::PositionFromLine(int line
) {
1266 return SendMsg(2167, line
, 0);
1269 // Scroll horizontally and vertically.
1270 void wxStyledTextCtrl::LineScroll(int columns
, int lines
) {
1271 SendMsg(2168, columns
, lines
);
1274 // Ensure the caret is visible.
1275 void wxStyledTextCtrl::EnsureCaretVisible() {
1276 SendMsg(2169, 0, 0);
1279 // Replace the selected text with the argument text.
1280 void wxStyledTextCtrl::ReplaceSelection(const wxString
& text
) {
1281 SendMsg(2170, 0, (long)(const char*)wx2stc(text
));
1284 // Set to read only or read write.
1285 void wxStyledTextCtrl::SetReadOnly(bool readOnly
) {
1286 SendMsg(2171, readOnly
, 0);
1289 // Will a paste succeed?
1290 bool wxStyledTextCtrl::CanPaste() {
1291 return SendMsg(2173, 0, 0) != 0;
1294 // Are there any undoable actions in the undo history?
1295 bool wxStyledTextCtrl::CanUndo() {
1296 return SendMsg(2174, 0, 0) != 0;
1299 // Delete the undo history.
1300 void wxStyledTextCtrl::EmptyUndoBuffer() {
1301 SendMsg(2175, 0, 0);
1304 // Undo one action in the undo history.
1305 void wxStyledTextCtrl::Undo() {
1306 SendMsg(2176, 0, 0);
1309 // Cut the selection to the clipboard.
1310 void wxStyledTextCtrl::Cut() {
1311 SendMsg(2177, 0, 0);
1314 // Copy the selection to the clipboard.
1315 void wxStyledTextCtrl::Copy() {
1316 SendMsg(2178, 0, 0);
1319 // Paste the contents of the clipboard into the document replacing the selection.
1320 void wxStyledTextCtrl::Paste() {
1321 SendMsg(2179, 0, 0);
1324 // Clear the selection.
1325 void wxStyledTextCtrl::Clear() {
1326 SendMsg(2180, 0, 0);
1329 // Replace the contents of the document with the argument text.
1330 void wxStyledTextCtrl::SetText(const wxString
& text
) {
1331 SendMsg(2181, 0, (long)(const char*)wx2stc(text
));
1334 // Retrieve all the text in the document.
1335 wxString
wxStyledTextCtrl::GetText() {
1336 int len
= GetTextLength();
1337 wxMemoryBuffer
mbuf(len
+1); // leave room for the null...
1338 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1339 SendMsg(2182, len
+1, (long)buf
);
1340 mbuf
.UngetWriteBuf(len
);
1345 // Retrieve the number of characters in the document.
1346 int wxStyledTextCtrl::GetTextLength() {
1347 return SendMsg(2183, 0, 0);
1350 // Set to overtype (true) or insert mode.
1351 void wxStyledTextCtrl::SetOvertype(bool overtype
) {
1352 SendMsg(2186, overtype
, 0);
1355 // Returns true if overtype mode is active otherwise false is returned.
1356 bool wxStyledTextCtrl::GetOvertype() {
1357 return SendMsg(2187, 0, 0) != 0;
1360 // Set the width of the insert mode caret.
1361 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth
) {
1362 SendMsg(2188, pixelWidth
, 0);
1365 // Returns the width of the insert mode caret.
1366 int wxStyledTextCtrl::GetCaretWidth() {
1367 return SendMsg(2189, 0, 0);
1370 // Sets the position that starts the target which is used for updating the
1371 // document without affecting the scroll position.
1372 void wxStyledTextCtrl::SetTargetStart(int pos
) {
1373 SendMsg(2190, pos
, 0);
1376 // Get the position that starts the target.
1377 int wxStyledTextCtrl::GetTargetStart() {
1378 return SendMsg(2191, 0, 0);
1381 // Sets the position that ends the target which is used for updating the
1382 // document without affecting the scroll position.
1383 void wxStyledTextCtrl::SetTargetEnd(int pos
) {
1384 SendMsg(2192, pos
, 0);
1387 // Get the position that ends the target.
1388 int wxStyledTextCtrl::GetTargetEnd() {
1389 return SendMsg(2193, 0, 0);
1392 // Replace the target text with the argument text.
1393 // Text is counted so it can contain NULs.
1394 // Returns the length of the replacement text.
1396 int wxStyledTextCtrl::ReplaceTarget(const wxString
& text
) {
1397 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1398 return SendMsg(2194, strlen(buf
), (long)(const char*)buf
);
1401 // Replace the target text with the argument text after \d processing.
1402 // Text is counted so it can contain NULs.
1403 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1404 // matched in the last search operation which were surrounded by \( and \).
1405 // Returns the length of the replacement text including any change
1406 // caused by processing the \d patterns.
1408 int wxStyledTextCtrl::ReplaceTargetRE(const wxString
& text
) {
1409 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1410 return SendMsg(2195, strlen(buf
), (long)(const char*)buf
);
1413 // Search for a counted string in the target and set the target to the found
1414 // range. Text is counted so it can contain NULs.
1415 // Returns length of range or -1 for failure in which case target is not moved.
1417 int wxStyledTextCtrl::SearchInTarget(const wxString
& text
) {
1418 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1419 return SendMsg(2197, strlen(buf
), (long)(const char*)buf
);
1422 // Set the search flags used by SearchInTarget.
1423 void wxStyledTextCtrl::SetSearchFlags(int flags
) {
1424 SendMsg(2198, flags
, 0);
1427 // Get the search flags used by SearchInTarget.
1428 int wxStyledTextCtrl::GetSearchFlags() {
1429 return SendMsg(2199, 0, 0);
1432 // Show a call tip containing a definition near position pos.
1433 void wxStyledTextCtrl::CallTipShow(int pos
, const wxString
& definition
) {
1434 SendMsg(2200, pos
, (long)(const char*)wx2stc(definition
));
1437 // Remove the call tip from the screen.
1438 void wxStyledTextCtrl::CallTipCancel() {
1439 SendMsg(2201, 0, 0);
1442 // Is there an active call tip?
1443 bool wxStyledTextCtrl::CallTipActive() {
1444 return SendMsg(2202, 0, 0) != 0;
1447 // Retrieve the position where the caret was before displaying the call tip.
1448 int wxStyledTextCtrl::CallTipPosAtStart() {
1449 return SendMsg(2203, 0, 0);
1452 // Highlight a segment of the definition.
1453 void wxStyledTextCtrl::CallTipSetHighlight(int start
, int end
) {
1454 SendMsg(2204, start
, end
);
1457 // Set the background colour for the call tip.
1458 void wxStyledTextCtrl::CallTipSetBackground(const wxColour
& back
) {
1459 SendMsg(2205, wxColourAsLong(back
), 0);
1462 // Set the foreground colour for the call tip.
1463 void wxStyledTextCtrl::CallTipSetForeground(const wxColour
& fore
) {
1464 SendMsg(2206, wxColourAsLong(fore
), 0);
1467 // Set the foreground colour for the highlighted part of the call tip.
1468 void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour
& fore
) {
1469 SendMsg(2207, wxColourAsLong(fore
), 0);
1472 // Enable use of STYLE_CALLTIP and set call tip tab size in pixels.
1473 void wxStyledTextCtrl::CallTipUseStyle(int tabSize
) {
1474 SendMsg(2212, tabSize
, 0);
1477 // Find the display line of a document line taking hidden lines into account.
1478 int wxStyledTextCtrl::VisibleFromDocLine(int line
) {
1479 return SendMsg(2220, line
, 0);
1482 // Find the document line of a display line taking hidden lines into account.
1483 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay
) {
1484 return SendMsg(2221, lineDisplay
, 0);
1487 // The number of display lines needed to wrap a document line
1488 int wxStyledTextCtrl::WrapCount(int line
) {
1489 return SendMsg(2235, line
, 0);
1492 // Set the fold level of a line.
1493 // This encodes an integer level along with flags indicating whether the
1494 // line is a header and whether it is effectively white space.
1495 void wxStyledTextCtrl::SetFoldLevel(int line
, int level
) {
1496 SendMsg(2222, line
, level
);
1499 // Retrieve the fold level of a line.
1500 int wxStyledTextCtrl::GetFoldLevel(int line
) {
1501 return SendMsg(2223, line
, 0);
1504 // Find the last child line of a header line.
1505 int wxStyledTextCtrl::GetLastChild(int line
, int level
) {
1506 return SendMsg(2224, line
, level
);
1509 // Find the parent line of a child line.
1510 int wxStyledTextCtrl::GetFoldParent(int line
) {
1511 return SendMsg(2225, line
, 0);
1514 // Make a range of lines visible.
1515 void wxStyledTextCtrl::ShowLines(int lineStart
, int lineEnd
) {
1516 SendMsg(2226, lineStart
, lineEnd
);
1519 // Make a range of lines invisible.
1520 void wxStyledTextCtrl::HideLines(int lineStart
, int lineEnd
) {
1521 SendMsg(2227, lineStart
, lineEnd
);
1524 // Is a line visible?
1525 bool wxStyledTextCtrl::GetLineVisible(int line
) {
1526 return SendMsg(2228, line
, 0) != 0;
1529 // Show the children of a header line.
1530 void wxStyledTextCtrl::SetFoldExpanded(int line
, bool expanded
) {
1531 SendMsg(2229, line
, expanded
);
1534 // Is a header line expanded?
1535 bool wxStyledTextCtrl::GetFoldExpanded(int line
) {
1536 return SendMsg(2230, line
, 0) != 0;
1539 // Switch a header line between expanded and contracted.
1540 void wxStyledTextCtrl::ToggleFold(int line
) {
1541 SendMsg(2231, line
, 0);
1544 // Ensure a particular line is visible by expanding any header line hiding it.
1545 void wxStyledTextCtrl::EnsureVisible(int line
) {
1546 SendMsg(2232, line
, 0);
1549 // Set some style options for folding.
1550 void wxStyledTextCtrl::SetFoldFlags(int flags
) {
1551 SendMsg(2233, flags
, 0);
1554 // Ensure a particular line is visible by expanding any header line hiding it.
1555 // Use the currently set visibility policy to determine which range to display.
1556 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line
) {
1557 SendMsg(2234, line
, 0);
1560 // Sets whether a tab pressed when caret is within indentation indents.
1561 void wxStyledTextCtrl::SetTabIndents(bool tabIndents
) {
1562 SendMsg(2260, tabIndents
, 0);
1565 // Does a tab pressed when caret is within indentation indent?
1566 bool wxStyledTextCtrl::GetTabIndents() {
1567 return SendMsg(2261, 0, 0) != 0;
1570 // Sets whether a backspace pressed when caret is within indentation unindents.
1571 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents
) {
1572 SendMsg(2262, bsUnIndents
, 0);
1575 // Does a backspace pressed when caret is within indentation unindent?
1576 bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1577 return SendMsg(2263, 0, 0) != 0;
1580 // Sets the time the mouse must sit still to generate a mouse dwell event.
1581 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds
) {
1582 SendMsg(2264, periodMilliseconds
, 0);
1585 // Retrieve the time the mouse must sit still to generate a mouse dwell event.
1586 int wxStyledTextCtrl::GetMouseDwellTime() {
1587 return SendMsg(2265, 0, 0);
1590 // Get position of start of word.
1591 int wxStyledTextCtrl::WordStartPosition(int pos
, bool onlyWordCharacters
) {
1592 return SendMsg(2266, pos
, onlyWordCharacters
);
1595 // Get position of end of word.
1596 int wxStyledTextCtrl::WordEndPosition(int pos
, bool onlyWordCharacters
) {
1597 return SendMsg(2267, pos
, onlyWordCharacters
);
1600 // Sets whether text is word wrapped.
1601 void wxStyledTextCtrl::SetWrapMode(int mode
) {
1602 SendMsg(2268, mode
, 0);
1605 // Retrieve whether text is word wrapped.
1606 int wxStyledTextCtrl::GetWrapMode() {
1607 return SendMsg(2269, 0, 0);
1610 // Set the display mode of visual flags for wrapped lines.
1611 void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags
) {
1612 SendMsg(2460, wrapVisualFlags
, 0);
1615 // Retrive the display mode of visual flags for wrapped lines.
1616 int wxStyledTextCtrl::GetWrapVisualFlags() {
1617 return SendMsg(2461, 0, 0);
1620 // Set the location of visual flags for wrapped lines.
1621 void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation
) {
1622 SendMsg(2462, wrapVisualFlagsLocation
, 0);
1625 // Retrive the location of visual flags for wrapped lines.
1626 int wxStyledTextCtrl::GetWrapVisualFlagsLocation() {
1627 return SendMsg(2463, 0, 0);
1630 // Set the start indent for wrapped lines.
1631 void wxStyledTextCtrl::SetWrapStartIndent(int indent
) {
1632 SendMsg(2464, indent
, 0);
1635 // Retrive the start indent for wrapped lines.
1636 int wxStyledTextCtrl::GetWrapStartIndent() {
1637 return SendMsg(2465, 0, 0);
1640 // Sets the degree of caching of layout information.
1641 void wxStyledTextCtrl::SetLayoutCache(int mode
) {
1642 SendMsg(2272, mode
, 0);
1645 // Retrieve the degree of caching of layout information.
1646 int wxStyledTextCtrl::GetLayoutCache() {
1647 return SendMsg(2273, 0, 0);
1650 // Sets the document width assumed for scrolling.
1651 void wxStyledTextCtrl::SetScrollWidth(int pixelWidth
) {
1652 SendMsg(2274, pixelWidth
, 0);
1655 // Retrieve the document width assumed for scrolling.
1656 int wxStyledTextCtrl::GetScrollWidth() {
1657 return SendMsg(2275, 0, 0);
1660 // Measure the pixel width of some text in a particular style.
1661 // NUL terminated text argument.
1662 // Does not handle tab or control characters.
1663 int wxStyledTextCtrl::TextWidth(int style
, const wxString
& text
) {
1664 return SendMsg(2276, style
, (long)(const char*)wx2stc(text
));
1667 // Sets the scroll range so that maximum scroll position has
1668 // the last line at the bottom of the view (default).
1669 // Setting this to false allows scrolling one page below the last line.
1670 void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine
) {
1671 SendMsg(2277, endAtLastLine
, 0);
1674 // Retrieve whether the maximum scroll position has the last
1675 // line at the bottom of the view.
1676 bool wxStyledTextCtrl::GetEndAtLastLine() {
1677 return SendMsg(2278, 0, 0) != 0;
1680 // Retrieve the height of a particular line of text in pixels.
1681 int wxStyledTextCtrl::TextHeight(int line
) {
1682 return SendMsg(2279, line
, 0);
1685 // Show or hide the vertical scroll bar.
1686 void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show
) {
1687 SendMsg(2280, show
, 0);
1690 // Is the vertical scroll bar visible?
1691 bool wxStyledTextCtrl::GetUseVerticalScrollBar() {
1692 return SendMsg(2281, 0, 0) != 0;
1695 // Append a string to the end of the document without changing the selection.
1696 void wxStyledTextCtrl::AppendText(const wxString
& text
) {
1697 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1698 SendMsg(2282, strlen(buf
), (long)(const char*)buf
);
1701 // Is drawing done in two phases with backgrounds drawn before foregrounds?
1702 bool wxStyledTextCtrl::GetTwoPhaseDraw() {
1703 return SendMsg(2283, 0, 0) != 0;
1706 // In twoPhaseDraw mode, drawing is performed in two phases, first the background
1707 // and then the foreground. This avoids chopping off characters that overlap the next run.
1708 void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase
) {
1709 SendMsg(2284, twoPhase
, 0);
1712 // Make the target range start and end be the same as the selection range start and end.
1713 void wxStyledTextCtrl::TargetFromSelection() {
1714 SendMsg(2287, 0, 0);
1717 // Join the lines in the target.
1718 void wxStyledTextCtrl::LinesJoin() {
1719 SendMsg(2288, 0, 0);
1722 // Split the lines in the target into lines that are less wide than pixelWidth
1724 void wxStyledTextCtrl::LinesSplit(int pixelWidth
) {
1725 SendMsg(2289, pixelWidth
, 0);
1728 // Set the colours used as a chequerboard pattern in the fold margin
1729 void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting
, const wxColour
& back
) {
1730 SendMsg(2290, useSetting
, wxColourAsLong(back
));
1732 void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting
, const wxColour
& fore
) {
1733 SendMsg(2291, useSetting
, wxColourAsLong(fore
));
1736 // Move caret down one line.
1737 void wxStyledTextCtrl::LineDown() {
1738 SendMsg(2300, 0, 0);
1741 // Move caret down one line extending selection to new caret position.
1742 void wxStyledTextCtrl::LineDownExtend() {
1743 SendMsg(2301, 0, 0);
1746 // Move caret up one line.
1747 void wxStyledTextCtrl::LineUp() {
1748 SendMsg(2302, 0, 0);
1751 // Move caret up one line extending selection to new caret position.
1752 void wxStyledTextCtrl::LineUpExtend() {
1753 SendMsg(2303, 0, 0);
1756 // Move caret left one character.
1757 void wxStyledTextCtrl::CharLeft() {
1758 SendMsg(2304, 0, 0);
1761 // Move caret left one character extending selection to new caret position.
1762 void wxStyledTextCtrl::CharLeftExtend() {
1763 SendMsg(2305, 0, 0);
1766 // Move caret right one character.
1767 void wxStyledTextCtrl::CharRight() {
1768 SendMsg(2306, 0, 0);
1771 // Move caret right one character extending selection to new caret position.
1772 void wxStyledTextCtrl::CharRightExtend() {
1773 SendMsg(2307, 0, 0);
1776 // Move caret left one word.
1777 void wxStyledTextCtrl::WordLeft() {
1778 SendMsg(2308, 0, 0);
1781 // Move caret left one word extending selection to new caret position.
1782 void wxStyledTextCtrl::WordLeftExtend() {
1783 SendMsg(2309, 0, 0);
1786 // Move caret right one word.
1787 void wxStyledTextCtrl::WordRight() {
1788 SendMsg(2310, 0, 0);
1791 // Move caret right one word extending selection to new caret position.
1792 void wxStyledTextCtrl::WordRightExtend() {
1793 SendMsg(2311, 0, 0);
1796 // Move caret to first position on line.
1797 void wxStyledTextCtrl::Home() {
1798 SendMsg(2312, 0, 0);
1801 // Move caret to first position on line extending selection to new caret position.
1802 void wxStyledTextCtrl::HomeExtend() {
1803 SendMsg(2313, 0, 0);
1806 // Move caret to last position on line.
1807 void wxStyledTextCtrl::LineEnd() {
1808 SendMsg(2314, 0, 0);
1811 // Move caret to last position on line extending selection to new caret position.
1812 void wxStyledTextCtrl::LineEndExtend() {
1813 SendMsg(2315, 0, 0);
1816 // Move caret to first position in document.
1817 void wxStyledTextCtrl::DocumentStart() {
1818 SendMsg(2316, 0, 0);
1821 // Move caret to first position in document extending selection to new caret position.
1822 void wxStyledTextCtrl::DocumentStartExtend() {
1823 SendMsg(2317, 0, 0);
1826 // Move caret to last position in document.
1827 void wxStyledTextCtrl::DocumentEnd() {
1828 SendMsg(2318, 0, 0);
1831 // Move caret to last position in document extending selection to new caret position.
1832 void wxStyledTextCtrl::DocumentEndExtend() {
1833 SendMsg(2319, 0, 0);
1836 // Move caret one page up.
1837 void wxStyledTextCtrl::PageUp() {
1838 SendMsg(2320, 0, 0);
1841 // Move caret one page up extending selection to new caret position.
1842 void wxStyledTextCtrl::PageUpExtend() {
1843 SendMsg(2321, 0, 0);
1846 // Move caret one page down.
1847 void wxStyledTextCtrl::PageDown() {
1848 SendMsg(2322, 0, 0);
1851 // Move caret one page down extending selection to new caret position.
1852 void wxStyledTextCtrl::PageDownExtend() {
1853 SendMsg(2323, 0, 0);
1856 // Switch from insert to overtype mode or the reverse.
1857 void wxStyledTextCtrl::EditToggleOvertype() {
1858 SendMsg(2324, 0, 0);
1861 // Cancel any modes such as call tip or auto-completion list display.
1862 void wxStyledTextCtrl::Cancel() {
1863 SendMsg(2325, 0, 0);
1866 // Delete the selection or if no selection, the character before the caret.
1867 void wxStyledTextCtrl::DeleteBack() {
1868 SendMsg(2326, 0, 0);
1871 // If selection is empty or all on one line replace the selection with a tab character.
1872 // If more than one line selected, indent the lines.
1873 void wxStyledTextCtrl::Tab() {
1874 SendMsg(2327, 0, 0);
1877 // Dedent the selected lines.
1878 void wxStyledTextCtrl::BackTab() {
1879 SendMsg(2328, 0, 0);
1882 // Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
1883 void wxStyledTextCtrl::NewLine() {
1884 SendMsg(2329, 0, 0);
1887 // Insert a Form Feed character.
1888 void wxStyledTextCtrl::FormFeed() {
1889 SendMsg(2330, 0, 0);
1892 // Move caret to before first visible character on line.
1893 // If already there move to first character on line.
1894 void wxStyledTextCtrl::VCHome() {
1895 SendMsg(2331, 0, 0);
1898 // Like VCHome but extending selection to new caret position.
1899 void wxStyledTextCtrl::VCHomeExtend() {
1900 SendMsg(2332, 0, 0);
1903 // Magnify the displayed text by increasing the sizes by 1 point.
1904 void wxStyledTextCtrl::ZoomIn() {
1905 SendMsg(2333, 0, 0);
1908 // Make the displayed text smaller by decreasing the sizes by 1 point.
1909 void wxStyledTextCtrl::ZoomOut() {
1910 SendMsg(2334, 0, 0);
1913 // Delete the word to the left of the caret.
1914 void wxStyledTextCtrl::DelWordLeft() {
1915 SendMsg(2335, 0, 0);
1918 // Delete the word to the right of the caret.
1919 void wxStyledTextCtrl::DelWordRight() {
1920 SendMsg(2336, 0, 0);
1923 // Cut the line containing the caret.
1924 void wxStyledTextCtrl::LineCut() {
1925 SendMsg(2337, 0, 0);
1928 // Delete the line containing the caret.
1929 void wxStyledTextCtrl::LineDelete() {
1930 SendMsg(2338, 0, 0);
1933 // Switch the current line with the previous.
1934 void wxStyledTextCtrl::LineTranspose() {
1935 SendMsg(2339, 0, 0);
1938 // Duplicate the current line.
1939 void wxStyledTextCtrl::LineDuplicate() {
1940 SendMsg(2404, 0, 0);
1943 // Transform the selection to lower case.
1944 void wxStyledTextCtrl::LowerCase() {
1945 SendMsg(2340, 0, 0);
1948 // Transform the selection to upper case.
1949 void wxStyledTextCtrl::UpperCase() {
1950 SendMsg(2341, 0, 0);
1953 // Scroll the document down, keeping the caret visible.
1954 void wxStyledTextCtrl::LineScrollDown() {
1955 SendMsg(2342, 0, 0);
1958 // Scroll the document up, keeping the caret visible.
1959 void wxStyledTextCtrl::LineScrollUp() {
1960 SendMsg(2343, 0, 0);
1963 // Delete the selection or if no selection, the character before the caret.
1964 // Will not delete the character before at the start of a line.
1965 void wxStyledTextCtrl::DeleteBackNotLine() {
1966 SendMsg(2344, 0, 0);
1969 // Move caret to first position on display line.
1970 void wxStyledTextCtrl::HomeDisplay() {
1971 SendMsg(2345, 0, 0);
1974 // Move caret to first position on display line extending selection to
1975 // new caret position.
1976 void wxStyledTextCtrl::HomeDisplayExtend() {
1977 SendMsg(2346, 0, 0);
1980 // Move caret to last position on display line.
1981 void wxStyledTextCtrl::LineEndDisplay() {
1982 SendMsg(2347, 0, 0);
1985 // Move caret to last position on display line extending selection to new
1987 void wxStyledTextCtrl::LineEndDisplayExtend() {
1988 SendMsg(2348, 0, 0);
1991 // These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
1992 // except they behave differently when word-wrap is enabled:
1993 // They go first to the start / end of the display line, like (Home|LineEnd)Display
1994 // The difference is that, the cursor is already at the point, it goes on to the start
1995 // or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
1996 void wxStyledTextCtrl::HomeWrap() {
1997 SendMsg(2349, 0, 0);
1999 void wxStyledTextCtrl::HomeWrapExtend() {
2000 SendMsg(2450, 0, 0);
2002 void wxStyledTextCtrl::LineEndWrap() {
2003 SendMsg(2451, 0, 0);
2005 void wxStyledTextCtrl::LineEndWrapExtend() {
2006 SendMsg(2452, 0, 0);
2008 void wxStyledTextCtrl::VCHomeWrap() {
2009 SendMsg(2453, 0, 0);
2011 void wxStyledTextCtrl::VCHomeWrapExtend() {
2012 SendMsg(2454, 0, 0);
2015 // Copy the line containing the caret.
2016 void wxStyledTextCtrl::LineCopy() {
2017 SendMsg(2455, 0, 0);
2020 // Move the caret inside current view if it's not there already.
2021 void wxStyledTextCtrl::MoveCaretInsideView() {
2022 SendMsg(2401, 0, 0);
2025 // How many characters are on a line, not including end of line characters?
2026 int wxStyledTextCtrl::LineLength(int line
) {
2027 return SendMsg(2350, line
, 0);
2030 // Highlight the characters at two positions.
2031 void wxStyledTextCtrl::BraceHighlight(int pos1
, int pos2
) {
2032 SendMsg(2351, pos1
, pos2
);
2035 // Highlight the character at a position indicating there is no matching brace.
2036 void wxStyledTextCtrl::BraceBadLight(int pos
) {
2037 SendMsg(2352, pos
, 0);
2040 // Find the position of a matching brace or INVALID_POSITION if no match.
2041 int wxStyledTextCtrl::BraceMatch(int pos
) {
2042 return SendMsg(2353, pos
, 0);
2045 // Are the end of line characters visible?
2046 bool wxStyledTextCtrl::GetViewEOL() {
2047 return SendMsg(2355, 0, 0) != 0;
2050 // Make the end of line characters visible or invisible.
2051 void wxStyledTextCtrl::SetViewEOL(bool visible
) {
2052 SendMsg(2356, visible
, 0);
2055 // Retrieve a pointer to the document object.
2056 void* wxStyledTextCtrl::GetDocPointer() {
2057 return (void*)SendMsg(2357);
2060 // Change the document object used.
2061 void wxStyledTextCtrl::SetDocPointer(void* docPointer
) {
2062 SendMsg(2358, 0, (long)docPointer
);
2065 // Set which document modification events are sent to the container.
2066 void wxStyledTextCtrl::SetModEventMask(int mask
) {
2067 SendMsg(2359, mask
, 0);
2070 // Retrieve the column number which text should be kept within.
2071 int wxStyledTextCtrl::GetEdgeColumn() {
2072 return SendMsg(2360, 0, 0);
2075 // Set the column number of the edge.
2076 // If text goes past the edge then it is highlighted.
2077 void wxStyledTextCtrl::SetEdgeColumn(int column
) {
2078 SendMsg(2361, column
, 0);
2081 // Retrieve the edge highlight mode.
2082 int wxStyledTextCtrl::GetEdgeMode() {
2083 return SendMsg(2362, 0, 0);
2086 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
2087 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
2088 void wxStyledTextCtrl::SetEdgeMode(int mode
) {
2089 SendMsg(2363, mode
, 0);
2092 // Retrieve the colour used in edge indication.
2093 wxColour
wxStyledTextCtrl::GetEdgeColour() {
2094 long c
= SendMsg(2364, 0, 0);
2095 return wxColourFromLong(c
);
2098 // Change the colour used in edge indication.
2099 void wxStyledTextCtrl::SetEdgeColour(const wxColour
& edgeColour
) {
2100 SendMsg(2365, wxColourAsLong(edgeColour
), 0);
2103 // Sets the current caret position to be the search anchor.
2104 void wxStyledTextCtrl::SearchAnchor() {
2105 SendMsg(2366, 0, 0);
2108 // Find some text starting at the search anchor.
2109 // Does not ensure the selection is visible.
2110 int wxStyledTextCtrl::SearchNext(int flags
, const wxString
& text
) {
2111 return SendMsg(2367, flags
, (long)(const char*)wx2stc(text
));
2114 // Find some text starting at the search anchor and moving backwards.
2115 // Does not ensure the selection is visible.
2116 int wxStyledTextCtrl::SearchPrev(int flags
, const wxString
& text
) {
2117 return SendMsg(2368, flags
, (long)(const char*)wx2stc(text
));
2120 // Retrieves the number of lines completely visible.
2121 int wxStyledTextCtrl::LinesOnScreen() {
2122 return SendMsg(2370, 0, 0);
2125 // Set whether a pop up menu is displayed automatically when the user presses
2126 // the wrong mouse button.
2127 void wxStyledTextCtrl::UsePopUp(bool allowPopUp
) {
2128 SendMsg(2371, allowPopUp
, 0);
2131 // Is the selection rectangular? The alternative is the more common stream selection.
2132 bool wxStyledTextCtrl::SelectionIsRectangle() {
2133 return SendMsg(2372, 0, 0) != 0;
2136 // Set the zoom level. This number of points is added to the size of all fonts.
2137 // It may be positive to magnify or negative to reduce.
2138 void wxStyledTextCtrl::SetZoom(int zoom
) {
2139 SendMsg(2373, zoom
, 0);
2142 // Retrieve the zoom level.
2143 int wxStyledTextCtrl::GetZoom() {
2144 return SendMsg(2374, 0, 0);
2147 // Create a new document object.
2148 // Starts with reference count of 1 and not selected into editor.
2149 void* wxStyledTextCtrl::CreateDocument() {
2150 return (void*)SendMsg(2375);
2153 // Extend life of document.
2154 void wxStyledTextCtrl::AddRefDocument(void* docPointer
) {
2155 SendMsg(2376, 0, (long)docPointer
);
2158 // Release a reference to the document, deleting document if it fades to black.
2159 void wxStyledTextCtrl::ReleaseDocument(void* docPointer
) {
2160 SendMsg(2377, 0, (long)docPointer
);
2163 // Get which document modification events are sent to the container.
2164 int wxStyledTextCtrl::GetModEventMask() {
2165 return SendMsg(2378, 0, 0);
2168 // Change internal focus flag.
2169 void wxStyledTextCtrl::SetSTCFocus(bool focus
) {
2170 SendMsg(2380, focus
, 0);
2173 // Get internal focus flag.
2174 bool wxStyledTextCtrl::GetSTCFocus() {
2175 return SendMsg(2381, 0, 0) != 0;
2178 // Change error status - 0 = OK.
2179 void wxStyledTextCtrl::SetStatus(int statusCode
) {
2180 SendMsg(2382, statusCode
, 0);
2183 // Get error status.
2184 int wxStyledTextCtrl::GetStatus() {
2185 return SendMsg(2383, 0, 0);
2188 // Set whether the mouse is captured when its button is pressed.
2189 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures
) {
2190 SendMsg(2384, captures
, 0);
2193 // Get whether mouse gets captured.
2194 bool wxStyledTextCtrl::GetMouseDownCaptures() {
2195 return SendMsg(2385, 0, 0) != 0;
2198 // Sets the cursor to one of the SC_CURSOR* values.
2199 void wxStyledTextCtrl::SetSTCCursor(int cursorType
) {
2200 SendMsg(2386, cursorType
, 0);
2204 int wxStyledTextCtrl::GetSTCCursor() {
2205 return SendMsg(2387, 0, 0);
2208 // Change the way control characters are displayed:
2209 // If symbol is < 32, keep the drawn way, else, use the given character.
2210 void wxStyledTextCtrl::SetControlCharSymbol(int symbol
) {
2211 SendMsg(2388, symbol
, 0);
2214 // Get the way control characters are displayed.
2215 int wxStyledTextCtrl::GetControlCharSymbol() {
2216 return SendMsg(2389, 0, 0);
2219 // Move to the previous change in capitalisation.
2220 void wxStyledTextCtrl::WordPartLeft() {
2221 SendMsg(2390, 0, 0);
2224 // Move to the previous change in capitalisation extending selection
2225 // to new caret position.
2226 void wxStyledTextCtrl::WordPartLeftExtend() {
2227 SendMsg(2391, 0, 0);
2230 // Move to the change next in capitalisation.
2231 void wxStyledTextCtrl::WordPartRight() {
2232 SendMsg(2392, 0, 0);
2235 // Move to the next change in capitalisation extending selection
2236 // to new caret position.
2237 void wxStyledTextCtrl::WordPartRightExtend() {
2238 SendMsg(2393, 0, 0);
2241 // Set the way the display area is determined when a particular line
2242 // is to be moved to by Find, FindNext, GotoLine, etc.
2243 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy
, int visibleSlop
) {
2244 SendMsg(2394, visiblePolicy
, visibleSlop
);
2247 // Delete back from the current position to the start of the line.
2248 void wxStyledTextCtrl::DelLineLeft() {
2249 SendMsg(2395, 0, 0);
2252 // Delete forwards from the current position to the end of the line.
2253 void wxStyledTextCtrl::DelLineRight() {
2254 SendMsg(2396, 0, 0);
2257 // Get and Set the xOffset (ie, horizonal scroll position).
2258 void wxStyledTextCtrl::SetXOffset(int newOffset
) {
2259 SendMsg(2397, newOffset
, 0);
2261 int wxStyledTextCtrl::GetXOffset() {
2262 return SendMsg(2398, 0, 0);
2265 // Set the last x chosen value to be the caret x position.
2266 void wxStyledTextCtrl::ChooseCaretX() {
2267 SendMsg(2399, 0, 0);
2270 // Set the way the caret is kept visible when going sideway.
2271 // The exclusion zone is given in pixels.
2272 void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy
, int caretSlop
) {
2273 SendMsg(2402, caretPolicy
, caretSlop
);
2276 // Set the way the line the caret is on is kept visible.
2277 // The exclusion zone is given in lines.
2278 void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy
, int caretSlop
) {
2279 SendMsg(2403, caretPolicy
, caretSlop
);
2282 // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
2283 void wxStyledTextCtrl::SetPrintWrapMode(int mode
) {
2284 SendMsg(2406, mode
, 0);
2287 // Is printing line wrapped?
2288 int wxStyledTextCtrl::GetPrintWrapMode() {
2289 return SendMsg(2407, 0, 0);
2292 // Set a fore colour for active hotspots.
2293 void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting
, const wxColour
& fore
) {
2294 SendMsg(2410, useSetting
, wxColourAsLong(fore
));
2297 // Set a back colour for active hotspots.
2298 void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting
, const wxColour
& back
) {
2299 SendMsg(2411, useSetting
, wxColourAsLong(back
));
2302 // Enable / Disable underlining active hotspots.
2303 void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline
) {
2304 SendMsg(2412, underline
, 0);
2307 // Limit hotspots to single line so hotspots on two lines don't merge.
2308 void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine
) {
2309 SendMsg(2421, singleLine
, 0);
2312 // Move caret between paragraphs (delimited by empty lines).
2313 void wxStyledTextCtrl::ParaDown() {
2314 SendMsg(2413, 0, 0);
2316 void wxStyledTextCtrl::ParaDownExtend() {
2317 SendMsg(2414, 0, 0);
2319 void wxStyledTextCtrl::ParaUp() {
2320 SendMsg(2415, 0, 0);
2322 void wxStyledTextCtrl::ParaUpExtend() {
2323 SendMsg(2416, 0, 0);
2326 // Given a valid document position, return the previous position taking code
2327 // page into account. Returns 0 if passed 0.
2328 int wxStyledTextCtrl::PositionBefore(int pos
) {
2329 return SendMsg(2417, pos
, 0);
2332 // Given a valid document position, return the next position taking code
2333 // page into account. Maximum value returned is the last position in the document.
2334 int wxStyledTextCtrl::PositionAfter(int pos
) {
2335 return SendMsg(2418, pos
, 0);
2338 // Copy a range of text to the clipboard. Positions are clipped into the document.
2339 void wxStyledTextCtrl::CopyRange(int start
, int end
) {
2340 SendMsg(2419, start
, end
);
2343 // Copy argument text to the clipboard.
2344 void wxStyledTextCtrl::CopyText(int length
, const wxString
& text
) {
2345 SendMsg(2420, length
, (long)(const char*)wx2stc(text
));
2348 // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or
2349 // by lines (SC_SEL_LINES).
2350 void wxStyledTextCtrl::SetSelectionMode(int mode
) {
2351 SendMsg(2422, mode
, 0);
2354 // Get the mode of the current selection.
2355 int wxStyledTextCtrl::GetSelectionMode() {
2356 return SendMsg(2423, 0, 0);
2359 // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
2360 int wxStyledTextCtrl::GetLineSelStartPosition(int line
) {
2361 return SendMsg(2424, line
, 0);
2364 // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
2365 int wxStyledTextCtrl::GetLineSelEndPosition(int line
) {
2366 return SendMsg(2425, line
, 0);
2369 // Move caret down one line, extending rectangular selection to new caret position.
2370 void wxStyledTextCtrl::LineDownRectExtend() {
2371 SendMsg(2426, 0, 0);
2374 // Move caret up one line, extending rectangular selection to new caret position.
2375 void wxStyledTextCtrl::LineUpRectExtend() {
2376 SendMsg(2427, 0, 0);
2379 // Move caret left one character, extending rectangular selection to new caret position.
2380 void wxStyledTextCtrl::CharLeftRectExtend() {
2381 SendMsg(2428, 0, 0);
2384 // Move caret right one character, extending rectangular selection to new caret position.
2385 void wxStyledTextCtrl::CharRightRectExtend() {
2386 SendMsg(2429, 0, 0);
2389 // Move caret to first position on line, extending rectangular selection to new caret position.
2390 void wxStyledTextCtrl::HomeRectExtend() {
2391 SendMsg(2430, 0, 0);
2394 // Move caret to before first visible character on line.
2395 // If already there move to first character on line.
2396 // In either case, extend rectangular selection to new caret position.
2397 void wxStyledTextCtrl::VCHomeRectExtend() {
2398 SendMsg(2431, 0, 0);
2401 // Move caret to last position on line, extending rectangular selection to new caret position.
2402 void wxStyledTextCtrl::LineEndRectExtend() {
2403 SendMsg(2432, 0, 0);
2406 // Move caret one page up, extending rectangular selection to new caret position.
2407 void wxStyledTextCtrl::PageUpRectExtend() {
2408 SendMsg(2433, 0, 0);
2411 // Move caret one page down, extending rectangular selection to new caret position.
2412 void wxStyledTextCtrl::PageDownRectExtend() {
2413 SendMsg(2434, 0, 0);
2416 // Move caret to top of page, or one page up if already at top of page.
2417 void wxStyledTextCtrl::StutteredPageUp() {
2418 SendMsg(2435, 0, 0);
2421 // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
2422 void wxStyledTextCtrl::StutteredPageUpExtend() {
2423 SendMsg(2436, 0, 0);
2426 // Move caret to bottom of page, or one page down if already at bottom of page.
2427 void wxStyledTextCtrl::StutteredPageDown() {
2428 SendMsg(2437, 0, 0);
2431 // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
2432 void wxStyledTextCtrl::StutteredPageDownExtend() {
2433 SendMsg(2438, 0, 0);
2436 // Move caret left one word, position cursor at end of word.
2437 void wxStyledTextCtrl::WordLeftEnd() {
2438 SendMsg(2439, 0, 0);
2441 // Move caret left one word, position cursor at end of word, extending selection to new caret position.
2442 void wxStyledTextCtrl::WordLeftEndExtend() {
2443 SendMsg(2440, 0, 0);
2446 // Move caret right one word, position cursor at end of word.
2447 void wxStyledTextCtrl::WordRightEnd() {
2448 SendMsg(2441, 0, 0);
2451 // Move caret right one word, position cursor at end of word, extending selection to new caret position.
2452 void wxStyledTextCtrl::WordRightEndExtend() {
2453 SendMsg(2442, 0, 0);
2456 // Set the set of characters making up whitespace for when moving or selecting by word.
2457 // Should be called after SetWordChars.
2458 void wxStyledTextCtrl::SetWhitespaceChars(const wxString
& characters
) {
2459 SendMsg(2443, 0, (long)(const char*)wx2stc(characters
));
2462 // Reset the set of characters for whitespace and word characters to the defaults.
2463 void wxStyledTextCtrl::SetCharsDefault() {
2464 SendMsg(2444, 0, 0);
2467 // Get currently selected item position in the auto-completion list
2468 int wxStyledTextCtrl::AutoCompGetCurrent() {
2469 return SendMsg(2445, 0, 0);
2472 // Enlarge the document to a particular size of text bytes.
2473 void wxStyledTextCtrl::Allocate(int bytes
) {
2474 SendMsg(2446, bytes
, 0);
2477 // Find the position of a column on a line taking into account tabs and
2478 // multi-byte characters. If beyond end of line, return line end position.
2479 int wxStyledTextCtrl::FindColumn(int line
, int column
) {
2480 return SendMsg(2456, line
, column
);
2483 // Can the caret preferred x position only be changed by explicit movement commands?
2484 bool wxStyledTextCtrl::GetCaretSticky() {
2485 return SendMsg(2457, 0, 0) != 0;
2488 // Stop the caret preferred x position changing when the user types.
2489 void wxStyledTextCtrl::SetCaretSticky(bool useCaretStickyBehaviour
) {
2490 SendMsg(2458, useCaretStickyBehaviour
, 0);
2493 // Switch between sticky and non-sticky: meant to be bound to a key.
2494 void wxStyledTextCtrl::ToggleCaretSticky() {
2495 SendMsg(2459, 0, 0);
2498 // Enable/Disable convert-on-paste for line endings
2499 void wxStyledTextCtrl::SetPasteConvertEndings(bool convert
) {
2500 SendMsg(2467, convert
, 0);
2503 // Get convert-on-paste setting
2504 bool wxStyledTextCtrl::GetPasteConvertEndings() {
2505 return SendMsg(2468, 0, 0) != 0;
2508 // Duplicate the selection. If selection empty duplicate the line containing the caret.
2509 void wxStyledTextCtrl::SelectionDuplicate() {
2510 SendMsg(2469, 0, 0);
2513 // Set background alpha of the caret line.
2514 void wxStyledTextCtrl::SetCaretLineBackAlpha(int alpha
) {
2515 SendMsg(2470, alpha
, 0);
2518 // Get the background alpha of the caret line.
2519 int wxStyledTextCtrl::GetCaretLineBackAlpha() {
2520 return SendMsg(2471, 0, 0);
2523 // Start notifying the container of all key presses and commands.
2524 void wxStyledTextCtrl::StartRecord() {
2525 SendMsg(3001, 0, 0);
2528 // Stop notifying the container of all key presses and commands.
2529 void wxStyledTextCtrl::StopRecord() {
2530 SendMsg(3002, 0, 0);
2533 // Set the lexing language of the document.
2534 void wxStyledTextCtrl::SetLexer(int lexer
) {
2535 SendMsg(4001, lexer
, 0);
2538 // Retrieve the lexing language of the document.
2539 int wxStyledTextCtrl::GetLexer() {
2540 return SendMsg(4002, 0, 0);
2543 // Colourise a segment of the document using the current lexing language.
2544 void wxStyledTextCtrl::Colourise(int start
, int end
) {
2545 SendMsg(4003, start
, end
);
2548 // Set up a value that may be used by a lexer for some optional feature.
2549 void wxStyledTextCtrl::SetProperty(const wxString
& key
, const wxString
& value
) {
2550 SendMsg(4004, (long)(const char*)wx2stc(key
), (long)(const char*)wx2stc(value
));
2553 // Set up the key words used by the lexer.
2554 void wxStyledTextCtrl::SetKeyWords(int keywordSet
, const wxString
& keyWords
) {
2555 SendMsg(4005, keywordSet
, (long)(const char*)wx2stc(keyWords
));
2558 // Set the lexing language of the document based on string name.
2559 void wxStyledTextCtrl::SetLexerLanguage(const wxString
& language
) {
2560 SendMsg(4006, 0, (long)(const char*)wx2stc(language
));
2563 // Retrieve a 'property' value previously set with SetProperty.
2564 wxString
wxStyledTextCtrl::GetProperty(const wxString
& key
) {
2565 int len
= SendMsg(SCI_GETPROPERTY
, (long)(const char*)wx2stc(key
), 0);
2566 if (!len
) return wxEmptyString
;
2568 wxMemoryBuffer
mbuf(len
+1);
2569 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
2570 SendMsg(4008, (long)(const char*)wx2stc(key
), (long)buf
);
2571 mbuf
.UngetWriteBuf(len
);
2576 // Retrieve a 'property' value previously set with SetProperty,
2577 // with '$()' variable replacement on returned buffer.
2578 wxString
wxStyledTextCtrl::GetPropertyExpanded(const wxString
& key
) {
2579 int len
= SendMsg(SCI_GETPROPERTYEXPANDED
, (long)(const char*)wx2stc(key
), 0);
2580 if (!len
) return wxEmptyString
;
2582 wxMemoryBuffer
mbuf(len
+1);
2583 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
2584 SendMsg(4009, (long)(const char*)wx2stc(key
), (long)buf
);
2585 mbuf
.UngetWriteBuf(len
);
2590 // Retrieve a 'property' value previously set with SetProperty,
2591 // interpreted as an int AFTER any '$()' variable replacement.
2592 int wxStyledTextCtrl::GetPropertyInt(const wxString
& key
) {
2593 return SendMsg(4010, (long)(const char*)wx2stc(key
), 0);
2596 // Retrieve the number of bits the current lexer needs for styling.
2597 int wxStyledTextCtrl::GetStyleBitsNeeded() {
2598 return SendMsg(4011, 0, 0);
2601 // END of generated section
2602 //----------------------------------------------------------------------
2605 // Returns the line number of the line with the caret.
2606 int wxStyledTextCtrl::GetCurrentLine() {
2607 int line
= LineFromPosition(GetCurrentPos());
2612 // Extract style settings from a spec-string which is composed of one or
2613 // more of the following comma separated elements:
2615 // bold turns on bold
2616 // italic turns on italics
2617 // fore:[name or #RRGGBB] sets the foreground colour
2618 // back:[name or #RRGGBB] sets the background colour
2619 // face:[facename] sets the font face name to use
2620 // size:[num] sets the font size in points
2621 // eol turns on eol filling
2622 // underline turns on underlining
2624 void wxStyledTextCtrl::StyleSetSpec(int styleNum
, const wxString
& spec
) {
2626 wxStringTokenizer
tkz(spec
, wxT(","));
2627 while (tkz
.HasMoreTokens()) {
2628 wxString token
= tkz
.GetNextToken();
2630 wxString option
= token
.BeforeFirst(':');
2631 wxString val
= token
.AfterFirst(':');
2633 if (option
== wxT("bold"))
2634 StyleSetBold(styleNum
, true);
2636 else if (option
== wxT("italic"))
2637 StyleSetItalic(styleNum
, true);
2639 else if (option
== wxT("underline"))
2640 StyleSetUnderline(styleNum
, true);
2642 else if (option
== wxT("eol"))
2643 StyleSetEOLFilled(styleNum
, true);
2645 else if (option
== wxT("size")) {
2647 if (val
.ToLong(&points
))
2648 StyleSetSize(styleNum
, points
);
2651 else if (option
== wxT("face"))
2652 StyleSetFaceName(styleNum
, val
);
2654 else if (option
== wxT("fore"))
2655 StyleSetForeground(styleNum
, wxColourFromSpec(val
));
2657 else if (option
== wxT("back"))
2658 StyleSetBackground(styleNum
, wxColourFromSpec(val
));
2663 // Set style size, face, bold, italic, and underline attributes from
2664 // a wxFont's attributes.
2665 void wxStyledTextCtrl::StyleSetFont(int styleNum
, wxFont
& font
) {
2667 // Ensure that the native font is initialized
2669 GetTextExtent(wxT("X"), &x
, &y
, NULL
, NULL
, &font
);
2671 int size
= font
.GetPointSize();
2672 wxString faceName
= font
.GetFaceName();
2673 bool bold
= font
.GetWeight() == wxBOLD
;
2674 bool italic
= font
.GetStyle() != wxNORMAL
;
2675 bool under
= font
.GetUnderlined();
2676 wxFontEncoding encoding
= font
.GetEncoding();
2678 StyleSetFontAttr(styleNum
, size
, faceName
, bold
, italic
, under
, encoding
);
2681 // Set all font style attributes at once.
2682 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum
, int size
,
2683 const wxString
& faceName
,
2684 bool bold
, bool italic
,
2686 wxFontEncoding encoding
) {
2687 StyleSetSize(styleNum
, size
);
2688 StyleSetFaceName(styleNum
, faceName
);
2689 StyleSetBold(styleNum
, bold
);
2690 StyleSetItalic(styleNum
, italic
);
2691 StyleSetUnderline(styleNum
, underline
);
2692 StyleSetFontEncoding(styleNum
, encoding
);
2696 // Set the character set of the font in a style. Converts the Scintilla
2697 // character set values to a wxFontEncoding.
2698 void wxStyledTextCtrl::StyleSetCharacterSet(int style
, int characterSet
)
2700 wxFontEncoding encoding
;
2702 // Translate the Scintilla characterSet to a wxFontEncoding
2703 switch (characterSet
) {
2705 case wxSTC_CHARSET_ANSI
:
2706 case wxSTC_CHARSET_DEFAULT
:
2707 encoding
= wxFONTENCODING_DEFAULT
;
2710 case wxSTC_CHARSET_BALTIC
:
2711 encoding
= wxFONTENCODING_ISO8859_13
;
2714 case wxSTC_CHARSET_CHINESEBIG5
:
2715 encoding
= wxFONTENCODING_CP950
;
2718 case wxSTC_CHARSET_EASTEUROPE
:
2719 encoding
= wxFONTENCODING_ISO8859_2
;
2722 case wxSTC_CHARSET_GB2312
:
2723 encoding
= wxFONTENCODING_CP936
;
2726 case wxSTC_CHARSET_GREEK
:
2727 encoding
= wxFONTENCODING_ISO8859_7
;
2730 case wxSTC_CHARSET_HANGUL
:
2731 encoding
= wxFONTENCODING_CP949
;
2734 case wxSTC_CHARSET_MAC
:
2735 encoding
= wxFONTENCODING_DEFAULT
;
2738 case wxSTC_CHARSET_OEM
:
2739 encoding
= wxFONTENCODING_DEFAULT
;
2742 case wxSTC_CHARSET_RUSSIAN
:
2743 encoding
= wxFONTENCODING_KOI8
;
2746 case wxSTC_CHARSET_SHIFTJIS
:
2747 encoding
= wxFONTENCODING_CP932
;
2750 case wxSTC_CHARSET_SYMBOL
:
2751 encoding
= wxFONTENCODING_DEFAULT
;
2754 case wxSTC_CHARSET_TURKISH
:
2755 encoding
= wxFONTENCODING_ISO8859_9
;
2758 case wxSTC_CHARSET_JOHAB
:
2759 encoding
= wxFONTENCODING_DEFAULT
;
2762 case wxSTC_CHARSET_HEBREW
:
2763 encoding
= wxFONTENCODING_ISO8859_8
;
2766 case wxSTC_CHARSET_ARABIC
:
2767 encoding
= wxFONTENCODING_ISO8859_6
;
2770 case wxSTC_CHARSET_VIETNAMESE
:
2771 encoding
= wxFONTENCODING_DEFAULT
;
2774 case wxSTC_CHARSET_THAI
:
2775 encoding
= wxFONTENCODING_ISO8859_11
;
2778 case wxSTC_CHARSET_CYRILLIC
:
2779 encoding
= wxFONTENCODING_ISO8859_5
;
2782 case wxSTC_CHARSET_8859_15
:
2783 encoding
= wxFONTENCODING_ISO8859_15
;;
2787 // We just have Scintilla track the wxFontEncoding for us. It gets used
2788 // in Font::Create in PlatWX.cpp. We add one to the value so that the
2789 // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
2790 // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
2791 // to wxFONENCODING_DEFAULT in Font::Create.
2792 SendMsg(SCI_STYLESETCHARACTERSET
, style
, encoding
+1);
2796 // Set the font encoding to be used by a style.
2797 void wxStyledTextCtrl::StyleSetFontEncoding(int style
, wxFontEncoding encoding
)
2799 SendMsg(SCI_STYLESETCHARACTERSET
, style
, encoding
+1);
2803 // Perform one of the operations defined by the wxSTC_CMD_* constants.
2804 void wxStyledTextCtrl::CmdKeyExecute(int cmd
) {
2809 // Set the left and right margin in the edit area, measured in pixels.
2810 void wxStyledTextCtrl::SetMargins(int left
, int right
) {
2811 SetMarginLeft(left
);
2812 SetMarginRight(right
);
2816 // Retrieve the start and end positions of the current selection.
2817 void wxStyledTextCtrl::GetSelection(int* startPos
, int* endPos
) {
2818 if (startPos
!= NULL
)
2819 *startPos
= SendMsg(SCI_GETSELECTIONSTART
);
2821 *endPos
= SendMsg(SCI_GETSELECTIONEND
);
2825 // Retrieve the point in the window where a position is displayed.
2826 wxPoint
wxStyledTextCtrl::PointFromPosition(int pos
) {
2827 int x
= SendMsg(SCI_POINTXFROMPOSITION
, 0, pos
);
2828 int y
= SendMsg(SCI_POINTYFROMPOSITION
, 0, pos
);
2829 return wxPoint(x
, y
);
2832 // Scroll enough to make the given line visible
2833 void wxStyledTextCtrl::ScrollToLine(int line
) {
2834 m_swx
->DoScrollToLine(line
);
2838 // Scroll enough to make the given column visible
2839 void wxStyledTextCtrl::ScrollToColumn(int column
) {
2840 m_swx
->DoScrollToColumn(column
);
2844 bool wxStyledTextCtrl::SaveFile(const wxString
& filename
)
2846 wxFile
file(filename
, wxFile::write
);
2848 if (!file
.IsOpened())
2851 bool success
= file
.Write(GetText(), *wxConvCurrent
);
2859 bool wxStyledTextCtrl::LoadFile(const wxString
& filename
)
2861 bool success
= false;
2862 wxFile
file(filename
, wxFile::read
);
2864 if (file
.IsOpened())
2867 // get the file size (assume it is not huge file...)
2868 ssize_t len
= (ssize_t
)file
.Length();
2873 wxMemoryBuffer
buffer(len
+1);
2874 success
= (file
.Read(buffer
.GetData(), len
) == len
);
2876 ((char*)buffer
.GetData())[len
] = 0;
2877 contents
= wxString(buffer
, *wxConvCurrent
, len
);
2881 success
= (file
.Read(wxStringBuffer(buffer
, len
), len
) == len
);
2888 success
= true; // empty file is ok
2890 success
= false; // len == wxInvalidOffset
2905 #if wxUSE_DRAG_AND_DROP
2906 wxDragResult
wxStyledTextCtrl::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
2907 return m_swx
->DoDragOver(x
, y
, def
);
2911 bool wxStyledTextCtrl::DoDropText(long x
, long y
, const wxString
& data
) {
2912 return m_swx
->DoDropText(x
, y
, data
);
2917 void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA
) {
2918 m_swx
->SetUseAntiAliasing(useAA
);
2921 bool wxStyledTextCtrl::GetUseAntiAliasing() {
2922 return m_swx
->GetUseAntiAliasing();
2929 void wxStyledTextCtrl::AddTextRaw(const char* text
)
2931 SendMsg(SCI_ADDTEXT
, strlen(text
), (long)text
);
2934 void wxStyledTextCtrl::InsertTextRaw(int pos
, const char* text
)
2936 SendMsg(SCI_INSERTTEXT
, pos
, (long)text
);
2939 wxCharBuffer
wxStyledTextCtrl::GetCurLineRaw(int* linePos
)
2941 int len
= LineLength(GetCurrentLine());
2943 if (linePos
) *linePos
= 0;
2948 wxCharBuffer
buf(len
);
2949 int pos
= SendMsg(SCI_GETCURLINE
, len
, (long)buf
.data());
2950 if (linePos
) *linePos
= pos
;
2954 wxCharBuffer
wxStyledTextCtrl::GetLineRaw(int line
)
2956 int len
= LineLength(line
);
2962 wxCharBuffer
buf(len
);
2963 SendMsg(SCI_GETLINE
, line
, (long)buf
.data());
2967 wxCharBuffer
wxStyledTextCtrl::GetSelectedTextRaw()
2972 GetSelection(&start
, &end
);
2973 int len
= end
- start
;
2979 wxCharBuffer
buf(len
);
2980 SendMsg(SCI_GETSELTEXT
, 0, (long)buf
.data());
2984 wxCharBuffer
wxStyledTextCtrl::GetTextRangeRaw(int startPos
, int endPos
)
2986 if (endPos
< startPos
) {
2987 int temp
= startPos
;
2991 int len
= endPos
- startPos
;
2997 wxCharBuffer
buf(len
);
2999 tr
.lpstrText
= buf
.data();
3000 tr
.chrg
.cpMin
= startPos
;
3001 tr
.chrg
.cpMax
= endPos
;
3002 SendMsg(SCI_GETTEXTRANGE
, 0, (long)&tr
);
3006 void wxStyledTextCtrl::SetTextRaw(const char* text
)
3008 SendMsg(SCI_SETTEXT
, 0, (long)text
);
3011 wxCharBuffer
wxStyledTextCtrl::GetTextRaw()
3013 int len
= GetTextLength();
3014 wxCharBuffer
buf(len
);
3015 SendMsg(SCI_GETTEXT
, len
, (long)buf
.data());
3019 void wxStyledTextCtrl::AppendTextRaw(const char* text
)
3021 SendMsg(SCI_APPENDTEXT
, strlen(text
), (long)text
);
3028 //----------------------------------------------------------------------
3031 void wxStyledTextCtrl::OnPaint(wxPaintEvent
& WXUNUSED(evt
)) {
3033 m_swx
->DoPaint(&dc
, GetUpdateRegion().GetBox());
3036 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent
& evt
) {
3037 if (evt
.GetOrientation() == wxHORIZONTAL
)
3038 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
3040 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
3043 void wxStyledTextCtrl::OnScroll(wxScrollEvent
& evt
) {
3044 wxScrollBar
* sb
= wxDynamicCast(evt
.GetEventObject(), wxScrollBar
);
3046 if (sb
->IsVertical())
3047 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
3049 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
3053 void wxStyledTextCtrl::OnSize(wxSizeEvent
& WXUNUSED(evt
)) {
3055 wxSize sz
= GetClientSize();
3056 m_swx
->DoSize(sz
.x
, sz
.y
);
3060 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent
& evt
) {
3062 wxPoint pt
= evt
.GetPosition();
3063 m_swx
->DoLeftButtonDown(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
3064 evt
.ShiftDown(), evt
.ControlDown(), evt
.AltDown());
3067 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent
& evt
) {
3068 wxPoint pt
= evt
.GetPosition();
3069 m_swx
->DoLeftButtonMove(Point(pt
.x
, pt
.y
));
3072 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent
& evt
) {
3073 wxPoint pt
= evt
.GetPosition();
3074 m_swx
->DoLeftButtonUp(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
3079 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent
& evt
) {
3080 wxPoint pt
= evt
.GetPosition();
3081 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
3085 void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent
& evt
) {
3086 wxPoint pt
= evt
.GetPosition();
3087 m_swx
->DoMiddleButtonUp(Point(pt
.x
, pt
.y
));
3090 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent
& evt
) {
3091 wxPoint pt
= evt
.GetPosition();
3092 ScreenToClient(&pt
.x
, &pt
.y
);
3094 Show context menu at event point if it's within the window,
3095 or at caret location if not
3097 wxHitTest ht
= this->HitTest(pt
);
3098 if (ht
!= wxHT_WINDOW_INSIDE
) {
3099 pt
= this->PointFromPosition(this->GetCurrentPos());
3101 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
3105 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent
& evt
) {
3106 m_swx
->DoMouseWheel(evt
.GetWheelRotation(),
3107 evt
.GetWheelDelta(),
3108 evt
.GetLinesPerAction(),
3110 evt
.IsPageScroll());
3114 void wxStyledTextCtrl::OnChar(wxKeyEvent
& evt
) {
3115 // On (some?) non-US PC keyboards the AltGr key is required to enter some
3116 // common characters. It comes to us as both Alt and Ctrl down so we need
3117 // to let the char through in that case, otherwise if only ctrl or only
3118 // alt let's skip it.
3119 bool ctrl
= evt
.ControlDown();
3121 // On the Mac the Alt key is just a modifier key (like Shift) so we need
3122 // to allow the char events to be processed when Alt is pressed.
3123 // TODO: Should we check MetaDown instead in this case?
3126 bool alt
= evt
.AltDown();
3128 bool skip
= ((ctrl
|| alt
) && ! (ctrl
&& alt
));
3131 // apparently if we don't do this, Unicode keys pressed after non-char
3132 // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989)
3133 if (m_lastKeyDownConsumed
&& evt
.GetUnicodeKey() > 255)
3134 m_lastKeyDownConsumed
= false;
3137 if (!m_lastKeyDownConsumed
&& !skip
) {
3139 int key
= evt
.GetUnicodeKey();
3142 // if the unicode key code is not really a unicode character (it may
3143 // be a function key or etc., the platforms appear to always give us a
3144 // small value in this case) then fallback to the ascii key code but
3145 // don't do anything for function keys or etc.
3147 key
= evt
.GetKeyCode();
3148 keyOk
= (key
<= 127);
3151 m_swx
->DoAddChar(key
);
3155 int key
= evt
.GetKeyCode();
3156 if (key
<= WXK_START
|| key
> WXK_COMMAND
) {
3157 m_swx
->DoAddChar(key
);
3167 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent
& evt
) {
3168 int processed
= m_swx
->DoKeyDown(evt
, &m_lastKeyDownConsumed
);
3169 if (!processed
&& !m_lastKeyDownConsumed
)
3174 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent
& evt
) {
3175 m_swx
->DoLoseFocus();
3180 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent
& evt
) {
3181 m_swx
->DoGainFocus();
3186 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent
& WXUNUSED(evt
)) {
3187 m_swx
->DoSysColourChange();
3191 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent
& WXUNUSED(evt
)) {
3192 // do nothing to help avoid flashing
3197 void wxStyledTextCtrl::OnMenu(wxCommandEvent
& evt
) {
3198 m_swx
->DoCommand(evt
.GetId());
3202 void wxStyledTextCtrl::OnListBox(wxCommandEvent
& WXUNUSED(evt
)) {
3203 m_swx
->DoOnListBox();
3207 void wxStyledTextCtrl::OnIdle(wxIdleEvent
& evt
) {
3208 m_swx
->DoOnIdle(evt
);
3212 wxSize
wxStyledTextCtrl::DoGetBestSize() const
3214 // What would be the best size for a wxSTC?
3215 // Just give a reasonable minimum until something else can be figured out.
3216 return wxSize(200,100);
3220 //----------------------------------------------------------------------
3221 // Turn notifications from Scintilla into events
3224 void wxStyledTextCtrl::NotifyChange() {
3225 wxStyledTextEvent
evt(wxEVT_STC_CHANGE
, GetId());
3226 evt
.SetEventObject(this);
3227 GetEventHandler()->ProcessEvent(evt
);
3231 static void SetEventText(wxStyledTextEvent
& evt
, const char* text
,
3235 evt
.SetText(stc2wx(text
, length
));
3239 void wxStyledTextCtrl::NotifyParent(SCNotification
* _scn
) {
3240 SCNotification
& scn
= *_scn
;
3241 wxStyledTextEvent
evt(0, GetId());
3243 evt
.SetEventObject(this);
3244 evt
.SetPosition(scn
.position
);
3246 evt
.SetModifiers(scn
.modifiers
);
3248 switch (scn
.nmhdr
.code
) {
3249 case SCN_STYLENEEDED
:
3250 evt
.SetEventType(wxEVT_STC_STYLENEEDED
);
3254 evt
.SetEventType(wxEVT_STC_CHARADDED
);
3257 case SCN_SAVEPOINTREACHED
:
3258 evt
.SetEventType(wxEVT_STC_SAVEPOINTREACHED
);
3261 case SCN_SAVEPOINTLEFT
:
3262 evt
.SetEventType(wxEVT_STC_SAVEPOINTLEFT
);
3265 case SCN_MODIFYATTEMPTRO
:
3266 evt
.SetEventType(wxEVT_STC_ROMODIFYATTEMPT
);
3270 evt
.SetEventType(wxEVT_STC_KEY
);
3273 case SCN_DOUBLECLICK
:
3274 evt
.SetEventType(wxEVT_STC_DOUBLECLICK
);
3278 evt
.SetEventType(wxEVT_STC_UPDATEUI
);
3282 evt
.SetEventType(wxEVT_STC_MODIFIED
);
3283 evt
.SetModificationType(scn
.modificationType
);
3284 SetEventText(evt
, scn
.text
, scn
.length
);
3285 evt
.SetLength(scn
.length
);
3286 evt
.SetLinesAdded(scn
.linesAdded
);
3287 evt
.SetLine(scn
.line
);
3288 evt
.SetFoldLevelNow(scn
.foldLevelNow
);
3289 evt
.SetFoldLevelPrev(scn
.foldLevelPrev
);
3292 case SCN_MACRORECORD
:
3293 evt
.SetEventType(wxEVT_STC_MACRORECORD
);
3294 evt
.SetMessage(scn
.message
);
3295 evt
.SetWParam(scn
.wParam
);
3296 evt
.SetLParam(scn
.lParam
);
3299 case SCN_MARGINCLICK
:
3300 evt
.SetEventType(wxEVT_STC_MARGINCLICK
);
3301 evt
.SetMargin(scn
.margin
);
3305 evt
.SetEventType(wxEVT_STC_NEEDSHOWN
);
3306 evt
.SetLength(scn
.length
);
3310 evt
.SetEventType(wxEVT_STC_PAINTED
);
3313 case SCN_AUTOCSELECTION
:
3314 evt
.SetEventType(wxEVT_STC_AUTOCOMP_SELECTION
);
3315 evt
.SetListType(scn
.listType
);
3316 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
3317 evt
.SetPosition(scn
.lParam
);
3320 case SCN_USERLISTSELECTION
:
3321 evt
.SetEventType(wxEVT_STC_USERLISTSELECTION
);
3322 evt
.SetListType(scn
.listType
);
3323 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
3324 evt
.SetPosition(scn
.lParam
);
3327 case SCN_URIDROPPED
:
3328 evt
.SetEventType(wxEVT_STC_URIDROPPED
);
3329 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
3332 case SCN_DWELLSTART
:
3333 evt
.SetEventType(wxEVT_STC_DWELLSTART
);
3339 evt
.SetEventType(wxEVT_STC_DWELLEND
);
3345 evt
.SetEventType(wxEVT_STC_ZOOM
);
3348 case SCN_HOTSPOTCLICK
:
3349 evt
.SetEventType(wxEVT_STC_HOTSPOT_CLICK
);
3352 case SCN_HOTSPOTDOUBLECLICK
:
3353 evt
.SetEventType(wxEVT_STC_HOTSPOT_DCLICK
);
3356 case SCN_CALLTIPCLICK
:
3357 evt
.SetEventType(wxEVT_STC_CALLTIP_CLICK
);
3364 GetEventHandler()->ProcessEvent(evt
);
3368 //----------------------------------------------------------------------
3369 //----------------------------------------------------------------------
3370 //----------------------------------------------------------------------
3372 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType
, int id
)
3373 : wxCommandEvent(commandType
, id
)
3378 m_modificationType
= 0;
3383 m_foldLevelPrev
= 0;
3391 m_dragAllowMove
= false;
3392 #if wxUSE_DRAG_AND_DROP
3393 m_dragResult
= wxDragNone
;
3397 bool wxStyledTextEvent::GetShift() const { return (m_modifiers
& SCI_SHIFT
) != 0; }
3398 bool wxStyledTextEvent::GetControl() const { return (m_modifiers
& SCI_CTRL
) != 0; }
3399 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers
& SCI_ALT
) != 0; }
3402 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent
& event
):
3403 wxCommandEvent(event
)
3405 m_position
= event
.m_position
;
3406 m_key
= event
.m_key
;
3407 m_modifiers
= event
.m_modifiers
;
3408 m_modificationType
= event
.m_modificationType
;
3409 m_text
= event
.m_text
;
3410 m_length
= event
.m_length
;
3411 m_linesAdded
= event
.m_linesAdded
;
3412 m_line
= event
.m_line
;
3413 m_foldLevelNow
= event
.m_foldLevelNow
;
3414 m_foldLevelPrev
= event
.m_foldLevelPrev
;
3416 m_margin
= event
.m_margin
;
3418 m_message
= event
.m_message
;
3419 m_wParam
= event
.m_wParam
;
3420 m_lParam
= event
.m_lParam
;
3422 m_listType
= event
.m_listType
;
3426 m_dragText
= event
.m_dragText
;
3427 m_dragAllowMove
=event
.m_dragAllowMove
;
3428 #if wxUSE_DRAG_AND_DROP
3429 m_dragResult
= event
.m_dragResult
;
3433 //----------------------------------------------------------------------
3434 //----------------------------------------------------------------------