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