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