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"
31 #include "wx/tokenzr.h"
32 #include "wx/mstream.h"
36 #include "wx/stc/stc.h"
37 #include "ScintillaWX.h"
39 //----------------------------------------------------------------------
41 const wxChar
* wxSTCNameStr
= wxT("stcwindow");
47 #define MAKELONG(a, b) ((a) | ((b) << 16))
50 static long wxColourAsLong(const wxColour
& co
) {
51 return (((long)co
.Blue() << 16) |
52 ((long)co
.Green() << 8) |
56 static wxColour
wxColourFromLong(long c
) {
58 clr
.Set((unsigned char)(c
& 0xff),
59 (unsigned char)((c
>> 8) & 0xff),
60 (unsigned char)((c
>> 16) & 0xff));
65 static wxColour
wxColourFromSpec(const wxString
& spec
) {
66 // spec should be a colour name or "#RRGGBB"
67 if (spec
.GetChar(0) == wxT('#')) {
69 long red
, green
, blue
;
70 red
= green
= blue
= 0;
71 spec
.Mid(1,2).ToLong(&red
, 16);
72 spec
.Mid(3,2).ToLong(&green
, 16);
73 spec
.Mid(5,2).ToLong(&blue
, 16);
74 return wxColour((unsigned char)red
,
79 return wxColour(spec
);
82 //----------------------------------------------------------------------
84 DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE
)
85 DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED
)
86 DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED
)
87 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED
)
88 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT
)
89 DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT
)
90 DEFINE_EVENT_TYPE( wxEVT_STC_KEY
)
91 DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK
)
92 DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI
)
93 DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED
)
94 DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD
)
95 DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK
)
96 DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN
)
97 DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED
)
98 DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION
)
99 DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED
)
100 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART
)
101 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND
)
102 DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG
)
103 DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER
)
104 DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP
)
105 DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM
)
106 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK
)
107 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK
)
108 DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK
)
109 DEFINE_EVENT_TYPE( wxEVT_STC_AUTOCOMP_SELECTION
)
113 BEGIN_EVENT_TABLE(wxStyledTextCtrl
, wxControl
)
114 EVT_PAINT (wxStyledTextCtrl::OnPaint
)
115 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin
)
116 EVT_SCROLL (wxStyledTextCtrl::OnScroll
)
117 EVT_SIZE (wxStyledTextCtrl::OnSize
)
118 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown
)
119 // Let Scintilla see the double click as a second click
120 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown
)
121 EVT_MOTION (wxStyledTextCtrl::OnMouseMove
)
122 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp
)
123 #if defined(__WXGTK__) || defined(__WXMAC__)
124 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp
)
126 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu
)
128 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel
)
129 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp
)
130 EVT_CHAR (wxStyledTextCtrl::OnChar
)
131 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown
)
132 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus
)
133 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus
)
134 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged
)
135 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground
)
136 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu
)
137 EVT_LISTBOX_DCLICK (wxID_ANY
, wxStyledTextCtrl::OnListBox
)
141 IMPLEMENT_CLASS(wxStyledTextCtrl
, wxControl
)
142 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent
, wxCommandEvent
)
145 // forces the linking of the lexer modules
146 int Scintilla_LinkLexers();
149 //----------------------------------------------------------------------
150 // Constructor and Destructor
152 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow
*parent
,
157 const wxString
& name
)
160 Create(parent
, id
, pos
, size
, style
, name
);
164 bool wxStyledTextCtrl::Create(wxWindow
*parent
,
169 const wxString
& name
)
171 style
|= wxVSCROLL
| wxHSCROLL
;
172 if (!wxControl::Create(parent
, id
, pos
, size
,
173 style
| wxWANTS_CHARS
| wxCLIP_CHILDREN
,
174 wxDefaultValidator
, name
))
178 Scintilla_LinkLexers();
180 m_swx
= new ScintillaWX(this);
182 m_lastKeyDownConsumed
= false;
186 // Put Scintilla into unicode (UTF-8) mode
187 SetCodePage(wxSTC_CP_UTF8
);
190 SetInitialSize(size
);
192 // Reduces flicker on GTK+/X11
193 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
198 wxStyledTextCtrl::~wxStyledTextCtrl() {
203 //----------------------------------------------------------------------
205 long wxStyledTextCtrl::SendMsg(int msg
, long wp
, long lp
) {
207 return m_swx
->WndProc(msg
, wp
, lp
);
210 //----------------------------------------------------------------------
212 // Set the vertical scrollbar to use instead of the ont that's built-in.
213 void wxStyledTextCtrl::SetVScrollBar(wxScrollBar
* bar
) {
216 // ensure that the built-in scrollbar is not visible
217 SetScrollbar(wxVERTICAL
, 0, 0, 0);
222 // Set the horizontal scrollbar to use instead of the ont that's built-in.
223 void wxStyledTextCtrl::SetHScrollBar(wxScrollBar
* bar
) {
226 // ensure that the built-in scrollbar is not visible
227 SetScrollbar(wxHORIZONTAL
, 0, 0, 0);
231 //----------------------------------------------------------------------
232 // BEGIN generated section. The following code is automatically generated
233 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
234 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
237 // Add text to the document at current position.
238 void wxStyledTextCtrl::AddText(const wxString
& text
) {
239 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
240 SendMsg(2001, strlen(buf
), (long)(const char*)buf
);
243 // Add array of cells to document.
244 void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer
& data
) {
245 SendMsg(2002, data
.GetDataLen(), (long)data
.GetData());
248 // Insert string at a position.
249 void wxStyledTextCtrl::InsertText(int pos
, const wxString
& text
) {
250 SendMsg(2003, pos
, (long)(const char*)wx2stc(text
));
253 // Delete all text in the document.
254 void wxStyledTextCtrl::ClearAll() {
258 // Set all style bytes to 0, remove all folding information.
259 void wxStyledTextCtrl::ClearDocumentStyle() {
263 // Returns the number of characters in the document.
264 int wxStyledTextCtrl::GetLength() {
265 return SendMsg(2006, 0, 0);
268 // Returns the character byte at the position.
269 int wxStyledTextCtrl::GetCharAt(int pos
) {
270 return (unsigned char)SendMsg(2007, pos
, 0);
273 // Returns the position of the caret.
274 int wxStyledTextCtrl::GetCurrentPos() {
275 return SendMsg(2008, 0, 0);
278 // Returns the position of the opposite end of the selection to the caret.
279 int wxStyledTextCtrl::GetAnchor() {
280 return SendMsg(2009, 0, 0);
283 // Returns the style byte at the position.
284 int wxStyledTextCtrl::GetStyleAt(int pos
) {
285 return (unsigned char)SendMsg(2010, pos
, 0);
288 // Redoes the next action on the undo history.
289 void wxStyledTextCtrl::Redo() {
293 // Choose between collecting actions into the undo
294 // history and discarding them.
295 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo
) {
296 SendMsg(2012, collectUndo
, 0);
299 // Select all the text in the document.
300 void wxStyledTextCtrl::SelectAll() {
304 // Remember the current position in the undo history as the position
305 // at which the document was saved.
306 void wxStyledTextCtrl::SetSavePoint() {
310 // Retrieve a buffer of cells.
311 wxMemoryBuffer
wxStyledTextCtrl::GetStyledText(int startPos
, int endPos
) {
313 if (endPos
< startPos
) {
318 int len
= endPos
- startPos
;
319 if (!len
) return buf
;
321 tr
.lpstrText
= (char*)buf
.GetWriteBuf(len
*2+1);
322 tr
.chrg
.cpMin
= startPos
;
323 tr
.chrg
.cpMax
= endPos
;
324 len
= SendMsg(2015, 0, (long)&tr
);
325 buf
.UngetWriteBuf(len
);
329 // Are there any redoable actions in the undo history?
330 bool wxStyledTextCtrl::CanRedo() {
331 return SendMsg(2016, 0, 0) != 0;
334 // Retrieve the line number at which a particular marker is located.
335 int wxStyledTextCtrl::MarkerLineFromHandle(int handle
) {
336 return SendMsg(2017, handle
, 0);
340 void wxStyledTextCtrl::MarkerDeleteHandle(int handle
) {
341 SendMsg(2018, handle
, 0);
344 // Is undo history being collected?
345 bool wxStyledTextCtrl::GetUndoCollection() {
346 return SendMsg(2019, 0, 0) != 0;
349 // Are white space characters currently visible?
350 // Returns one of SCWS_* constants.
351 int wxStyledTextCtrl::GetViewWhiteSpace() {
352 return SendMsg(2020, 0, 0);
355 // Make white space characters invisible, always visible or visible outside indentation.
356 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS
) {
357 SendMsg(2021, viewWS
, 0);
360 // Find the position from a point within the window.
361 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt
) {
362 return SendMsg(2022, pt
.x
, pt
.y
);
365 // Find the position from a point within the window but return
366 // INVALID_POSITION if not close to text.
367 int wxStyledTextCtrl::PositionFromPointClose(int x
, int y
) {
368 return SendMsg(2023, x
, y
);
371 // Set caret to start of a line and ensure it is visible.
372 void wxStyledTextCtrl::GotoLine(int line
) {
373 SendMsg(2024, line
, 0);
376 // Set caret to a position and ensure it is visible.
377 void wxStyledTextCtrl::GotoPos(int pos
) {
378 SendMsg(2025, pos
, 0);
381 // Set the selection anchor to a position. The anchor is the opposite
382 // end of the selection from the caret.
383 void wxStyledTextCtrl::SetAnchor(int posAnchor
) {
384 SendMsg(2026, posAnchor
, 0);
387 // Retrieve the text of the line containing the caret.
388 // Returns the index of the caret on the line.
389 wxString
wxStyledTextCtrl::GetCurLine(int* linePos
) {
390 int len
= LineLength(GetCurrentLine());
392 if (linePos
) *linePos
= 0;
393 return wxEmptyString
;
396 wxMemoryBuffer
mbuf(len
+1);
397 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
399 int pos
= SendMsg(2027, len
+1, (long)buf
);
400 mbuf
.UngetWriteBuf(len
);
402 if (linePos
) *linePos
= pos
;
406 // Retrieve the position of the last correctly styled character.
407 int wxStyledTextCtrl::GetEndStyled() {
408 return SendMsg(2028, 0, 0);
411 // Convert all line endings in the document to one mode.
412 void wxStyledTextCtrl::ConvertEOLs(int eolMode
) {
413 SendMsg(2029, eolMode
, 0);
416 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
417 int wxStyledTextCtrl::GetEOLMode() {
418 return SendMsg(2030, 0, 0);
421 // Set the current end of line mode.
422 void wxStyledTextCtrl::SetEOLMode(int eolMode
) {
423 SendMsg(2031, eolMode
, 0);
426 // Set the current styling position to pos and the styling mask to mask.
427 // The styling mask can be used to protect some bits in each styling byte from modification.
428 void wxStyledTextCtrl::StartStyling(int pos
, int mask
) {
429 SendMsg(2032, pos
, mask
);
432 // Change style from current styling position for length characters to a style
433 // and move the current styling position to after this newly styled segment.
434 void wxStyledTextCtrl::SetStyling(int length
, int style
) {
435 SendMsg(2033, length
, style
);
438 // Is drawing done first into a buffer or direct to the screen?
439 bool wxStyledTextCtrl::GetBufferedDraw() {
440 return SendMsg(2034, 0, 0) != 0;
443 // If drawing is buffered then each line of text is drawn into a bitmap buffer
444 // before drawing it to the screen to avoid flicker.
445 void wxStyledTextCtrl::SetBufferedDraw(bool buffered
) {
446 SendMsg(2035, buffered
, 0);
449 // Change the visible size of a tab to be a multiple of the width of a space character.
450 void wxStyledTextCtrl::SetTabWidth(int tabWidth
) {
451 SendMsg(2036, tabWidth
, 0);
454 // Retrieve the visible size of a tab.
455 int wxStyledTextCtrl::GetTabWidth() {
456 return SendMsg(2121, 0, 0);
459 // Set the code page used to interpret the bytes of the document as characters.
460 void wxStyledTextCtrl::SetCodePage(int codePage
) {
462 wxASSERT_MSG(codePage
== wxSTC_CP_UTF8
,
463 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
465 wxASSERT_MSG(codePage
!= wxSTC_CP_UTF8
,
466 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
468 SendMsg(2037, codePage
);
471 // Set the symbol used for a particular marker number,
472 // and optionally the fore and background colours.
473 void wxStyledTextCtrl::MarkerDefine(int markerNumber
, int markerSymbol
,
474 const wxColour
& foreground
,
475 const wxColour
& background
) {
477 SendMsg(2040, markerNumber
, markerSymbol
);
479 MarkerSetForeground(markerNumber
, foreground
);
481 MarkerSetBackground(markerNumber
, background
);
484 // Set the foreground colour used for a particular marker number.
485 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber
, const wxColour
& fore
) {
486 SendMsg(2041, markerNumber
, wxColourAsLong(fore
));
489 // Set the background colour used for a particular marker number.
490 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber
, const wxColour
& back
) {
491 SendMsg(2042, markerNumber
, wxColourAsLong(back
));
494 // Add a marker to a line, returning an ID which can be used to find or delete the marker.
495 int wxStyledTextCtrl::MarkerAdd(int line
, int markerNumber
) {
496 return SendMsg(2043, line
, markerNumber
);
499 // Delete a marker from a line.
500 void wxStyledTextCtrl::MarkerDelete(int line
, int markerNumber
) {
501 SendMsg(2044, line
, markerNumber
);
504 // Delete all markers with a particular number from all lines.
505 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber
) {
506 SendMsg(2045, markerNumber
, 0);
509 // Get a bit mask of all the markers set on a line.
510 int wxStyledTextCtrl::MarkerGet(int line
) {
511 return SendMsg(2046, line
, 0);
514 // Find the next line after lineStart that includes a marker in mask.
515 int wxStyledTextCtrl::MarkerNext(int lineStart
, int markerMask
) {
516 return SendMsg(2047, lineStart
, markerMask
);
519 // Find the previous line before lineStart that includes a marker in mask.
520 int wxStyledTextCtrl::MarkerPrevious(int lineStart
, int markerMask
) {
521 return SendMsg(2048, lineStart
, markerMask
);
524 // Define a marker from a bitmap
525 void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber
, const wxBitmap
& bmp
) {
526 // convert bmp to a xpm in a string
527 wxMemoryOutputStream strm
;
528 wxImage img
= bmp
.ConvertToImage();
530 img
.ConvertAlphaToMask();
531 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
532 size_t len
= strm
.GetSize();
533 char* buff
= new char[len
+1];
534 strm
.CopyTo(buff
, len
);
536 SendMsg(2049, markerNumber
, (long)buff
);
541 // Add a set of markers to a line.
542 void wxStyledTextCtrl::MarkerAddSet(int line
, int set
) {
543 SendMsg(2466, line
, set
);
546 // Set the alpha used for a marker that is drawn in the text area, not the margin.
547 void wxStyledTextCtrl::MarkerSetAlpha(int markerNumber
, int alpha
) {
548 SendMsg(2476, markerNumber
, alpha
);
551 // Set a margin to be either numeric or symbolic.
552 void wxStyledTextCtrl::SetMarginType(int margin
, int marginType
) {
553 SendMsg(2240, margin
, marginType
);
556 // Retrieve the type of a margin.
557 int wxStyledTextCtrl::GetMarginType(int margin
) {
558 return SendMsg(2241, margin
, 0);
561 // Set the width of a margin to a width expressed in pixels.
562 void wxStyledTextCtrl::SetMarginWidth(int margin
, int pixelWidth
) {
563 SendMsg(2242, margin
, pixelWidth
);
566 // Retrieve the width of a margin in pixels.
567 int wxStyledTextCtrl::GetMarginWidth(int margin
) {
568 return SendMsg(2243, margin
, 0);
571 // Set a mask that determines which markers are displayed in a margin.
572 void wxStyledTextCtrl::SetMarginMask(int margin
, int mask
) {
573 SendMsg(2244, margin
, mask
);
576 // Retrieve the marker mask of a margin.
577 int wxStyledTextCtrl::GetMarginMask(int margin
) {
578 return SendMsg(2245, margin
, 0);
581 // Make a margin sensitive or insensitive to mouse clicks.
582 void wxStyledTextCtrl::SetMarginSensitive(int margin
, bool sensitive
) {
583 SendMsg(2246, margin
, sensitive
);
586 // Retrieve the mouse click sensitivity of a margin.
587 bool wxStyledTextCtrl::GetMarginSensitive(int margin
) {
588 return SendMsg(2247, margin
, 0) != 0;
591 // Clear all the styles and make equivalent to the global default style.
592 void wxStyledTextCtrl::StyleClearAll() {
596 // Set the foreground colour of a style.
597 void wxStyledTextCtrl::StyleSetForeground(int style
, const wxColour
& fore
) {
598 SendMsg(2051, style
, wxColourAsLong(fore
));
601 // Set the background colour of a style.
602 void wxStyledTextCtrl::StyleSetBackground(int style
, const wxColour
& back
) {
603 SendMsg(2052, style
, wxColourAsLong(back
));
606 // Set a style to be bold or not.
607 void wxStyledTextCtrl::StyleSetBold(int style
, bool bold
) {
608 SendMsg(2053, style
, bold
);
611 // Set a style to be italic or not.
612 void wxStyledTextCtrl::StyleSetItalic(int style
, bool italic
) {
613 SendMsg(2054, style
, italic
);
616 // Set the size of characters of a style.
617 void wxStyledTextCtrl::StyleSetSize(int style
, int sizePoints
) {
618 SendMsg(2055, style
, sizePoints
);
621 // Set the font of a style.
622 void wxStyledTextCtrl::StyleSetFaceName(int style
, const wxString
& fontName
) {
623 SendMsg(2056, style
, (long)(const char*)wx2stc(fontName
));
626 // Set a style to have its end of line filled or not.
627 void wxStyledTextCtrl::StyleSetEOLFilled(int style
, bool filled
) {
628 SendMsg(2057, style
, filled
);
631 // Reset the default style to its state at startup
632 void wxStyledTextCtrl::StyleResetDefault() {
636 // Set a style to be underlined or not.
637 void wxStyledTextCtrl::StyleSetUnderline(int style
, bool underline
) {
638 SendMsg(2059, style
, underline
);
641 // Set a style to be mixed case, or to force upper or lower case.
642 void wxStyledTextCtrl::StyleSetCase(int style
, int caseForce
) {
643 SendMsg(2060, style
, caseForce
);
646 // Set a style to be a hotspot or not.
647 void wxStyledTextCtrl::StyleSetHotSpot(int style
, bool hotspot
) {
648 SendMsg(2409, style
, hotspot
);
651 // Set the foreground colour of the selection and whether to use this setting.
652 void wxStyledTextCtrl::SetSelForeground(bool useSetting
, const wxColour
& fore
) {
653 SendMsg(2067, useSetting
, wxColourAsLong(fore
));
656 // Set the background colour of the selection and whether to use this setting.
657 void wxStyledTextCtrl::SetSelBackground(bool useSetting
, const wxColour
& back
) {
658 SendMsg(2068, useSetting
, wxColourAsLong(back
));
661 // Get the alpha of the selection.
662 int wxStyledTextCtrl::GetSelAlpha() {
663 return SendMsg(2477, 0, 0);
666 // Set the alpha of the selection.
667 void wxStyledTextCtrl::SetSelAlpha(int alpha
) {
668 SendMsg(2478, alpha
, 0);
671 // Set the foreground colour of the caret.
672 void wxStyledTextCtrl::SetCaretForeground(const wxColour
& fore
) {
673 SendMsg(2069, wxColourAsLong(fore
), 0);
676 // When key+modifier combination km is pressed perform msg.
677 void wxStyledTextCtrl::CmdKeyAssign(int key
, int modifiers
, int cmd
) {
678 SendMsg(2070, MAKELONG(key
, modifiers
), cmd
);
681 // When key+modifier combination km is pressed do nothing.
682 void wxStyledTextCtrl::CmdKeyClear(int key
, int modifiers
) {
683 SendMsg(2071, MAKELONG(key
, modifiers
));
686 // Drop all key mappings.
687 void wxStyledTextCtrl::CmdKeyClearAll() {
691 // Set the styles for a segment of the document.
692 void wxStyledTextCtrl::SetStyleBytes(int length
, char* styleBytes
) {
693 SendMsg(2073, length
, (long)styleBytes
);
696 // Set a style to be visible or not.
697 void wxStyledTextCtrl::StyleSetVisible(int style
, bool visible
) {
698 SendMsg(2074, style
, visible
);
701 // Get the time in milliseconds that the caret is on and off.
702 int wxStyledTextCtrl::GetCaretPeriod() {
703 return SendMsg(2075, 0, 0);
706 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
707 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds
) {
708 SendMsg(2076, periodMilliseconds
, 0);
711 // Set the set of characters making up words for when moving or selecting by word.
712 // First sets deaults like SetCharsDefault.
713 void wxStyledTextCtrl::SetWordChars(const wxString
& characters
) {
714 SendMsg(2077, 0, (long)(const char*)wx2stc(characters
));
717 // Start a sequence of actions that is undone and redone as a unit.
719 void wxStyledTextCtrl::BeginUndoAction() {
723 // End a sequence of actions that is undone and redone as a unit.
724 void wxStyledTextCtrl::EndUndoAction() {
728 // Set an indicator to plain, squiggle or TT.
729 void wxStyledTextCtrl::IndicatorSetStyle(int indic
, int style
) {
730 SendMsg(2080, indic
, style
);
733 // Retrieve the style of an indicator.
734 int wxStyledTextCtrl::IndicatorGetStyle(int indic
) {
735 return SendMsg(2081, indic
, 0);
738 // Set the foreground colour of an indicator.
739 void wxStyledTextCtrl::IndicatorSetForeground(int indic
, const wxColour
& fore
) {
740 SendMsg(2082, indic
, wxColourAsLong(fore
));
743 // Retrieve the foreground colour of an indicator.
744 wxColour
wxStyledTextCtrl::IndicatorGetForeground(int indic
) {
745 long c
= SendMsg(2083, indic
, 0);
746 return wxColourFromLong(c
);
749 // Set the foreground colour of all whitespace and whether to use this setting.
750 void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting
, const wxColour
& fore
) {
751 SendMsg(2084, useSetting
, wxColourAsLong(fore
));
754 // Set the background colour of all whitespace and whether to use this setting.
755 void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting
, const wxColour
& back
) {
756 SendMsg(2085, useSetting
, wxColourAsLong(back
));
759 // Divide each styling byte into lexical class bits (default: 5) and indicator
760 // bits (default: 3). If a lexer requires more than 32 lexical states, then this
761 // is used to expand the possible states.
762 void wxStyledTextCtrl::SetStyleBits(int bits
) {
763 SendMsg(2090, bits
, 0);
766 // Retrieve number of bits in style bytes used to hold the lexical state.
767 int wxStyledTextCtrl::GetStyleBits() {
768 return SendMsg(2091, 0, 0);
771 // Used to hold extra styling information for each line.
772 void wxStyledTextCtrl::SetLineState(int line
, int state
) {
773 SendMsg(2092, line
, state
);
776 // Retrieve the extra styling information for a line.
777 int wxStyledTextCtrl::GetLineState(int line
) {
778 return SendMsg(2093, line
, 0);
781 // Retrieve the last line number that has line state.
782 int wxStyledTextCtrl::GetMaxLineState() {
783 return SendMsg(2094, 0, 0);
786 // Is the background of the line containing the caret in a different colour?
787 bool wxStyledTextCtrl::GetCaretLineVisible() {
788 return SendMsg(2095, 0, 0) != 0;
791 // Display the background of the line containing the caret in a different colour.
792 void wxStyledTextCtrl::SetCaretLineVisible(bool show
) {
793 SendMsg(2096, show
, 0);
796 // Get the colour of the background of the line containing the caret.
797 wxColour
wxStyledTextCtrl::GetCaretLineBackground() {
798 long c
= SendMsg(2097, 0, 0);
799 return wxColourFromLong(c
);
802 // Set the colour of the background of the line containing the caret.
803 void wxStyledTextCtrl::SetCaretLineBackground(const wxColour
& back
) {
804 SendMsg(2098, wxColourAsLong(back
), 0);
807 // Set a style to be changeable or not (read only).
808 // Experimental feature, currently buggy.
809 void wxStyledTextCtrl::StyleSetChangeable(int style
, bool changeable
) {
810 SendMsg(2099, style
, changeable
);
813 // Display a auto-completion list.
814 // The lenEntered parameter indicates how many characters before
815 // the caret should be used to provide context.
816 void wxStyledTextCtrl::AutoCompShow(int lenEntered
, const wxString
& itemList
) {
817 SendMsg(2100, lenEntered
, (long)(const char*)wx2stc(itemList
));
820 // Remove the auto-completion list from the screen.
821 void wxStyledTextCtrl::AutoCompCancel() {
825 // Is there an auto-completion list visible?
826 bool wxStyledTextCtrl::AutoCompActive() {
827 return SendMsg(2102, 0, 0) != 0;
830 // Retrieve the position of the caret when the auto-completion list was displayed.
831 int wxStyledTextCtrl::AutoCompPosStart() {
832 return SendMsg(2103, 0, 0);
835 // User has selected an item so remove the list and insert the selection.
836 void wxStyledTextCtrl::AutoCompComplete() {
840 // Define a set of character that when typed cancel the auto-completion list.
841 void wxStyledTextCtrl::AutoCompStops(const wxString
& characterSet
) {
842 SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet
));
845 // Change the separator character in the string setting up an auto-completion list.
846 // Default is space but can be changed if items contain space.
847 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter
) {
848 SendMsg(2106, separatorCharacter
, 0);
851 // Retrieve the auto-completion list separator character.
852 int wxStyledTextCtrl::AutoCompGetSeparator() {
853 return SendMsg(2107, 0, 0);
856 // Select the item in the auto-completion list that starts with a string.
857 void wxStyledTextCtrl::AutoCompSelect(const wxString
& text
) {
858 SendMsg(2108, 0, (long)(const char*)wx2stc(text
));
861 // Should the auto-completion list be cancelled if the user backspaces to a
862 // position before where the box was created.
863 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel
) {
864 SendMsg(2110, cancel
, 0);
867 // Retrieve whether auto-completion cancelled by backspacing before start.
868 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
869 return SendMsg(2111, 0, 0) != 0;
872 // Define a set of characters that when typed will cause the autocompletion to
873 // choose the selected item.
874 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString
& characterSet
) {
875 SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet
));
878 // Should a single item auto-completion list automatically choose the item.
879 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle
) {
880 SendMsg(2113, chooseSingle
, 0);
883 // Retrieve whether a single item auto-completion list automatically choose the item.
884 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
885 return SendMsg(2114, 0, 0) != 0;
888 // Set whether case is significant when performing auto-completion searches.
889 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase
) {
890 SendMsg(2115, ignoreCase
, 0);
893 // Retrieve state of ignore case flag.
894 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
895 return SendMsg(2116, 0, 0) != 0;
898 // Display a list of strings and send notification when user chooses one.
899 void wxStyledTextCtrl::UserListShow(int listType
, const wxString
& itemList
) {
900 SendMsg(2117, listType
, (long)(const char*)wx2stc(itemList
));
903 // Set whether or not autocompletion is hidden automatically when nothing matches.
904 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide
) {
905 SendMsg(2118, autoHide
, 0);
908 // Retrieve whether or not autocompletion is hidden automatically when nothing matches.
909 bool wxStyledTextCtrl::AutoCompGetAutoHide() {
910 return SendMsg(2119, 0, 0) != 0;
913 // Set whether or not autocompletion deletes any word characters
914 // after the inserted text upon completion.
915 void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord
) {
916 SendMsg(2270, dropRestOfWord
, 0);
919 // Retrieve whether or not autocompletion deletes any word characters
920 // after the inserted text upon completion.
921 bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
922 return SendMsg(2271, 0, 0) != 0;
925 // Register an image for use in autocompletion lists.
926 void wxStyledTextCtrl::RegisterImage(int type
, const wxBitmap
& bmp
) {
927 // convert bmp to a xpm in a string
928 wxMemoryOutputStream strm
;
929 wxImage img
= bmp
.ConvertToImage();
931 img
.ConvertAlphaToMask();
932 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
933 size_t len
= strm
.GetSize();
934 char* buff
= new char[len
+1];
935 strm
.CopyTo(buff
, len
);
937 SendMsg(2405, type
, (long)buff
);
942 // Clear all the registered images.
943 void wxStyledTextCtrl::ClearRegisteredImages() {
947 // Retrieve the auto-completion list type-separator character.
948 int wxStyledTextCtrl::AutoCompGetTypeSeparator() {
949 return SendMsg(2285, 0, 0);
952 // Change the type-separator character in the string setting up an auto-completion list.
953 // Default is '?' but can be changed if items contain '?'.
954 void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter
) {
955 SendMsg(2286, separatorCharacter
, 0);
958 // Set the maximum width, in characters, of auto-completion and user lists.
959 // Set to 0 to autosize to fit longest item, which is the default.
960 void wxStyledTextCtrl::AutoCompSetMaxWidth(int characterCount
) {
961 SendMsg(2208, characterCount
, 0);
964 // Get the maximum width, in characters, of auto-completion and user lists.
965 int wxStyledTextCtrl::AutoCompGetMaxWidth() {
966 return SendMsg(2209, 0, 0);
969 // Set the maximum height, in rows, of auto-completion and user lists.
970 // The default is 5 rows.
971 void wxStyledTextCtrl::AutoCompSetMaxHeight(int rowCount
) {
972 SendMsg(2210, rowCount
, 0);
975 // Set the maximum height, in rows, of auto-completion and user lists.
976 int wxStyledTextCtrl::AutoCompGetMaxHeight() {
977 return SendMsg(2211, 0, 0);
980 // Set the number of spaces used for one level of indentation.
981 void wxStyledTextCtrl::SetIndent(int indentSize
) {
982 SendMsg(2122, indentSize
, 0);
985 // Retrieve indentation size.
986 int wxStyledTextCtrl::GetIndent() {
987 return SendMsg(2123, 0, 0);
990 // Indentation will only use space characters if useTabs is false, otherwise
991 // it will use a combination of tabs and spaces.
992 void wxStyledTextCtrl::SetUseTabs(bool useTabs
) {
993 SendMsg(2124, useTabs
, 0);
996 // Retrieve whether tabs will be used in indentation.
997 bool wxStyledTextCtrl::GetUseTabs() {
998 return SendMsg(2125, 0, 0) != 0;
1001 // Change the indentation of a line to a number of columns.
1002 void wxStyledTextCtrl::SetLineIndentation(int line
, int indentSize
) {
1003 SendMsg(2126, line
, indentSize
);
1006 // Retrieve the number of columns that a line is indented.
1007 int wxStyledTextCtrl::GetLineIndentation(int line
) {
1008 return SendMsg(2127, line
, 0);
1011 // Retrieve the position before the first non indentation character on a line.
1012 int wxStyledTextCtrl::GetLineIndentPosition(int line
) {
1013 return SendMsg(2128, line
, 0);
1016 // Retrieve the column number of a position, taking tab width into account.
1017 int wxStyledTextCtrl::GetColumn(int pos
) {
1018 return SendMsg(2129, pos
, 0);
1021 // Show or hide the horizontal scroll bar.
1022 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show
) {
1023 SendMsg(2130, show
, 0);
1026 // Is the horizontal scroll bar visible?
1027 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
1028 return SendMsg(2131, 0, 0) != 0;
1031 // Show or hide indentation guides.
1032 void wxStyledTextCtrl::SetIndentationGuides(bool show
) {
1033 SendMsg(2132, show
, 0);
1036 // Are the indentation guides visible?
1037 bool wxStyledTextCtrl::GetIndentationGuides() {
1038 return SendMsg(2133, 0, 0) != 0;
1041 // Set the highlighted indentation guide column.
1042 // 0 = no highlighted guide.
1043 void wxStyledTextCtrl::SetHighlightGuide(int column
) {
1044 SendMsg(2134, column
, 0);
1047 // Get the highlighted indentation guide column.
1048 int wxStyledTextCtrl::GetHighlightGuide() {
1049 return SendMsg(2135, 0, 0);
1052 // Get the position after the last visible characters on a line.
1053 int wxStyledTextCtrl::GetLineEndPosition(int line
) {
1054 return SendMsg(2136, line
, 0);
1057 // Get the code page used to interpret the bytes of the document as characters.
1058 int wxStyledTextCtrl::GetCodePage() {
1059 return SendMsg(2137, 0, 0);
1062 // Get the foreground colour of the caret.
1063 wxColour
wxStyledTextCtrl::GetCaretForeground() {
1064 long c
= SendMsg(2138, 0, 0);
1065 return wxColourFromLong(c
);
1068 // In read-only mode?
1069 bool wxStyledTextCtrl::GetReadOnly() {
1070 return SendMsg(2140, 0, 0) != 0;
1073 // Sets the position of the caret.
1074 void wxStyledTextCtrl::SetCurrentPos(int pos
) {
1075 SendMsg(2141, pos
, 0);
1078 // Sets the position that starts the selection - this becomes the anchor.
1079 void wxStyledTextCtrl::SetSelectionStart(int pos
) {
1080 SendMsg(2142, pos
, 0);
1083 // Returns the position at the start of the selection.
1084 int wxStyledTextCtrl::GetSelectionStart() {
1085 return SendMsg(2143, 0, 0);
1088 // Sets the position that ends the selection - this becomes the currentPosition.
1089 void wxStyledTextCtrl::SetSelectionEnd(int pos
) {
1090 SendMsg(2144, pos
, 0);
1093 // Returns the position at the end of the selection.
1094 int wxStyledTextCtrl::GetSelectionEnd() {
1095 return SendMsg(2145, 0, 0);
1098 // Sets the print magnification added to the point size of each style for printing.
1099 void wxStyledTextCtrl::SetPrintMagnification(int magnification
) {
1100 SendMsg(2146, magnification
, 0);
1103 // Returns the print magnification.
1104 int wxStyledTextCtrl::GetPrintMagnification() {
1105 return SendMsg(2147, 0, 0);
1108 // Modify colours when printing for clearer printed text.
1109 void wxStyledTextCtrl::SetPrintColourMode(int mode
) {
1110 SendMsg(2148, mode
, 0);
1113 // Returns the print colour mode.
1114 int wxStyledTextCtrl::GetPrintColourMode() {
1115 return SendMsg(2149, 0, 0);
1118 // Find some text in the document.
1119 int wxStyledTextCtrl::FindText(int minPos
, int maxPos
,
1120 const wxString
& text
,
1123 ft
.chrg
.cpMin
= minPos
;
1124 ft
.chrg
.cpMax
= maxPos
;
1125 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1126 ft
.lpstrText
= (char*)(const char*)buf
;
1128 return SendMsg(2150, flags
, (long)&ft
);
1131 // On Windows, will draw the document into a display context such as a printer.
1132 int wxStyledTextCtrl::FormatRange(bool doDraw
,
1141 if (endPos
< startPos
) {
1142 int temp
= startPos
;
1147 fr
.hdcTarget
= target
;
1148 fr
.rc
.top
= renderRect
.GetTop();
1149 fr
.rc
.left
= renderRect
.GetLeft();
1150 fr
.rc
.right
= renderRect
.GetRight();
1151 fr
.rc
.bottom
= renderRect
.GetBottom();
1152 fr
.rcPage
.top
= pageRect
.GetTop();
1153 fr
.rcPage
.left
= pageRect
.GetLeft();
1154 fr
.rcPage
.right
= pageRect
.GetRight();
1155 fr
.rcPage
.bottom
= pageRect
.GetBottom();
1156 fr
.chrg
.cpMin
= startPos
;
1157 fr
.chrg
.cpMax
= endPos
;
1159 return SendMsg(2151, doDraw
, (long)&fr
);
1162 // Retrieve the display line at the top of the display.
1163 int wxStyledTextCtrl::GetFirstVisibleLine() {
1164 return SendMsg(2152, 0, 0);
1167 // Retrieve the contents of a line.
1168 wxString
wxStyledTextCtrl::GetLine(int line
) {
1169 int len
= LineLength(line
);
1170 if (!len
) return wxEmptyString
;
1172 wxMemoryBuffer
mbuf(len
+1);
1173 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1174 SendMsg(2153, line
, (long)buf
);
1175 mbuf
.UngetWriteBuf(len
);
1180 // Returns the number of lines in the document. There is always at least one.
1181 int wxStyledTextCtrl::GetLineCount() {
1182 return SendMsg(2154, 0, 0);
1185 // Sets the size in pixels of the left margin.
1186 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth
) {
1187 SendMsg(2155, 0, pixelWidth
);
1190 // Returns the size in pixels of the left margin.
1191 int wxStyledTextCtrl::GetMarginLeft() {
1192 return SendMsg(2156, 0, 0);
1195 // Sets the size in pixels of the right margin.
1196 void wxStyledTextCtrl::SetMarginRight(int pixelWidth
) {
1197 SendMsg(2157, 0, pixelWidth
);
1200 // Returns the size in pixels of the right margin.
1201 int wxStyledTextCtrl::GetMarginRight() {
1202 return SendMsg(2158, 0, 0);
1205 // Is the document different from when it was last saved?
1206 bool wxStyledTextCtrl::GetModify() {
1207 return SendMsg(2159, 0, 0) != 0;
1210 // Select a range of text.
1211 void wxStyledTextCtrl::SetSelection(int start
, int end
) {
1212 SendMsg(2160, start
, end
);
1215 // Retrieve the selected text.
1216 wxString
wxStyledTextCtrl::GetSelectedText() {
1220 GetSelection(&start
, &end
);
1221 int len
= end
- start
;
1222 if (!len
) return wxEmptyString
;
1224 wxMemoryBuffer
mbuf(len
+2);
1225 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1226 SendMsg(2161, 0, (long)buf
);
1227 mbuf
.UngetWriteBuf(len
);
1232 // Retrieve a range of text.
1233 wxString
wxStyledTextCtrl::GetTextRange(int startPos
, int endPos
) {
1234 if (endPos
< startPos
) {
1235 int temp
= startPos
;
1239 int len
= endPos
- startPos
;
1240 if (!len
) return wxEmptyString
;
1241 wxMemoryBuffer
mbuf(len
+1);
1242 char* buf
= (char*)mbuf
.GetWriteBuf(len
);
1245 tr
.chrg
.cpMin
= startPos
;
1246 tr
.chrg
.cpMax
= endPos
;
1247 SendMsg(2162, 0, (long)&tr
);
1248 mbuf
.UngetWriteBuf(len
);
1253 // Draw the selection in normal style or with selection highlighted.
1254 void wxStyledTextCtrl::HideSelection(bool normal
) {
1255 SendMsg(2163, normal
, 0);
1258 // Retrieve the line containing a position.
1259 int wxStyledTextCtrl::LineFromPosition(int pos
) {
1260 return SendMsg(2166, pos
, 0);
1263 // Retrieve the position at the start of a line.
1264 int wxStyledTextCtrl::PositionFromLine(int line
) {
1265 return SendMsg(2167, line
, 0);
1268 // Scroll horizontally and vertically.
1269 void wxStyledTextCtrl::LineScroll(int columns
, int lines
) {
1270 SendMsg(2168, columns
, lines
);
1273 // Ensure the caret is visible.
1274 void wxStyledTextCtrl::EnsureCaretVisible() {
1275 SendMsg(2169, 0, 0);
1278 // Replace the selected text with the argument text.
1279 void wxStyledTextCtrl::ReplaceSelection(const wxString
& text
) {
1280 SendMsg(2170, 0, (long)(const char*)wx2stc(text
));
1283 // Set to read only or read write.
1284 void wxStyledTextCtrl::SetReadOnly(bool readOnly
) {
1285 SendMsg(2171, readOnly
, 0);
1288 // Will a paste succeed?
1289 bool wxStyledTextCtrl::CanPaste() {
1290 return SendMsg(2173, 0, 0) != 0;
1293 // Are there any undoable actions in the undo history?
1294 bool wxStyledTextCtrl::CanUndo() {
1295 return SendMsg(2174, 0, 0) != 0;
1298 // Delete the undo history.
1299 void wxStyledTextCtrl::EmptyUndoBuffer() {
1300 SendMsg(2175, 0, 0);
1303 // Undo one action in the undo history.
1304 void wxStyledTextCtrl::Undo() {
1305 SendMsg(2176, 0, 0);
1308 // Cut the selection to the clipboard.
1309 void wxStyledTextCtrl::Cut() {
1310 SendMsg(2177, 0, 0);
1313 // Copy the selection to the clipboard.
1314 void wxStyledTextCtrl::Copy() {
1315 SendMsg(2178, 0, 0);
1318 // Paste the contents of the clipboard into the document replacing the selection.
1319 void wxStyledTextCtrl::Paste() {
1320 SendMsg(2179, 0, 0);
1323 // Clear the selection.
1324 void wxStyledTextCtrl::Clear() {
1325 SendMsg(2180, 0, 0);
1328 // Replace the contents of the document with the argument text.
1329 void wxStyledTextCtrl::SetText(const wxString
& text
) {
1330 SendMsg(2181, 0, (long)(const char*)wx2stc(text
));
1333 // Retrieve all the text in the document.
1334 wxString
wxStyledTextCtrl::GetText() {
1335 int len
= GetTextLength();
1336 wxMemoryBuffer
mbuf(len
+1); // leave room for the null...
1337 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1338 SendMsg(2182, len
+1, (long)buf
);
1339 mbuf
.UngetWriteBuf(len
);
1344 // Retrieve the number of characters in the document.
1345 int wxStyledTextCtrl::GetTextLength() {
1346 return SendMsg(2183, 0, 0);
1349 // Set to overtype (true) or insert mode.
1350 void wxStyledTextCtrl::SetOvertype(bool overtype
) {
1351 SendMsg(2186, overtype
, 0);
1354 // Returns true if overtype mode is active otherwise false is returned.
1355 bool wxStyledTextCtrl::GetOvertype() {
1356 return SendMsg(2187, 0, 0) != 0;
1359 // Set the width of the insert mode caret.
1360 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth
) {
1361 SendMsg(2188, pixelWidth
, 0);
1364 // Returns the width of the insert mode caret.
1365 int wxStyledTextCtrl::GetCaretWidth() {
1366 return SendMsg(2189, 0, 0);
1369 // Sets the position that starts the target which is used for updating the
1370 // document without affecting the scroll position.
1371 void wxStyledTextCtrl::SetTargetStart(int pos
) {
1372 SendMsg(2190, pos
, 0);
1375 // Get the position that starts the target.
1376 int wxStyledTextCtrl::GetTargetStart() {
1377 return SendMsg(2191, 0, 0);
1380 // Sets the position that ends the target which is used for updating the
1381 // document without affecting the scroll position.
1382 void wxStyledTextCtrl::SetTargetEnd(int pos
) {
1383 SendMsg(2192, pos
, 0);
1386 // Get the position that ends the target.
1387 int wxStyledTextCtrl::GetTargetEnd() {
1388 return SendMsg(2193, 0, 0);
1391 // Replace the target text with the argument text.
1392 // Text is counted so it can contain NULs.
1393 // Returns the length of the replacement text.
1395 int wxStyledTextCtrl::ReplaceTarget(const wxString
& text
) {
1396 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1397 return SendMsg(2194, strlen(buf
), (long)(const char*)buf
);
1400 // Replace the target text with the argument text after \d processing.
1401 // Text is counted so it can contain NULs.
1402 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1403 // matched in the last search operation which were surrounded by \( and \).
1404 // Returns the length of the replacement text including any change
1405 // caused by processing the \d patterns.
1407 int wxStyledTextCtrl::ReplaceTargetRE(const wxString
& text
) {
1408 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1409 return SendMsg(2195, strlen(buf
), (long)(const char*)buf
);
1412 // Search for a counted string in the target and set the target to the found
1413 // range. Text is counted so it can contain NULs.
1414 // Returns length of range or -1 for failure in which case target is not moved.
1416 int wxStyledTextCtrl::SearchInTarget(const wxString
& text
) {
1417 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1418 return SendMsg(2197, strlen(buf
), (long)(const char*)buf
);
1421 // Set the search flags used by SearchInTarget.
1422 void wxStyledTextCtrl::SetSearchFlags(int flags
) {
1423 SendMsg(2198, flags
, 0);
1426 // Get the search flags used by SearchInTarget.
1427 int wxStyledTextCtrl::GetSearchFlags() {
1428 return SendMsg(2199, 0, 0);
1431 // Show a call tip containing a definition near position pos.
1432 void wxStyledTextCtrl::CallTipShow(int pos
, const wxString
& definition
) {
1433 SendMsg(2200, pos
, (long)(const char*)wx2stc(definition
));
1436 // Remove the call tip from the screen.
1437 void wxStyledTextCtrl::CallTipCancel() {
1438 SendMsg(2201, 0, 0);
1441 // Is there an active call tip?
1442 bool wxStyledTextCtrl::CallTipActive() {
1443 return SendMsg(2202, 0, 0) != 0;
1446 // Retrieve the position where the caret was before displaying the call tip.
1447 int wxStyledTextCtrl::CallTipPosAtStart() {
1448 return SendMsg(2203, 0, 0);
1451 // Highlight a segment of the definition.
1452 void wxStyledTextCtrl::CallTipSetHighlight(int start
, int end
) {
1453 SendMsg(2204, start
, end
);
1456 // Set the background colour for the call tip.
1457 void wxStyledTextCtrl::CallTipSetBackground(const wxColour
& back
) {
1458 SendMsg(2205, wxColourAsLong(back
), 0);
1461 // Set the foreground colour for the call tip.
1462 void wxStyledTextCtrl::CallTipSetForeground(const wxColour
& fore
) {
1463 SendMsg(2206, wxColourAsLong(fore
), 0);
1466 // Set the foreground colour for the highlighted part of the call tip.
1467 void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour
& fore
) {
1468 SendMsg(2207, wxColourAsLong(fore
), 0);
1471 // Enable use of STYLE_CALLTIP and set call tip tab size in pixels.
1472 void wxStyledTextCtrl::CallTipUseStyle(int tabSize
) {
1473 SendMsg(2212, tabSize
, 0);
1476 // Find the display line of a document line taking hidden lines into account.
1477 int wxStyledTextCtrl::VisibleFromDocLine(int line
) {
1478 return SendMsg(2220, line
, 0);
1481 // Find the document line of a display line taking hidden lines into account.
1482 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay
) {
1483 return SendMsg(2221, lineDisplay
, 0);
1486 // The number of display lines needed to wrap a document line
1487 int wxStyledTextCtrl::WrapCount(int line
) {
1488 return SendMsg(2235, line
, 0);
1491 // Set the fold level of a line.
1492 // This encodes an integer level along with flags indicating whether the
1493 // line is a header and whether it is effectively white space.
1494 void wxStyledTextCtrl::SetFoldLevel(int line
, int level
) {
1495 SendMsg(2222, line
, level
);
1498 // Retrieve the fold level of a line.
1499 int wxStyledTextCtrl::GetFoldLevel(int line
) {
1500 return SendMsg(2223, line
, 0);
1503 // Find the last child line of a header line.
1504 int wxStyledTextCtrl::GetLastChild(int line
, int level
) {
1505 return SendMsg(2224, line
, level
);
1508 // Find the parent line of a child line.
1509 int wxStyledTextCtrl::GetFoldParent(int line
) {
1510 return SendMsg(2225, line
, 0);
1513 // Make a range of lines visible.
1514 void wxStyledTextCtrl::ShowLines(int lineStart
, int lineEnd
) {
1515 SendMsg(2226, lineStart
, lineEnd
);
1518 // Make a range of lines invisible.
1519 void wxStyledTextCtrl::HideLines(int lineStart
, int lineEnd
) {
1520 SendMsg(2227, lineStart
, lineEnd
);
1523 // Is a line visible?
1524 bool wxStyledTextCtrl::GetLineVisible(int line
) {
1525 return SendMsg(2228, line
, 0) != 0;
1528 // Show the children of a header line.
1529 void wxStyledTextCtrl::SetFoldExpanded(int line
, bool expanded
) {
1530 SendMsg(2229, line
, expanded
);
1533 // Is a header line expanded?
1534 bool wxStyledTextCtrl::GetFoldExpanded(int line
) {
1535 return SendMsg(2230, line
, 0) != 0;
1538 // Switch a header line between expanded and contracted.
1539 void wxStyledTextCtrl::ToggleFold(int line
) {
1540 SendMsg(2231, line
, 0);
1543 // Ensure a particular line is visible by expanding any header line hiding it.
1544 void wxStyledTextCtrl::EnsureVisible(int line
) {
1545 SendMsg(2232, line
, 0);
1548 // Set some style options for folding.
1549 void wxStyledTextCtrl::SetFoldFlags(int flags
) {
1550 SendMsg(2233, flags
, 0);
1553 // Ensure a particular line is visible by expanding any header line hiding it.
1554 // Use the currently set visibility policy to determine which range to display.
1555 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line
) {
1556 SendMsg(2234, line
, 0);
1559 // Sets whether a tab pressed when caret is within indentation indents.
1560 void wxStyledTextCtrl::SetTabIndents(bool tabIndents
) {
1561 SendMsg(2260, tabIndents
, 0);
1564 // Does a tab pressed when caret is within indentation indent?
1565 bool wxStyledTextCtrl::GetTabIndents() {
1566 return SendMsg(2261, 0, 0) != 0;
1569 // Sets whether a backspace pressed when caret is within indentation unindents.
1570 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents
) {
1571 SendMsg(2262, bsUnIndents
, 0);
1574 // Does a backspace pressed when caret is within indentation unindent?
1575 bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1576 return SendMsg(2263, 0, 0) != 0;
1579 // Sets the time the mouse must sit still to generate a mouse dwell event.
1580 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds
) {
1581 SendMsg(2264, periodMilliseconds
, 0);
1584 // Retrieve the time the mouse must sit still to generate a mouse dwell event.
1585 int wxStyledTextCtrl::GetMouseDwellTime() {
1586 return SendMsg(2265, 0, 0);
1589 // Get position of start of word.
1590 int wxStyledTextCtrl::WordStartPosition(int pos
, bool onlyWordCharacters
) {
1591 return SendMsg(2266, pos
, onlyWordCharacters
);
1594 // Get position of end of word.
1595 int wxStyledTextCtrl::WordEndPosition(int pos
, bool onlyWordCharacters
) {
1596 return SendMsg(2267, pos
, onlyWordCharacters
);
1599 // Sets whether text is word wrapped.
1600 void wxStyledTextCtrl::SetWrapMode(int mode
) {
1601 SendMsg(2268, mode
, 0);
1604 // Retrieve whether text is word wrapped.
1605 int wxStyledTextCtrl::GetWrapMode() {
1606 return SendMsg(2269, 0, 0);
1609 // Set the display mode of visual flags for wrapped lines.
1610 void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags
) {
1611 SendMsg(2460, wrapVisualFlags
, 0);
1614 // Retrive the display mode of visual flags for wrapped lines.
1615 int wxStyledTextCtrl::GetWrapVisualFlags() {
1616 return SendMsg(2461, 0, 0);
1619 // Set the location of visual flags for wrapped lines.
1620 void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation
) {
1621 SendMsg(2462, wrapVisualFlagsLocation
, 0);
1624 // Retrive the location of visual flags for wrapped lines.
1625 int wxStyledTextCtrl::GetWrapVisualFlagsLocation() {
1626 return SendMsg(2463, 0, 0);
1629 // Set the start indent for wrapped lines.
1630 void wxStyledTextCtrl::SetWrapStartIndent(int indent
) {
1631 SendMsg(2464, indent
, 0);
1634 // Retrive the start indent for wrapped lines.
1635 int wxStyledTextCtrl::GetWrapStartIndent() {
1636 return SendMsg(2465, 0, 0);
1639 // Sets the degree of caching of layout information.
1640 void wxStyledTextCtrl::SetLayoutCache(int mode
) {
1641 SendMsg(2272, mode
, 0);
1644 // Retrieve the degree of caching of layout information.
1645 int wxStyledTextCtrl::GetLayoutCache() {
1646 return SendMsg(2273, 0, 0);
1649 // Sets the document width assumed for scrolling.
1650 void wxStyledTextCtrl::SetScrollWidth(int pixelWidth
) {
1651 SendMsg(2274, pixelWidth
, 0);
1654 // Retrieve the document width assumed for scrolling.
1655 int wxStyledTextCtrl::GetScrollWidth() {
1656 return SendMsg(2275, 0, 0);
1659 // Measure the pixel width of some text in a particular style.
1660 // NUL terminated text argument.
1661 // Does not handle tab or control characters.
1662 int wxStyledTextCtrl::TextWidth(int style
, const wxString
& text
) {
1663 return SendMsg(2276, style
, (long)(const char*)wx2stc(text
));
1666 // Sets the scroll range so that maximum scroll position has
1667 // the last line at the bottom of the view (default).
1668 // Setting this to false allows scrolling one page below the last line.
1669 void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine
) {
1670 SendMsg(2277, endAtLastLine
, 0);
1673 // Retrieve whether the maximum scroll position has the last
1674 // line at the bottom of the view.
1675 bool wxStyledTextCtrl::GetEndAtLastLine() {
1676 return SendMsg(2278, 0, 0) != 0;
1679 // Retrieve the height of a particular line of text in pixels.
1680 int wxStyledTextCtrl::TextHeight(int line
) {
1681 return SendMsg(2279, line
, 0);
1684 // Show or hide the vertical scroll bar.
1685 void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show
) {
1686 SendMsg(2280, show
, 0);
1689 // Is the vertical scroll bar visible?
1690 bool wxStyledTextCtrl::GetUseVerticalScrollBar() {
1691 return SendMsg(2281, 0, 0) != 0;
1694 // Append a string to the end of the document without changing the selection.
1695 void wxStyledTextCtrl::AppendText(const wxString
& text
) {
1696 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1697 SendMsg(2282, strlen(buf
), (long)(const char*)buf
);
1700 // Is drawing done in two phases with backgrounds drawn before foregrounds?
1701 bool wxStyledTextCtrl::GetTwoPhaseDraw() {
1702 return SendMsg(2283, 0, 0) != 0;
1705 // In twoPhaseDraw mode, drawing is performed in two phases, first the background
1706 // and then the foreground. This avoids chopping off characters that overlap the next run.
1707 void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase
) {
1708 SendMsg(2284, twoPhase
, 0);
1711 // Make the target range start and end be the same as the selection range start and end.
1712 void wxStyledTextCtrl::TargetFromSelection() {
1713 SendMsg(2287, 0, 0);
1716 // Join the lines in the target.
1717 void wxStyledTextCtrl::LinesJoin() {
1718 SendMsg(2288, 0, 0);
1721 // Split the lines in the target into lines that are less wide than pixelWidth
1723 void wxStyledTextCtrl::LinesSplit(int pixelWidth
) {
1724 SendMsg(2289, pixelWidth
, 0);
1727 // Set the colours used as a chequerboard pattern in the fold margin
1728 void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting
, const wxColour
& back
) {
1729 SendMsg(2290, useSetting
, wxColourAsLong(back
));
1731 void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting
, const wxColour
& fore
) {
1732 SendMsg(2291, useSetting
, wxColourAsLong(fore
));
1735 // Move caret down one line.
1736 void wxStyledTextCtrl::LineDown() {
1737 SendMsg(2300, 0, 0);
1740 // Move caret down one line extending selection to new caret position.
1741 void wxStyledTextCtrl::LineDownExtend() {
1742 SendMsg(2301, 0, 0);
1745 // Move caret up one line.
1746 void wxStyledTextCtrl::LineUp() {
1747 SendMsg(2302, 0, 0);
1750 // Move caret up one line extending selection to new caret position.
1751 void wxStyledTextCtrl::LineUpExtend() {
1752 SendMsg(2303, 0, 0);
1755 // Move caret left one character.
1756 void wxStyledTextCtrl::CharLeft() {
1757 SendMsg(2304, 0, 0);
1760 // Move caret left one character extending selection to new caret position.
1761 void wxStyledTextCtrl::CharLeftExtend() {
1762 SendMsg(2305, 0, 0);
1765 // Move caret right one character.
1766 void wxStyledTextCtrl::CharRight() {
1767 SendMsg(2306, 0, 0);
1770 // Move caret right one character extending selection to new caret position.
1771 void wxStyledTextCtrl::CharRightExtend() {
1772 SendMsg(2307, 0, 0);
1775 // Move caret left one word.
1776 void wxStyledTextCtrl::WordLeft() {
1777 SendMsg(2308, 0, 0);
1780 // Move caret left one word extending selection to new caret position.
1781 void wxStyledTextCtrl::WordLeftExtend() {
1782 SendMsg(2309, 0, 0);
1785 // Move caret right one word.
1786 void wxStyledTextCtrl::WordRight() {
1787 SendMsg(2310, 0, 0);
1790 // Move caret right one word extending selection to new caret position.
1791 void wxStyledTextCtrl::WordRightExtend() {
1792 SendMsg(2311, 0, 0);
1795 // Move caret to first position on line.
1796 void wxStyledTextCtrl::Home() {
1797 SendMsg(2312, 0, 0);
1800 // Move caret to first position on line extending selection to new caret position.
1801 void wxStyledTextCtrl::HomeExtend() {
1802 SendMsg(2313, 0, 0);
1805 // Move caret to last position on line.
1806 void wxStyledTextCtrl::LineEnd() {
1807 SendMsg(2314, 0, 0);
1810 // Move caret to last position on line extending selection to new caret position.
1811 void wxStyledTextCtrl::LineEndExtend() {
1812 SendMsg(2315, 0, 0);
1815 // Move caret to first position in document.
1816 void wxStyledTextCtrl::DocumentStart() {
1817 SendMsg(2316, 0, 0);
1820 // Move caret to first position in document extending selection to new caret position.
1821 void wxStyledTextCtrl::DocumentStartExtend() {
1822 SendMsg(2317, 0, 0);
1825 // Move caret to last position in document.
1826 void wxStyledTextCtrl::DocumentEnd() {
1827 SendMsg(2318, 0, 0);
1830 // Move caret to last position in document extending selection to new caret position.
1831 void wxStyledTextCtrl::DocumentEndExtend() {
1832 SendMsg(2319, 0, 0);
1835 // Move caret one page up.
1836 void wxStyledTextCtrl::PageUp() {
1837 SendMsg(2320, 0, 0);
1840 // Move caret one page up extending selection to new caret position.
1841 void wxStyledTextCtrl::PageUpExtend() {
1842 SendMsg(2321, 0, 0);
1845 // Move caret one page down.
1846 void wxStyledTextCtrl::PageDown() {
1847 SendMsg(2322, 0, 0);
1850 // Move caret one page down extending selection to new caret position.
1851 void wxStyledTextCtrl::PageDownExtend() {
1852 SendMsg(2323, 0, 0);
1855 // Switch from insert to overtype mode or the reverse.
1856 void wxStyledTextCtrl::EditToggleOvertype() {
1857 SendMsg(2324, 0, 0);
1860 // Cancel any modes such as call tip or auto-completion list display.
1861 void wxStyledTextCtrl::Cancel() {
1862 SendMsg(2325, 0, 0);
1865 // Delete the selection or if no selection, the character before the caret.
1866 void wxStyledTextCtrl::DeleteBack() {
1867 SendMsg(2326, 0, 0);
1870 // If selection is empty or all on one line replace the selection with a tab character.
1871 // If more than one line selected, indent the lines.
1872 void wxStyledTextCtrl::Tab() {
1873 SendMsg(2327, 0, 0);
1876 // Dedent the selected lines.
1877 void wxStyledTextCtrl::BackTab() {
1878 SendMsg(2328, 0, 0);
1881 // Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
1882 void wxStyledTextCtrl::NewLine() {
1883 SendMsg(2329, 0, 0);
1886 // Insert a Form Feed character.
1887 void wxStyledTextCtrl::FormFeed() {
1888 SendMsg(2330, 0, 0);
1891 // Move caret to before first visible character on line.
1892 // If already there move to first character on line.
1893 void wxStyledTextCtrl::VCHome() {
1894 SendMsg(2331, 0, 0);
1897 // Like VCHome but extending selection to new caret position.
1898 void wxStyledTextCtrl::VCHomeExtend() {
1899 SendMsg(2332, 0, 0);
1902 // Magnify the displayed text by increasing the sizes by 1 point.
1903 void wxStyledTextCtrl::ZoomIn() {
1904 SendMsg(2333, 0, 0);
1907 // Make the displayed text smaller by decreasing the sizes by 1 point.
1908 void wxStyledTextCtrl::ZoomOut() {
1909 SendMsg(2334, 0, 0);
1912 // Delete the word to the left of the caret.
1913 void wxStyledTextCtrl::DelWordLeft() {
1914 SendMsg(2335, 0, 0);
1917 // Delete the word to the right of the caret.
1918 void wxStyledTextCtrl::DelWordRight() {
1919 SendMsg(2336, 0, 0);
1922 // Cut the line containing the caret.
1923 void wxStyledTextCtrl::LineCut() {
1924 SendMsg(2337, 0, 0);
1927 // Delete the line containing the caret.
1928 void wxStyledTextCtrl::LineDelete() {
1929 SendMsg(2338, 0, 0);
1932 // Switch the current line with the previous.
1933 void wxStyledTextCtrl::LineTranspose() {
1934 SendMsg(2339, 0, 0);
1937 // Duplicate the current line.
1938 void wxStyledTextCtrl::LineDuplicate() {
1939 SendMsg(2404, 0, 0);
1942 // Transform the selection to lower case.
1943 void wxStyledTextCtrl::LowerCase() {
1944 SendMsg(2340, 0, 0);
1947 // Transform the selection to upper case.
1948 void wxStyledTextCtrl::UpperCase() {
1949 SendMsg(2341, 0, 0);
1952 // Scroll the document down, keeping the caret visible.
1953 void wxStyledTextCtrl::LineScrollDown() {
1954 SendMsg(2342, 0, 0);
1957 // Scroll the document up, keeping the caret visible.
1958 void wxStyledTextCtrl::LineScrollUp() {
1959 SendMsg(2343, 0, 0);
1962 // Delete the selection or if no selection, the character before the caret.
1963 // Will not delete the character before at the start of a line.
1964 void wxStyledTextCtrl::DeleteBackNotLine() {
1965 SendMsg(2344, 0, 0);
1968 // Move caret to first position on display line.
1969 void wxStyledTextCtrl::HomeDisplay() {
1970 SendMsg(2345, 0, 0);
1973 // Move caret to first position on display line extending selection to
1974 // new caret position.
1975 void wxStyledTextCtrl::HomeDisplayExtend() {
1976 SendMsg(2346, 0, 0);
1979 // Move caret to last position on display line.
1980 void wxStyledTextCtrl::LineEndDisplay() {
1981 SendMsg(2347, 0, 0);
1984 // Move caret to last position on display line extending selection to new
1986 void wxStyledTextCtrl::LineEndDisplayExtend() {
1987 SendMsg(2348, 0, 0);
1990 // These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
1991 // except they behave differently when word-wrap is enabled:
1992 // They go first to the start / end of the display line, like (Home|LineEnd)Display
1993 // The difference is that, the cursor is already at the point, it goes on to the start
1994 // or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
1995 void wxStyledTextCtrl::HomeWrap() {
1996 SendMsg(2349, 0, 0);
1998 void wxStyledTextCtrl::HomeWrapExtend() {
1999 SendMsg(2450, 0, 0);
2001 void wxStyledTextCtrl::LineEndWrap() {
2002 SendMsg(2451, 0, 0);
2004 void wxStyledTextCtrl::LineEndWrapExtend() {
2005 SendMsg(2452, 0, 0);
2007 void wxStyledTextCtrl::VCHomeWrap() {
2008 SendMsg(2453, 0, 0);
2010 void wxStyledTextCtrl::VCHomeWrapExtend() {
2011 SendMsg(2454, 0, 0);
2014 // Copy the line containing the caret.
2015 void wxStyledTextCtrl::LineCopy() {
2016 SendMsg(2455, 0, 0);
2019 // Move the caret inside current view if it's not there already.
2020 void wxStyledTextCtrl::MoveCaretInsideView() {
2021 SendMsg(2401, 0, 0);
2024 // How many characters are on a line, not including end of line characters?
2025 int wxStyledTextCtrl::LineLength(int line
) {
2026 return SendMsg(2350, line
, 0);
2029 // Highlight the characters at two positions.
2030 void wxStyledTextCtrl::BraceHighlight(int pos1
, int pos2
) {
2031 SendMsg(2351, pos1
, pos2
);
2034 // Highlight the character at a position indicating there is no matching brace.
2035 void wxStyledTextCtrl::BraceBadLight(int pos
) {
2036 SendMsg(2352, pos
, 0);
2039 // Find the position of a matching brace or INVALID_POSITION if no match.
2040 int wxStyledTextCtrl::BraceMatch(int pos
) {
2041 return SendMsg(2353, pos
, 0);
2044 // Are the end of line characters visible?
2045 bool wxStyledTextCtrl::GetViewEOL() {
2046 return SendMsg(2355, 0, 0) != 0;
2049 // Make the end of line characters visible or invisible.
2050 void wxStyledTextCtrl::SetViewEOL(bool visible
) {
2051 SendMsg(2356, visible
, 0);
2054 // Retrieve a pointer to the document object.
2055 void* wxStyledTextCtrl::GetDocPointer() {
2056 return (void*)SendMsg(2357);
2059 // Change the document object used.
2060 void wxStyledTextCtrl::SetDocPointer(void* docPointer
) {
2061 SendMsg(2358, 0, (long)docPointer
);
2064 // Set which document modification events are sent to the container.
2065 void wxStyledTextCtrl::SetModEventMask(int mask
) {
2066 SendMsg(2359, mask
, 0);
2069 // Retrieve the column number which text should be kept within.
2070 int wxStyledTextCtrl::GetEdgeColumn() {
2071 return SendMsg(2360, 0, 0);
2074 // Set the column number of the edge.
2075 // If text goes past the edge then it is highlighted.
2076 void wxStyledTextCtrl::SetEdgeColumn(int column
) {
2077 SendMsg(2361, column
, 0);
2080 // Retrieve the edge highlight mode.
2081 int wxStyledTextCtrl::GetEdgeMode() {
2082 return SendMsg(2362, 0, 0);
2085 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
2086 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
2087 void wxStyledTextCtrl::SetEdgeMode(int mode
) {
2088 SendMsg(2363, mode
, 0);
2091 // Retrieve the colour used in edge indication.
2092 wxColour
wxStyledTextCtrl::GetEdgeColour() {
2093 long c
= SendMsg(2364, 0, 0);
2094 return wxColourFromLong(c
);
2097 // Change the colour used in edge indication.
2098 void wxStyledTextCtrl::SetEdgeColour(const wxColour
& edgeColour
) {
2099 SendMsg(2365, wxColourAsLong(edgeColour
), 0);
2102 // Sets the current caret position to be the search anchor.
2103 void wxStyledTextCtrl::SearchAnchor() {
2104 SendMsg(2366, 0, 0);
2107 // Find some text starting at the search anchor.
2108 // Does not ensure the selection is visible.
2109 int wxStyledTextCtrl::SearchNext(int flags
, const wxString
& text
) {
2110 return SendMsg(2367, flags
, (long)(const char*)wx2stc(text
));
2113 // Find some text starting at the search anchor and moving backwards.
2114 // Does not ensure the selection is visible.
2115 int wxStyledTextCtrl::SearchPrev(int flags
, const wxString
& text
) {
2116 return SendMsg(2368, flags
, (long)(const char*)wx2stc(text
));
2119 // Retrieves the number of lines completely visible.
2120 int wxStyledTextCtrl::LinesOnScreen() {
2121 return SendMsg(2370, 0, 0);
2124 // Set whether a pop up menu is displayed automatically when the user presses
2125 // the wrong mouse button.
2126 void wxStyledTextCtrl::UsePopUp(bool allowPopUp
) {
2127 SendMsg(2371, allowPopUp
, 0);
2130 // Is the selection rectangular? The alternative is the more common stream selection.
2131 bool wxStyledTextCtrl::SelectionIsRectangle() {
2132 return SendMsg(2372, 0, 0) != 0;
2135 // Set the zoom level. This number of points is added to the size of all fonts.
2136 // It may be positive to magnify or negative to reduce.
2137 void wxStyledTextCtrl::SetZoom(int zoom
) {
2138 SendMsg(2373, zoom
, 0);
2141 // Retrieve the zoom level.
2142 int wxStyledTextCtrl::GetZoom() {
2143 return SendMsg(2374, 0, 0);
2146 // Create a new document object.
2147 // Starts with reference count of 1 and not selected into editor.
2148 void* wxStyledTextCtrl::CreateDocument() {
2149 return (void*)SendMsg(2375);
2152 // Extend life of document.
2153 void wxStyledTextCtrl::AddRefDocument(void* docPointer
) {
2154 SendMsg(2376, 0, (long)docPointer
);
2157 // Release a reference to the document, deleting document if it fades to black.
2158 void wxStyledTextCtrl::ReleaseDocument(void* docPointer
) {
2159 SendMsg(2377, 0, (long)docPointer
);
2162 // Get which document modification events are sent to the container.
2163 int wxStyledTextCtrl::GetModEventMask() {
2164 return SendMsg(2378, 0, 0);
2167 // Change internal focus flag.
2168 void wxStyledTextCtrl::SetSTCFocus(bool focus
) {
2169 SendMsg(2380, focus
, 0);
2172 // Get internal focus flag.
2173 bool wxStyledTextCtrl::GetSTCFocus() {
2174 return SendMsg(2381, 0, 0) != 0;
2177 // Change error status - 0 = OK.
2178 void wxStyledTextCtrl::SetStatus(int statusCode
) {
2179 SendMsg(2382, statusCode
, 0);
2182 // Get error status.
2183 int wxStyledTextCtrl::GetStatus() {
2184 return SendMsg(2383, 0, 0);
2187 // Set whether the mouse is captured when its button is pressed.
2188 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures
) {
2189 SendMsg(2384, captures
, 0);
2192 // Get whether mouse gets captured.
2193 bool wxStyledTextCtrl::GetMouseDownCaptures() {
2194 return SendMsg(2385, 0, 0) != 0;
2197 // Sets the cursor to one of the SC_CURSOR* values.
2198 void wxStyledTextCtrl::SetSTCCursor(int cursorType
) {
2199 SendMsg(2386, cursorType
, 0);
2203 int wxStyledTextCtrl::GetSTCCursor() {
2204 return SendMsg(2387, 0, 0);
2207 // Change the way control characters are displayed:
2208 // If symbol is < 32, keep the drawn way, else, use the given character.
2209 void wxStyledTextCtrl::SetControlCharSymbol(int symbol
) {
2210 SendMsg(2388, symbol
, 0);
2213 // Get the way control characters are displayed.
2214 int wxStyledTextCtrl::GetControlCharSymbol() {
2215 return SendMsg(2389, 0, 0);
2218 // Move to the previous change in capitalisation.
2219 void wxStyledTextCtrl::WordPartLeft() {
2220 SendMsg(2390, 0, 0);
2223 // Move to the previous change in capitalisation extending selection
2224 // to new caret position.
2225 void wxStyledTextCtrl::WordPartLeftExtend() {
2226 SendMsg(2391, 0, 0);
2229 // Move to the change next in capitalisation.
2230 void wxStyledTextCtrl::WordPartRight() {
2231 SendMsg(2392, 0, 0);
2234 // Move to the next change in capitalisation extending selection
2235 // to new caret position.
2236 void wxStyledTextCtrl::WordPartRightExtend() {
2237 SendMsg(2393, 0, 0);
2240 // Set the way the display area is determined when a particular line
2241 // is to be moved to by Find, FindNext, GotoLine, etc.
2242 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy
, int visibleSlop
) {
2243 SendMsg(2394, visiblePolicy
, visibleSlop
);
2246 // Delete back from the current position to the start of the line.
2247 void wxStyledTextCtrl::DelLineLeft() {
2248 SendMsg(2395, 0, 0);
2251 // Delete forwards from the current position to the end of the line.
2252 void wxStyledTextCtrl::DelLineRight() {
2253 SendMsg(2396, 0, 0);
2256 // Get and Set the xOffset (ie, horizonal scroll position).
2257 void wxStyledTextCtrl::SetXOffset(int newOffset
) {
2258 SendMsg(2397, newOffset
, 0);
2260 int wxStyledTextCtrl::GetXOffset() {
2261 return SendMsg(2398, 0, 0);
2264 // Set the last x chosen value to be the caret x position.
2265 void wxStyledTextCtrl::ChooseCaretX() {
2266 SendMsg(2399, 0, 0);
2269 // Set the way the caret is kept visible when going sideway.
2270 // The exclusion zone is given in pixels.
2271 void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy
, int caretSlop
) {
2272 SendMsg(2402, caretPolicy
, caretSlop
);
2275 // Set the way the line the caret is on is kept visible.
2276 // The exclusion zone is given in lines.
2277 void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy
, int caretSlop
) {
2278 SendMsg(2403, caretPolicy
, caretSlop
);
2281 // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
2282 void wxStyledTextCtrl::SetPrintWrapMode(int mode
) {
2283 SendMsg(2406, mode
, 0);
2286 // Is printing line wrapped?
2287 int wxStyledTextCtrl::GetPrintWrapMode() {
2288 return SendMsg(2407, 0, 0);
2291 // Set a fore colour for active hotspots.
2292 void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting
, const wxColour
& fore
) {
2293 SendMsg(2410, useSetting
, wxColourAsLong(fore
));
2296 // Set a back colour for active hotspots.
2297 void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting
, const wxColour
& back
) {
2298 SendMsg(2411, useSetting
, wxColourAsLong(back
));
2301 // Enable / Disable underlining active hotspots.
2302 void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline
) {
2303 SendMsg(2412, underline
, 0);
2306 // Limit hotspots to single line so hotspots on two lines don't merge.
2307 void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine
) {
2308 SendMsg(2421, singleLine
, 0);
2311 // Move caret between paragraphs (delimited by empty lines).
2312 void wxStyledTextCtrl::ParaDown() {
2313 SendMsg(2413, 0, 0);
2315 void wxStyledTextCtrl::ParaDownExtend() {
2316 SendMsg(2414, 0, 0);
2318 void wxStyledTextCtrl::ParaUp() {
2319 SendMsg(2415, 0, 0);
2321 void wxStyledTextCtrl::ParaUpExtend() {
2322 SendMsg(2416, 0, 0);
2325 // Given a valid document position, return the previous position taking code
2326 // page into account. Returns 0 if passed 0.
2327 int wxStyledTextCtrl::PositionBefore(int pos
) {
2328 return SendMsg(2417, pos
, 0);
2331 // Given a valid document position, return the next position taking code
2332 // page into account. Maximum value returned is the last position in the document.
2333 int wxStyledTextCtrl::PositionAfter(int pos
) {
2334 return SendMsg(2418, pos
, 0);
2337 // Copy a range of text to the clipboard. Positions are clipped into the document.
2338 void wxStyledTextCtrl::CopyRange(int start
, int end
) {
2339 SendMsg(2419, start
, end
);
2342 // Copy argument text to the clipboard.
2343 void wxStyledTextCtrl::CopyText(int length
, const wxString
& text
) {
2344 SendMsg(2420, length
, (long)(const char*)wx2stc(text
));
2347 // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or
2348 // by lines (SC_SEL_LINES).
2349 void wxStyledTextCtrl::SetSelectionMode(int mode
) {
2350 SendMsg(2422, mode
, 0);
2353 // Get the mode of the current selection.
2354 int wxStyledTextCtrl::GetSelectionMode() {
2355 return SendMsg(2423, 0, 0);
2358 // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
2359 int wxStyledTextCtrl::GetLineSelStartPosition(int line
) {
2360 return SendMsg(2424, line
, 0);
2363 // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
2364 int wxStyledTextCtrl::GetLineSelEndPosition(int line
) {
2365 return SendMsg(2425, line
, 0);
2368 // Move caret down one line, extending rectangular selection to new caret position.
2369 void wxStyledTextCtrl::LineDownRectExtend() {
2370 SendMsg(2426, 0, 0);
2373 // Move caret up one line, extending rectangular selection to new caret position.
2374 void wxStyledTextCtrl::LineUpRectExtend() {
2375 SendMsg(2427, 0, 0);
2378 // Move caret left one character, extending rectangular selection to new caret position.
2379 void wxStyledTextCtrl::CharLeftRectExtend() {
2380 SendMsg(2428, 0, 0);
2383 // Move caret right one character, extending rectangular selection to new caret position.
2384 void wxStyledTextCtrl::CharRightRectExtend() {
2385 SendMsg(2429, 0, 0);
2388 // Move caret to first position on line, extending rectangular selection to new caret position.
2389 void wxStyledTextCtrl::HomeRectExtend() {
2390 SendMsg(2430, 0, 0);
2393 // Move caret to before first visible character on line.
2394 // If already there move to first character on line.
2395 // In either case, extend rectangular selection to new caret position.
2396 void wxStyledTextCtrl::VCHomeRectExtend() {
2397 SendMsg(2431, 0, 0);
2400 // Move caret to last position on line, extending rectangular selection to new caret position.
2401 void wxStyledTextCtrl::LineEndRectExtend() {
2402 SendMsg(2432, 0, 0);
2405 // Move caret one page up, extending rectangular selection to new caret position.
2406 void wxStyledTextCtrl::PageUpRectExtend() {
2407 SendMsg(2433, 0, 0);
2410 // Move caret one page down, extending rectangular selection to new caret position.
2411 void wxStyledTextCtrl::PageDownRectExtend() {
2412 SendMsg(2434, 0, 0);
2415 // Move caret to top of page, or one page up if already at top of page.
2416 void wxStyledTextCtrl::StutteredPageUp() {
2417 SendMsg(2435, 0, 0);
2420 // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
2421 void wxStyledTextCtrl::StutteredPageUpExtend() {
2422 SendMsg(2436, 0, 0);
2425 // Move caret to bottom of page, or one page down if already at bottom of page.
2426 void wxStyledTextCtrl::StutteredPageDown() {
2427 SendMsg(2437, 0, 0);
2430 // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
2431 void wxStyledTextCtrl::StutteredPageDownExtend() {
2432 SendMsg(2438, 0, 0);
2435 // Move caret left one word, position cursor at end of word.
2436 void wxStyledTextCtrl::WordLeftEnd() {
2437 SendMsg(2439, 0, 0);
2440 // Move caret left one word, position cursor at end of word, extending selection to new caret position.
2441 void wxStyledTextCtrl::WordLeftEndExtend() {
2442 SendMsg(2440, 0, 0);
2445 // Move caret right one word, position cursor at end of word.
2446 void wxStyledTextCtrl::WordRightEnd() {
2447 SendMsg(2441, 0, 0);
2450 // Move caret right one word, position cursor at end of word, extending selection to new caret position.
2451 void wxStyledTextCtrl::WordRightEndExtend() {
2452 SendMsg(2442, 0, 0);
2455 // Set the set of characters making up whitespace for when moving or selecting by word.
2456 // Should be called after SetWordChars.
2457 void wxStyledTextCtrl::SetWhitespaceChars(const wxString
& characters
) {
2458 SendMsg(2443, 0, (long)(const char*)wx2stc(characters
));
2461 // Reset the set of characters for whitespace and word characters to the defaults.
2462 void wxStyledTextCtrl::SetCharsDefault() {
2463 SendMsg(2444, 0, 0);
2466 // Get currently selected item position in the auto-completion list
2467 int wxStyledTextCtrl::AutoCompGetCurrent() {
2468 return SendMsg(2445, 0, 0);
2471 // Enlarge the document to a particular size of text bytes.
2472 void wxStyledTextCtrl::Allocate(int bytes
) {
2473 SendMsg(2446, bytes
, 0);
2476 // Find the position of a column on a line taking into account tabs and
2477 // multi-byte characters. If beyond end of line, return line end position.
2478 int wxStyledTextCtrl::FindColumn(int line
, int column
) {
2479 return SendMsg(2456, line
, column
);
2482 // Can the caret preferred x position only be changed by explicit movement commands?
2483 bool wxStyledTextCtrl::GetCaretSticky() {
2484 return SendMsg(2457, 0, 0) != 0;
2487 // Stop the caret preferred x position changing when the user types.
2488 void wxStyledTextCtrl::SetCaretSticky(bool useCaretStickyBehaviour
) {
2489 SendMsg(2458, useCaretStickyBehaviour
, 0);
2492 // Switch between sticky and non-sticky: meant to be bound to a key.
2493 void wxStyledTextCtrl::ToggleCaretSticky() {
2494 SendMsg(2459, 0, 0);
2497 // Enable/Disable convert-on-paste for line endings
2498 void wxStyledTextCtrl::SetPasteConvertEndings(bool convert
) {
2499 SendMsg(2467, convert
, 0);
2502 // Get convert-on-paste setting
2503 bool wxStyledTextCtrl::GetPasteConvertEndings() {
2504 return SendMsg(2468, 0, 0) != 0;
2507 // Duplicate the selection. If selection empty duplicate the line containing the caret.
2508 void wxStyledTextCtrl::SelectionDuplicate() {
2509 SendMsg(2469, 0, 0);
2512 // Set background alpha of the caret line.
2513 void wxStyledTextCtrl::SetCaretLineBackAlpha(int alpha
) {
2514 SendMsg(2470, alpha
, 0);
2517 // Get the background alpha of the caret line.
2518 int wxStyledTextCtrl::GetCaretLineBackAlpha() {
2519 return SendMsg(2471, 0, 0);
2522 // Start notifying the container of all key presses and commands.
2523 void wxStyledTextCtrl::StartRecord() {
2524 SendMsg(3001, 0, 0);
2527 // Stop notifying the container of all key presses and commands.
2528 void wxStyledTextCtrl::StopRecord() {
2529 SendMsg(3002, 0, 0);
2532 // Set the lexing language of the document.
2533 void wxStyledTextCtrl::SetLexer(int lexer
) {
2534 SendMsg(4001, lexer
, 0);
2537 // Retrieve the lexing language of the document.
2538 int wxStyledTextCtrl::GetLexer() {
2539 return SendMsg(4002, 0, 0);
2542 // Colourise a segment of the document using the current lexing language.
2543 void wxStyledTextCtrl::Colourise(int start
, int end
) {
2544 SendMsg(4003, start
, end
);
2547 // Set up a value that may be used by a lexer for some optional feature.
2548 void wxStyledTextCtrl::SetProperty(const wxString
& key
, const wxString
& value
) {
2549 SendMsg(4004, (long)(const char*)wx2stc(key
), (long)(const char*)wx2stc(value
));
2552 // Set up the key words used by the lexer.
2553 void wxStyledTextCtrl::SetKeyWords(int keywordSet
, const wxString
& keyWords
) {
2554 SendMsg(4005, keywordSet
, (long)(const char*)wx2stc(keyWords
));
2557 // Set the lexing language of the document based on string name.
2558 void wxStyledTextCtrl::SetLexerLanguage(const wxString
& language
) {
2559 SendMsg(4006, 0, (long)(const char*)wx2stc(language
));
2562 // Retrieve a 'property' value previously set with SetProperty.
2563 wxString
wxStyledTextCtrl::GetProperty(const wxString
& key
) {
2564 int len
= SendMsg(SCI_GETPROPERTY
, (long)(const char*)wx2stc(key
), (long)NULL
);
2565 if (!len
) return wxEmptyString
;
2567 wxMemoryBuffer
mbuf(len
+1);
2568 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
2569 SendMsg(4008, (long)(const char*)wx2stc(key
), (long)buf
);
2570 mbuf
.UngetWriteBuf(len
);
2575 // Retrieve a 'property' value previously set with SetProperty,
2576 // with '$()' variable replacement on returned buffer.
2577 wxString
wxStyledTextCtrl::GetPropertyExpanded(const wxString
& key
) {
2578 int len
= SendMsg(SCI_GETPROPERTYEXPANDED
, (long)(const char*)wx2stc(key
), (long)NULL
);
2579 if (!len
) return wxEmptyString
;
2581 wxMemoryBuffer
mbuf(len
+1);
2582 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
2583 SendMsg(4009, (long)(const char*)wx2stc(key
), (long)buf
);
2584 mbuf
.UngetWriteBuf(len
);
2589 // Retrieve a 'property' value previously set with SetProperty,
2590 // interpreted as an int AFTER any '$()' variable replacement.
2591 int wxStyledTextCtrl::GetPropertyInt(const wxString
& key
) {
2592 return SendMsg(4010, (long)(const char*)wx2stc(key
), 0);
2595 // Retrieve the number of bits the current lexer needs for styling.
2596 int wxStyledTextCtrl::GetStyleBitsNeeded() {
2597 return SendMsg(4011, 0, 0);
2600 // END of generated section
2601 //----------------------------------------------------------------------
2604 // Returns the line number of the line with the caret.
2605 int wxStyledTextCtrl::GetCurrentLine() {
2606 int line
= LineFromPosition(GetCurrentPos());
2611 // Extract style settings from a spec-string which is composed of one or
2612 // more of the following comma separated elements:
2614 // bold turns on bold
2615 // italic turns on italics
2616 // fore:[name or #RRGGBB] sets the foreground colour
2617 // back:[name or #RRGGBB] sets the background colour
2618 // face:[facename] sets the font face name to use
2619 // size:[num] sets the font size in points
2620 // eol turns on eol filling
2621 // underline turns on underlining
2623 void wxStyledTextCtrl::StyleSetSpec(int styleNum
, const wxString
& spec
) {
2625 wxStringTokenizer
tkz(spec
, wxT(","));
2626 while (tkz
.HasMoreTokens()) {
2627 wxString token
= tkz
.GetNextToken();
2629 wxString option
= token
.BeforeFirst(':');
2630 wxString val
= token
.AfterFirst(':');
2632 if (option
== wxT("bold"))
2633 StyleSetBold(styleNum
, true);
2635 else if (option
== wxT("italic"))
2636 StyleSetItalic(styleNum
, true);
2638 else if (option
== wxT("underline"))
2639 StyleSetUnderline(styleNum
, true);
2641 else if (option
== wxT("eol"))
2642 StyleSetEOLFilled(styleNum
, true);
2644 else if (option
== wxT("size")) {
2646 if (val
.ToLong(&points
))
2647 StyleSetSize(styleNum
, points
);
2650 else if (option
== wxT("face"))
2651 StyleSetFaceName(styleNum
, val
);
2653 else if (option
== wxT("fore"))
2654 StyleSetForeground(styleNum
, wxColourFromSpec(val
));
2656 else if (option
== wxT("back"))
2657 StyleSetBackground(styleNum
, wxColourFromSpec(val
));
2662 // Set style size, face, bold, italic, and underline attributes from
2663 // a wxFont's attributes.
2664 void wxStyledTextCtrl::StyleSetFont(int styleNum
, wxFont
& font
) {
2666 // Ensure that the native font is initialized
2668 GetTextExtent(wxT("X"), &x
, &y
, NULL
, NULL
, &font
);
2670 int size
= font
.GetPointSize();
2671 wxString faceName
= font
.GetFaceName();
2672 bool bold
= font
.GetWeight() == wxBOLD
;
2673 bool italic
= font
.GetStyle() != wxNORMAL
;
2674 bool under
= font
.GetUnderlined();
2675 wxFontEncoding encoding
= font
.GetEncoding();
2677 StyleSetFontAttr(styleNum
, size
, faceName
, bold
, italic
, under
, encoding
);
2680 // Set all font style attributes at once.
2681 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum
, int size
,
2682 const wxString
& faceName
,
2683 bool bold
, bool italic
,
2685 wxFontEncoding encoding
) {
2686 StyleSetSize(styleNum
, size
);
2687 StyleSetFaceName(styleNum
, faceName
);
2688 StyleSetBold(styleNum
, bold
);
2689 StyleSetItalic(styleNum
, italic
);
2690 StyleSetUnderline(styleNum
, underline
);
2691 StyleSetFontEncoding(styleNum
, encoding
);
2695 // Set the character set of the font in a style. Converts the Scintilla
2696 // character set values to a wxFontEncoding.
2697 void wxStyledTextCtrl::StyleSetCharacterSet(int style
, int characterSet
)
2699 wxFontEncoding encoding
;
2701 // Translate the Scintilla characterSet to a wxFontEncoding
2702 switch (characterSet
) {
2704 case wxSTC_CHARSET_ANSI
:
2705 case wxSTC_CHARSET_DEFAULT
:
2706 encoding
= wxFONTENCODING_DEFAULT
;
2709 case wxSTC_CHARSET_BALTIC
:
2710 encoding
= wxFONTENCODING_ISO8859_13
;
2713 case wxSTC_CHARSET_CHINESEBIG5
:
2714 encoding
= wxFONTENCODING_CP950
;
2717 case wxSTC_CHARSET_EASTEUROPE
:
2718 encoding
= wxFONTENCODING_ISO8859_2
;
2721 case wxSTC_CHARSET_GB2312
:
2722 encoding
= wxFONTENCODING_CP936
;
2725 case wxSTC_CHARSET_GREEK
:
2726 encoding
= wxFONTENCODING_ISO8859_7
;
2729 case wxSTC_CHARSET_HANGUL
:
2730 encoding
= wxFONTENCODING_CP949
;
2733 case wxSTC_CHARSET_MAC
:
2734 encoding
= wxFONTENCODING_DEFAULT
;
2737 case wxSTC_CHARSET_OEM
:
2738 encoding
= wxFONTENCODING_DEFAULT
;
2741 case wxSTC_CHARSET_RUSSIAN
:
2742 encoding
= wxFONTENCODING_KOI8
;
2745 case wxSTC_CHARSET_SHIFTJIS
:
2746 encoding
= wxFONTENCODING_CP932
;
2749 case wxSTC_CHARSET_SYMBOL
:
2750 encoding
= wxFONTENCODING_DEFAULT
;
2753 case wxSTC_CHARSET_TURKISH
:
2754 encoding
= wxFONTENCODING_ISO8859_9
;
2757 case wxSTC_CHARSET_JOHAB
:
2758 encoding
= wxFONTENCODING_DEFAULT
;
2761 case wxSTC_CHARSET_HEBREW
:
2762 encoding
= wxFONTENCODING_ISO8859_8
;
2765 case wxSTC_CHARSET_ARABIC
:
2766 encoding
= wxFONTENCODING_ISO8859_6
;
2769 case wxSTC_CHARSET_VIETNAMESE
:
2770 encoding
= wxFONTENCODING_DEFAULT
;
2773 case wxSTC_CHARSET_THAI
:
2774 encoding
= wxFONTENCODING_ISO8859_11
;
2777 case wxSTC_CHARSET_CYRILLIC
:
2778 encoding
= wxFONTENCODING_ISO8859_5
;
2781 case wxSTC_CHARSET_8859_15
:
2782 encoding
= wxFONTENCODING_ISO8859_15
;;
2786 // We just have Scintilla track the wxFontEncoding for us. It gets used
2787 // in Font::Create in PlatWX.cpp. We add one to the value so that the
2788 // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
2789 // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
2790 // to wxFONENCODING_DEFAULT in Font::Create.
2791 SendMsg(SCI_STYLESETCHARACTERSET
, style
, encoding
+1);
2795 // Set the font encoding to be used by a style.
2796 void wxStyledTextCtrl::StyleSetFontEncoding(int style
, wxFontEncoding encoding
)
2798 SendMsg(SCI_STYLESETCHARACTERSET
, style
, encoding
+1);
2802 // Perform one of the operations defined by the wxSTC_CMD_* constants.
2803 void wxStyledTextCtrl::CmdKeyExecute(int cmd
) {
2808 // Set the left and right margin in the edit area, measured in pixels.
2809 void wxStyledTextCtrl::SetMargins(int left
, int right
) {
2810 SetMarginLeft(left
);
2811 SetMarginRight(right
);
2815 // Retrieve the start and end positions of the current selection.
2816 void wxStyledTextCtrl::GetSelection(int* startPos
, int* endPos
) {
2817 if (startPos
!= NULL
)
2818 *startPos
= SendMsg(SCI_GETSELECTIONSTART
);
2820 *endPos
= SendMsg(SCI_GETSELECTIONEND
);
2824 // Retrieve the point in the window where a position is displayed.
2825 wxPoint
wxStyledTextCtrl::PointFromPosition(int pos
) {
2826 int x
= SendMsg(SCI_POINTXFROMPOSITION
, 0, pos
);
2827 int y
= SendMsg(SCI_POINTYFROMPOSITION
, 0, pos
);
2828 return wxPoint(x
, y
);
2831 // Scroll enough to make the given line visible
2832 void wxStyledTextCtrl::ScrollToLine(int line
) {
2833 m_swx
->DoScrollToLine(line
);
2837 // Scroll enough to make the given column visible
2838 void wxStyledTextCtrl::ScrollToColumn(int column
) {
2839 m_swx
->DoScrollToColumn(column
);
2843 bool wxStyledTextCtrl::SaveFile(const wxString
& filename
)
2845 wxFile
file(filename
, wxFile::write
);
2847 if (!file
.IsOpened())
2850 bool success
= file
.Write(GetText(), *wxConvCurrent
);
2858 bool wxStyledTextCtrl::LoadFile(const wxString
& filename
)
2860 bool success
= false;
2861 wxFile
file(filename
, wxFile::read
);
2863 if (file
.IsOpened())
2866 // get the file size (assume it is not huge file...)
2867 ssize_t len
= (ssize_t
)file
.Length();
2872 wxMemoryBuffer
buffer(len
+1);
2873 success
= (file
.Read(buffer
.GetData(), len
) == len
);
2875 ((char*)buffer
.GetData())[len
] = 0;
2876 contents
= wxString(buffer
, *wxConvCurrent
, len
);
2880 success
= (file
.Read(wxStringBuffer(buffer
, len
), len
) == len
);
2887 success
= true; // empty file is ok
2889 success
= false; // len == wxInvalidOffset
2904 #if wxUSE_DRAG_AND_DROP
2905 wxDragResult
wxStyledTextCtrl::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
2906 return m_swx
->DoDragOver(x
, y
, def
);
2910 bool wxStyledTextCtrl::DoDropText(long x
, long y
, const wxString
& data
) {
2911 return m_swx
->DoDropText(x
, y
, data
);
2916 void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA
) {
2917 m_swx
->SetUseAntiAliasing(useAA
);
2920 bool wxStyledTextCtrl::GetUseAntiAliasing() {
2921 return m_swx
->GetUseAntiAliasing();
2928 void wxStyledTextCtrl::AddTextRaw(const char* text
)
2930 SendMsg(SCI_ADDTEXT
, strlen(text
), (long)text
);
2933 void wxStyledTextCtrl::InsertTextRaw(int pos
, const char* text
)
2935 SendMsg(SCI_INSERTTEXT
, pos
, (long)text
);
2938 wxCharBuffer
wxStyledTextCtrl::GetCurLineRaw(int* linePos
)
2940 int len
= LineLength(GetCurrentLine());
2942 if (linePos
) *linePos
= 0;
2947 wxCharBuffer
buf(len
);
2948 int pos
= SendMsg(SCI_GETCURLINE
, len
, (long)buf
.data());
2949 if (linePos
) *linePos
= pos
;
2953 wxCharBuffer
wxStyledTextCtrl::GetLineRaw(int line
)
2955 int len
= LineLength(line
);
2961 wxCharBuffer
buf(len
);
2962 SendMsg(SCI_GETLINE
, line
, (long)buf
.data());
2966 wxCharBuffer
wxStyledTextCtrl::GetSelectedTextRaw()
2971 GetSelection(&start
, &end
);
2972 int len
= end
- start
;
2978 wxCharBuffer
buf(len
);
2979 SendMsg(SCI_GETSELTEXT
, 0, (long)buf
.data());
2983 wxCharBuffer
wxStyledTextCtrl::GetTextRangeRaw(int startPos
, int endPos
)
2985 if (endPos
< startPos
) {
2986 int temp
= startPos
;
2990 int len
= endPos
- startPos
;
2996 wxCharBuffer
buf(len
);
2998 tr
.lpstrText
= buf
.data();
2999 tr
.chrg
.cpMin
= startPos
;
3000 tr
.chrg
.cpMax
= endPos
;
3001 SendMsg(SCI_GETTEXTRANGE
, 0, (long)&tr
);
3005 void wxStyledTextCtrl::SetTextRaw(const char* text
)
3007 SendMsg(SCI_SETTEXT
, 0, (long)text
);
3010 wxCharBuffer
wxStyledTextCtrl::GetTextRaw()
3012 int len
= GetTextLength();
3013 wxCharBuffer
buf(len
);
3014 SendMsg(SCI_GETTEXT
, len
, (long)buf
.data());
3018 void wxStyledTextCtrl::AppendTextRaw(const char* text
)
3020 SendMsg(SCI_APPENDTEXT
, strlen(text
), (long)text
);
3027 //----------------------------------------------------------------------
3030 void wxStyledTextCtrl::OnPaint(wxPaintEvent
& WXUNUSED(evt
)) {
3032 m_swx
->DoPaint(&dc
, GetUpdateRegion().GetBox());
3035 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent
& evt
) {
3036 if (evt
.GetOrientation() == wxHORIZONTAL
)
3037 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
3039 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
3042 void wxStyledTextCtrl::OnScroll(wxScrollEvent
& evt
) {
3043 wxScrollBar
* sb
= wxDynamicCast(evt
.GetEventObject(), wxScrollBar
);
3045 if (sb
->IsVertical())
3046 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
3048 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
3052 void wxStyledTextCtrl::OnSize(wxSizeEvent
& WXUNUSED(evt
)) {
3054 wxSize sz
= GetClientSize();
3055 m_swx
->DoSize(sz
.x
, sz
.y
);
3059 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent
& evt
) {
3061 wxPoint pt
= evt
.GetPosition();
3062 m_swx
->DoLeftButtonDown(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
3063 evt
.ShiftDown(), evt
.ControlDown(), evt
.AltDown());
3066 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent
& evt
) {
3067 wxPoint pt
= evt
.GetPosition();
3068 m_swx
->DoLeftButtonMove(Point(pt
.x
, pt
.y
));
3071 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent
& evt
) {
3072 wxPoint pt
= evt
.GetPosition();
3073 m_swx
->DoLeftButtonUp(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
3078 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent
& evt
) {
3079 wxPoint pt
= evt
.GetPosition();
3080 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
3084 void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent
& evt
) {
3085 wxPoint pt
= evt
.GetPosition();
3086 m_swx
->DoMiddleButtonUp(Point(pt
.x
, pt
.y
));
3089 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent
& evt
) {
3090 wxPoint pt
= evt
.GetPosition();
3091 ScreenToClient(&pt
.x
, &pt
.y
);
3093 Show context menu at event point if it's within the window,
3094 or at caret location if not
3096 wxHitTest ht
= this->HitTest(pt
);
3097 if (ht
!= wxHT_WINDOW_INSIDE
) {
3098 pt
= this->PointFromPosition(this->GetCurrentPos());
3100 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
3104 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent
& evt
) {
3105 m_swx
->DoMouseWheel(evt
.GetWheelRotation(),
3106 evt
.GetWheelDelta(),
3107 evt
.GetLinesPerAction(),
3109 evt
.IsPageScroll());
3113 void wxStyledTextCtrl::OnChar(wxKeyEvent
& evt
) {
3114 // On (some?) non-US PC keyboards the AltGr key is required to enter some
3115 // common characters. It comes to us as both Alt and Ctrl down so we need
3116 // to let the char through in that case, otherwise if only ctrl or only
3117 // alt let's skip it.
3118 bool ctrl
= evt
.ControlDown();
3120 // On the Mac the Alt key is just a modifier key (like Shift) so we need
3121 // to allow the char events to be processed when Alt is pressed.
3122 // TODO: Should we check MetaDown instead in this case?
3125 bool alt
= evt
.AltDown();
3127 bool skip
= ((ctrl
|| alt
) && ! (ctrl
&& alt
));
3130 // apparently if we don't do this, Unicode keys pressed after non-char
3131 // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989)
3132 if (m_lastKeyDownConsumed
&& evt
.GetUnicodeKey() > 255)
3133 m_lastKeyDownConsumed
= false;
3136 if (!m_lastKeyDownConsumed
&& !skip
) {
3138 int key
= evt
.GetUnicodeKey();
3141 // if the unicode key code is not really a unicode character (it may
3142 // be a function key or etc., the platforms appear to always give us a
3143 // small value in this case) then fallback to the ascii key code but
3144 // don't do anything for function keys or etc.
3146 key
= evt
.GetKeyCode();
3147 keyOk
= (key
<= 127);
3150 m_swx
->DoAddChar(key
);
3154 int key
= evt
.GetKeyCode();
3155 if (key
<= WXK_START
|| key
> WXK_COMMAND
) {
3156 m_swx
->DoAddChar(key
);
3166 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent
& evt
) {
3167 int processed
= m_swx
->DoKeyDown(evt
, &m_lastKeyDownConsumed
);
3168 if (!processed
&& !m_lastKeyDownConsumed
)
3173 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent
& evt
) {
3174 m_swx
->DoLoseFocus();
3179 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent
& evt
) {
3180 m_swx
->DoGainFocus();
3185 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent
& WXUNUSED(evt
)) {
3186 m_swx
->DoSysColourChange();
3190 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent
& WXUNUSED(evt
)) {
3191 // do nothing to help avoid flashing
3196 void wxStyledTextCtrl::OnMenu(wxCommandEvent
& evt
) {
3197 m_swx
->DoCommand(evt
.GetId());
3201 void wxStyledTextCtrl::OnListBox(wxCommandEvent
& WXUNUSED(evt
)) {
3202 m_swx
->DoOnListBox();
3206 void wxStyledTextCtrl::OnIdle(wxIdleEvent
& evt
) {
3207 m_swx
->DoOnIdle(evt
);
3211 wxSize
wxStyledTextCtrl::DoGetBestSize() const
3213 // What would be the best size for a wxSTC?
3214 // Just give a reasonable minimum until something else can be figured out.
3215 return wxSize(200,100);
3219 //----------------------------------------------------------------------
3220 // Turn notifications from Scintilla into events
3223 void wxStyledTextCtrl::NotifyChange() {
3224 wxStyledTextEvent
evt(wxEVT_STC_CHANGE
, GetId());
3225 evt
.SetEventObject(this);
3226 GetEventHandler()->ProcessEvent(evt
);
3230 static void SetEventText(wxStyledTextEvent
& evt
, const char* text
,
3234 evt
.SetText(stc2wx(text
, length
));
3238 void wxStyledTextCtrl::NotifyParent(SCNotification
* _scn
) {
3239 SCNotification
& scn
= *_scn
;
3240 wxStyledTextEvent
evt(0, GetId());
3242 evt
.SetEventObject(this);
3243 evt
.SetPosition(scn
.position
);
3245 evt
.SetModifiers(scn
.modifiers
);
3247 switch (scn
.nmhdr
.code
) {
3248 case SCN_STYLENEEDED
:
3249 evt
.SetEventType(wxEVT_STC_STYLENEEDED
);
3253 evt
.SetEventType(wxEVT_STC_CHARADDED
);
3256 case SCN_SAVEPOINTREACHED
:
3257 evt
.SetEventType(wxEVT_STC_SAVEPOINTREACHED
);
3260 case SCN_SAVEPOINTLEFT
:
3261 evt
.SetEventType(wxEVT_STC_SAVEPOINTLEFT
);
3264 case SCN_MODIFYATTEMPTRO
:
3265 evt
.SetEventType(wxEVT_STC_ROMODIFYATTEMPT
);
3269 evt
.SetEventType(wxEVT_STC_KEY
);
3272 case SCN_DOUBLECLICK
:
3273 evt
.SetEventType(wxEVT_STC_DOUBLECLICK
);
3277 evt
.SetEventType(wxEVT_STC_UPDATEUI
);
3281 evt
.SetEventType(wxEVT_STC_MODIFIED
);
3282 evt
.SetModificationType(scn
.modificationType
);
3283 SetEventText(evt
, scn
.text
, scn
.length
);
3284 evt
.SetLength(scn
.length
);
3285 evt
.SetLinesAdded(scn
.linesAdded
);
3286 evt
.SetLine(scn
.line
);
3287 evt
.SetFoldLevelNow(scn
.foldLevelNow
);
3288 evt
.SetFoldLevelPrev(scn
.foldLevelPrev
);
3291 case SCN_MACRORECORD
:
3292 evt
.SetEventType(wxEVT_STC_MACRORECORD
);
3293 evt
.SetMessage(scn
.message
);
3294 evt
.SetWParam(scn
.wParam
);
3295 evt
.SetLParam(scn
.lParam
);
3298 case SCN_MARGINCLICK
:
3299 evt
.SetEventType(wxEVT_STC_MARGINCLICK
);
3300 evt
.SetMargin(scn
.margin
);
3304 evt
.SetEventType(wxEVT_STC_NEEDSHOWN
);
3305 evt
.SetLength(scn
.length
);
3309 evt
.SetEventType(wxEVT_STC_PAINTED
);
3312 case SCN_AUTOCSELECTION
:
3313 evt
.SetEventType(wxEVT_STC_AUTOCOMP_SELECTION
);
3314 evt
.SetListType(scn
.listType
);
3315 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
3316 evt
.SetPosition(scn
.lParam
);
3319 case SCN_USERLISTSELECTION
:
3320 evt
.SetEventType(wxEVT_STC_USERLISTSELECTION
);
3321 evt
.SetListType(scn
.listType
);
3322 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
3323 evt
.SetPosition(scn
.lParam
);
3326 case SCN_URIDROPPED
:
3327 evt
.SetEventType(wxEVT_STC_URIDROPPED
);
3328 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
3331 case SCN_DWELLSTART
:
3332 evt
.SetEventType(wxEVT_STC_DWELLSTART
);
3338 evt
.SetEventType(wxEVT_STC_DWELLEND
);
3344 evt
.SetEventType(wxEVT_STC_ZOOM
);
3347 case SCN_HOTSPOTCLICK
:
3348 evt
.SetEventType(wxEVT_STC_HOTSPOT_CLICK
);
3351 case SCN_HOTSPOTDOUBLECLICK
:
3352 evt
.SetEventType(wxEVT_STC_HOTSPOT_DCLICK
);
3355 case SCN_CALLTIPCLICK
:
3356 evt
.SetEventType(wxEVT_STC_CALLTIP_CLICK
);
3363 GetEventHandler()->ProcessEvent(evt
);
3367 //----------------------------------------------------------------------
3368 //----------------------------------------------------------------------
3369 //----------------------------------------------------------------------
3371 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType
, int id
)
3372 : wxCommandEvent(commandType
, id
)
3377 m_modificationType
= 0;
3382 m_foldLevelPrev
= 0;
3390 m_dragAllowMove
= false;
3391 #if wxUSE_DRAG_AND_DROP
3392 m_dragResult
= wxDragNone
;
3396 bool wxStyledTextEvent::GetShift() const { return (m_modifiers
& SCI_SHIFT
) != 0; }
3397 bool wxStyledTextEvent::GetControl() const { return (m_modifiers
& SCI_CTRL
) != 0; }
3398 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers
& SCI_ALT
) != 0; }
3401 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent
& event
):
3402 wxCommandEvent(event
)
3404 m_position
= event
.m_position
;
3405 m_key
= event
.m_key
;
3406 m_modifiers
= event
.m_modifiers
;
3407 m_modificationType
= event
.m_modificationType
;
3408 m_text
= event
.m_text
;
3409 m_length
= event
.m_length
;
3410 m_linesAdded
= event
.m_linesAdded
;
3411 m_line
= event
.m_line
;
3412 m_foldLevelNow
= event
.m_foldLevelNow
;
3413 m_foldLevelPrev
= event
.m_foldLevelPrev
;
3415 m_margin
= event
.m_margin
;
3417 m_message
= event
.m_message
;
3418 m_wParam
= event
.m_wParam
;
3419 m_lParam
= event
.m_lParam
;
3421 m_listType
= event
.m_listType
;
3425 m_dragText
= event
.m_dragText
;
3426 m_dragAllowMove
=event
.m_dragAllowMove
;
3427 #if wxUSE_DRAG_AND_DROP
3428 m_dragResult
= event
.m_dragResult
;
3432 //----------------------------------------------------------------------
3433 //----------------------------------------------------------------------