1 ////////////////////////////////////////////////////////////////////////////
2 // Name: stc.cpp
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.
9 //
10 // Author: Robin Dunn
11 //
12 // Created: 13-Jan-2000
13 // Copyright: (c) 2000 by Total Control Software
14 // Licence: wxWindows licence
15 /////////////////////////////////////////////////////////////////////////////
16
17 /*
18 IMPORTANT: src/stc/stc.cpp is generated by src/stc/gen_iface.py from
19 src/stc/stc.cpp.in, don't edit stc.cpp file as your changes will be
20 lost after the next regeneration, edit stc.cpp.in and rerun the
21 gen_iface.py script instead!
22
23 Parts of this file generated by the script are found in between
24 the special "{{{" and "}}}" markers, the rest of it is copied
25 verbatim from src.h.in.
26 */
27
28 // For compilers that support precompilation, includes "wx.h".
29 #include "wx/wxprec.h"
30
31
32 #if wxUSE_STC
33
34 #include "wx/stc/stc.h"
35 #include "wx/stc/private.h"
36
37 #ifndef WX_PRECOMP
38 #include "wx/wx.h"
39 #endif // WX_PRECOMP
40
41 #include <ctype.h>
42
43 #include "wx/tokenzr.h"
44 #include "wx/mstream.h"
45 #include "wx/image.h"
46 #include "wx/vlbox.h"
47 #include "wx/stack.h"
48 #if wxUSE_FFILE
49 #include "wx/ffile.h"
50 #elif wxUSE_FILE
51 #include "wx/file.h"
52 #endif
53
54 #include "wx/dcbuffer.h"
55
56 #include "ScintillaWX.h"
57
58 //----------------------------------------------------------------------
59
60 const char wxSTCNameStr[] = "stcwindow";
61
62 #ifdef MAKELONG
63 #undef MAKELONG
64 #endif
65
66 #define MAKELONG(a, b) ((a) | ((b) << 16))
67
68
wxColourAsLong(const wxColour & co)69 static long wxColourAsLong(const wxColour& co) {
70 return (((long)co.Blue() << 16) |
71 ((long)co.Green() << 8) |
72 ((long)co.Red()));
73 }
74
wxColourFromLong(long c)75 static wxColour wxColourFromLong(long c) {
76 wxColour clr;
77 clr.Set((unsigned char)(c & 0xff),
78 (unsigned char)((c >> 8) & 0xff),
79 (unsigned char)((c >> 16) & 0xff));
80 return clr;
81 }
82
83
wxColourFromSpec(const wxString & spec)84 static wxColour wxColourFromSpec(const wxString& spec) {
85 // spec should be a colour name or "#RRGGBB"
86 if (spec.GetChar(0) == wxT('#')) {
87
88 long red, green, blue;
89 red = green = blue = 0;
90 spec.Mid(1,2).ToLong(&red, 16);
91 spec.Mid(3,2).ToLong(&green, 16);
92 spec.Mid(5,2).ToLong(&blue, 16);
93 return wxColour((unsigned char)red,
94 (unsigned char)green,
95 (unsigned char)blue);
96 }
97 else
98 return wxColour(spec);
99 }
100
101 //----------------------------------------------------------------------
102
103 wxDEFINE_EVENT( wxEVT_STC_CHANGE, wxStyledTextEvent );
104 wxDEFINE_EVENT( wxEVT_STC_STYLENEEDED, wxStyledTextEvent );
105 wxDEFINE_EVENT( wxEVT_STC_CHARADDED, wxStyledTextEvent );
106 wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTREACHED, wxStyledTextEvent );
107 wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTLEFT, wxStyledTextEvent );
108 wxDEFINE_EVENT( wxEVT_STC_ROMODIFYATTEMPT, wxStyledTextEvent );
109 wxDEFINE_EVENT( wxEVT_STC_KEY, wxStyledTextEvent );
110 wxDEFINE_EVENT( wxEVT_STC_DOUBLECLICK, wxStyledTextEvent );
111 wxDEFINE_EVENT( wxEVT_STC_UPDATEUI, wxStyledTextEvent );
112 wxDEFINE_EVENT( wxEVT_STC_MODIFIED, wxStyledTextEvent );
113 wxDEFINE_EVENT( wxEVT_STC_MACRORECORD, wxStyledTextEvent );
114 wxDEFINE_EVENT( wxEVT_STC_MARGINCLICK, wxStyledTextEvent );
115 wxDEFINE_EVENT( wxEVT_STC_NEEDSHOWN, wxStyledTextEvent );
116 wxDEFINE_EVENT( wxEVT_STC_PAINTED, wxStyledTextEvent );
117 wxDEFINE_EVENT( wxEVT_STC_USERLISTSELECTION, wxStyledTextEvent );
118 wxDEFINE_EVENT( wxEVT_STC_URIDROPPED, wxStyledTextEvent );
119 wxDEFINE_EVENT( wxEVT_STC_DWELLSTART, wxStyledTextEvent );
120 wxDEFINE_EVENT( wxEVT_STC_DWELLEND, wxStyledTextEvent );
121 wxDEFINE_EVENT( wxEVT_STC_START_DRAG, wxStyledTextEvent );
122 wxDEFINE_EVENT( wxEVT_STC_DRAG_OVER, wxStyledTextEvent );
123 wxDEFINE_EVENT( wxEVT_STC_DO_DROP, wxStyledTextEvent );
124 wxDEFINE_EVENT( wxEVT_STC_ZOOM, wxStyledTextEvent );
125 wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_CLICK, wxStyledTextEvent );
126 wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_DCLICK, wxStyledTextEvent );
127 wxDEFINE_EVENT( wxEVT_STC_CALLTIP_CLICK, wxStyledTextEvent );
128 wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_SELECTION, wxStyledTextEvent );
129 wxDEFINE_EVENT( wxEVT_STC_INDICATOR_CLICK, wxStyledTextEvent );
130 wxDEFINE_EVENT( wxEVT_STC_INDICATOR_RELEASE, wxStyledTextEvent );
131 wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CANCELLED, wxStyledTextEvent );
132 wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CHAR_DELETED, wxStyledTextEvent );
133 wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_RELEASE_CLICK, wxStyledTextEvent );
134 wxDEFINE_EVENT( wxEVT_STC_CLIPBOARD_COPY, wxStyledTextEvent );
135 wxDEFINE_EVENT( wxEVT_STC_CLIPBOARD_PASTE, wxStyledTextEvent );
136 wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_COMPLETED, wxStyledTextEvent );
137 wxDEFINE_EVENT( wxEVT_STC_MARGIN_RIGHT_CLICK, wxStyledTextEvent );
138 wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_SELECTION_CHANGE, wxStyledTextEvent );
139
140
141 wxBEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
142 EVT_PAINT (wxStyledTextCtrl::OnPaint)
143 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin)
144 EVT_SCROLL (wxStyledTextCtrl::OnScroll)
145 EVT_SIZE (wxStyledTextCtrl::OnSize)
146 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
147 EVT_RIGHT_DOWN (wxStyledTextCtrl::OnMouseRightDown)
148 // Let Scintilla see the double click as a second click
149 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
150 EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
151 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
152 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
153 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
154 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp)
155 EVT_CHAR (wxStyledTextCtrl::OnChar)
156 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
157 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
158 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus)
159 EVT_DPI_CHANGED (wxStyledTextCtrl::OnDPIChanged)
160 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
161 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
162 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu)
163 EVT_LISTBOX_DCLICK (wxID_ANY, wxStyledTextCtrl::OnListBox)
164 EVT_MOUSE_CAPTURE_LOST (wxStyledTextCtrl::OnMouseCaptureLost)
165 wxEND_EVENT_TABLE()
166
167
168 wxIMPLEMENT_CLASS(wxStyledTextCtrl, wxControl);
169 wxIMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent);
170
171 #ifdef LINK_LEXERS
172 // forces the linking of the lexer modules
173 int Scintilla_LinkLexers();
174 #endif
175
176 //----------------------------------------------------------------------
177 // Constructor and Destructor
178
wxStyledTextCtrl(wxWindow * parent,wxWindowID id,const wxPoint & pos,const wxSize & size,long style,const wxString & name)179 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
180 wxWindowID id,
181 const wxPoint& pos,
182 const wxSize& size,
183 long style,
184 const wxString& name)
185 {
186 m_swx = NULL;
187 Create(parent, id, pos, size, style, name);
188 }
189
190
Create(wxWindow * parent,wxWindowID id,const wxPoint & pos,const wxSize & size,long style,const wxString & name)191 bool wxStyledTextCtrl::Create(wxWindow *parent,
192 wxWindowID id,
193 const wxPoint& pos,
194 const wxSize& size,
195 long style,
196 const wxString& name)
197 {
198 style |= wxVSCROLL | wxHSCROLL;
199 if (!wxControl::Create(parent, id, pos, size,
200 style | wxWANTS_CHARS | wxCLIP_CHILDREN,
201 wxDefaultValidator, name))
202 return false;
203
204 #ifdef LINK_LEXERS
205 Scintilla_LinkLexers();
206 #endif
207 m_swx = new ScintillaWX(this);
208 m_stopWatch.Start();
209 m_lastKeyDownConsumed = false;
210 m_vScrollBar = NULL;
211 m_hScrollBar = NULL;
212 #if wxUSE_UNICODE
213 // Put Scintilla into unicode (UTF-8) mode
214 SetCodePage(wxSTC_CP_UTF8);
215 #endif
216
217 SetInitialSize(size);
218
219 // Reduces flicker on GTK+/X11
220 SetBackgroundStyle(wxBG_STYLE_PAINT);
221
222 // Make sure it can take the focus
223 SetCanFocus(true);
224
225 // STC doesn't support RTL languages at all
226 SetLayoutDirection(wxLayout_LeftToRight);
227
228 // Rely on native double buffering by default, except under Mac where it
229 // doesn't work for some reason, see #18085.
230 #if wxALWAYS_NATIVE_DOUBLE_BUFFER && !defined(__WXMAC__)
231 SetBufferedDraw(false);
232 #else
233 SetBufferedDraw(true);
234 #endif
235
236 #if wxUSE_GRAPHICS_DIRECT2D
237 SetFontQuality(wxSTC_EFF_QUALITY_DEFAULT);
238 #endif
239
240 return true;
241 }
242
243
~wxStyledTextCtrl()244 wxStyledTextCtrl::~wxStyledTextCtrl() {
245 delete m_swx;
246 }
247
248
249 //----------------------------------------------------------------------
250
SendMsg(int msg,wxUIntPtr wp,wxIntPtr lp) const251 wxIntPtr wxStyledTextCtrl::SendMsg(int msg, wxUIntPtr wp, wxIntPtr lp) const
252 {
253 return m_swx->WndProc(msg, wp, lp);
254 }
255
256 //----------------------------------------------------------------------
257
258 // Set the vertical scrollbar to use instead of the one that's built-in.
SetVScrollBar(wxScrollBar * bar)259 void wxStyledTextCtrl::SetVScrollBar(wxScrollBar* bar) {
260 m_vScrollBar = bar;
261 if (bar != NULL) {
262 // ensure that the built-in scrollbar is not visible
263 SetScrollbar(wxVERTICAL, 0, 0, 0);
264 }
265 }
266
267
268 // Set the horizontal scrollbar to use instead of the one that's built-in.
SetHScrollBar(wxScrollBar * bar)269 void wxStyledTextCtrl::SetHScrollBar(wxScrollBar* bar) {
270 m_hScrollBar = bar;
271 if (bar != NULL) {
272 // ensure that the built-in scrollbar is not visible
273 SetScrollbar(wxHORIZONTAL, 0, 0, 0);
274 }
275 }
276
277 //----------------------------------------------------------------------
278 // Generated methods implementation section {{{
279
280
281 // Add text to the document at current position.
AddText(const wxString & text)282 void wxStyledTextCtrl::AddText(const wxString& text) {
283 const wxWX2MBbuf buf = wx2stc(text);
284 SendMsg(SCI_ADDTEXT, wx2stclen(text, buf), (sptr_t)(const char*)buf);
285 }
286
287 // Add array of cells to document.
AddStyledText(const wxMemoryBuffer & data)288 void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer& data) {
289 SendMsg(SCI_ADDSTYLEDTEXT, data.GetDataLen(), (sptr_t)data.GetData());
290 }
291
292 // Insert string at a position.
InsertText(int pos,const wxString & text)293 void wxStyledTextCtrl::InsertText(int pos, const wxString& text)
294 {
295 SendMsg(SCI_INSERTTEXT, pos, (sptr_t)(const char*)wx2stc(text));
296 }
297
298 // Change the text that is being inserted in response to wxSTC_MOD_INSERTCHECK
ChangeInsertion(int length,const wxString & text)299 void wxStyledTextCtrl::ChangeInsertion(int length, const wxString& text)
300 {
301 SendMsg(SCI_CHANGEINSERTION, length, (sptr_t)(const char*)wx2stc(text));
302 }
303
304 // Delete all text in the document.
ClearAll()305 void wxStyledTextCtrl::ClearAll()
306 {
307 SendMsg(SCI_CLEARALL, 0, 0);
308 }
309
310 // Delete a range of text in the document.
DeleteRange(int start,int lengthDelete)311 void wxStyledTextCtrl::DeleteRange(int start, int lengthDelete)
312 {
313 SendMsg(SCI_DELETERANGE, start, lengthDelete);
314 }
315
316 // Set all style bytes to 0, remove all folding information.
ClearDocumentStyle()317 void wxStyledTextCtrl::ClearDocumentStyle()
318 {
319 SendMsg(SCI_CLEARDOCUMENTSTYLE, 0, 0);
320 }
321
322 // Returns the number of bytes in the document.
GetLength() const323 int wxStyledTextCtrl::GetLength() const
324 {
325 return SendMsg(SCI_GETLENGTH, 0, 0);
326 }
327
328 // Returns the character byte at the position.
GetCharAt(int pos) const329 int wxStyledTextCtrl::GetCharAt(int pos) const {
330 return (unsigned char)SendMsg(SCI_GETCHARAT, pos, 0);
331 }
332
333 // Returns the position of the caret.
GetCurrentPos() const334 int wxStyledTextCtrl::GetCurrentPos() const
335 {
336 return SendMsg(SCI_GETCURRENTPOS, 0, 0);
337 }
338
339 // Returns the position of the opposite end of the selection to the caret.
GetAnchor() const340 int wxStyledTextCtrl::GetAnchor() const
341 {
342 return SendMsg(SCI_GETANCHOR, 0, 0);
343 }
344
345 // Returns the style byte at the position.
GetStyleAt(int pos) const346 int wxStyledTextCtrl::GetStyleAt(int pos) const {
347 return (unsigned char)SendMsg(SCI_GETSTYLEAT, pos, 0);
348 }
349
350 // Redoes the next action on the undo history.
Redo()351 void wxStyledTextCtrl::Redo()
352 {
353 SendMsg(SCI_REDO, 0, 0);
354 }
355
356 // Choose between collecting actions into the undo
357 // history and discarding them.
SetUndoCollection(bool collectUndo)358 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo)
359 {
360 SendMsg(SCI_SETUNDOCOLLECTION, collectUndo, 0);
361 }
362
363 // Select all the text in the document.
SelectAll()364 void wxStyledTextCtrl::SelectAll()
365 {
366 SendMsg(SCI_SELECTALL, 0, 0);
367 }
368
369 // Remember the current position in the undo history as the position
370 // at which the document was saved.
SetSavePoint()371 void wxStyledTextCtrl::SetSavePoint()
372 {
373 SendMsg(SCI_SETSAVEPOINT, 0, 0);
374 }
375
376 // Retrieve a buffer of cells.
GetStyledText(int startPos,int endPos)377 wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) {
378 wxMemoryBuffer buf;
379 if (endPos < startPos) {
380 wxSwap(startPos, endPos);
381 }
382 int len = endPos - startPos;
383 if (!len) return buf;
384 Sci_TextRange tr;
385 tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
386 tr.chrg.cpMin = startPos;
387 tr.chrg.cpMax = endPos;
388 len = SendMsg(SCI_GETSTYLEDTEXT, 0, (sptr_t)&tr);
389 buf.UngetWriteBuf(len);
390 return buf;
391 }
392
393 // Are there any redoable actions in the undo history?
CanRedo() const394 bool wxStyledTextCtrl::CanRedo() const
395 {
396 return SendMsg(SCI_CANREDO, 0, 0) != 0;
397 }
398
399 // Retrieve the line number at which a particular marker is located.
MarkerLineFromHandle(int markerHandle)400 int wxStyledTextCtrl::MarkerLineFromHandle(int markerHandle)
401 {
402 return SendMsg(SCI_MARKERLINEFROMHANDLE, markerHandle, 0);
403 }
404
405 // Delete a marker.
MarkerDeleteHandle(int markerHandle)406 void wxStyledTextCtrl::MarkerDeleteHandle(int markerHandle)
407 {
408 SendMsg(SCI_MARKERDELETEHANDLE, markerHandle, 0);
409 }
410
411 // Is undo history being collected?
GetUndoCollection() const412 bool wxStyledTextCtrl::GetUndoCollection() const
413 {
414 return SendMsg(SCI_GETUNDOCOLLECTION, 0, 0) != 0;
415 }
416
417 // Are white space characters currently visible?
418 // Returns one of wxSTC_WS_* constants.
GetViewWhiteSpace() const419 int wxStyledTextCtrl::GetViewWhiteSpace() const
420 {
421 return SendMsg(SCI_GETVIEWWS, 0, 0);
422 }
423
424 // Make white space characters invisible, always visible or visible outside indentation.
SetViewWhiteSpace(int viewWS)425 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS)
426 {
427 SendMsg(SCI_SETVIEWWS, viewWS, 0);
428 }
429
430 // Retrieve the current tab draw mode.
431 // Returns one of wxSTC_TD_* constants.
GetTabDrawMode() const432 int wxStyledTextCtrl::GetTabDrawMode() const
433 {
434 return SendMsg(SCI_GETTABDRAWMODE, 0, 0);
435 }
436
437 // Set how tabs are drawn when visible.
SetTabDrawMode(int tabDrawMode)438 void wxStyledTextCtrl::SetTabDrawMode(int tabDrawMode)
439 {
440 SendMsg(SCI_SETTABDRAWMODE, tabDrawMode, 0);
441 }
442
443 // Find the position from a point within the window.
PositionFromPoint(wxPoint pt) const444 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) const {
445 return SendMsg(SCI_POSITIONFROMPOINT, pt.x, pt.y);
446 }
447
448 // Find the position from a point within the window but return
449 // wxSTC_INVALID_POSITION if not close to text.
PositionFromPointClose(int x,int y)450 int wxStyledTextCtrl::PositionFromPointClose(int x, int y)
451 {
452 return SendMsg(SCI_POSITIONFROMPOINTCLOSE, x, y);
453 }
454
455 // Set caret to start of a line and ensure it is visible.
GotoLine(int line)456 void wxStyledTextCtrl::GotoLine(int line)
457 {
458 SendMsg(SCI_GOTOLINE, line, 0);
459 }
460
461 // Set caret to a position and ensure it is visible.
GotoPos(int caret)462 void wxStyledTextCtrl::GotoPos(int caret)
463 {
464 SendMsg(SCI_GOTOPOS, caret, 0);
465 }
466
467 // Set the selection anchor to a position. The anchor is the opposite
468 // end of the selection from the caret.
SetAnchor(int anchor)469 void wxStyledTextCtrl::SetAnchor(int anchor)
470 {
471 SendMsg(SCI_SETANCHOR, anchor, 0);
472 }
473
474 // Retrieve the text of the line containing the caret.
GetCurLine(int * linePos)475 wxString wxStyledTextCtrl::GetCurLine(int* linePos) {
476 int len = LineLength(GetCurrentLine());
477 if (!len) {
478 if (linePos) *linePos = 0;
479 return wxEmptyString;
480 }
481
482 wxCharBuffer buf(len);
483 int pos = SendMsg(SCI_GETCURLINE, len+1, (sptr_t)buf.data());
484 if (linePos) *linePos = pos;
485 return stc2wx(buf);
486 }
487
488 // Retrieve the position of the last correctly styled character.
GetEndStyled() const489 int wxStyledTextCtrl::GetEndStyled() const
490 {
491 return SendMsg(SCI_GETENDSTYLED, 0, 0);
492 }
493
494 // Convert all line endings in the document to one mode.
ConvertEOLs(int eolMode)495 void wxStyledTextCtrl::ConvertEOLs(int eolMode)
496 {
497 SendMsg(SCI_CONVERTEOLS, eolMode, 0);
498 }
499
500 // Retrieve the current end of line mode - one of wxSTC_EOL_CRLF, wxSTC_EOL_CR, or wxSTC_EOL_LF.
GetEOLMode() const501 int wxStyledTextCtrl::GetEOLMode() const
502 {
503 return SendMsg(SCI_GETEOLMODE, 0, 0);
504 }
505
506 // Set the current end of line mode.
SetEOLMode(int eolMode)507 void wxStyledTextCtrl::SetEOLMode(int eolMode)
508 {
509 SendMsg(SCI_SETEOLMODE, eolMode, 0);
510 }
511
512 // Set the current styling position to start.
StartStyling(int start)513 void wxStyledTextCtrl::StartStyling(int start) {
514 SendMsg(SCI_STARTSTYLING, start, 0);
515 }
516
517 // Change style from current styling position for length characters to a style
518 // and move the current styling position to after this newly styled segment.
SetStyling(int length,int style)519 void wxStyledTextCtrl::SetStyling(int length, int style)
520 {
521 SendMsg(SCI_SETSTYLING, length, style);
522 }
523
524 // Is drawing done first into a buffer or direct to the screen?
GetBufferedDraw() const525 bool wxStyledTextCtrl::GetBufferedDraw() const
526 {
527 return SendMsg(SCI_GETBUFFEREDDRAW, 0, 0) != 0;
528 }
529
530 // If drawing is buffered then each line of text is drawn into a bitmap buffer
531 // before drawing it to the screen to avoid flicker.
SetBufferedDraw(bool buffered)532 void wxStyledTextCtrl::SetBufferedDraw(bool buffered)
533 {
534 SendMsg(SCI_SETBUFFEREDDRAW, buffered, 0);
535 }
536
537 // Change the visible size of a tab to be a multiple of the width of a space character.
SetTabWidth(int tabWidth)538 void wxStyledTextCtrl::SetTabWidth(int tabWidth)
539 {
540 SendMsg(SCI_SETTABWIDTH, tabWidth, 0);
541 }
542
543 // Retrieve the visible size of a tab.
GetTabWidth() const544 int wxStyledTextCtrl::GetTabWidth() const
545 {
546 return SendMsg(SCI_GETTABWIDTH, 0, 0);
547 }
548
549 // Clear explicit tabstops on a line.
ClearTabStops(int line)550 void wxStyledTextCtrl::ClearTabStops(int line)
551 {
552 SendMsg(SCI_CLEARTABSTOPS, line, 0);
553 }
554
555 // Add an explicit tab stop for a line.
AddTabStop(int line,int x)556 void wxStyledTextCtrl::AddTabStop(int line, int x)
557 {
558 SendMsg(SCI_ADDTABSTOP, line, x);
559 }
560
561 // Find the next explicit tab stop position on a line after a position.
GetNextTabStop(int line,int x)562 int wxStyledTextCtrl::GetNextTabStop(int line, int x)
563 {
564 return SendMsg(SCI_GETNEXTTABSTOP, line, x);
565 }
566
567 // Set the code page used to interpret the bytes of the document as characters.
SetCodePage(int codePage)568 void wxStyledTextCtrl::SetCodePage(int codePage) {
569 #if wxUSE_UNICODE
570 wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
571 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
572 #else
573 wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
574 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
575 #endif
576 SendMsg(SCI_SETCODEPAGE, codePage);
577 }
578
579 // Is the IME displayed in a window or inline?
GetIMEInteraction() const580 int wxStyledTextCtrl::GetIMEInteraction() const
581 {
582 return SendMsg(SCI_GETIMEINTERACTION, 0, 0);
583 }
584
585 // Choose to display the IME in a winow or inline.
SetIMEInteraction(int imeInteraction)586 void wxStyledTextCtrl::SetIMEInteraction(int imeInteraction)
587 {
588 SendMsg(SCI_SETIMEINTERACTION, imeInteraction, 0);
589 }
590
591 // Set the symbol used for a particular marker number,
592 // and optionally the fore and background colours.
MarkerDefine(int markerNumber,int markerSymbol,const wxColour & foreground,const wxColour & background)593 void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
594 const wxColour& foreground,
595 const wxColour& background) {
596
597 SendMsg(SCI_MARKERDEFINE, markerNumber, markerSymbol);
598 if (foreground.IsOk())
599 MarkerSetForeground(markerNumber, foreground);
600 if (background.IsOk())
601 MarkerSetBackground(markerNumber, background);
602 }
603
604 // Set the foreground colour used for a particular marker number.
MarkerSetForeground(int markerNumber,const wxColour & fore)605 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore)
606 {
607 SendMsg(SCI_MARKERSETFORE, markerNumber, wxColourAsLong(fore));
608 }
609
610 // Set the background colour used for a particular marker number.
MarkerSetBackground(int markerNumber,const wxColour & back)611 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back)
612 {
613 SendMsg(SCI_MARKERSETBACK, markerNumber, wxColourAsLong(back));
614 }
615
616 // Set the background colour used for a particular marker number when its folding block is selected.
MarkerSetBackgroundSelected(int markerNumber,const wxColour & back)617 void wxStyledTextCtrl::MarkerSetBackgroundSelected(int markerNumber, const wxColour& back)
618 {
619 SendMsg(SCI_MARKERSETBACKSELECTED, markerNumber, wxColourAsLong(back));
620 }
621
622 // Enable/disable highlight for current folding block (smallest one that contains the caret)
MarkerEnableHighlight(bool enabled)623 void wxStyledTextCtrl::MarkerEnableHighlight(bool enabled)
624 {
625 SendMsg(SCI_MARKERENABLEHIGHLIGHT, enabled, 0);
626 }
627
628 // Add a marker to a line, returning an ID which can be used to find or delete the marker.
MarkerAdd(int line,int markerNumber)629 int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber)
630 {
631 return SendMsg(SCI_MARKERADD, line, markerNumber);
632 }
633
634 // Delete a marker from a line.
MarkerDelete(int line,int markerNumber)635 void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber)
636 {
637 SendMsg(SCI_MARKERDELETE, line, markerNumber);
638 }
639
640 // Delete all markers with a particular number from all lines.
MarkerDeleteAll(int markerNumber)641 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber)
642 {
643 SendMsg(SCI_MARKERDELETEALL, markerNumber, 0);
644 }
645
646 // Get a bit mask of all the markers set on a line.
MarkerGet(int line)647 int wxStyledTextCtrl::MarkerGet(int line)
648 {
649 return SendMsg(SCI_MARKERGET, line, 0);
650 }
651
652 // Find the next line at or after lineStart that includes a marker in mask.
653 // Return -1 when no more lines.
MarkerNext(int lineStart,int markerMask)654 int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask)
655 {
656 return SendMsg(SCI_MARKERNEXT, lineStart, markerMask);
657 }
658
659 // Find the previous line before lineStart that includes a marker in mask.
MarkerPrevious(int lineStart,int markerMask)660 int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask)
661 {
662 return SendMsg(SCI_MARKERPREVIOUS, lineStart, markerMask);
663 }
664
665 // Define a marker from a bitmap
MarkerDefinePixmap(int markerNumber,const char * const * xpmData)666 void wxStyledTextCtrl::MarkerDefinePixmap(int markerNumber, const char* const* xpmData) {
667 SendMsg(SCI_MARKERDEFINEPIXMAP, markerNumber, (sptr_t)xpmData);
668 }
669
670 // Add a set of markers to a line.
MarkerAddSet(int line,int markerSet)671 void wxStyledTextCtrl::MarkerAddSet(int line, int markerSet)
672 {
673 SendMsg(SCI_MARKERADDSET, line, markerSet);
674 }
675
676 // Set the alpha used for a marker that is drawn in the text area, not the margin.
MarkerSetAlpha(int markerNumber,int alpha)677 void wxStyledTextCtrl::MarkerSetAlpha(int markerNumber, int alpha)
678 {
679 SendMsg(SCI_MARKERSETALPHA, markerNumber, alpha);
680 }
681
682 // Set a margin to be either numeric or symbolic.
SetMarginType(int margin,int marginType)683 void wxStyledTextCtrl::SetMarginType(int margin, int marginType)
684 {
685 SendMsg(SCI_SETMARGINTYPEN, margin, marginType);
686 }
687
688 // Retrieve the type of a margin.
GetMarginType(int margin) const689 int wxStyledTextCtrl::GetMarginType(int margin) const
690 {
691 return SendMsg(SCI_GETMARGINTYPEN, margin, 0);
692 }
693
694 // Set the width of a margin to a width expressed in pixels.
SetMarginWidth(int margin,int pixelWidth)695 void wxStyledTextCtrl::SetMarginWidth(int margin, int pixelWidth)
696 {
697 SendMsg(SCI_SETMARGINWIDTHN, margin, pixelWidth);
698 }
699
700 // Retrieve the width of a margin in pixels.
GetMarginWidth(int margin) const701 int wxStyledTextCtrl::GetMarginWidth(int margin) const
702 {
703 return SendMsg(SCI_GETMARGINWIDTHN, margin, 0);
704 }
705
706 // Set a mask that determines which markers are displayed in a margin.
SetMarginMask(int margin,int mask)707 void wxStyledTextCtrl::SetMarginMask(int margin, int mask)
708 {
709 SendMsg(SCI_SETMARGINMASKN, margin, mask);
710 }
711
712 // Retrieve the marker mask of a margin.
GetMarginMask(int margin) const713 int wxStyledTextCtrl::GetMarginMask(int margin) const
714 {
715 return SendMsg(SCI_GETMARGINMASKN, margin, 0);
716 }
717
718 // Make a margin sensitive or insensitive to mouse clicks.
SetMarginSensitive(int margin,bool sensitive)719 void wxStyledTextCtrl::SetMarginSensitive(int margin, bool sensitive)
720 {
721 SendMsg(SCI_SETMARGINSENSITIVEN, margin, sensitive);
722 }
723
724 // Retrieve the mouse click sensitivity of a margin.
GetMarginSensitive(int margin) const725 bool wxStyledTextCtrl::GetMarginSensitive(int margin) const
726 {
727 return SendMsg(SCI_GETMARGINSENSITIVEN, margin, 0) != 0;
728 }
729
730 // Set the cursor shown when the mouse is inside a margin.
SetMarginCursor(int margin,int cursor)731 void wxStyledTextCtrl::SetMarginCursor(int margin, int cursor)
732 {
733 SendMsg(SCI_SETMARGINCURSORN, margin, cursor);
734 }
735
736 // Retrieve the cursor shown in a margin.
GetMarginCursor(int margin) const737 int wxStyledTextCtrl::GetMarginCursor(int margin) const
738 {
739 return SendMsg(SCI_GETMARGINCURSORN, margin, 0);
740 }
741
742 // Set the background colour of a margin. Only visible for wxSTC_MARGIN_COLOUR.
SetMarginBackground(int margin,const wxColour & back)743 void wxStyledTextCtrl::SetMarginBackground(int margin, const wxColour& back)
744 {
745 SendMsg(SCI_SETMARGINBACKN, margin, wxColourAsLong(back));
746 }
747
748 // Retrieve the background colour of a margin
GetMarginBackground(int margin) const749 wxColour wxStyledTextCtrl::GetMarginBackground(int margin) const
750 {
751 long c = SendMsg(SCI_GETMARGINBACKN, margin, 0);
752 return wxColourFromLong(c);
753 }
754
755 // Allocate a non-standard number of margins.
SetMarginCount(int margins)756 void wxStyledTextCtrl::SetMarginCount(int margins)
757 {
758 SendMsg(SCI_SETMARGINS, margins, 0);
759 }
760
761 // How many margins are there?.
GetMarginCount() const762 int wxStyledTextCtrl::GetMarginCount() const
763 {
764 return SendMsg(SCI_GETMARGINS, 0, 0);
765 }
766
767 // Clear all the styles and make equivalent to the global default style.
StyleClearAll()768 void wxStyledTextCtrl::StyleClearAll()
769 {
770 SendMsg(SCI_STYLECLEARALL, 0, 0);
771 }
772
773 // Set the foreground colour of a style.
StyleSetForeground(int style,const wxColour & fore)774 void wxStyledTextCtrl::StyleSetForeground(int style, const wxColour& fore)
775 {
776 SendMsg(SCI_STYLESETFORE, style, wxColourAsLong(fore));
777 }
778
779 // Set the background colour of a style.
StyleSetBackground(int style,const wxColour & back)780 void wxStyledTextCtrl::StyleSetBackground(int style, const wxColour& back)
781 {
782 SendMsg(SCI_STYLESETBACK, style, wxColourAsLong(back));
783 }
784
785 // Set a style to be bold or not.
StyleSetBold(int style,bool bold)786 void wxStyledTextCtrl::StyleSetBold(int style, bool bold)
787 {
788 SendMsg(SCI_STYLESETBOLD, style, bold);
789 }
790
791 // Set a style to be italic or not.
StyleSetItalic(int style,bool italic)792 void wxStyledTextCtrl::StyleSetItalic(int style, bool italic)
793 {
794 SendMsg(SCI_STYLESETITALIC, style, italic);
795 }
796
797 // Set the size of characters of a style.
StyleSetSize(int style,int sizePoints)798 void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints)
799 {
800 SendMsg(SCI_STYLESETSIZE, style, sizePoints);
801 }
802
803 // Set the font of a style.
StyleSetFaceName(int style,const wxString & fontName)804 void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName)
805 {
806 SendMsg(SCI_STYLESETFONT, style, (sptr_t)(const char*)wx2stc(fontName));
807 }
808
809 // Set a style to have its end of line filled or not.
StyleSetEOLFilled(int style,bool eolFilled)810 void wxStyledTextCtrl::StyleSetEOLFilled(int style, bool eolFilled)
811 {
812 SendMsg(SCI_STYLESETEOLFILLED, style, eolFilled);
813 }
814
815 // Reset the default style to its state at startup
StyleResetDefault()816 void wxStyledTextCtrl::StyleResetDefault()
817 {
818 SendMsg(SCI_STYLERESETDEFAULT, 0, 0);
819 }
820
821 // Set a style to be underlined or not.
StyleSetUnderline(int style,bool underline)822 void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline)
823 {
824 SendMsg(SCI_STYLESETUNDERLINE, style, underline);
825 }
826
827 // Get the foreground colour of a style.
StyleGetForeground(int style) const828 wxColour wxStyledTextCtrl::StyleGetForeground(int style) const
829 {
830 long c = SendMsg(SCI_STYLEGETFORE, style, 0);
831 return wxColourFromLong(c);
832 }
833
834 // Get the background colour of a style.
StyleGetBackground(int style) const835 wxColour wxStyledTextCtrl::StyleGetBackground(int style) const
836 {
837 long c = SendMsg(SCI_STYLEGETBACK, style, 0);
838 return wxColourFromLong(c);
839 }
840
841 // Get is a style bold or not.
StyleGetBold(int style) const842 bool wxStyledTextCtrl::StyleGetBold(int style) const
843 {
844 return SendMsg(SCI_STYLEGETBOLD, style, 0) != 0;
845 }
846
847 // Get is a style italic or not.
StyleGetItalic(int style) const848 bool wxStyledTextCtrl::StyleGetItalic(int style) const
849 {
850 return SendMsg(SCI_STYLEGETITALIC, style, 0) != 0;
851 }
852
853 // Get the size of characters of a style.
StyleGetSize(int style) const854 int wxStyledTextCtrl::StyleGetSize(int style) const
855 {
856 return SendMsg(SCI_STYLEGETSIZE, style, 0);
857 }
858
859 // Get the font facename of a style
StyleGetFaceName(int style)860 wxString wxStyledTextCtrl::StyleGetFaceName(int style) {
861 const int msg = SCI_STYLEGETFONT;
862 long len = SendMsg(msg, style, 0);
863 if (!len) return wxEmptyString;
864
865 wxCharBuffer buf(len);
866 SendMsg(msg, style, (sptr_t)buf.data());
867 return stc2wx(buf);
868 }
869
870 // Get is a style to have its end of line filled or not.
StyleGetEOLFilled(int style) const871 bool wxStyledTextCtrl::StyleGetEOLFilled(int style) const
872 {
873 return SendMsg(SCI_STYLEGETEOLFILLED, style, 0) != 0;
874 }
875
876 // Get is a style underlined or not.
StyleGetUnderline(int style) const877 bool wxStyledTextCtrl::StyleGetUnderline(int style) const
878 {
879 return SendMsg(SCI_STYLEGETUNDERLINE, style, 0) != 0;
880 }
881
882 // Get is a style mixed case, or to force upper or lower case.
StyleGetCase(int style) const883 int wxStyledTextCtrl::StyleGetCase(int style) const
884 {
885 return SendMsg(SCI_STYLEGETCASE, style, 0);
886 }
887
888 // Get the character get of the font in a style.
StyleGetCharacterSet(int style) const889 int wxStyledTextCtrl::StyleGetCharacterSet(int style) const
890 {
891 return SendMsg(SCI_STYLEGETCHARACTERSET, style, 0);
892 }
893
894 // Get is a style visible or not.
StyleGetVisible(int style) const895 bool wxStyledTextCtrl::StyleGetVisible(int style) const
896 {
897 return SendMsg(SCI_STYLEGETVISIBLE, style, 0) != 0;
898 }
899
900 // Get is a style changeable or not (read only).
901 // Experimental feature, currently buggy.
StyleGetChangeable(int style) const902 bool wxStyledTextCtrl::StyleGetChangeable(int style) const
903 {
904 return SendMsg(SCI_STYLEGETCHANGEABLE, style, 0) != 0;
905 }
906
907 // Get is a style a hotspot or not.
StyleGetHotSpot(int style) const908 bool wxStyledTextCtrl::StyleGetHotSpot(int style) const
909 {
910 return SendMsg(SCI_STYLEGETHOTSPOT, style, 0) != 0;
911 }
912
913 // Set a style to be mixed case, or to force upper or lower case.
StyleSetCase(int style,int caseVisible)914 void wxStyledTextCtrl::StyleSetCase(int style, int caseVisible)
915 {
916 SendMsg(SCI_STYLESETCASE, style, caseVisible);
917 }
918
919 // Set the size of characters of a style. Size is in points multiplied by 100.
StyleSetSizeFractional(int style,int sizeHundredthPoints)920 void wxStyledTextCtrl::StyleSetSizeFractional(int style, int sizeHundredthPoints)
921 {
922 SendMsg(SCI_STYLESETSIZEFRACTIONAL, style, sizeHundredthPoints);
923 }
924
925 // Get the size of characters of a style in points multiplied by 100
StyleGetSizeFractional(int style) const926 int wxStyledTextCtrl::StyleGetSizeFractional(int style) const
927 {
928 return SendMsg(SCI_STYLEGETSIZEFRACTIONAL, style, 0);
929 }
930
931 // Set the weight of characters of a style.
StyleSetWeight(int style,int weight)932 void wxStyledTextCtrl::StyleSetWeight(int style, int weight)
933 {
934 SendMsg(SCI_STYLESETWEIGHT, style, weight);
935 }
936
937 // Get the weight of characters of a style.
StyleGetWeight(int style) const938 int wxStyledTextCtrl::StyleGetWeight(int style) const
939 {
940 return SendMsg(SCI_STYLEGETWEIGHT, style, 0);
941 }
942
943 // Set the character set of the font in a style.
StyleSetCharacterSet(int style,int characterSet)944 void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet) {
945 wxFontEncoding encoding;
946
947 // Translate the Scintilla characterSet to a wxFontEncoding
948 switch (characterSet) {
949 default:
950 case wxSTC_CHARSET_ANSI:
951 case wxSTC_CHARSET_DEFAULT:
952 encoding = wxFONTENCODING_DEFAULT;
953 break;
954
955 case wxSTC_CHARSET_BALTIC:
956 encoding = wxFONTENCODING_ISO8859_13;
957 break;
958
959 case wxSTC_CHARSET_CHINESEBIG5:
960 encoding = wxFONTENCODING_CP950;
961 break;
962
963 case wxSTC_CHARSET_EASTEUROPE:
964 encoding = wxFONTENCODING_ISO8859_2;
965 break;
966
967 case wxSTC_CHARSET_GB2312:
968 encoding = wxFONTENCODING_CP936;
969 break;
970
971 case wxSTC_CHARSET_GREEK:
972 encoding = wxFONTENCODING_ISO8859_7;
973 break;
974
975 case wxSTC_CHARSET_HANGUL:
976 encoding = wxFONTENCODING_CP949;
977 break;
978
979 case wxSTC_CHARSET_MAC:
980 encoding = wxFONTENCODING_DEFAULT;
981 break;
982
983 case wxSTC_CHARSET_OEM:
984 encoding = wxFONTENCODING_DEFAULT;
985 break;
986
987 case wxSTC_CHARSET_RUSSIAN:
988 encoding = wxFONTENCODING_KOI8;
989 break;
990
991 case wxSTC_CHARSET_SHIFTJIS:
992 encoding = wxFONTENCODING_CP932;
993 break;
994
995 case wxSTC_CHARSET_SYMBOL:
996 encoding = wxFONTENCODING_DEFAULT;
997 break;
998
999 case wxSTC_CHARSET_TURKISH:
1000 encoding = wxFONTENCODING_ISO8859_9;
1001 break;
1002
1003 case wxSTC_CHARSET_JOHAB:
1004 encoding = wxFONTENCODING_DEFAULT;
1005 break;
1006
1007 case wxSTC_CHARSET_HEBREW:
1008 encoding = wxFONTENCODING_ISO8859_8;
1009 break;
1010
1011 case wxSTC_CHARSET_ARABIC:
1012 encoding = wxFONTENCODING_ISO8859_6;
1013 break;
1014
1015 case wxSTC_CHARSET_VIETNAMESE:
1016 encoding = wxFONTENCODING_DEFAULT;
1017 break;
1018
1019 case wxSTC_CHARSET_THAI:
1020 encoding = wxFONTENCODING_ISO8859_11;
1021 break;
1022
1023 case wxSTC_CHARSET_CYRILLIC:
1024 encoding = wxFONTENCODING_ISO8859_5;
1025 break;
1026
1027 case wxSTC_CHARSET_8859_15:
1028 encoding = wxFONTENCODING_ISO8859_15;
1029 break;
1030 }
1031
1032 // We just have Scintilla track the wxFontEncoding for us. It gets used
1033 // in Font::Create in PlatWX.cpp. We add one to the value so that the
1034 // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
1035 // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
1036 // to wxFONENCODING_DEFAULT in Font::Create.
1037 SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
1038 }
1039
1040 // Set a style to be a hotspot or not.
StyleSetHotSpot(int style,bool hotspot)1041 void wxStyledTextCtrl::StyleSetHotSpot(int style, bool hotspot)
1042 {
1043 SendMsg(SCI_STYLESETHOTSPOT, style, hotspot);
1044 }
1045
1046 // Set the foreground colour of the main and additional selections and whether to use this setting.
SetSelForeground(bool useSetting,const wxColour & fore)1047 void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore)
1048 {
1049 SendMsg(SCI_SETSELFORE, useSetting, wxColourAsLong(fore));
1050 }
1051
1052 // Set the background colour of the main and additional selections and whether to use this setting.
SetSelBackground(bool useSetting,const wxColour & back)1053 void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back)
1054 {
1055 SendMsg(SCI_SETSELBACK, useSetting, wxColourAsLong(back));
1056 }
1057
1058 // Get the alpha of the selection.
GetSelAlpha() const1059 int wxStyledTextCtrl::GetSelAlpha() const
1060 {
1061 return SendMsg(SCI_GETSELALPHA, 0, 0);
1062 }
1063
1064 // Set the alpha of the selection.
SetSelAlpha(int alpha)1065 void wxStyledTextCtrl::SetSelAlpha(int alpha)
1066 {
1067 SendMsg(SCI_SETSELALPHA, alpha, 0);
1068 }
1069
1070 // Is the selection end of line filled?
GetSelEOLFilled() const1071 bool wxStyledTextCtrl::GetSelEOLFilled() const
1072 {
1073 return SendMsg(SCI_GETSELEOLFILLED, 0, 0) != 0;
1074 }
1075
1076 // Set the selection to have its end of line filled or not.
SetSelEOLFilled(bool filled)1077 void wxStyledTextCtrl::SetSelEOLFilled(bool filled)
1078 {
1079 SendMsg(SCI_SETSELEOLFILLED, filled, 0);
1080 }
1081
1082 // Set the foreground colour of the caret.
SetCaretForeground(const wxColour & fore)1083 void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore)
1084 {
1085 SendMsg(SCI_SETCARETFORE, wxColourAsLong(fore), 0);
1086 }
1087
1088 // When key+modifier combination keyDefinition is pressed perform sciCommand.
CmdKeyAssign(int key,int modifiers,int cmd)1089 void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) {
1090 SendMsg(SCI_ASSIGNCMDKEY, MAKELONG(key, modifiers), cmd);
1091 }
1092
1093 // When key+modifier combination keyDefinition is pressed do nothing.
CmdKeyClear(int key,int modifiers)1094 void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) {
1095 SendMsg(SCI_CLEARCMDKEY, MAKELONG(key, modifiers));
1096 }
1097
1098 // Drop all key mappings.
CmdKeyClearAll()1099 void wxStyledTextCtrl::CmdKeyClearAll()
1100 {
1101 SendMsg(SCI_CLEARALLCMDKEYS, 0, 0);
1102 }
1103
1104 // Set the styles for a segment of the document.
SetStyleBytes(int length,char * styleBytes)1105 void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) {
1106 SendMsg(SCI_SETSTYLINGEX, length, (sptr_t)styleBytes);
1107 }
1108
1109 // Set a style to be visible or not.
StyleSetVisible(int style,bool visible)1110 void wxStyledTextCtrl::StyleSetVisible(int style, bool visible)
1111 {
1112 SendMsg(SCI_STYLESETVISIBLE, style, visible);
1113 }
1114
1115 // Get the time in milliseconds that the caret is on and off.
GetCaretPeriod() const1116 int wxStyledTextCtrl::GetCaretPeriod() const
1117 {
1118 return SendMsg(SCI_GETCARETPERIOD, 0, 0);
1119 }
1120
1121 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
SetCaretPeriod(int periodMilliseconds)1122 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds)
1123 {
1124 SendMsg(SCI_SETCARETPERIOD, periodMilliseconds, 0);
1125 }
1126
1127 // Set the set of characters making up words for when moving or selecting by word.
1128 // First sets defaults like SetCharsDefault.
SetWordChars(const wxString & characters)1129 void wxStyledTextCtrl::SetWordChars(const wxString& characters)
1130 {
1131 SendMsg(SCI_SETWORDCHARS, 0, (sptr_t)(const char*)wx2stc(characters));
1132 }
1133
1134 // Get the set of characters making up words for when moving or selecting by word.
GetWordChars() const1135 wxString wxStyledTextCtrl::GetWordChars() const {
1136 const int msg = SCI_GETWORDCHARS;
1137 int len = SendMsg(msg, 0, (sptr_t)NULL);
1138 if (!len) return wxEmptyString;
1139
1140 wxMemoryBuffer mbuf(len+1);
1141 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1142 SendMsg(msg, 0, (sptr_t)buf);
1143 mbuf.UngetWriteBuf(len);
1144 mbuf.AppendByte(0);
1145 return stc2wx(buf);
1146 }
1147
1148 // Start a sequence of actions that is undone and redone as a unit.
1149 // May be nested.
BeginUndoAction()1150 void wxStyledTextCtrl::BeginUndoAction()
1151 {
1152 SendMsg(SCI_BEGINUNDOACTION, 0, 0);
1153 }
1154
1155 // End a sequence of actions that is undone and redone as a unit.
EndUndoAction()1156 void wxStyledTextCtrl::EndUndoAction()
1157 {
1158 SendMsg(SCI_ENDUNDOACTION, 0, 0);
1159 }
1160
1161 // Set an indicator to plain, squiggle or TT.
IndicatorSetStyle(int indicator,int indicatorStyle)1162 void wxStyledTextCtrl::IndicatorSetStyle(int indicator, int indicatorStyle)
1163 {
1164 SendMsg(SCI_INDICSETSTYLE, indicator, indicatorStyle);
1165 }
1166
1167 // Retrieve the style of an indicator.
IndicatorGetStyle(int indicator) const1168 int wxStyledTextCtrl::IndicatorGetStyle(int indicator) const
1169 {
1170 return SendMsg(SCI_INDICGETSTYLE, indicator, 0);
1171 }
1172
1173 // Set the foreground colour of an indicator.
IndicatorSetForeground(int indicator,const wxColour & fore)1174 void wxStyledTextCtrl::IndicatorSetForeground(int indicator, const wxColour& fore)
1175 {
1176 SendMsg(SCI_INDICSETFORE, indicator, wxColourAsLong(fore));
1177 }
1178
1179 // Retrieve the foreground colour of an indicator.
IndicatorGetForeground(int indicator) const1180 wxColour wxStyledTextCtrl::IndicatorGetForeground(int indicator) const
1181 {
1182 long c = SendMsg(SCI_INDICGETFORE, indicator, 0);
1183 return wxColourFromLong(c);
1184 }
1185
1186 // Set an indicator to draw under text or over(default).
IndicatorSetUnder(int indicator,bool under)1187 void wxStyledTextCtrl::IndicatorSetUnder(int indicator, bool under)
1188 {
1189 SendMsg(SCI_INDICSETUNDER, indicator, under);
1190 }
1191
1192 // Retrieve whether indicator drawn under or over text.
IndicatorGetUnder(int indicator) const1193 bool wxStyledTextCtrl::IndicatorGetUnder(int indicator) const
1194 {
1195 return SendMsg(SCI_INDICGETUNDER, indicator, 0) != 0;
1196 }
1197
1198 // Set a hover indicator to plain, squiggle or TT.
IndicatorSetHoverStyle(int indicator,int indicatorStyle)1199 void wxStyledTextCtrl::IndicatorSetHoverStyle(int indicator, int indicatorStyle)
1200 {
1201 SendMsg(SCI_INDICSETHOVERSTYLE, indicator, indicatorStyle);
1202 }
1203
1204 // Retrieve the hover style of an indicator.
IndicatorGetHoverStyle(int indicator) const1205 int wxStyledTextCtrl::IndicatorGetHoverStyle(int indicator) const
1206 {
1207 return SendMsg(SCI_INDICGETHOVERSTYLE, indicator, 0);
1208 }
1209
1210 // Set the foreground hover colour of an indicator.
IndicatorSetHoverForeground(int indicator,const wxColour & fore)1211 void wxStyledTextCtrl::IndicatorSetHoverForeground(int indicator, const wxColour& fore)
1212 {
1213 SendMsg(SCI_INDICSETHOVERFORE, indicator, wxColourAsLong(fore));
1214 }
1215
1216 // Retrieve the foreground hover colour of an indicator.
IndicatorGetHoverForeground(int indicator) const1217 wxColour wxStyledTextCtrl::IndicatorGetHoverForeground(int indicator) const
1218 {
1219 long c = SendMsg(SCI_INDICGETHOVERFORE, indicator, 0);
1220 return wxColourFromLong(c);
1221 }
1222
1223 // Set the attributes of an indicator.
IndicatorSetFlags(int indicator,int flags)1224 void wxStyledTextCtrl::IndicatorSetFlags(int indicator, int flags)
1225 {
1226 SendMsg(SCI_INDICSETFLAGS, indicator, flags);
1227 }
1228
1229 // Retrieve the attributes of an indicator.
IndicatorGetFlags(int indicator) const1230 int wxStyledTextCtrl::IndicatorGetFlags(int indicator) const
1231 {
1232 return SendMsg(SCI_INDICGETFLAGS, indicator, 0);
1233 }
1234
1235 // Set the foreground colour of all whitespace and whether to use this setting.
SetWhitespaceForeground(bool useSetting,const wxColour & fore)1236 void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting, const wxColour& fore)
1237 {
1238 SendMsg(SCI_SETWHITESPACEFORE, useSetting, wxColourAsLong(fore));
1239 }
1240
1241 // Set the background colour of all whitespace and whether to use this setting.
SetWhitespaceBackground(bool useSetting,const wxColour & back)1242 void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting, const wxColour& back)
1243 {
1244 SendMsg(SCI_SETWHITESPACEBACK, useSetting, wxColourAsLong(back));
1245 }
1246
1247 // Set the size of the dots used to mark space characters.
SetWhitespaceSize(int size)1248 void wxStyledTextCtrl::SetWhitespaceSize(int size)
1249 {
1250 SendMsg(SCI_SETWHITESPACESIZE, size, 0);
1251 }
1252
1253 // Get the size of the dots used to mark space characters.
GetWhitespaceSize() const1254 int wxStyledTextCtrl::GetWhitespaceSize() const
1255 {
1256 return SendMsg(SCI_GETWHITESPACESIZE, 0, 0);
1257 }
1258
1259 // Divide each styling byte into lexical class bits (default: 5) and indicator
1260 // bits (default: 3). If a lexer requires more than 32 lexical states, then this
1261 // is used to expand the possible states.
SetStyleBits(int bits)1262 void wxStyledTextCtrl::SetStyleBits(int bits)
1263 {
1264 SendMsg(SCI_SETSTYLEBITS, bits, 0);
1265 }
1266
1267 // Retrieve number of bits in style bytes used to hold the lexical state.
GetStyleBits() const1268 int wxStyledTextCtrl::GetStyleBits() const
1269 {
1270 return SendMsg(SCI_GETSTYLEBITS, 0, 0);
1271 }
1272
1273 // Used to hold extra styling information for each line.
SetLineState(int line,int state)1274 void wxStyledTextCtrl::SetLineState(int line, int state)
1275 {
1276 SendMsg(SCI_SETLINESTATE, line, state);
1277 }
1278
1279 // Retrieve the extra styling information for a line.
GetLineState(int line) const1280 int wxStyledTextCtrl::GetLineState(int line) const
1281 {
1282 return SendMsg(SCI_GETLINESTATE, line, 0);
1283 }
1284
1285 // Retrieve the last line number that has line state.
GetMaxLineState() const1286 int wxStyledTextCtrl::GetMaxLineState() const
1287 {
1288 return SendMsg(SCI_GETMAXLINESTATE, 0, 0);
1289 }
1290
1291 // Is the background of the line containing the caret in a different colour?
GetCaretLineVisible() const1292 bool wxStyledTextCtrl::GetCaretLineVisible() const
1293 {
1294 return SendMsg(SCI_GETCARETLINEVISIBLE, 0, 0) != 0;
1295 }
1296
1297 // Display the background of the line containing the caret in a different colour.
SetCaretLineVisible(bool show)1298 void wxStyledTextCtrl::SetCaretLineVisible(bool show)
1299 {
1300 SendMsg(SCI_SETCARETLINEVISIBLE, show, 0);
1301 }
1302
1303 // Get the colour of the background of the line containing the caret.
GetCaretLineBackground() const1304 wxColour wxStyledTextCtrl::GetCaretLineBackground() const
1305 {
1306 long c = SendMsg(SCI_GETCARETLINEBACK, 0, 0);
1307 return wxColourFromLong(c);
1308 }
1309
1310 // Set the colour of the background of the line containing the caret.
SetCaretLineBackground(const wxColour & back)1311 void wxStyledTextCtrl::SetCaretLineBackground(const wxColour& back)
1312 {
1313 SendMsg(SCI_SETCARETLINEBACK, wxColourAsLong(back), 0);
1314 }
1315
1316 // Set a style to be changeable or not (read only).
1317 // Experimental feature, currently buggy.
StyleSetChangeable(int style,bool changeable)1318 void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable)
1319 {
1320 SendMsg(SCI_STYLESETCHANGEABLE, style, changeable);
1321 }
1322
1323 // Display an auto-completion list.
1324 // The lengthEntered parameter indicates how many characters before
1325 // the caret should be used to provide context.
AutoCompShow(int lengthEntered,const wxString & itemList)1326 void wxStyledTextCtrl::AutoCompShow(int lengthEntered, const wxString& itemList)
1327 {
1328 SendMsg(SCI_AUTOCSHOW, lengthEntered, (sptr_t)(const char*)wx2stc(itemList));
1329 }
1330
1331 // Remove the auto-completion list from the screen.
AutoCompCancel()1332 void wxStyledTextCtrl::AutoCompCancel()
1333 {
1334 SendMsg(SCI_AUTOCCANCEL, 0, 0);
1335 }
1336
1337 // Is there an auto-completion list visible?
AutoCompActive()1338 bool wxStyledTextCtrl::AutoCompActive()
1339 {
1340 return SendMsg(SCI_AUTOCACTIVE, 0, 0) != 0;
1341 }
1342
1343 // Retrieve the position of the caret when the auto-completion list was displayed.
AutoCompPosStart()1344 int wxStyledTextCtrl::AutoCompPosStart()
1345 {
1346 return SendMsg(SCI_AUTOCPOSSTART, 0, 0);
1347 }
1348
1349 // User has selected an item so remove the list and insert the selection.
AutoCompComplete()1350 void wxStyledTextCtrl::AutoCompComplete()
1351 {
1352 SendMsg(SCI_AUTOCCOMPLETE, 0, 0);
1353 }
1354
1355 // Define a set of character that when typed cancel the auto-completion list.
AutoCompStops(const wxString & characterSet)1356 void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet)
1357 {
1358 SendMsg(SCI_AUTOCSTOPS, 0, (sptr_t)(const char*)wx2stc(characterSet));
1359 }
1360
1361 // Change the separator character in the string setting up an auto-completion list.
1362 // Default is space but can be changed if items contain space.
AutoCompSetSeparator(int separatorCharacter)1363 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter)
1364 {
1365 SendMsg(SCI_AUTOCSETSEPARATOR, separatorCharacter, 0);
1366 }
1367
1368 // Retrieve the auto-completion list separator character.
AutoCompGetSeparator() const1369 int wxStyledTextCtrl::AutoCompGetSeparator() const
1370 {
1371 return SendMsg(SCI_AUTOCGETSEPARATOR, 0, 0);
1372 }
1373
1374 // Select the item in the auto-completion list that starts with a string.
AutoCompSelect(const wxString & select)1375 void wxStyledTextCtrl::AutoCompSelect(const wxString& select)
1376 {
1377 SendMsg(SCI_AUTOCSELECT, 0, (sptr_t)(const char*)wx2stc(select));
1378 }
1379
1380 // Should the auto-completion list be cancelled if the user backspaces to a
1381 // position before where the box was created.
AutoCompSetCancelAtStart(bool cancel)1382 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel)
1383 {
1384 SendMsg(SCI_AUTOCSETCANCELATSTART, cancel, 0);
1385 }
1386
1387 // Retrieve whether auto-completion cancelled by backspacing before start.
AutoCompGetCancelAtStart() const1388 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() const
1389 {
1390 return SendMsg(SCI_AUTOCGETCANCELATSTART, 0, 0) != 0;
1391 }
1392
1393 // Define a set of characters that when typed will cause the autocompletion to
1394 // choose the selected item.
AutoCompSetFillUps(const wxString & characterSet)1395 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet)
1396 {
1397 SendMsg(SCI_AUTOCSETFILLUPS, 0, (sptr_t)(const char*)wx2stc(characterSet));
1398 }
1399
1400 // Should a single item auto-completion list automatically choose the item.
AutoCompSetChooseSingle(bool chooseSingle)1401 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle)
1402 {
1403 SendMsg(SCI_AUTOCSETCHOOSESINGLE, chooseSingle, 0);
1404 }
1405
1406 // Retrieve whether a single item auto-completion list automatically choose the item.
AutoCompGetChooseSingle() const1407 bool wxStyledTextCtrl::AutoCompGetChooseSingle() const
1408 {
1409 return SendMsg(SCI_AUTOCGETCHOOSESINGLE, 0, 0) != 0;
1410 }
1411
1412 // Set whether case is significant when performing auto-completion searches.
AutoCompSetIgnoreCase(bool ignoreCase)1413 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase)
1414 {
1415 SendMsg(SCI_AUTOCSETIGNORECASE, ignoreCase, 0);
1416 }
1417
1418 // Retrieve state of ignore case flag.
AutoCompGetIgnoreCase() const1419 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() const
1420 {
1421 return SendMsg(SCI_AUTOCGETIGNORECASE, 0, 0) != 0;
1422 }
1423
1424 // Display a list of strings and send notification when user chooses one.
UserListShow(int listType,const wxString & itemList)1425 void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList)
1426 {
1427 SendMsg(SCI_USERLISTSHOW, listType, (sptr_t)(const char*)wx2stc(itemList));
1428 }
1429
1430 // Set whether or not autocompletion is hidden automatically when nothing matches.
AutoCompSetAutoHide(bool autoHide)1431 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide)
1432 {
1433 SendMsg(SCI_AUTOCSETAUTOHIDE, autoHide, 0);
1434 }
1435
1436 // Retrieve whether or not autocompletion is hidden automatically when nothing matches.
AutoCompGetAutoHide() const1437 bool wxStyledTextCtrl::AutoCompGetAutoHide() const
1438 {
1439 return SendMsg(SCI_AUTOCGETAUTOHIDE, 0, 0) != 0;
1440 }
1441
1442 // Set whether or not autocompletion deletes any word characters
1443 // after the inserted text upon completion.
AutoCompSetDropRestOfWord(bool dropRestOfWord)1444 void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord)
1445 {
1446 SendMsg(SCI_AUTOCSETDROPRESTOFWORD, dropRestOfWord, 0);
1447 }
1448
1449 // Retrieve whether or not autocompletion deletes any word characters
1450 // after the inserted text upon completion.
AutoCompGetDropRestOfWord() const1451 bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() const
1452 {
1453 return SendMsg(SCI_AUTOCGETDROPRESTOFWORD, 0, 0) != 0;
1454 }
1455
1456 // Register an image for use in autocompletion lists.
RegisterImage(int type,const char * const * xpmData)1457 void wxStyledTextCtrl::RegisterImage(int type, const char* const* xpmData) {
1458 SendMsg(SCI_REGISTERIMAGE, type, (sptr_t)xpmData);
1459 }
1460
1461 // Clear all the registered images.
ClearRegisteredImages()1462 void wxStyledTextCtrl::ClearRegisteredImages()
1463 {
1464 SendMsg(SCI_CLEARREGISTEREDIMAGES, 0, 0);
1465 }
1466
1467 // Retrieve the auto-completion list type-separator character.
AutoCompGetTypeSeparator() const1468 int wxStyledTextCtrl::AutoCompGetTypeSeparator() const
1469 {
1470 return SendMsg(SCI_AUTOCGETTYPESEPARATOR, 0, 0);
1471 }
1472
1473 // Change the type-separator character in the string setting up an auto-completion list.
1474 // Default is '?' but can be changed if items contain '?'.
AutoCompSetTypeSeparator(int separatorCharacter)1475 void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter)
1476 {
1477 SendMsg(SCI_AUTOCSETTYPESEPARATOR, separatorCharacter, 0);
1478 }
1479
1480 // Set the maximum width, in characters, of auto-completion and user lists.
1481 // Set to 0 to autosize to fit longest item, which is the default.
AutoCompSetMaxWidth(int characterCount)1482 void wxStyledTextCtrl::AutoCompSetMaxWidth(int characterCount)
1483 {
1484 SendMsg(SCI_AUTOCSETMAXWIDTH, characterCount, 0);
1485 }
1486
1487 // Get the maximum width, in characters, of auto-completion and user lists.
AutoCompGetMaxWidth() const1488 int wxStyledTextCtrl::AutoCompGetMaxWidth() const
1489 {
1490 return SendMsg(SCI_AUTOCGETMAXWIDTH, 0, 0);
1491 }
1492
1493 // Set the maximum height, in rows, of auto-completion and user lists.
1494 // The default is 5 rows.
AutoCompSetMaxHeight(int rowCount)1495 void wxStyledTextCtrl::AutoCompSetMaxHeight(int rowCount)
1496 {
1497 SendMsg(SCI_AUTOCSETMAXHEIGHT, rowCount, 0);
1498 }
1499
1500 // Set the maximum height, in rows, of auto-completion and user lists.
AutoCompGetMaxHeight() const1501 int wxStyledTextCtrl::AutoCompGetMaxHeight() const
1502 {
1503 return SendMsg(SCI_AUTOCGETMAXHEIGHT, 0, 0);
1504 }
1505
1506 // Set the number of spaces used for one level of indentation.
SetIndent(int indentSize)1507 void wxStyledTextCtrl::SetIndent(int indentSize)
1508 {
1509 SendMsg(SCI_SETINDENT, indentSize, 0);
1510 }
1511
1512 // Retrieve indentation size.
GetIndent() const1513 int wxStyledTextCtrl::GetIndent() const
1514 {
1515 return SendMsg(SCI_GETINDENT, 0, 0);
1516 }
1517
1518 // Indentation will only use space characters if useTabs is false, otherwise
1519 // it will use a combination of tabs and spaces.
SetUseTabs(bool useTabs)1520 void wxStyledTextCtrl::SetUseTabs(bool useTabs)
1521 {
1522 SendMsg(SCI_SETUSETABS, useTabs, 0);
1523 }
1524
1525 // Retrieve whether tabs will be used in indentation.
GetUseTabs() const1526 bool wxStyledTextCtrl::GetUseTabs() const
1527 {
1528 return SendMsg(SCI_GETUSETABS, 0, 0) != 0;
1529 }
1530
1531 // Change the indentation of a line to a number of columns.
SetLineIndentation(int line,int indentation)1532 void wxStyledTextCtrl::SetLineIndentation(int line, int indentation)
1533 {
1534 SendMsg(SCI_SETLINEINDENTATION, line, indentation);
1535 }
1536
1537 // Retrieve the number of columns that a line is indented.
GetLineIndentation(int line) const1538 int wxStyledTextCtrl::GetLineIndentation(int line) const
1539 {
1540 return SendMsg(SCI_GETLINEINDENTATION, line, 0);
1541 }
1542
1543 // Retrieve the position before the first non indentation character on a line.
GetLineIndentPosition(int line) const1544 int wxStyledTextCtrl::GetLineIndentPosition(int line) const
1545 {
1546 return SendMsg(SCI_GETLINEINDENTPOSITION, line, 0);
1547 }
1548
1549 // Retrieve the column number of a position, taking tab width into account.
GetColumn(int pos) const1550 int wxStyledTextCtrl::GetColumn(int pos) const
1551 {
1552 return SendMsg(SCI_GETCOLUMN, pos, 0);
1553 }
1554
1555 // Count characters between two positions.
CountCharacters(int start,int end)1556 int wxStyledTextCtrl::CountCharacters(int start, int end)
1557 {
1558 return SendMsg(SCI_COUNTCHARACTERS, start, end);
1559 }
1560
1561 // Show or hide the horizontal scroll bar.
SetUseHorizontalScrollBar(bool visible)1562 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool visible)
1563 {
1564 SendMsg(SCI_SETHSCROLLBAR, visible, 0);
1565 }
1566
1567 // Is the horizontal scroll bar visible?
GetUseHorizontalScrollBar() const1568 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() const
1569 {
1570 return SendMsg(SCI_GETHSCROLLBAR, 0, 0) != 0;
1571 }
1572
1573 // Show or hide indentation guides.
SetIndentationGuides(int indentView)1574 void wxStyledTextCtrl::SetIndentationGuides(int indentView)
1575 {
1576 SendMsg(SCI_SETINDENTATIONGUIDES, indentView, 0);
1577 }
1578
1579 // Are the indentation guides visible?
GetIndentationGuides() const1580 int wxStyledTextCtrl::GetIndentationGuides() const
1581 {
1582 return SendMsg(SCI_GETINDENTATIONGUIDES, 0, 0);
1583 }
1584
1585 // Set the highlighted indentation guide column.
1586 // 0 = no highlighted guide.
SetHighlightGuide(int column)1587 void wxStyledTextCtrl::SetHighlightGuide(int column)
1588 {
1589 SendMsg(SCI_SETHIGHLIGHTGUIDE, column, 0);
1590 }
1591
1592 // Get the highlighted indentation guide column.
GetHighlightGuide() const1593 int wxStyledTextCtrl::GetHighlightGuide() const
1594 {
1595 return SendMsg(SCI_GETHIGHLIGHTGUIDE, 0, 0);
1596 }
1597
1598 // Get the position after the last visible characters on a line.
GetLineEndPosition(int line) const1599 int wxStyledTextCtrl::GetLineEndPosition(int line) const
1600 {
1601 return SendMsg(SCI_GETLINEENDPOSITION, line, 0);
1602 }
1603
1604 // Get the code page used to interpret the bytes of the document as characters.
GetCodePage() const1605 int wxStyledTextCtrl::GetCodePage() const
1606 {
1607 return SendMsg(SCI_GETCODEPAGE, 0, 0);
1608 }
1609
1610 // Get the foreground colour of the caret.
GetCaretForeground() const1611 wxColour wxStyledTextCtrl::GetCaretForeground() const
1612 {
1613 long c = SendMsg(SCI_GETCARETFORE, 0, 0);
1614 return wxColourFromLong(c);
1615 }
1616
1617 // In read-only mode?
GetReadOnly() const1618 bool wxStyledTextCtrl::GetReadOnly() const
1619 {
1620 return SendMsg(SCI_GETREADONLY, 0, 0) != 0;
1621 }
1622
1623 // Sets the position of the caret.
SetCurrentPos(int caret)1624 void wxStyledTextCtrl::SetCurrentPos(int caret)
1625 {
1626 SendMsg(SCI_SETCURRENTPOS, caret, 0);
1627 }
1628
1629 // Sets the position that starts the selection - this becomes the anchor.
SetSelectionStart(int anchor)1630 void wxStyledTextCtrl::SetSelectionStart(int anchor)
1631 {
1632 SendMsg(SCI_SETSELECTIONSTART, anchor, 0);
1633 }
1634
1635 // Returns the position at the start of the selection.
GetSelectionStart() const1636 int wxStyledTextCtrl::GetSelectionStart() const
1637 {
1638 return SendMsg(SCI_GETSELECTIONSTART, 0, 0);
1639 }
1640
1641 // Sets the position that ends the selection - this becomes the caret.
SetSelectionEnd(int caret)1642 void wxStyledTextCtrl::SetSelectionEnd(int caret)
1643 {
1644 SendMsg(SCI_SETSELECTIONEND, caret, 0);
1645 }
1646
1647 // Returns the position at the end of the selection.
GetSelectionEnd() const1648 int wxStyledTextCtrl::GetSelectionEnd() const
1649 {
1650 return SendMsg(SCI_GETSELECTIONEND, 0, 0);
1651 }
1652
1653 // Set caret to a position, while removing any existing selection.
SetEmptySelection(int caret)1654 void wxStyledTextCtrl::SetEmptySelection(int caret)
1655 {
1656 SendMsg(SCI_SETEMPTYSELECTION, caret, 0);
1657 }
1658
1659 // Sets the print magnification added to the point size of each style for printing.
SetPrintMagnification(int magnification)1660 void wxStyledTextCtrl::SetPrintMagnification(int magnification)
1661 {
1662 SendMsg(SCI_SETPRINTMAGNIFICATION, magnification, 0);
1663 }
1664
1665 // Returns the print magnification.
GetPrintMagnification() const1666 int wxStyledTextCtrl::GetPrintMagnification() const
1667 {
1668 return SendMsg(SCI_GETPRINTMAGNIFICATION, 0, 0);
1669 }
1670
1671 // Modify colours when printing for clearer printed text.
SetPrintColourMode(int mode)1672 void wxStyledTextCtrl::SetPrintColourMode(int mode)
1673 {
1674 SendMsg(SCI_SETPRINTCOLOURMODE, mode, 0);
1675 }
1676
1677 // Returns the print colour mode.
GetPrintColourMode() const1678 int wxStyledTextCtrl::GetPrintColourMode() const
1679 {
1680 return SendMsg(SCI_GETPRINTCOLOURMODE, 0, 0);
1681 }
1682
1683 // Find some text in the document.
FindText(int minPos,int maxPos,const wxString & text,int flags,int * findEnd)1684 int wxStyledTextCtrl::FindText(int minPos, int maxPos, const wxString& text,
1685 int flags, int* findEnd) {
1686 Sci_TextToFind ft;
1687 ft.chrg.cpMin = minPos;
1688 ft.chrg.cpMax = maxPos;
1689 const wxWX2MBbuf buf = wx2stc(text);
1690 ft.lpstrText = buf;
1691
1692 int pos = SendMsg(SCI_FINDTEXT, flags, (sptr_t)&ft);
1693 if (findEnd) *findEnd=(pos==-1?wxSTC_INVALID_POSITION:ft.chrgText.cpMax);
1694 return pos;
1695 }
1696
1697 // On Windows, will draw the document into a display context such as a printer.
FormatRange(bool doDraw,int startPos,int endPos,wxDC * draw,wxDC * target,wxRect renderRect,wxRect pageRect)1698 int wxStyledTextCtrl::FormatRange(bool doDraw,
1699 int startPos,
1700 int endPos,
1701 wxDC* draw,
1702 wxDC* target,
1703 wxRect renderRect,
1704 wxRect pageRect) {
1705 Sci_RangeToFormat fr;
1706
1707 if (endPos < startPos) {
1708 wxSwap(startPos, endPos);
1709 }
1710 fr.hdc = draw;
1711 fr.hdcTarget = target;
1712 fr.rc.top = renderRect.GetTop();
1713 fr.rc.left = renderRect.GetLeft();
1714 fr.rc.right = renderRect.GetRight();
1715 fr.rc.bottom = renderRect.GetBottom();
1716 fr.rcPage.top = pageRect.GetTop();
1717 fr.rcPage.left = pageRect.GetLeft();
1718 fr.rcPage.right = pageRect.GetRight();
1719 fr.rcPage.bottom = pageRect.GetBottom();
1720 fr.chrg.cpMin = startPos;
1721 fr.chrg.cpMax = endPos;
1722
1723 return SendMsg(SCI_FORMATRANGE, doDraw, (sptr_t)&fr);
1724 }
1725
1726 // Retrieve the display line at the top of the display.
GetFirstVisibleLine() const1727 int wxStyledTextCtrl::GetFirstVisibleLine() const
1728 {
1729 return SendMsg(SCI_GETFIRSTVISIBLELINE, 0, 0);
1730 }
1731
1732 // Retrieve the contents of a line.
GetLine(int line) const1733 wxString wxStyledTextCtrl::GetLine(int line) const {
1734 int len = LineLength(line);
1735 if (!len) return wxEmptyString;
1736
1737 wxCharBuffer buf(len);
1738 SendMsg(SCI_GETLINE, line, (sptr_t)buf.data());
1739 return stc2wx(buf);
1740 }
1741
1742 // Returns the number of lines in the document. There is always at least one.
GetLineCount() const1743 int wxStyledTextCtrl::GetLineCount() const
1744 {
1745 return SendMsg(SCI_GETLINECOUNT, 0, 0);
1746 }
1747
1748 // Sets the size in pixels of the left margin.
SetMarginLeft(int pixelWidth)1749 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth)
1750 {
1751 SendMsg(SCI_SETMARGINLEFT, 0, pixelWidth);
1752 }
1753
1754 // Returns the size in pixels of the left margin.
GetMarginLeft() const1755 int wxStyledTextCtrl::GetMarginLeft() const
1756 {
1757 return SendMsg(SCI_GETMARGINLEFT, 0, 0);
1758 }
1759
1760 // Sets the size in pixels of the right margin.
SetMarginRight(int pixelWidth)1761 void wxStyledTextCtrl::SetMarginRight(int pixelWidth)
1762 {
1763 SendMsg(SCI_SETMARGINRIGHT, 0, pixelWidth);
1764 }
1765
1766 // Returns the size in pixels of the right margin.
GetMarginRight() const1767 int wxStyledTextCtrl::GetMarginRight() const
1768 {
1769 return SendMsg(SCI_GETMARGINRIGHT, 0, 0);
1770 }
1771
1772 // Is the document different from when it was last saved?
GetModify() const1773 bool wxStyledTextCtrl::GetModify() const
1774 {
1775 return SendMsg(SCI_GETMODIFY, 0, 0) != 0;
1776 }
1777
1778 // Retrieve the selected text.
GetSelectedText()1779 wxString wxStyledTextCtrl::GetSelectedText() {
1780 const int msg = SCI_GETSELTEXT;
1781 long len = SendMsg(msg, 0, (sptr_t)0);
1782 if (!len) return wxEmptyString;
1783
1784 wxCharBuffer buf(len);
1785 SendMsg(msg, 0, (sptr_t)buf.data());
1786 return stc2wx(buf);
1787 }
1788
1789 // Retrieve a range of text.
GetTextRange(int startPos,int endPos)1790 wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) {
1791 if (endPos < startPos) {
1792 wxSwap(startPos, endPos);
1793 }
1794 int len = endPos - startPos;
1795 if (!len) return wxEmptyString;
1796
1797 wxCharBuffer buf(len);
1798 Sci_TextRange tr;
1799 tr.lpstrText = buf.data();
1800 tr.chrg.cpMin = startPos;
1801 tr.chrg.cpMax = endPos;
1802 tr.lpstrText[0] = '\0'; // initialize with 0 in case the range is invalid
1803 SendMsg(SCI_GETTEXTRANGE, 0, (sptr_t)&tr);
1804 return stc2wx(buf);
1805 }
1806
1807 // Draw the selection in normal style or with selection highlighted.
HideSelection(bool hide)1808 void wxStyledTextCtrl::HideSelection(bool hide)
1809 {
1810 SendMsg(SCI_HIDESELECTION, hide, 0);
1811 }
1812
1813 // Retrieve the point in the window where a position is displayed.
PointFromPosition(int pos)1814 wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
1815 int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
1816 int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
1817 return wxPoint(x, y);
1818 }
1819
1820 // Retrieve the line containing a position.
LineFromPosition(int pos) const1821 int wxStyledTextCtrl::LineFromPosition(int pos) const
1822 {
1823 return SendMsg(SCI_LINEFROMPOSITION, pos, 0);
1824 }
1825
1826 // Retrieve the position at the start of a line.
PositionFromLine(int line) const1827 int wxStyledTextCtrl::PositionFromLine(int line) const
1828 {
1829 return SendMsg(SCI_POSITIONFROMLINE, line, 0);
1830 }
1831
1832 // Scroll horizontally and vertically.
LineScroll(int columns,int lines)1833 void wxStyledTextCtrl::LineScroll(int columns, int lines)
1834 {
1835 SendMsg(SCI_LINESCROLL, columns, lines);
1836 }
1837
1838 // Ensure the caret is visible.
EnsureCaretVisible()1839 void wxStyledTextCtrl::EnsureCaretVisible()
1840 {
1841 SendMsg(SCI_SCROLLCARET, 0, 0);
1842 }
1843
1844 // Scroll the argument positions and the range between them into view giving
1845 // priority to the primary position then the secondary position.
1846 // This may be used to make a search match visible.
ScrollRange(int secondary,int primary)1847 void wxStyledTextCtrl::ScrollRange(int secondary, int primary)
1848 {
1849 SendMsg(SCI_SCROLLRANGE, secondary, primary);
1850 }
1851
1852 // Replace the selected text with the argument text.
ReplaceSelection(const wxString & text)1853 void wxStyledTextCtrl::ReplaceSelection(const wxString& text)
1854 {
1855 SendMsg(SCI_REPLACESEL, 0, (sptr_t)(const char*)wx2stc(text));
1856 }
1857
1858 // Set to read only or read write.
SetReadOnly(bool readOnly)1859 void wxStyledTextCtrl::SetReadOnly(bool readOnly)
1860 {
1861 SendMsg(SCI_SETREADONLY, readOnly, 0);
1862 }
1863
1864 // Will a paste succeed?
CanPaste() const1865 bool wxStyledTextCtrl::CanPaste() const
1866 {
1867 return SendMsg(SCI_CANPASTE, 0, 0) != 0;
1868 }
1869
1870 // Are there any undoable actions in the undo history?
CanUndo() const1871 bool wxStyledTextCtrl::CanUndo() const
1872 {
1873 return SendMsg(SCI_CANUNDO, 0, 0) != 0;
1874 }
1875
1876 // Delete the undo history.
EmptyUndoBuffer()1877 void wxStyledTextCtrl::EmptyUndoBuffer()
1878 {
1879 SendMsg(SCI_EMPTYUNDOBUFFER, 0, 0);
1880 }
1881
1882 // Undo one action in the undo history.
Undo()1883 void wxStyledTextCtrl::Undo()
1884 {
1885 SendMsg(SCI_UNDO, 0, 0);
1886 }
1887
1888 // Cut the selection to the clipboard.
Cut()1889 void wxStyledTextCtrl::Cut()
1890 {
1891 SendMsg(SCI_CUT, 0, 0);
1892 }
1893
1894 // Copy the selection to the clipboard.
Copy()1895 void wxStyledTextCtrl::Copy()
1896 {
1897 SendMsg(SCI_COPY, 0, 0);
1898 }
1899
1900 // Paste the contents of the clipboard into the document replacing the selection.
Paste()1901 void wxStyledTextCtrl::Paste()
1902 {
1903 SendMsg(SCI_PASTE, 0, 0);
1904 }
1905
1906 // Clear the selection.
Clear()1907 void wxStyledTextCtrl::Clear()
1908 {
1909 SendMsg(SCI_CLEAR, 0, 0);
1910 }
1911
1912 // Replace the contents of the document with the argument text.
SetText(const wxString & text)1913 void wxStyledTextCtrl::SetText(const wxString& text)
1914 {
1915 SendMsg(SCI_SETTEXT, 0, (sptr_t)(const char*)wx2stc(text));
1916 }
1917
1918 // Retrieve all the text in the document.
GetText() const1919 wxString wxStyledTextCtrl::GetText() const {
1920 int len = GetTextLength();
1921 if (!len) return wxEmptyString;
1922
1923 wxCharBuffer buf(len);
1924 SendMsg(SCI_GETTEXT, len+1, (sptr_t)buf.data());
1925 return stc2wx(buf);
1926 }
1927
1928 // Retrieve the number of characters in the document.
GetTextLength() const1929 int wxStyledTextCtrl::GetTextLength() const
1930 {
1931 return SendMsg(SCI_GETTEXTLENGTH, 0, 0);
1932 }
1933
1934 // Retrieve a pointer to a function that processes messages for this Scintilla.
GetDirectFunction() const1935 void* wxStyledTextCtrl::GetDirectFunction() const {
1936 return (void*)SendMsg(SCI_GETDIRECTFUNCTION);
1937 }
1938
1939 // Retrieve a pointer value to use as the first argument when calling
1940 // the function returned by GetDirectFunction.
GetDirectPointer() const1941 void* wxStyledTextCtrl::GetDirectPointer() const {
1942 return (void*)SendMsg(SCI_GETDIRECTPOINTER);
1943 }
1944
1945 // Set to overtype (true) or insert mode.
SetOvertype(bool overType)1946 void wxStyledTextCtrl::SetOvertype(bool overType)
1947 {
1948 SendMsg(SCI_SETOVERTYPE, overType, 0);
1949 }
1950
1951 // Returns true if overtype mode is active otherwise false is returned.
GetOvertype() const1952 bool wxStyledTextCtrl::GetOvertype() const
1953 {
1954 return SendMsg(SCI_GETOVERTYPE, 0, 0) != 0;
1955 }
1956
1957 // Set the width of the insert mode caret.
SetCaretWidth(int pixelWidth)1958 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth)
1959 {
1960 SendMsg(SCI_SETCARETWIDTH, pixelWidth, 0);
1961 }
1962
1963 // Returns the width of the insert mode caret.
GetCaretWidth() const1964 int wxStyledTextCtrl::GetCaretWidth() const
1965 {
1966 return SendMsg(SCI_GETCARETWIDTH, 0, 0);
1967 }
1968
1969 // Sets the position that starts the target which is used for updating the
1970 // document without affecting the scroll position.
SetTargetStart(int start)1971 void wxStyledTextCtrl::SetTargetStart(int start)
1972 {
1973 SendMsg(SCI_SETTARGETSTART, start, 0);
1974 }
1975
1976 // Get the position that starts the target.
GetTargetStart() const1977 int wxStyledTextCtrl::GetTargetStart() const
1978 {
1979 return SendMsg(SCI_GETTARGETSTART, 0, 0);
1980 }
1981
1982 // Sets the position that ends the target which is used for updating the
1983 // document without affecting the scroll position.
SetTargetEnd(int end)1984 void wxStyledTextCtrl::SetTargetEnd(int end)
1985 {
1986 SendMsg(SCI_SETTARGETEND, end, 0);
1987 }
1988
1989 // Get the position that ends the target.
GetTargetEnd() const1990 int wxStyledTextCtrl::GetTargetEnd() const
1991 {
1992 return SendMsg(SCI_GETTARGETEND, 0, 0);
1993 }
1994
1995 // Sets both the start and end of the target in one call.
SetTargetRange(int start,int end)1996 void wxStyledTextCtrl::SetTargetRange(int start, int end)
1997 {
1998 SendMsg(SCI_SETTARGETRANGE, start, end);
1999 }
2000
2001 // Retrieve the text in the target.
GetTargetText() const2002 wxString wxStyledTextCtrl::GetTargetText() const {
2003 int len = GetTargetEnd() - GetTargetStart();
2004 wxCharBuffer buf(len);
2005 SendMsg(SCI_GETTARGETTEXT, 0, (sptr_t)buf.data());
2006 return stc2wx(buf);
2007 }
2008
2009 // Make the target range start and end be the same as the selection range start and end.
TargetFromSelection()2010 void wxStyledTextCtrl::TargetFromSelection()
2011 {
2012 SendMsg(SCI_TARGETFROMSELECTION, 0, 0);
2013 }
2014
2015 // Sets the target to the whole document.
TargetWholeDocument()2016 void wxStyledTextCtrl::TargetWholeDocument()
2017 {
2018 SendMsg(SCI_TARGETWHOLEDOCUMENT, 0, 0);
2019 }
2020
2021 // Replace the target text with the argument text.
2022 // Text is counted so it can contain NULs.
2023 // Returns the length of the replacement text.
2024
ReplaceTarget(const wxString & text)2025 int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
2026 const wxWX2MBbuf buf = wx2stc(text);
2027 return SendMsg(SCI_REPLACETARGET, wx2stclen(text, buf), (sptr_t)(const char*)buf);
2028 }
2029
2030 // Replace the target text with the argument text after \\d processing.
2031 // Text is counted so it can contain NULs.
2032 // Looks for \\d where d is between 1 and 9 and replaces these with the strings
2033 // matched in the last search operation which were surrounded by \\( and \\).
2034 // Returns the length of the replacement text including any change
2035 // caused by processing the \\d patterns.
2036
ReplaceTargetRE(const wxString & text)2037 int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
2038 const wxWX2MBbuf buf = wx2stc(text);
2039 return SendMsg(SCI_REPLACETARGETRE, wx2stclen(text, buf), (sptr_t)(const char*)buf);
2040 }
2041
2042 // Search for a counted string in the target and set the target to the found
2043 // range. Text is counted so it can contain NULs.
2044 // Returns length of range or -1 for failure in which case target is not moved.
2045
SearchInTarget(const wxString & text)2046 int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
2047 const wxWX2MBbuf buf = wx2stc(text);
2048 return SendMsg(SCI_SEARCHINTARGET, wx2stclen(text, buf), (sptr_t)(const char*)buf);
2049 }
2050
2051 // Set the search flags used by SearchInTarget.
SetSearchFlags(int searchFlags)2052 void wxStyledTextCtrl::SetSearchFlags(int searchFlags)
2053 {
2054 SendMsg(SCI_SETSEARCHFLAGS, searchFlags, 0);
2055 }
2056
2057 // Get the search flags used by SearchInTarget.
GetSearchFlags() const2058 int wxStyledTextCtrl::GetSearchFlags() const
2059 {
2060 return SendMsg(SCI_GETSEARCHFLAGS, 0, 0);
2061 }
2062
2063 // Show a call tip containing a definition near position pos.
CallTipShow(int pos,const wxString & definition)2064 void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition)
2065 {
2066 SendMsg(SCI_CALLTIPSHOW, pos, (sptr_t)(const char*)wx2stc(definition));
2067 }
2068
2069 // Remove the call tip from the screen.
CallTipCancel()2070 void wxStyledTextCtrl::CallTipCancel()
2071 {
2072 SendMsg(SCI_CALLTIPCANCEL, 0, 0);
2073 }
2074
2075 // Is there an active call tip?
CallTipActive()2076 bool wxStyledTextCtrl::CallTipActive()
2077 {
2078 return SendMsg(SCI_CALLTIPACTIVE, 0, 0) != 0;
2079 }
2080
2081 // Retrieve the position where the caret was before displaying the call tip.
CallTipPosAtStart()2082 int wxStyledTextCtrl::CallTipPosAtStart()
2083 {
2084 return SendMsg(SCI_CALLTIPPOSSTART, 0, 0);
2085 }
2086
2087 // Set the start position in order to change when backspacing removes the calltip.
CallTipSetPosAtStart(int posStart)2088 void wxStyledTextCtrl::CallTipSetPosAtStart(int posStart)
2089 {
2090 SendMsg(SCI_CALLTIPSETPOSSTART, posStart, 0);
2091 }
2092
2093 // Highlight a segment of the definition.
CallTipSetHighlight(int highlightStart,int highlightEnd)2094 void wxStyledTextCtrl::CallTipSetHighlight(int highlightStart, int highlightEnd)
2095 {
2096 SendMsg(SCI_CALLTIPSETHLT, highlightStart, highlightEnd);
2097 }
2098
2099 // Set the background colour for the call tip.
CallTipSetBackground(const wxColour & back)2100 void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back)
2101 {
2102 SendMsg(SCI_CALLTIPSETBACK, wxColourAsLong(back), 0);
2103 }
2104
2105 // Set the foreground colour for the call tip.
CallTipSetForeground(const wxColour & fore)2106 void wxStyledTextCtrl::CallTipSetForeground(const wxColour& fore)
2107 {
2108 SendMsg(SCI_CALLTIPSETFORE, wxColourAsLong(fore), 0);
2109 }
2110
2111 // Set the foreground colour for the highlighted part of the call tip.
CallTipSetForegroundHighlight(const wxColour & fore)2112 void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour& fore)
2113 {
2114 SendMsg(SCI_CALLTIPSETFOREHLT, wxColourAsLong(fore), 0);
2115 }
2116
2117 // Enable use of wxSTC_STYLE_CALLTIP and set call tip tab size in pixels.
CallTipUseStyle(int tabSize)2118 void wxStyledTextCtrl::CallTipUseStyle(int tabSize)
2119 {
2120 SendMsg(SCI_CALLTIPUSESTYLE, tabSize, 0);
2121 }
2122
2123 // Set position of calltip, above or below text.
CallTipSetPosition(bool above)2124 void wxStyledTextCtrl::CallTipSetPosition(bool above)
2125 {
2126 SendMsg(SCI_CALLTIPSETPOSITION, above, 0);
2127 }
2128
2129 // Find the display line of a document line taking hidden lines into account.
VisibleFromDocLine(int docLine)2130 int wxStyledTextCtrl::VisibleFromDocLine(int docLine)
2131 {
2132 return SendMsg(SCI_VISIBLEFROMDOCLINE, docLine, 0);
2133 }
2134
2135 // Find the document line of a display line taking hidden lines into account.
DocLineFromVisible(int displayLine)2136 int wxStyledTextCtrl::DocLineFromVisible(int displayLine)
2137 {
2138 return SendMsg(SCI_DOCLINEFROMVISIBLE, displayLine, 0);
2139 }
2140
2141 // The number of display lines needed to wrap a document line
WrapCount(int docLine)2142 int wxStyledTextCtrl::WrapCount(int docLine)
2143 {
2144 return SendMsg(SCI_WRAPCOUNT, docLine, 0);
2145 }
2146
2147 // Set the fold level of a line.
2148 // This encodes an integer level along with flags indicating whether the
2149 // line is a header and whether it is effectively white space.
SetFoldLevel(int line,int level)2150 void wxStyledTextCtrl::SetFoldLevel(int line, int level)
2151 {
2152 SendMsg(SCI_SETFOLDLEVEL, line, level);
2153 }
2154
2155 // Retrieve the fold level of a line.
GetFoldLevel(int line) const2156 int wxStyledTextCtrl::GetFoldLevel(int line) const
2157 {
2158 return SendMsg(SCI_GETFOLDLEVEL, line, 0);
2159 }
2160
2161 // Find the last child line of a header line.
GetLastChild(int line,int level) const2162 int wxStyledTextCtrl::GetLastChild(int line, int level) const
2163 {
2164 return SendMsg(SCI_GETLASTCHILD, line, level);
2165 }
2166
2167 // Find the parent line of a child line.
GetFoldParent(int line) const2168 int wxStyledTextCtrl::GetFoldParent(int line) const
2169 {
2170 return SendMsg(SCI_GETFOLDPARENT, line, 0);
2171 }
2172
2173 // Make a range of lines visible.
ShowLines(int lineStart,int lineEnd)2174 void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd)
2175 {
2176 SendMsg(SCI_SHOWLINES, lineStart, lineEnd);
2177 }
2178
2179 // Make a range of lines invisible.
HideLines(int lineStart,int lineEnd)2180 void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd)
2181 {
2182 SendMsg(SCI_HIDELINES, lineStart, lineEnd);
2183 }
2184
2185 // Is a line visible?
GetLineVisible(int line) const2186 bool wxStyledTextCtrl::GetLineVisible(int line) const
2187 {
2188 return SendMsg(SCI_GETLINEVISIBLE, line, 0) != 0;
2189 }
2190
2191 // Are all lines visible?
GetAllLinesVisible() const2192 bool wxStyledTextCtrl::GetAllLinesVisible() const
2193 {
2194 return SendMsg(SCI_GETALLLINESVISIBLE, 0, 0) != 0;
2195 }
2196
2197 // Show the children of a header line.
SetFoldExpanded(int line,bool expanded)2198 void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded)
2199 {
2200 SendMsg(SCI_SETFOLDEXPANDED, line, expanded);
2201 }
2202
2203 // Is a header line expanded?
GetFoldExpanded(int line) const2204 bool wxStyledTextCtrl::GetFoldExpanded(int line) const
2205 {
2206 return SendMsg(SCI_GETFOLDEXPANDED, line, 0) != 0;
2207 }
2208
2209 // Switch a header line between expanded and contracted.
ToggleFold(int line)2210 void wxStyledTextCtrl::ToggleFold(int line)
2211 {
2212 SendMsg(SCI_TOGGLEFOLD, line, 0);
2213 }
2214
2215 // Switch a header line between expanded and contracted and show some text after the line.
ToggleFoldShowText(int line,const wxString & text)2216 void wxStyledTextCtrl::ToggleFoldShowText(int line, const wxString& text)
2217 {
2218 SendMsg(SCI_TOGGLEFOLDSHOWTEXT, line, (sptr_t)(const char*)wx2stc(text));
2219 }
2220
2221 // Set the style of fold display text
FoldDisplayTextSetStyle(int style)2222 void wxStyledTextCtrl::FoldDisplayTextSetStyle(int style)
2223 {
2224 SendMsg(SCI_FOLDDISPLAYTEXTSETSTYLE, style, 0);
2225 }
2226
2227 // Expand or contract a fold header.
FoldLine(int line,int action)2228 void wxStyledTextCtrl::FoldLine(int line, int action)
2229 {
2230 SendMsg(SCI_FOLDLINE, line, action);
2231 }
2232
2233 // Expand or contract a fold header and its children.
FoldChildren(int line,int action)2234 void wxStyledTextCtrl::FoldChildren(int line, int action)
2235 {
2236 SendMsg(SCI_FOLDCHILDREN, line, action);
2237 }
2238
2239 // Expand a fold header and all children. Use the level argument instead of the line's current level.
ExpandChildren(int line,int level)2240 void wxStyledTextCtrl::ExpandChildren(int line, int level)
2241 {
2242 SendMsg(SCI_EXPANDCHILDREN, line, level);
2243 }
2244
2245 // Expand or contract all fold headers.
FoldAll(int action)2246 void wxStyledTextCtrl::FoldAll(int action)
2247 {
2248 SendMsg(SCI_FOLDALL, action, 0);
2249 }
2250
2251 // Ensure a particular line is visible by expanding any header line hiding it.
EnsureVisible(int line)2252 void wxStyledTextCtrl::EnsureVisible(int line)
2253 {
2254 SendMsg(SCI_ENSUREVISIBLE, line, 0);
2255 }
2256
2257 // Set automatic folding behaviours.
SetAutomaticFold(int automaticFold)2258 void wxStyledTextCtrl::SetAutomaticFold(int automaticFold)
2259 {
2260 SendMsg(SCI_SETAUTOMATICFOLD, automaticFold, 0);
2261 }
2262
2263 // Get automatic folding behaviours.
GetAutomaticFold() const2264 int wxStyledTextCtrl::GetAutomaticFold() const
2265 {
2266 return SendMsg(SCI_GETAUTOMATICFOLD, 0, 0);
2267 }
2268
2269 // Set some style options for folding.
SetFoldFlags(int flags)2270 void wxStyledTextCtrl::SetFoldFlags(int flags)
2271 {
2272 SendMsg(SCI_SETFOLDFLAGS, flags, 0);
2273 }
2274
2275 // Ensure a particular line is visible by expanding any header line hiding it.
2276 // Use the currently set visibility policy to determine which range to display.
EnsureVisibleEnforcePolicy(int line)2277 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line)
2278 {
2279 SendMsg(SCI_ENSUREVISIBLEENFORCEPOLICY, line, 0);
2280 }
2281
2282 // Sets whether a tab pressed when caret is within indentation indents.
SetTabIndents(bool tabIndents)2283 void wxStyledTextCtrl::SetTabIndents(bool tabIndents)
2284 {
2285 SendMsg(SCI_SETTABINDENTS, tabIndents, 0);
2286 }
2287
2288 // Does a tab pressed when caret is within indentation indent?
GetTabIndents() const2289 bool wxStyledTextCtrl::GetTabIndents() const
2290 {
2291 return SendMsg(SCI_GETTABINDENTS, 0, 0) != 0;
2292 }
2293
2294 // Sets whether a backspace pressed when caret is within indentation unindents.
SetBackSpaceUnIndents(bool bsUnIndents)2295 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents)
2296 {
2297 SendMsg(SCI_SETBACKSPACEUNINDENTS, bsUnIndents, 0);
2298 }
2299
2300 // Does a backspace pressed when caret is within indentation unindent?
GetBackSpaceUnIndents() const2301 bool wxStyledTextCtrl::GetBackSpaceUnIndents() const
2302 {
2303 return SendMsg(SCI_GETBACKSPACEUNINDENTS, 0, 0) != 0;
2304 }
2305
2306 // Sets the time the mouse must sit still to generate a mouse dwell event.
SetMouseDwellTime(int periodMilliseconds)2307 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds)
2308 {
2309 SendMsg(SCI_SETMOUSEDWELLTIME, periodMilliseconds, 0);
2310 }
2311
2312 // Retrieve the time the mouse must sit still to generate a mouse dwell event.
GetMouseDwellTime() const2313 int wxStyledTextCtrl::GetMouseDwellTime() const
2314 {
2315 return SendMsg(SCI_GETMOUSEDWELLTIME, 0, 0);
2316 }
2317
2318 // Get position of start of word.
WordStartPosition(int pos,bool onlyWordCharacters)2319 int wxStyledTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters)
2320 {
2321 return SendMsg(SCI_WORDSTARTPOSITION, pos, onlyWordCharacters);
2322 }
2323
2324 // Get position of end of word.
WordEndPosition(int pos,bool onlyWordCharacters)2325 int wxStyledTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters)
2326 {
2327 return SendMsg(SCI_WORDENDPOSITION, pos, onlyWordCharacters);
2328 }
2329
2330 // Is the range start..end considered a word?
IsRangeWord(int start,int end)2331 bool wxStyledTextCtrl::IsRangeWord(int start, int end)
2332 {
2333 return SendMsg(SCI_ISRANGEWORD, start, end) != 0;
2334 }
2335
2336 // Sets limits to idle styling.
SetIdleStyling(int idleStyling)2337 void wxStyledTextCtrl::SetIdleStyling(int idleStyling)
2338 {
2339 SendMsg(SCI_SETIDLESTYLING, idleStyling, 0);
2340 }
2341
2342 // Retrieve the limits to idle styling.
GetIdleStyling() const2343 int wxStyledTextCtrl::GetIdleStyling() const
2344 {
2345 return SendMsg(SCI_GETIDLESTYLING, 0, 0);
2346 }
2347
2348 // Sets whether text is word wrapped.
SetWrapMode(int wrapMode)2349 void wxStyledTextCtrl::SetWrapMode(int wrapMode)
2350 {
2351 SendMsg(SCI_SETWRAPMODE, wrapMode, 0);
2352 }
2353
2354 // Retrieve whether text is word wrapped.
GetWrapMode() const2355 int wxStyledTextCtrl::GetWrapMode() const
2356 {
2357 return SendMsg(SCI_GETWRAPMODE, 0, 0);
2358 }
2359
2360 // Set the display mode of visual flags for wrapped lines.
SetWrapVisualFlags(int wrapVisualFlags)2361 void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags)
2362 {
2363 SendMsg(SCI_SETWRAPVISUALFLAGS, wrapVisualFlags, 0);
2364 }
2365
2366 // Retrieve the display mode of visual flags for wrapped lines.
GetWrapVisualFlags() const2367 int wxStyledTextCtrl::GetWrapVisualFlags() const
2368 {
2369 return SendMsg(SCI_GETWRAPVISUALFLAGS, 0, 0);
2370 }
2371
2372 // Set the location of visual flags for wrapped lines.
SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation)2373 void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation)
2374 {
2375 SendMsg(SCI_SETWRAPVISUALFLAGSLOCATION, wrapVisualFlagsLocation, 0);
2376 }
2377
2378 // Retrieve the location of visual flags for wrapped lines.
GetWrapVisualFlagsLocation() const2379 int wxStyledTextCtrl::GetWrapVisualFlagsLocation() const
2380 {
2381 return SendMsg(SCI_GETWRAPVISUALFLAGSLOCATION, 0, 0);
2382 }
2383
2384 // Set the start indent for wrapped lines.
SetWrapStartIndent(int indent)2385 void wxStyledTextCtrl::SetWrapStartIndent(int indent)
2386 {
2387 SendMsg(SCI_SETWRAPSTARTINDENT, indent, 0);
2388 }
2389
2390 // Retrieve the start indent for wrapped lines.
GetWrapStartIndent() const2391 int wxStyledTextCtrl::GetWrapStartIndent() const
2392 {
2393 return SendMsg(SCI_GETWRAPSTARTINDENT, 0, 0);
2394 }
2395
2396 // Sets how wrapped sublines are placed. Default is wxSTC_WRAPINDENT_FIXED.
SetWrapIndentMode(int wrapIndentMode)2397 void wxStyledTextCtrl::SetWrapIndentMode(int wrapIndentMode)
2398 {
2399 SendMsg(SCI_SETWRAPINDENTMODE, wrapIndentMode, 0);
2400 }
2401
2402 // Retrieve how wrapped sublines are placed. Default is wxSTC_WRAPINDENT_FIXED.
GetWrapIndentMode() const2403 int wxStyledTextCtrl::GetWrapIndentMode() const
2404 {
2405 return SendMsg(SCI_GETWRAPINDENTMODE, 0, 0);
2406 }
2407
2408 // Sets the degree of caching of layout information.
SetLayoutCache(int cacheMode)2409 void wxStyledTextCtrl::SetLayoutCache(int cacheMode)
2410 {
2411 SendMsg(SCI_SETLAYOUTCACHE, cacheMode, 0);
2412 }
2413
2414 // Retrieve the degree of caching of layout information.
GetLayoutCache() const2415 int wxStyledTextCtrl::GetLayoutCache() const
2416 {
2417 return SendMsg(SCI_GETLAYOUTCACHE, 0, 0);
2418 }
2419
2420 // Sets the document width assumed for scrolling.
SetScrollWidth(int pixelWidth)2421 void wxStyledTextCtrl::SetScrollWidth(int pixelWidth)
2422 {
2423 SendMsg(SCI_SETSCROLLWIDTH, pixelWidth, 0);
2424 }
2425
2426 // Retrieve the document width assumed for scrolling.
GetScrollWidth() const2427 int wxStyledTextCtrl::GetScrollWidth() const
2428 {
2429 return SendMsg(SCI_GETSCROLLWIDTH, 0, 0);
2430 }
2431
2432 // Sets whether the maximum width line displayed is used to set scroll width.
SetScrollWidthTracking(bool tracking)2433 void wxStyledTextCtrl::SetScrollWidthTracking(bool tracking)
2434 {
2435 SendMsg(SCI_SETSCROLLWIDTHTRACKING, tracking, 0);
2436 }
2437
2438 // Retrieve whether the scroll width tracks wide lines.
GetScrollWidthTracking() const2439 bool wxStyledTextCtrl::GetScrollWidthTracking() const
2440 {
2441 return SendMsg(SCI_GETSCROLLWIDTHTRACKING, 0, 0) != 0;
2442 }
2443
2444 // Measure the pixel width of some text in a particular style.
2445 // Does not handle tab or control characters.
TextWidth(int style,const wxString & text)2446 int wxStyledTextCtrl::TextWidth(int style, const wxString& text)
2447 {
2448 return SendMsg(SCI_TEXTWIDTH, style, (sptr_t)(const char*)wx2stc(text));
2449 }
2450
2451 // Sets the scroll range so that maximum scroll position has
2452 // the last line at the bottom of the view (default).
2453 // Setting this to false allows scrolling one page below the last line.
SetEndAtLastLine(bool endAtLastLine)2454 void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine)
2455 {
2456 SendMsg(SCI_SETENDATLASTLINE, endAtLastLine, 0);
2457 }
2458
2459 // Retrieve whether the maximum scroll position has the last
2460 // line at the bottom of the view.
GetEndAtLastLine() const2461 bool wxStyledTextCtrl::GetEndAtLastLine() const
2462 {
2463 return SendMsg(SCI_GETENDATLASTLINE, 0, 0) != 0;
2464 }
2465
2466 // Retrieve the height of a particular line of text in pixels.
TextHeight(int line)2467 int wxStyledTextCtrl::TextHeight(int line)
2468 {
2469 return SendMsg(SCI_TEXTHEIGHT, line, 0);
2470 }
2471
2472 // Show or hide the vertical scroll bar.
SetUseVerticalScrollBar(bool visible)2473 void wxStyledTextCtrl::SetUseVerticalScrollBar(bool visible)
2474 {
2475 SendMsg(SCI_SETVSCROLLBAR, visible, 0);
2476 }
2477
2478 // Is the vertical scroll bar visible?
GetUseVerticalScrollBar() const2479 bool wxStyledTextCtrl::GetUseVerticalScrollBar() const
2480 {
2481 return SendMsg(SCI_GETVSCROLLBAR, 0, 0) != 0;
2482 }
2483
2484 // Append a string to the end of the document without changing the selection.
AppendText(const wxString & text)2485 void wxStyledTextCtrl::AppendText(const wxString& text) {
2486 const wxWX2MBbuf buf = wx2stc(text);
2487 SendMsg(SCI_APPENDTEXT, wx2stclen(text, buf), (sptr_t)(const char*)buf);
2488 }
2489
2490 // Is drawing done in two phases with backgrounds drawn before foregrounds?
GetTwoPhaseDraw() const2491 bool wxStyledTextCtrl::GetTwoPhaseDraw() const
2492 {
2493 return SendMsg(SCI_GETTWOPHASEDRAW, 0, 0) != 0;
2494 }
2495
2496 // In twoPhaseDraw mode, drawing is performed in two phases, first the background
2497 // and then the foreground. This avoids chopping off characters that overlap the next run.
SetTwoPhaseDraw(bool twoPhase)2498 void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase)
2499 {
2500 SendMsg(SCI_SETTWOPHASEDRAW, twoPhase, 0);
2501 }
2502
2503 // How many phases is drawing done in?
GetPhasesDraw() const2504 int wxStyledTextCtrl::GetPhasesDraw() const
2505 {
2506 return SendMsg(SCI_GETPHASESDRAW, 0, 0);
2507 }
2508
2509 // In one phase draw, text is drawn in a series of rectangular blocks with no overlap.
2510 // In two phase draw, text is drawn in a series of lines allowing runs to overlap horizontally.
2511 // In multiple phase draw, each element is drawn over the whole drawing area, allowing text
2512 // to overlap from one line to the next.
SetPhasesDraw(int phases)2513 void wxStyledTextCtrl::SetPhasesDraw(int phases)
2514 {
2515 SendMsg(SCI_SETPHASESDRAW, phases, 0);
2516 }
2517
2518 // Choose the quality level for text.
SetFontQuality(int fontQuality)2519 void wxStyledTextCtrl::SetFontQuality(int fontQuality)
2520 {
2521 SendMsg(SCI_SETFONTQUALITY, fontQuality, 0);
2522 }
2523
2524 // Retrieve the quality level for text.
GetFontQuality() const2525 int wxStyledTextCtrl::GetFontQuality() const
2526 {
2527 return SendMsg(SCI_GETFONTQUALITY, 0, 0);
2528 }
2529
2530 // Scroll so that a display line is at the top of the display.
SetFirstVisibleLine(int displayLine)2531 void wxStyledTextCtrl::SetFirstVisibleLine(int displayLine)
2532 {
2533 SendMsg(SCI_SETFIRSTVISIBLELINE, displayLine, 0);
2534 }
2535
2536 // Change the effect of pasting when there are multiple selections.
SetMultiPaste(int multiPaste)2537 void wxStyledTextCtrl::SetMultiPaste(int multiPaste)
2538 {
2539 SendMsg(SCI_SETMULTIPASTE, multiPaste, 0);
2540 }
2541
2542 // Retrieve the effect of pasting when there are multiple selections.
GetMultiPaste() const2543 int wxStyledTextCtrl::GetMultiPaste() const
2544 {
2545 return SendMsg(SCI_GETMULTIPASTE, 0, 0);
2546 }
2547
2548 // Retrieve the value of a tag from a regular expression search.
GetTag(int tagNumber) const2549 wxString wxStyledTextCtrl::GetTag(int tagNumber) const {
2550 const int msg = SCI_GETTAG;
2551 long len = SendMsg(msg, tagNumber, (sptr_t)NULL);
2552 if (!len) return wxEmptyString;
2553
2554 wxCharBuffer buf(len);
2555 SendMsg(msg, tagNumber, (sptr_t)buf.data());
2556 return stc2wx(buf);
2557 }
2558
2559 // Join the lines in the target.
LinesJoin()2560 void wxStyledTextCtrl::LinesJoin()
2561 {
2562 SendMsg(SCI_LINESJOIN, 0, 0);
2563 }
2564
2565 // Split the lines in the target into lines that are less wide than pixelWidth
2566 // where possible.
LinesSplit(int pixelWidth)2567 void wxStyledTextCtrl::LinesSplit(int pixelWidth)
2568 {
2569 SendMsg(SCI_LINESSPLIT, pixelWidth, 0);
2570 }
2571
2572 // Set one of the colours used as a chequerboard pattern in the fold margin
SetFoldMarginColour(bool useSetting,const wxColour & back)2573 void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting, const wxColour& back)
2574 {
2575 SendMsg(SCI_SETFOLDMARGINCOLOUR, useSetting, wxColourAsLong(back));
2576 }
2577
2578 // Set the other colour used as a chequerboard pattern in the fold margin
SetFoldMarginHiColour(bool useSetting,const wxColour & fore)2579 void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting, const wxColour& fore)
2580 {
2581 SendMsg(SCI_SETFOLDMARGINHICOLOUR, useSetting, wxColourAsLong(fore));
2582 }
2583
2584 // Move caret down one line.
LineDown()2585 void wxStyledTextCtrl::LineDown()
2586 {
2587 SendMsg(SCI_LINEDOWN, 0, 0);
2588 }
2589
2590 // Move caret down one line extending selection to new caret position.
LineDownExtend()2591 void wxStyledTextCtrl::LineDownExtend()
2592 {
2593 SendMsg(SCI_LINEDOWNEXTEND, 0, 0);
2594 }
2595
2596 // Move caret up one line.
LineUp()2597 void wxStyledTextCtrl::LineUp()
2598 {
2599 SendMsg(SCI_LINEUP, 0, 0);
2600 }
2601
2602 // Move caret up one line extending selection to new caret position.
LineUpExtend()2603 void wxStyledTextCtrl::LineUpExtend()
2604 {
2605 SendMsg(SCI_LINEUPEXTEND, 0, 0);
2606 }
2607
2608 // Move caret left one character.
CharLeft()2609 void wxStyledTextCtrl::CharLeft()
2610 {
2611 SendMsg(SCI_CHARLEFT, 0, 0);
2612 }
2613
2614 // Move caret left one character extending selection to new caret position.
CharLeftExtend()2615 void wxStyledTextCtrl::CharLeftExtend()
2616 {
2617 SendMsg(SCI_CHARLEFTEXTEND, 0, 0);
2618 }
2619
2620 // Move caret right one character.
CharRight()2621 void wxStyledTextCtrl::CharRight()
2622 {
2623 SendMsg(SCI_CHARRIGHT, 0, 0);
2624 }
2625
2626 // Move caret right one character extending selection to new caret position.
CharRightExtend()2627 void wxStyledTextCtrl::CharRightExtend()
2628 {
2629 SendMsg(SCI_CHARRIGHTEXTEND, 0, 0);
2630 }
2631
2632 // Move caret left one word.
WordLeft()2633 void wxStyledTextCtrl::WordLeft()
2634 {
2635 SendMsg(SCI_WORDLEFT, 0, 0);
2636 }
2637
2638 // Move caret left one word extending selection to new caret position.
WordLeftExtend()2639 void wxStyledTextCtrl::WordLeftExtend()
2640 {
2641 SendMsg(SCI_WORDLEFTEXTEND, 0, 0);
2642 }
2643
2644 // Move caret right one word.
WordRight()2645 void wxStyledTextCtrl::WordRight()
2646 {
2647 SendMsg(SCI_WORDRIGHT, 0, 0);
2648 }
2649
2650 // Move caret right one word extending selection to new caret position.
WordRightExtend()2651 void wxStyledTextCtrl::WordRightExtend()
2652 {
2653 SendMsg(SCI_WORDRIGHTEXTEND, 0, 0);
2654 }
2655
2656 // Move caret to first position on line.
Home()2657 void wxStyledTextCtrl::Home()
2658 {
2659 SendMsg(SCI_HOME, 0, 0);
2660 }
2661
2662 // Move caret to first position on line extending selection to new caret position.
HomeExtend()2663 void wxStyledTextCtrl::HomeExtend()
2664 {
2665 SendMsg(SCI_HOMEEXTEND, 0, 0);
2666 }
2667
2668 // Move caret to last position on line.
LineEnd()2669 void wxStyledTextCtrl::LineEnd()
2670 {
2671 SendMsg(SCI_LINEEND, 0, 0);
2672 }
2673
2674 // Move caret to last position on line extending selection to new caret position.
LineEndExtend()2675 void wxStyledTextCtrl::LineEndExtend()
2676 {
2677 SendMsg(SCI_LINEENDEXTEND, 0, 0);
2678 }
2679
2680 // Move caret to first position in document.
DocumentStart()2681 void wxStyledTextCtrl::DocumentStart()
2682 {
2683 SendMsg(SCI_DOCUMENTSTART, 0, 0);
2684 }
2685
2686 // Move caret to first position in document extending selection to new caret position.
DocumentStartExtend()2687 void wxStyledTextCtrl::DocumentStartExtend()
2688 {
2689 SendMsg(SCI_DOCUMENTSTARTEXTEND, 0, 0);
2690 }
2691
2692 // Move caret to last position in document.
DocumentEnd()2693 void wxStyledTextCtrl::DocumentEnd()
2694 {
2695 SendMsg(SCI_DOCUMENTEND, 0, 0);
2696 }
2697
2698 // Move caret to last position in document extending selection to new caret position.
DocumentEndExtend()2699 void wxStyledTextCtrl::DocumentEndExtend()
2700 {
2701 SendMsg(SCI_DOCUMENTENDEXTEND, 0, 0);
2702 }
2703
2704 // Move caret one page up.
PageUp()2705 void wxStyledTextCtrl::PageUp()
2706 {
2707 SendMsg(SCI_PAGEUP, 0, 0);
2708 }
2709
2710 // Move caret one page up extending selection to new caret position.
PageUpExtend()2711 void wxStyledTextCtrl::PageUpExtend()
2712 {
2713 SendMsg(SCI_PAGEUPEXTEND, 0, 0);
2714 }
2715
2716 // Move caret one page down.
PageDown()2717 void wxStyledTextCtrl::PageDown()
2718 {
2719 SendMsg(SCI_PAGEDOWN, 0, 0);
2720 }
2721
2722 // Move caret one page down extending selection to new caret position.
PageDownExtend()2723 void wxStyledTextCtrl::PageDownExtend()
2724 {
2725 SendMsg(SCI_PAGEDOWNEXTEND, 0, 0);
2726 }
2727
2728 // Switch from insert to overtype mode or the reverse.
EditToggleOvertype()2729 void wxStyledTextCtrl::EditToggleOvertype()
2730 {
2731 SendMsg(SCI_EDITTOGGLEOVERTYPE, 0, 0);
2732 }
2733
2734 // Cancel any modes such as call tip or auto-completion list display.
Cancel()2735 void wxStyledTextCtrl::Cancel()
2736 {
2737 SendMsg(SCI_CANCEL, 0, 0);
2738 }
2739
2740 // Delete the selection or if no selection, the character before the caret.
DeleteBack()2741 void wxStyledTextCtrl::DeleteBack()
2742 {
2743 SendMsg(SCI_DELETEBACK, 0, 0);
2744 }
2745
2746 // If selection is empty or all on one line replace the selection with a tab character.
2747 // If more than one line selected, indent the lines.
Tab()2748 void wxStyledTextCtrl::Tab()
2749 {
2750 SendMsg(SCI_TAB, 0, 0);
2751 }
2752
2753 // Dedent the selected lines.
BackTab()2754 void wxStyledTextCtrl::BackTab()
2755 {
2756 SendMsg(SCI_BACKTAB, 0, 0);
2757 }
2758
2759 // Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
NewLine()2760 void wxStyledTextCtrl::NewLine()
2761 {
2762 SendMsg(SCI_NEWLINE, 0, 0);
2763 }
2764
2765 // Insert a Form Feed character.
FormFeed()2766 void wxStyledTextCtrl::FormFeed()
2767 {
2768 SendMsg(SCI_FORMFEED, 0, 0);
2769 }
2770
2771 // Move caret to before first visible character on line.
2772 // If already there move to first character on line.
VCHome()2773 void wxStyledTextCtrl::VCHome()
2774 {
2775 SendMsg(SCI_VCHOME, 0, 0);
2776 }
2777
2778 // Like VCHome but extending selection to new caret position.
VCHomeExtend()2779 void wxStyledTextCtrl::VCHomeExtend()
2780 {
2781 SendMsg(SCI_VCHOMEEXTEND, 0, 0);
2782 }
2783
2784 // Magnify the displayed text by increasing the sizes by 1 point.
ZoomIn()2785 void wxStyledTextCtrl::ZoomIn()
2786 {
2787 SendMsg(SCI_ZOOMIN, 0, 0);
2788 }
2789
2790 // Make the displayed text smaller by decreasing the sizes by 1 point.
ZoomOut()2791 void wxStyledTextCtrl::ZoomOut()
2792 {
2793 SendMsg(SCI_ZOOMOUT, 0, 0);
2794 }
2795
2796 // Delete the word to the left of the caret.
DelWordLeft()2797 void wxStyledTextCtrl::DelWordLeft()
2798 {
2799 SendMsg(SCI_DELWORDLEFT, 0, 0);
2800 }
2801
2802 // Delete the word to the right of the caret.
DelWordRight()2803 void wxStyledTextCtrl::DelWordRight()
2804 {
2805 SendMsg(SCI_DELWORDRIGHT, 0, 0);
2806 }
2807
2808 // Delete the word to the right of the caret, but not the trailing non-word characters.
DelWordRightEnd()2809 void wxStyledTextCtrl::DelWordRightEnd()
2810 {
2811 SendMsg(SCI_DELWORDRIGHTEND, 0, 0);
2812 }
2813
2814 // Cut the line containing the caret.
LineCut()2815 void wxStyledTextCtrl::LineCut()
2816 {
2817 SendMsg(SCI_LINECUT, 0, 0);
2818 }
2819
2820 // Delete the line containing the caret.
LineDelete()2821 void wxStyledTextCtrl::LineDelete()
2822 {
2823 SendMsg(SCI_LINEDELETE, 0, 0);
2824 }
2825
2826 // Switch the current line with the previous.
LineTranspose()2827 void wxStyledTextCtrl::LineTranspose()
2828 {
2829 SendMsg(SCI_LINETRANSPOSE, 0, 0);
2830 }
2831
2832 // Duplicate the current line.
LineDuplicate()2833 void wxStyledTextCtrl::LineDuplicate()
2834 {
2835 SendMsg(SCI_LINEDUPLICATE, 0, 0);
2836 }
2837
2838 // Transform the selection to lower case.
LowerCase()2839 void wxStyledTextCtrl::LowerCase()
2840 {
2841 SendMsg(SCI_LOWERCASE, 0, 0);
2842 }
2843
2844 // Transform the selection to upper case.
UpperCase()2845 void wxStyledTextCtrl::UpperCase()
2846 {
2847 SendMsg(SCI_UPPERCASE, 0, 0);
2848 }
2849
2850 // Scroll the document down, keeping the caret visible.
LineScrollDown()2851 void wxStyledTextCtrl::LineScrollDown()
2852 {
2853 SendMsg(SCI_LINESCROLLDOWN, 0, 0);
2854 }
2855
2856 // Scroll the document up, keeping the caret visible.
LineScrollUp()2857 void wxStyledTextCtrl::LineScrollUp()
2858 {
2859 SendMsg(SCI_LINESCROLLUP, 0, 0);
2860 }
2861
2862 // Delete the selection or if no selection, the character before the caret.
2863 // Will not delete the character before at the start of a line.
DeleteBackNotLine()2864 void wxStyledTextCtrl::DeleteBackNotLine()
2865 {
2866 SendMsg(SCI_DELETEBACKNOTLINE, 0, 0);
2867 }
2868
2869 // Move caret to first position on display line.
HomeDisplay()2870 void wxStyledTextCtrl::HomeDisplay()
2871 {
2872 SendMsg(SCI_HOMEDISPLAY, 0, 0);
2873 }
2874
2875 // Move caret to first position on display line extending selection to
2876 // new caret position.
HomeDisplayExtend()2877 void wxStyledTextCtrl::HomeDisplayExtend()
2878 {
2879 SendMsg(SCI_HOMEDISPLAYEXTEND, 0, 0);
2880 }
2881
2882 // Move caret to last position on display line.
LineEndDisplay()2883 void wxStyledTextCtrl::LineEndDisplay()
2884 {
2885 SendMsg(SCI_LINEENDDISPLAY, 0, 0);
2886 }
2887
2888 // Move caret to last position on display line extending selection to new
2889 // caret position.
LineEndDisplayExtend()2890 void wxStyledTextCtrl::LineEndDisplayExtend()
2891 {
2892 SendMsg(SCI_LINEENDDISPLAYEXTEND, 0, 0);
2893 }
2894
2895 // Like Home but when word-wrap is enabled goes first to start of display line
2896 // HomeDisplay, then to start of document line Home.
HomeWrap()2897 void wxStyledTextCtrl::HomeWrap()
2898 {
2899 SendMsg(SCI_HOMEWRAP, 0, 0);
2900 }
2901
2902 // Like HomeExtend but when word-wrap is enabled extends first to start of display line
2903 // HomeDisplayExtend, then to start of document line HomeExtend.
HomeWrapExtend()2904 void wxStyledTextCtrl::HomeWrapExtend()
2905 {
2906 SendMsg(SCI_HOMEWRAPEXTEND, 0, 0);
2907 }
2908
2909 // Like LineEnd but when word-wrap is enabled goes first to end of display line
2910 // LineEndDisplay, then to start of document line LineEnd.
LineEndWrap()2911 void wxStyledTextCtrl::LineEndWrap()
2912 {
2913 SendMsg(SCI_LINEENDWRAP, 0, 0);
2914 }
2915
2916 // Like LineEndExtend but when word-wrap is enabled extends first to end of display line
2917 // LineEndDisplayExtend, then to start of document line LineEndExtend.
LineEndWrapExtend()2918 void wxStyledTextCtrl::LineEndWrapExtend()
2919 {
2920 SendMsg(SCI_LINEENDWRAPEXTEND, 0, 0);
2921 }
2922
2923 // Like VCHome but when word-wrap is enabled goes first to start of display line
2924 // VCHomeDisplay, then behaves like VCHome.
VCHomeWrap()2925 void wxStyledTextCtrl::VCHomeWrap()
2926 {
2927 SendMsg(SCI_VCHOMEWRAP, 0, 0);
2928 }
2929
2930 // Like VCHomeExtend but when word-wrap is enabled extends first to start of display line
2931 // VCHomeDisplayExtend, then behaves like VCHomeExtend.
VCHomeWrapExtend()2932 void wxStyledTextCtrl::VCHomeWrapExtend()
2933 {
2934 SendMsg(SCI_VCHOMEWRAPEXTEND, 0, 0);
2935 }
2936
2937 // Copy the line containing the caret.
LineCopy()2938 void wxStyledTextCtrl::LineCopy()
2939 {
2940 SendMsg(SCI_LINECOPY, 0, 0);
2941 }
2942
2943 // Move the caret inside current view if it's not there already.
MoveCaretInsideView()2944 void wxStyledTextCtrl::MoveCaretInsideView()
2945 {
2946 SendMsg(SCI_MOVECARETINSIDEVIEW, 0, 0);
2947 }
2948
2949 // How many characters are on a line, including end of line characters?
LineLength(int line) const2950 int wxStyledTextCtrl::LineLength(int line) const
2951 {
2952 return SendMsg(SCI_LINELENGTH, line, 0);
2953 }
2954
2955 // Highlight the characters at two positions.
BraceHighlight(int posA,int posB)2956 void wxStyledTextCtrl::BraceHighlight(int posA, int posB)
2957 {
2958 SendMsg(SCI_BRACEHIGHLIGHT, posA, posB);
2959 }
2960
2961 // Use specified indicator to highlight matching braces instead of changing their style.
BraceHighlightIndicator(bool useSetting,int indicator)2962 void wxStyledTextCtrl::BraceHighlightIndicator(bool useSetting, int indicator)
2963 {
2964 SendMsg(SCI_BRACEHIGHLIGHTINDICATOR, useSetting, indicator);
2965 }
2966
2967 // Highlight the character at a position indicating there is no matching brace.
BraceBadLight(int pos)2968 void wxStyledTextCtrl::BraceBadLight(int pos)
2969 {
2970 SendMsg(SCI_BRACEBADLIGHT, pos, 0);
2971 }
2972
2973 // Use specified indicator to highlight non matching brace instead of changing its style.
BraceBadLightIndicator(bool useSetting,int indicator)2974 void wxStyledTextCtrl::BraceBadLightIndicator(bool useSetting, int indicator)
2975 {
2976 SendMsg(SCI_BRACEBADLIGHTINDICATOR, useSetting, indicator);
2977 }
2978
2979 // Find the position of a matching brace or wxSTC_INVALID_POSITION if no match.
2980 // The maxReStyle must be 0 for now. It may be defined in a future release.
BraceMatch(int pos,int maxReStyle)2981 int wxStyledTextCtrl::BraceMatch(int pos, int maxReStyle){
2982 wxASSERT_MSG(maxReStyle==0,
2983 "The second argument passed to BraceMatch should be 0");
2984
2985 return SendMsg(SCI_BRACEMATCH, pos, maxReStyle);
2986 }
2987
2988 // Are the end of line characters visible?
GetViewEOL() const2989 bool wxStyledTextCtrl::GetViewEOL() const
2990 {
2991 return SendMsg(SCI_GETVIEWEOL, 0, 0) != 0;
2992 }
2993
2994 // Make the end of line characters visible or invisible.
SetViewEOL(bool visible)2995 void wxStyledTextCtrl::SetViewEOL(bool visible)
2996 {
2997 SendMsg(SCI_SETVIEWEOL, visible, 0);
2998 }
2999
3000 // Retrieve a pointer to the document object.
GetDocPointer()3001 void* wxStyledTextCtrl::GetDocPointer() {
3002 return (void*)SendMsg(SCI_GETDOCPOINTER);
3003 }
3004
3005 // Change the document object used.
SetDocPointer(void * docPointer)3006 void wxStyledTextCtrl::SetDocPointer(void* docPointer) {
3007 SendMsg(SCI_SETDOCPOINTER, 0, (sptr_t)docPointer);
3008 }
3009
3010 // Set which document modification events are sent to the container.
SetModEventMask(int eventMask)3011 void wxStyledTextCtrl::SetModEventMask(int eventMask)
3012 {
3013 SendMsg(SCI_SETMODEVENTMASK, eventMask, 0);
3014 }
3015
3016 // Retrieve the column number which text should be kept within.
GetEdgeColumn() const3017 int wxStyledTextCtrl::GetEdgeColumn() const
3018 {
3019 return SendMsg(SCI_GETEDGECOLUMN, 0, 0);
3020 }
3021
3022 // Set the column number of the edge.
3023 // If text goes past the edge then it is highlighted.
SetEdgeColumn(int column)3024 void wxStyledTextCtrl::SetEdgeColumn(int column)
3025 {
3026 SendMsg(SCI_SETEDGECOLUMN, column, 0);
3027 }
3028
3029 // Retrieve the edge highlight mode.
GetEdgeMode() const3030 int wxStyledTextCtrl::GetEdgeMode() const
3031 {
3032 return SendMsg(SCI_GETEDGEMODE, 0, 0);
3033 }
3034
3035 // The edge may be displayed by a line (wxSTC_EDGE_LINE/wxSTC_EDGE_MULTILINE) or by highlighting text that
3036 // goes beyond it (wxSTC_EDGE_BACKGROUND) or not displayed at all (wxSTC_EDGE_NONE).
SetEdgeMode(int edgeMode)3037 void wxStyledTextCtrl::SetEdgeMode(int edgeMode)
3038 {
3039 SendMsg(SCI_SETEDGEMODE, edgeMode, 0);
3040 }
3041
3042 // Retrieve the colour used in edge indication.
GetEdgeColour() const3043 wxColour wxStyledTextCtrl::GetEdgeColour() const
3044 {
3045 long c = SendMsg(SCI_GETEDGECOLOUR, 0, 0);
3046 return wxColourFromLong(c);
3047 }
3048
3049 // Change the colour used in edge indication.
SetEdgeColour(const wxColour & edgeColour)3050 void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour)
3051 {
3052 SendMsg(SCI_SETEDGECOLOUR, wxColourAsLong(edgeColour), 0);
3053 }
3054
3055 // Add a new vertical edge to the view.
MultiEdgeAddLine(int column,const wxColour & edgeColour)3056 void wxStyledTextCtrl::MultiEdgeAddLine(int column, const wxColour& edgeColour)
3057 {
3058 SendMsg(SCI_MULTIEDGEADDLINE, column, wxColourAsLong(edgeColour));
3059 }
3060
3061 // Clear all vertical edges.
MultiEdgeClearAll()3062 void wxStyledTextCtrl::MultiEdgeClearAll()
3063 {
3064 SendMsg(SCI_MULTIEDGECLEARALL, 0, 0);
3065 }
3066
3067 // Sets the current caret position to be the search anchor.
SearchAnchor()3068 void wxStyledTextCtrl::SearchAnchor()
3069 {
3070 SendMsg(SCI_SEARCHANCHOR, 0, 0);
3071 }
3072
3073 // Find some text starting at the search anchor.
3074 // Does not ensure the selection is visible.
SearchNext(int searchFlags,const wxString & text)3075 int wxStyledTextCtrl::SearchNext(int searchFlags, const wxString& text)
3076 {
3077 return SendMsg(SCI_SEARCHNEXT, searchFlags, (sptr_t)(const char*)wx2stc(text));
3078 }
3079
3080 // Find some text starting at the search anchor and moving backwards.
3081 // Does not ensure the selection is visible.
SearchPrev(int searchFlags,const wxString & text)3082 int wxStyledTextCtrl::SearchPrev(int searchFlags, const wxString& text)
3083 {
3084 return SendMsg(SCI_SEARCHPREV, searchFlags, (sptr_t)(const char*)wx2stc(text));
3085 }
3086
3087 // Retrieves the number of lines completely visible.
LinesOnScreen() const3088 int wxStyledTextCtrl::LinesOnScreen() const
3089 {
3090 return SendMsg(SCI_LINESONSCREEN, 0, 0);
3091 }
3092
3093 // Set whether a pop up menu is displayed automatically when the user presses
3094 // the wrong mouse button on certain areas.
UsePopUp(int popUpMode)3095 void wxStyledTextCtrl::UsePopUp(int popUpMode)
3096 {
3097 SendMsg(SCI_USEPOPUP, popUpMode, 0);
3098 }
3099
3100 // Is the selection rectangular? The alternative is the more common stream selection.
SelectionIsRectangle() const3101 bool wxStyledTextCtrl::SelectionIsRectangle() const
3102 {
3103 return SendMsg(SCI_SELECTIONISRECTANGLE, 0, 0) != 0;
3104 }
3105
3106 // Set the zoom level. This number of points is added to the size of all fonts.
3107 // It may be positive to magnify or negative to reduce.
SetZoom(int zoomInPoints)3108 void wxStyledTextCtrl::SetZoom(int zoomInPoints)
3109 {
3110 SendMsg(SCI_SETZOOM, zoomInPoints, 0);
3111 }
3112
3113 // Retrieve the zoom level.
GetZoom() const3114 int wxStyledTextCtrl::GetZoom() const
3115 {
3116 return SendMsg(SCI_GETZOOM, 0, 0);
3117 }
3118
3119 // Create a new document object.
3120 // Starts with reference count of 1 and not selected into editor.
CreateDocument()3121 void* wxStyledTextCtrl::CreateDocument() {
3122 return (void*)SendMsg(SCI_CREATEDOCUMENT);
3123 }
3124
3125 // Extend life of document.
AddRefDocument(void * docPointer)3126 void wxStyledTextCtrl::AddRefDocument(void* docPointer) {
3127 SendMsg(SCI_ADDREFDOCUMENT, 0, (sptr_t)docPointer);
3128 }
3129
3130 // Release a reference to the document, deleting document if it fades to black.
ReleaseDocument(void * docPointer)3131 void wxStyledTextCtrl::ReleaseDocument(void* docPointer) {
3132 SendMsg(SCI_RELEASEDOCUMENT, 0, (sptr_t)docPointer);
3133 }
3134
3135 // Get which document modification events are sent to the container.
GetModEventMask() const3136 int wxStyledTextCtrl::GetModEventMask() const
3137 {
3138 return SendMsg(SCI_GETMODEVENTMASK, 0, 0);
3139 }
3140
3141 // Change internal focus flag.
SetSTCFocus(bool focus)3142 void wxStyledTextCtrl::SetSTCFocus(bool focus)
3143 {
3144 SendMsg(SCI_SETFOCUS, focus, 0);
3145 }
3146
3147 // Get internal focus flag.
GetSTCFocus() const3148 bool wxStyledTextCtrl::GetSTCFocus() const
3149 {
3150 return SendMsg(SCI_GETFOCUS, 0, 0) != 0;
3151 }
3152
3153 // Change error status - 0 = OK.
SetStatus(int status)3154 void wxStyledTextCtrl::SetStatus(int status)
3155 {
3156 SendMsg(SCI_SETSTATUS, status, 0);
3157 }
3158
3159 // Get error status.
GetStatus() const3160 int wxStyledTextCtrl::GetStatus() const
3161 {
3162 return SendMsg(SCI_GETSTATUS, 0, 0);
3163 }
3164
3165 // Set whether the mouse is captured when its button is pressed.
SetMouseDownCaptures(bool captures)3166 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures)
3167 {
3168 SendMsg(SCI_SETMOUSEDOWNCAPTURES, captures, 0);
3169 }
3170
3171 // Get whether mouse gets captured.
GetMouseDownCaptures() const3172 bool wxStyledTextCtrl::GetMouseDownCaptures() const
3173 {
3174 return SendMsg(SCI_GETMOUSEDOWNCAPTURES, 0, 0) != 0;
3175 }
3176
3177 // Set whether the mouse wheel can be active outside the window.
SetMouseWheelCaptures(bool captures)3178 void wxStyledTextCtrl::SetMouseWheelCaptures(bool captures)
3179 {
3180 SendMsg(SCI_SETMOUSEWHEELCAPTURES, captures, 0);
3181 }
3182
3183 // Get whether mouse wheel can be active outside the window.
GetMouseWheelCaptures() const3184 bool wxStyledTextCtrl::GetMouseWheelCaptures() const
3185 {
3186 return SendMsg(SCI_GETMOUSEWHEELCAPTURES, 0, 0) != 0;
3187 }
3188
3189 // Sets the cursor to one of the wxSTC_CURSOR* values.
SetSTCCursor(int cursorType)3190 void wxStyledTextCtrl::SetSTCCursor(int cursorType)
3191 {
3192 SendMsg(SCI_SETCURSOR, cursorType, 0);
3193 }
3194
3195 // Get cursor type.
GetSTCCursor() const3196 int wxStyledTextCtrl::GetSTCCursor() const
3197 {
3198 return SendMsg(SCI_GETCURSOR, 0, 0);
3199 }
3200
3201 // Change the way control characters are displayed:
3202 // If symbol is < 32, keep the drawn way, else, use the given character.
SetControlCharSymbol(int symbol)3203 void wxStyledTextCtrl::SetControlCharSymbol(int symbol)
3204 {
3205 SendMsg(SCI_SETCONTROLCHARSYMBOL, symbol, 0);
3206 }
3207
3208 // Get the way control characters are displayed.
GetControlCharSymbol() const3209 int wxStyledTextCtrl::GetControlCharSymbol() const
3210 {
3211 return SendMsg(SCI_GETCONTROLCHARSYMBOL, 0, 0);
3212 }
3213
3214 // Move to the previous change in capitalisation.
WordPartLeft()3215 void wxStyledTextCtrl::WordPartLeft()
3216 {
3217 SendMsg(SCI_WORDPARTLEFT, 0, 0);
3218 }
3219
3220 // Move to the previous change in capitalisation extending selection
3221 // to new caret position.
WordPartLeftExtend()3222 void wxStyledTextCtrl::WordPartLeftExtend()
3223 {
3224 SendMsg(SCI_WORDPARTLEFTEXTEND, 0, 0);
3225 }
3226
3227 // Move to the change next in capitalisation.
WordPartRight()3228 void wxStyledTextCtrl::WordPartRight()
3229 {
3230 SendMsg(SCI_WORDPARTRIGHT, 0, 0);
3231 }
3232
3233 // Move to the next change in capitalisation extending selection
3234 // to new caret position.
WordPartRightExtend()3235 void wxStyledTextCtrl::WordPartRightExtend()
3236 {
3237 SendMsg(SCI_WORDPARTRIGHTEXTEND, 0, 0);
3238 }
3239
3240 // Set the way the display area is determined when a particular line
3241 // is to be moved to by Find, FindNext, GotoLine, etc.
SetVisiblePolicy(int visiblePolicy,int visibleSlop)3242 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop)
3243 {
3244 SendMsg(SCI_SETVISIBLEPOLICY, visiblePolicy, visibleSlop);
3245 }
3246
3247 // Delete back from the current position to the start of the line.
DelLineLeft()3248 void wxStyledTextCtrl::DelLineLeft()
3249 {
3250 SendMsg(SCI_DELLINELEFT, 0, 0);
3251 }
3252
3253 // Delete forwards from the current position to the end of the line.
DelLineRight()3254 void wxStyledTextCtrl::DelLineRight()
3255 {
3256 SendMsg(SCI_DELLINERIGHT, 0, 0);
3257 }
3258
3259 // Set the xOffset (ie, horizontal scroll position).
SetXOffset(int xOffset)3260 void wxStyledTextCtrl::SetXOffset(int xOffset)
3261 {
3262 SendMsg(SCI_SETXOFFSET, xOffset, 0);
3263 }
3264
3265 // Get the xOffset (ie, horizontal scroll position).
GetXOffset() const3266 int wxStyledTextCtrl::GetXOffset() const
3267 {
3268 return SendMsg(SCI_GETXOFFSET, 0, 0);
3269 }
3270
3271 // Set the last x chosen value to be the caret x position.
ChooseCaretX()3272 void wxStyledTextCtrl::ChooseCaretX()
3273 {
3274 SendMsg(SCI_CHOOSECARETX, 0, 0);
3275 }
3276
3277 // Set the way the caret is kept visible when going sideways.
3278 // The exclusion zone is given in pixels.
SetXCaretPolicy(int caretPolicy,int caretSlop)3279 void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy, int caretSlop)
3280 {
3281 SendMsg(SCI_SETXCARETPOLICY, caretPolicy, caretSlop);
3282 }
3283
3284 // Set the way the line the caret is on is kept visible.
3285 // The exclusion zone is given in lines.
SetYCaretPolicy(int caretPolicy,int caretSlop)3286 void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy, int caretSlop)
3287 {
3288 SendMsg(SCI_SETYCARETPOLICY, caretPolicy, caretSlop);
3289 }
3290
3291 // Set printing to line wrapped (wxSTC_WRAP_WORD) or not line wrapped (wxSTC_WRAP_NONE).
SetPrintWrapMode(int wrapMode)3292 void wxStyledTextCtrl::SetPrintWrapMode(int wrapMode)
3293 {
3294 SendMsg(SCI_SETPRINTWRAPMODE, wrapMode, 0);
3295 }
3296
3297 // Is printing line wrapped?
GetPrintWrapMode() const3298 int wxStyledTextCtrl::GetPrintWrapMode() const
3299 {
3300 return SendMsg(SCI_GETPRINTWRAPMODE, 0, 0);
3301 }
3302
3303 // Set a fore colour for active hotspots.
SetHotspotActiveForeground(bool useSetting,const wxColour & fore)3304 void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting, const wxColour& fore)
3305 {
3306 SendMsg(SCI_SETHOTSPOTACTIVEFORE, useSetting, wxColourAsLong(fore));
3307 }
3308
3309 // Get the fore colour for active hotspots.
GetHotspotActiveForeground() const3310 wxColour wxStyledTextCtrl::GetHotspotActiveForeground() const
3311 {
3312 long c = SendMsg(SCI_GETHOTSPOTACTIVEFORE, 0, 0);
3313 return wxColourFromLong(c);
3314 }
3315
3316 // Set a back colour for active hotspots.
SetHotspotActiveBackground(bool useSetting,const wxColour & back)3317 void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting, const wxColour& back)
3318 {
3319 SendMsg(SCI_SETHOTSPOTACTIVEBACK, useSetting, wxColourAsLong(back));
3320 }
3321
3322 // Get the back colour for active hotspots.
GetHotspotActiveBackground() const3323 wxColour wxStyledTextCtrl::GetHotspotActiveBackground() const
3324 {
3325 long c = SendMsg(SCI_GETHOTSPOTACTIVEBACK, 0, 0);
3326 return wxColourFromLong(c);
3327 }
3328
3329 // Enable / Disable underlining active hotspots.
SetHotspotActiveUnderline(bool underline)3330 void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline)
3331 {
3332 SendMsg(SCI_SETHOTSPOTACTIVEUNDERLINE, underline, 0);
3333 }
3334
3335 // Get whether underlining for active hotspots.
GetHotspotActiveUnderline() const3336 bool wxStyledTextCtrl::GetHotspotActiveUnderline() const
3337 {
3338 return SendMsg(SCI_GETHOTSPOTACTIVEUNDERLINE, 0, 0) != 0;
3339 }
3340
3341 // Limit hotspots to single line so hotspots on two lines don't merge.
SetHotspotSingleLine(bool singleLine)3342 void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine)
3343 {
3344 SendMsg(SCI_SETHOTSPOTSINGLELINE, singleLine, 0);
3345 }
3346
3347 // Get the HotspotSingleLine property
GetHotspotSingleLine() const3348 bool wxStyledTextCtrl::GetHotspotSingleLine() const
3349 {
3350 return SendMsg(SCI_GETHOTSPOTSINGLELINE, 0, 0) != 0;
3351 }
3352
3353 // Move caret down one paragraph (delimited by empty lines).
ParaDown()3354 void wxStyledTextCtrl::ParaDown()
3355 {
3356 SendMsg(SCI_PARADOWN, 0, 0);
3357 }
3358
3359 // Extend selection down one paragraph (delimited by empty lines).
ParaDownExtend()3360 void wxStyledTextCtrl::ParaDownExtend()
3361 {
3362 SendMsg(SCI_PARADOWNEXTEND, 0, 0);
3363 }
3364
3365 // Move caret up one paragraph (delimited by empty lines).
ParaUp()3366 void wxStyledTextCtrl::ParaUp()
3367 {
3368 SendMsg(SCI_PARAUP, 0, 0);
3369 }
3370
3371 // Extend selection up one paragraph (delimited by empty lines).
ParaUpExtend()3372 void wxStyledTextCtrl::ParaUpExtend()
3373 {
3374 SendMsg(SCI_PARAUPEXTEND, 0, 0);
3375 }
3376
3377 // Given a valid document position, return the previous position taking code
3378 // page into account. Returns 0 if passed 0.
PositionBefore(int pos)3379 int wxStyledTextCtrl::PositionBefore(int pos)
3380 {
3381 return SendMsg(SCI_POSITIONBEFORE, pos, 0);
3382 }
3383
3384 // Given a valid document position, return the next position taking code
3385 // page into account. Maximum value returned is the last position in the document.
PositionAfter(int pos)3386 int wxStyledTextCtrl::PositionAfter(int pos)
3387 {
3388 return SendMsg(SCI_POSITIONAFTER, pos, 0);
3389 }
3390
3391 // Given a valid document position, return a position that differs in a number
3392 // of characters. Returned value is always between 0 and last position in document.
PositionRelative(int pos,int relative)3393 int wxStyledTextCtrl::PositionRelative(int pos, int relative)
3394 {
3395 return SendMsg(SCI_POSITIONRELATIVE, pos, relative);
3396 }
3397
3398 // Copy a range of text to the clipboard. Positions are clipped into the document.
CopyRange(int start,int end)3399 void wxStyledTextCtrl::CopyRange(int start, int end)
3400 {
3401 SendMsg(SCI_COPYRANGE, start, end);
3402 }
3403
3404 // Copy argument text to the clipboard.
CopyText(int length,const wxString & text)3405 void wxStyledTextCtrl::CopyText(int length, const wxString& text)
3406 {
3407 SendMsg(SCI_COPYTEXT, length, (sptr_t)(const char*)wx2stc(text));
3408 }
3409
3410 // Set the selection mode to stream (wxSTC_SEL_STREAM) or rectangular (wxSTC_SEL_RECTANGLE/wxSTC_SEL_THIN) or
3411 // by lines (wxSTC_SEL_LINES).
SetSelectionMode(int selectionMode)3412 void wxStyledTextCtrl::SetSelectionMode(int selectionMode)
3413 {
3414 SendMsg(SCI_SETSELECTIONMODE, selectionMode, 0);
3415 }
3416
3417 // Get the mode of the current selection.
GetSelectionMode() const3418 int wxStyledTextCtrl::GetSelectionMode() const
3419 {
3420 return SendMsg(SCI_GETSELECTIONMODE, 0, 0);
3421 }
3422
3423 // Retrieve the position of the start of the selection at the given line (wxSTC_INVALID_POSITION if no selection on this line).
GetLineSelStartPosition(int line)3424 int wxStyledTextCtrl::GetLineSelStartPosition(int line)
3425 {
3426 return SendMsg(SCI_GETLINESELSTARTPOSITION, line, 0);
3427 }
3428
3429 // Retrieve the position of the end of the selection at the given line (wxSTC_INVALID_POSITION if no selection on this line).
GetLineSelEndPosition(int line)3430 int wxStyledTextCtrl::GetLineSelEndPosition(int line)
3431 {
3432 return SendMsg(SCI_GETLINESELENDPOSITION, line, 0);
3433 }
3434
3435 // Move caret down one line, extending rectangular selection to new caret position.
LineDownRectExtend()3436 void wxStyledTextCtrl::LineDownRectExtend()
3437 {
3438 SendMsg(SCI_LINEDOWNRECTEXTEND, 0, 0);
3439 }
3440
3441 // Move caret up one line, extending rectangular selection to new caret position.
LineUpRectExtend()3442 void wxStyledTextCtrl::LineUpRectExtend()
3443 {
3444 SendMsg(SCI_LINEUPRECTEXTEND, 0, 0);
3445 }
3446
3447 // Move caret left one character, extending rectangular selection to new caret position.
CharLeftRectExtend()3448 void wxStyledTextCtrl::CharLeftRectExtend()
3449 {
3450 SendMsg(SCI_CHARLEFTRECTEXTEND, 0, 0);
3451 }
3452
3453 // Move caret right one character, extending rectangular selection to new caret position.
CharRightRectExtend()3454 void wxStyledTextCtrl::CharRightRectExtend()
3455 {
3456 SendMsg(SCI_CHARRIGHTRECTEXTEND, 0, 0);
3457 }
3458
3459 // Move caret to first position on line, extending rectangular selection to new caret position.
HomeRectExtend()3460 void wxStyledTextCtrl::HomeRectExtend()
3461 {
3462 SendMsg(SCI_HOMERECTEXTEND, 0, 0);
3463 }
3464
3465 // Move caret to before first visible character on line.
3466 // If already there move to first character on line.
3467 // In either case, extend rectangular selection to new caret position.
VCHomeRectExtend()3468 void wxStyledTextCtrl::VCHomeRectExtend()
3469 {
3470 SendMsg(SCI_VCHOMERECTEXTEND, 0, 0);
3471 }
3472
3473 // Move caret to last position on line, extending rectangular selection to new caret position.
LineEndRectExtend()3474 void wxStyledTextCtrl::LineEndRectExtend()
3475 {
3476 SendMsg(SCI_LINEENDRECTEXTEND, 0, 0);
3477 }
3478
3479 // Move caret one page up, extending rectangular selection to new caret position.
PageUpRectExtend()3480 void wxStyledTextCtrl::PageUpRectExtend()
3481 {
3482 SendMsg(SCI_PAGEUPRECTEXTEND, 0, 0);
3483 }
3484
3485 // Move caret one page down, extending rectangular selection to new caret position.
PageDownRectExtend()3486 void wxStyledTextCtrl::PageDownRectExtend()
3487 {
3488 SendMsg(SCI_PAGEDOWNRECTEXTEND, 0, 0);
3489 }
3490
3491 // Move caret to top of page, or one page up if already at top of page.
StutteredPageUp()3492 void wxStyledTextCtrl::StutteredPageUp()
3493 {
3494 SendMsg(SCI_STUTTEREDPAGEUP, 0, 0);
3495 }
3496
3497 // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
StutteredPageUpExtend()3498 void wxStyledTextCtrl::StutteredPageUpExtend()
3499 {
3500 SendMsg(SCI_STUTTEREDPAGEUPEXTEND, 0, 0);
3501 }
3502
3503 // Move caret to bottom of page, or one page down if already at bottom of page.
StutteredPageDown()3504 void wxStyledTextCtrl::StutteredPageDown()
3505 {
3506 SendMsg(SCI_STUTTEREDPAGEDOWN, 0, 0);
3507 }
3508
3509 // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
StutteredPageDownExtend()3510 void wxStyledTextCtrl::StutteredPageDownExtend()
3511 {
3512 SendMsg(SCI_STUTTEREDPAGEDOWNEXTEND, 0, 0);
3513 }
3514
3515 // Move caret left one word, position cursor at end of word.
WordLeftEnd()3516 void wxStyledTextCtrl::WordLeftEnd()
3517 {
3518 SendMsg(SCI_WORDLEFTEND, 0, 0);
3519 }
3520
3521 // Move caret left one word, position cursor at end of word, extending selection to new caret position.
WordLeftEndExtend()3522 void wxStyledTextCtrl::WordLeftEndExtend()
3523 {
3524 SendMsg(SCI_WORDLEFTENDEXTEND, 0, 0);
3525 }
3526
3527 // Move caret right one word, position cursor at end of word.
WordRightEnd()3528 void wxStyledTextCtrl::WordRightEnd()
3529 {
3530 SendMsg(SCI_WORDRIGHTEND, 0, 0);
3531 }
3532
3533 // Move caret right one word, position cursor at end of word, extending selection to new caret position.
WordRightEndExtend()3534 void wxStyledTextCtrl::WordRightEndExtend()
3535 {
3536 SendMsg(SCI_WORDRIGHTENDEXTEND, 0, 0);
3537 }
3538
3539 // Set the set of characters making up whitespace for when moving or selecting by word.
3540 // Should be called after SetWordChars.
SetWhitespaceChars(const wxString & characters)3541 void wxStyledTextCtrl::SetWhitespaceChars(const wxString& characters)
3542 {
3543 SendMsg(SCI_SETWHITESPACECHARS, 0, (sptr_t)(const char*)wx2stc(characters));
3544 }
3545
3546 // Get the set of characters making up whitespace for when moving or selecting by word.
GetWhitespaceChars() const3547 wxString wxStyledTextCtrl::GetWhitespaceChars() const {
3548 const int msg = SCI_GETWHITESPACECHARS;
3549 int len = SendMsg(msg, 0, (sptr_t)NULL);
3550 if (!len) return wxEmptyString;
3551
3552 wxMemoryBuffer mbuf(len+1);
3553 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3554 SendMsg(msg, 0, (sptr_t)buf);
3555 mbuf.UngetWriteBuf(len);
3556 mbuf.AppendByte(0);
3557 return stc2wx(buf);
3558 }
3559
3560 // Set the set of characters making up punctuation characters
3561 // Should be called after SetWordChars.
SetPunctuationChars(const wxString & characters)3562 void wxStyledTextCtrl::SetPunctuationChars(const wxString& characters)
3563 {
3564 SendMsg(SCI_SETPUNCTUATIONCHARS, 0, (sptr_t)(const char*)wx2stc(characters));
3565 }
3566
3567 // Get the set of characters making up punctuation characters
GetPunctuationChars() const3568 wxString wxStyledTextCtrl::GetPunctuationChars() const {
3569 const int msg = SCI_GETPUNCTUATIONCHARS;
3570 int len = SendMsg(msg, 0, (sptr_t)NULL);
3571 if (!len) return wxEmptyString;
3572
3573 wxMemoryBuffer mbuf(len+1);
3574 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3575 SendMsg(msg, 0, (sptr_t)buf);
3576 mbuf.UngetWriteBuf(len);
3577 mbuf.AppendByte(0);
3578 return stc2wx(buf);
3579 }
3580
3581 // Reset the set of characters for whitespace and word characters to the defaults.
SetCharsDefault()3582 void wxStyledTextCtrl::SetCharsDefault()
3583 {
3584 SendMsg(SCI_SETCHARSDEFAULT, 0, 0);
3585 }
3586
3587 // Get currently selected item position in the auto-completion list
AutoCompGetCurrent() const3588 int wxStyledTextCtrl::AutoCompGetCurrent() const
3589 {
3590 return SendMsg(SCI_AUTOCGETCURRENT, 0, 0);
3591 }
3592
3593 // Get currently selected item text in the auto-completion list
AutoCompGetCurrentText() const3594 wxString wxStyledTextCtrl::AutoCompGetCurrentText() const {
3595 const int msg = SCI_AUTOCGETCURRENTTEXT;
3596 long len = SendMsg(msg, 0, 0);
3597 if (!len) return wxEmptyString;
3598
3599 wxCharBuffer buf(len);
3600 SendMsg(msg, 0, (sptr_t)buf.data());
3601 return stc2wx(buf);
3602 }
3603
3604 // Set auto-completion case insensitive behaviour to either prefer case-sensitive matches or have no preference.
AutoCompSetCaseInsensitiveBehaviour(int behaviour)3605 void wxStyledTextCtrl::AutoCompSetCaseInsensitiveBehaviour(int behaviour)
3606 {
3607 SendMsg(SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR, behaviour, 0);
3608 }
3609
3610 // Get auto-completion case insensitive behaviour.
AutoCompGetCaseInsensitiveBehaviour() const3611 int wxStyledTextCtrl::AutoCompGetCaseInsensitiveBehaviour() const
3612 {
3613 return SendMsg(SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR, 0, 0);
3614 }
3615
3616 // Change the effect of autocompleting when there are multiple selections.
AutoCompSetMulti(int multi)3617 void wxStyledTextCtrl::AutoCompSetMulti(int multi)
3618 {
3619 SendMsg(SCI_AUTOCSETMULTI, multi, 0);
3620 }
3621
3622 // Retrieve the effect of autocompleting when there are multiple selections.
AutoCompGetMulti() const3623 int wxStyledTextCtrl::AutoCompGetMulti() const
3624 {
3625 return SendMsg(SCI_AUTOCGETMULTI, 0, 0);
3626 }
3627
3628 // Set the way autocompletion lists are ordered.
AutoCompSetOrder(int order)3629 void wxStyledTextCtrl::AutoCompSetOrder(int order)
3630 {
3631 SendMsg(SCI_AUTOCSETORDER, order, 0);
3632 }
3633
3634 // Get the way autocompletion lists are ordered.
AutoCompGetOrder() const3635 int wxStyledTextCtrl::AutoCompGetOrder() const
3636 {
3637 return SendMsg(SCI_AUTOCGETORDER, 0, 0);
3638 }
3639
3640 // Enlarge the document to a particular size of text bytes.
Allocate(int bytes)3641 void wxStyledTextCtrl::Allocate(int bytes)
3642 {
3643 SendMsg(SCI_ALLOCATE, bytes, 0);
3644 }
3645
3646 // Find the position of a column on a line taking into account tabs and
3647 // multi-byte characters. If beyond end of line, return line end position.
FindColumn(int line,int column)3648 int wxStyledTextCtrl::FindColumn(int line, int column)
3649 {
3650 return SendMsg(SCI_FINDCOLUMN, line, column);
3651 }
3652
3653 // Can the caret preferred x position only be changed by explicit movement commands?
GetCaretSticky() const3654 int wxStyledTextCtrl::GetCaretSticky() const
3655 {
3656 return SendMsg(SCI_GETCARETSTICKY, 0, 0);
3657 }
3658
3659 // Stop the caret preferred x position changing when the user types.
SetCaretSticky(int useCaretStickyBehaviour)3660 void wxStyledTextCtrl::SetCaretSticky(int useCaretStickyBehaviour)
3661 {
3662 SendMsg(SCI_SETCARETSTICKY, useCaretStickyBehaviour, 0);
3663 }
3664
3665 // Switch between sticky and non-sticky: meant to be bound to a key.
ToggleCaretSticky()3666 void wxStyledTextCtrl::ToggleCaretSticky()
3667 {
3668 SendMsg(SCI_TOGGLECARETSTICKY, 0, 0);
3669 }
3670
3671 // Enable/Disable convert-on-paste for line endings
SetPasteConvertEndings(bool convert)3672 void wxStyledTextCtrl::SetPasteConvertEndings(bool convert)
3673 {
3674 SendMsg(SCI_SETPASTECONVERTENDINGS, convert, 0);
3675 }
3676
3677 // Get convert-on-paste setting
GetPasteConvertEndings() const3678 bool wxStyledTextCtrl::GetPasteConvertEndings() const
3679 {
3680 return SendMsg(SCI_GETPASTECONVERTENDINGS, 0, 0) != 0;
3681 }
3682
3683 // Duplicate the selection. If selection empty duplicate the line containing the caret.
SelectionDuplicate()3684 void wxStyledTextCtrl::SelectionDuplicate()
3685 {
3686 SendMsg(SCI_SELECTIONDUPLICATE, 0, 0);
3687 }
3688
3689 // Set background alpha of the caret line.
SetCaretLineBackAlpha(int alpha)3690 void wxStyledTextCtrl::SetCaretLineBackAlpha(int alpha)
3691 {
3692 SendMsg(SCI_SETCARETLINEBACKALPHA, alpha, 0);
3693 }
3694
3695 // Get the background alpha of the caret line.
GetCaretLineBackAlpha() const3696 int wxStyledTextCtrl::GetCaretLineBackAlpha() const
3697 {
3698 return SendMsg(SCI_GETCARETLINEBACKALPHA, 0, 0);
3699 }
3700
3701 // Set the style of the caret to be drawn.
SetCaretStyle(int caretStyle)3702 void wxStyledTextCtrl::SetCaretStyle(int caretStyle)
3703 {
3704 SendMsg(SCI_SETCARETSTYLE, caretStyle, 0);
3705 }
3706
3707 // Returns the current style of the caret.
GetCaretStyle() const3708 int wxStyledTextCtrl::GetCaretStyle() const
3709 {
3710 return SendMsg(SCI_GETCARETSTYLE, 0, 0);
3711 }
3712
3713 // Set the indicator used for IndicatorFillRange and IndicatorClearRange
SetIndicatorCurrent(int indicator)3714 void wxStyledTextCtrl::SetIndicatorCurrent(int indicator)
3715 {
3716 SendMsg(SCI_SETINDICATORCURRENT, indicator, 0);
3717 }
3718
3719 // Get the current indicator
GetIndicatorCurrent() const3720 int wxStyledTextCtrl::GetIndicatorCurrent() const
3721 {
3722 return SendMsg(SCI_GETINDICATORCURRENT, 0, 0);
3723 }
3724
3725 // Set the value used for IndicatorFillRange
SetIndicatorValue(int value)3726 void wxStyledTextCtrl::SetIndicatorValue(int value)
3727 {
3728 SendMsg(SCI_SETINDICATORVALUE, value, 0);
3729 }
3730
3731 // Get the current indicator value
GetIndicatorValue() const3732 int wxStyledTextCtrl::GetIndicatorValue() const
3733 {
3734 return SendMsg(SCI_GETINDICATORVALUE, 0, 0);
3735 }
3736
3737 // Turn an indicator on over a range.
IndicatorFillRange(int start,int lengthFill)3738 void wxStyledTextCtrl::IndicatorFillRange(int start, int lengthFill)
3739 {
3740 SendMsg(SCI_INDICATORFILLRANGE, start, lengthFill);
3741 }
3742
3743 // Turn an indicator off over a range.
IndicatorClearRange(int start,int lengthClear)3744 void wxStyledTextCtrl::IndicatorClearRange(int start, int lengthClear)
3745 {
3746 SendMsg(SCI_INDICATORCLEARRANGE, start, lengthClear);
3747 }
3748
3749 // Are any indicators present at pos?
IndicatorAllOnFor(int pos)3750 int wxStyledTextCtrl::IndicatorAllOnFor(int pos)
3751 {
3752 return SendMsg(SCI_INDICATORALLONFOR, pos, 0);
3753 }
3754
3755 // What value does a particular indicator have at a position?
IndicatorValueAt(int indicator,int pos)3756 int wxStyledTextCtrl::IndicatorValueAt(int indicator, int pos)
3757 {
3758 return SendMsg(SCI_INDICATORVALUEAT, indicator, pos);
3759 }
3760
3761 // Where does a particular indicator start?
IndicatorStart(int indicator,int pos)3762 int wxStyledTextCtrl::IndicatorStart(int indicator, int pos)
3763 {
3764 return SendMsg(SCI_INDICATORSTART, indicator, pos);
3765 }
3766
3767 // Where does a particular indicator end?
IndicatorEnd(int indicator,int pos)3768 int wxStyledTextCtrl::IndicatorEnd(int indicator, int pos)
3769 {
3770 return SendMsg(SCI_INDICATOREND, indicator, pos);
3771 }
3772
3773 // Set number of entries in position cache
SetPositionCacheSize(int size)3774 void wxStyledTextCtrl::SetPositionCacheSize(int size)
3775 {
3776 SendMsg(SCI_SETPOSITIONCACHE, size, 0);
3777 }
3778
3779 // How many entries are allocated to the position cache?
GetPositionCacheSize() const3780 int wxStyledTextCtrl::GetPositionCacheSize() const
3781 {
3782 return SendMsg(SCI_GETPOSITIONCACHE, 0, 0);
3783 }
3784
3785 // Copy the selection, if selection empty copy the line with the caret
CopyAllowLine()3786 void wxStyledTextCtrl::CopyAllowLine()
3787 {
3788 SendMsg(SCI_COPYALLOWLINE, 0, 0);
3789 }
3790
3791 // Compact the document buffer and return a read-only pointer to the
3792 // characters in the document.
GetCharacterPointer() const3793 const char* wxStyledTextCtrl::GetCharacterPointer() const {
3794 return (const char*)SendMsg(SCI_GETCHARACTERPOINTER, 0, 0);
3795 }
3796
3797 // Return a read-only pointer to a range of characters in the document.
3798 // May move the gap so that the range is contiguous, but will only move up
3799 // to lengthRange bytes.
GetRangePointer(int position,int rangeLength) const3800 const char* wxStyledTextCtrl::GetRangePointer(int position, int rangeLength) const {
3801 return (const char*)SendMsg(SCI_GETRANGEPOINTER, position, rangeLength);
3802 }
3803
3804 // Return a position which, to avoid performance costs, should not be within
3805 // the range of a call to GetRangePointer.
GetGapPosition() const3806 int wxStyledTextCtrl::GetGapPosition() const
3807 {
3808 return SendMsg(SCI_GETGAPPOSITION, 0, 0);
3809 }
3810
3811 // Set the alpha fill colour of the given indicator.
IndicatorSetAlpha(int indicator,int alpha)3812 void wxStyledTextCtrl::IndicatorSetAlpha(int indicator, int alpha)
3813 {
3814 SendMsg(SCI_INDICSETALPHA, indicator, alpha);
3815 }
3816
3817 // Get the alpha fill colour of the given indicator.
IndicatorGetAlpha(int indicator) const3818 int wxStyledTextCtrl::IndicatorGetAlpha(int indicator) const
3819 {
3820 return SendMsg(SCI_INDICGETALPHA, indicator, 0);
3821 }
3822
3823 // Set the alpha outline colour of the given indicator.
IndicatorSetOutlineAlpha(int indicator,int alpha)3824 void wxStyledTextCtrl::IndicatorSetOutlineAlpha(int indicator, int alpha)
3825 {
3826 SendMsg(SCI_INDICSETOUTLINEALPHA, indicator, alpha);
3827 }
3828
3829 // Get the alpha outline colour of the given indicator.
IndicatorGetOutlineAlpha(int indicator) const3830 int wxStyledTextCtrl::IndicatorGetOutlineAlpha(int indicator) const
3831 {
3832 return SendMsg(SCI_INDICGETOUTLINEALPHA, indicator, 0);
3833 }
3834
3835 // Set extra ascent for each line
SetExtraAscent(int extraAscent)3836 void wxStyledTextCtrl::SetExtraAscent(int extraAscent)
3837 {
3838 SendMsg(SCI_SETEXTRAASCENT, extraAscent, 0);
3839 }
3840
3841 // Get extra ascent for each line
GetExtraAscent() const3842 int wxStyledTextCtrl::GetExtraAscent() const
3843 {
3844 return SendMsg(SCI_GETEXTRAASCENT, 0, 0);
3845 }
3846
3847 // Set extra descent for each line
SetExtraDescent(int extraDescent)3848 void wxStyledTextCtrl::SetExtraDescent(int extraDescent)
3849 {
3850 SendMsg(SCI_SETEXTRADESCENT, extraDescent, 0);
3851 }
3852
3853 // Get extra descent for each line
GetExtraDescent() const3854 int wxStyledTextCtrl::GetExtraDescent() const
3855 {
3856 return SendMsg(SCI_GETEXTRADESCENT, 0, 0);
3857 }
3858
3859 // Which symbol was defined for markerNumber with MarkerDefine
GetMarkerSymbolDefined(int markerNumber)3860 int wxStyledTextCtrl::GetMarkerSymbolDefined(int markerNumber)
3861 {
3862 return SendMsg(SCI_MARKERSYMBOLDEFINED, markerNumber, 0);
3863 }
3864
3865 // Set the text in the text margin for a line
MarginSetText(int line,const wxString & text)3866 void wxStyledTextCtrl::MarginSetText(int line, const wxString& text)
3867 {
3868 SendMsg(SCI_MARGINSETTEXT, line, (sptr_t)(const char*)wx2stc(text));
3869 }
3870
3871 // Get the text in the text margin for a line
MarginGetText(int line) const3872 wxString wxStyledTextCtrl::MarginGetText(int line) const {
3873 const int msg = SCI_MARGINGETTEXT;
3874 long len = SendMsg(msg, line, 0);
3875
3876 wxCharBuffer buf(len);
3877 SendMsg(msg, line, (sptr_t)buf.data());
3878 return stc2wx(buf);
3879 }
3880
3881 // Set the style number for the text margin for a line
MarginSetStyle(int line,int style)3882 void wxStyledTextCtrl::MarginSetStyle(int line, int style)
3883 {
3884 SendMsg(SCI_MARGINSETSTYLE, line, style);
3885 }
3886
3887 // Get the style number for the text margin for a line
MarginGetStyle(int line) const3888 int wxStyledTextCtrl::MarginGetStyle(int line) const
3889 {
3890 return SendMsg(SCI_MARGINGETSTYLE, line, 0);
3891 }
3892
3893 // Set the style in the text margin for a line
MarginSetStyles(int line,const wxString & styles)3894 void wxStyledTextCtrl::MarginSetStyles(int line, const wxString& styles)
3895 {
3896 SendMsg(SCI_MARGINSETSTYLES, line, (sptr_t)(const char*)wx2stc(styles));
3897 }
3898
3899 // Get the styles in the text margin for a line
MarginGetStyles(int line) const3900 wxString wxStyledTextCtrl::MarginGetStyles(int line) const {
3901 const int msg = SCI_MARGINGETSTYLES;
3902 long len = SendMsg(msg, line, 0);
3903
3904 wxMemoryBuffer mbuf(len+1);
3905 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3906 SendMsg(msg, line, (sptr_t)buf);
3907 mbuf.UngetWriteBuf(len);
3908 mbuf.AppendByte(0);
3909 return stc2wx(buf);
3910 }
3911
3912 // Clear the margin text on all lines
MarginTextClearAll()3913 void wxStyledTextCtrl::MarginTextClearAll()
3914 {
3915 SendMsg(SCI_MARGINTEXTCLEARALL, 0, 0);
3916 }
3917
3918 // Get the start of the range of style numbers used for margin text
MarginSetStyleOffset(int style)3919 void wxStyledTextCtrl::MarginSetStyleOffset(int style)
3920 {
3921 SendMsg(SCI_MARGINSETSTYLEOFFSET, style, 0);
3922 }
3923
3924 // Get the start of the range of style numbers used for margin text
MarginGetStyleOffset() const3925 int wxStyledTextCtrl::MarginGetStyleOffset() const
3926 {
3927 return SendMsg(SCI_MARGINGETSTYLEOFFSET, 0, 0);
3928 }
3929
3930 // Set the margin options.
SetMarginOptions(int marginOptions)3931 void wxStyledTextCtrl::SetMarginOptions(int marginOptions)
3932 {
3933 SendMsg(SCI_SETMARGINOPTIONS, marginOptions, 0);
3934 }
3935
3936 // Get the margin options.
GetMarginOptions() const3937 int wxStyledTextCtrl::GetMarginOptions() const
3938 {
3939 return SendMsg(SCI_GETMARGINOPTIONS, 0, 0);
3940 }
3941
3942 // Set the annotation text for a line
AnnotationSetText(int line,const wxString & text)3943 void wxStyledTextCtrl::AnnotationSetText(int line, const wxString& text)
3944 {
3945 SendMsg(SCI_ANNOTATIONSETTEXT, line, (sptr_t)(const char*)wx2stc(text));
3946 }
3947
3948 // Get the annotation text for a line
AnnotationGetText(int line) const3949 wxString wxStyledTextCtrl::AnnotationGetText(int line) const {
3950 const int msg = SCI_ANNOTATIONGETTEXT;
3951 long len = SendMsg(msg, line, 0);
3952 if (!len) return wxEmptyString;
3953
3954 wxCharBuffer buf(len);
3955 SendMsg(msg, line, (sptr_t)buf.data());
3956 return stc2wx(buf);
3957 }
3958
3959 // Set the style number for the annotations for a line
AnnotationSetStyle(int line,int style)3960 void wxStyledTextCtrl::AnnotationSetStyle(int line, int style)
3961 {
3962 SendMsg(SCI_ANNOTATIONSETSTYLE, line, style);
3963 }
3964
3965 // Get the style number for the annotations for a line
AnnotationGetStyle(int line) const3966 int wxStyledTextCtrl::AnnotationGetStyle(int line) const
3967 {
3968 return SendMsg(SCI_ANNOTATIONGETSTYLE, line, 0);
3969 }
3970
3971 // Set the annotation styles for a line
AnnotationSetStyles(int line,const wxString & styles)3972 void wxStyledTextCtrl::AnnotationSetStyles(int line, const wxString& styles)
3973 {
3974 SendMsg(SCI_ANNOTATIONSETSTYLES, line, (sptr_t)(const char*)wx2stc(styles));
3975 }
3976
3977 // Get the annotation styles for a line
AnnotationGetStyles(int line) const3978 wxString wxStyledTextCtrl::AnnotationGetStyles(int line) const {
3979 const int msg = SCI_ANNOTATIONGETSTYLES;
3980 long len = SendMsg(msg, line, 0);
3981
3982 wxMemoryBuffer mbuf(len+1);
3983 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3984 SendMsg(msg, line, (sptr_t)buf);
3985 mbuf.UngetWriteBuf(len);
3986 mbuf.AppendByte(0);
3987 return stc2wx(buf);
3988 }
3989
3990 // Get the number of annotation lines for a line
AnnotationGetLines(int line) const3991 int wxStyledTextCtrl::AnnotationGetLines(int line) const
3992 {
3993 return SendMsg(SCI_ANNOTATIONGETLINES, line, 0);
3994 }
3995
3996 // Clear the annotations from all lines
AnnotationClearAll()3997 void wxStyledTextCtrl::AnnotationClearAll()
3998 {
3999 SendMsg(SCI_ANNOTATIONCLEARALL, 0, 0);
4000 }
4001
4002 // Set the visibility for the annotations for a view
AnnotationSetVisible(int visible)4003 void wxStyledTextCtrl::AnnotationSetVisible(int visible)
4004 {
4005 SendMsg(SCI_ANNOTATIONSETVISIBLE, visible, 0);
4006 }
4007
4008 // Get the visibility for the annotations for a view
AnnotationGetVisible() const4009 int wxStyledTextCtrl::AnnotationGetVisible() const
4010 {
4011 return SendMsg(SCI_ANNOTATIONGETVISIBLE, 0, 0);
4012 }
4013
4014 // Get the start of the range of style numbers used for annotations
AnnotationSetStyleOffset(int style)4015 void wxStyledTextCtrl::AnnotationSetStyleOffset(int style)
4016 {
4017 SendMsg(SCI_ANNOTATIONSETSTYLEOFFSET, style, 0);
4018 }
4019
4020 // Get the start of the range of style numbers used for annotations
AnnotationGetStyleOffset() const4021 int wxStyledTextCtrl::AnnotationGetStyleOffset() const
4022 {
4023 return SendMsg(SCI_ANNOTATIONGETSTYLEOFFSET, 0, 0);
4024 }
4025
4026 // Release all extended (>255) style numbers
ReleaseAllExtendedStyles()4027 void wxStyledTextCtrl::ReleaseAllExtendedStyles()
4028 {
4029 SendMsg(SCI_RELEASEALLEXTENDEDSTYLES, 0, 0);
4030 }
4031
4032 // Allocate some extended (>255) style numbers and return the start of the range
AllocateExtendedStyles(int numberStyles)4033 int wxStyledTextCtrl::AllocateExtendedStyles(int numberStyles)
4034 {
4035 return SendMsg(SCI_ALLOCATEEXTENDEDSTYLES, numberStyles, 0);
4036 }
4037
4038 // Add a container action to the undo stack
AddUndoAction(int token,int flags)4039 void wxStyledTextCtrl::AddUndoAction(int token, int flags)
4040 {
4041 SendMsg(SCI_ADDUNDOACTION, token, flags);
4042 }
4043
4044 // Find the position of a character from a point within the window.
CharPositionFromPoint(int x,int y)4045 int wxStyledTextCtrl::CharPositionFromPoint(int x, int y)
4046 {
4047 return SendMsg(SCI_CHARPOSITIONFROMPOINT, x, y);
4048 }
4049
4050 // Find the position of a character from a point within the window.
4051 // Return wxSTC_INVALID_POSITION if not close to text.
CharPositionFromPointClose(int x,int y)4052 int wxStyledTextCtrl::CharPositionFromPointClose(int x, int y)
4053 {
4054 return SendMsg(SCI_CHARPOSITIONFROMPOINTCLOSE, x, y);
4055 }
4056
4057 // Set whether switching to rectangular mode while selecting with the mouse is allowed.
SetMouseSelectionRectangularSwitch(bool mouseSelectionRectangularSwitch)4058 void wxStyledTextCtrl::SetMouseSelectionRectangularSwitch(bool mouseSelectionRectangularSwitch)
4059 {
4060 SendMsg(SCI_SETMOUSESELECTIONRECTANGULARSWITCH, mouseSelectionRectangularSwitch, 0);
4061 }
4062
4063 // Whether switching to rectangular mode while selecting with the mouse is allowed.
GetMouseSelectionRectangularSwitch() const4064 bool wxStyledTextCtrl::GetMouseSelectionRectangularSwitch() const
4065 {
4066 return SendMsg(SCI_GETMOUSESELECTIONRECTANGULARSWITCH, 0, 0) != 0;
4067 }
4068
4069 // Set whether multiple selections can be made
SetMultipleSelection(bool multipleSelection)4070 void wxStyledTextCtrl::SetMultipleSelection(bool multipleSelection)
4071 {
4072 SendMsg(SCI_SETMULTIPLESELECTION, multipleSelection, 0);
4073 }
4074
4075 // Whether multiple selections can be made
GetMultipleSelection() const4076 bool wxStyledTextCtrl::GetMultipleSelection() const
4077 {
4078 return SendMsg(SCI_GETMULTIPLESELECTION, 0, 0) != 0;
4079 }
4080
4081 // Set whether typing can be performed into multiple selections
SetAdditionalSelectionTyping(bool additionalSelectionTyping)4082 void wxStyledTextCtrl::SetAdditionalSelectionTyping(bool additionalSelectionTyping)
4083 {
4084 SendMsg(SCI_SETADDITIONALSELECTIONTYPING, additionalSelectionTyping, 0);
4085 }
4086
4087 // Whether typing can be performed into multiple selections
GetAdditionalSelectionTyping() const4088 bool wxStyledTextCtrl::GetAdditionalSelectionTyping() const
4089 {
4090 return SendMsg(SCI_GETADDITIONALSELECTIONTYPING, 0, 0) != 0;
4091 }
4092
4093 // Set whether additional carets will blink
SetAdditionalCaretsBlink(bool additionalCaretsBlink)4094 void wxStyledTextCtrl::SetAdditionalCaretsBlink(bool additionalCaretsBlink)
4095 {
4096 SendMsg(SCI_SETADDITIONALCARETSBLINK, additionalCaretsBlink, 0);
4097 }
4098
4099 // Whether additional carets will blink
GetAdditionalCaretsBlink() const4100 bool wxStyledTextCtrl::GetAdditionalCaretsBlink() const
4101 {
4102 return SendMsg(SCI_GETADDITIONALCARETSBLINK, 0, 0) != 0;
4103 }
4104
4105 // Set whether additional carets are visible
SetAdditionalCaretsVisible(bool additionalCaretsVisible)4106 void wxStyledTextCtrl::SetAdditionalCaretsVisible(bool additionalCaretsVisible)
4107 {
4108 SendMsg(SCI_SETADDITIONALCARETSVISIBLE, additionalCaretsVisible, 0);
4109 }
4110
4111 // Whether additional carets are visible
GetAdditionalCaretsVisible() const4112 bool wxStyledTextCtrl::GetAdditionalCaretsVisible() const
4113 {
4114 return SendMsg(SCI_GETADDITIONALCARETSVISIBLE, 0, 0) != 0;
4115 }
4116
4117 // How many selections are there?
GetSelections() const4118 int wxStyledTextCtrl::GetSelections() const
4119 {
4120 return SendMsg(SCI_GETSELECTIONS, 0, 0);
4121 }
4122
4123 // Is every selected range empty?
GetSelectionEmpty() const4124 bool wxStyledTextCtrl::GetSelectionEmpty() const
4125 {
4126 return SendMsg(SCI_GETSELECTIONEMPTY, 0, 0) != 0;
4127 }
4128
4129 // Clear selections to a single empty stream selection
ClearSelections()4130 void wxStyledTextCtrl::ClearSelections()
4131 {
4132 SendMsg(SCI_CLEARSELECTIONS, 0, 0);
4133 }
4134
4135 // Add a selection
AddSelection(int caret,int anchor)4136 int wxStyledTextCtrl::AddSelection(int caret, int anchor)
4137 {
4138 return SendMsg(SCI_ADDSELECTION, caret, anchor);
4139 }
4140
4141 // Drop one selection
DropSelectionN(int selection)4142 void wxStyledTextCtrl::DropSelectionN(int selection)
4143 {
4144 SendMsg(SCI_DROPSELECTIONN, selection, 0);
4145 }
4146
4147 // Set the main selection
SetMainSelection(int selection)4148 void wxStyledTextCtrl::SetMainSelection(int selection)
4149 {
4150 SendMsg(SCI_SETMAINSELECTION, selection, 0);
4151 }
4152
4153 // Which selection is the main selection
GetMainSelection() const4154 int wxStyledTextCtrl::GetMainSelection() const
4155 {
4156 return SendMsg(SCI_GETMAINSELECTION, 0, 0);
4157 }
4158
4159 // Set the caret position of the nth selection.
SetSelectionNCaret(int selection,int caret)4160 void wxStyledTextCtrl::SetSelectionNCaret(int selection, int caret)
4161 {
4162 SendMsg(SCI_SETSELECTIONNCARET, selection, caret);
4163 }
4164
4165 // Return the caret position of the nth selection.
GetSelectionNCaret(int selection) const4166 int wxStyledTextCtrl::GetSelectionNCaret(int selection) const
4167 {
4168 return SendMsg(SCI_GETSELECTIONNCARET, selection, 0);
4169 }
4170
4171 // Set the anchor position of the nth selection.
SetSelectionNAnchor(int selection,int anchor)4172 void wxStyledTextCtrl::SetSelectionNAnchor(int selection, int anchor)
4173 {
4174 SendMsg(SCI_SETSELECTIONNANCHOR, selection, anchor);
4175 }
4176
4177 // Return the anchor position of the nth selection.
GetSelectionNAnchor(int selection) const4178 int wxStyledTextCtrl::GetSelectionNAnchor(int selection) const
4179 {
4180 return SendMsg(SCI_GETSELECTIONNANCHOR, selection, 0);
4181 }
4182
4183 // Set the virtual space of the caret of the nth selection.
SetSelectionNCaretVirtualSpace(int selection,int space)4184 void wxStyledTextCtrl::SetSelectionNCaretVirtualSpace(int selection, int space)
4185 {
4186 SendMsg(SCI_SETSELECTIONNCARETVIRTUALSPACE, selection, space);
4187 }
4188
4189 // Return the virtual space of the caret of the nth selection.
GetSelectionNCaretVirtualSpace(int selection) const4190 int wxStyledTextCtrl::GetSelectionNCaretVirtualSpace(int selection) const
4191 {
4192 return SendMsg(SCI_GETSELECTIONNCARETVIRTUALSPACE, selection, 0);
4193 }
4194
4195 // Set the virtual space of the anchor of the nth selection.
SetSelectionNAnchorVirtualSpace(int selection,int space)4196 void wxStyledTextCtrl::SetSelectionNAnchorVirtualSpace(int selection, int space)
4197 {
4198 SendMsg(SCI_SETSELECTIONNANCHORVIRTUALSPACE, selection, space);
4199 }
4200
4201 // Return the virtual space of the anchor of the nth selection.
GetSelectionNAnchorVirtualSpace(int selection) const4202 int wxStyledTextCtrl::GetSelectionNAnchorVirtualSpace(int selection) const
4203 {
4204 return SendMsg(SCI_GETSELECTIONNANCHORVIRTUALSPACE, selection, 0);
4205 }
4206
4207 // Sets the position that starts the selection - this becomes the anchor.
SetSelectionNStart(int selection,int anchor)4208 void wxStyledTextCtrl::SetSelectionNStart(int selection, int anchor)
4209 {
4210 SendMsg(SCI_SETSELECTIONNSTART, selection, anchor);
4211 }
4212
4213 // Returns the position at the start of the selection.
GetSelectionNStart(int selection) const4214 int wxStyledTextCtrl::GetSelectionNStart(int selection) const
4215 {
4216 return SendMsg(SCI_GETSELECTIONNSTART, selection, 0);
4217 }
4218
4219 // Sets the position that ends the selection - this becomes the currentPosition.
SetSelectionNEnd(int selection,int caret)4220 void wxStyledTextCtrl::SetSelectionNEnd(int selection, int caret)
4221 {
4222 SendMsg(SCI_SETSELECTIONNEND, selection, caret);
4223 }
4224
4225 // Returns the position at the end of the selection.
GetSelectionNEnd(int selection) const4226 int wxStyledTextCtrl::GetSelectionNEnd(int selection) const
4227 {
4228 return SendMsg(SCI_GETSELECTIONNEND, selection, 0);
4229 }
4230
4231 // Set the caret position of the rectangular selection.
SetRectangularSelectionCaret(int caret)4232 void wxStyledTextCtrl::SetRectangularSelectionCaret(int caret)
4233 {
4234 SendMsg(SCI_SETRECTANGULARSELECTIONCARET, caret, 0);
4235 }
4236
4237 // Return the caret position of the rectangular selection.
GetRectangularSelectionCaret() const4238 int wxStyledTextCtrl::GetRectangularSelectionCaret() const
4239 {
4240 return SendMsg(SCI_GETRECTANGULARSELECTIONCARET, 0, 0);
4241 }
4242
4243 // Set the anchor position of the rectangular selection.
SetRectangularSelectionAnchor(int anchor)4244 void wxStyledTextCtrl::SetRectangularSelectionAnchor(int anchor)
4245 {
4246 SendMsg(SCI_SETRECTANGULARSELECTIONANCHOR, anchor, 0);
4247 }
4248
4249 // Return the anchor position of the rectangular selection.
GetRectangularSelectionAnchor() const4250 int wxStyledTextCtrl::GetRectangularSelectionAnchor() const
4251 {
4252 return SendMsg(SCI_GETRECTANGULARSELECTIONANCHOR, 0, 0);
4253 }
4254
4255 // Set the virtual space of the caret of the rectangular selection.
SetRectangularSelectionCaretVirtualSpace(int space)4256 void wxStyledTextCtrl::SetRectangularSelectionCaretVirtualSpace(int space)
4257 {
4258 SendMsg(SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE, space, 0);
4259 }
4260
4261 // Return the virtual space of the caret of the rectangular selection.
GetRectangularSelectionCaretVirtualSpace() const4262 int wxStyledTextCtrl::GetRectangularSelectionCaretVirtualSpace() const
4263 {
4264 return SendMsg(SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE, 0, 0);
4265 }
4266
4267 // Set the virtual space of the anchor of the rectangular selection.
SetRectangularSelectionAnchorVirtualSpace(int space)4268 void wxStyledTextCtrl::SetRectangularSelectionAnchorVirtualSpace(int space)
4269 {
4270 SendMsg(SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE, space, 0);
4271 }
4272
4273 // Return the virtual space of the anchor of the rectangular selection.
GetRectangularSelectionAnchorVirtualSpace() const4274 int wxStyledTextCtrl::GetRectangularSelectionAnchorVirtualSpace() const
4275 {
4276 return SendMsg(SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE, 0, 0);
4277 }
4278
4279 // Set options for virtual space behaviour.
SetVirtualSpaceOptions(int virtualSpaceOptions)4280 void wxStyledTextCtrl::SetVirtualSpaceOptions(int virtualSpaceOptions)
4281 {
4282 SendMsg(SCI_SETVIRTUALSPACEOPTIONS, virtualSpaceOptions, 0);
4283 }
4284
4285 // Return options for virtual space behaviour.
GetVirtualSpaceOptions() const4286 int wxStyledTextCtrl::GetVirtualSpaceOptions() const
4287 {
4288 return SendMsg(SCI_GETVIRTUALSPACEOPTIONS, 0, 0);
4289 }
4290
4291 // On GTK+, allow selecting the modifier key to use for mouse-based
4292 // rectangular selection. Often the window manager requires Alt+Mouse Drag
4293 // for moving windows.
4294 // Valid values are wxSTC_KEYMOD_CTRL (default), wxSTC_KEYMOD_ALT, or wxSTC_KEYMOD_SUPER.
SetRectangularSelectionModifier(int modifier)4295 void wxStyledTextCtrl::SetRectangularSelectionModifier(int modifier)
4296 {
4297 SendMsg(SCI_SETRECTANGULARSELECTIONMODIFIER, modifier, 0);
4298 }
4299
4300 // Get the modifier key used for rectangular selection.
GetRectangularSelectionModifier() const4301 int wxStyledTextCtrl::GetRectangularSelectionModifier() const
4302 {
4303 return SendMsg(SCI_GETRECTANGULARSELECTIONMODIFIER, 0, 0);
4304 }
4305
4306 // Set the foreground colour of additional selections.
4307 // Must have previously called SetSelFore with non-zero first argument for this to have an effect.
SetAdditionalSelForeground(const wxColour & fore)4308 void wxStyledTextCtrl::SetAdditionalSelForeground(const wxColour& fore)
4309 {
4310 SendMsg(SCI_SETADDITIONALSELFORE, wxColourAsLong(fore), 0);
4311 }
4312
4313 // Set the background colour of additional selections.
4314 // Must have previously called SetSelBack with non-zero first argument for this to have an effect.
SetAdditionalSelBackground(const wxColour & back)4315 void wxStyledTextCtrl::SetAdditionalSelBackground(const wxColour& back)
4316 {
4317 SendMsg(SCI_SETADDITIONALSELBACK, wxColourAsLong(back), 0);
4318 }
4319
4320 // Set the alpha of the selection.
SetAdditionalSelAlpha(int alpha)4321 void wxStyledTextCtrl::SetAdditionalSelAlpha(int alpha)
4322 {
4323 SendMsg(SCI_SETADDITIONALSELALPHA, alpha, 0);
4324 }
4325
4326 // Get the alpha of the selection.
GetAdditionalSelAlpha() const4327 int wxStyledTextCtrl::GetAdditionalSelAlpha() const
4328 {
4329 return SendMsg(SCI_GETADDITIONALSELALPHA, 0, 0);
4330 }
4331
4332 // Set the foreground colour of additional carets.
SetAdditionalCaretForeground(const wxColour & fore)4333 void wxStyledTextCtrl::SetAdditionalCaretForeground(const wxColour& fore)
4334 {
4335 SendMsg(SCI_SETADDITIONALCARETFORE, wxColourAsLong(fore), 0);
4336 }
4337
4338 // Get the foreground colour of additional carets.
GetAdditionalCaretForeground() const4339 wxColour wxStyledTextCtrl::GetAdditionalCaretForeground() const
4340 {
4341 long c = SendMsg(SCI_GETADDITIONALCARETFORE, 0, 0);
4342 return wxColourFromLong(c);
4343 }
4344
4345 // Set the main selection to the next selection.
RotateSelection()4346 void wxStyledTextCtrl::RotateSelection()
4347 {
4348 SendMsg(SCI_ROTATESELECTION, 0, 0);
4349 }
4350
4351 // Swap that caret and anchor of the main selection.
SwapMainAnchorCaret()4352 void wxStyledTextCtrl::SwapMainAnchorCaret()
4353 {
4354 SendMsg(SCI_SWAPMAINANCHORCARET, 0, 0);
4355 }
4356
4357 // Add the next occurrence of the main selection to the set of selections as main.
4358 // If the current selection is empty then select word around caret.
MultipleSelectAddNext()4359 void wxStyledTextCtrl::MultipleSelectAddNext()
4360 {
4361 SendMsg(SCI_MULTIPLESELECTADDNEXT, 0, 0);
4362 }
4363
4364 // Add each occurrence of the main selection in the target to the set of selections.
4365 // If the current selection is empty then select word around caret.
MultipleSelectAddEach()4366 void wxStyledTextCtrl::MultipleSelectAddEach()
4367 {
4368 SendMsg(SCI_MULTIPLESELECTADDEACH, 0, 0);
4369 }
4370
4371 // Indicate that the internal state of a lexer has changed over a range and therefore
4372 // there may be a need to redraw.
ChangeLexerState(int start,int end)4373 int wxStyledTextCtrl::ChangeLexerState(int start, int end)
4374 {
4375 return SendMsg(SCI_CHANGELEXERSTATE, start, end);
4376 }
4377
4378 // Find the next line at or after lineStart that is a contracted fold header line.
4379 // Return -1 when no more lines.
ContractedFoldNext(int lineStart)4380 int wxStyledTextCtrl::ContractedFoldNext(int lineStart)
4381 {
4382 return SendMsg(SCI_CONTRACTEDFOLDNEXT, lineStart, 0);
4383 }
4384
4385 // Centre current line in window.
VerticalCentreCaret()4386 void wxStyledTextCtrl::VerticalCentreCaret()
4387 {
4388 SendMsg(SCI_VERTICALCENTRECARET, 0, 0);
4389 }
4390
4391 // Move the selected lines up one line, shifting the line above after the selection
MoveSelectedLinesUp()4392 void wxStyledTextCtrl::MoveSelectedLinesUp()
4393 {
4394 SendMsg(SCI_MOVESELECTEDLINESUP, 0, 0);
4395 }
4396
4397 // Move the selected lines down one line, shifting the line below before the selection
MoveSelectedLinesDown()4398 void wxStyledTextCtrl::MoveSelectedLinesDown()
4399 {
4400 SendMsg(SCI_MOVESELECTEDLINESDOWN, 0, 0);
4401 }
4402
4403 // Set the identifier reported as idFrom in notification messages.
SetIdentifier(int identifier)4404 void wxStyledTextCtrl::SetIdentifier(int identifier)
4405 {
4406 SendMsg(SCI_SETIDENTIFIER, identifier, 0);
4407 }
4408
4409 // Get the identifier.
GetIdentifier() const4410 int wxStyledTextCtrl::GetIdentifier() const
4411 {
4412 return SendMsg(SCI_GETIDENTIFIER, 0, 0);
4413 }
4414
4415 // Set the width for future RGBA image data.
RGBAImageSetWidth(int width)4416 void wxStyledTextCtrl::RGBAImageSetWidth(int width)
4417 {
4418 SendMsg(SCI_RGBAIMAGESETWIDTH, width, 0);
4419 }
4420
4421 // Set the height for future RGBA image data.
RGBAImageSetHeight(int height)4422 void wxStyledTextCtrl::RGBAImageSetHeight(int height)
4423 {
4424 SendMsg(SCI_RGBAIMAGESETHEIGHT, height, 0);
4425 }
4426
4427 // Set the scale factor in percent for future RGBA image data.
RGBAImageSetScale(int scalePercent)4428 void wxStyledTextCtrl::RGBAImageSetScale(int scalePercent)
4429 {
4430 SendMsg(SCI_RGBAIMAGESETSCALE, scalePercent, 0);
4431 }
4432
4433 // Define a marker from RGBA data.
4434 // It has the width and height from RGBAImageSetWidth/Height
MarkerDefineRGBAImage(int markerNumber,const unsigned char * pixels)4435 void wxStyledTextCtrl::MarkerDefineRGBAImage(int markerNumber, const unsigned char* pixels) {
4436 SendMsg(SCI_MARKERDEFINERGBAIMAGE, markerNumber, (sptr_t)pixels);
4437 }
4438
4439 // Register an RGBA image for use in autocompletion lists.
4440 // It has the width and height from RGBAImageSetWidth/Height
RegisterRGBAImage(int type,const unsigned char * pixels)4441 void wxStyledTextCtrl::RegisterRGBAImage(int type, const unsigned char* pixels) {
4442 SendMsg(SCI_REGISTERRGBAIMAGE, type, (sptr_t)pixels);
4443 }
4444
4445 // Scroll to start of document.
ScrollToStart()4446 void wxStyledTextCtrl::ScrollToStart()
4447 {
4448 SendMsg(SCI_SCROLLTOSTART, 0, 0);
4449 }
4450
4451 // Scroll to end of document.
ScrollToEnd()4452 void wxStyledTextCtrl::ScrollToEnd()
4453 {
4454 SendMsg(SCI_SCROLLTOEND, 0, 0);
4455 }
4456
4457 // Set the technology used.
SetTechnology(int technology)4458 void wxStyledTextCtrl::SetTechnology(int technology)
4459 {
4460 SendMsg(SCI_SETTECHNOLOGY, technology, 0);
4461 }
4462
4463 // Get the tech.
GetTechnology() const4464 int wxStyledTextCtrl::GetTechnology() const
4465 {
4466 return SendMsg(SCI_GETTECHNOLOGY, 0, 0);
4467 }
4468
4469 // Create an ILoader*.
CreateLoader(int bytes) const4470 void* wxStyledTextCtrl::CreateLoader(int bytes) const {
4471 return (void*)(sptr_t)SendMsg(SCI_CREATELOADER, bytes);
4472 }
4473
4474 // Move caret to before first visible character on display line.
4475 // If already there move to first character on display line.
VCHomeDisplay()4476 void wxStyledTextCtrl::VCHomeDisplay()
4477 {
4478 SendMsg(SCI_VCHOMEDISPLAY, 0, 0);
4479 }
4480
4481 // Like VCHomeDisplay but extending selection to new caret position.
VCHomeDisplayExtend()4482 void wxStyledTextCtrl::VCHomeDisplayExtend()
4483 {
4484 SendMsg(SCI_VCHOMEDISPLAYEXTEND, 0, 0);
4485 }
4486
4487 // Is the caret line always visible?
GetCaretLineVisibleAlways() const4488 bool wxStyledTextCtrl::GetCaretLineVisibleAlways() const
4489 {
4490 return SendMsg(SCI_GETCARETLINEVISIBLEALWAYS, 0, 0) != 0;
4491 }
4492
4493 // Sets the caret line to always visible.
SetCaretLineVisibleAlways(bool alwaysVisible)4494 void wxStyledTextCtrl::SetCaretLineVisibleAlways(bool alwaysVisible)
4495 {
4496 SendMsg(SCI_SETCARETLINEVISIBLEALWAYS, alwaysVisible, 0);
4497 }
4498
4499 // Set the line end types that the application wants to use. May not be used if incompatible with lexer or encoding.
SetLineEndTypesAllowed(int lineEndBitSet)4500 void wxStyledTextCtrl::SetLineEndTypesAllowed(int lineEndBitSet)
4501 {
4502 SendMsg(SCI_SETLINEENDTYPESALLOWED, lineEndBitSet, 0);
4503 }
4504
4505 // Get the line end types currently allowed.
GetLineEndTypesAllowed() const4506 int wxStyledTextCtrl::GetLineEndTypesAllowed() const
4507 {
4508 return SendMsg(SCI_GETLINEENDTYPESALLOWED, 0, 0);
4509 }
4510
4511 // Get the line end types currently recognised. May be a subset of the allowed types due to lexer limitation.
GetLineEndTypesActive() const4512 int wxStyledTextCtrl::GetLineEndTypesActive() const
4513 {
4514 return SendMsg(SCI_GETLINEENDTYPESACTIVE, 0, 0);
4515 }
4516
4517 // Set the way a character is drawn.
SetRepresentation(const wxString & encodedCharacter,const wxString & representation)4518 void wxStyledTextCtrl::SetRepresentation(const wxString& encodedCharacter, const wxString& representation)
4519 {
4520 SendMsg(SCI_SETREPRESENTATION, (sptr_t)(const char*)wx2stc(encodedCharacter), (sptr_t)(const char*)wx2stc(representation));
4521 }
4522
4523 // Set the way a character is drawn.
GetRepresentation(const wxString & encodedCharacter) const4524 wxString wxStyledTextCtrl::GetRepresentation(const wxString& encodedCharacter) const {
4525 const int msg = SCI_GETREPRESENTATION;
4526 const wxWX2MBbuf encCharBuf = wx2stc(encodedCharacter);
4527 long len = SendMsg(msg, (sptr_t)(const char*)encCharBuf, (sptr_t)NULL);
4528 if (!len) return wxEmptyString;
4529
4530 wxCharBuffer buf(len);
4531 SendMsg(msg, (sptr_t)(const char*)encCharBuf, (sptr_t)buf.data());
4532 return stc2wx(buf);
4533 }
4534
4535 // Remove a character representation.
ClearRepresentation(const wxString & encodedCharacter)4536 void wxStyledTextCtrl::ClearRepresentation(const wxString& encodedCharacter)
4537 {
4538 SendMsg(SCI_CLEARREPRESENTATION, (sptr_t)(const char*)wx2stc(encodedCharacter), 0);
4539 }
4540
4541 // Start notifying the container of all key presses and commands.
StartRecord()4542 void wxStyledTextCtrl::StartRecord()
4543 {
4544 SendMsg(SCI_STARTRECORD, 0, 0);
4545 }
4546
4547 // Stop notifying the container of all key presses and commands.
StopRecord()4548 void wxStyledTextCtrl::StopRecord()
4549 {
4550 SendMsg(SCI_STOPRECORD, 0, 0);
4551 }
4552
4553 // Set the lexing language of the document.
SetLexer(int lexer)4554 void wxStyledTextCtrl::SetLexer(int lexer)
4555 {
4556 SendMsg(SCI_SETLEXER, lexer, 0);
4557 }
4558
4559 // Retrieve the lexing language of the document.
GetLexer() const4560 int wxStyledTextCtrl::GetLexer() const
4561 {
4562 return SendMsg(SCI_GETLEXER, 0, 0);
4563 }
4564
4565 // Colourise a segment of the document using the current lexing language.
Colourise(int start,int end)4566 void wxStyledTextCtrl::Colourise(int start, int end)
4567 {
4568 SendMsg(SCI_COLOURISE, start, end);
4569 }
4570
4571 // Set up a value that may be used by a lexer for some optional feature.
SetProperty(const wxString & key,const wxString & value)4572 void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value)
4573 {
4574 SendMsg(SCI_SETPROPERTY, (sptr_t)(const char*)wx2stc(key), (sptr_t)(const char*)wx2stc(value));
4575 }
4576
4577 // Set up the key words used by the lexer.
SetKeyWords(int keyWordSet,const wxString & keyWords)4578 void wxStyledTextCtrl::SetKeyWords(int keyWordSet, const wxString& keyWords)
4579 {
4580 SendMsg(SCI_SETKEYWORDS, keyWordSet, (sptr_t)(const char*)wx2stc(keyWords));
4581 }
4582
4583 // Set the lexing language of the document based on string name.
SetLexerLanguage(const wxString & language)4584 void wxStyledTextCtrl::SetLexerLanguage(const wxString& language)
4585 {
4586 SendMsg(SCI_SETLEXERLANGUAGE, 0, (sptr_t)(const char*)wx2stc(language));
4587 }
4588
4589 // Load a lexer library (dll / so).
LoadLexerLibrary(const wxString & path)4590 void wxStyledTextCtrl::LoadLexerLibrary(const wxString& path)
4591 {
4592 SendMsg(SCI_LOADLEXERLIBRARY, 0, (sptr_t)(const char*)wx2stc(path));
4593 }
4594
4595 // Retrieve a "property" value previously set with SetProperty.
GetProperty(const wxString & key)4596 wxString wxStyledTextCtrl::GetProperty(const wxString& key) {
4597 const int msg = SCI_GETPROPERTY;
4598 const wxWX2MBbuf keyBuf = wx2stc(key);
4599 long len = SendMsg(msg, (uptr_t)(const char*)keyBuf, 0);
4600 if (!len) return wxEmptyString;
4601
4602 wxCharBuffer buf(len);
4603 SendMsg(msg, (uptr_t)(const char*)keyBuf, (sptr_t)buf.data());
4604 return stc2wx(buf);
4605 }
4606
4607 // Retrieve a "property" value previously set with SetProperty,
4608 // with "$()" variable replacement on returned buffer.
GetPropertyExpanded(const wxString & key)4609 wxString wxStyledTextCtrl::GetPropertyExpanded(const wxString& key) {
4610 const int msg = SCI_GETPROPERTYEXPANDED;
4611 const wxWX2MBbuf keyBuf = wx2stc(key);
4612 long len = SendMsg(msg, (uptr_t)(const char*)keyBuf, 0);
4613 if (!len) return wxEmptyString;
4614
4615 wxCharBuffer buf(len);
4616 SendMsg(msg, (uptr_t)(const char*)keyBuf, (sptr_t)buf.data());
4617 return stc2wx(buf);
4618 }
4619
4620 // Retrieve a "property" value previously set with SetProperty,
4621 // interpreted as an int AFTER any "$()" variable replacement.
GetPropertyInt(const wxString & key,int defaultValue) const4622 int wxStyledTextCtrl::GetPropertyInt(const wxString &key, int defaultValue) const {
4623 return SendMsg(SCI_GETPROPERTYINT, (uptr_t)(const char*)wx2stc(key), defaultValue);
4624 }
4625
4626 // Retrieve the number of bits the current lexer needs for styling.
GetStyleBitsNeeded() const4627 int wxStyledTextCtrl::GetStyleBitsNeeded() const
4628 {
4629 return SendMsg(SCI_GETSTYLEBITSNEEDED, 0, 0);
4630 }
4631
4632 // Retrieve the lexing language of the document.
GetLexerLanguage() const4633 wxString wxStyledTextCtrl::GetLexerLanguage() const {
4634 const int msg = SCI_GETLEXERLANGUAGE;
4635 int len = SendMsg(msg, 0, (sptr_t)NULL);
4636 if (!len) return wxEmptyString;
4637
4638 wxCharBuffer buf(len);
4639 SendMsg(msg, 0, (sptr_t)buf.data());
4640 return stc2wx(buf);
4641 }
4642
4643 // For private communication between an application and a known lexer.
PrivateLexerCall(int operation,void * pointer)4644 void* wxStyledTextCtrl::PrivateLexerCall(int operation, void* pointer) {
4645 return (void*)(sptr_t)SendMsg(SCI_PRIVATELEXERCALL, operation, (sptr_t)pointer);
4646 }
4647
4648 // Retrieve a '\\n' separated list of properties understood by the current lexer.
PropertyNames() const4649 wxString wxStyledTextCtrl::PropertyNames() const {
4650 const int msg = SCI_PROPERTYNAMES;
4651 long len = SendMsg(msg, 0, (sptr_t)NULL);
4652 if (!len) return wxEmptyString;
4653
4654 wxCharBuffer buf(len);
4655 SendMsg(msg, 0, (sptr_t)buf.data());
4656 return stc2wx(buf);
4657 }
4658
4659 // Retrieve the type of a property.
PropertyType(const wxString & name)4660 int wxStyledTextCtrl::PropertyType(const wxString& name)
4661 {
4662 return SendMsg(SCI_PROPERTYTYPE, (sptr_t)(const char*)wx2stc(name), 0);
4663 }
4664
4665 // Describe a property.
DescribeProperty(const wxString & name) const4666 wxString wxStyledTextCtrl::DescribeProperty(const wxString& name) const {
4667 const int msg = SCI_DESCRIBEPROPERTY;
4668 const wxWX2MBbuf nameBuf = wx2stc(name);
4669 long len = SendMsg(msg, (uptr_t)(const char*)nameBuf, (sptr_t)NULL);
4670 if (!len) return wxEmptyString;
4671
4672 wxCharBuffer buf(len);
4673 SendMsg(msg, (uptr_t)(const char*)nameBuf, (sptr_t)buf.data());
4674 return stc2wx(buf);
4675 }
4676
4677 // Retrieve a '\\n' separated list of descriptions of the keyword sets understood by the current lexer.
DescribeKeyWordSets() const4678 wxString wxStyledTextCtrl::DescribeKeyWordSets() const {
4679 const int msg = SCI_DESCRIBEKEYWORDSETS;
4680 long len = SendMsg(msg, 0, (sptr_t)NULL);
4681 if (!len) return wxEmptyString;
4682
4683 wxCharBuffer buf(len);
4684 SendMsg(msg, 0, (sptr_t)buf.data());
4685 return stc2wx(buf);
4686 }
4687
4688 // Bit set of LineEndType enumertion for which line ends beyond the standard
4689 // LF, CR, and CRLF are supported by the lexer.
GetLineEndTypesSupported() const4690 int wxStyledTextCtrl::GetLineEndTypesSupported() const
4691 {
4692 return SendMsg(SCI_GETLINEENDTYPESSUPPORTED, 0, 0);
4693 }
4694
4695 // Allocate a set of sub styles for a particular base style, returning start of range
AllocateSubStyles(int styleBase,int numberStyles)4696 int wxStyledTextCtrl::AllocateSubStyles(int styleBase, int numberStyles)
4697 {
4698 return SendMsg(SCI_ALLOCATESUBSTYLES, styleBase, numberStyles);
4699 }
4700
4701 // The starting style number for the sub styles associated with a base style
GetSubStylesStart(int styleBase) const4702 int wxStyledTextCtrl::GetSubStylesStart(int styleBase) const
4703 {
4704 return SendMsg(SCI_GETSUBSTYLESSTART, styleBase, 0);
4705 }
4706
4707 // The number of sub styles associated with a base style
GetSubStylesLength(int styleBase) const4708 int wxStyledTextCtrl::GetSubStylesLength(int styleBase) const
4709 {
4710 return SendMsg(SCI_GETSUBSTYLESLENGTH, styleBase, 0);
4711 }
4712
4713 // For a sub style, return the base style, else return the argument.
GetStyleFromSubStyle(int subStyle) const4714 int wxStyledTextCtrl::GetStyleFromSubStyle(int subStyle) const
4715 {
4716 return SendMsg(SCI_GETSTYLEFROMSUBSTYLE, subStyle, 0);
4717 }
4718
4719 // For a secondary style, return the primary style, else return the argument.
GetPrimaryStyleFromStyle(int style) const4720 int wxStyledTextCtrl::GetPrimaryStyleFromStyle(int style) const
4721 {
4722 return SendMsg(SCI_GETPRIMARYSTYLEFROMSTYLE, style, 0);
4723 }
4724
4725 // Free allocated sub styles
FreeSubStyles()4726 void wxStyledTextCtrl::FreeSubStyles()
4727 {
4728 SendMsg(SCI_FREESUBSTYLES, 0, 0);
4729 }
4730
4731 // Set the identifiers that are shown in a particular style
SetIdentifiers(int style,const wxString & identifiers)4732 void wxStyledTextCtrl::SetIdentifiers(int style, const wxString& identifiers)
4733 {
4734 SendMsg(SCI_SETIDENTIFIERS, style, (sptr_t)(const char*)wx2stc(identifiers));
4735 }
4736
4737 // Where styles are duplicated by a feature such as active/inactive code
4738 // return the distance between the two types.
DistanceToSecondaryStyles() const4739 int wxStyledTextCtrl::DistanceToSecondaryStyles() const
4740 {
4741 return SendMsg(SCI_DISTANCETOSECONDARYSTYLES, 0, 0);
4742 }
4743
4744 // Get the set of base styles that can be extended with sub styles
GetSubStyleBases() const4745 wxString wxStyledTextCtrl::GetSubStyleBases() const {
4746 const int msg = SCI_GETSUBSTYLEBASES;
4747 long len = SendMsg(msg, 0, (sptr_t)NULL);
4748 if (!len) return wxEmptyString;
4749
4750 wxCharBuffer buf(len);
4751 SendMsg(msg, 0, (sptr_t)buf.data());
4752 return stc2wx(buf);
4753 }
4754
4755 //}}}
4756 //----------------------------------------------------------------------
4757
4758
4759 // Returns the line number of the line with the caret.
GetCurrentLine()4760 int wxStyledTextCtrl::GetCurrentLine() {
4761 int line = LineFromPosition(GetCurrentPos());
4762 return line;
4763 }
4764
4765
4766 // Extract style settings from a spec-string which is composed of one or
4767 // more of the following comma separated elements:
4768 //
4769 // bold turns on bold
4770 // italic turns on italics
4771 // fore:[name or #RRGGBB] sets the foreground colour
4772 // back:[name or #RRGGBB] sets the background colour
4773 // face:[facename] sets the font face name to use
4774 // size:[num] sets the font size in points
4775 // eol turns on eol filling
4776 // underline turns on underlining
4777 //
StyleSetSpec(int styleNum,const wxString & spec)4778 void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
4779
4780 wxStringTokenizer tkz(spec, wxT(","));
4781 while (tkz.HasMoreTokens()) {
4782 wxString token = tkz.GetNextToken();
4783
4784 wxString option = token.BeforeFirst(':');
4785 wxString val = token.AfterFirst(':');
4786
4787 if (option == wxT("bold"))
4788 StyleSetBold(styleNum, true);
4789
4790 else if (option == wxT("italic"))
4791 StyleSetItalic(styleNum, true);
4792
4793 else if (option == wxT("underline"))
4794 StyleSetUnderline(styleNum, true);
4795
4796 else if (option == wxT("eol"))
4797 StyleSetEOLFilled(styleNum, true);
4798
4799 else if (option == wxT("size")) {
4800 long points;
4801 if (val.ToLong(&points))
4802 StyleSetSize(styleNum, points);
4803 }
4804
4805 else if (option == wxT("face"))
4806 StyleSetFaceName(styleNum, val);
4807
4808 else if (option == wxT("fore"))
4809 StyleSetForeground(styleNum, wxColourFromSpec(val));
4810
4811 else if (option == wxT("back"))
4812 StyleSetBackground(styleNum, wxColourFromSpec(val));
4813 }
4814 }
4815
4816
4817 // Get the font of a style
StyleGetFont(int style)4818 wxFont wxStyledTextCtrl::StyleGetFont(int style) {
4819 wxFont font;
4820 font.SetPointSize(StyleGetSize(style));
4821 font.SetFaceName(StyleGetFaceName(style));
4822 if( StyleGetBold(style) )
4823 font.SetWeight(wxFONTWEIGHT_BOLD);
4824 else
4825 font.SetWeight(wxFONTWEIGHT_NORMAL);
4826
4827 if( StyleGetItalic(style) )
4828 font.SetStyle(wxFONTSTYLE_ITALIC);
4829 else
4830 font.SetStyle(wxFONTSTYLE_NORMAL);
4831
4832 return font;
4833 }
4834
4835
4836 // Set style size, face, bold, italic, and underline attributes from
4837 // a wxFont's attributes.
StyleSetFont(int styleNum,const wxFont & font)4838 void wxStyledTextCtrl::StyleSetFont(int styleNum, const wxFont& font) {
4839 #ifdef __WXGTK__
4840 // Ensure that the native font is initialized
4841 int x, y;
4842 GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font);
4843 #endif
4844 int size = font.GetPointSize();
4845 wxString faceName = font.GetFaceName();
4846 bool bold = font.GetWeight() == wxFONTWEIGHT_BOLD;
4847 bool italic = font.GetStyle() != wxFONTSTYLE_NORMAL;
4848 bool under = font.GetUnderlined();
4849 wxFontEncoding encoding = font.GetEncoding();
4850
4851 StyleSetFontAttr(styleNum, size, faceName, bold, italic, under, encoding);
4852 }
4853
4854 // Set all font style attributes at once.
StyleSetFontAttr(int styleNum,int size,const wxString & faceName,bool bold,bool italic,bool underline,wxFontEncoding encoding)4855 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
4856 const wxString& faceName,
4857 bool bold, bool italic,
4858 bool underline,
4859 wxFontEncoding encoding) {
4860 StyleSetSize(styleNum, size);
4861 StyleSetFaceName(styleNum, faceName);
4862 StyleSetBold(styleNum, bold);
4863 StyleSetItalic(styleNum, italic);
4864 StyleSetUnderline(styleNum, underline);
4865 StyleSetFontEncoding(styleNum, encoding);
4866 }
4867
4868
4869 // Set the font encoding to be used by a style.
StyleSetFontEncoding(int style,wxFontEncoding encoding)4870 void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding)
4871 {
4872 SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
4873 }
4874
4875
4876 // Perform one of the operations defined by the wxSTC_CMD_* constants.
CmdKeyExecute(int cmd)4877 void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
4878 SendMsg(cmd);
4879 }
4880
4881
4882 // Set the left and right margin in the edit area, measured in pixels.
SetMargins(int left,int right)4883 void wxStyledTextCtrl::SetMargins(int left, int right) {
4884 SetMarginLeft(left);
4885 SetMarginRight(right);
4886 }
4887
4888
4889 // Scroll enough to make the given line visible
ScrollToLine(int line)4890 void wxStyledTextCtrl::ScrollToLine(int line) {
4891 m_swx->DoScrollToLine(line);
4892 }
4893
4894
4895 // Scroll enough to make the given column visible
ScrollToColumn(int column)4896 void wxStyledTextCtrl::ScrollToColumn(int column) {
4897 m_swx->DoScrollToColumn(column);
4898 }
4899
4900
DoSetValue(const wxString & value,int flags)4901 void wxStyledTextCtrl::DoSetValue(const wxString& value, int flags)
4902 {
4903 if ( flags & SetValue_SelectionOnly )
4904 ReplaceSelection(value);
4905 else
4906 SetText(value);
4907
4908 // We don't send wxEVT_TEXT anyhow, so ignore the
4909 // SetValue_SendEvent bit of the flags
4910 }
4911
4912 bool
DoSaveFile(const wxString & filename,int WXUNUSED (fileType))4913 wxStyledTextCtrl::DoSaveFile(const wxString& filename, int WXUNUSED(fileType))
4914 {
4915 #if wxUSE_FFILE || wxUSE_FILE
4916
4917 #if wxUSE_FFILE
4918 // Take care to use "b" to ensure that possibly non-native EOLs in the file
4919 // contents are not mangled when saving it.
4920 wxFFile file(filename, wxS("wb"));
4921 #elif wxUSE_FILE
4922 wxFile file(filename, wxFile::write);
4923 #endif
4924
4925 if ( file.IsOpened() && file.Write(GetValue(), *wxConvCurrent) )
4926 {
4927 SetSavePoint();
4928
4929 return true;
4930 }
4931
4932 #endif // !wxUSE_FFILE && !wxUSE_FILE
4933
4934 return false;
4935 }
4936
4937 bool
DoLoadFile(const wxString & filename,int WXUNUSED (fileType))4938 wxStyledTextCtrl::DoLoadFile(const wxString& filename, int WXUNUSED(fileType))
4939 {
4940 #if wxUSE_FFILE || wxUSE_FILE
4941
4942 #if wxUSE_FFILE
4943 // As above, we want to read the real EOLs from the file, e.g. without
4944 // translating them to just LFs under Windows, so that the original CR LF
4945 // are preserved when it's written back.
4946 wxFFile file(filename, wxS("rb"));
4947 #else
4948 wxFile file(filename);
4949 #endif
4950
4951 if ( file.IsOpened() )
4952 {
4953 wxString text;
4954 if ( file.ReadAll(&text, wxConvAuto()) )
4955 {
4956 // Detect the EOL: we use just the first line because there is not
4957 // much we can do if the file uses inconsistent EOLs anyhow, we'd
4958 // need to ask the user about the one we should really use and we
4959 // don't currently provide a way to do it.
4960 //
4961 // We also only check for Unix and DOS EOLs but not classic Mac
4962 // CR-only one as it's obsolete by now.
4963 const wxString::size_type posLF = text.find('\n');
4964 if ( posLF != wxString::npos )
4965 {
4966 // Set EOL mode to ensure that the new lines inserted into the
4967 // text use the same EOLs as the existing ones.
4968 if ( posLF > 0 && text[posLF - 1] == '\r' )
4969 SetEOLMode(wxSTC_EOL_CRLF);
4970 else
4971 SetEOLMode(wxSTC_EOL_LF);
4972 }
4973 //else: Use the default EOL for the current platform.
4974
4975 SetValue(text);
4976 EmptyUndoBuffer();
4977 SetSavePoint();
4978
4979 return true;
4980 }
4981 }
4982 #endif // !wxUSE_FFILE && !wxUSE_FILE
4983
4984 return false;
4985 }
4986
4987 // If we don't derive from wxTextAreaBase, we need to implement these methods
4988 // ourselves, otherwise we already inherit them.
4989 #if !wxUSE_TEXTCTRL
4990
SaveFile(const wxString & filename)4991 bool wxStyledTextCtrl::SaveFile(const wxString& filename)
4992 {
4993 if ( filename.empty() )
4994 return false;
4995
4996 return DoSaveFile(filename, wxTEXT_TYPE_ANY);
4997 }
4998
LoadFile(const wxString & filename)4999 bool wxStyledTextCtrl::LoadFile(const wxString& filename)
5000 {
5001 if ( filename.empty() )
5002 return false;
5003
5004 return DoLoadFile(filename, wxTEXT_TYPE_ANY);
5005 }
5006
5007 #endif // !wxUSE_TEXTCTRL
5008
5009 #if wxUSE_DRAG_AND_DROP
DoDragEnter(wxCoord x,wxCoord y,wxDragResult def)5010 wxDragResult wxStyledTextCtrl::DoDragEnter(wxCoord x, wxCoord y, wxDragResult def) {
5011 return m_swx->DoDragEnter(x, y, def);
5012 }
5013
DoDragOver(wxCoord x,wxCoord y,wxDragResult def)5014 wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
5015 return m_swx->DoDragOver(x, y, def);
5016 }
5017
DoDragLeave()5018 void wxStyledTextCtrl::DoDragLeave() {
5019 m_swx->DoDragLeave();
5020 }
5021
DoDropText(long x,long y,const wxString & data)5022 bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) {
5023 return m_swx->DoDropText(x, y, data);
5024 }
5025 #endif
5026
5027
SetUseAntiAliasing(bool useAA)5028 void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) {
5029 m_swx->SetUseAntiAliasing(useAA);
5030 }
5031
GetUseAntiAliasing()5032 bool wxStyledTextCtrl::GetUseAntiAliasing() {
5033 return m_swx->GetUseAntiAliasing();
5034 }
5035
AnnotationClearLine(int line)5036 void wxStyledTextCtrl::AnnotationClearLine(int line) {
5037 SendMsg(SCI_ANNOTATIONSETTEXT, line, (sptr_t)NULL);
5038 }
5039
MarkerDefineBitmap(int markerNumber,const wxBitmap & bmp)5040 void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber,
5041 const wxBitmap& bmp) {
5042 m_swx->DoMarkerDefineBitmap(markerNumber, bmp);
5043 }
5044
RegisterImage(int type,const wxBitmap & bmp)5045 void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp)
5046 {
5047 m_swx->DoRegisterImage(type, bmp);
5048 }
5049
5050
5051
5052
AddTextRaw(const char * text,int length)5053 void wxStyledTextCtrl::AddTextRaw(const char* text, int length)
5054 {
5055 if (length == -1)
5056 length = strlen(text);
5057 SendMsg(SCI_ADDTEXT, length, (sptr_t)text);
5058 }
5059
InsertTextRaw(int pos,const char * text)5060 void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text)
5061 {
5062 SendMsg(SCI_INSERTTEXT, pos, (sptr_t)text);
5063 }
5064
GetCurLineRaw(int * linePos)5065 wxCharBuffer wxStyledTextCtrl::GetCurLineRaw(int* linePos)
5066 {
5067 int len = LineLength(GetCurrentLine());
5068 if (!len) {
5069 if (linePos) *linePos = 0;
5070 wxCharBuffer empty;
5071 return empty;
5072 }
5073
5074 wxCharBuffer buf(len);
5075 int pos = SendMsg(SCI_GETCURLINE, len, (sptr_t)buf.data());
5076 if (linePos) *linePos = pos;
5077 return buf;
5078 }
5079
GetLineRaw(int line)5080 wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line)
5081 {
5082 int len = LineLength(line);
5083 if (!len) {
5084 wxCharBuffer empty;
5085 return empty;
5086 }
5087
5088 wxCharBuffer buf(len);
5089 SendMsg(SCI_GETLINE, line, (sptr_t)buf.data());
5090 return buf;
5091 }
5092
GetSelectedTextRaw()5093 wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw()
5094 {
5095 // Calculate the length needed first.
5096 const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0);
5097
5098 // And then really get the data.
5099 wxCharBuffer buf(len);
5100 SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data());
5101 return buf;
5102 }
5103
GetTargetTextRaw()5104 wxCharBuffer wxStyledTextCtrl::GetTargetTextRaw()
5105 {
5106 // Calculate the length needed first.
5107 const int len = SendMsg(SCI_GETTARGETEND, 0, 0) - SendMsg(SCI_GETTARGETSTART, 0, 0);
5108
5109 // And then really get the data.
5110 wxCharBuffer buf(len);
5111 SendMsg(SCI_GETTARGETTEXT, 0, (sptr_t)buf.data());
5112 return buf;
5113 }
5114
GetTextRangeRaw(int startPos,int endPos)5115 wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos)
5116 {
5117 if (endPos < startPos) {
5118 wxSwap(startPos, endPos);
5119 }
5120 int len = endPos - startPos;
5121 if (!len) {
5122 wxCharBuffer empty;
5123 return empty;
5124 }
5125
5126 wxCharBuffer buf(len);
5127 Sci_TextRange tr;
5128 tr.lpstrText = buf.data();
5129 tr.chrg.cpMin = startPos;
5130 tr.chrg.cpMax = endPos;
5131 tr.lpstrText[0] = '\0'; // initialize with 0 in case the range is invalid
5132 SendMsg(SCI_GETTEXTRANGE, 0, (sptr_t)&tr);
5133 return buf;
5134 }
5135
SetTextRaw(const char * text)5136 void wxStyledTextCtrl::SetTextRaw(const char* text)
5137 {
5138 SendMsg(SCI_SETTEXT, 0, (sptr_t)text);
5139 }
5140
GetTextRaw()5141 wxCharBuffer wxStyledTextCtrl::GetTextRaw()
5142 {
5143 int len = GetTextLength();
5144 wxCharBuffer buf(len); // adds 1 for NUL automatically
5145 SendMsg(SCI_GETTEXT, len + 1, (sptr_t)buf.data());
5146 return buf;
5147 }
5148
AppendTextRaw(const char * text,int length)5149 void wxStyledTextCtrl::AppendTextRaw(const char* text, int length)
5150 {
5151 if (length == -1)
5152 length = strlen(text);
5153 SendMsg(SCI_APPENDTEXT, length, (sptr_t)text);
5154 }
5155
ReplaceSelectionRaw(const char * text)5156 void wxStyledTextCtrl::ReplaceSelectionRaw(const char* text)
5157 {
5158 SendMsg(SCI_REPLACESEL, 0, reinterpret_cast<sptr_t>(text));
5159 }
5160
ReplaceTargetRaw(const char * text,int length)5161 int wxStyledTextCtrl::ReplaceTargetRaw(const char* text, int length)
5162 {
5163 if ( length == -1 )
5164 length = strlen(text);
5165
5166 return SendMsg(SCI_REPLACETARGET, length, reinterpret_cast<sptr_t>(text));
5167 }
5168
ReplaceTargetRERaw(const char * text,int length)5169 int wxStyledTextCtrl::ReplaceTargetRERaw(const char* text, int length)
5170 {
5171 if ( length == -1 )
5172 length = strlen(text);
5173
5174 return SendMsg(SCI_REPLACETARGETRE, length, reinterpret_cast<sptr_t>(text));
5175 }
5176
5177 #if WXWIN_COMPATIBILITY_3_0
5178 // Deprecated since Scintilla 3.7.2
UsePopUp(bool allowPopUp)5179 void wxStyledTextCtrl::UsePopUp(bool allowPopUp)
5180 {
5181 SendMsg(SCI_USEPOPUP, allowPopUp ? SC_POPUP_ALL : SC_POPUP_NEVER, 0);
5182 }
5183
StartStyling(int start,int unused)5184 void wxStyledTextCtrl::StartStyling(int start, int unused)
5185 {
5186 wxASSERT_MSG(unused==0,
5187 "The second argument passed to StartStyling should be 0");
5188
5189 SendMsg(SCI_STARTSTYLING, start, unused);
5190 }
5191 #endif // WXWIN_COMPATIBILITY_3_0
5192
5193 //----------------------------------------------------------------------
5194 // Event handlers
5195
OnPaint(wxPaintEvent & WXUNUSED (evt))5196 void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
5197 wxPaintDC dc(this);
5198 m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
5199 }
5200
OnScrollWin(wxScrollWinEvent & evt)5201 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) {
5202 if (evt.GetOrientation() == wxHORIZONTAL)
5203 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
5204 else
5205 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
5206 }
5207
OnScroll(wxScrollEvent & evt)5208 void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
5209 wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar);
5210 if (sb) {
5211 if (sb->IsVertical())
5212 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
5213 else
5214 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
5215 }
5216 }
5217
OnSize(wxSizeEvent & WXUNUSED (evt))5218 void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) {
5219 if (m_swx) {
5220 wxSize sz = GetClientSize();
5221 m_swx->DoSize(sz.x, sz.y);
5222 }
5223 }
5224
OnMouseLeftDown(wxMouseEvent & evt)5225 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
5226 SetFocus();
5227 wxPoint pt = evt.GetPosition();
5228 m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
5229 evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
5230 }
5231
OnMouseRightDown(wxMouseEvent & evt)5232 void wxStyledTextCtrl::OnMouseRightDown(wxMouseEvent& evt) {
5233 SetFocus();
5234 wxPoint pt = evt.GetPosition();
5235 m_swx->DoRightButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
5236 evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
5237 // We need to call evt.Skip() to allow generating EVT_CONTEXT_MENU
5238 evt.Skip();
5239 }
5240
OnMouseMove(wxMouseEvent & evt)5241 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
5242 wxPoint pt = evt.GetPosition();
5243 m_swx->DoLeftButtonMove(Point(pt.x, pt.y));
5244 }
5245
OnMouseLeftUp(wxMouseEvent & evt)5246 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
5247 wxPoint pt = evt.GetPosition();
5248 m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
5249 evt.ControlDown());
5250 }
5251
OnMouseMiddleUp(wxMouseEvent & evt)5252 void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) {
5253 wxPoint pt = evt.GetPosition();
5254 m_swx->DoMiddleButtonUp(Point(pt.x, pt.y));
5255 }
5256
OnContextMenu(wxContextMenuEvent & evt)5257 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
5258 wxPoint pt = evt.GetPosition();
5259 ScreenToClient(&pt.x, &pt.y);
5260 /*
5261 Show context menu at event point if it's within the window,
5262 or at caret location if not
5263 */
5264 wxHitTest ht = this->HitTest(pt);
5265 if (ht != wxHT_WINDOW_INSIDE) {
5266 pt = this->PointFromPosition(this->GetCurrentPos());
5267 }
5268 if ( !m_swx->DoContextMenu(Point(pt.x, pt.y)) )
5269 evt.Skip();
5270 }
5271
5272
OnMouseWheel(wxMouseEvent & evt)5273 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt)
5274 {
5275 // The default action of this method is to call m_swx->DoMouseWheel.
5276 // However, it might be necessary to do something else depending on whether
5277 // 1) the mouse wheel captures for the STC,
5278 // 2) the event's position is in the STC's rect, and
5279 // 3) and an autocompletion list is currently being shown.
5280 // This table summarizes when each action is needed.
5281
5282 // InRect | MouseWheelCaptures | Autocomp Active | action
5283 // -------+--------------------+-----------------+-------------------
5284 // true | true | true | scroll ac list
5285 // true | true | false | default
5286 // true | false | true | scroll ac list
5287 // true | false | false | default
5288 // false | true | true | scroll ac list
5289 // false | true | false | default
5290 // false | false | true | forward to parent
5291 // false | false | false | forward to parent
5292
5293 // if the mouse wheel is not captured, test if the mouse
5294 // pointer is over the editor window and if not, don't
5295 // handle the message but pass it on.
5296 if ( !GetMouseWheelCaptures() && !GetRect().Contains(evt.GetPosition()) )
5297 {
5298 wxWindow* parent = GetParent();
5299 if ( parent != NULL )
5300 {
5301 wxMouseEvent newevt(evt);
5302 newevt.SetPosition(
5303 parent->ScreenToClient(ClientToScreen(evt.GetPosition())));
5304 parent->ProcessWindowEvent(newevt);
5305 }
5306 }
5307 else if ( AutoCompActive() )
5308 {
5309 // When the autocompletion popup is active, Scintilla uses the mouse
5310 // wheel to scroll the autocomp list instead of the editor.
5311
5312 // First try to find the list. It will be a wxVListBox named
5313 // "AutoCompListBox".
5314 wxWindow* curWin = this, *acListBox = NULL;
5315 wxStack<wxWindow*> windows;
5316 windows.push(curWin);
5317
5318 while ( !windows.empty() )
5319 {
5320 curWin = windows.top();
5321 windows.pop();
5322
5323 if ( curWin->IsKindOf(wxCLASSINFO(wxVListBox)) &&
5324 curWin->GetName() == "AutoCompListBox")
5325 {
5326 acListBox = curWin;
5327 break;
5328 }
5329
5330 wxWindowList& children = curWin->GetChildren();
5331 wxWindowList::iterator it;
5332
5333 for ( it = children.begin(); it!=children.end(); ++it )
5334 {
5335 windows.push(*it);
5336 }
5337 }
5338
5339 // Next if the list was found, send it a copy of this event.
5340 if ( acListBox )
5341 {
5342 wxMouseEvent newevt(evt);
5343 newevt.SetPosition(
5344 acListBox->ScreenToClient(ClientToScreen(evt.GetPosition())));
5345 acListBox->ProcessWindowEvent(newevt);
5346 }
5347 }
5348 else
5349 {
5350 m_swx->DoMouseWheel(evt.GetWheelAxis(),
5351 evt.GetWheelRotation(),
5352 evt.GetWheelDelta(),
5353 evt.GetLinesPerAction(),
5354 evt.GetColumnsPerAction(),
5355 evt.ControlDown(),
5356 evt.IsPageScroll());
5357 }
5358 }
5359
5360
OnChar(wxKeyEvent & evt)5361 void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
5362 // On (some?) non-US PC keyboards the AltGr key is required to enter some
5363 // common characters. It comes to us as both Alt and Ctrl down so we need
5364 // to let the char through in that case, otherwise if only ctrl or only
5365 // alt let's skip it.
5366 bool ctrl = evt.ControlDown();
5367 #ifdef __WXMAC__
5368 // On the Mac the Alt key is just a modifier key (like Shift) so we need
5369 // to allow the char events to be processed when Alt is pressed.
5370 // TODO: Should we check MetaDown instead in this case?
5371 bool alt = false;
5372 #else
5373 bool alt = evt.AltDown();
5374 #endif
5375 bool skip = ((ctrl || alt) && ! (ctrl && alt));
5376
5377 #if wxUSE_UNICODE
5378 // apparently if we don't do this, Unicode keys pressed after non-char
5379 // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989)
5380 if (m_lastKeyDownConsumed && evt.GetUnicodeKey() > 255)
5381 m_lastKeyDownConsumed = false;
5382 #endif
5383
5384 if (!m_lastKeyDownConsumed && !skip) {
5385 #if wxUSE_UNICODE
5386 int key = evt.GetUnicodeKey();
5387 bool keyOk = true;
5388
5389 // if the unicode key code is not really a unicode character (it may
5390 // be a function key or etc., the platforms appear to always give us a
5391 // small value in this case) then fallback to the ascii key code but
5392 // don't do anything for function keys or etc.
5393 if (key <= 127) {
5394 key = evt.GetKeyCode();
5395 keyOk = (key <= 127);
5396 }
5397 if (keyOk) {
5398 m_swx->DoAddChar(key);
5399 return;
5400 }
5401 #else
5402 int key = evt.GetKeyCode();
5403 if (key < WXK_START) {
5404 m_swx->DoAddChar(key);
5405 return;
5406 }
5407 #endif
5408 }
5409
5410 evt.Skip();
5411 }
5412
5413
OnKeyDown(wxKeyEvent & evt)5414 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
5415 int processed = m_swx->DoKeyDown(evt, &m_lastKeyDownConsumed);
5416 if (!processed && !m_lastKeyDownConsumed)
5417 evt.Skip();
5418 }
5419
5420
OnLoseFocus(wxFocusEvent & evt)5421 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
5422 m_swx->DoLoseFocus();
5423 evt.Skip();
5424 }
5425
5426
OnGainFocus(wxFocusEvent & evt)5427 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
5428 m_swx->DoGainFocus();
5429 evt.Skip();
5430 }
5431
5432
OnDPIChanged(wxDPIChangedEvent & evt)5433 void wxStyledTextCtrl::OnDPIChanged(wxDPIChangedEvent& evt) {
5434 m_swx->DoInvalidateStyleData();
5435
5436 // trigger a cursor change, so any cursors created by wxWidgets (like reverse arrow) will be recreated
5437 const int oldCursor = GetSTCCursor();
5438 SetSTCCursor(-1);
5439 SetSTCCursor(oldCursor);
5440
5441 // adjust the margins to the new DPI
5442 for ( int i = 0; i < SC_MAX_MARGIN; ++i )
5443 {
5444 SetMarginWidth(i, (int)wxMulDivInt32(GetMarginWidth(i), evt.GetNewDPI().y, evt.GetOldDPI().y));
5445 }
5446
5447 // Hide auto-complete popup, there is no (easy) way to set it to the correct size
5448 // and position
5449 if ( AutoCompActive() )
5450 {
5451 AutoCompCancel();
5452 }
5453 }
5454
5455
OnSysColourChanged(wxSysColourChangedEvent & WXUNUSED (evt))5456 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) {
5457 m_swx->DoInvalidateStyleData();
5458 }
5459
5460
OnEraseBackground(wxEraseEvent & WXUNUSED (evt))5461 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) {
5462 // do nothing to help avoid flashing
5463 }
5464
5465
5466
OnMenu(wxCommandEvent & evt)5467 void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
5468 m_swx->DoCommand(evt.GetId());
5469 }
5470
5471
OnListBox(wxCommandEvent & WXUNUSED (evt))5472 void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) {
5473 m_swx->DoOnListBox();
5474 }
5475
5476
OnIdle(wxIdleEvent & evt)5477 void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) {
5478 m_swx->DoOnIdle(evt);
5479 }
5480
5481
OnMouseCaptureLost(wxMouseCaptureLostEvent & WXUNUSED (evt))5482 void wxStyledTextCtrl::OnMouseCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(evt)) {
5483 m_swx->DoMouseCaptureLost();
5484 }
5485
5486
DoGetBestSize() const5487 wxSize wxStyledTextCtrl::DoGetBestSize() const
5488 {
5489 // What would be the best size for a wxSTC?
5490 // Just give a reasonable minimum until something else can be figured out.
5491 return FromDIP(wxSize(200,100));
5492 }
5493
5494
5495 //----------------------------------------------------------------------
5496 // Turn notifications from Scintilla into events
5497
5498
NotifyChange()5499 void wxStyledTextCtrl::NotifyChange() {
5500 wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId());
5501 evt.SetEventObject(this);
5502 GetEventHandler()->ProcessEvent(evt);
5503 }
5504
5505
SetEventText(wxStyledTextEvent & evt,const char * text,size_t length)5506 static void SetEventText(wxStyledTextEvent& evt, const char* text,
5507 size_t length) {
5508 if(!text) return;
5509
5510 evt.SetString(stc2wx(text, length));
5511 }
5512
5513
NotifyParent(SCNotification * _scn)5514 void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
5515 SCNotification& scn = *_scn;
5516 wxStyledTextEvent evt(0, GetId());
5517
5518 evt.SetEventObject(this);
5519 evt.SetPosition(scn.position);
5520 evt.SetKey(scn.ch);
5521 evt.SetModifiers(scn.modifiers);
5522
5523 switch (scn.nmhdr.code) {
5524 case SCN_STYLENEEDED:
5525 evt.SetEventType(wxEVT_STC_STYLENEEDED);
5526 break;
5527
5528 case SCN_CHARADDED:
5529 evt.SetEventType(wxEVT_STC_CHARADDED);
5530 break;
5531
5532 case SCN_SAVEPOINTREACHED:
5533 evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED);
5534 break;
5535
5536 case SCN_SAVEPOINTLEFT:
5537 evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT);
5538 break;
5539
5540 case SCN_MODIFYATTEMPTRO:
5541 evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT);
5542 break;
5543
5544 case SCN_DOUBLECLICK:
5545 evt.SetEventType(wxEVT_STC_DOUBLECLICK);
5546 evt.SetLine(scn.line);
5547 break;
5548
5549 case SCN_UPDATEUI:
5550 evt.SetEventType(wxEVT_STC_UPDATEUI);
5551 evt.SetUpdated(scn.updated);
5552 break;
5553
5554 case SCN_MODIFIED:
5555 evt.SetEventType(wxEVT_STC_MODIFIED);
5556 evt.SetModificationType(scn.modificationType);
5557 SetEventText(evt, scn.text, scn.length);
5558 evt.SetLength(scn.length);
5559 evt.SetLinesAdded(scn.linesAdded);
5560 evt.SetLine(scn.line);
5561 evt.SetFoldLevelNow(scn.foldLevelNow);
5562 evt.SetFoldLevelPrev(scn.foldLevelPrev);
5563 evt.SetToken(scn.token);
5564 evt.SetAnnotationLinesAdded(scn.annotationLinesAdded);
5565 break;
5566
5567 case SCN_MACRORECORD:
5568 evt.SetEventType(wxEVT_STC_MACRORECORD);
5569 evt.SetMessage(scn.message);
5570 evt.SetWParam(scn.wParam);
5571 evt.SetLParam(scn.lParam);
5572 break;
5573
5574 case SCN_MARGINCLICK:
5575 evt.SetEventType(wxEVT_STC_MARGINCLICK);
5576 evt.SetMargin(scn.margin);
5577 break;
5578
5579 case SCN_NEEDSHOWN:
5580 evt.SetEventType(wxEVT_STC_NEEDSHOWN);
5581 evt.SetLength(scn.length);
5582 break;
5583
5584 case SCN_PAINTED:
5585 evt.SetEventType(wxEVT_STC_PAINTED);
5586 break;
5587
5588 case SCN_USERLISTSELECTION:
5589 evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
5590 evt.SetListType(scn.listType);
5591 SetEventText(evt, scn.text, strlen(scn.text));
5592 evt.SetPosition(scn.lParam);
5593 evt.SetListCompletionMethod(scn.listCompletionMethod);
5594 break;
5595
5596 case SCN_DWELLSTART:
5597 evt.SetEventType(wxEVT_STC_DWELLSTART);
5598 evt.SetX(scn.x);
5599 evt.SetY(scn.y);
5600 break;
5601
5602 case SCN_DWELLEND:
5603 evt.SetEventType(wxEVT_STC_DWELLEND);
5604 evt.SetX(scn.x);
5605 evt.SetY(scn.y);
5606 break;
5607
5608 case SCN_ZOOM:
5609 evt.SetEventType(wxEVT_STC_ZOOM);
5610 break;
5611
5612 case SCN_HOTSPOTCLICK:
5613 evt.SetEventType(wxEVT_STC_HOTSPOT_CLICK);
5614 break;
5615
5616 case SCN_HOTSPOTDOUBLECLICK:
5617 evt.SetEventType(wxEVT_STC_HOTSPOT_DCLICK);
5618 break;
5619
5620 case SCN_HOTSPOTRELEASECLICK:
5621 evt.SetEventType(wxEVT_STC_HOTSPOT_RELEASE_CLICK);
5622 break;
5623
5624 case SCN_INDICATORCLICK:
5625 evt.SetEventType(wxEVT_STC_INDICATOR_CLICK);
5626 break;
5627
5628 case SCN_INDICATORRELEASE:
5629 evt.SetEventType(wxEVT_STC_INDICATOR_RELEASE);
5630 break;
5631
5632 case SCN_CALLTIPCLICK:
5633 evt.SetEventType(wxEVT_STC_CALLTIP_CLICK);
5634 break;
5635
5636 case SCN_AUTOCSELECTION:
5637 evt.SetEventType(wxEVT_STC_AUTOCOMP_SELECTION);
5638 evt.SetListType(scn.listType);
5639 SetEventText(evt, scn.text, strlen(scn.text));
5640 evt.SetPosition(scn.lParam);
5641 evt.SetListCompletionMethod(scn.listCompletionMethod);
5642 break;
5643
5644 case SCN_AUTOCCANCELLED:
5645 evt.SetEventType(wxEVT_STC_AUTOCOMP_CANCELLED);
5646 break;
5647
5648 case SCN_AUTOCCHARDELETED:
5649 evt.SetEventType(wxEVT_STC_AUTOCOMP_CHAR_DELETED);
5650 break;
5651
5652 case SCN_AUTOCCOMPLETED:
5653 evt.SetEventType(wxEVT_STC_AUTOCOMP_COMPLETED);
5654 evt.SetListType(scn.listType);
5655 SetEventText(evt, scn.text, strlen(scn.text));
5656 evt.SetPosition(scn.lParam);
5657 evt.SetListCompletionMethod(scn.listCompletionMethod);
5658 break;
5659
5660 case SCN_MARGINRIGHTCLICK:
5661 evt.SetEventType(wxEVT_STC_MARGIN_RIGHT_CLICK);
5662 evt.SetMargin(scn.margin);
5663 break;
5664
5665 default:
5666 return;
5667 }
5668
5669 GetEventHandler()->ProcessEvent(evt);
5670 }
5671
5672 #ifdef __WXMSW__
MSWWindowProc(WXUINT nMsg,WXWPARAM wParam,WXLPARAM lParam)5673 WXLRESULT wxStyledTextCtrl::MSWWindowProc(WXUINT nMsg,
5674 WXWPARAM wParam,
5675 WXLPARAM lParam)
5676 {
5677 switch(nMsg) {
5678 // Forward IME messages to ScintillaWX
5679 case WM_IME_KEYDOWN:
5680 case WM_IME_REQUEST:
5681 case WM_IME_STARTCOMPOSITION:
5682 case WM_IME_ENDCOMPOSITION:
5683 case WM_IME_COMPOSITION:
5684 case WM_IME_SETCONTEXT:
5685 return SendMsg(nMsg, wParam, lParam);
5686 default:
5687 return wxControl::MSWWindowProc(nMsg, wParam, lParam);
5688 }
5689 }
5690 #endif
5691
5692
5693 //----------------------------------------------------------------------
5694 //----------------------------------------------------------------------
5695 //----------------------------------------------------------------------
5696
wxStyledTextEvent(wxEventType commandType,int id)5697 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
5698 : wxCommandEvent(commandType, id)
5699 {
5700 m_position = 0;
5701 m_key = 0;
5702 m_modifiers = 0;
5703 m_modificationType = 0;
5704 m_length = 0;
5705 m_linesAdded = 0;
5706 m_line = 0;
5707 m_foldLevelNow = 0;
5708 m_foldLevelPrev = 0;
5709 m_margin = 0;
5710 m_message = 0;
5711 m_wParam = 0;
5712 m_lParam = 0;
5713 m_listType = 0;
5714 m_x = 0;
5715 m_y = 0;
5716 m_token = 0;
5717 m_annotationLinesAdded = 0;
5718 m_updated = 0;
5719 m_listCompletionMethod = 0;
5720
5721 #if wxUSE_DRAG_AND_DROP
5722 m_dragFlags = wxDrag_CopyOnly;
5723 m_dragResult = wxDragNone;
5724 #endif
5725 }
5726
GetShift() const5727 bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
GetControl() const5728 bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; }
GetAlt() const5729 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; }
5730
5731
wxStyledTextEvent(const wxStyledTextEvent & event)5732 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event):
5733 wxCommandEvent(event)
5734 {
5735 m_position = event.m_position;
5736 m_key = event.m_key;
5737 m_modifiers = event.m_modifiers;
5738 m_modificationType = event.m_modificationType;
5739 m_length = event.m_length;
5740 m_linesAdded = event.m_linesAdded;
5741 m_line = event.m_line;
5742 m_foldLevelNow = event.m_foldLevelNow;
5743 m_foldLevelPrev = event.m_foldLevelPrev;
5744
5745 m_margin = event.m_margin;
5746
5747 m_message = event.m_message;
5748 m_wParam = event.m_wParam;
5749 m_lParam = event.m_lParam;
5750
5751 m_listType = event.m_listType;
5752 m_x = event.m_x;
5753 m_y = event.m_y;
5754
5755 m_token = event.m_token;
5756 m_annotationLinesAdded = event.m_annotationLinesAdded;
5757 m_updated = event.m_updated;
5758 m_listCompletionMethod = event.m_listCompletionMethod;
5759
5760 #if wxUSE_DRAG_AND_DROP
5761 m_dragFlags = event.m_dragFlags;
5762 m_dragResult = event.m_dragResult;
5763 #endif
5764 }
5765
5766 //----------------------------------------------------------------------
5767 //----------------------------------------------------------------------
5768
GetLibraryVersionInfo()5769 /*static*/ wxVersionInfo wxStyledTextCtrl::GetLibraryVersionInfo()
5770 {
5771 return wxVersionInfo("Scintilla", 3, 7, 2, "Scintilla 3.7.2");
5772 }
5773
5774 #endif // wxUSE_STC
5775