]> git.saurik.com Git - wxWidgets.git/blame - src/stc/stc.cpp
fixes #13557
[wxWidgets.git] / src / stc / stc.cpp
CommitLineData
9ce192d4 1////////////////////////////////////////////////////////////////////////////
4ce59b1f 2// Name: stc.cpp
be5a51fb 3// Purpose: A wxWidgets implementation of Scintilla. This class is the
9ce192d4
RD
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
f6bcfd97 8// namespace with all the classes and identifiers from Scintilla.
9ce192d4
RD
9//
10// Author: Robin Dunn
11//
12// Created: 13-Jan-2000
13// RCS-ID: $Id$
14// Copyright: (c) 2000 by Total Control Software
526954c5 15// Licence: wxWindows licence
9ce192d4
RD
16/////////////////////////////////////////////////////////////////////////////
17
a5c2ccf2
VZ
18/*
19 IMPORTANT: src/stc/stc.cpp is generated by src/stc/gen_iface.py from
20 src/stc/stc.cpp.in, don't edit stc.cpp file as your changes will be
21 lost after the next regeneration, edit stc.cpp.in and rerun the
22 gen_iface.py script instead!
23
24 Parts of this file generated by the script are found in between
25 the special "{{{" and "}}}" markers, the rest of it is copied
26 verbatim from src.h.in.
27 */
28
54429bb3
RD
29// For compilers that support precompilation, includes "wx.h".
30#include "wx/wxprec.h"
31
32#ifdef __BORLANDC__
33 #pragma hdrstop
34#endif
35
29825f5f
PC
36#if wxUSE_STC
37
38#include "wx/stc/stc.h"
ea88e9bc 39#include "wx/stc/private.h"
54429bb3
RD
40
41#ifndef WX_PRECOMP
29825f5f 42 #include "wx/wx.h"
54429bb3
RD
43#endif // WX_PRECOMP
44
f6bcfd97
BP
45#include <ctype.h>
46
d6655166
WS
47#include "wx/tokenzr.h"
48#include "wx/mstream.h"
49#include "wx/image.h"
3396739d 50#include "wx/ffile.h"
9ce192d4 51
f9ee2e27 52#include "ScintillaWX.h"
f6bcfd97 53
9ce192d4
RD
54//----------------------------------------------------------------------
55
23318a53 56const char wxSTCNameStr[] = "stcwindow";
9ce192d4 57
451c5cc7
RD
58#ifdef MAKELONG
59#undef MAKELONG
60#endif
61
62#define MAKELONG(a, b) ((a) | ((b) << 16))
63
64
65static long wxColourAsLong(const wxColour& co) {
66 return (((long)co.Blue() << 16) |
67 ((long)co.Green() << 8) |
68 ((long)co.Red()));
69}
70
71static wxColour wxColourFromLong(long c) {
72 wxColour clr;
c8b75e94
WS
73 clr.Set((unsigned char)(c & 0xff),
74 (unsigned char)((c >> 8) & 0xff),
75 (unsigned char)((c >> 16) & 0xff));
451c5cc7
RD
76 return clr;
77}
78
79
80static wxColour wxColourFromSpec(const wxString& spec) {
5ee1d760
RD
81 // spec should be a colour name or "#RRGGBB"
82 if (spec.GetChar(0) == wxT('#')) {
7e126a07 83
5ee1d760
RD
84 long red, green, blue;
85 red = green = blue = 0;
86 spec.Mid(1,2).ToLong(&red, 16);
87 spec.Mid(3,2).ToLong(&green, 16);
88 spec.Mid(5,2).ToLong(&blue, 16);
c8b75e94
WS
89 return wxColour((unsigned char)red,
90 (unsigned char)green,
91 (unsigned char)blue);
5ee1d760
RD
92 }
93 else
94 return wxColour(spec);
451c5cc7
RD
95}
96
97//----------------------------------------------------------------------
98
9b11752c
VZ
99wxDEFINE_EVENT( wxEVT_STC_CHANGE, wxStyledTextEvent );
100wxDEFINE_EVENT( wxEVT_STC_STYLENEEDED, wxStyledTextEvent );
101wxDEFINE_EVENT( wxEVT_STC_CHARADDED, wxStyledTextEvent );
102wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTREACHED, wxStyledTextEvent );
103wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTLEFT, wxStyledTextEvent );
104wxDEFINE_EVENT( wxEVT_STC_ROMODIFYATTEMPT, wxStyledTextEvent );
105wxDEFINE_EVENT( wxEVT_STC_KEY, wxStyledTextEvent );
106wxDEFINE_EVENT( wxEVT_STC_DOUBLECLICK, wxStyledTextEvent );
107wxDEFINE_EVENT( wxEVT_STC_UPDATEUI, wxStyledTextEvent );
108wxDEFINE_EVENT( wxEVT_STC_MODIFIED, wxStyledTextEvent );
109wxDEFINE_EVENT( wxEVT_STC_MACRORECORD, wxStyledTextEvent );
110wxDEFINE_EVENT( wxEVT_STC_MARGINCLICK, wxStyledTextEvent );
111wxDEFINE_EVENT( wxEVT_STC_NEEDSHOWN, wxStyledTextEvent );
112wxDEFINE_EVENT( wxEVT_STC_PAINTED, wxStyledTextEvent );
113wxDEFINE_EVENT( wxEVT_STC_USERLISTSELECTION, wxStyledTextEvent );
114wxDEFINE_EVENT( wxEVT_STC_URIDROPPED, wxStyledTextEvent );
115wxDEFINE_EVENT( wxEVT_STC_DWELLSTART, wxStyledTextEvent );
116wxDEFINE_EVENT( wxEVT_STC_DWELLEND, wxStyledTextEvent );
117wxDEFINE_EVENT( wxEVT_STC_START_DRAG, wxStyledTextEvent );
118wxDEFINE_EVENT( wxEVT_STC_DRAG_OVER, wxStyledTextEvent );
119wxDEFINE_EVENT( wxEVT_STC_DO_DROP, wxStyledTextEvent );
120wxDEFINE_EVENT( wxEVT_STC_ZOOM, wxStyledTextEvent );
121wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_CLICK, wxStyledTextEvent );
122wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_DCLICK, wxStyledTextEvent );
123wxDEFINE_EVENT( wxEVT_STC_CALLTIP_CLICK, wxStyledTextEvent );
124wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_SELECTION, wxStyledTextEvent );
125wxDEFINE_EVENT( wxEVT_STC_INDICATOR_CLICK, wxStyledTextEvent );
126wxDEFINE_EVENT( wxEVT_STC_INDICATOR_RELEASE, wxStyledTextEvent );
9e96e16f
RD
127wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CANCELLED, wxStyledTextEvent );
128wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CHAR_DELETED, wxStyledTextEvent );
54173563 129wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_RELEASE_CLICK, wxStyledTextEvent );
9e730a78 130
d25f5fbb
RD
131
132
9ce192d4
RD
133BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
134 EVT_PAINT (wxStyledTextCtrl::OnPaint)
135 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin)
5fa4613c 136 EVT_SCROLL (wxStyledTextCtrl::OnScroll)
9ce192d4
RD
137 EVT_SIZE (wxStyledTextCtrl::OnSize)
138 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
4ceb1196
RD
139 // Let Scintilla see the double click as a second click
140 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
9ce192d4
RD
141 EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
142 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
451c5cc7 143#if defined(__WXGTK__) || defined(__WXMAC__)
ddf2da08
RD
144 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
145#else
65ec6247 146 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
ddf2da08 147#endif
37d62433 148 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
2b5f62a0 149 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp)
9ce192d4 150 EVT_CHAR (wxStyledTextCtrl::OnChar)
f6bcfd97 151 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
9ce192d4
RD
152 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
153 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus)
154 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
155 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
dd4aa550 156 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu)
7e126a07 157 EVT_LISTBOX_DCLICK (wxID_ANY, wxStyledTextCtrl::OnListBox)
9ce192d4
RD
158END_EVENT_TABLE()
159
f6bcfd97
BP
160
161IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
162IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
163
40716a51 164#ifdef LINK_LEXERS
1a2fb4cd 165// forces the linking of the lexer modules
a834585d 166int Scintilla_LinkLexers();
40716a51 167#endif
1a2fb4cd 168
9ce192d4
RD
169//----------------------------------------------------------------------
170// Constructor and Destructor
171
172wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
173 wxWindowID id,
174 const wxPoint& pos,
175 const wxSize& size,
176 long style,
39c0acb6
RD
177 const wxString& name)
178{
179 m_swx = NULL;
180 Create(parent, id, pos, size, style, name);
181}
182
183
a48cb415
RD
184bool wxStyledTextCtrl::Create(wxWindow *parent,
185 wxWindowID id,
186 const wxPoint& pos,
187 const wxSize& size,
188 long style,
189 const wxString& name)
9ce192d4 190{
2659dad3 191 style |= wxVSCROLL | wxHSCROLL;
a48cb415
RD
192 if (!wxControl::Create(parent, id, pos, size,
193 style | wxWANTS_CHARS | wxCLIP_CHILDREN,
194 wxDefaultValidator, name))
195 return false;
39c0acb6 196
40716a51 197#ifdef LINK_LEXERS
a834585d 198 Scintilla_LinkLexers();
40716a51 199#endif
9ce192d4 200 m_swx = new ScintillaWX(this);
9ce192d4 201 m_stopWatch.Start();
7e126a07 202 m_lastKeyDownConsumed = false;
5fa4613c
RD
203 m_vScrollBar = NULL;
204 m_hScrollBar = NULL;
10ef30eb
RD
205#if wxUSE_UNICODE
206 // Put Scintilla into unicode (UTF-8) mode
207 SetCodePage(wxSTC_CP_UTF8);
208#endif
8ae4f086 209
170acdc9 210 SetInitialSize(size);
f9ee2e27 211
be108f96 212 // Reduces flicker on GTK+/X11
c3e0999b 213 SetBackgroundStyle(wxBG_STYLE_PAINT);
439cce14
RD
214
215 // Make sure it can take the focus
216 SetCanFocus(true);
217
a48cb415 218 return true;
9ce192d4
RD
219}
220
221
222wxStyledTextCtrl::~wxStyledTextCtrl() {
223 delete m_swx;
9ce192d4
RD
224}
225
226
227//----------------------------------------------------------------------
228
fafd43c5 229wxIntPtr wxStyledTextCtrl::SendMsg(int msg, wxUIntPtr wp, wxIntPtr lp) const
8e0945da 230{
9ce192d4
RD
231 return m_swx->WndProc(msg, wp, lp);
232}
233
ccfc3219
RD
234//----------------------------------------------------------------------
235
236// Set the vertical scrollbar to use instead of the ont that's built-in.
237void wxStyledTextCtrl::SetVScrollBar(wxScrollBar* bar) {
238 m_vScrollBar = bar;
239 if (bar != NULL) {
240 // ensure that the built-in scrollbar is not visible
241 SetScrollbar(wxVERTICAL, 0, 0, 0);
242 }
243}
9ce192d4 244
9ce192d4 245
ccfc3219
RD
246// Set the horizontal scrollbar to use instead of the ont that's built-in.
247void wxStyledTextCtrl::SetHScrollBar(wxScrollBar* bar) {
248 m_hScrollBar = bar;
249 if (bar != NULL) {
250 // ensure that the built-in scrollbar is not visible
251 SetScrollbar(wxHORIZONTAL, 0, 0, 0);
252 }
253}
254
4370573a 255//----------------------------------------------------------------------
a5c2ccf2 256// Generated methods implementation section {{{
9ce192d4
RD
257
258
591d01be 259// Add text to the document at current position.
9ce192d4 260void wxStyledTextCtrl::AddText(const wxString& text) {
2ed48ef8 261 const wxWX2MBbuf buf = wx2stc(text);
d7b46878 262 SendMsg(2001, wx2stclen(text, buf), (sptr_t)(const char*)buf);
9ce192d4
RD
263}
264
a834585d 265// Add array of cells to document.
10ef30eb 266void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer& data) {
b796ba39 267 SendMsg(2002, data.GetDataLen(), (sptr_t)data.GetData());
9ce192d4
RD
268}
269
a834585d 270// Insert string at a position.
8e0945da
VZ
271void wxStyledTextCtrl::InsertText(int pos, const wxString& text)
272{
b796ba39 273 SendMsg(2003, pos, (sptr_t)(const char*)wx2stc(text));
9ce192d4
RD
274}
275
a834585d 276// Delete all text in the document.
8e0945da
VZ
277void wxStyledTextCtrl::ClearAll()
278{
4370573a 279 SendMsg(2004, 0, 0);
9ce192d4
RD
280}
281
9b01abb8
RD
282// Delete a range of text in the document.
283void wxStyledTextCtrl::DeleteRange(int pos, int deleteLength)
284{
285 SendMsg(2645, pos, deleteLength);
286}
287
a834585d 288// Set all style bytes to 0, remove all folding information.
8e0945da
VZ
289void wxStyledTextCtrl::ClearDocumentStyle()
290{
4370573a 291 SendMsg(2005, 0, 0);
9ce192d4
RD
292}
293
9e96e16f 294// Returns the number of bytes in the document.
8e0945da
VZ
295int wxStyledTextCtrl::GetLength() const
296{
4370573a 297 return SendMsg(2006, 0, 0);
9ce192d4
RD
298}
299
a834585d 300// Returns the character byte at the position.
8e0945da 301int wxStyledTextCtrl::GetCharAt(int pos) const {
9e730a78 302 return (unsigned char)SendMsg(2007, pos, 0);
9ce192d4
RD
303}
304
a834585d 305// Returns the position of the caret.
8e0945da
VZ
306int wxStyledTextCtrl::GetCurrentPos() const
307{
4370573a 308 return SendMsg(2008, 0, 0);
9ce192d4
RD
309}
310
a834585d 311// Returns the position of the opposite end of the selection to the caret.
8e0945da
VZ
312int wxStyledTextCtrl::GetAnchor() const
313{
4370573a 314 return SendMsg(2009, 0, 0);
9ce192d4
RD
315}
316
a834585d 317// Returns the style byte at the position.
8e0945da 318int wxStyledTextCtrl::GetStyleAt(int pos) const {
9e730a78 319 return (unsigned char)SendMsg(2010, pos, 0);
9ce192d4
RD
320}
321
a834585d 322// Redoes the next action on the undo history.
8e0945da
VZ
323void wxStyledTextCtrl::Redo()
324{
4370573a 325 SendMsg(2011, 0, 0);
9ce192d4
RD
326}
327
4370573a
RD
328// Choose between collecting actions into the undo
329// history and discarding them.
8e0945da
VZ
330void wxStyledTextCtrl::SetUndoCollection(bool collectUndo)
331{
4370573a 332 SendMsg(2012, collectUndo, 0);
9ce192d4
RD
333}
334
4370573a 335// Select all the text in the document.
8e0945da
VZ
336void wxStyledTextCtrl::SelectAll()
337{
4370573a 338 SendMsg(2013, 0, 0);
9ce192d4
RD
339}
340
4370573a
RD
341// Remember the current position in the undo history as the position
342// at which the document was saved.
8e0945da
VZ
343void wxStyledTextCtrl::SetSavePoint()
344{
4370573a 345 SendMsg(2014, 0, 0);
9ce192d4
RD
346}
347
4370573a 348// Retrieve a buffer of cells.
10ef30eb 349wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) {
9e730a78
RD
350 wxMemoryBuffer buf;
351 if (endPos < startPos) {
352 int temp = startPos;
353 startPos = endPos;
354 endPos = temp;
355 }
356 int len = endPos - startPos;
357 if (!len) return buf;
358 TextRange tr;
359 tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
360 tr.chrg.cpMin = startPos;
361 tr.chrg.cpMax = endPos;
b796ba39 362 len = SendMsg(2015, 0, (sptr_t)&tr);
9e730a78
RD
363 buf.UngetWriteBuf(len);
364 return buf;
9ce192d4
RD
365}
366
a834585d 367// Are there any redoable actions in the undo history?
93578927 368bool wxStyledTextCtrl::CanRedo() const
8e0945da 369{
4370573a 370 return SendMsg(2016, 0, 0) != 0;
9ce192d4
RD
371}
372
a834585d 373// Retrieve the line number at which a particular marker is located.
8e0945da
VZ
374int wxStyledTextCtrl::MarkerLineFromHandle(int handle)
375{
4370573a 376 return SendMsg(2017, handle, 0);
9ce192d4
RD
377}
378
4370573a 379// Delete a marker.
8e0945da
VZ
380void wxStyledTextCtrl::MarkerDeleteHandle(int handle)
381{
4370573a 382 SendMsg(2018, handle, 0);
9ce192d4
RD
383}
384
4370573a 385// Is undo history being collected?
8e0945da
VZ
386bool wxStyledTextCtrl::GetUndoCollection() const
387{
4370573a 388 return SendMsg(2019, 0, 0) != 0;
9ce192d4
RD
389}
390
4370573a
RD
391// Are white space characters currently visible?
392// Returns one of SCWS_* constants.
8e0945da
VZ
393int wxStyledTextCtrl::GetViewWhiteSpace() const
394{
4370573a 395 return SendMsg(2020, 0, 0);
9ce192d4
RD
396}
397
4370573a 398// Make white space characters invisible, always visible or visible outside indentation.
8e0945da
VZ
399void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS)
400{
4370573a 401 SendMsg(2021, viewWS, 0);
9ce192d4
RD
402}
403
4370573a 404// Find the position from a point within the window.
2bfca191 405int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) const {
9e730a78 406 return SendMsg(2022, pt.x, pt.y);
9ce192d4
RD
407}
408
65ec6247
RD
409// Find the position from a point within the window but return
410// INVALID_POSITION if not close to text.
8e0945da
VZ
411int wxStyledTextCtrl::PositionFromPointClose(int x, int y)
412{
65ec6247
RD
413 return SendMsg(2023, x, y);
414}
415
4370573a 416// Set caret to start of a line and ensure it is visible.
8e0945da
VZ
417void wxStyledTextCtrl::GotoLine(int line)
418{
4370573a 419 SendMsg(2024, line, 0);
9ce192d4
RD
420}
421
4370573a 422// Set caret to a position and ensure it is visible.
8e0945da
VZ
423void wxStyledTextCtrl::GotoPos(int pos)
424{
4370573a 425 SendMsg(2025, pos, 0);
9ce192d4
RD
426}
427
4370573a
RD
428// Set the selection anchor to a position. The anchor is the opposite
429// end of the selection from the caret.
8e0945da
VZ
430void wxStyledTextCtrl::SetAnchor(int posAnchor)
431{
4370573a 432 SendMsg(2026, posAnchor, 0);
9ce192d4
RD
433}
434
4370573a
RD
435// Retrieve the text of the line containing the caret.
436// Returns the index of the caret on the line.
437wxString wxStyledTextCtrl::GetCurLine(int* linePos) {
9e730a78
RD
438 int len = LineLength(GetCurrentLine());
439 if (!len) {
440 if (linePos) *linePos = 0;
441 return wxEmptyString;
442 }
10ef30eb 443
9e730a78
RD
444 wxMemoryBuffer mbuf(len+1);
445 char* buf = (char*)mbuf.GetWriteBuf(len+1);
8de28db9 446
b796ba39 447 int pos = SendMsg(2027, len+1, (sptr_t)buf);
9e730a78
RD
448 mbuf.UngetWriteBuf(len);
449 mbuf.AppendByte(0);
450 if (linePos) *linePos = pos;
451 return stc2wx(buf);
9ce192d4
RD
452}
453
4370573a 454// Retrieve the position of the last correctly styled character.
8e0945da
VZ
455int wxStyledTextCtrl::GetEndStyled() const
456{
4370573a 457 return SendMsg(2028, 0, 0);
9ce192d4
RD
458}
459
65ec6247 460// Convert all line endings in the document to one mode.
8e0945da
VZ
461void wxStyledTextCtrl::ConvertEOLs(int eolMode)
462{
65ec6247 463 SendMsg(2029, eolMode, 0);
9ce192d4
RD
464}
465
4370573a 466// Retrieve the current end of line mode - one of CRLF, CR, or LF.
8e0945da
VZ
467int wxStyledTextCtrl::GetEOLMode() const
468{
4370573a 469 return SendMsg(2030, 0, 0);
9ce192d4
RD
470}
471
4370573a 472// Set the current end of line mode.
8e0945da
VZ
473void wxStyledTextCtrl::SetEOLMode(int eolMode)
474{
4370573a 475 SendMsg(2031, eolMode, 0);
9ce192d4
RD
476}
477
4370573a 478// Set the current styling position to pos and the styling mask to mask.
a834585d 479// The styling mask can be used to protect some bits in each styling byte from modification.
8e0945da
VZ
480void wxStyledTextCtrl::StartStyling(int pos, int mask)
481{
4370573a 482 SendMsg(2032, pos, mask);
9ce192d4
RD
483}
484
4370573a
RD
485// Change style from current styling position for length characters to a style
486// and move the current styling position to after this newly styled segment.
8e0945da
VZ
487void wxStyledTextCtrl::SetStyling(int length, int style)
488{
4370573a 489 SendMsg(2033, length, style);
f6bcfd97
BP
490}
491
a834585d 492// Is drawing done first into a buffer or direct to the screen?
8e0945da
VZ
493bool wxStyledTextCtrl::GetBufferedDraw() const
494{
4370573a 495 return SendMsg(2034, 0, 0) != 0;
f6bcfd97
BP
496}
497
4370573a
RD
498// If drawing is buffered then each line of text is drawn into a bitmap buffer
499// before drawing it to the screen to avoid flicker.
8e0945da
VZ
500void wxStyledTextCtrl::SetBufferedDraw(bool buffered)
501{
4370573a 502 SendMsg(2035, buffered, 0);
f6bcfd97
BP
503}
504
a834585d 505// Change the visible size of a tab to be a multiple of the width of a space character.
8e0945da
VZ
506void wxStyledTextCtrl::SetTabWidth(int tabWidth)
507{
4370573a 508 SendMsg(2036, tabWidth, 0);
f6bcfd97
BP
509}
510
4370573a 511// Retrieve the visible size of a tab.
8e0945da
VZ
512int wxStyledTextCtrl::GetTabWidth() const
513{
4370573a 514 return SendMsg(2121, 0, 0);
9ce192d4
RD
515}
516
4370573a 517// Set the code page used to interpret the bytes of the document as characters.
4370573a 518void wxStyledTextCtrl::SetCodePage(int codePage) {
10ef30eb
RD
519#if wxUSE_UNICODE
520 wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
521 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
522#else
523 wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
524 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
525#endif
9e730a78 526 SendMsg(2037, codePage);
9ce192d4
RD
527}
528
4370573a 529// Set the symbol used for a particular marker number,
1a2fb4cd 530// and optionally the fore and background colours.
4370573a 531void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
9e730a78
RD
532 const wxColour& foreground,
533 const wxColour& background) {
9ce192d4 534
9e730a78 535 SendMsg(2040, markerNumber, markerSymbol);
6a06eecf 536 if (foreground.IsOk())
9e730a78 537 MarkerSetForeground(markerNumber, foreground);
6a06eecf 538 if (background.IsOk())
9e730a78 539 MarkerSetBackground(markerNumber, background);
9ce192d4
RD
540}
541
4370573a 542// Set the foreground colour used for a particular marker number.
8e0945da
VZ
543void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore)
544{
4370573a 545 SendMsg(2041, markerNumber, wxColourAsLong(fore));
9ce192d4
RD
546}
547
4370573a 548// Set the background colour used for a particular marker number.
8e0945da
VZ
549void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back)
550{
4370573a 551 SendMsg(2042, markerNumber, wxColourAsLong(back));
9ce192d4
RD
552}
553
9b01abb8 554// Set the background colour used for a particular marker number when its folding block is selected.
54173563 555void wxStyledTextCtrl::MarkerSetBackgroundSelected(int markerNumber, const wxColour& back)
9b01abb8
RD
556{
557 SendMsg(2292, markerNumber, wxColourAsLong(back));
558}
559
560// Enable/disable highlight for current folding bloc (smallest one that contains the caret)
561void wxStyledTextCtrl::MarkerEnableHighlight(bool enabled)
562{
563 SendMsg(2293, enabled, 0);
564}
565
1a2fb4cd 566// Add a marker to a line, returning an ID which can be used to find or delete the marker.
8e0945da
VZ
567int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber)
568{
1a2fb4cd 569 return SendMsg(2043, line, markerNumber);
9ce192d4
RD
570}
571
a834585d 572// Delete a marker from a line.
8e0945da
VZ
573void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber)
574{
4370573a 575 SendMsg(2044, line, markerNumber);
9ce192d4
RD
576}
577
a834585d 578// Delete all markers with a particular number from all lines.
8e0945da
VZ
579void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber)
580{
4370573a 581 SendMsg(2045, markerNumber, 0);
9ce192d4
RD
582}
583
4370573a 584// Get a bit mask of all the markers set on a line.
8e0945da
VZ
585int wxStyledTextCtrl::MarkerGet(int line)
586{
4370573a 587 return SendMsg(2046, line, 0);
9ce192d4
RD
588}
589
9b01abb8
RD
590// Find the next line at or after lineStart that includes a marker in mask.
591// Return -1 when no more lines.
8e0945da
VZ
592int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask)
593{
4370573a 594 return SendMsg(2047, lineStart, markerMask);
9ce192d4
RD
595}
596
4370573a 597// Find the previous line before lineStart that includes a marker in mask.
8e0945da
VZ
598int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask)
599{
4370573a 600 return SendMsg(2048, lineStart, markerMask);
9ce192d4
RD
601}
602
9e730a78
RD
603// Define a marker from a bitmap
604void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp) {
605 // convert bmp to a xpm in a string
606 wxMemoryOutputStream strm;
607 wxImage img = bmp.ConvertToImage();
e45b3f17
RD
608 if (img.HasAlpha())
609 img.ConvertAlphaToMask();
9e730a78
RD
610 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
611 size_t len = strm.GetSize();
612 char* buff = new char[len+1];
613 strm.CopyTo(buff, len);
614 buff[len] = 0;
b796ba39 615 SendMsg(2049, markerNumber, (sptr_t)buff);
9e730a78 616 delete [] buff;
35f8d83d 617
9e730a78
RD
618}
619
1e9bafca 620// Add a set of markers to a line.
8e0945da
VZ
621void wxStyledTextCtrl::MarkerAddSet(int line, int set)
622{
1e9bafca
RD
623 SendMsg(2466, line, set);
624}
625
b8193d80 626// Set the alpha used for a marker that is drawn in the text area, not the margin.
8e0945da
VZ
627void wxStyledTextCtrl::MarkerSetAlpha(int markerNumber, int alpha)
628{
b8193d80
RD
629 SendMsg(2476, markerNumber, alpha);
630}
631
4370573a 632// Set a margin to be either numeric or symbolic.
8e0945da
VZ
633void wxStyledTextCtrl::SetMarginType(int margin, int marginType)
634{
4370573a 635 SendMsg(2240, margin, marginType);
9ce192d4
RD
636}
637
4370573a 638// Retrieve the type of a margin.
8e0945da
VZ
639int wxStyledTextCtrl::GetMarginType(int margin) const
640{
4370573a 641 return SendMsg(2241, margin, 0);
9ce192d4
RD
642}
643
4370573a 644// Set the width of a margin to a width expressed in pixels.
8e0945da
VZ
645void wxStyledTextCtrl::SetMarginWidth(int margin, int pixelWidth)
646{
4370573a 647 SendMsg(2242, margin, pixelWidth);
9ce192d4
RD
648}
649
4370573a 650// Retrieve the width of a margin in pixels.
8e0945da
VZ
651int wxStyledTextCtrl::GetMarginWidth(int margin) const
652{
4370573a 653 return SendMsg(2243, margin, 0);
f6bcfd97
BP
654}
655
4370573a 656// Set a mask that determines which markers are displayed in a margin.
8e0945da
VZ
657void wxStyledTextCtrl::SetMarginMask(int margin, int mask)
658{
4370573a 659 SendMsg(2244, margin, mask);
f6bcfd97
BP
660}
661
4370573a 662// Retrieve the marker mask of a margin.
8e0945da
VZ
663int wxStyledTextCtrl::GetMarginMask(int margin) const
664{
4370573a 665 return SendMsg(2245, margin, 0);
9ce192d4
RD
666}
667
4370573a 668// Make a margin sensitive or insensitive to mouse clicks.
8e0945da
VZ
669void wxStyledTextCtrl::SetMarginSensitive(int margin, bool sensitive)
670{
4370573a 671 SendMsg(2246, margin, sensitive);
9ce192d4
RD
672}
673
4370573a 674// Retrieve the mouse click sensitivity of a margin.
8e0945da
VZ
675bool wxStyledTextCtrl::GetMarginSensitive(int margin) const
676{
4370573a 677 return SendMsg(2247, margin, 0) != 0;
9ce192d4
RD
678}
679
9b01abb8 680// Set the cursor shown when the mouse is inside a margin.
54173563 681void wxStyledTextCtrl::SetMarginCursor(int margin, int cursor)
9b01abb8
RD
682{
683 SendMsg(2248, margin, cursor);
684}
685
686// Retrieve the cursor shown in a margin.
54173563 687int wxStyledTextCtrl::GetMarginCursor(int margin) const
9b01abb8
RD
688{
689 return SendMsg(2249, margin, 0);
690}
691
4370573a 692// Clear all the styles and make equivalent to the global default style.
8e0945da
VZ
693void wxStyledTextCtrl::StyleClearAll()
694{
4370573a 695 SendMsg(2050, 0, 0);
9ce192d4
RD
696}
697
4370573a 698// Set the foreground colour of a style.
8e0945da
VZ
699void wxStyledTextCtrl::StyleSetForeground(int style, const wxColour& fore)
700{
4370573a 701 SendMsg(2051, style, wxColourAsLong(fore));
9ce192d4
RD
702}
703
4370573a 704// Set the background colour of a style.
8e0945da
VZ
705void wxStyledTextCtrl::StyleSetBackground(int style, const wxColour& back)
706{
4370573a 707 SendMsg(2052, style, wxColourAsLong(back));
9ce192d4
RD
708}
709
4370573a 710// Set a style to be bold or not.
8e0945da
VZ
711void wxStyledTextCtrl::StyleSetBold(int style, bool bold)
712{
4370573a 713 SendMsg(2053, style, bold);
9ce192d4
RD
714}
715
4370573a 716// Set a style to be italic or not.
8e0945da
VZ
717void wxStyledTextCtrl::StyleSetItalic(int style, bool italic)
718{
4370573a 719 SendMsg(2054, style, italic);
9ce192d4
RD
720}
721
4370573a 722// Set the size of characters of a style.
8e0945da
VZ
723void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints)
724{
4370573a 725 SendMsg(2055, style, sizePoints);
9ce192d4
RD
726}
727
4370573a 728// Set the font of a style.
8e0945da
VZ
729void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName)
730{
b796ba39 731 SendMsg(2056, style, (sptr_t)(const char*)wx2stc(fontName));
9ce192d4
RD
732}
733
4370573a 734// Set a style to have its end of line filled or not.
8e0945da
VZ
735void wxStyledTextCtrl::StyleSetEOLFilled(int style, bool filled)
736{
4370573a 737 SendMsg(2057, style, filled);
9ce192d4
RD
738}
739
4370573a 740// Reset the default style to its state at startup
8e0945da
VZ
741void wxStyledTextCtrl::StyleResetDefault()
742{
4370573a 743 SendMsg(2058, 0, 0);
9ce192d4
RD
744}
745
4370573a 746// Set a style to be underlined or not.
8e0945da
VZ
747void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline)
748{
4370573a 749 SendMsg(2059, style, underline);
9ce192d4
RD
750}
751
7e0c58e9 752// Get the foreground colour of a style.
8e0945da
VZ
753wxColour wxStyledTextCtrl::StyleGetForeground(int style) const
754{
7e0c58e9
RD
755 long c = SendMsg(2481, style, 0);
756 return wxColourFromLong(c);
757}
758
759// Get the background colour of a style.
8e0945da
VZ
760wxColour wxStyledTextCtrl::StyleGetBackground(int style) const
761{
7e0c58e9
RD
762 long c = SendMsg(2482, style, 0);
763 return wxColourFromLong(c);
764}
765
766// Get is a style bold or not.
8e0945da
VZ
767bool wxStyledTextCtrl::StyleGetBold(int style) const
768{
7e0c58e9
RD
769 return SendMsg(2483, style, 0) != 0;
770}
771
772// Get is a style italic or not.
8e0945da
VZ
773bool wxStyledTextCtrl::StyleGetItalic(int style) const
774{
7e0c58e9
RD
775 return SendMsg(2484, style, 0) != 0;
776}
777
778// Get the size of characters of a style.
8e0945da
VZ
779int wxStyledTextCtrl::StyleGetSize(int style) const
780{
7e0c58e9
RD
781 return SendMsg(2485, style, 0);
782}
783
784// Get the font facename of a style
785wxString wxStyledTextCtrl::StyleGetFaceName(int style) {
786 long msg = 2486;
787 long len = SendMsg(msg, style, 0);
788 wxMemoryBuffer mbuf(len+1);
789 char* buf = (char*)mbuf.GetWriteBuf(len+1);
b796ba39 790 SendMsg(msg, style, (sptr_t)buf);
7e0c58e9
RD
791 mbuf.UngetWriteBuf(len);
792 mbuf.AppendByte(0);
793 return stc2wx(buf);
794}
795
796// Get is a style to have its end of line filled or not.
8e0945da
VZ
797bool wxStyledTextCtrl::StyleGetEOLFilled(int style) const
798{
7e0c58e9
RD
799 return SendMsg(2487, style, 0) != 0;
800}
801
802// Get is a style underlined or not.
8e0945da
VZ
803bool wxStyledTextCtrl::StyleGetUnderline(int style) const
804{
7e0c58e9
RD
805 return SendMsg(2488, style, 0) != 0;
806}
807
808// Get is a style mixed case, or to force upper or lower case.
8e0945da
VZ
809int wxStyledTextCtrl::StyleGetCase(int style) const
810{
7e0c58e9
RD
811 return SendMsg(2489, style, 0);
812}
813
814// Get the character set of the font in a style.
8e0945da
VZ
815int wxStyledTextCtrl::StyleGetCharacterSet(int style) const
816{
7e0c58e9
RD
817 return SendMsg(2490, style, 0);
818}
819
820// Get is a style visible or not.
8e0945da
VZ
821bool wxStyledTextCtrl::StyleGetVisible(int style) const
822{
7e0c58e9
RD
823 return SendMsg(2491, style, 0) != 0;
824}
825
826// Get is a style changeable or not (read only).
827// Experimental feature, currently buggy.
8e0945da
VZ
828bool wxStyledTextCtrl::StyleGetChangeable(int style) const
829{
7e0c58e9
RD
830 return SendMsg(2492, style, 0) != 0;
831}
832
833// Get is a style a hotspot or not.
8e0945da
VZ
834bool wxStyledTextCtrl::StyleGetHotSpot(int style) const
835{
7e0c58e9
RD
836 return SendMsg(2493, style, 0) != 0;
837}
838
65ec6247 839// Set a style to be mixed case, or to force upper or lower case.
8e0945da
VZ
840void wxStyledTextCtrl::StyleSetCase(int style, int caseForce)
841{
65ec6247
RD
842 SendMsg(2060, style, caseForce);
843}
844
9b01abb8
RD
845// Set the size of characters of a style. Size is in points multiplied by 100.
846void wxStyledTextCtrl::StyleSetSizeFractional(int style, int caseForce)
847{
848 SendMsg(2061, style, caseForce);
849}
850
851// Get the size of characters of a style in points multiplied by 100
852int wxStyledTextCtrl::StyleGetSizeFractional(int style) const
853{
854 return SendMsg(2062, style, 0);
855}
856
857// Set the weight of characters of a style.
858void wxStyledTextCtrl::StyleSetWeight(int style, int weight)
859{
860 SendMsg(2063, style, weight);
861}
862
863// Get the weight of characters of a style.
864int wxStyledTextCtrl::StyleGetWeight(int style) const
865{
866 return SendMsg(2064, style, 0);
867}
868
9e730a78 869// Set a style to be a hotspot or not.
8e0945da
VZ
870void wxStyledTextCtrl::StyleSetHotSpot(int style, bool hotspot)
871{
9e730a78
RD
872 SendMsg(2409, style, hotspot);
873}
874
9e96e16f 875// Set the foreground colour of the main and additional selections and whether to use this setting.
8e0945da
VZ
876void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore)
877{
4370573a 878 SendMsg(2067, useSetting, wxColourAsLong(fore));
9ce192d4
RD
879}
880
9e96e16f 881// Set the background colour of the main and additional selections and whether to use this setting.
8e0945da
VZ
882void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back)
883{
4370573a 884 SendMsg(2068, useSetting, wxColourAsLong(back));
9ce192d4
RD
885}
886
b8193d80 887// Get the alpha of the selection.
8e0945da
VZ
888int wxStyledTextCtrl::GetSelAlpha() const
889{
b8193d80
RD
890 return SendMsg(2477, 0, 0);
891}
892
893// Set the alpha of the selection.
8e0945da
VZ
894void wxStyledTextCtrl::SetSelAlpha(int alpha)
895{
b8193d80
RD
896 SendMsg(2478, alpha, 0);
897}
898
7e0c58e9 899// Is the selection end of line filled?
8e0945da
VZ
900bool wxStyledTextCtrl::GetSelEOLFilled() const
901{
7e0c58e9
RD
902 return SendMsg(2479, 0, 0) != 0;
903}
904
905// Set the selection to have its end of line filled or not.
8e0945da
VZ
906void wxStyledTextCtrl::SetSelEOLFilled(bool filled)
907{
7e0c58e9
RD
908 SendMsg(2480, filled, 0);
909}
910
4370573a 911// Set the foreground colour of the caret.
8e0945da
VZ
912void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore)
913{
4370573a 914 SendMsg(2069, wxColourAsLong(fore), 0);
9ce192d4
RD
915}
916
4370573a
RD
917// When key+modifier combination km is pressed perform msg.
918void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) {
9e730a78 919 SendMsg(2070, MAKELONG(key, modifiers), cmd);
9ce192d4
RD
920}
921
8e54aaed 922// When key+modifier combination km is pressed do nothing.
4370573a 923void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) {
9e730a78 924 SendMsg(2071, MAKELONG(key, modifiers));
9ce192d4
RD
925}
926
4370573a 927// Drop all key mappings.
8e0945da
VZ
928void wxStyledTextCtrl::CmdKeyClearAll()
929{
4370573a
RD
930 SendMsg(2072, 0, 0);
931}
9ce192d4 932
4370573a
RD
933// Set the styles for a segment of the document.
934void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) {
b796ba39 935 SendMsg(2073, length, (sptr_t)styleBytes);
9ce192d4
RD
936}
937
4370573a 938// Set a style to be visible or not.
8e0945da
VZ
939void wxStyledTextCtrl::StyleSetVisible(int style, bool visible)
940{
4370573a
RD
941 SendMsg(2074, style, visible);
942}
9ce192d4 943
4370573a 944// Get the time in milliseconds that the caret is on and off.
8e0945da
VZ
945int wxStyledTextCtrl::GetCaretPeriod() const
946{
4370573a 947 return SendMsg(2075, 0, 0);
9ce192d4
RD
948}
949
4370573a 950// Get the time in milliseconds that the caret is on and off. 0 = steady on.
8e0945da
VZ
951void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds)
952{
4370573a
RD
953 SendMsg(2076, periodMilliseconds, 0);
954}
9ce192d4 955
a834585d 956// Set the set of characters making up words for when moving or selecting by word.
9e96e16f 957// First sets defaults like SetCharsDefault.
8e0945da
VZ
958void wxStyledTextCtrl::SetWordChars(const wxString& characters)
959{
b796ba39 960 SendMsg(2077, 0, (sptr_t)(const char*)wx2stc(characters));
9ce192d4
RD
961}
962
9b01abb8
RD
963// Get the set of characters making up words for when moving or selecting by word.
964wxString wxStyledTextCtrl::GetWordChars() const {
965 int msg = 2646;
c4bdd822 966 int len = SendMsg(msg, 0, (sptr_t)NULL);
9b01abb8
RD
967 if (!len) return wxEmptyString;
968
969 wxMemoryBuffer mbuf(len+1);
970 char* buf = (char*)mbuf.GetWriteBuf(len+1);
54173563 971 SendMsg(msg, 0, (sptr_t)buf);
9b01abb8
RD
972 mbuf.UngetWriteBuf(len);
973 mbuf.AppendByte(0);
974 return stc2wx(buf);
975}
976
4370573a
RD
977// Start a sequence of actions that is undone and redone as a unit.
978// May be nested.
8e0945da
VZ
979void wxStyledTextCtrl::BeginUndoAction()
980{
4370573a
RD
981 SendMsg(2078, 0, 0);
982}
9ce192d4 983
4370573a 984// End a sequence of actions that is undone and redone as a unit.
8e0945da
VZ
985void wxStyledTextCtrl::EndUndoAction()
986{
4370573a
RD
987 SendMsg(2079, 0, 0);
988}
9ce192d4 989
4370573a 990// Set an indicator to plain, squiggle or TT.
8e0945da
VZ
991void wxStyledTextCtrl::IndicatorSetStyle(int indic, int style)
992{
4370573a
RD
993 SendMsg(2080, indic, style);
994}
9ce192d4 995
4370573a 996// Retrieve the style of an indicator.
8e0945da
VZ
997int wxStyledTextCtrl::IndicatorGetStyle(int indic) const
998{
4370573a
RD
999 return SendMsg(2081, indic, 0);
1000}
9ce192d4 1001
4370573a 1002// Set the foreground colour of an indicator.
8e0945da
VZ
1003void wxStyledTextCtrl::IndicatorSetForeground(int indic, const wxColour& fore)
1004{
4370573a 1005 SendMsg(2082, indic, wxColourAsLong(fore));
9ce192d4
RD
1006}
1007
4370573a 1008// Retrieve the foreground colour of an indicator.
8e0945da
VZ
1009wxColour wxStyledTextCtrl::IndicatorGetForeground(int indic) const
1010{
4370573a
RD
1011 long c = SendMsg(2083, indic, 0);
1012 return wxColourFromLong(c);
1013}
9ce192d4 1014
7e0c58e9 1015// Set an indicator to draw under text or over(default).
8e0945da
VZ
1016void wxStyledTextCtrl::IndicatorSetUnder(int indic, bool under)
1017{
7e0c58e9
RD
1018 SendMsg(2510, indic, under);
1019}
1020
1021// Retrieve whether indicator drawn under or over text.
8e0945da
VZ
1022bool wxStyledTextCtrl::IndicatorGetUnder(int indic) const
1023{
7e0c58e9
RD
1024 return SendMsg(2511, indic, 0) != 0;
1025}
1026
f114b858 1027// Set the foreground colour of all whitespace and whether to use this setting.
8e0945da
VZ
1028void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting, const wxColour& fore)
1029{
f114b858
RD
1030 SendMsg(2084, useSetting, wxColourAsLong(fore));
1031}
1032
1033// Set the background colour of all whitespace and whether to use this setting.
8e0945da
VZ
1034void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting, const wxColour& back)
1035{
f114b858
RD
1036 SendMsg(2085, useSetting, wxColourAsLong(back));
1037}
1038
9e96e16f
RD
1039// Set the size of the dots used to mark space characters.
1040void wxStyledTextCtrl::SetWhitespaceSize(int size)
1041{
1042 SendMsg(2086, size, 0);
1043}
1044
1045// Get the size of the dots used to mark space characters.
1046int wxStyledTextCtrl::GetWhitespaceSize() const
1047{
1048 return SendMsg(2087, 0, 0);
1049}
1050
a834585d
RD
1051// Divide each styling byte into lexical class bits (default: 5) and indicator
1052// bits (default: 3). If a lexer requires more than 32 lexical states, then this
4370573a 1053// is used to expand the possible states.
8e0945da
VZ
1054void wxStyledTextCtrl::SetStyleBits(int bits)
1055{
4370573a 1056 SendMsg(2090, bits, 0);
9ce192d4
RD
1057}
1058
4370573a 1059// Retrieve number of bits in style bytes used to hold the lexical state.
8e0945da
VZ
1060int wxStyledTextCtrl::GetStyleBits() const
1061{
4370573a
RD
1062 return SendMsg(2091, 0, 0);
1063}
9ce192d4 1064
4370573a 1065// Used to hold extra styling information for each line.
8e0945da
VZ
1066void wxStyledTextCtrl::SetLineState(int line, int state)
1067{
4370573a 1068 SendMsg(2092, line, state);
f6bcfd97
BP
1069}
1070
4370573a 1071// Retrieve the extra styling information for a line.
8e0945da
VZ
1072int wxStyledTextCtrl::GetLineState(int line) const
1073{
4370573a
RD
1074 return SendMsg(2093, line, 0);
1075}
f6bcfd97 1076
4370573a 1077// Retrieve the last line number that has line state.
8e0945da
VZ
1078int wxStyledTextCtrl::GetMaxLineState() const
1079{
4370573a 1080 return SendMsg(2094, 0, 0);
f6bcfd97
BP
1081}
1082
65ec6247 1083// Is the background of the line containing the caret in a different colour?
8e0945da
VZ
1084bool wxStyledTextCtrl::GetCaretLineVisible() const
1085{
65ec6247
RD
1086 return SendMsg(2095, 0, 0) != 0;
1087}
1088
a834585d 1089// Display the background of the line containing the caret in a different colour.
8e0945da
VZ
1090void wxStyledTextCtrl::SetCaretLineVisible(bool show)
1091{
65ec6247
RD
1092 SendMsg(2096, show, 0);
1093}
1094
1095// Get the colour of the background of the line containing the caret.
8e0945da
VZ
1096wxColour wxStyledTextCtrl::GetCaretLineBackground() const
1097{
65ec6247
RD
1098 long c = SendMsg(2097, 0, 0);
1099 return wxColourFromLong(c);
1100}
1101
1102// Set the colour of the background of the line containing the caret.
8e0945da
VZ
1103void wxStyledTextCtrl::SetCaretLineBackground(const wxColour& back)
1104{
65ec6247
RD
1105 SendMsg(2098, wxColourAsLong(back), 0);
1106}
1107
1a2fb4cd
RD
1108// Set a style to be changeable or not (read only).
1109// Experimental feature, currently buggy.
8e0945da
VZ
1110void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable)
1111{
1a2fb4cd
RD
1112 SendMsg(2099, style, changeable);
1113}
1114
4370573a
RD
1115// Display a auto-completion list.
1116// The lenEntered parameter indicates how many characters before
1117// the caret should be used to provide context.
8e0945da
VZ
1118void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList)
1119{
b796ba39 1120 SendMsg(2100, lenEntered, (sptr_t)(const char*)wx2stc(itemList));
4370573a 1121}
f6bcfd97 1122
4370573a 1123// Remove the auto-completion list from the screen.
8e0945da
VZ
1124void wxStyledTextCtrl::AutoCompCancel()
1125{
4370573a 1126 SendMsg(2101, 0, 0);
f6bcfd97
BP
1127}
1128
4370573a 1129// Is there an auto-completion list visible?
8e0945da
VZ
1130bool wxStyledTextCtrl::AutoCompActive()
1131{
4370573a
RD
1132 return SendMsg(2102, 0, 0) != 0;
1133}
f6bcfd97 1134
a834585d 1135// Retrieve the position of the caret when the auto-completion list was displayed.
8e0945da
VZ
1136int wxStyledTextCtrl::AutoCompPosStart()
1137{
4370573a 1138 return SendMsg(2103, 0, 0);
f6bcfd97
BP
1139}
1140
4370573a 1141// User has selected an item so remove the list and insert the selection.
8e0945da
VZ
1142void wxStyledTextCtrl::AutoCompComplete()
1143{
4370573a
RD
1144 SendMsg(2104, 0, 0);
1145}
f6bcfd97 1146
4370573a 1147// Define a set of character that when typed cancel the auto-completion list.
8e0945da
VZ
1148void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet)
1149{
b796ba39 1150 SendMsg(2105, 0, (sptr_t)(const char*)wx2stc(characterSet));
f6bcfd97
BP
1151}
1152
a834585d
RD
1153// Change the separator character in the string setting up an auto-completion list.
1154// Default is space but can be changed if items contain space.
8e0945da
VZ
1155void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter)
1156{
4370573a
RD
1157 SendMsg(2106, separatorCharacter, 0);
1158}
f6bcfd97 1159
4370573a 1160// Retrieve the auto-completion list separator character.
8e0945da
VZ
1161int wxStyledTextCtrl::AutoCompGetSeparator() const
1162{
4370573a 1163 return SendMsg(2107, 0, 0);
9ce192d4
RD
1164}
1165
4370573a 1166// Select the item in the auto-completion list that starts with a string.
8e0945da
VZ
1167void wxStyledTextCtrl::AutoCompSelect(const wxString& text)
1168{
b796ba39 1169 SendMsg(2108, 0, (sptr_t)(const char*)wx2stc(text));
4370573a 1170}
9ce192d4 1171
4370573a
RD
1172// Should the auto-completion list be cancelled if the user backspaces to a
1173// position before where the box was created.
8e0945da
VZ
1174void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel)
1175{
4370573a 1176 SendMsg(2110, cancel, 0);
f6bcfd97
BP
1177}
1178
4370573a 1179// Retrieve whether auto-completion cancelled by backspacing before start.
8e0945da
VZ
1180bool wxStyledTextCtrl::AutoCompGetCancelAtStart() const
1181{
4370573a
RD
1182 return SendMsg(2111, 0, 0) != 0;
1183}
f6bcfd97 1184
1a2fb4cd
RD
1185// Define a set of characters that when typed will cause the autocompletion to
1186// choose the selected item.
8e0945da
VZ
1187void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet)
1188{
b796ba39 1189 SendMsg(2112, 0, (sptr_t)(const char*)wx2stc(characterSet));
4370573a 1190}
9ce192d4 1191
4370573a 1192// Should a single item auto-completion list automatically choose the item.
8e0945da
VZ
1193void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle)
1194{
4370573a
RD
1195 SendMsg(2113, chooseSingle, 0);
1196}
9ce192d4 1197
4370573a 1198// Retrieve whether a single item auto-completion list automatically choose the item.
8e0945da
VZ
1199bool wxStyledTextCtrl::AutoCompGetChooseSingle() const
1200{
4370573a 1201 return SendMsg(2114, 0, 0) != 0;
9ce192d4
RD
1202}
1203
4370573a 1204// Set whether case is significant when performing auto-completion searches.
8e0945da
VZ
1205void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase)
1206{
4370573a
RD
1207 SendMsg(2115, ignoreCase, 0);
1208}
9ce192d4 1209
4370573a 1210// Retrieve state of ignore case flag.
8e0945da
VZ
1211bool wxStyledTextCtrl::AutoCompGetIgnoreCase() const
1212{
4370573a 1213 return SendMsg(2116, 0, 0) != 0;
9ce192d4
RD
1214}
1215
65ec6247 1216// Display a list of strings and send notification when user chooses one.
8e0945da
VZ
1217void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList)
1218{
b796ba39 1219 SendMsg(2117, listType, (sptr_t)(const char*)wx2stc(itemList));
65ec6247
RD
1220}
1221
a834585d 1222// Set whether or not autocompletion is hidden automatically when nothing matches.
8e0945da
VZ
1223void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide)
1224{
65ec6247
RD
1225 SendMsg(2118, autoHide, 0);
1226}
1227
a834585d 1228// Retrieve whether or not autocompletion is hidden automatically when nothing matches.
8e0945da
VZ
1229bool wxStyledTextCtrl::AutoCompGetAutoHide() const
1230{
65ec6247
RD
1231 return SendMsg(2119, 0, 0) != 0;
1232}
1233
a834585d
RD
1234// Set whether or not autocompletion deletes any word characters
1235// after the inserted text upon completion.
8e0945da
VZ
1236void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord)
1237{
1a2fb4cd
RD
1238 SendMsg(2270, dropRestOfWord, 0);
1239}
1240
a834585d
RD
1241// Retrieve whether or not autocompletion deletes any word characters
1242// after the inserted text upon completion.
8e0945da
VZ
1243bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() const
1244{
1a2fb4cd
RD
1245 return SendMsg(2271, 0, 0) != 0;
1246}
1247
9e730a78
RD
1248// Register an image for use in autocompletion lists.
1249void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) {
1250 // convert bmp to a xpm in a string
1251 wxMemoryOutputStream strm;
1252 wxImage img = bmp.ConvertToImage();
e45b3f17
RD
1253 if (img.HasAlpha())
1254 img.ConvertAlphaToMask();
9e730a78
RD
1255 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
1256 size_t len = strm.GetSize();
1257 char* buff = new char[len+1];
1258 strm.CopyTo(buff, len);
1259 buff[len] = 0;
b796ba39 1260 SendMsg(2405, type, (sptr_t)buff);
9e730a78 1261 delete [] buff;
35f8d83d 1262
9e730a78
RD
1263}
1264
1265// Clear all the registered images.
8e0945da
VZ
1266void wxStyledTextCtrl::ClearRegisteredImages()
1267{
9e730a78
RD
1268 SendMsg(2408, 0, 0);
1269}
1270
1271// Retrieve the auto-completion list type-separator character.
8e0945da
VZ
1272int wxStyledTextCtrl::AutoCompGetTypeSeparator() const
1273{
9e730a78
RD
1274 return SendMsg(2285, 0, 0);
1275}
1276
1277// Change the type-separator character in the string setting up an auto-completion list.
1278// Default is '?' but can be changed if items contain '?'.
8e0945da
VZ
1279void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter)
1280{
9e730a78
RD
1281 SendMsg(2286, separatorCharacter, 0);
1282}
1283
1e9bafca
RD
1284// Set the maximum width, in characters, of auto-completion and user lists.
1285// Set to 0 to autosize to fit longest item, which is the default.
8e0945da
VZ
1286void wxStyledTextCtrl::AutoCompSetMaxWidth(int characterCount)
1287{
1e9bafca
RD
1288 SendMsg(2208, characterCount, 0);
1289}
1290
1291// Get the maximum width, in characters, of auto-completion and user lists.
8e0945da
VZ
1292int wxStyledTextCtrl::AutoCompGetMaxWidth() const
1293{
1e9bafca
RD
1294 return SendMsg(2209, 0, 0);
1295}
1296
1297// Set the maximum height, in rows, of auto-completion and user lists.
1298// The default is 5 rows.
8e0945da
VZ
1299void wxStyledTextCtrl::AutoCompSetMaxHeight(int rowCount)
1300{
1e9bafca
RD
1301 SendMsg(2210, rowCount, 0);
1302}
1303
1304// Set the maximum height, in rows, of auto-completion and user lists.
8e0945da
VZ
1305int wxStyledTextCtrl::AutoCompGetMaxHeight() const
1306{
1e9bafca
RD
1307 return SendMsg(2211, 0, 0);
1308}
1309
4370573a 1310// Set the number of spaces used for one level of indentation.
8e0945da
VZ
1311void wxStyledTextCtrl::SetIndent(int indentSize)
1312{
4370573a
RD
1313 SendMsg(2122, indentSize, 0);
1314}
9ce192d4 1315
4370573a 1316// Retrieve indentation size.
8e0945da
VZ
1317int wxStyledTextCtrl::GetIndent() const
1318{
4370573a 1319 return SendMsg(2123, 0, 0);
9ce192d4
RD
1320}
1321
4370573a
RD
1322// Indentation will only use space characters if useTabs is false, otherwise
1323// it will use a combination of tabs and spaces.
8e0945da
VZ
1324void wxStyledTextCtrl::SetUseTabs(bool useTabs)
1325{
4370573a
RD
1326 SendMsg(2124, useTabs, 0);
1327}
9ce192d4 1328
4370573a 1329// Retrieve whether tabs will be used in indentation.
8e0945da
VZ
1330bool wxStyledTextCtrl::GetUseTabs() const
1331{
4370573a
RD
1332 return SendMsg(2125, 0, 0) != 0;
1333}
9ce192d4 1334
4370573a 1335// Change the indentation of a line to a number of columns.
8e0945da
VZ
1336void wxStyledTextCtrl::SetLineIndentation(int line, int indentSize)
1337{
4370573a
RD
1338 SendMsg(2126, line, indentSize);
1339}
9ce192d4 1340
4370573a 1341// Retrieve the number of columns that a line is indented.
8e0945da
VZ
1342int wxStyledTextCtrl::GetLineIndentation(int line) const
1343{
4370573a 1344 return SendMsg(2127, line, 0);
9ce192d4
RD
1345}
1346
4370573a 1347// Retrieve the position before the first non indentation character on a line.
8e0945da
VZ
1348int wxStyledTextCtrl::GetLineIndentPosition(int line) const
1349{
4370573a
RD
1350 return SendMsg(2128, line, 0);
1351}
9ce192d4 1352
4370573a 1353// Retrieve the column number of a position, taking tab width into account.
8e0945da
VZ
1354int wxStyledTextCtrl::GetColumn(int pos) const
1355{
4370573a 1356 return SendMsg(2129, pos, 0);
9ce192d4
RD
1357}
1358
9b01abb8
RD
1359// Count characters between two positions.
1360int wxStyledTextCtrl::CountCharacters(int startPos, int endPos)
1361{
1362 return SendMsg(2633, startPos, endPos);
1363}
1364
4370573a 1365// Show or hide the horizontal scroll bar.
8e0945da
VZ
1366void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show)
1367{
4370573a
RD
1368 SendMsg(2130, show, 0);
1369}
9ce192d4 1370
4370573a 1371// Is the horizontal scroll bar visible?
8e0945da
VZ
1372bool wxStyledTextCtrl::GetUseHorizontalScrollBar() const
1373{
4370573a 1374 return SendMsg(2131, 0, 0) != 0;
9ce192d4
RD
1375}
1376
4370573a 1377// Show or hide indentation guides.
8e0945da
VZ
1378void wxStyledTextCtrl::SetIndentationGuides(int indentView)
1379{
7e0c58e9 1380 SendMsg(2132, indentView, 0);
4370573a 1381}
9ce192d4 1382
4370573a 1383// Are the indentation guides visible?
8e0945da
VZ
1384int wxStyledTextCtrl::GetIndentationGuides() const
1385{
7e0c58e9 1386 return SendMsg(2133, 0, 0);
9ce192d4
RD
1387}
1388
4370573a
RD
1389// Set the highlighted indentation guide column.
1390// 0 = no highlighted guide.
8e0945da
VZ
1391void wxStyledTextCtrl::SetHighlightGuide(int column)
1392{
4370573a
RD
1393 SendMsg(2134, column, 0);
1394}
9ce192d4 1395
4370573a 1396// Get the highlighted indentation guide column.
8e0945da
VZ
1397int wxStyledTextCtrl::GetHighlightGuide() const
1398{
4370573a 1399 return SendMsg(2135, 0, 0);
9ce192d4
RD
1400}
1401
4370573a 1402// Get the position after the last visible characters on a line.
8e0945da
VZ
1403int wxStyledTextCtrl::GetLineEndPosition(int line) const
1404{
4370573a
RD
1405 return SendMsg(2136, line, 0);
1406}
9ce192d4 1407
4370573a 1408// Get the code page used to interpret the bytes of the document as characters.
8e0945da
VZ
1409int wxStyledTextCtrl::GetCodePage() const
1410{
4370573a 1411 return SendMsg(2137, 0, 0);
9ce192d4
RD
1412}
1413
4370573a 1414// Get the foreground colour of the caret.
8e0945da
VZ
1415wxColour wxStyledTextCtrl::GetCaretForeground() const
1416{
4370573a
RD
1417 long c = SendMsg(2138, 0, 0);
1418 return wxColourFromLong(c);
1419}
9ce192d4 1420
4370573a 1421// In read-only mode?
8e0945da
VZ
1422bool wxStyledTextCtrl::GetReadOnly() const
1423{
4370573a 1424 return SendMsg(2140, 0, 0) != 0;
9ce192d4
RD
1425}
1426
4370573a 1427// Sets the position of the caret.
8e0945da
VZ
1428void wxStyledTextCtrl::SetCurrentPos(int pos)
1429{
4370573a
RD
1430 SendMsg(2141, pos, 0);
1431}
9ce192d4 1432
4370573a 1433// Sets the position that starts the selection - this becomes the anchor.
8e0945da
VZ
1434void wxStyledTextCtrl::SetSelectionStart(int pos)
1435{
4370573a 1436 SendMsg(2142, pos, 0);
9ce192d4
RD
1437}
1438
4370573a 1439// Returns the position at the start of the selection.
8e0945da
VZ
1440int wxStyledTextCtrl::GetSelectionStart() const
1441{
4370573a
RD
1442 return SendMsg(2143, 0, 0);
1443}
9ce192d4 1444
4370573a 1445// Sets the position that ends the selection - this becomes the currentPosition.
8e0945da
VZ
1446void wxStyledTextCtrl::SetSelectionEnd(int pos)
1447{
4370573a 1448 SendMsg(2144, pos, 0);
9ce192d4
RD
1449}
1450
4370573a 1451// Returns the position at the end of the selection.
8e0945da
VZ
1452int wxStyledTextCtrl::GetSelectionEnd() const
1453{
4370573a
RD
1454 return SendMsg(2145, 0, 0);
1455}
9ce192d4 1456
9b01abb8
RD
1457// Set caret to a position, while removing any existing selection.
1458void wxStyledTextCtrl::SetEmptySelection(int pos)
1459{
1460 SendMsg(2556, pos, 0);
1461}
1462
4370573a 1463// Sets the print magnification added to the point size of each style for printing.
8e0945da
VZ
1464void wxStyledTextCtrl::SetPrintMagnification(int magnification)
1465{
4370573a 1466 SendMsg(2146, magnification, 0);
9ce192d4
RD
1467}
1468
4370573a 1469// Returns the print magnification.
8e0945da
VZ
1470int wxStyledTextCtrl::GetPrintMagnification() const
1471{
4370573a
RD
1472 return SendMsg(2147, 0, 0);
1473}
9ce192d4 1474
4370573a 1475// Modify colours when printing for clearer printed text.
8e0945da
VZ
1476void wxStyledTextCtrl::SetPrintColourMode(int mode)
1477{
4370573a 1478 SendMsg(2148, mode, 0);
9ce192d4
RD
1479}
1480
4370573a 1481// Returns the print colour mode.
8e0945da
VZ
1482int wxStyledTextCtrl::GetPrintColourMode() const
1483{
4370573a
RD
1484 return SendMsg(2149, 0, 0);
1485}
9ce192d4 1486
4370573a
RD
1487// Find some text in the document.
1488int wxStyledTextCtrl::FindText(int minPos, int maxPos,
9e730a78
RD
1489 const wxString& text,
1490 int flags) {
1491 TextToFind ft;
1492 ft.chrg.cpMin = minPos;
1493 ft.chrg.cpMax = maxPos;
2ed48ef8 1494 const wxWX2MBbuf buf = wx2stc(text);
9e730a78 1495 ft.lpstrText = (char*)(const char*)buf;
4370573a 1496
b796ba39 1497 return SendMsg(2150, flags, (sptr_t)&ft);
4370573a
RD
1498}
1499
a834585d 1500// On Windows, will draw the document into a display context such as a printer.
a5b274d7
WS
1501 int wxStyledTextCtrl::FormatRange(bool doDraw,
1502 int startPos,
1503 int endPos,
1504 wxDC* draw,
a5c2ccf2 1505 wxDC* target,
a5b274d7
WS
1506 wxRect renderRect,
1507 wxRect pageRect) {
1508 RangeToFormat fr;
1509
1510 if (endPos < startPos) {
1511 int temp = startPos;
1512 startPos = endPos;
1513 endPos = temp;
1514 }
1515 fr.hdc = draw;
1516 fr.hdcTarget = target;
1517 fr.rc.top = renderRect.GetTop();
1518 fr.rc.left = renderRect.GetLeft();
1519 fr.rc.right = renderRect.GetRight();
1520 fr.rc.bottom = renderRect.GetBottom();
1521 fr.rcPage.top = pageRect.GetTop();
1522 fr.rcPage.left = pageRect.GetLeft();
1523 fr.rcPage.right = pageRect.GetRight();
1524 fr.rcPage.bottom = pageRect.GetBottom();
1525 fr.chrg.cpMin = startPos;
1526 fr.chrg.cpMax = endPos;
1527
b796ba39 1528 return SendMsg(2151, doDraw, (sptr_t)&fr);
9e730a78
RD
1529}
1530
1531// Retrieve the display line at the top of the display.
8e0945da
VZ
1532int wxStyledTextCtrl::GetFirstVisibleLine() const
1533{
4370573a 1534 return SendMsg(2152, 0, 0);
9ce192d4
RD
1535}
1536
4370573a 1537// Retrieve the contents of a line.
2bfca191 1538wxString wxStyledTextCtrl::GetLine(int line) const {
9e730a78
RD
1539 int len = LineLength(line);
1540 if (!len) return wxEmptyString;
9ce192d4 1541
9e730a78
RD
1542 wxMemoryBuffer mbuf(len+1);
1543 char* buf = (char*)mbuf.GetWriteBuf(len+1);
b796ba39 1544 SendMsg(2153, line, (sptr_t)buf);
9e730a78
RD
1545 mbuf.UngetWriteBuf(len);
1546 mbuf.AppendByte(0);
1547 return stc2wx(buf);
4370573a
RD
1548}
1549
1550// Returns the number of lines in the document. There is always at least one.
8e0945da
VZ
1551int wxStyledTextCtrl::GetLineCount() const
1552{
4370573a
RD
1553 return SendMsg(2154, 0, 0);
1554}
9ce192d4 1555
4370573a 1556// Sets the size in pixels of the left margin.
8e0945da
VZ
1557void wxStyledTextCtrl::SetMarginLeft(int pixelWidth)
1558{
65ec6247 1559 SendMsg(2155, 0, pixelWidth);
4370573a 1560}
9ce192d4 1561
4370573a 1562// Returns the size in pixels of the left margin.
8e0945da
VZ
1563int wxStyledTextCtrl::GetMarginLeft() const
1564{
4370573a 1565 return SendMsg(2156, 0, 0);
9ce192d4
RD
1566}
1567
4370573a 1568// Sets the size in pixels of the right margin.
8e0945da
VZ
1569void wxStyledTextCtrl::SetMarginRight(int pixelWidth)
1570{
65ec6247 1571 SendMsg(2157, 0, pixelWidth);
4370573a 1572}
9ce192d4 1573
4370573a 1574// Returns the size in pixels of the right margin.
8e0945da
VZ
1575int wxStyledTextCtrl::GetMarginRight() const
1576{
4370573a 1577 return SendMsg(2158, 0, 0);
9ce192d4
RD
1578}
1579
4370573a 1580// Is the document different from when it was last saved?
8e0945da
VZ
1581bool wxStyledTextCtrl::GetModify() const
1582{
4370573a
RD
1583 return SendMsg(2159, 0, 0) != 0;
1584}
9ce192d4 1585
4370573a
RD
1586// Retrieve the selected text.
1587wxString wxStyledTextCtrl::GetSelectedText() {
6094165c 1588 const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0);
9e730a78 1589 if (!len) return wxEmptyString;
9ce192d4 1590
3d7a4fe8 1591 wxMemoryBuffer mbuf(len+2);
9e730a78 1592 char* buf = (char*)mbuf.GetWriteBuf(len+1);
b796ba39 1593 SendMsg(2161, 0, (sptr_t)buf);
9e730a78
RD
1594 mbuf.UngetWriteBuf(len);
1595 mbuf.AppendByte(0);
1596 return stc2wx(buf);
4370573a 1597}
9ce192d4 1598
4370573a
RD
1599// Retrieve a range of text.
1600wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) {
9e730a78
RD
1601 if (endPos < startPos) {
1602 int temp = startPos;
1603 startPos = endPos;
1604 endPos = temp;
1605 }
1606 int len = endPos - startPos;
1607 if (!len) return wxEmptyString;
1608 wxMemoryBuffer mbuf(len+1);
1609 char* buf = (char*)mbuf.GetWriteBuf(len);
1610 TextRange tr;
1611 tr.lpstrText = buf;
1612 tr.chrg.cpMin = startPos;
1613 tr.chrg.cpMax = endPos;
b796ba39 1614 SendMsg(2162, 0, (sptr_t)&tr);
9e730a78
RD
1615 mbuf.UngetWriteBuf(len);
1616 mbuf.AppendByte(0);
1617 return stc2wx(buf);
9ce192d4
RD
1618}
1619
4370573a 1620// Draw the selection in normal style or with selection highlighted.
8e0945da
VZ
1621void wxStyledTextCtrl::HideSelection(bool normal)
1622{
4370573a
RD
1623 SendMsg(2163, normal, 0);
1624}
9ce192d4 1625
4370573a 1626// Retrieve the line containing a position.
2bfca191 1627int wxStyledTextCtrl::LineFromPosition(int pos) const
8e0945da 1628{
4370573a 1629 return SendMsg(2166, pos, 0);
9ce192d4
RD
1630}
1631
4370573a 1632// Retrieve the position at the start of a line.
2bfca191 1633int wxStyledTextCtrl::PositionFromLine(int line) const
8e0945da 1634{
4370573a
RD
1635 return SendMsg(2167, line, 0);
1636}
9ce192d4 1637
4370573a 1638// Scroll horizontally and vertically.
8e0945da
VZ
1639void wxStyledTextCtrl::LineScroll(int columns, int lines)
1640{
4370573a 1641 SendMsg(2168, columns, lines);
9ce192d4
RD
1642}
1643
4370573a 1644// Ensure the caret is visible.
8e0945da
VZ
1645void wxStyledTextCtrl::EnsureCaretVisible()
1646{
4370573a
RD
1647 SendMsg(2169, 0, 0);
1648}
9ce192d4 1649
4370573a 1650// Replace the selected text with the argument text.
8e0945da
VZ
1651void wxStyledTextCtrl::ReplaceSelection(const wxString& text)
1652{
b796ba39 1653 SendMsg(2170, 0, (sptr_t)(const char*)wx2stc(text));
9ce192d4
RD
1654}
1655
4370573a 1656// Set to read only or read write.
8e0945da
VZ
1657void wxStyledTextCtrl::SetReadOnly(bool readOnly)
1658{
4370573a
RD
1659 SendMsg(2171, readOnly, 0);
1660}
9ce192d4 1661
4370573a 1662// Will a paste succeed?
7d6d76d0 1663bool wxStyledTextCtrl::CanPaste() const
8e0945da 1664{
4370573a 1665 return SendMsg(2173, 0, 0) != 0;
9ce192d4
RD
1666}
1667
a834585d 1668// Are there any undoable actions in the undo history?
93578927 1669bool wxStyledTextCtrl::CanUndo() const
8e0945da 1670{
4370573a
RD
1671 return SendMsg(2174, 0, 0) != 0;
1672}
9ce192d4 1673
4370573a 1674// Delete the undo history.
8e0945da
VZ
1675void wxStyledTextCtrl::EmptyUndoBuffer()
1676{
4370573a 1677 SendMsg(2175, 0, 0);
9ce192d4
RD
1678}
1679
4370573a 1680// Undo one action in the undo history.
8e0945da
VZ
1681void wxStyledTextCtrl::Undo()
1682{
4370573a
RD
1683 SendMsg(2176, 0, 0);
1684}
9ce192d4 1685
4370573a 1686// Cut the selection to the clipboard.
8e0945da
VZ
1687void wxStyledTextCtrl::Cut()
1688{
4370573a 1689 SendMsg(2177, 0, 0);
f6bcfd97
BP
1690}
1691
4370573a 1692// Copy the selection to the clipboard.
8e0945da
VZ
1693void wxStyledTextCtrl::Copy()
1694{
4370573a
RD
1695 SendMsg(2178, 0, 0);
1696}
f6bcfd97 1697
4370573a 1698// Paste the contents of the clipboard into the document replacing the selection.
8e0945da
VZ
1699void wxStyledTextCtrl::Paste()
1700{
4370573a 1701 SendMsg(2179, 0, 0);
f6bcfd97
BP
1702}
1703
4370573a 1704// Clear the selection.
8e0945da
VZ
1705void wxStyledTextCtrl::Clear()
1706{
4370573a
RD
1707 SendMsg(2180, 0, 0);
1708}
f6bcfd97 1709
4370573a 1710// Replace the contents of the document with the argument text.
8e0945da
VZ
1711void wxStyledTextCtrl::SetText(const wxString& text)
1712{
b796ba39 1713 SendMsg(2181, 0, (sptr_t)(const char*)wx2stc(text));
f6bcfd97
BP
1714}
1715
4370573a 1716// Retrieve all the text in the document.
93578927 1717wxString wxStyledTextCtrl::GetText() const {
9e730a78
RD
1718 int len = GetTextLength();
1719 wxMemoryBuffer mbuf(len+1); // leave room for the null...
1720 char* buf = (char*)mbuf.GetWriteBuf(len+1);
b796ba39 1721 SendMsg(2182, len+1, (sptr_t)buf);
9e730a78
RD
1722 mbuf.UngetWriteBuf(len);
1723 mbuf.AppendByte(0);
1724 return stc2wx(buf);
4370573a 1725}
9ce192d4 1726
4370573a 1727// Retrieve the number of characters in the document.
8e0945da
VZ
1728int wxStyledTextCtrl::GetTextLength() const
1729{
4370573a 1730 return SendMsg(2183, 0, 0);
9ce192d4
RD
1731}
1732
a834585d 1733// Set to overtype (true) or insert mode.
8e0945da
VZ
1734void wxStyledTextCtrl::SetOvertype(bool overtype)
1735{
4370573a
RD
1736 SendMsg(2186, overtype, 0);
1737}
9ce192d4 1738
4370573a 1739// Returns true if overtype mode is active otherwise false is returned.
8e0945da
VZ
1740bool wxStyledTextCtrl::GetOvertype() const
1741{
4370573a 1742 return SendMsg(2187, 0, 0) != 0;
9ce192d4
RD
1743}
1744
a834585d 1745// Set the width of the insert mode caret.
8e0945da
VZ
1746void wxStyledTextCtrl::SetCaretWidth(int pixelWidth)
1747{
65ec6247
RD
1748 SendMsg(2188, pixelWidth, 0);
1749}
1750
a834585d 1751// Returns the width of the insert mode caret.
8e0945da
VZ
1752int wxStyledTextCtrl::GetCaretWidth() const
1753{
65ec6247
RD
1754 return SendMsg(2189, 0, 0);
1755}
1756
1757// Sets the position that starts the target which is used for updating the
1758// document without affecting the scroll position.
8e0945da
VZ
1759void wxStyledTextCtrl::SetTargetStart(int pos)
1760{
65ec6247
RD
1761 SendMsg(2190, pos, 0);
1762}
1763
1764// Get the position that starts the target.
8e0945da
VZ
1765int wxStyledTextCtrl::GetTargetStart() const
1766{
65ec6247
RD
1767 return SendMsg(2191, 0, 0);
1768}
1769
1770// Sets the position that ends the target which is used for updating the
1771// document without affecting the scroll position.
8e0945da
VZ
1772void wxStyledTextCtrl::SetTargetEnd(int pos)
1773{
65ec6247
RD
1774 SendMsg(2192, pos, 0);
1775}
1776
1777// Get the position that ends the target.
8e0945da
VZ
1778int wxStyledTextCtrl::GetTargetEnd() const
1779{
65ec6247
RD
1780 return SendMsg(2193, 0, 0);
1781}
1782
1783// Replace the target text with the argument text.
8e54aaed 1784// Text is counted so it can contain NULs.
65ec6247
RD
1785// Returns the length of the replacement text.
1786
9e730a78 1787 int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
2ed48ef8 1788 const wxWX2MBbuf buf = wx2stc(text);
d7b46878 1789 return SendMsg(2194, wx2stclen(text, buf), (sptr_t)(const char*)buf);
65ec6247
RD
1790}
1791
1792// Replace the target text with the argument text after \d processing.
8e54aaed 1793// Text is counted so it can contain NULs.
65ec6247
RD
1794// Looks for \d where d is between 1 and 9 and replaces these with the strings
1795// matched in the last search operation which were surrounded by \( and \).
1796// Returns the length of the replacement text including any change
1797// caused by processing the \d patterns.
1798
9e730a78 1799 int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
2ed48ef8 1800 const wxWX2MBbuf buf = wx2stc(text);
d7b46878 1801 return SendMsg(2195, wx2stclen(text, buf), (sptr_t)(const char*)buf);
65ec6247
RD
1802}
1803
1804// Search for a counted string in the target and set the target to the found
8e54aaed 1805// range. Text is counted so it can contain NULs.
65ec6247
RD
1806// Returns length of range or -1 for failure in which case target is not moved.
1807
9e730a78 1808 int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
2ed48ef8 1809 const wxWX2MBbuf buf = wx2stc(text);
d7b46878 1810 return SendMsg(2197, wx2stclen(text, buf), (sptr_t)(const char*)buf);
65ec6247
RD
1811}
1812
a834585d 1813// Set the search flags used by SearchInTarget.
8e0945da
VZ
1814void wxStyledTextCtrl::SetSearchFlags(int flags)
1815{
65ec6247
RD
1816 SendMsg(2198, flags, 0);
1817}
1818
a834585d 1819// Get the search flags used by SearchInTarget.
8e0945da
VZ
1820int wxStyledTextCtrl::GetSearchFlags() const
1821{
65ec6247
RD
1822 return SendMsg(2199, 0, 0);
1823}
1824
4370573a 1825// Show a call tip containing a definition near position pos.
8e0945da
VZ
1826void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition)
1827{
b796ba39 1828 SendMsg(2200, pos, (sptr_t)(const char*)wx2stc(definition));
4370573a 1829}
9ce192d4 1830
4370573a 1831// Remove the call tip from the screen.
8e0945da
VZ
1832void wxStyledTextCtrl::CallTipCancel()
1833{
4370573a 1834 SendMsg(2201, 0, 0);
9ce192d4
RD
1835}
1836
4370573a 1837// Is there an active call tip?
8e0945da
VZ
1838bool wxStyledTextCtrl::CallTipActive()
1839{
4370573a
RD
1840 return SendMsg(2202, 0, 0) != 0;
1841}
9ce192d4 1842
4370573a 1843// Retrieve the position where the caret was before displaying the call tip.
8e0945da
VZ
1844int wxStyledTextCtrl::CallTipPosAtStart()
1845{
4370573a 1846 return SendMsg(2203, 0, 0);
9ce192d4
RD
1847}
1848
4370573a 1849// Highlight a segment of the definition.
8e0945da
VZ
1850void wxStyledTextCtrl::CallTipSetHighlight(int start, int end)
1851{
4370573a 1852 SendMsg(2204, start, end);
9ce192d4
RD
1853}
1854
4370573a 1855// Set the background colour for the call tip.
8e0945da
VZ
1856void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back)
1857{
4370573a
RD
1858 SendMsg(2205, wxColourAsLong(back), 0);
1859}
9ce192d4 1860
9e730a78 1861// Set the foreground colour for the call tip.
8e0945da
VZ
1862void wxStyledTextCtrl::CallTipSetForeground(const wxColour& fore)
1863{
9e730a78
RD
1864 SendMsg(2206, wxColourAsLong(fore), 0);
1865}
1866
1867// Set the foreground colour for the highlighted part of the call tip.
8e0945da
VZ
1868void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour& fore)
1869{
9e730a78
RD
1870 SendMsg(2207, wxColourAsLong(fore), 0);
1871}
1872
b8193d80 1873// Enable use of STYLE_CALLTIP and set call tip tab size in pixels.
8e0945da
VZ
1874void wxStyledTextCtrl::CallTipUseStyle(int tabSize)
1875{
b8193d80
RD
1876 SendMsg(2212, tabSize, 0);
1877}
1878
9b01abb8
RD
1879// Set position of calltip, above or below text.
1880void wxStyledTextCtrl::CallTipSetPosition(bool above)
1881{
1882 SendMsg(2213, above, 0);
1883}
1884
4370573a 1885// Find the display line of a document line taking hidden lines into account.
8e0945da
VZ
1886int wxStyledTextCtrl::VisibleFromDocLine(int line)
1887{
4370573a 1888 return SendMsg(2220, line, 0);
9ce192d4
RD
1889}
1890
4370573a 1891// Find the document line of a display line taking hidden lines into account.
8e0945da
VZ
1892int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay)
1893{
4370573a
RD
1894 return SendMsg(2221, lineDisplay, 0);
1895}
9ce192d4 1896
1e9bafca 1897// The number of display lines needed to wrap a document line
8e0945da
VZ
1898int wxStyledTextCtrl::WrapCount(int line)
1899{
1e9bafca
RD
1900 return SendMsg(2235, line, 0);
1901}
1902
4370573a
RD
1903// Set the fold level of a line.
1904// This encodes an integer level along with flags indicating whether the
1905// line is a header and whether it is effectively white space.
8e0945da
VZ
1906void wxStyledTextCtrl::SetFoldLevel(int line, int level)
1907{
4370573a
RD
1908 SendMsg(2222, line, level);
1909}
9ce192d4 1910
4370573a 1911// Retrieve the fold level of a line.
8e0945da
VZ
1912int wxStyledTextCtrl::GetFoldLevel(int line) const
1913{
4370573a
RD
1914 return SendMsg(2223, line, 0);
1915}
d134f170 1916
4370573a 1917// Find the last child line of a header line.
8e0945da
VZ
1918int wxStyledTextCtrl::GetLastChild(int line, int level) const
1919{
4370573a 1920 return SendMsg(2224, line, level);
9ce192d4
RD
1921}
1922
4370573a 1923// Find the parent line of a child line.
8e0945da
VZ
1924int wxStyledTextCtrl::GetFoldParent(int line) const
1925{
4370573a
RD
1926 return SendMsg(2225, line, 0);
1927}
9ce192d4 1928
4370573a 1929// Make a range of lines visible.
8e0945da
VZ
1930void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd)
1931{
4370573a 1932 SendMsg(2226, lineStart, lineEnd);
9ce192d4
RD
1933}
1934
4370573a 1935// Make a range of lines invisible.
8e0945da
VZ
1936void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd)
1937{
4370573a
RD
1938 SendMsg(2227, lineStart, lineEnd);
1939}
9ce192d4 1940
4370573a 1941// Is a line visible?
8e0945da
VZ
1942bool wxStyledTextCtrl::GetLineVisible(int line) const
1943{
4370573a 1944 return SendMsg(2228, line, 0) != 0;
9ce192d4
RD
1945}
1946
9b01abb8
RD
1947// Are all lines visible?
1948bool wxStyledTextCtrl::GetAllLinesVisible() const
1949{
1950 return SendMsg(2236, 0, 0) != 0;
1951}
1952
4370573a 1953// Show the children of a header line.
8e0945da
VZ
1954void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded)
1955{
4370573a
RD
1956 SendMsg(2229, line, expanded);
1957}
9ce192d4 1958
4370573a 1959// Is a header line expanded?
8e0945da
VZ
1960bool wxStyledTextCtrl::GetFoldExpanded(int line) const
1961{
4370573a 1962 return SendMsg(2230, line, 0) != 0;
9ce192d4
RD
1963}
1964
4370573a 1965// Switch a header line between expanded and contracted.
8e0945da
VZ
1966void wxStyledTextCtrl::ToggleFold(int line)
1967{
4370573a
RD
1968 SendMsg(2231, line, 0);
1969}
9ce192d4 1970
4370573a 1971// Ensure a particular line is visible by expanding any header line hiding it.
8e0945da
VZ
1972void wxStyledTextCtrl::EnsureVisible(int line)
1973{
4370573a
RD
1974 SendMsg(2232, line, 0);
1975}
9ce192d4 1976
9e730a78 1977// Set some style options for folding.
8e0945da
VZ
1978void wxStyledTextCtrl::SetFoldFlags(int flags)
1979{
4370573a 1980 SendMsg(2233, flags, 0);
9ce192d4
RD
1981}
1982
65ec6247
RD
1983// Ensure a particular line is visible by expanding any header line hiding it.
1984// Use the currently set visibility policy to determine which range to display.
8e0945da
VZ
1985void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line)
1986{
65ec6247
RD
1987 SendMsg(2234, line, 0);
1988}
1989
a834585d 1990// Sets whether a tab pressed when caret is within indentation indents.
8e0945da
VZ
1991void wxStyledTextCtrl::SetTabIndents(bool tabIndents)
1992{
65ec6247
RD
1993 SendMsg(2260, tabIndents, 0);
1994}
1995
1996// Does a tab pressed when caret is within indentation indent?
8e0945da
VZ
1997bool wxStyledTextCtrl::GetTabIndents() const
1998{
65ec6247
RD
1999 return SendMsg(2261, 0, 0) != 0;
2000}
2001
a834585d 2002// Sets whether a backspace pressed when caret is within indentation unindents.
8e0945da
VZ
2003void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents)
2004{
65ec6247
RD
2005 SendMsg(2262, bsUnIndents, 0);
2006}
2007
2008// Does a backspace pressed when caret is within indentation unindent?
8e0945da
VZ
2009bool wxStyledTextCtrl::GetBackSpaceUnIndents() const
2010{
65ec6247
RD
2011 return SendMsg(2263, 0, 0) != 0;
2012}
2013
a834585d 2014// Sets the time the mouse must sit still to generate a mouse dwell event.
8e0945da
VZ
2015void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds)
2016{
65ec6247
RD
2017 SendMsg(2264, periodMilliseconds, 0);
2018}
2019
a834585d 2020// Retrieve the time the mouse must sit still to generate a mouse dwell event.
8e0945da
VZ
2021int wxStyledTextCtrl::GetMouseDwellTime() const
2022{
65ec6247
RD
2023 return SendMsg(2265, 0, 0);
2024}
2025
a834585d 2026// Get position of start of word.
8e0945da
VZ
2027int wxStyledTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters)
2028{
1a2fb4cd
RD
2029 return SendMsg(2266, pos, onlyWordCharacters);
2030}
2031
a834585d 2032// Get position of end of word.
8e0945da
VZ
2033int wxStyledTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters)
2034{
1a2fb4cd
RD
2035 return SendMsg(2267, pos, onlyWordCharacters);
2036}
2037
a834585d 2038// Sets whether text is word wrapped.
8e0945da
VZ
2039void wxStyledTextCtrl::SetWrapMode(int mode)
2040{
1a2fb4cd
RD
2041 SendMsg(2268, mode, 0);
2042}
2043
a834585d 2044// Retrieve whether text is word wrapped.
8e0945da
VZ
2045int wxStyledTextCtrl::GetWrapMode() const
2046{
1a2fb4cd
RD
2047 return SendMsg(2269, 0, 0);
2048}
2049
591d01be 2050// Set the display mode of visual flags for wrapped lines.
8e0945da
VZ
2051void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags)
2052{
591d01be
RD
2053 SendMsg(2460, wrapVisualFlags, 0);
2054}
2055
4ce59b1f 2056// Retrive the display mode of visual flags for wrapped lines.
8e0945da
VZ
2057int wxStyledTextCtrl::GetWrapVisualFlags() const
2058{
591d01be
RD
2059 return SendMsg(2461, 0, 0);
2060}
2061
2062// Set the location of visual flags for wrapped lines.
8e0945da
VZ
2063void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation)
2064{
591d01be
RD
2065 SendMsg(2462, wrapVisualFlagsLocation, 0);
2066}
2067
4ce59b1f 2068// Retrive the location of visual flags for wrapped lines.
8e0945da
VZ
2069int wxStyledTextCtrl::GetWrapVisualFlagsLocation() const
2070{
591d01be
RD
2071 return SendMsg(2463, 0, 0);
2072}
2073
2074// Set the start indent for wrapped lines.
8e0945da
VZ
2075void wxStyledTextCtrl::SetWrapStartIndent(int indent)
2076{
591d01be
RD
2077 SendMsg(2464, indent, 0);
2078}
2079
4ce59b1f 2080// Retrive the start indent for wrapped lines.
8e0945da
VZ
2081int wxStyledTextCtrl::GetWrapStartIndent() const
2082{
591d01be
RD
2083 return SendMsg(2465, 0, 0);
2084}
2085
9e96e16f
RD
2086// Sets how wrapped sublines are placed. Default is fixed.
2087void wxStyledTextCtrl::SetWrapIndentMode(int mode)
2088{
2089 SendMsg(2472, mode, 0);
2090}
2091
2092// Retrieve how wrapped sublines are placed. Default is fixed.
2093int wxStyledTextCtrl::GetWrapIndentMode() const
2094{
2095 return SendMsg(2473, 0, 0);
2096}
2097
a834585d 2098// Sets the degree of caching of layout information.
8e0945da
VZ
2099void wxStyledTextCtrl::SetLayoutCache(int mode)
2100{
1a2fb4cd
RD
2101 SendMsg(2272, mode, 0);
2102}
2103
a834585d 2104// Retrieve the degree of caching of layout information.
8e0945da
VZ
2105int wxStyledTextCtrl::GetLayoutCache() const
2106{
1a2fb4cd
RD
2107 return SendMsg(2273, 0, 0);
2108}
2109
a834585d 2110// Sets the document width assumed for scrolling.
8e0945da
VZ
2111void wxStyledTextCtrl::SetScrollWidth(int pixelWidth)
2112{
a834585d
RD
2113 SendMsg(2274, pixelWidth, 0);
2114}
2115
2116// Retrieve the document width assumed for scrolling.
8e0945da
VZ
2117int wxStyledTextCtrl::GetScrollWidth() const
2118{
a834585d
RD
2119 return SendMsg(2275, 0, 0);
2120}
2121
7e0c58e9 2122// Sets whether the maximum width line displayed is used to set scroll width.
8e0945da
VZ
2123void wxStyledTextCtrl::SetScrollWidthTracking(bool tracking)
2124{
7e0c58e9
RD
2125 SendMsg(2516, tracking, 0);
2126}
2127
2128// Retrieve whether the scroll width tracks wide lines.
8e0945da
VZ
2129bool wxStyledTextCtrl::GetScrollWidthTracking() const
2130{
7e0c58e9
RD
2131 return SendMsg(2517, 0, 0) != 0;
2132}
2133
a834585d 2134// Measure the pixel width of some text in a particular style.
8e54aaed 2135// NUL terminated text argument.
a834585d 2136// Does not handle tab or control characters.
8e0945da
VZ
2137int wxStyledTextCtrl::TextWidth(int style, const wxString& text)
2138{
b796ba39 2139 return SendMsg(2276, style, (sptr_t)(const char*)wx2stc(text));
a834585d
RD
2140}
2141
2142// Sets the scroll range so that maximum scroll position has
2143// the last line at the bottom of the view (default).
2144// Setting this to false allows scrolling one page below the last line.
8e0945da
VZ
2145void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine)
2146{
a834585d
RD
2147 SendMsg(2277, endAtLastLine, 0);
2148}
2149
2150// Retrieve whether the maximum scroll position has the last
2151// line at the bottom of the view.
8e0945da
VZ
2152bool wxStyledTextCtrl::GetEndAtLastLine() const
2153{
1e9bafca 2154 return SendMsg(2278, 0, 0) != 0;
a834585d
RD
2155}
2156
2157// Retrieve the height of a particular line of text in pixels.
8e0945da
VZ
2158int wxStyledTextCtrl::TextHeight(int line)
2159{
a834585d
RD
2160 return SendMsg(2279, line, 0);
2161}
2162
9e730a78 2163// Show or hide the vertical scroll bar.
8e0945da
VZ
2164void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show)
2165{
9e730a78
RD
2166 SendMsg(2280, show, 0);
2167}
2168
2169// Is the vertical scroll bar visible?
8e0945da
VZ
2170bool wxStyledTextCtrl::GetUseVerticalScrollBar() const
2171{
9e730a78
RD
2172 return SendMsg(2281, 0, 0) != 0;
2173}
2174
2175// Append a string to the end of the document without changing the selection.
41a499cd 2176void wxStyledTextCtrl::AppendText(const wxString& text) {
2ed48ef8 2177 const wxWX2MBbuf buf = wx2stc(text);
d7b46878 2178 SendMsg(2282, wx2stclen(text, buf), (sptr_t)(const char*)buf);
9e730a78
RD
2179}
2180
2181// Is drawing done in two phases with backgrounds drawn before foregrounds?
8e0945da
VZ
2182bool wxStyledTextCtrl::GetTwoPhaseDraw() const
2183{
9e730a78
RD
2184 return SendMsg(2283, 0, 0) != 0;
2185}
2186
2187// In twoPhaseDraw mode, drawing is performed in two phases, first the background
2188// and then the foreground. This avoids chopping off characters that overlap the next run.
8e0945da
VZ
2189void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase)
2190{
9e730a78
RD
2191 SendMsg(2284, twoPhase, 0);
2192}
2193
9e96e16f
RD
2194// Scroll so that a display line is at the top of the display.
2195void wxStyledTextCtrl::SetFirstVisibleLine(int lineDisplay)
2196{
2197 SendMsg(2613, lineDisplay, 0);
2198}
2199
9b01abb8
RD
2200// Change the effect of pasting when there are multiple selections.
2201void wxStyledTextCtrl::SetMultiPaste(int multiPaste)
2202{
2203 SendMsg(2614, multiPaste, 0);
2204}
2205
2206// Retrieve the effect of pasting when there are multiple selections..
2207int wxStyledTextCtrl::GetMultiPaste() const
2208{
2209 return SendMsg(2615, 0, 0);
2210}
2211
2212// Retrieve the value of a tag from a regular expression search.
2213wxString wxStyledTextCtrl::GetTag(int tagNumber) const {
2214 int msg = 2616;
c4bdd822 2215 int len = SendMsg(msg, tagNumber, (sptr_t)NULL);
9b01abb8
RD
2216 if (!len) return wxEmptyString;
2217
2218 wxMemoryBuffer mbuf(len+1);
2219 char* buf = (char*)mbuf.GetWriteBuf(len+1);
2220 SendMsg(msg, tagNumber, (sptr_t)buf);
2221 mbuf.UngetWriteBuf(len);
2222 mbuf.AppendByte(0);
2223 return stc2wx(buf);
2224}
2225
9e730a78 2226// Make the target range start and end be the same as the selection range start and end.
8e0945da
VZ
2227void wxStyledTextCtrl::TargetFromSelection()
2228{
9e730a78
RD
2229 SendMsg(2287, 0, 0);
2230}
2231
2232// Join the lines in the target.
8e0945da
VZ
2233void wxStyledTextCtrl::LinesJoin()
2234{
9e730a78
RD
2235 SendMsg(2288, 0, 0);
2236}
2237
2238// Split the lines in the target into lines that are less wide than pixelWidth
2239// where possible.
8e0945da
VZ
2240void wxStyledTextCtrl::LinesSplit(int pixelWidth)
2241{
9e730a78
RD
2242 SendMsg(2289, pixelWidth, 0);
2243}
2244
2245// Set the colours used as a chequerboard pattern in the fold margin
8e0945da
VZ
2246void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting, const wxColour& back)
2247{
9e730a78
RD
2248 SendMsg(2290, useSetting, wxColourAsLong(back));
2249}
8e0945da
VZ
2250void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting, const wxColour& fore)
2251{
9e730a78
RD
2252 SendMsg(2291, useSetting, wxColourAsLong(fore));
2253}
2254
c26dba42 2255// Move caret down one line.
8e0945da
VZ
2256void wxStyledTextCtrl::LineDown()
2257{
c26dba42
RD
2258 SendMsg(2300, 0, 0);
2259}
2260
2261// Move caret down one line extending selection to new caret position.
8e0945da
VZ
2262void wxStyledTextCtrl::LineDownExtend()
2263{
c26dba42
RD
2264 SendMsg(2301, 0, 0);
2265}
2266
2267// Move caret up one line.
8e0945da
VZ
2268void wxStyledTextCtrl::LineUp()
2269{
c26dba42
RD
2270 SendMsg(2302, 0, 0);
2271}
2272
2273// Move caret up one line extending selection to new caret position.
8e0945da
VZ
2274void wxStyledTextCtrl::LineUpExtend()
2275{
c26dba42
RD
2276 SendMsg(2303, 0, 0);
2277}
2278
2279// Move caret left one character.
8e0945da
VZ
2280void wxStyledTextCtrl::CharLeft()
2281{
c26dba42
RD
2282 SendMsg(2304, 0, 0);
2283}
2284
2285// Move caret left one character extending selection to new caret position.
8e0945da
VZ
2286void wxStyledTextCtrl::CharLeftExtend()
2287{
c26dba42
RD
2288 SendMsg(2305, 0, 0);
2289}
2290
2291// Move caret right one character.
8e0945da
VZ
2292void wxStyledTextCtrl::CharRight()
2293{
c26dba42
RD
2294 SendMsg(2306, 0, 0);
2295}
2296
2297// Move caret right one character extending selection to new caret position.
8e0945da
VZ
2298void wxStyledTextCtrl::CharRightExtend()
2299{
c26dba42
RD
2300 SendMsg(2307, 0, 0);
2301}
2302
2303// Move caret left one word.
8e0945da
VZ
2304void wxStyledTextCtrl::WordLeft()
2305{
c26dba42
RD
2306 SendMsg(2308, 0, 0);
2307}
2308
2309// Move caret left one word extending selection to new caret position.
8e0945da
VZ
2310void wxStyledTextCtrl::WordLeftExtend()
2311{
c26dba42
RD
2312 SendMsg(2309, 0, 0);
2313}
2314
2315// Move caret right one word.
8e0945da
VZ
2316void wxStyledTextCtrl::WordRight()
2317{
c26dba42
RD
2318 SendMsg(2310, 0, 0);
2319}
2320
2321// Move caret right one word extending selection to new caret position.
8e0945da
VZ
2322void wxStyledTextCtrl::WordRightExtend()
2323{
c26dba42
RD
2324 SendMsg(2311, 0, 0);
2325}
2326
2327// Move caret to first position on line.
8e0945da
VZ
2328void wxStyledTextCtrl::Home()
2329{
c26dba42
RD
2330 SendMsg(2312, 0, 0);
2331}
2332
2333// Move caret to first position on line extending selection to new caret position.
8e0945da
VZ
2334void wxStyledTextCtrl::HomeExtend()
2335{
c26dba42
RD
2336 SendMsg(2313, 0, 0);
2337}
2338
2339// Move caret to last position on line.
8e0945da
VZ
2340void wxStyledTextCtrl::LineEnd()
2341{
c26dba42
RD
2342 SendMsg(2314, 0, 0);
2343}
2344
2345// Move caret to last position on line extending selection to new caret position.
8e0945da
VZ
2346void wxStyledTextCtrl::LineEndExtend()
2347{
c26dba42
RD
2348 SendMsg(2315, 0, 0);
2349}
2350
2351// Move caret to first position in document.
8e0945da
VZ
2352void wxStyledTextCtrl::DocumentStart()
2353{
c26dba42
RD
2354 SendMsg(2316, 0, 0);
2355}
2356
2357// Move caret to first position in document extending selection to new caret position.
8e0945da
VZ
2358void wxStyledTextCtrl::DocumentStartExtend()
2359{
c26dba42
RD
2360 SendMsg(2317, 0, 0);
2361}
2362
2363// Move caret to last position in document.
8e0945da
VZ
2364void wxStyledTextCtrl::DocumentEnd()
2365{
c26dba42
RD
2366 SendMsg(2318, 0, 0);
2367}
2368
2369// Move caret to last position in document extending selection to new caret position.
8e0945da
VZ
2370void wxStyledTextCtrl::DocumentEndExtend()
2371{
c26dba42
RD
2372 SendMsg(2319, 0, 0);
2373}
2374
2375// Move caret one page up.
8e0945da
VZ
2376void wxStyledTextCtrl::PageUp()
2377{
c26dba42
RD
2378 SendMsg(2320, 0, 0);
2379}
2380
2381// Move caret one page up extending selection to new caret position.
8e0945da
VZ
2382void wxStyledTextCtrl::PageUpExtend()
2383{
c26dba42
RD
2384 SendMsg(2321, 0, 0);
2385}
2386
2387// Move caret one page down.
8e0945da
VZ
2388void wxStyledTextCtrl::PageDown()
2389{
c26dba42
RD
2390 SendMsg(2322, 0, 0);
2391}
2392
2393// Move caret one page down extending selection to new caret position.
8e0945da
VZ
2394void wxStyledTextCtrl::PageDownExtend()
2395{
c26dba42
RD
2396 SendMsg(2323, 0, 0);
2397}
2398
2399// Switch from insert to overtype mode or the reverse.
8e0945da
VZ
2400void wxStyledTextCtrl::EditToggleOvertype()
2401{
c26dba42
RD
2402 SendMsg(2324, 0, 0);
2403}
2404
2405// Cancel any modes such as call tip or auto-completion list display.
8e0945da
VZ
2406void wxStyledTextCtrl::Cancel()
2407{
c26dba42
RD
2408 SendMsg(2325, 0, 0);
2409}
2410
2411// Delete the selection or if no selection, the character before the caret.
8e0945da
VZ
2412void wxStyledTextCtrl::DeleteBack()
2413{
c26dba42
RD
2414 SendMsg(2326, 0, 0);
2415}
2416
2417// If selection is empty or all on one line replace the selection with a tab character.
2418// If more than one line selected, indent the lines.
8e0945da
VZ
2419void wxStyledTextCtrl::Tab()
2420{
c26dba42
RD
2421 SendMsg(2327, 0, 0);
2422}
2423
2424// Dedent the selected lines.
8e0945da
VZ
2425void wxStyledTextCtrl::BackTab()
2426{
c26dba42
RD
2427 SendMsg(2328, 0, 0);
2428}
2429
2430// Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
8e0945da
VZ
2431void wxStyledTextCtrl::NewLine()
2432{
c26dba42
RD
2433 SendMsg(2329, 0, 0);
2434}
2435
2436// Insert a Form Feed character.
8e0945da
VZ
2437void wxStyledTextCtrl::FormFeed()
2438{
c26dba42
RD
2439 SendMsg(2330, 0, 0);
2440}
2441
2442// Move caret to before first visible character on line.
2443// If already there move to first character on line.
8e0945da
VZ
2444void wxStyledTextCtrl::VCHome()
2445{
c26dba42
RD
2446 SendMsg(2331, 0, 0);
2447}
2448
2449// Like VCHome but extending selection to new caret position.
8e0945da
VZ
2450void wxStyledTextCtrl::VCHomeExtend()
2451{
c26dba42
RD
2452 SendMsg(2332, 0, 0);
2453}
2454
2455// Magnify the displayed text by increasing the sizes by 1 point.
8e0945da
VZ
2456void wxStyledTextCtrl::ZoomIn()
2457{
c26dba42
RD
2458 SendMsg(2333, 0, 0);
2459}
2460
2461// Make the displayed text smaller by decreasing the sizes by 1 point.
8e0945da
VZ
2462void wxStyledTextCtrl::ZoomOut()
2463{
c26dba42
RD
2464 SendMsg(2334, 0, 0);
2465}
2466
2467// Delete the word to the left of the caret.
8e0945da
VZ
2468void wxStyledTextCtrl::DelWordLeft()
2469{
c26dba42
RD
2470 SendMsg(2335, 0, 0);
2471}
2472
2473// Delete the word to the right of the caret.
8e0945da
VZ
2474void wxStyledTextCtrl::DelWordRight()
2475{
c26dba42
RD
2476 SendMsg(2336, 0, 0);
2477}
2478
7e0c58e9 2479// Delete the word to the right of the caret, but not the trailing non-word characters.
8e0945da
VZ
2480void wxStyledTextCtrl::DelWordRightEnd()
2481{
7e0c58e9
RD
2482 SendMsg(2518, 0, 0);
2483}
2484
c26dba42 2485// Cut the line containing the caret.
8e0945da
VZ
2486void wxStyledTextCtrl::LineCut()
2487{
c26dba42
RD
2488 SendMsg(2337, 0, 0);
2489}
2490
2491// Delete the line containing the caret.
8e0945da
VZ
2492void wxStyledTextCtrl::LineDelete()
2493{
c26dba42
RD
2494 SendMsg(2338, 0, 0);
2495}
2496
2497// Switch the current line with the previous.
8e0945da
VZ
2498void wxStyledTextCtrl::LineTranspose()
2499{
c26dba42
RD
2500 SendMsg(2339, 0, 0);
2501}
2502
9e730a78 2503// Duplicate the current line.
8e0945da
VZ
2504void wxStyledTextCtrl::LineDuplicate()
2505{
9e730a78
RD
2506 SendMsg(2404, 0, 0);
2507}
2508
c26dba42 2509// Transform the selection to lower case.
8e0945da
VZ
2510void wxStyledTextCtrl::LowerCase()
2511{
c26dba42
RD
2512 SendMsg(2340, 0, 0);
2513}
2514
2515// Transform the selection to upper case.
8e0945da
VZ
2516void wxStyledTextCtrl::UpperCase()
2517{
c26dba42
RD
2518 SendMsg(2341, 0, 0);
2519}
2520
2521// Scroll the document down, keeping the caret visible.
8e0945da
VZ
2522void wxStyledTextCtrl::LineScrollDown()
2523{
c26dba42
RD
2524 SendMsg(2342, 0, 0);
2525}
2526
2527// Scroll the document up, keeping the caret visible.
8e0945da
VZ
2528void wxStyledTextCtrl::LineScrollUp()
2529{
c26dba42
RD
2530 SendMsg(2343, 0, 0);
2531}
2532
2533// Delete the selection or if no selection, the character before the caret.
2534// Will not delete the character before at the start of a line.
8e0945da
VZ
2535void wxStyledTextCtrl::DeleteBackNotLine()
2536{
c26dba42
RD
2537 SendMsg(2344, 0, 0);
2538}
2539
f114b858 2540// Move caret to first position on display line.
8e0945da
VZ
2541void wxStyledTextCtrl::HomeDisplay()
2542{
f114b858
RD
2543 SendMsg(2345, 0, 0);
2544}
2545
2b5f62a0 2546// Move caret to first position on display line extending selection to
f114b858 2547// new caret position.
8e0945da
VZ
2548void wxStyledTextCtrl::HomeDisplayExtend()
2549{
f114b858
RD
2550 SendMsg(2346, 0, 0);
2551}
2552
2553// Move caret to last position on display line.
8e0945da
VZ
2554void wxStyledTextCtrl::LineEndDisplay()
2555{
f114b858
RD
2556 SendMsg(2347, 0, 0);
2557}
2558
2b5f62a0 2559// Move caret to last position on display line extending selection to new
f114b858 2560// caret position.
8e0945da
VZ
2561void wxStyledTextCtrl::LineEndDisplayExtend()
2562{
f114b858
RD
2563 SendMsg(2348, 0, 0);
2564}
2565
c26dba42
RD
2566// These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
2567// except they behave differently when word-wrap is enabled:
2568// They go first to the start / end of the display line, like (Home|LineEnd)Display
2569// The difference is that, the cursor is already at the point, it goes on to the start
2570// or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
8e0945da
VZ
2571void wxStyledTextCtrl::HomeWrap()
2572{
c26dba42
RD
2573 SendMsg(2349, 0, 0);
2574}
8e0945da
VZ
2575void wxStyledTextCtrl::HomeWrapExtend()
2576{
c26dba42
RD
2577 SendMsg(2450, 0, 0);
2578}
8e0945da
VZ
2579void wxStyledTextCtrl::LineEndWrap()
2580{
c26dba42
RD
2581 SendMsg(2451, 0, 0);
2582}
8e0945da
VZ
2583void wxStyledTextCtrl::LineEndWrapExtend()
2584{
c26dba42
RD
2585 SendMsg(2452, 0, 0);
2586}
8e0945da
VZ
2587void wxStyledTextCtrl::VCHomeWrap()
2588{
c26dba42
RD
2589 SendMsg(2453, 0, 0);
2590}
8e0945da
VZ
2591void wxStyledTextCtrl::VCHomeWrapExtend()
2592{
c26dba42
RD
2593 SendMsg(2454, 0, 0);
2594}
2595
e14d10b0 2596// Copy the line containing the caret.
8e0945da
VZ
2597void wxStyledTextCtrl::LineCopy()
2598{
e14d10b0
RD
2599 SendMsg(2455, 0, 0);
2600}
2601
a834585d 2602// Move the caret inside current view if it's not there already.
8e0945da
VZ
2603void wxStyledTextCtrl::MoveCaretInsideView()
2604{
65ec6247
RD
2605 SendMsg(2401, 0, 0);
2606}
2607
9e96e16f 2608// How many characters are on a line, including end of line characters?
2bfca191 2609int wxStyledTextCtrl::LineLength(int line) const
8e0945da 2610{
4370573a
RD
2611 return SendMsg(2350, line, 0);
2612}
9ce192d4 2613
4370573a 2614// Highlight the characters at two positions.
8e0945da
VZ
2615void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2)
2616{
4370573a
RD
2617 SendMsg(2351, pos1, pos2);
2618}
9ce192d4 2619
9b01abb8
RD
2620// Use specified indicator to highlight matching braces instead of changing their style.
2621void wxStyledTextCtrl::BraceHighlightIndicator(bool useBraceHighlightIndicator, int indicator)
2622{
2623 SendMsg(2498, useBraceHighlightIndicator, indicator);
2624}
2625
4370573a 2626// Highlight the character at a position indicating there is no matching brace.
8e0945da
VZ
2627void wxStyledTextCtrl::BraceBadLight(int pos)
2628{
4370573a 2629 SendMsg(2352, pos, 0);
9ce192d4
RD
2630}
2631
9b01abb8
RD
2632// Use specified indicator to highlight non matching brace instead of changing its style.
2633void wxStyledTextCtrl::BraceBadLightIndicator(bool useBraceBadLightIndicator, int indicator)
2634{
2635 SendMsg(2499, useBraceBadLightIndicator, indicator);
2636}
2637
4370573a 2638// Find the position of a matching brace or INVALID_POSITION if no match.
8e0945da
VZ
2639int wxStyledTextCtrl::BraceMatch(int pos)
2640{
4370573a
RD
2641 return SendMsg(2353, pos, 0);
2642}
9ce192d4 2643
a834585d 2644// Are the end of line characters visible?
8e0945da
VZ
2645bool wxStyledTextCtrl::GetViewEOL() const
2646{
4370573a 2647 return SendMsg(2355, 0, 0) != 0;
9ce192d4
RD
2648}
2649
a834585d 2650// Make the end of line characters visible or invisible.
8e0945da
VZ
2651void wxStyledTextCtrl::SetViewEOL(bool visible)
2652{
4370573a
RD
2653 SendMsg(2356, visible, 0);
2654}
9ce192d4 2655
4370573a
RD
2656// Retrieve a pointer to the document object.
2657void* wxStyledTextCtrl::GetDocPointer() {
9e730a78 2658 return (void*)SendMsg(2357);
4370573a 2659}
67003d1a 2660
4370573a
RD
2661// Change the document object used.
2662void wxStyledTextCtrl::SetDocPointer(void* docPointer) {
b796ba39 2663 SendMsg(2358, 0, (sptr_t)docPointer);
67003d1a
RD
2664}
2665
4370573a 2666// Set which document modification events are sent to the container.
8e0945da
VZ
2667void wxStyledTextCtrl::SetModEventMask(int mask)
2668{
4370573a
RD
2669 SendMsg(2359, mask, 0);
2670}
67003d1a 2671
4370573a 2672// Retrieve the column number which text should be kept within.
8e0945da
VZ
2673int wxStyledTextCtrl::GetEdgeColumn() const
2674{
4370573a 2675 return SendMsg(2360, 0, 0);
67003d1a
RD
2676}
2677
4370573a
RD
2678// Set the column number of the edge.
2679// If text goes past the edge then it is highlighted.
8e0945da
VZ
2680void wxStyledTextCtrl::SetEdgeColumn(int column)
2681{
4370573a
RD
2682 SendMsg(2361, column, 0);
2683}
67003d1a 2684
4370573a 2685// Retrieve the edge highlight mode.
8e0945da
VZ
2686int wxStyledTextCtrl::GetEdgeMode() const
2687{
4370573a 2688 return SendMsg(2362, 0, 0);
67003d1a
RD
2689}
2690
4370573a
RD
2691// The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
2692// goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
8e0945da
VZ
2693void wxStyledTextCtrl::SetEdgeMode(int mode)
2694{
4370573a
RD
2695 SendMsg(2363, mode, 0);
2696}
67003d1a 2697
4370573a 2698// Retrieve the colour used in edge indication.
8e0945da
VZ
2699wxColour wxStyledTextCtrl::GetEdgeColour() const
2700{
4370573a
RD
2701 long c = SendMsg(2364, 0, 0);
2702 return wxColourFromLong(c);
67003d1a
RD
2703}
2704
4370573a 2705// Change the colour used in edge indication.
8e0945da
VZ
2706void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour)
2707{
4370573a
RD
2708 SendMsg(2365, wxColourAsLong(edgeColour), 0);
2709}
67003d1a 2710
4370573a 2711// Sets the current caret position to be the search anchor.
8e0945da
VZ
2712void wxStyledTextCtrl::SearchAnchor()
2713{
4370573a 2714 SendMsg(2366, 0, 0);
67003d1a
RD
2715}
2716
4370573a 2717// Find some text starting at the search anchor.
65ec6247 2718// Does not ensure the selection is visible.
8e0945da
VZ
2719int wxStyledTextCtrl::SearchNext(int flags, const wxString& text)
2720{
b796ba39 2721 return SendMsg(2367, flags, (sptr_t)(const char*)wx2stc(text));
4370573a 2722}
67003d1a 2723
4370573a 2724// Find some text starting at the search anchor and moving backwards.
65ec6247 2725// Does not ensure the selection is visible.
8e0945da
VZ
2726int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text)
2727{
b796ba39 2728 return SendMsg(2368, flags, (sptr_t)(const char*)wx2stc(text));
67003d1a
RD
2729}
2730
4370573a 2731// Retrieves the number of lines completely visible.
8e0945da
VZ
2732int wxStyledTextCtrl::LinesOnScreen() const
2733{
4370573a 2734 return SendMsg(2370, 0, 0);
67003d1a
RD
2735}
2736
4370573a
RD
2737// Set whether a pop up menu is displayed automatically when the user presses
2738// the wrong mouse button.
8e0945da
VZ
2739void wxStyledTextCtrl::UsePopUp(bool allowPopUp)
2740{
4370573a
RD
2741 SendMsg(2371, allowPopUp, 0);
2742}
67003d1a 2743
a834585d 2744// Is the selection rectangular? The alternative is the more common stream selection.
8e0945da
VZ
2745bool wxStyledTextCtrl::SelectionIsRectangle() const
2746{
4370573a 2747 return SendMsg(2372, 0, 0) != 0;
67003d1a
RD
2748}
2749
4370573a
RD
2750// Set the zoom level. This number of points is added to the size of all fonts.
2751// It may be positive to magnify or negative to reduce.
8e0945da
VZ
2752void wxStyledTextCtrl::SetZoom(int zoom)
2753{
4370573a
RD
2754 SendMsg(2373, zoom, 0);
2755}
67003d1a 2756
4370573a 2757// Retrieve the zoom level.
8e0945da
VZ
2758int wxStyledTextCtrl::GetZoom() const
2759{
4370573a 2760 return SendMsg(2374, 0, 0);
67003d1a
RD
2761}
2762
4370573a
RD
2763// Create a new document object.
2764// Starts with reference count of 1 and not selected into editor.
2765void* wxStyledTextCtrl::CreateDocument() {
9e730a78 2766 return (void*)SendMsg(2375);
4370573a 2767}
67003d1a 2768
4370573a
RD
2769// Extend life of document.
2770void wxStyledTextCtrl::AddRefDocument(void* docPointer) {
b796ba39 2771 SendMsg(2376, 0, (sptr_t)docPointer);
67003d1a
RD
2772}
2773
4370573a
RD
2774// Release a reference to the document, deleting document if it fades to black.
2775void wxStyledTextCtrl::ReleaseDocument(void* docPointer) {
b796ba39 2776 SendMsg(2377, 0, (sptr_t)docPointer);
4370573a 2777}
67003d1a 2778
4370573a 2779// Get which document modification events are sent to the container.
8e0945da
VZ
2780int wxStyledTextCtrl::GetModEventMask() const
2781{
4370573a 2782 return SendMsg(2378, 0, 0);
67003d1a
RD
2783}
2784
a834585d 2785// Change internal focus flag.
8e0945da
VZ
2786void wxStyledTextCtrl::SetSTCFocus(bool focus)
2787{
65ec6247
RD
2788 SendMsg(2380, focus, 0);
2789}
2790
a834585d 2791// Get internal focus flag.
8e0945da
VZ
2792bool wxStyledTextCtrl::GetSTCFocus() const
2793{
65ec6247
RD
2794 return SendMsg(2381, 0, 0) != 0;
2795}
2796
a834585d 2797// Change error status - 0 = OK.
8e0945da
VZ
2798void wxStyledTextCtrl::SetStatus(int statusCode)
2799{
65ec6247
RD
2800 SendMsg(2382, statusCode, 0);
2801}
2802
a834585d 2803// Get error status.
8e0945da
VZ
2804int wxStyledTextCtrl::GetStatus() const
2805{
65ec6247
RD
2806 return SendMsg(2383, 0, 0);
2807}
2808
a834585d 2809// Set whether the mouse is captured when its button is pressed.
8e0945da
VZ
2810void wxStyledTextCtrl::SetMouseDownCaptures(bool captures)
2811{
65ec6247
RD
2812 SendMsg(2384, captures, 0);
2813}
2814
a834585d 2815// Get whether mouse gets captured.
8e0945da
VZ
2816bool wxStyledTextCtrl::GetMouseDownCaptures() const
2817{
65ec6247
RD
2818 return SendMsg(2385, 0, 0) != 0;
2819}
2820
a834585d 2821// Sets the cursor to one of the SC_CURSOR* values.
8e0945da
VZ
2822void wxStyledTextCtrl::SetSTCCursor(int cursorType)
2823{
65ec6247
RD
2824 SendMsg(2386, cursorType, 0);
2825}
2826
a834585d 2827// Get cursor type.
8e0945da
VZ
2828int wxStyledTextCtrl::GetSTCCursor() const
2829{
65ec6247
RD
2830 return SendMsg(2387, 0, 0);
2831}
2832
1a2fb4cd 2833// Change the way control characters are displayed:
a834585d 2834// If symbol is < 32, keep the drawn way, else, use the given character.
8e0945da
VZ
2835void wxStyledTextCtrl::SetControlCharSymbol(int symbol)
2836{
1a2fb4cd
RD
2837 SendMsg(2388, symbol, 0);
2838}
2839
a834585d 2840// Get the way control characters are displayed.
8e0945da
VZ
2841int wxStyledTextCtrl::GetControlCharSymbol() const
2842{
1a2fb4cd
RD
2843 return SendMsg(2389, 0, 0);
2844}
2845
a834585d 2846// Move to the previous change in capitalisation.
8e0945da
VZ
2847void wxStyledTextCtrl::WordPartLeft()
2848{
65ec6247
RD
2849 SendMsg(2390, 0, 0);
2850}
2851
a834585d
RD
2852// Move to the previous change in capitalisation extending selection
2853// to new caret position.
8e0945da
VZ
2854void wxStyledTextCtrl::WordPartLeftExtend()
2855{
65ec6247
RD
2856 SendMsg(2391, 0, 0);
2857}
2858
a834585d 2859// Move to the change next in capitalisation.
8e0945da
VZ
2860void wxStyledTextCtrl::WordPartRight()
2861{
65ec6247
RD
2862 SendMsg(2392, 0, 0);
2863}
2864
a834585d
RD
2865// Move to the next change in capitalisation extending selection
2866// to new caret position.
8e0945da
VZ
2867void wxStyledTextCtrl::WordPartRightExtend()
2868{
65ec6247
RD
2869 SendMsg(2393, 0, 0);
2870}
2871
a834585d
RD
2872// Set the way the display area is determined when a particular line
2873// is to be moved to by Find, FindNext, GotoLine, etc.
8e0945da
VZ
2874void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop)
2875{
65ec6247
RD
2876 SendMsg(2394, visiblePolicy, visibleSlop);
2877}
2878
a834585d 2879// Delete back from the current position to the start of the line.
8e0945da
VZ
2880void wxStyledTextCtrl::DelLineLeft()
2881{
65ec6247
RD
2882 SendMsg(2395, 0, 0);
2883}
2884
a834585d 2885// Delete forwards from the current position to the end of the line.
8e0945da
VZ
2886void wxStyledTextCtrl::DelLineRight()
2887{
65ec6247
RD
2888 SendMsg(2396, 0, 0);
2889}
2890
9b01abb8 2891// Get and Set the xOffset (ie, horizontal scroll position).
8e0945da
VZ
2892void wxStyledTextCtrl::SetXOffset(int newOffset)
2893{
1a2fb4cd
RD
2894 SendMsg(2397, newOffset, 0);
2895}
8e0945da
VZ
2896int wxStyledTextCtrl::GetXOffset() const
2897{
1a2fb4cd
RD
2898 return SendMsg(2398, 0, 0);
2899}
2900
8e54aaed 2901// Set the last x chosen value to be the caret x position.
8e0945da
VZ
2902void wxStyledTextCtrl::ChooseCaretX()
2903{
9e730a78
RD
2904 SendMsg(2399, 0, 0);
2905}
2906
9b01abb8 2907// Set the way the caret is kept visible when going sideways.
a834585d 2908// The exclusion zone is given in pixels.
8e0945da
VZ
2909void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy, int caretSlop)
2910{
a834585d
RD
2911 SendMsg(2402, caretPolicy, caretSlop);
2912}
2913
2914// Set the way the line the caret is on is kept visible.
2915// The exclusion zone is given in lines.
8e0945da
VZ
2916void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy, int caretSlop)
2917{
a834585d
RD
2918 SendMsg(2403, caretPolicy, caretSlop);
2919}
2920
9e730a78 2921// Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
8e0945da
VZ
2922void wxStyledTextCtrl::SetPrintWrapMode(int mode)
2923{
9e730a78
RD
2924 SendMsg(2406, mode, 0);
2925}
2926
8e54aaed 2927// Is printing line wrapped?
8e0945da
VZ
2928int wxStyledTextCtrl::GetPrintWrapMode() const
2929{
9e730a78
RD
2930 return SendMsg(2407, 0, 0);
2931}
2932
2933// Set a fore colour for active hotspots.
8e0945da
VZ
2934void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting, const wxColour& fore)
2935{
9e730a78
RD
2936 SendMsg(2410, useSetting, wxColourAsLong(fore));
2937}
2938
7e0c58e9 2939// Get the fore colour for active hotspots.
8e0945da
VZ
2940wxColour wxStyledTextCtrl::GetHotspotActiveForeground() const
2941{
7e0c58e9
RD
2942 long c = SendMsg(2494, 0, 0);
2943 return wxColourFromLong(c);
2944}
2945
9e730a78 2946// Set a back colour for active hotspots.
8e0945da
VZ
2947void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting, const wxColour& back)
2948{
9e730a78
RD
2949 SendMsg(2411, useSetting, wxColourAsLong(back));
2950}
2951
7e0c58e9 2952// Get the back colour for active hotspots.
8e0945da
VZ
2953wxColour wxStyledTextCtrl::GetHotspotActiveBackground() const
2954{
7e0c58e9
RD
2955 long c = SendMsg(2495, 0, 0);
2956 return wxColourFromLong(c);
2957}
2958
9e730a78 2959// Enable / Disable underlining active hotspots.
8e0945da
VZ
2960void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline)
2961{
9e730a78
RD
2962 SendMsg(2412, underline, 0);
2963}
2964
7e0c58e9 2965// Get whether underlining for active hotspots.
8e0945da
VZ
2966bool wxStyledTextCtrl::GetHotspotActiveUnderline() const
2967{
7e0c58e9
RD
2968 return SendMsg(2496, 0, 0) != 0;
2969}
2970
8e54aaed 2971// Limit hotspots to single line so hotspots on two lines don't merge.
8e0945da
VZ
2972void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine)
2973{
8e54aaed
RD
2974 SendMsg(2421, singleLine, 0);
2975}
2976
7e0c58e9 2977// Get the HotspotSingleLine property
8e0945da
VZ
2978bool wxStyledTextCtrl::GetHotspotSingleLine() const
2979{
7e0c58e9
RD
2980 return SendMsg(2497, 0, 0) != 0;
2981}
2982
c26dba42 2983// Move caret between paragraphs (delimited by empty lines).
8e0945da
VZ
2984void wxStyledTextCtrl::ParaDown()
2985{
c26dba42
RD
2986 SendMsg(2413, 0, 0);
2987}
8e0945da
VZ
2988void wxStyledTextCtrl::ParaDownExtend()
2989{
c26dba42
RD
2990 SendMsg(2414, 0, 0);
2991}
8e0945da
VZ
2992void wxStyledTextCtrl::ParaUp()
2993{
c26dba42
RD
2994 SendMsg(2415, 0, 0);
2995}
8e0945da
VZ
2996void wxStyledTextCtrl::ParaUpExtend()
2997{
c26dba42
RD
2998 SendMsg(2416, 0, 0);
2999}
3000
e14d10b0
RD
3001// Given a valid document position, return the previous position taking code
3002// page into account. Returns 0 if passed 0.
8e0945da
VZ
3003int wxStyledTextCtrl::PositionBefore(int pos)
3004{
e14d10b0
RD
3005 return SendMsg(2417, pos, 0);
3006}
3007
3008// Given a valid document position, return the next position taking code
3009// page into account. Maximum value returned is the last position in the document.
8e0945da
VZ
3010int wxStyledTextCtrl::PositionAfter(int pos)
3011{
e14d10b0
RD
3012 return SendMsg(2418, pos, 0);
3013}
3014
3015// Copy a range of text to the clipboard. Positions are clipped into the document.
8e0945da
VZ
3016void wxStyledTextCtrl::CopyRange(int start, int end)
3017{
e14d10b0
RD
3018 SendMsg(2419, start, end);
3019}
3020
3021// Copy argument text to the clipboard.
8e0945da
VZ
3022void wxStyledTextCtrl::CopyText(int length, const wxString& text)
3023{
b796ba39 3024 SendMsg(2420, length, (sptr_t)(const char*)wx2stc(text));
e14d10b0
RD
3025}
3026
9e96e16f 3027// Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE/SC_SEL_THIN) or
8e54aaed 3028// by lines (SC_SEL_LINES).
8e0945da
VZ
3029void wxStyledTextCtrl::SetSelectionMode(int mode)
3030{
8e54aaed
RD
3031 SendMsg(2422, mode, 0);
3032}
3033
3034// Get the mode of the current selection.
8e0945da
VZ
3035int wxStyledTextCtrl::GetSelectionMode() const
3036{
8e54aaed
RD
3037 return SendMsg(2423, 0, 0);
3038}
3039
3040// Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
8e0945da
VZ
3041int wxStyledTextCtrl::GetLineSelStartPosition(int line)
3042{
8e54aaed
RD
3043 return SendMsg(2424, line, 0);
3044}
3045
3046// Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
8e0945da
VZ
3047int wxStyledTextCtrl::GetLineSelEndPosition(int line)
3048{
8e54aaed
RD
3049 return SendMsg(2425, line, 0);
3050}
3051
c26dba42 3052// Move caret down one line, extending rectangular selection to new caret position.
8e0945da
VZ
3053void wxStyledTextCtrl::LineDownRectExtend()
3054{
c26dba42
RD
3055 SendMsg(2426, 0, 0);
3056}
3057
3058// Move caret up one line, extending rectangular selection to new caret position.
8e0945da
VZ
3059void wxStyledTextCtrl::LineUpRectExtend()
3060{
c26dba42
RD
3061 SendMsg(2427, 0, 0);
3062}
3063
3064// Move caret left one character, extending rectangular selection to new caret position.
8e0945da
VZ
3065void wxStyledTextCtrl::CharLeftRectExtend()
3066{
c26dba42
RD
3067 SendMsg(2428, 0, 0);
3068}
3069
3070// Move caret right one character, extending rectangular selection to new caret position.
8e0945da
VZ
3071void wxStyledTextCtrl::CharRightRectExtend()
3072{
c26dba42
RD
3073 SendMsg(2429, 0, 0);
3074}
3075
3076// Move caret to first position on line, extending rectangular selection to new caret position.
8e0945da
VZ
3077void wxStyledTextCtrl::HomeRectExtend()
3078{
c26dba42
RD
3079 SendMsg(2430, 0, 0);
3080}
3081
3082// Move caret to before first visible character on line.
3083// If already there move to first character on line.
3084// In either case, extend rectangular selection to new caret position.
8e0945da
VZ
3085void wxStyledTextCtrl::VCHomeRectExtend()
3086{
c26dba42
RD
3087 SendMsg(2431, 0, 0);
3088}
3089
3090// Move caret to last position on line, extending rectangular selection to new caret position.
8e0945da
VZ
3091void wxStyledTextCtrl::LineEndRectExtend()
3092{
c26dba42
RD
3093 SendMsg(2432, 0, 0);
3094}
3095
3096// Move caret one page up, extending rectangular selection to new caret position.
8e0945da
VZ
3097void wxStyledTextCtrl::PageUpRectExtend()
3098{
c26dba42
RD
3099 SendMsg(2433, 0, 0);
3100}
3101
3102// Move caret one page down, extending rectangular selection to new caret position.
8e0945da
VZ
3103void wxStyledTextCtrl::PageDownRectExtend()
3104{
c26dba42
RD
3105 SendMsg(2434, 0, 0);
3106}
3107
3108// Move caret to top of page, or one page up if already at top of page.
8e0945da
VZ
3109void wxStyledTextCtrl::StutteredPageUp()
3110{
c26dba42
RD
3111 SendMsg(2435, 0, 0);
3112}
3113
3114// Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
8e0945da
VZ
3115void wxStyledTextCtrl::StutteredPageUpExtend()
3116{
c26dba42
RD
3117 SendMsg(2436, 0, 0);
3118}
3119
3120// Move caret to bottom of page, or one page down if already at bottom of page.
8e0945da
VZ
3121void wxStyledTextCtrl::StutteredPageDown()
3122{
c26dba42
RD
3123 SendMsg(2437, 0, 0);
3124}
3125
3126// Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
8e0945da
VZ
3127void wxStyledTextCtrl::StutteredPageDownExtend()
3128{
c26dba42
RD
3129 SendMsg(2438, 0, 0);
3130}
3131
3132// Move caret left one word, position cursor at end of word.
8e0945da
VZ
3133void wxStyledTextCtrl::WordLeftEnd()
3134{
c26dba42
RD
3135 SendMsg(2439, 0, 0);
3136}
3137
3138// Move caret left one word, position cursor at end of word, extending selection to new caret position.
8e0945da
VZ
3139void wxStyledTextCtrl::WordLeftEndExtend()
3140{
c26dba42
RD
3141 SendMsg(2440, 0, 0);
3142}
3143
3144// Move caret right one word, position cursor at end of word.
8e0945da
VZ
3145void wxStyledTextCtrl::WordRightEnd()
3146{
c26dba42
RD
3147 SendMsg(2441, 0, 0);
3148}
3149
3150// Move caret right one word, position cursor at end of word, extending selection to new caret position.
8e0945da
VZ
3151void wxStyledTextCtrl::WordRightEndExtend()
3152{
c26dba42
RD
3153 SendMsg(2442, 0, 0);
3154}
3155
8e54aaed
RD
3156// Set the set of characters making up whitespace for when moving or selecting by word.
3157// Should be called after SetWordChars.
8e0945da
VZ
3158void wxStyledTextCtrl::SetWhitespaceChars(const wxString& characters)
3159{
b796ba39 3160 SendMsg(2443, 0, (sptr_t)(const char*)wx2stc(characters));
8e54aaed
RD
3161}
3162
9b01abb8
RD
3163// Get the set of characters making up whitespace for when moving or selecting by word.
3164wxString wxStyledTextCtrl::GetWhitespaceChars() const {
3165 int msg = 2647;
c4bdd822 3166 int len = SendMsg(msg, 0, (sptr_t)NULL);
9b01abb8
RD
3167 if (!len) return wxEmptyString;
3168
3169 wxMemoryBuffer mbuf(len+1);
3170 char* buf = (char*)mbuf.GetWriteBuf(len+1);
54173563 3171 SendMsg(msg, 0, (sptr_t)buf);
9b01abb8
RD
3172 mbuf.UngetWriteBuf(len);
3173 mbuf.AppendByte(0);
3174 return stc2wx(buf);
3175}
3176
3177// Set the set of characters making up punctuation characters
3178// Should be called after SetWordChars.
3179void wxStyledTextCtrl::SetPunctuationChars(const wxString& characters)
3180{
3181 SendMsg(2648, 0, (sptr_t)(const char*)wx2stc(characters));
3182}
3183
3184// Get the set of characters making up punctuation characters
3185wxString wxStyledTextCtrl::GetPunctuationChars() const {
3186 int msg = 2649;
c4bdd822 3187 int len = SendMsg(msg, 0, (sptr_t)NULL);
9b01abb8
RD
3188 if (!len) return wxEmptyString;
3189
3190 wxMemoryBuffer mbuf(len+1);
3191 char* buf = (char*)mbuf.GetWriteBuf(len+1);
54173563 3192 SendMsg(msg, 0, (sptr_t)buf);
9b01abb8
RD
3193 mbuf.UngetWriteBuf(len);
3194 mbuf.AppendByte(0);
3195 return stc2wx(buf);
3196}
3197
8e54aaed 3198// Reset the set of characters for whitespace and word characters to the defaults.
8e0945da
VZ
3199void wxStyledTextCtrl::SetCharsDefault()
3200{
8e54aaed
RD
3201 SendMsg(2444, 0, 0);
3202}
3203
3204// Get currently selected item position in the auto-completion list
9b01abb8 3205int wxStyledTextCtrl::AutoCompGetCurrent() const
8e0945da 3206{
8e54aaed
RD
3207 return SendMsg(2445, 0, 0);
3208}
3209
9b01abb8 3210// Set auto-completion case insensitive behaviour to either prefer case-sensitive matches or have no preference.
54173563 3211void wxStyledTextCtrl::AutoCompSetCaseInsensitiveBehaviour(int behaviour)
9b01abb8
RD
3212{
3213 SendMsg(2634, behaviour, 0);
3214}
3215
3216// Get auto-completion case insensitive behaviour.
54173563 3217int wxStyledTextCtrl::AutoCompGetCaseInsensitiveBehaviour() const
9b01abb8
RD
3218{
3219 return SendMsg(2635, 0, 0);
3220}
3221
591d01be 3222// Enlarge the document to a particular size of text bytes.
8e0945da
VZ
3223void wxStyledTextCtrl::Allocate(int bytes)
3224{
591d01be
RD
3225 SendMsg(2446, bytes, 0);
3226}
3227
1e9bafca 3228// Find the position of a column on a line taking into account tabs and
a33203cb 3229// multi-byte characters. If beyond end of line, return line end position.
8e0945da
VZ
3230int wxStyledTextCtrl::FindColumn(int line, int column)
3231{
a33203cb
RD
3232 return SendMsg(2456, line, column);
3233}
3234
1e9bafca 3235// Can the caret preferred x position only be changed by explicit movement commands?
9b01abb8 3236int wxStyledTextCtrl::GetCaretSticky() const
8e0945da 3237{
9b01abb8 3238 return SendMsg(2457, 0, 0);
1e9bafca
RD
3239}
3240
3241// Stop the caret preferred x position changing when the user types.
9b01abb8 3242void wxStyledTextCtrl::SetCaretSticky(int useCaretStickyBehaviour)
8e0945da 3243{
1e9bafca
RD
3244 SendMsg(2458, useCaretStickyBehaviour, 0);
3245}
3246
3247// Switch between sticky and non-sticky: meant to be bound to a key.
8e0945da
VZ
3248void wxStyledTextCtrl::ToggleCaretSticky()
3249{
1e9bafca
RD
3250 SendMsg(2459, 0, 0);
3251}
3252
3253// Enable/Disable convert-on-paste for line endings
8e0945da
VZ
3254void wxStyledTextCtrl::SetPasteConvertEndings(bool convert)
3255{
1e9bafca
RD
3256 SendMsg(2467, convert, 0);
3257}
3258
3259// Get convert-on-paste setting
8e0945da
VZ
3260bool wxStyledTextCtrl::GetPasteConvertEndings() const
3261{
1e9bafca
RD
3262 return SendMsg(2468, 0, 0) != 0;
3263}
3264
3265// Duplicate the selection. If selection empty duplicate the line containing the caret.
8e0945da
VZ
3266void wxStyledTextCtrl::SelectionDuplicate()
3267{
1e9bafca
RD
3268 SendMsg(2469, 0, 0);
3269}
3270
b8193d80 3271// Set background alpha of the caret line.
8e0945da
VZ
3272void wxStyledTextCtrl::SetCaretLineBackAlpha(int alpha)
3273{
b8193d80
RD
3274 SendMsg(2470, alpha, 0);
3275}
3276
3277// Get the background alpha of the caret line.
8e0945da
VZ
3278int wxStyledTextCtrl::GetCaretLineBackAlpha() const
3279{
b8193d80
RD
3280 return SendMsg(2471, 0, 0);
3281}
3282
7e0c58e9 3283// Set the style of the caret to be drawn.
8e0945da
VZ
3284void wxStyledTextCtrl::SetCaretStyle(int caretStyle)
3285{
7e0c58e9
RD
3286 SendMsg(2512, caretStyle, 0);
3287}
3288
3289// Returns the current style of the caret.
8e0945da
VZ
3290int wxStyledTextCtrl::GetCaretStyle() const
3291{
7e0c58e9
RD
3292 return SendMsg(2513, 0, 0);
3293}
3294
3295// Set the indicator used for IndicatorFillRange and IndicatorClearRange
8e0945da
VZ
3296void wxStyledTextCtrl::SetIndicatorCurrent(int indicator)
3297{
7e0c58e9
RD
3298 SendMsg(2500, indicator, 0);
3299}
3300
3301// Get the current indicator
8e0945da
VZ
3302int wxStyledTextCtrl::GetIndicatorCurrent() const
3303{
7e0c58e9
RD
3304 return SendMsg(2501, 0, 0);
3305}
3306
3307// Set the value used for IndicatorFillRange
8e0945da
VZ
3308void wxStyledTextCtrl::SetIndicatorValue(int value)
3309{
7e0c58e9
RD
3310 SendMsg(2502, value, 0);
3311}
3312
9b01abb8 3313// Get the current indicator value
8e0945da
VZ
3314int wxStyledTextCtrl::GetIndicatorValue() const
3315{
7e0c58e9
RD
3316 return SendMsg(2503, 0, 0);
3317}
3318
3319// Turn a indicator on over a range.
8e0945da
VZ
3320void wxStyledTextCtrl::IndicatorFillRange(int position, int fillLength)
3321{
7e0c58e9
RD
3322 SendMsg(2504, position, fillLength);
3323}
3324
3325// Turn a indicator off over a range.
8e0945da
VZ
3326void wxStyledTextCtrl::IndicatorClearRange(int position, int clearLength)
3327{
7e0c58e9
RD
3328 SendMsg(2505, position, clearLength);
3329}
3330
3331// Are any indicators present at position?
8e0945da
VZ
3332int wxStyledTextCtrl::IndicatorAllOnFor(int position)
3333{
7e0c58e9
RD
3334 return SendMsg(2506, position, 0);
3335}
3336
3337// What value does a particular indicator have at at a position?
8e0945da
VZ
3338int wxStyledTextCtrl::IndicatorValueAt(int indicator, int position)
3339{
7e0c58e9
RD
3340 return SendMsg(2507, indicator, position);
3341}
3342
3343// Where does a particular indicator start?
8e0945da
VZ
3344int wxStyledTextCtrl::IndicatorStart(int indicator, int position)
3345{
7e0c58e9
RD
3346 return SendMsg(2508, indicator, position);
3347}
3348
3349// Where does a particular indicator end?
8e0945da
VZ
3350int wxStyledTextCtrl::IndicatorEnd(int indicator, int position)
3351{
7e0c58e9
RD
3352 return SendMsg(2509, indicator, position);
3353}
3354
3355// Set number of entries in position cache
8e0945da
VZ
3356void wxStyledTextCtrl::SetPositionCacheSize(int size)
3357{
7e0c58e9
RD
3358 SendMsg(2514, size, 0);
3359}
3360
3361// How many entries are allocated to the position cache?
8e0945da
VZ
3362int wxStyledTextCtrl::GetPositionCacheSize() const
3363{
7e0c58e9
RD
3364 return SendMsg(2515, 0, 0);
3365}
3366
9e96e16f
RD
3367// Copy the selection, if selection empty copy the line with the caret
3368void wxStyledTextCtrl::CopyAllowLine()
3369{
3370 SendMsg(2519, 0, 0);
3371}
3372
3373// Compact the document buffer and return a read-only pointer to the
3374// characters in the document.
54173563 3375const char* wxStyledTextCtrl::GetCharacterPointer() const {
9e96e16f
RD
3376 return (const char*)SendMsg(2520, 0, 0);
3377}
3378
9b01abb8
RD
3379// Return a read-only pointer to a range of characters in the document.
3380// May move the gap so that the range is contiguous, but will only move up
3381// to rangeLength bytes.
54173563
RD
3382const char* wxStyledTextCtrl::GetRangePointer(int position, int rangeLength) const {
3383 return (const char*)SendMsg(2643, position, rangeLength);
9b01abb8
RD
3384}
3385
3386// Return a position which, to avoid performance costs, should not be within
3387// the range of a call to GetRangePointer.
3388int wxStyledTextCtrl::GetGapPosition() const
3389{
3390 return SendMsg(2644, 0, 0);
3391}
3392
9e96e16f
RD
3393// Always interpret keyboard input as Unicode
3394void wxStyledTextCtrl::SetKeysUnicode(bool keysUnicode)
3395{
3396 SendMsg(2521, keysUnicode, 0);
3397}
3398
3399// Are keys always interpreted as Unicode?
3400bool wxStyledTextCtrl::GetKeysUnicode() const
3401{
3402 return SendMsg(2522, 0, 0) != 0;
3403}
3404
3405// Set the alpha fill colour of the given indicator.
3406void wxStyledTextCtrl::IndicatorSetAlpha(int indicator, int alpha)
3407{
3408 SendMsg(2523, indicator, alpha);
3409}
3410
3411// Get the alpha fill colour of the given indicator.
3412int wxStyledTextCtrl::IndicatorGetAlpha(int indicator) const
3413{
3414 return SendMsg(2524, indicator, 0);
3415}
3416
9b01abb8 3417// Set the alpha outline colour of the given indicator.
54173563 3418void wxStyledTextCtrl::IndicatorSetOutlineAlpha(int indicator, int alpha)
9b01abb8
RD
3419{
3420 SendMsg(2558, indicator, alpha);
3421}
3422
3423// Get the alpha outline colour of the given indicator.
54173563 3424int wxStyledTextCtrl::IndicatorGetOutlineAlpha(int indicator) const
9b01abb8
RD
3425{
3426 return SendMsg(2559, indicator, 0);
3427}
3428
9e96e16f
RD
3429// Set extra ascent for each line
3430void wxStyledTextCtrl::SetExtraAscent(int extraAscent)
3431{
3432 SendMsg(2525, extraAscent, 0);
3433}
3434
3435// Get extra ascent for each line
3436int wxStyledTextCtrl::GetExtraAscent() const
3437{
3438 return SendMsg(2526, 0, 0);
3439}
3440
3441// Set extra descent for each line
3442void wxStyledTextCtrl::SetExtraDescent(int extraDescent)
3443{
3444 SendMsg(2527, extraDescent, 0);
3445}
3446
3447// Get extra descent for each line
3448int wxStyledTextCtrl::GetExtraDescent() const
3449{
3450 return SendMsg(2528, 0, 0);
3451}
3452
3453// Which symbol was defined for markerNumber with MarkerDefine
3454int wxStyledTextCtrl::GetMarkerSymbolDefined(int markerNumber)
3455{
3456 return SendMsg(2529, markerNumber, 0);
3457}
3458
3459// Set the text in the text margin for a line
3460void wxStyledTextCtrl::MarginSetText(int line, const wxString& text)
3461{
3462 SendMsg(2530, line, (sptr_t)(const char*)wx2stc(text));
3463}
3464
3465// Get the text in the text margin for a line
3466wxString wxStyledTextCtrl::MarginGetText(int line) const {
3467 long msg = 2531;
3468 long len = SendMsg(msg, line, 0);
3469
3470 wxMemoryBuffer mbuf(len+1);
3471 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3472 SendMsg(msg, line, (sptr_t)buf);
3473 mbuf.UngetWriteBuf(len);
3474 mbuf.AppendByte(0);
3475 return stc2wx(buf);
3476}
3477
3478// Set the style number for the text margin for a line
3479void wxStyledTextCtrl::MarginSetStyle(int line, int style)
3480{
3481 SendMsg(2532, line, style);
3482}
3483
3484// Get the style number for the text margin for a line
3485int wxStyledTextCtrl::MarginGetStyle(int line) const
3486{
3487 return SendMsg(2533, line, 0);
3488}
3489
3490// Set the style in the text margin for a line
3491void wxStyledTextCtrl::MarginSetStyles(int line, const wxString& styles)
3492{
3493 SendMsg(2534, line, (sptr_t)(const char*)wx2stc(styles));
3494}
3495
3496// Get the styles in the text margin for a line
3497wxString wxStyledTextCtrl::MarginGetStyles(int line) const {
3498 long msg = 2535;
3499 long len = SendMsg(msg, line, 0);
3500
3501 wxMemoryBuffer mbuf(len+1);
3502 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3503 SendMsg(msg, line, (sptr_t)buf);
3504 mbuf.UngetWriteBuf(len);
3505 mbuf.AppendByte(0);
3506 return stc2wx(buf);
3507}
3508
3509// Clear the margin text on all lines
3510void wxStyledTextCtrl::MarginTextClearAll()
3511{
3512 SendMsg(2536, 0, 0);
3513}
3514
3515// Get the start of the range of style numbers used for margin text
3516void wxStyledTextCtrl::MarginSetStyleOffset(int style)
3517{
3518 SendMsg(2537, style, 0);
3519}
3520
3521// Get the start of the range of style numbers used for margin text
3522int wxStyledTextCtrl::MarginGetStyleOffset() const
3523{
3524 return SendMsg(2538, 0, 0);
3525}
3526
9b01abb8
RD
3527// Set the margin options.
3528void wxStyledTextCtrl::SetMarginOptions(int marginOptions)
3529{
3530 SendMsg(2539, marginOptions, 0);
3531}
3532
3533// Get the margin options.
3534int wxStyledTextCtrl::GetMarginOptions() const
3535{
3536 return SendMsg(2557, 0, 0);
3537}
3538
9e96e16f
RD
3539// Set the annotation text for a line
3540void wxStyledTextCtrl::AnnotationSetText(int line, const wxString& text)
3541{
3542 SendMsg(2540, line, (sptr_t)(const char*)wx2stc(text));
3543}
3544
3545// Get the annotation text for a line
3546wxString wxStyledTextCtrl::AnnotationGetText(int line) const {
3547 long msg = 2541;
3548 long len = SendMsg(msg, line, 0);
3549
3550 wxMemoryBuffer mbuf(len+1);
3551 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3552 SendMsg(msg, line, (sptr_t)buf);
3553 mbuf.UngetWriteBuf(len);
3554 mbuf.AppendByte(0);
3555 return stc2wx(buf);
3556}
3557
3558// Set the style number for the annotations for a line
3559void wxStyledTextCtrl::AnnotationSetStyle(int line, int style)
3560{
3561 SendMsg(2542, line, style);
3562}
3563
3564// Get the style number for the annotations for a line
3565int wxStyledTextCtrl::AnnotationGetStyle(int line) const
3566{
3567 return SendMsg(2543, line, 0);
3568}
3569
3570// Set the annotation styles for a line
3571void wxStyledTextCtrl::AnnotationSetStyles(int line, const wxString& styles)
3572{
3573 SendMsg(2544, line, (sptr_t)(const char*)wx2stc(styles));
3574}
3575
3576// Get the annotation styles for a line
3577wxString wxStyledTextCtrl::AnnotationGetStyles(int line) const {
3578 long msg = 2545;
3579 long len = SendMsg(msg, line, 0);
3580
3581 wxMemoryBuffer mbuf(len+1);
3582 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3583 SendMsg(msg, line, (sptr_t)buf);
3584 mbuf.UngetWriteBuf(len);
3585 mbuf.AppendByte(0);
3586 return stc2wx(buf);
3587}
3588
3589// Get the number of annotation lines for a line
3590int wxStyledTextCtrl::AnnotationGetLines(int line) const
3591{
3592 return SendMsg(2546, line, 0);
3593}
3594
3595// Clear the annotations from all lines
3596void wxStyledTextCtrl::AnnotationClearAll()
3597{
3598 SendMsg(2547, 0, 0);
3599}
3600
3601// Set the visibility for the annotations for a view
3602void wxStyledTextCtrl::AnnotationSetVisible(int visible)
3603{
3604 SendMsg(2548, visible, 0);
3605}
3606
3607// Get the visibility for the annotations for a view
3608int wxStyledTextCtrl::AnnotationGetVisible() const
3609{
3610 return SendMsg(2549, 0, 0);
3611}
3612
3613// Get the start of the range of style numbers used for annotations
3614void wxStyledTextCtrl::AnnotationSetStyleOffset(int style)
3615{
3616 SendMsg(2550, style, 0);
3617}
3618
3619// Get the start of the range of style numbers used for annotations
3620int wxStyledTextCtrl::AnnotationGetStyleOffset() const
3621{
3622 return SendMsg(2551, 0, 0);
3623}
3624
3625// Add a container action to the undo stack
3626void wxStyledTextCtrl::AddUndoAction(int token, int flags)
3627{
3628 SendMsg(2560, token, flags);
3629}
3630
3631// Find the position of a character from a point within the window.
3632int wxStyledTextCtrl::CharPositionFromPoint(int x, int y)
3633{
3634 return SendMsg(2561, x, y);
3635}
3636
3637// Find the position of a character from a point within the window.
3638// Return INVALID_POSITION if not close to text.
3639int wxStyledTextCtrl::CharPositionFromPointClose(int x, int y)
3640{
3641 return SendMsg(2562, x, y);
3642}
3643
3644// Set whether multiple selections can be made
3645void wxStyledTextCtrl::SetMultipleSelection(bool multipleSelection)
3646{
3647 SendMsg(2563, multipleSelection, 0);
3648}
3649
3650// Whether multiple selections can be made
3651bool wxStyledTextCtrl::GetMultipleSelection() const
3652{
3653 return SendMsg(2564, 0, 0) != 0;
3654}
3655
3656// Set whether typing can be performed into multiple selections
3657void wxStyledTextCtrl::SetAdditionalSelectionTyping(bool additionalSelectionTyping)
3658{
3659 SendMsg(2565, additionalSelectionTyping, 0);
3660}
3661
3662// Whether typing can be performed into multiple selections
3663bool wxStyledTextCtrl::GetAdditionalSelectionTyping() const
3664{
3665 return SendMsg(2566, 0, 0) != 0;
3666}
3667
3668// Set whether additional carets will blink
3669void wxStyledTextCtrl::SetAdditionalCaretsBlink(bool additionalCaretsBlink)
3670{
3671 SendMsg(2567, additionalCaretsBlink, 0);
3672}
3673
3674// Whether additional carets will blink
3675bool wxStyledTextCtrl::GetAdditionalCaretsBlink() const
3676{
3677 return SendMsg(2568, 0, 0) != 0;
3678}
3679
3680// Set whether additional carets are visible
3681void wxStyledTextCtrl::SetAdditionalCaretsVisible(bool additionalCaretsBlink)
3682{
3683 SendMsg(2608, additionalCaretsBlink, 0);
3684}
3685
3686// Whether additional carets are visible
3687bool wxStyledTextCtrl::GetAdditionalCaretsVisible() const
3688{
3689 return SendMsg(2609, 0, 0) != 0;
3690}
3691
3692// How many selections are there?
3693int wxStyledTextCtrl::GetSelections() const
3694{
3695 return SendMsg(2570, 0, 0);
3696}
3697
3698// Clear selections to a single empty stream selection
3699void wxStyledTextCtrl::ClearSelections()
3700{
3701 SendMsg(2571, 0, 0);
3702}
3703
3704// Add a selection
3705int wxStyledTextCtrl::AddSelection(int caret, int anchor)
3706{
3707 return SendMsg(2573, caret, anchor);
3708}
3709
3710// Set the main selection
3711void wxStyledTextCtrl::SetMainSelection(int selection)
3712{
3713 SendMsg(2574, selection, 0);
3714}
3715
3716// Which selection is the main selection
3717int wxStyledTextCtrl::GetMainSelection() const
3718{
3719 return SendMsg(2575, 0, 0);
3720}
3721void wxStyledTextCtrl::SetSelectionNCaret(int selection, int pos)
3722{
3723 SendMsg(2576, selection, pos);
3724}
3725int wxStyledTextCtrl::GetSelectionNCaret(int selection) const
3726{
3727 return SendMsg(2577, selection, 0);
3728}
3729void wxStyledTextCtrl::SetSelectionNAnchor(int selection, int posAnchor)
3730{
3731 SendMsg(2578, selection, posAnchor);
3732}
3733int wxStyledTextCtrl::GetSelectionNAnchor(int selection) const
3734{
3735 return SendMsg(2579, selection, 0);
3736}
3737void wxStyledTextCtrl::SetSelectionNCaretVirtualSpace(int selection, int space)
3738{
3739 SendMsg(2580, selection, space);
3740}
3741int wxStyledTextCtrl::GetSelectionNCaretVirtualSpace(int selection) const
3742{
3743 return SendMsg(2581, selection, 0);
3744}
3745void wxStyledTextCtrl::SetSelectionNAnchorVirtualSpace(int selection, int space)
3746{
3747 SendMsg(2582, selection, space);
3748}
3749int wxStyledTextCtrl::GetSelectionNAnchorVirtualSpace(int selection) const
3750{
3751 return SendMsg(2583, selection, 0);
3752}
3753
3754// Sets the position that starts the selection - this becomes the anchor.
3755void wxStyledTextCtrl::SetSelectionNStart(int selection, int pos)
3756{
3757 SendMsg(2584, selection, pos);
3758}
3759
3760// Returns the position at the start of the selection.
3761int wxStyledTextCtrl::GetSelectionNStart(int selection) const
3762{
3763 return SendMsg(2585, selection, 0);
3764}
3765
3766// Sets the position that ends the selection - this becomes the currentPosition.
3767void wxStyledTextCtrl::SetSelectionNEnd(int selection, int pos)
3768{
3769 SendMsg(2586, selection, pos);
3770}
3771
3772// Returns the position at the end of the selection.
3773int wxStyledTextCtrl::GetSelectionNEnd(int selection) const
3774{
3775 return SendMsg(2587, selection, 0);
3776}
3777void wxStyledTextCtrl::SetRectangularSelectionCaret(int pos)
3778{
3779 SendMsg(2588, pos, 0);
3780}
3781int wxStyledTextCtrl::GetRectangularSelectionCaret() const
3782{
3783 return SendMsg(2589, 0, 0);
3784}
3785void wxStyledTextCtrl::SetRectangularSelectionAnchor(int posAnchor)
3786{
3787 SendMsg(2590, posAnchor, 0);
3788}
3789int wxStyledTextCtrl::GetRectangularSelectionAnchor() const
3790{
3791 return SendMsg(2591, 0, 0);
3792}
3793void wxStyledTextCtrl::SetRectangularSelectionCaretVirtualSpace(int space)
3794{
3795 SendMsg(2592, space, 0);
3796}
3797int wxStyledTextCtrl::GetRectangularSelectionCaretVirtualSpace() const
3798{
3799 return SendMsg(2593, 0, 0);
3800}
3801void wxStyledTextCtrl::SetRectangularSelectionAnchorVirtualSpace(int space)
3802{
3803 SendMsg(2594, space, 0);
3804}
3805int wxStyledTextCtrl::GetRectangularSelectionAnchorVirtualSpace() const
3806{
3807 return SendMsg(2595, 0, 0);
3808}
3809void wxStyledTextCtrl::SetVirtualSpaceOptions(int virtualSpaceOptions)
3810{
3811 SendMsg(2596, virtualSpaceOptions, 0);
3812}
3813int wxStyledTextCtrl::GetVirtualSpaceOptions() const
3814{
3815 return SendMsg(2597, 0, 0);
3816}
3817
3818// On GTK+, allow selecting the modifier key to use for mouse-based
3819// rectangular selection. Often the window manager requires Alt+Mouse Drag
3820// for moving windows.
3821// Valid values are SCMOD_CTRL(default), SCMOD_ALT, or SCMOD_SUPER.
3822void wxStyledTextCtrl::SetRectangularSelectionModifier(int modifier)
3823{
3824 SendMsg(2598, modifier, 0);
3825}
3826
3827// Get the modifier key used for rectangular selection.
3828int wxStyledTextCtrl::GetRectangularSelectionModifier() const
3829{
3830 return SendMsg(2599, 0, 0);
3831}
3832
3833// Set the foreground colour of additional selections.
3834// Must have previously called SetSelFore with non-zero first argument for this to have an effect.
3835void wxStyledTextCtrl::SetAdditionalSelForeground(const wxColour& fore)
3836{
3837 SendMsg(2600, wxColourAsLong(fore), 0);
3838}
3839
3840// Set the background colour of additional selections.
3841// Must have previously called SetSelBack with non-zero first argument for this to have an effect.
3842void wxStyledTextCtrl::SetAdditionalSelBackground(const wxColour& back)
3843{
3844 SendMsg(2601, wxColourAsLong(back), 0);
3845}
3846
3847// Set the alpha of the selection.
3848void wxStyledTextCtrl::SetAdditionalSelAlpha(int alpha)
3849{
3850 SendMsg(2602, alpha, 0);
3851}
3852
3853// Get the alpha of the selection.
3854int wxStyledTextCtrl::GetAdditionalSelAlpha() const
3855{
3856 return SendMsg(2603, 0, 0);
3857}
3858
3859// Set the foreground colour of additional carets.
3860void wxStyledTextCtrl::SetAdditionalCaretForeground(const wxColour& fore)
3861{
3862 SendMsg(2604, wxColourAsLong(fore), 0);
3863}
3864
3865// Get the foreground colour of additional carets.
3866wxColour wxStyledTextCtrl::GetAdditionalCaretForeground() const
3867{
3868 long c = SendMsg(2605, 0, 0);
3869 return wxColourFromLong(c);
3870}
3871
3872// Set the main selection to the next selection.
3873void wxStyledTextCtrl::RotateSelection()
3874{
3875 SendMsg(2606, 0, 0);
3876}
3877
3878// Swap that caret and anchor of the main selection.
3879void wxStyledTextCtrl::SwapMainAnchorCaret()
3880{
3881 SendMsg(2607, 0, 0);
3882}
3883
9b01abb8
RD
3884// Indicate that the internal state of a lexer has changed over a range and therefore
3885// there may be a need to redraw.
3886int wxStyledTextCtrl::ChangeLexerState(int start, int end)
3887{
3888 return SendMsg(2617, start, end);
3889}
3890
3891// Find the next line at or after lineStart that is a contracted fold header line.
3892// Return -1 when no more lines.
3893int wxStyledTextCtrl::ContractedFoldNext(int lineStart)
3894{
3895 return SendMsg(2618, lineStart, 0);
3896}
3897
3898// Centre current line in window.
3899void wxStyledTextCtrl::VerticalCentreCaret()
3900{
3901 SendMsg(2619, 0, 0);
3902}
3903
3904// Move the selected lines up one line, shifting the line above after the selection
3905void wxStyledTextCtrl::MoveSelectedLinesUp()
3906{
3907 SendMsg(2620, 0, 0);
3908}
3909
3910// Move the selected lines down one line, shifting the line below before the selection
3911void wxStyledTextCtrl::MoveSelectedLinesDown()
3912{
3913 SendMsg(2621, 0, 0);
3914}
3915
3916// Set the identifier reported as idFrom in notification messages.
3917void wxStyledTextCtrl::SetIdentifier(int identifier)
3918{
3919 SendMsg(2622, identifier, 0);
3920}
3921
3922// Get the identifier.
3923int wxStyledTextCtrl::GetIdentifier() const
3924{
3925 return SendMsg(2623, 0, 0);
3926}
3927
3928// Set the width for future RGBA image data.
3929void wxStyledTextCtrl::RGBAImageSetWidth(int width)
3930{
3931 SendMsg(2624, width, 0);
3932}
3933
3934// Set the height for future RGBA image data.
3935void wxStyledTextCtrl::RGBAImageSetHeight(int height)
3936{
3937 SendMsg(2625, height, 0);
3938}
3939
3940// Define a marker from RGBA data.
3941// It has the width and height from RGBAImageSetWidth/Height
54173563
RD
3942void wxStyledTextCtrl::MarkerDefineRGBAImage(int markerNumber, const unsigned char* pixels) {
3943 SendMsg(2626, markerNumber, (sptr_t)pixels);
9b01abb8
RD
3944}
3945
3946// Register an RGBA image for use in autocompletion lists.
3947// It has the width and height from RGBAImageSetWidth/Height
54173563
RD
3948void wxStyledTextCtrl::RegisterRGBAImage(int type, const unsigned char* pixels) {
3949 SendMsg(2627, type, (sptr_t)pixels);
9b01abb8
RD
3950}
3951
3952// Scroll to start of document.
3953void wxStyledTextCtrl::ScrollToStart()
3954{
3955 SendMsg(2628, 0, 0);
3956}
3957
3958// Scroll to end of document.
3959void wxStyledTextCtrl::ScrollToEnd()
3960{
3961 SendMsg(2629, 0, 0);
3962}
3963
3964// Set the technology used.
3965void wxStyledTextCtrl::SetTechnology(int technology)
3966{
3967 SendMsg(2630, technology, 0);
3968}
3969
3970// Get the tech.
3971int wxStyledTextCtrl::GetTechnology() const
3972{
3973 return SendMsg(2631, 0, 0);
3974}
3975
3976// Create an ILoader*.
54173563
RD
3977void* wxStyledTextCtrl::CreateLoader(int bytes) const {
3978 return (void*)(sptr_t)SendMsg(2632, bytes);
9b01abb8
RD
3979}
3980
4370573a 3981// Start notifying the container of all key presses and commands.
8e0945da
VZ
3982void wxStyledTextCtrl::StartRecord()
3983{
4370573a
RD
3984 SendMsg(3001, 0, 0);
3985}
67003d1a 3986
4370573a 3987// Stop notifying the container of all key presses and commands.
8e0945da
VZ
3988void wxStyledTextCtrl::StopRecord()
3989{
4370573a 3990 SendMsg(3002, 0, 0);
67003d1a
RD
3991}
3992
4370573a 3993// Set the lexing language of the document.
8e0945da
VZ
3994void wxStyledTextCtrl::SetLexer(int lexer)
3995{
4370573a
RD
3996 SendMsg(4001, lexer, 0);
3997}
67003d1a 3998
4370573a 3999// Retrieve the lexing language of the document.
8e0945da
VZ
4000int wxStyledTextCtrl::GetLexer() const
4001{
4370573a 4002 return SendMsg(4002, 0, 0);
67003d1a
RD
4003}
4004
4370573a 4005// Colourise a segment of the document using the current lexing language.
8e0945da
VZ
4006void wxStyledTextCtrl::Colourise(int start, int end)
4007{
4370573a
RD
4008 SendMsg(4003, start, end);
4009}
67003d1a 4010
4370573a 4011// Set up a value that may be used by a lexer for some optional feature.
8e0945da
VZ
4012void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value)
4013{
b796ba39 4014 SendMsg(4004, (sptr_t)(const char*)wx2stc(key), (sptr_t)(const char*)wx2stc(value));
f6bcfd97
BP
4015}
4016
4370573a 4017// Set up the key words used by the lexer.
8e0945da
VZ
4018void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords)
4019{
b796ba39 4020 SendMsg(4005, keywordSet, (sptr_t)(const char*)wx2stc(keyWords));
4370573a 4021}
f6bcfd97 4022
65ec6247 4023// Set the lexing language of the document based on string name.
8e0945da
VZ
4024void wxStyledTextCtrl::SetLexerLanguage(const wxString& language)
4025{
b796ba39 4026 SendMsg(4006, 0, (sptr_t)(const char*)wx2stc(language));
65ec6247
RD
4027}
4028
1e9bafca
RD
4029// Retrieve a 'property' value previously set with SetProperty.
4030wxString wxStyledTextCtrl::GetProperty(const wxString& key) {
b796ba39 4031 int len = SendMsg(SCI_GETPROPERTY, (sptr_t)(const char*)wx2stc(key), 0);
1e9bafca
RD
4032 if (!len) return wxEmptyString;
4033
4034 wxMemoryBuffer mbuf(len+1);
4035 char* buf = (char*)mbuf.GetWriteBuf(len+1);
b796ba39 4036 SendMsg(4008, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf);
1e9bafca
RD
4037 mbuf.UngetWriteBuf(len);
4038 mbuf.AppendByte(0);
4039 return stc2wx(buf);
4040}
4041
4042// Retrieve a 'property' value previously set with SetProperty,
4043// with '$()' variable replacement on returned buffer.
4044wxString wxStyledTextCtrl::GetPropertyExpanded(const wxString& key) {
b796ba39 4045 int len = SendMsg(SCI_GETPROPERTYEXPANDED, (uptr_t)(const char*)wx2stc(key), 0);
1e9bafca
RD
4046 if (!len) return wxEmptyString;
4047
4048 wxMemoryBuffer mbuf(len+1);
4049 char* buf = (char*)mbuf.GetWriteBuf(len+1);
b796ba39 4050 SendMsg(4009, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf);
1e9bafca
RD
4051 mbuf.UngetWriteBuf(len);
4052 mbuf.AppendByte(0);
4053 return stc2wx(buf);
4054}
4055
4056// Retrieve a 'property' value previously set with SetProperty,
4057// interpreted as an int AFTER any '$()' variable replacement.
8e0945da
VZ
4058int wxStyledTextCtrl::GetPropertyInt(const wxString& key) const
4059{
b796ba39 4060 return SendMsg(4010, (sptr_t)(const char*)wx2stc(key), 0);
1e9bafca
RD
4061}
4062
4063// Retrieve the number of bits the current lexer needs for styling.
8e0945da
VZ
4064int wxStyledTextCtrl::GetStyleBitsNeeded() const
4065{
1e9bafca
RD
4066 return SendMsg(4011, 0, 0);
4067}
4068
9b01abb8 4069// For private communication between an application and a known lexer.
54173563
RD
4070void* wxStyledTextCtrl::PrivateLexerCall(int operation, void* pointer) {
4071 return (void*)(sptr_t)SendMsg(4013, operation, (sptr_t)pointer);
9b01abb8
RD
4072}
4073
4074// Retrieve a '\n' separated list of properties understood by the current lexer.
4075wxString wxStyledTextCtrl::PropertyNames() const {
4076 int msg = 4014;
c4bdd822 4077 int len = SendMsg(msg, 0, (sptr_t)NULL);
9b01abb8
RD
4078 if (!len) return wxEmptyString;
4079
4080 wxMemoryBuffer mbuf(len+1);
4081 char* buf = (char*)mbuf.GetWriteBuf(len+1);
54173563 4082 SendMsg(msg, 0, (sptr_t)buf);
9b01abb8
RD
4083 mbuf.UngetWriteBuf(len);
4084 mbuf.AppendByte(0);
4085 return stc2wx(buf);
4086}
4087
4088// Retrieve the type of a property.
4089int wxStyledTextCtrl::PropertyType(const wxString& name)
4090{
4091 return SendMsg(4015, (sptr_t)(const char*)wx2stc(name), 0);
4092}
4093
4094// Describe a property.
4095wxString wxStyledTextCtrl::DescribeProperty(const wxString& name) const {
4096 int msg = 4016;
c4bdd822 4097 int len = SendMsg(msg, (sptr_t)(const char*)wx2stc(name), (sptr_t)NULL);
9b01abb8
RD
4098 if (!len) return wxEmptyString;
4099
4100 wxMemoryBuffer mbuf(len+1);
4101 char* buf = (char*)mbuf.GetWriteBuf(len+1);
4102 SendMsg(msg, (sptr_t)(const char*)wx2stc(name), (sptr_t)buf);
4103 mbuf.UngetWriteBuf(len);
4104 mbuf.AppendByte(0);
4105 return stc2wx(buf);
4106}
4107
4108// Retrieve a '\n' separated list of descriptions of the keyword sets understood by the current lexer.
4109wxString wxStyledTextCtrl::DescribeKeyWordSets() const {
4110 int msg = 4017;
c4bdd822 4111 int len = SendMsg(msg, 0, (sptr_t)NULL);
9b01abb8
RD
4112 if (!len) return wxEmptyString;
4113
4114 wxMemoryBuffer mbuf(len+1);
4115 char* buf = (char*)mbuf.GetWriteBuf(len+1);
54173563 4116 SendMsg(msg, 0, (sptr_t)buf);
9b01abb8
RD
4117 mbuf.UngetWriteBuf(len);
4118 mbuf.AppendByte(0);
4119 return stc2wx(buf);
4120}
4121
a5c2ccf2 4122//}}}
f6bcfd97 4123//----------------------------------------------------------------------
f6bcfd97
BP
4124
4125
4370573a
RD
4126// Returns the line number of the line with the caret.
4127int wxStyledTextCtrl::GetCurrentLine() {
4128 int line = LineFromPosition(GetCurrentPos());
4129 return line;
f6bcfd97
BP
4130}
4131
4132
4370573a
RD
4133// Extract style settings from a spec-string which is composed of one or
4134// more of the following comma separated elements:
4135//
4136// bold turns on bold
4137// italic turns on italics
5ee1d760
RD
4138// fore:[name or #RRGGBB] sets the foreground colour
4139// back:[name or #RRGGBB] sets the background colour
4370573a
RD
4140// face:[facename] sets the font face name to use
4141// size:[num] sets the font size in points
4142// eol turns on eol filling
4143// underline turns on underlining
4144//
4145void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
4146
451c5cc7 4147 wxStringTokenizer tkz(spec, wxT(","));
4370573a
RD
4148 while (tkz.HasMoreTokens()) {
4149 wxString token = tkz.GetNextToken();
f6bcfd97 4150
4370573a
RD
4151 wxString option = token.BeforeFirst(':');
4152 wxString val = token.AfterFirst(':');
f6bcfd97 4153
451c5cc7 4154 if (option == wxT("bold"))
4370573a 4155 StyleSetBold(styleNum, true);
f6bcfd97 4156
451c5cc7 4157 else if (option == wxT("italic"))
4370573a 4158 StyleSetItalic(styleNum, true);
9ce192d4 4159
451c5cc7 4160 else if (option == wxT("underline"))
4370573a 4161 StyleSetUnderline(styleNum, true);
9ce192d4 4162
451c5cc7 4163 else if (option == wxT("eol"))
4370573a 4164 StyleSetEOLFilled(styleNum, true);
9ce192d4 4165
451c5cc7 4166 else if (option == wxT("size")) {
4370573a
RD
4167 long points;
4168 if (val.ToLong(&points))
4169 StyleSetSize(styleNum, points);
4170 }
9ce192d4 4171
451c5cc7 4172 else if (option == wxT("face"))
4370573a 4173 StyleSetFaceName(styleNum, val);
9ce192d4 4174
451c5cc7 4175 else if (option == wxT("fore"))
4370573a 4176 StyleSetForeground(styleNum, wxColourFromSpec(val));
9ce192d4 4177
451c5cc7 4178 else if (option == wxT("back"))
4370573a
RD
4179 StyleSetBackground(styleNum, wxColourFromSpec(val));
4180 }
9ce192d4
RD
4181}
4182
4183
7e0c58e9
RD
4184// Get the font of a style
4185wxFont wxStyledTextCtrl::StyleGetFont(int style) {
4186 wxFont font;
4187 font.SetPointSize(StyleGetSize(style));
4188 font.SetFaceName(StyleGetFaceName(style));
4189 if( StyleGetBold(style) )
4190 font.SetWeight(wxFONTWEIGHT_BOLD);
4191 else
4192 font.SetWeight(wxFONTWEIGHT_NORMAL);
4193
4194 if( StyleGetItalic(style) )
4195 font.SetStyle(wxFONTSTYLE_ITALIC);
4196 else
4197 font.SetStyle(wxFONTSTYLE_NORMAL);
4198
4199 return font;
4200}
4201
4202
4370573a
RD
4203// Set style size, face, bold, italic, and underline attributes from
4204// a wxFont's attributes.
4205void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
7475e814
RD
4206#ifdef __WXGTK__
4207 // Ensure that the native font is initialized
4208 int x, y;
4209 GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font);
4210#endif
af0531a5
RD
4211 int size = font.GetPointSize();
4212 wxString faceName = font.GetFaceName();
4213 bool bold = font.GetWeight() == wxBOLD;
4214 bool italic = font.GetStyle() != wxNORMAL;
4215 bool under = font.GetUnderlined();
c5bd09bf 4216 wxFontEncoding encoding = font.GetEncoding();
7e0c58e9 4217
af0531a5 4218 StyleSetFontAttr(styleNum, size, faceName, bold, italic, under, encoding);
9ce192d4
RD
4219}
4220
4370573a
RD
4221// Set all font style attributes at once.
4222void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
4223 const wxString& faceName,
4224 bool bold, bool italic,
3727c043
RD
4225 bool underline,
4226 wxFontEncoding encoding) {
4370573a
RD
4227 StyleSetSize(styleNum, size);
4228 StyleSetFaceName(styleNum, faceName);
4229 StyleSetBold(styleNum, bold);
4230 StyleSetItalic(styleNum, italic);
4231 StyleSetUnderline(styleNum, underline);
3727c043
RD
4232 StyleSetFontEncoding(styleNum, encoding);
4233}
9ce192d4 4234
3727c043
RD
4235
4236// Set the character set of the font in a style. Converts the Scintilla
4237// character set values to a wxFontEncoding.
4238void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet)
4239{
4240 wxFontEncoding encoding;
4241
4242 // Translate the Scintilla characterSet to a wxFontEncoding
4243 switch (characterSet) {
4244 default:
4245 case wxSTC_CHARSET_ANSI:
4246 case wxSTC_CHARSET_DEFAULT:
4247 encoding = wxFONTENCODING_DEFAULT;
4248 break;
4249
4250 case wxSTC_CHARSET_BALTIC:
4251 encoding = wxFONTENCODING_ISO8859_13;
4252 break;
4253
4254 case wxSTC_CHARSET_CHINESEBIG5:
4255 encoding = wxFONTENCODING_CP950;
4256 break;
4257
4258 case wxSTC_CHARSET_EASTEUROPE:
4259 encoding = wxFONTENCODING_ISO8859_2;
4260 break;
4261
4262 case wxSTC_CHARSET_GB2312:
4263 encoding = wxFONTENCODING_CP936;
4264 break;
4265
4266 case wxSTC_CHARSET_GREEK:
4267 encoding = wxFONTENCODING_ISO8859_7;
4268 break;
4269
4270 case wxSTC_CHARSET_HANGUL:
4271 encoding = wxFONTENCODING_CP949;
4272 break;
4273
4274 case wxSTC_CHARSET_MAC:
4275 encoding = wxFONTENCODING_DEFAULT;
4276 break;
4277
4278 case wxSTC_CHARSET_OEM:
4279 encoding = wxFONTENCODING_DEFAULT;
4280 break;
4281
4282 case wxSTC_CHARSET_RUSSIAN:
4283 encoding = wxFONTENCODING_KOI8;
4284 break;
4285
4286 case wxSTC_CHARSET_SHIFTJIS:
4287 encoding = wxFONTENCODING_CP932;
4288 break;
4289
4290 case wxSTC_CHARSET_SYMBOL:
4291 encoding = wxFONTENCODING_DEFAULT;
4292 break;
4293
4294 case wxSTC_CHARSET_TURKISH:
4295 encoding = wxFONTENCODING_ISO8859_9;
4296 break;
4297
4298 case wxSTC_CHARSET_JOHAB:
4299 encoding = wxFONTENCODING_DEFAULT;
4300 break;
4301
4302 case wxSTC_CHARSET_HEBREW:
4303 encoding = wxFONTENCODING_ISO8859_8;
4304 break;
4305
4306 case wxSTC_CHARSET_ARABIC:
4307 encoding = wxFONTENCODING_ISO8859_6;
4308 break;
4309
4310 case wxSTC_CHARSET_VIETNAMESE:
4311 encoding = wxFONTENCODING_DEFAULT;
4312 break;
4313
4314 case wxSTC_CHARSET_THAI:
4315 encoding = wxFONTENCODING_ISO8859_11;
4316 break;
1e9bafca
RD
4317
4318 case wxSTC_CHARSET_CYRILLIC:
4319 encoding = wxFONTENCODING_ISO8859_5;
4320 break;
7e0c58e9 4321
1e9bafca
RD
4322 case wxSTC_CHARSET_8859_15:
4323 encoding = wxFONTENCODING_ISO8859_15;;
4324 break;
3727c043
RD
4325 }
4326
4327 // We just have Scintilla track the wxFontEncoding for us. It gets used
4328 // in Font::Create in PlatWX.cpp. We add one to the value so that the
4329 // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
4330 // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
4331 // to wxFONENCODING_DEFAULT in Font::Create.
4332 SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
4333}
4334
4335
4336// Set the font encoding to be used by a style.
4337void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding)
4338{
4339 SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
9ce192d4
RD
4340}
4341
4342
4370573a
RD
4343// Perform one of the operations defined by the wxSTC_CMD_* constants.
4344void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
4345 SendMsg(cmd);
9ce192d4
RD
4346}
4347
4348
4370573a
RD
4349// Set the left and right margin in the edit area, measured in pixels.
4350void wxStyledTextCtrl::SetMargins(int left, int right) {
4351 SetMarginLeft(left);
4352 SetMarginRight(right);
9ce192d4
RD
4353}
4354
4355
4370573a
RD
4356// Retrieve the point in the window where a position is displayed.
4357wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
4358 int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
4359 int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
4360 return wxPoint(x, y);
f6bcfd97
BP
4361}
4362
f97d84a6
RD
4363// Scroll enough to make the given line visible
4364void wxStyledTextCtrl::ScrollToLine(int line) {
4365 m_swx->DoScrollToLine(line);
4366}
4367
4368
4369// Scroll enough to make the given column visible
4370void wxStyledTextCtrl::ScrollToColumn(int column) {
4371 m_swx->DoScrollToColumn(column);
4372}
4373
f6bcfd97 4374
2bfca191 4375#if wxUSE_TEXTCTRL
3396739d
VZ
4376bool wxStyledTextCtrl::DoSaveFile(const wxString& filename, int fileType)
4377{
4378 bool ok = wxTextAreaBase::DoSaveFile(filename, fileType);
2bfca191 4379#else
51566b0b
RD
4380bool wxStyledTextCtrl::SaveFile(const wxString& filename)
4381{
3396739d
VZ
4382#if wxUSE_FFILE
4383 wxFFile file(filename, wxT("w"));
4384 bool ok = file.IsOpened() && file.Write(GetValue(), *wxConvCurrent);
4385#else
4386 bool ok = false;
4387#endif // wxUSE_FFILE
4388#endif
4389 if (ok)
4390 {
51566b0b 4391 SetSavePoint();
3396739d
VZ
4392 }
4393 return ok;
51566b0b
RD
4394}
4395
2bfca191 4396#if wxUSE_TEXTCTRL
3396739d
VZ
4397bool wxStyledTextCtrl::DoLoadFile(const wxString& filename, int fileType)
4398{
4399 bool ok = wxTextAreaBase::DoLoadFile(filename, fileType);
2bfca191 4400#else
51566b0b
RD
4401bool wxStyledTextCtrl::LoadFile(const wxString& filename)
4402{
3396739d
VZ
4403#if wxUSE_FFILE
4404 wxFFile file(filename);
4405 bool ok = file.IsOpened();
4406 if (ok)
51566b0b 4407 {
3396739d
VZ
4408 wxString text;
4409 ok = file.ReadAll(&text, *wxConvCurrent);
4410 if (ok)
041973c5 4411 {
3396739d 4412 SetValue(text);
041973c5 4413 }
51566b0b 4414 }
3396739d
VZ
4415#else
4416 bool ok = false;
4417#endif // wxUSE_FFILE
4418#endif
4419 if (ok)
4420 {
4421 EmptyUndoBuffer();
4422 SetSavePoint();
4423 }
4424 return ok;
51566b0b
RD
4425}
4426
2fcce896 4427#if wxUSE_DRAG_AND_DROP
7e126a07
WS
4428wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
4429 return m_swx->DoDragOver(x, y, def);
4430}
4a65f2c8
RD
4431
4432
7e126a07 4433bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) {
4a65f2c8
RD
4434 return m_swx->DoDropText(x, y, data);
4435}
2fcce896 4436#endif
4a65f2c8
RD
4437
4438
d1558f3d
RD
4439void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) {
4440 m_swx->SetUseAntiAliasing(useAA);
4441}
4442
4443bool wxStyledTextCtrl::GetUseAntiAliasing() {
4444 return m_swx->GetUseAntiAliasing();
4445}
4446
41a499cd
RD
4447
4448
4449
4450
6f67e6d2 4451void wxStyledTextCtrl::AddTextRaw(const char* text, int length)
41a499cd 4452{
6f67e6d2
RD
4453 if (length == -1)
4454 length = strlen(text);
4455 SendMsg(SCI_ADDTEXT, length, (sptr_t)text);
41a499cd
RD
4456}
4457
4458void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text)
4459{
b796ba39 4460 SendMsg(SCI_INSERTTEXT, pos, (sptr_t)text);
41a499cd
RD
4461}
4462
4463wxCharBuffer wxStyledTextCtrl::GetCurLineRaw(int* linePos)
4464{
4465 int len = LineLength(GetCurrentLine());
4466 if (!len) {
4467 if (linePos) *linePos = 0;
4468 wxCharBuffer empty;
4469 return empty;
4470 }
4471
4472 wxCharBuffer buf(len);
b796ba39 4473 int pos = SendMsg(SCI_GETCURLINE, len, (sptr_t)buf.data());
41a499cd
RD
4474 if (linePos) *linePos = pos;
4475 return buf;
4476}
4477
4478wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line)
4479{
4480 int len = LineLength(line);
4481 if (!len) {
4482 wxCharBuffer empty;
4483 return empty;
4484 }
4485
4486 wxCharBuffer buf(len);
b796ba39 4487 SendMsg(SCI_GETLINE, line, (sptr_t)buf.data());
41a499cd
RD
4488 return buf;
4489}
4490
4491wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw()
4492{
1a692f0f
VZ
4493 // Calculate the length needed first.
4494 const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0);
41a499cd 4495
1a692f0f 4496 // And then really get the data.
41a499cd 4497 wxCharBuffer buf(len);
b796ba39 4498 SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data());
41a499cd
RD
4499 return buf;
4500}
4501
4502wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos)
4503{
4504 if (endPos < startPos) {
4505 int temp = startPos;
4506 startPos = endPos;
4507 endPos = temp;
4508 }
4509 int len = endPos - startPos;
4510 if (!len) {
4511 wxCharBuffer empty;
4512 return empty;
7e0c58e9 4513 }
41a499cd
RD
4514
4515 wxCharBuffer buf(len);
4516 TextRange tr;
4517 tr.lpstrText = buf.data();
4518 tr.chrg.cpMin = startPos;
4519 tr.chrg.cpMax = endPos;
b796ba39 4520 SendMsg(SCI_GETTEXTRANGE, 0, (sptr_t)&tr);
41a499cd
RD
4521 return buf;
4522}
4523
4524void wxStyledTextCtrl::SetTextRaw(const char* text)
4525{
b796ba39 4526 SendMsg(SCI_SETTEXT, 0, (sptr_t)text);
41a499cd
RD
4527}
4528
4529wxCharBuffer wxStyledTextCtrl::GetTextRaw()
4530{
949750de
VZ
4531 int len = GetTextLength();
4532 wxCharBuffer buf(len); // adds 1 for NUL automatically
b796ba39 4533 SendMsg(SCI_GETTEXT, len + 1, (sptr_t)buf.data());
41a499cd
RD
4534 return buf;
4535}
4536
6f67e6d2 4537void wxStyledTextCtrl::AppendTextRaw(const char* text, int length)
41a499cd 4538{
6f67e6d2
RD
4539 if (length == -1)
4540 length = strlen(text);
4541 SendMsg(SCI_APPENDTEXT, length, (sptr_t)text);
41a499cd
RD
4542}
4543
4544
4545
4546
4547
9ce192d4
RD
4548//----------------------------------------------------------------------
4549// Event handlers
4550
88a8b04e 4551void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
9ce192d4 4552 wxPaintDC dc(this);
9e730a78 4553 m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
9ce192d4
RD
4554}
4555
4556void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) {
4557 if (evt.GetOrientation() == wxHORIZONTAL)
4558 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
4559 else
4560 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
4561}
4562
5fa4613c
RD
4563void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
4564 wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar);
4565 if (sb) {
4566 if (sb->IsVertical())
4567 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
4568 else
4569 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
4570 }
4571}
4572
88a8b04e 4573void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) {
39c0acb6
RD
4574 if (m_swx) {
4575 wxSize sz = GetClientSize();
4576 m_swx->DoSize(sz.x, sz.y);
4577 }
9ce192d4
RD
4578}
4579
4580void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
cb1871ca 4581 SetFocus();
9ce192d4 4582 wxPoint pt = evt.GetPosition();
2b5f62a0 4583 m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
9ce192d4
RD
4584 evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
4585}
4586
4587void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
4588 wxPoint pt = evt.GetPosition();
2b5f62a0 4589 m_swx->DoLeftButtonMove(Point(pt.x, pt.y));
9ce192d4
RD
4590}
4591
4592void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
4593 wxPoint pt = evt.GetPosition();
2b5f62a0 4594 m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
9ce192d4
RD
4595 evt.ControlDown());
4596}
4597
4598
ddf2da08
RD
4599void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
4600 wxPoint pt = evt.GetPosition();
4601 m_swx->DoContextMenu(Point(pt.x, pt.y));
4602}
4603
4604
2b5f62a0
VZ
4605void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) {
4606 wxPoint pt = evt.GetPosition();
4607 m_swx->DoMiddleButtonUp(Point(pt.x, pt.y));
4608}
4609
65ec6247 4610void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
9ce192d4 4611 wxPoint pt = evt.GetPosition();
65ec6247 4612 ScreenToClient(&pt.x, &pt.y);
25484746
RD
4613 /*
4614 Show context menu at event point if it's within the window,
4615 or at caret location if not
4616 */
4617 wxHitTest ht = this->HitTest(pt);
4618 if (ht != wxHT_WINDOW_INSIDE) {
4619 pt = this->PointFromPosition(this->GetCurrentPos());
4620 }
9ce192d4
RD
4621 m_swx->DoContextMenu(Point(pt.x, pt.y));
4622}
4623
37d62433 4624
60957703
VZ
4625void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt)
4626{
42a4299b
VZ
4627 m_swx->DoMouseWheel(evt.GetWheelRotation(),
4628 evt.GetWheelDelta(),
4629 evt.GetLinesPerAction(),
4630 evt.ControlDown(),
4631 evt.IsPageScroll());
37d62433
RD
4632}
4633
4634
9ce192d4 4635void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
5fd656d5 4636 // On (some?) non-US PC keyboards the AltGr key is required to enter some
f3c2c221
RD
4637 // common characters. It comes to us as both Alt and Ctrl down so we need
4638 // to let the char through in that case, otherwise if only ctrl or only
4639 // alt let's skip it.
4640 bool ctrl = evt.ControlDown();
28e0c28e
RD
4641#ifdef __WXMAC__
4642 // On the Mac the Alt key is just a modifier key (like Shift) so we need
4643 // to allow the char events to be processed when Alt is pressed.
4644 // TODO: Should we check MetaDown instead in this case?
4645 bool alt = false;
4646#else
f3c2c221 4647 bool alt = evt.AltDown();
28e0c28e 4648#endif
00c64037 4649 bool skip = ((ctrl || alt) && ! (ctrl && alt));
f3c2c221 4650
a0421c77
RD
4651#if wxUSE_UNICODE
4652 // apparently if we don't do this, Unicode keys pressed after non-char
4653 // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989)
4654 if (m_lastKeyDownConsumed && evt.GetUnicodeKey() > 255)
4655 m_lastKeyDownConsumed = false;
4656#endif
4657
5fd656d5
RD
4658 if (!m_lastKeyDownConsumed && !skip) {
4659#if wxUSE_UNICODE
4660 int key = evt.GetUnicodeKey();
4661 bool keyOk = true;
4662
4663 // if the unicode key code is not really a unicode character (it may
4664 // be a function key or etc., the platforms appear to always give us a
4665 // small value in this case) then fallback to the ascii key code but
4666 // don't do anything for function keys or etc.
1b14227e 4667 if (key <= 127) {
5fd656d5 4668 key = evt.GetKeyCode();
1b14227e 4669 keyOk = (key <= 127);
5fd656d5
RD
4670 }
4671 if (keyOk) {
4672 m_swx->DoAddChar(key);
4673 return;
4674 }
4675#else
4676 int key = evt.GetKeyCode();
4677 if (key <= WXK_START || key > WXK_COMMAND) {
4678 m_swx->DoAddChar(key);
4679 return;
4680 }
4681#endif
d25f5fbb 4682 }
7e0c58e9 4683
f3c2c221 4684 evt.Skip();
f6bcfd97
BP
4685}
4686
d6582821 4687
f6bcfd97 4688void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
5fd656d5 4689 int processed = m_swx->DoKeyDown(evt, &m_lastKeyDownConsumed);
d6582821 4690 if (!processed && !m_lastKeyDownConsumed)
9ce192d4
RD
4691 evt.Skip();
4692}
4693
d6582821 4694
b6bfd8e8 4695void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
ec830416 4696 m_swx->DoLoseFocus();
b6bfd8e8 4697 evt.Skip();
9ce192d4
RD
4698}
4699
d6582821 4700
b6bfd8e8 4701void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
9ce192d4 4702 m_swx->DoGainFocus();
b6bfd8e8 4703 evt.Skip();
9ce192d4
RD
4704}
4705
d6582821 4706
88a8b04e 4707void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) {
9ce192d4
RD
4708 m_swx->DoSysColourChange();
4709}
4710
d6582821 4711
88a8b04e 4712void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) {
9ce192d4
RD
4713 // do nothing to help avoid flashing
4714}
4715
4716
4717
4718void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
4719 m_swx->DoCommand(evt.GetId());
4720}
4721
4722
88a8b04e 4723void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) {
f6bcfd97
BP
4724 m_swx->DoOnListBox();
4725}
4726
4727
8e54aaed
RD
4728void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) {
4729 m_swx->DoOnIdle(evt);
4730}
4731
4732
8ae4f086
RD
4733wxSize wxStyledTextCtrl::DoGetBestSize() const
4734{
4735 // What would be the best size for a wxSTC?
4736 // Just give a reasonable minimum until something else can be figured out.
4737 return wxSize(200,100);
4738}
4739
4740
9ce192d4
RD
4741//----------------------------------------------------------------------
4742// Turn notifications from Scintilla into events
4743
f6bcfd97 4744
9ce192d4
RD
4745void wxStyledTextCtrl::NotifyChange() {
4746 wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId());
a29a241f 4747 evt.SetEventObject(this);
9ce192d4
RD
4748 GetEventHandler()->ProcessEvent(evt);
4749}
4750
2b5f62a0
VZ
4751
4752static void SetEventText(wxStyledTextEvent& evt, const char* text,
4753 size_t length) {
4754 if(!text) return;
4755
1c930beb 4756 evt.SetText(stc2wx(text, length));
2b5f62a0
VZ
4757}
4758
4759
9ce192d4
RD
4760void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
4761 SCNotification& scn = *_scn;
65ec6247
RD
4762 wxStyledTextEvent evt(0, GetId());
4763
a29a241f 4764 evt.SetEventObject(this);
65ec6247
RD
4765 evt.SetPosition(scn.position);
4766 evt.SetKey(scn.ch);
4767 evt.SetModifiers(scn.modifiers);
4768
9ce192d4
RD
4769 switch (scn.nmhdr.code) {
4770 case SCN_STYLENEEDED:
65ec6247 4771 evt.SetEventType(wxEVT_STC_STYLENEEDED);
9ce192d4 4772 break;
65ec6247 4773
9ce192d4 4774 case SCN_CHARADDED:
65ec6247 4775 evt.SetEventType(wxEVT_STC_CHARADDED);
9ce192d4 4776 break;
65ec6247 4777
9ce192d4 4778 case SCN_SAVEPOINTREACHED:
65ec6247 4779 evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED);
9ce192d4 4780 break;
65ec6247 4781
9ce192d4 4782 case SCN_SAVEPOINTLEFT:
65ec6247 4783 evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT);
9ce192d4 4784 break;
65ec6247 4785
9ce192d4 4786 case SCN_MODIFYATTEMPTRO:
65ec6247 4787 evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT);
9ce192d4 4788 break;
65ec6247
RD
4789
4790 case SCN_KEY:
4791 evt.SetEventType(wxEVT_STC_KEY);
4792 break;
4793
9ce192d4 4794 case SCN_DOUBLECLICK:
65ec6247 4795 evt.SetEventType(wxEVT_STC_DOUBLECLICK);
54173563 4796 evt.SetLine(scn.line);
9ce192d4 4797 break;
65ec6247
RD
4798
4799 case SCN_UPDATEUI:
4800 evt.SetEventType(wxEVT_STC_UPDATEUI);
54173563 4801 evt.SetUpdated(scn.updated);
9ce192d4 4802 break;
65ec6247
RD
4803
4804 case SCN_MODIFIED:
4805 evt.SetEventType(wxEVT_STC_MODIFIED);
4806 evt.SetModificationType(scn.modificationType);
2b5f62a0 4807 SetEventText(evt, scn.text, scn.length);
65ec6247
RD
4808 evt.SetLength(scn.length);
4809 evt.SetLinesAdded(scn.linesAdded);
4810 evt.SetLine(scn.line);
4811 evt.SetFoldLevelNow(scn.foldLevelNow);
4812 evt.SetFoldLevelPrev(scn.foldLevelPrev);
54173563
RD
4813 evt.SetToken(scn.token);
4814 evt.SetAnnotationLinesAdded(scn.annotationLinesAdded);
9ce192d4 4815 break;
65ec6247 4816
9ce192d4 4817 case SCN_MACRORECORD:
65ec6247
RD
4818 evt.SetEventType(wxEVT_STC_MACRORECORD);
4819 evt.SetMessage(scn.message);
4820 evt.SetWParam(scn.wParam);
4821 evt.SetLParam(scn.lParam);
9ce192d4 4822 break;
65ec6247 4823
9ce192d4 4824 case SCN_MARGINCLICK:
65ec6247
RD
4825 evt.SetEventType(wxEVT_STC_MARGINCLICK);
4826 evt.SetMargin(scn.margin);
9ce192d4 4827 break;
65ec6247 4828
9ce192d4 4829 case SCN_NEEDSHOWN:
65ec6247
RD
4830 evt.SetEventType(wxEVT_STC_NEEDSHOWN);
4831 evt.SetLength(scn.length);
9ce192d4 4832 break;
65ec6247 4833
65ec6247
RD
4834 case SCN_PAINTED:
4835 evt.SetEventType(wxEVT_STC_PAINTED);
4836 break;
4837
0daf5e6b
RD
4838 case SCN_AUTOCSELECTION:
4839 evt.SetEventType(wxEVT_STC_AUTOCOMP_SELECTION);
4840 evt.SetListType(scn.listType);
4841 SetEventText(evt, scn.text, strlen(scn.text));
4842 evt.SetPosition(scn.lParam);
4843 break;
7e0c58e9 4844
65ec6247
RD
4845 case SCN_USERLISTSELECTION:
4846 evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
4847 evt.SetListType(scn.listType);
2b5f62a0 4848 SetEventText(evt, scn.text, strlen(scn.text));
0daf5e6b 4849 evt.SetPosition(scn.lParam);
65ec6247
RD
4850 break;
4851
4852 case SCN_URIDROPPED:
4853 evt.SetEventType(wxEVT_STC_URIDROPPED);
2b5f62a0 4854 SetEventText(evt, scn.text, strlen(scn.text));
65ec6247
RD
4855 break;
4856
4857 case SCN_DWELLSTART:
4858 evt.SetEventType(wxEVT_STC_DWELLSTART);
4859 evt.SetX(scn.x);
4860 evt.SetY(scn.y);
4861 break;
4862
4863 case SCN_DWELLEND:
4864 evt.SetEventType(wxEVT_STC_DWELLEND);
4865 evt.SetX(scn.x);
4866 evt.SetY(scn.y);
4867 break;
4868
a834585d
RD
4869 case SCN_ZOOM:
4870 evt.SetEventType(wxEVT_STC_ZOOM);
4871 break;
4872
9e730a78
RD
4873 case SCN_HOTSPOTCLICK:
4874 evt.SetEventType(wxEVT_STC_HOTSPOT_CLICK);
4875 break;
4876
4877 case SCN_HOTSPOTDOUBLECLICK:
4878 evt.SetEventType(wxEVT_STC_HOTSPOT_DCLICK);
4879 break;
4880
4881 case SCN_CALLTIPCLICK:
4882 evt.SetEventType(wxEVT_STC_CALLTIP_CLICK);
4883 break;
7e0c58e9
RD
4884
4885 case SCN_INDICATORCLICK:
4886 evt.SetEventType(wxEVT_STC_INDICATOR_CLICK);
4887 break;
4888
4889 case SCN_INDICATORRELEASE:
4890 evt.SetEventType(wxEVT_STC_INDICATOR_RELEASE);
4891 break;
4892
9e96e16f
RD
4893 case SCN_AUTOCCANCELLED:
4894 evt.SetEventType(wxEVT_STC_AUTOCOMP_CANCELLED);
4895 break;
4896
4897 case SCN_AUTOCCHARDELETED:
4898 evt.SetEventType(wxEVT_STC_AUTOCOMP_CHAR_DELETED);
4899 break;
4900
54173563
RD
4901 case SCN_HOTSPOTRELEASECLICK:
4902 evt.SetEventType(wxEVT_STC_HOTSPOT_RELEASE_CLICK);
4903 break;
4904
65ec6247
RD
4905 default:
4906 return;
9ce192d4 4907 }
65ec6247
RD
4908
4909 GetEventHandler()->ProcessEvent(evt);
9ce192d4
RD
4910}
4911
4912
9ce192d4
RD
4913//----------------------------------------------------------------------
4914//----------------------------------------------------------------------
4915//----------------------------------------------------------------------
4916
4917wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
4918 : wxCommandEvent(commandType, id)
4919{
4920 m_position = 0;
4921 m_key = 0;
4922 m_modifiers = 0;
4923 m_modificationType = 0;
4924 m_length = 0;
4925 m_linesAdded = 0;
4926 m_line = 0;
4927 m_foldLevelNow = 0;
4928 m_foldLevelPrev = 0;
4929 m_margin = 0;
4930 m_message = 0;
4931 m_wParam = 0;
4932 m_lParam = 0;
65ec6247
RD
4933 m_listType = 0;
4934 m_x = 0;
4935 m_y = 0;
d01ca1e4
RD
4936 m_token = 0;
4937 m_annotationLinesAdded = 0;
4938 m_updated = 0;
4939
92bbd64f 4940#if wxUSE_DRAG_AND_DROP
35f8d83d 4941 m_dragFlags = wxDrag_CopyOnly;
a29a241f 4942 m_dragResult = wxDragNone;
92bbd64f 4943#endif
9ce192d4
RD
4944}
4945
4946bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
4947bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; }
4948bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; }
4949
5fa4613c 4950
41286fd1
JS
4951wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event):
4952 wxCommandEvent(event)
4953{
4954 m_position = event.m_position;
4955 m_key = event.m_key;
4956 m_modifiers = event.m_modifiers;
4957 m_modificationType = event.m_modificationType;
4958 m_text = event.m_text;
4959 m_length = event.m_length;
4960 m_linesAdded = event.m_linesAdded;
4961 m_line = event.m_line;
4962 m_foldLevelNow = event.m_foldLevelNow;
4963 m_foldLevelPrev = event.m_foldLevelPrev;
4964
4965 m_margin = event.m_margin;
4966
4967 m_message = event.m_message;
4968 m_wParam = event.m_wParam;
4969 m_lParam = event.m_lParam;
4970
4971 m_listType = event.m_listType;
4972 m_x = event.m_x;
4973 m_y = event.m_y;
9ce192d4 4974
d01ca1e4
RD
4975 m_token = event.m_token;
4976 m_annotationLinesAdded = event.m_annotationLinesAdded;
4977 m_updated = event.m_updated;
4978
92bbd64f 4979#if wxUSE_DRAG_AND_DROP
35f8d83d
VZ
4980 m_dragText = event.m_dragText;
4981 m_dragFlags = event.m_dragFlags;
41286fd1 4982 m_dragResult = event.m_dragResult;
92bbd64f 4983#endif
9ce192d4
RD
4984}
4985
4986//----------------------------------------------------------------------
4987//----------------------------------------------------------------------
4988
ccec9093
VZ
4989/*static*/ wxVersionInfo wxStyledTextCtrl::GetLibraryVersionInfo()
4990{
d01ca1e4 4991 return wxVersionInfo("Scintilla", 3, 21, 0, "Scintilla 3.21");
ccec9093
VZ
4992}
4993
29825f5f 4994#endif // wxUSE_STC