]> git.saurik.com Git - wxWidgets.git/blame - contrib/src/stc/stc.cpp
wxWindowMSW now eats EVT_CHAR if the key was handled in EVT_KEY_DOWN
[wxWidgets.git] / contrib / src / stc / stc.cpp
CommitLineData
9ce192d4
RD
1////////////////////////////////////////////////////////////////////////////
2// Name: stc.cpp
3// Purpose: A wxWindows implementation of Scintilla. This class is the
4// one meant to be used directly by wx applications. It does not
5// derive directly from the Scintilla classes, but instead
6// delegates most things to the real Scintilla class.
7// This allows the use of Scintilla without polluting the
f6bcfd97 8// namespace with all the classes and identifiers from Scintilla.
9ce192d4
RD
9//
10// Author: Robin Dunn
11//
12// Created: 13-Jan-2000
13// RCS-ID: $Id$
14// Copyright: (c) 2000 by Total Control Software
15// Licence: wxWindows license
16/////////////////////////////////////////////////////////////////////////////
17
f6bcfd97
BP
18#include <ctype.h>
19
9ce192d4
RD
20#include "wx/stc/stc.h"
21#include "ScintillaWX.h"
22
23#include <wx/tokenzr.h>
24
f6bcfd97 25
9ce192d4
RD
26//----------------------------------------------------------------------
27
10ef30eb 28const wxChar* wxSTCNameStr = wxT("stcwindow");
9ce192d4 29
d25f5fbb
RD
30DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE )
31DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED )
32DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED )
d25f5fbb
RD
33DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED )
34DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT )
35DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT )
65ec6247 36DEFINE_EVENT_TYPE( wxEVT_STC_KEY )
d25f5fbb 37DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK )
65ec6247 38DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI )
d25f5fbb 39DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED )
d25f5fbb
RD
40DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD )
41DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK )
42DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN )
43DEFINE_EVENT_TYPE( wxEVT_STC_POSCHANGED )
65ec6247
RD
44DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED )
45DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION )
46DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED )
47DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART )
48DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND )
a29a241f
RD
49DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG )
50DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER )
51DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP )
d25f5fbb
RD
52
53
9ce192d4
RD
54BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
55 EVT_PAINT (wxStyledTextCtrl::OnPaint)
56 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin)
5fa4613c 57 EVT_SCROLL (wxStyledTextCtrl::OnScroll)
9ce192d4
RD
58 EVT_SIZE (wxStyledTextCtrl::OnSize)
59 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
4ceb1196
RD
60#ifdef __WXMSW__
61 // Let Scintilla see the double click as a second click
62 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
63#endif
9ce192d4
RD
64 EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
65 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
ddf2da08
RD
66#ifdef __WXGTK__
67 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
68#else
65ec6247 69 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
ddf2da08 70#endif
37d62433 71 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
9ce192d4 72 EVT_CHAR (wxStyledTextCtrl::OnChar)
f6bcfd97 73 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
9ce192d4
RD
74 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
75 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus)
76 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
77 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
78 EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu)
f6bcfd97 79 EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox)
9ce192d4
RD
80END_EVENT_TABLE()
81
f6bcfd97
BP
82
83IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
84IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
85
1a2fb4cd
RD
86// forces the linking of the lexer modules
87int Scintilla_LinkLexers();
88
9ce192d4
RD
89//----------------------------------------------------------------------
90// Constructor and Destructor
91
92wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
93 wxWindowID id,
94 const wxPoint& pos,
95 const wxSize& size,
96 long style,
97 const wxString& name) :
98 wxControl(parent, id, pos, size,
f97d84a6 99 style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN,
9ce192d4
RD
100 wxDefaultValidator, name)
101{
1a2fb4cd 102 Scintilla_LinkLexers();
9ce192d4 103 m_swx = new ScintillaWX(this);
9ce192d4 104 m_stopWatch.Start();
d6582821 105 m_lastKeyDownConsumed = FALSE;
5fa4613c
RD
106 m_vScrollBar = NULL;
107 m_hScrollBar = NULL;
10ef30eb
RD
108#if wxUSE_UNICODE
109 // Put Scintilla into unicode (UTF-8) mode
110 SetCodePage(wxSTC_CP_UTF8);
111#endif
9ce192d4
RD
112}
113
114
115wxStyledTextCtrl::~wxStyledTextCtrl() {
116 delete m_swx;
9ce192d4
RD
117}
118
119
120//----------------------------------------------------------------------
121
f6bcfd97 122long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) {
9ce192d4
RD
123
124 return m_swx->WndProc(msg, wp, lp);
125}
126
127
f97d84a6
RD
128#ifdef MAKELONG
129#undef MAKELONG
130#endif
131
4370573a 132#define MAKELONG(a, b) ((a) | ((b) << 16))
9ce192d4
RD
133
134
4370573a
RD
135static long wxColourAsLong(const wxColour& co) {
136 return (((long)co.Blue() << 16) |
137 ((long)co.Green() << 8) |
138 ((long)co.Red()));
9ce192d4
RD
139}
140
4370573a
RD
141static wxColour wxColourFromLong(long c) {
142 wxColour clr;
143 clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff);
144 return clr;
9ce192d4
RD
145}
146
147
4370573a 148static wxColour wxColourFromSpec(const wxString& spec) {
10ef30eb
RD
149 // spec should be "#RRGGBB"
150 long red, green, blue;
151 red = green = blue = 0;
152 spec.Mid(1,2).ToLong(&red, 16);
153 spec.Mid(3,2).ToLong(&green, 16);
154 spec.Mid(5,2).ToLong(&blue, 16);
4370573a 155 return wxColour(red, green, blue);
9ce192d4
RD
156}
157
158
4370573a
RD
159//----------------------------------------------------------------------
160// BEGIN generated section. The following code is automatically generated
161// by gen_iface.py from the contents of Scintilla.iface. Do not edit
162// this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
9ce192d4
RD
163
164
4370573a 165// Add text to the document
9ce192d4 166void wxStyledTextCtrl::AddText(const wxString& text) {
10ef30eb
RD
167 wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
168 SendMsg(2001, strlen(buf), (long)(const char*)buf);
9ce192d4
RD
169}
170
4370573a 171// Add array of cells to document
10ef30eb
RD
172void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer& data) {
173 SendMsg(2002, data.GetDataLen(), (long)data.GetData());
9ce192d4
RD
174}
175
4370573a 176// Insert string at a position
9ce192d4 177void wxStyledTextCtrl::InsertText(int pos, const wxString& text) {
10ef30eb 178 SendMsg(2003, pos, (long)(const char*)text.mb_str(wxConvUTF8));
9ce192d4
RD
179}
180
4370573a 181// Delete all text in the document
9ce192d4 182void wxStyledTextCtrl::ClearAll() {
4370573a 183 SendMsg(2004, 0, 0);
9ce192d4
RD
184}
185
4370573a
RD
186// Set all style bytes to 0, remove all folding information
187void wxStyledTextCtrl::ClearDocumentStyle() {
188 SendMsg(2005, 0, 0);
9ce192d4
RD
189}
190
4370573a
RD
191// The number of characters in the document
192int wxStyledTextCtrl::GetLength() {
193 return SendMsg(2006, 0, 0);
9ce192d4
RD
194}
195
4370573a
RD
196// Returns the character byte at the position
197int wxStyledTextCtrl::GetCharAt(int pos) {
198 return SendMsg(2007, pos, 0);
9ce192d4
RD
199}
200
4370573a
RD
201// Returns the position of the caret
202int wxStyledTextCtrl::GetCurrentPos() {
203 return SendMsg(2008, 0, 0);
9ce192d4
RD
204}
205
4370573a
RD
206// Returns the position of the opposite end of the selection to the caret
207int wxStyledTextCtrl::GetAnchor() {
208 return SendMsg(2009, 0, 0);
9ce192d4
RD
209}
210
4370573a
RD
211// Returns the style byte at the position
212int wxStyledTextCtrl::GetStyleAt(int pos) {
213 return SendMsg(2010, pos, 0);
9ce192d4
RD
214}
215
4370573a 216// Redoes the next action on the undo history
9ce192d4 217void wxStyledTextCtrl::Redo() {
4370573a 218 SendMsg(2011, 0, 0);
9ce192d4
RD
219}
220
4370573a
RD
221// Choose between collecting actions into the undo
222// history and discarding them.
223void wxStyledTextCtrl::SetUndoCollection(bool collectUndo) {
224 SendMsg(2012, collectUndo, 0);
9ce192d4
RD
225}
226
4370573a
RD
227// Select all the text in the document.
228void wxStyledTextCtrl::SelectAll() {
229 SendMsg(2013, 0, 0);
9ce192d4
RD
230}
231
4370573a
RD
232// Remember the current position in the undo history as the position
233// at which the document was saved.
234void wxStyledTextCtrl::SetSavePoint() {
235 SendMsg(2014, 0, 0);
9ce192d4
RD
236}
237
4370573a 238// Retrieve a buffer of cells.
10ef30eb
RD
239wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) {
240 wxMemoryBuffer buf;
e1a93f46
RD
241 if (endPos < startPos) {
242 int temp = startPos;
243 startPos = endPos;
244 endPos = temp;
245 }
4370573a 246 int len = endPos - startPos;
10ef30eb 247 if (!len) return buf;
4370573a 248 TextRange tr;
10ef30eb 249 tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
4370573a
RD
250 tr.chrg.cpMin = startPos;
251 tr.chrg.cpMax = endPos;
10ef30eb
RD
252 len = SendMsg(2015, 0, (long)&tr);
253 buf.UngetWriteBuf(len);
254 return buf;
9ce192d4
RD
255}
256
4370573a
RD
257// Are there any redoable actions in the undo history.
258bool wxStyledTextCtrl::CanRedo() {
259 return SendMsg(2016, 0, 0) != 0;
9ce192d4
RD
260}
261
4370573a
RD
262// Retrieve the line number at which a particular marker is located
263int wxStyledTextCtrl::MarkerLineFromHandle(int handle) {
264 return SendMsg(2017, handle, 0);
9ce192d4
RD
265}
266
4370573a
RD
267// Delete a marker.
268void wxStyledTextCtrl::MarkerDeleteHandle(int handle) {
269 SendMsg(2018, handle, 0);
9ce192d4
RD
270}
271
4370573a
RD
272// Is undo history being collected?
273bool wxStyledTextCtrl::GetUndoCollection() {
274 return SendMsg(2019, 0, 0) != 0;
9ce192d4
RD
275}
276
4370573a
RD
277// Are white space characters currently visible?
278// Returns one of SCWS_* constants.
279int wxStyledTextCtrl::GetViewWhiteSpace() {
280 return SendMsg(2020, 0, 0);
9ce192d4
RD
281}
282
4370573a
RD
283// Make white space characters invisible, always visible or visible outside indentation.
284void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS) {
285 SendMsg(2021, viewWS, 0);
9ce192d4
RD
286}
287
4370573a 288// Find the position from a point within the window.
9ce192d4 289int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) {
4370573a 290 return SendMsg(2022, pt.x, pt.y);
9ce192d4
RD
291}
292
65ec6247
RD
293// Find the position from a point within the window but return
294// INVALID_POSITION if not close to text.
295int wxStyledTextCtrl::PositionFromPointClose(int x, int y) {
296 return SendMsg(2023, x, y);
297}
298
4370573a
RD
299// Set caret to start of a line and ensure it is visible.
300void wxStyledTextCtrl::GotoLine(int line) {
301 SendMsg(2024, line, 0);
9ce192d4
RD
302}
303
4370573a 304// Set caret to a position and ensure it is visible.
9ce192d4 305void wxStyledTextCtrl::GotoPos(int pos) {
4370573a 306 SendMsg(2025, pos, 0);
9ce192d4
RD
307}
308
4370573a
RD
309// Set the selection anchor to a position. The anchor is the opposite
310// end of the selection from the caret.
311void wxStyledTextCtrl::SetAnchor(int posAnchor) {
312 SendMsg(2026, posAnchor, 0);
9ce192d4
RD
313}
314
4370573a
RD
315// Retrieve the text of the line containing the caret.
316// Returns the index of the caret on the line.
317wxString wxStyledTextCtrl::GetCurLine(int* linePos) {
4370573a 318 int len = LineLength(GetCurrentLine());
8de28db9
RD
319 if (!len) {
320 if (linePos) *linePos = 0;
10ef30eb 321 return wxEmptyString;
8de28db9 322 }
10ef30eb
RD
323
324 wxMemoryBuffer mbuf(len+1);
325 char* buf = (char*)mbuf.GetWriteBuf(len+1);
8de28db9
RD
326
327 int pos = SendMsg(2027, len+1, (long)buf);
10ef30eb
RD
328 mbuf.UngetWriteBuf(len);
329 mbuf.AppendByte(0);
4370573a 330 if (linePos) *linePos = pos;
10ef30eb 331 return wxString(buf, wxConvUTF8);
9ce192d4
RD
332}
333
4370573a
RD
334// Retrieve the position of the last correctly styled character.
335int wxStyledTextCtrl::GetEndStyled() {
336 return SendMsg(2028, 0, 0);
9ce192d4
RD
337}
338
65ec6247
RD
339// Convert all line endings in the document to one mode.
340void wxStyledTextCtrl::ConvertEOLs(int eolMode) {
341 SendMsg(2029, eolMode, 0);
9ce192d4
RD
342}
343
4370573a
RD
344// Retrieve the current end of line mode - one of CRLF, CR, or LF.
345int wxStyledTextCtrl::GetEOLMode() {
346 return SendMsg(2030, 0, 0);
9ce192d4
RD
347}
348
4370573a
RD
349// Set the current end of line mode.
350void wxStyledTextCtrl::SetEOLMode(int eolMode) {
351 SendMsg(2031, eolMode, 0);
9ce192d4
RD
352}
353
4370573a
RD
354// Set the current styling position to pos and the styling mask to mask.
355// The styling mask can be used to protect some bits in each styling byte from
356// modification.
357void wxStyledTextCtrl::StartStyling(int pos, int mask) {
358 SendMsg(2032, pos, mask);
9ce192d4
RD
359}
360
4370573a
RD
361// Change style from current styling position for length characters to a style
362// and move the current styling position to after this newly styled segment.
363void wxStyledTextCtrl::SetStyling(int length, int style) {
364 SendMsg(2033, length, style);
f6bcfd97
BP
365}
366
4370573a
RD
367// Is drawing done first into a buffer or direct to the screen.
368bool wxStyledTextCtrl::GetBufferedDraw() {
369 return SendMsg(2034, 0, 0) != 0;
f6bcfd97
BP
370}
371
4370573a
RD
372// If drawing is buffered then each line of text is drawn into a bitmap buffer
373// before drawing it to the screen to avoid flicker.
374void wxStyledTextCtrl::SetBufferedDraw(bool buffered) {
375 SendMsg(2035, buffered, 0);
f6bcfd97
BP
376}
377
4370573a
RD
378// Change the visible size of a tab to be a multiple of the width of a space
379// character.
380void wxStyledTextCtrl::SetTabWidth(int tabWidth) {
381 SendMsg(2036, tabWidth, 0);
f6bcfd97
BP
382}
383
4370573a
RD
384// Retrieve the visible size of a tab.
385int wxStyledTextCtrl::GetTabWidth() {
386 return SendMsg(2121, 0, 0);
9ce192d4
RD
387}
388
4370573a 389// Set the code page used to interpret the bytes of the document as characters.
4370573a 390void wxStyledTextCtrl::SetCodePage(int codePage) {
10ef30eb
RD
391#if wxUSE_UNICODE
392 wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
393 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
394#else
395 wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
396 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
397#endif
398 SendMsg(2037, codePage);
9ce192d4
RD
399}
400
4370573a 401// Set the symbol used for a particular marker number,
1a2fb4cd 402// and optionally the fore and background colours.
4370573a
RD
403void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
404 const wxColour& foreground,
405 const wxColour& background) {
9ce192d4 406
4370573a
RD
407 SendMsg(2040, markerNumber, markerSymbol);
408 if (foreground.Ok())
409 MarkerSetForeground(markerNumber, foreground);
410 if (background.Ok())
411 MarkerSetBackground(markerNumber, background);
9ce192d4
RD
412}
413
4370573a
RD
414// Set the foreground colour used for a particular marker number.
415void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore) {
416 SendMsg(2041, markerNumber, wxColourAsLong(fore));
9ce192d4
RD
417}
418
4370573a
RD
419// Set the background colour used for a particular marker number.
420void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back) {
421 SendMsg(2042, markerNumber, wxColourAsLong(back));
9ce192d4
RD
422}
423
1a2fb4cd
RD
424// Add a marker to a line, returning an ID which can be used to find or delete the marker.
425int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) {
426 return SendMsg(2043, line, markerNumber);
9ce192d4
RD
427}
428
4370573a
RD
429// Delete a marker from a line
430void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber) {
431 SendMsg(2044, line, markerNumber);
9ce192d4
RD
432}
433
4370573a
RD
434// Delete all markers with a particular number from all lines
435void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber) {
436 SendMsg(2045, markerNumber, 0);
9ce192d4
RD
437}
438
4370573a
RD
439// Get a bit mask of all the markers set on a line.
440int wxStyledTextCtrl::MarkerGet(int line) {
441 return SendMsg(2046, line, 0);
9ce192d4
RD
442}
443
4370573a
RD
444// Find the next line after lineStart that includes a marker in mask.
445int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask) {
446 return SendMsg(2047, lineStart, markerMask);
9ce192d4
RD
447}
448
4370573a
RD
449// Find the previous line before lineStart that includes a marker in mask.
450int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask) {
451 return SendMsg(2048, lineStart, markerMask);
9ce192d4
RD
452}
453
4370573a
RD
454// Set a margin to be either numeric or symbolic.
455void wxStyledTextCtrl::SetMarginType(int margin, int marginType) {
456 SendMsg(2240, margin, marginType);
9ce192d4
RD
457}
458
4370573a
RD
459// Retrieve the type of a margin.
460int wxStyledTextCtrl::GetMarginType(int margin) {
461 return SendMsg(2241, margin, 0);
9ce192d4
RD
462}
463
4370573a
RD
464// Set the width of a margin to a width expressed in pixels.
465void wxStyledTextCtrl::SetMarginWidth(int margin, int pixelWidth) {
466 SendMsg(2242, margin, pixelWidth);
9ce192d4
RD
467}
468
4370573a
RD
469// Retrieve the width of a margin in pixels.
470int wxStyledTextCtrl::GetMarginWidth(int margin) {
471 return SendMsg(2243, margin, 0);
f6bcfd97
BP
472}
473
4370573a
RD
474// Set a mask that determines which markers are displayed in a margin.
475void wxStyledTextCtrl::SetMarginMask(int margin, int mask) {
476 SendMsg(2244, margin, mask);
f6bcfd97
BP
477}
478
4370573a
RD
479// Retrieve the marker mask of a margin.
480int wxStyledTextCtrl::GetMarginMask(int margin) {
481 return SendMsg(2245, margin, 0);
9ce192d4
RD
482}
483
4370573a
RD
484// Make a margin sensitive or insensitive to mouse clicks.
485void wxStyledTextCtrl::SetMarginSensitive(int margin, bool sensitive) {
486 SendMsg(2246, margin, sensitive);
9ce192d4
RD
487}
488
4370573a
RD
489// Retrieve the mouse click sensitivity of a margin.
490bool wxStyledTextCtrl::GetMarginSensitive(int margin) {
491 return SendMsg(2247, margin, 0) != 0;
9ce192d4
RD
492}
493
4370573a 494// Clear all the styles and make equivalent to the global default style.
9ce192d4 495void wxStyledTextCtrl::StyleClearAll() {
4370573a 496 SendMsg(2050, 0, 0);
9ce192d4
RD
497}
498
4370573a
RD
499// Set the foreground colour of a style.
500void wxStyledTextCtrl::StyleSetForeground(int style, const wxColour& fore) {
501 SendMsg(2051, style, wxColourAsLong(fore));
9ce192d4
RD
502}
503
4370573a
RD
504// Set the background colour of a style.
505void wxStyledTextCtrl::StyleSetBackground(int style, const wxColour& back) {
506 SendMsg(2052, style, wxColourAsLong(back));
9ce192d4
RD
507}
508
4370573a
RD
509// Set a style to be bold or not.
510void wxStyledTextCtrl::StyleSetBold(int style, bool bold) {
511 SendMsg(2053, style, bold);
9ce192d4
RD
512}
513
4370573a
RD
514// Set a style to be italic or not.
515void wxStyledTextCtrl::StyleSetItalic(int style, bool italic) {
516 SendMsg(2054, style, italic);
9ce192d4
RD
517}
518
4370573a
RD
519// Set the size of characters of a style.
520void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints) {
521 SendMsg(2055, style, sizePoints);
9ce192d4
RD
522}
523
4370573a
RD
524// Set the font of a style.
525void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) {
10ef30eb 526 SendMsg(2056, style, (long)(const char*)fontName.mb_str(wxConvUTF8));
9ce192d4
RD
527}
528
4370573a
RD
529// Set a style to have its end of line filled or not.
530void wxStyledTextCtrl::StyleSetEOLFilled(int style, bool filled) {
531 SendMsg(2057, style, filled);
9ce192d4
RD
532}
533
4370573a
RD
534// Reset the default style to its state at startup
535void wxStyledTextCtrl::StyleResetDefault() {
536 SendMsg(2058, 0, 0);
9ce192d4
RD
537}
538
4370573a
RD
539// Set a style to be underlined or not.
540void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline) {
541 SendMsg(2059, style, underline);
9ce192d4
RD
542}
543
65ec6247
RD
544// Set a style to be mixed case, or to force upper or lower case.
545void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) {
546 SendMsg(2060, style, caseForce);
547}
548
10ef30eb
RD
549// Set the character set of the font in a style.
550void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet) {
551 SendMsg(2066, style, characterSet);
552}
553
4370573a
RD
554// Set the foreground colour of the selection and whether to use this setting.
555void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) {
556 SendMsg(2067, useSetting, wxColourAsLong(fore));
9ce192d4
RD
557}
558
4370573a
RD
559// Set the background colour of the selection and whether to use this setting.
560void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back) {
561 SendMsg(2068, useSetting, wxColourAsLong(back));
9ce192d4
RD
562}
563
4370573a
RD
564// Set the foreground colour of the caret.
565void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore) {
566 SendMsg(2069, wxColourAsLong(fore), 0);
9ce192d4
RD
567}
568
4370573a
RD
569// When key+modifier combination km is pressed perform msg.
570void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) {
571 SendMsg(2070, MAKELONG(key, modifiers), cmd);
9ce192d4
RD
572}
573
4370573a
RD
574// When key+modifier combination km do nothing.
575void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) {
576 SendMsg(2071, MAKELONG(key, modifiers));
9ce192d4
RD
577}
578
4370573a
RD
579// Drop all key mappings.
580void wxStyledTextCtrl::CmdKeyClearAll() {
581 SendMsg(2072, 0, 0);
582}
9ce192d4 583
4370573a
RD
584// Set the styles for a segment of the document.
585void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) {
586 SendMsg(2073, length, (long)styleBytes);
9ce192d4
RD
587}
588
4370573a
RD
589// Set a style to be visible or not.
590void wxStyledTextCtrl::StyleSetVisible(int style, bool visible) {
591 SendMsg(2074, style, visible);
592}
9ce192d4 593
4370573a 594// Get the time in milliseconds that the caret is on and off.
9ce192d4 595int wxStyledTextCtrl::GetCaretPeriod() {
4370573a 596 return SendMsg(2075, 0, 0);
9ce192d4
RD
597}
598
4370573a
RD
599// Get the time in milliseconds that the caret is on and off. 0 = steady on.
600void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) {
601 SendMsg(2076, periodMilliseconds, 0);
602}
9ce192d4 603
4370573a
RD
604// Set the set of characters making up words for when moving or selecting
605// by word.
606void wxStyledTextCtrl::SetWordChars(const wxString& characters) {
10ef30eb 607 SendMsg(2077, 0, (long)(const char*)characters.mb_str(wxConvUTF8));
9ce192d4
RD
608}
609
4370573a
RD
610// Start a sequence of actions that is undone and redone as a unit.
611// May be nested.
612void wxStyledTextCtrl::BeginUndoAction() {
613 SendMsg(2078, 0, 0);
614}
9ce192d4 615
4370573a
RD
616// End a sequence of actions that is undone and redone as a unit.
617void wxStyledTextCtrl::EndUndoAction() {
618 SendMsg(2079, 0, 0);
619}
9ce192d4 620
4370573a
RD
621// Set an indicator to plain, squiggle or TT.
622void wxStyledTextCtrl::IndicatorSetStyle(int indic, int style) {
623 SendMsg(2080, indic, style);
624}
9ce192d4 625
4370573a
RD
626// Retrieve the style of an indicator.
627int wxStyledTextCtrl::IndicatorGetStyle(int indic) {
628 return SendMsg(2081, indic, 0);
629}
9ce192d4 630
4370573a
RD
631// Set the foreground colour of an indicator.
632void wxStyledTextCtrl::IndicatorSetForeground(int indic, const wxColour& fore) {
633 SendMsg(2082, indic, wxColourAsLong(fore));
9ce192d4
RD
634}
635
4370573a
RD
636// Retrieve the foreground colour of an indicator.
637wxColour wxStyledTextCtrl::IndicatorGetForeground(int indic) {
638 long c = SendMsg(2083, indic, 0);
639 return wxColourFromLong(c);
640}
9ce192d4 641
4370573a
RD
642// Divide each styling byte into lexical class bits (default:5) and indicator
643// bits (default:3). If a lexer requires more than 32 lexical states, then this
644// is used to expand the possible states.
645void wxStyledTextCtrl::SetStyleBits(int bits) {
646 SendMsg(2090, bits, 0);
9ce192d4
RD
647}
648
4370573a
RD
649// Retrieve number of bits in style bytes used to hold the lexical state.
650int wxStyledTextCtrl::GetStyleBits() {
651 return SendMsg(2091, 0, 0);
652}
9ce192d4 653
4370573a
RD
654// Used to hold extra styling information for each line.
655void wxStyledTextCtrl::SetLineState(int line, int state) {
656 SendMsg(2092, line, state);
f6bcfd97
BP
657}
658
4370573a
RD
659// Retrieve the extra styling information for a line.
660int wxStyledTextCtrl::GetLineState(int line) {
661 return SendMsg(2093, line, 0);
662}
f6bcfd97 663
4370573a
RD
664// Retrieve the last line number that has line state.
665int wxStyledTextCtrl::GetMaxLineState() {
666 return SendMsg(2094, 0, 0);
f6bcfd97
BP
667}
668
65ec6247
RD
669// Is the background of the line containing the caret in a different colour?
670bool wxStyledTextCtrl::GetCaretLineVisible() {
671 return SendMsg(2095, 0, 0) != 0;
672}
673
1a2fb4cd 674// Dsplay the background of the line containing the caret in a different colour.
65ec6247
RD
675void wxStyledTextCtrl::SetCaretLineVisible(bool show) {
676 SendMsg(2096, show, 0);
677}
678
679// Get the colour of the background of the line containing the caret.
680wxColour wxStyledTextCtrl::GetCaretLineBack() {
681 long c = SendMsg(2097, 0, 0);
682 return wxColourFromLong(c);
683}
684
685// Set the colour of the background of the line containing the caret.
686void wxStyledTextCtrl::SetCaretLineBack(const wxColour& back) {
687 SendMsg(2098, wxColourAsLong(back), 0);
688}
689
1a2fb4cd
RD
690// Set a style to be changeable or not (read only).
691// Experimental feature, currently buggy.
692void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable) {
693 SendMsg(2099, style, changeable);
694}
695
4370573a
RD
696// Display a auto-completion list.
697// The lenEntered parameter indicates how many characters before
698// the caret should be used to provide context.
699void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) {
10ef30eb 700 SendMsg(2100, lenEntered, (long)(const char*)itemList.mb_str(wxConvUTF8));
4370573a 701}
f6bcfd97 702
4370573a
RD
703// Remove the auto-completion list from the screen.
704void wxStyledTextCtrl::AutoCompCancel() {
705 SendMsg(2101, 0, 0);
f6bcfd97
BP
706}
707
4370573a
RD
708// Is there an auto-completion list visible?
709bool wxStyledTextCtrl::AutoCompActive() {
710 return SendMsg(2102, 0, 0) != 0;
711}
f6bcfd97 712
4370573a
RD
713// Retrieve the position of the caret when the auto-completion list was
714// displayed.
715int wxStyledTextCtrl::AutoCompPosStart() {
716 return SendMsg(2103, 0, 0);
f6bcfd97
BP
717}
718
4370573a
RD
719// User has selected an item so remove the list and insert the selection.
720void wxStyledTextCtrl::AutoCompComplete() {
721 SendMsg(2104, 0, 0);
722}
f6bcfd97 723
4370573a
RD
724// Define a set of character that when typed cancel the auto-completion list.
725void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) {
10ef30eb 726 SendMsg(2105, 0, (long)(const char*)characterSet.mb_str(wxConvUTF8));
f6bcfd97
BP
727}
728
4370573a
RD
729// Change the separator character in the string setting up an auto-completion
730// list. Default is space but can be changed if items contain space.
731void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter) {
732 SendMsg(2106, separatorCharacter, 0);
733}
f6bcfd97 734
4370573a
RD
735// Retrieve the auto-completion list separator character.
736int wxStyledTextCtrl::AutoCompGetSeparator() {
737 return SendMsg(2107, 0, 0);
9ce192d4
RD
738}
739
4370573a
RD
740// Select the item in the auto-completion list that starts with a string.
741void wxStyledTextCtrl::AutoCompSelect(const wxString& text) {
10ef30eb 742 SendMsg(2108, 0, (long)(const char*)text.mb_str(wxConvUTF8));
4370573a 743}
9ce192d4 744
4370573a
RD
745// Should the auto-completion list be cancelled if the user backspaces to a
746// position before where the box was created.
747void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel) {
748 SendMsg(2110, cancel, 0);
f6bcfd97
BP
749}
750
4370573a
RD
751// Retrieve whether auto-completion cancelled by backspacing before start.
752bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
753 return SendMsg(2111, 0, 0) != 0;
754}
f6bcfd97 755
1a2fb4cd
RD
756// Define a set of characters that when typed will cause the autocompletion to
757// choose the selected item.
4370573a 758void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) {
10ef30eb 759 SendMsg(2112, 0, (long)(const char*)characterSet.mb_str(wxConvUTF8));
4370573a 760}
9ce192d4 761
4370573a
RD
762// Should a single item auto-completion list automatically choose the item.
763void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle) {
764 SendMsg(2113, chooseSingle, 0);
765}
9ce192d4 766
4370573a
RD
767// Retrieve whether a single item auto-completion list automatically choose the item.
768bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
769 return SendMsg(2114, 0, 0) != 0;
9ce192d4
RD
770}
771
4370573a
RD
772// Set whether case is significant when performing auto-completion searches.
773void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase) {
774 SendMsg(2115, ignoreCase, 0);
775}
9ce192d4 776
4370573a
RD
777// Retrieve state of ignore case flag.
778bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
779 return SendMsg(2116, 0, 0) != 0;
9ce192d4
RD
780}
781
65ec6247
RD
782// Display a list of strings and send notification when user chooses one.
783void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) {
10ef30eb 784 SendMsg(2117, listType, (long)(const char*)itemList.mb_str(wxConvUTF8));
65ec6247
RD
785}
786
787// Set whether or not autocompletion is hidden automatically when nothing matches
788void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide) {
789 SendMsg(2118, autoHide, 0);
790}
791
792// Retrieve whether or not autocompletion is hidden automatically when nothing matches
793bool wxStyledTextCtrl::AutoCompGetAutoHide() {
794 return SendMsg(2119, 0, 0) != 0;
795}
796
1a2fb4cd
RD
797// Set whether or not autocompletion deletes any word characters after the inserted text upon completion
798void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord) {
799 SendMsg(2270, dropRestOfWord, 0);
800}
801
802// Retrieve whether or not autocompletion deletes any word characters after the inserted text upon completion
803bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
804 return SendMsg(2271, 0, 0) != 0;
805}
806
4370573a
RD
807// Set the number of spaces used for one level of indentation.
808void wxStyledTextCtrl::SetIndent(int indentSize) {
809 SendMsg(2122, indentSize, 0);
810}
9ce192d4 811
4370573a
RD
812// Retrieve indentation size.
813int wxStyledTextCtrl::GetIndent() {
814 return SendMsg(2123, 0, 0);
9ce192d4
RD
815}
816
4370573a
RD
817// Indentation will only use space characters if useTabs is false, otherwise
818// it will use a combination of tabs and spaces.
819void wxStyledTextCtrl::SetUseTabs(bool useTabs) {
820 SendMsg(2124, useTabs, 0);
821}
9ce192d4 822
4370573a
RD
823// Retrieve whether tabs will be used in indentation.
824bool wxStyledTextCtrl::GetUseTabs() {
825 return SendMsg(2125, 0, 0) != 0;
826}
9ce192d4 827
4370573a
RD
828// Change the indentation of a line to a number of columns.
829void wxStyledTextCtrl::SetLineIndentation(int line, int indentSize) {
830 SendMsg(2126, line, indentSize);
831}
9ce192d4 832
4370573a
RD
833// Retrieve the number of columns that a line is indented.
834int wxStyledTextCtrl::GetLineIndentation(int line) {
835 return SendMsg(2127, line, 0);
9ce192d4
RD
836}
837
4370573a
RD
838// Retrieve the position before the first non indentation character on a line.
839int wxStyledTextCtrl::GetLineIndentPosition(int line) {
840 return SendMsg(2128, line, 0);
841}
9ce192d4 842
4370573a
RD
843// Retrieve the column number of a position, taking tab width into account.
844int wxStyledTextCtrl::GetColumn(int pos) {
845 return SendMsg(2129, pos, 0);
9ce192d4
RD
846}
847
4370573a
RD
848// Show or hide the horizontal scroll bar.
849void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show) {
850 SendMsg(2130, show, 0);
851}
9ce192d4 852
4370573a
RD
853// Is the horizontal scroll bar visible?
854bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
855 return SendMsg(2131, 0, 0) != 0;
9ce192d4
RD
856}
857
4370573a
RD
858// Show or hide indentation guides.
859void wxStyledTextCtrl::SetIndentationGuides(bool show) {
860 SendMsg(2132, show, 0);
861}
9ce192d4 862
4370573a
RD
863// Are the indentation guides visible?
864bool wxStyledTextCtrl::GetIndentationGuides() {
865 return SendMsg(2133, 0, 0) != 0;
9ce192d4
RD
866}
867
4370573a
RD
868// Set the highlighted indentation guide column.
869// 0 = no highlighted guide.
870void wxStyledTextCtrl::SetHighlightGuide(int column) {
871 SendMsg(2134, column, 0);
872}
9ce192d4 873
4370573a
RD
874// Get the highlighted indentation guide column.
875int wxStyledTextCtrl::GetHighlightGuide() {
876 return SendMsg(2135, 0, 0);
9ce192d4
RD
877}
878
4370573a
RD
879// Get the position after the last visible characters on a line.
880int wxStyledTextCtrl::GetLineEndPosition(int line) {
881 return SendMsg(2136, line, 0);
882}
9ce192d4 883
4370573a
RD
884// Get the code page used to interpret the bytes of the document as characters.
885int wxStyledTextCtrl::GetCodePage() {
886 return SendMsg(2137, 0, 0);
9ce192d4
RD
887}
888
4370573a
RD
889// Get the foreground colour of the caret.
890wxColour wxStyledTextCtrl::GetCaretForeground() {
891 long c = SendMsg(2138, 0, 0);
892 return wxColourFromLong(c);
893}
9ce192d4 894
4370573a
RD
895// In read-only mode?
896bool wxStyledTextCtrl::GetReadOnly() {
897 return SendMsg(2140, 0, 0) != 0;
9ce192d4
RD
898}
899
4370573a
RD
900// Sets the position of the caret.
901void wxStyledTextCtrl::SetCurrentPos(int pos) {
902 SendMsg(2141, pos, 0);
903}
9ce192d4 904
4370573a
RD
905// Sets the position that starts the selection - this becomes the anchor.
906void wxStyledTextCtrl::SetSelectionStart(int pos) {
907 SendMsg(2142, pos, 0);
9ce192d4
RD
908}
909
4370573a
RD
910// Returns the position at the start of the selection.
911int wxStyledTextCtrl::GetSelectionStart() {
912 return SendMsg(2143, 0, 0);
913}
9ce192d4 914
4370573a
RD
915// Sets the position that ends the selection - this becomes the currentPosition.
916void wxStyledTextCtrl::SetSelectionEnd(int pos) {
917 SendMsg(2144, pos, 0);
9ce192d4
RD
918}
919
4370573a
RD
920// Returns the position at the end of the selection.
921int wxStyledTextCtrl::GetSelectionEnd() {
922 return SendMsg(2145, 0, 0);
923}
9ce192d4 924
4370573a
RD
925// Sets the print magnification added to the point size of each style for printing.
926void wxStyledTextCtrl::SetPrintMagnification(int magnification) {
927 SendMsg(2146, magnification, 0);
9ce192d4
RD
928}
929
4370573a
RD
930// Returns the print magnification.
931int wxStyledTextCtrl::GetPrintMagnification() {
932 return SendMsg(2147, 0, 0);
933}
9ce192d4 934
4370573a
RD
935// Modify colours when printing for clearer printed text.
936void wxStyledTextCtrl::SetPrintColourMode(int mode) {
937 SendMsg(2148, mode, 0);
9ce192d4
RD
938}
939
4370573a
RD
940// Returns the print colour mode.
941int wxStyledTextCtrl::GetPrintColourMode() {
942 return SendMsg(2149, 0, 0);
943}
9ce192d4 944
4370573a
RD
945// Find some text in the document.
946int wxStyledTextCtrl::FindText(int minPos, int maxPos,
947 const wxString& text,
948 bool caseSensitive, bool wholeWord) {
949 TextToFind ft;
950 int flags = 0;
951
952 flags |= caseSensitive ? SCFIND_MATCHCASE : 0;
953 flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
954 ft.chrg.cpMin = minPos;
955 ft.chrg.cpMax = maxPos;
10ef30eb 956 ft.lpstrText = (char*)(const char*)text.mb_str(wxConvUTF8);
4370573a
RD
957
958 return SendMsg(2150, flags, (long)&ft);
959}
960
961// On Windows will draw the document into a display context such as a printer.
962 int wxStyledTextCtrl::FormatRange(bool doDraw,
963 int startPos,
964 int endPos,
965 wxDC* draw,
966 wxDC* target, // Why does it use two? Can they be the same?
967 wxRect renderRect,
968 wxRect pageRect) {
969 RangeToFormat fr;
970
e1a93f46
RD
971 if (endPos < startPos) {
972 int temp = startPos;
973 startPos = endPos;
974 endPos = temp;
975 }
4370573a
RD
976 fr.hdc = draw;
977 fr.hdcTarget = target;
978 fr.rc.top = renderRect.GetTop();
979 fr.rc.left = renderRect.GetLeft();
980 fr.rc.right = renderRect.GetRight();
981 fr.rc.bottom = renderRect.GetBottom();
982 fr.rcPage.top = pageRect.GetTop();
983 fr.rcPage.left = pageRect.GetLeft();
984 fr.rcPage.right = pageRect.GetRight();
985 fr.rcPage.bottom = pageRect.GetBottom();
986 fr.chrg.cpMin = startPos;
987 fr.chrg.cpMax = endPos;
988
989 return SendMsg(2151, doDraw, (long)&fr);
990}
991
992// Retrieve the line at the top of the display.
993int wxStyledTextCtrl::GetFirstVisibleLine() {
994 return SendMsg(2152, 0, 0);
9ce192d4
RD
995}
996
4370573a
RD
997// Retrieve the contents of a line.
998wxString wxStyledTextCtrl::GetLine(int line) {
4370573a 999 int len = LineLength(line);
10ef30eb 1000 if (!len) return wxEmptyString;
9ce192d4 1001
10ef30eb
RD
1002 wxMemoryBuffer mbuf(len+1);
1003 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1004 SendMsg(2153, line, (long)buf);
1005 mbuf.UngetWriteBuf(len);
1006 mbuf.AppendByte(0);
1007 return wxString(buf, wxConvUTF8);
4370573a
RD
1008}
1009
1010// Returns the number of lines in the document. There is always at least one.
1011int wxStyledTextCtrl::GetLineCount() {
1012 return SendMsg(2154, 0, 0);
1013}
9ce192d4 1014
4370573a 1015// Sets the size in pixels of the left margin.
65ec6247
RD
1016void wxStyledTextCtrl::SetMarginLeft(int pixelWidth) {
1017 SendMsg(2155, 0, pixelWidth);
4370573a 1018}
9ce192d4 1019
4370573a
RD
1020// Returns the size in pixels of the left margin.
1021int wxStyledTextCtrl::GetMarginLeft() {
1022 return SendMsg(2156, 0, 0);
9ce192d4
RD
1023}
1024
4370573a 1025// Sets the size in pixels of the right margin.
65ec6247
RD
1026void wxStyledTextCtrl::SetMarginRight(int pixelWidth) {
1027 SendMsg(2157, 0, pixelWidth);
4370573a 1028}
9ce192d4 1029
4370573a
RD
1030// Returns the size in pixels of the right margin.
1031int wxStyledTextCtrl::GetMarginRight() {
1032 return SendMsg(2158, 0, 0);
9ce192d4
RD
1033}
1034
4370573a
RD
1035// Is the document different from when it was last saved?
1036bool wxStyledTextCtrl::GetModify() {
1037 return SendMsg(2159, 0, 0) != 0;
1038}
9ce192d4 1039
4370573a
RD
1040// Select a range of text.
1041void wxStyledTextCtrl::SetSelection(int start, int end) {
1042 SendMsg(2160, start, end);
9ce192d4
RD
1043}
1044
4370573a
RD
1045// Retrieve the selected text.
1046wxString wxStyledTextCtrl::GetSelectedText() {
4370573a
RD
1047 int start;
1048 int end;
9ce192d4 1049
4370573a
RD
1050 GetSelection(&start, &end);
1051 int len = end - start;
10ef30eb 1052 if (!len) return wxEmptyString;
9ce192d4 1053
10ef30eb
RD
1054 wxMemoryBuffer mbuf(len+1);
1055 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1056 SendMsg(2161, 0, (long)buf);
1057 mbuf.UngetWriteBuf(len);
1058 mbuf.AppendByte(0);
1059 return wxString(buf, wxConvUTF8);
4370573a 1060}
9ce192d4 1061
4370573a
RD
1062// Retrieve a range of text.
1063wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) {
e1a93f46
RD
1064 if (endPos < startPos) {
1065 int temp = startPos;
1066 startPos = endPos;
1067 endPos = temp;
1068 }
4370573a 1069 int len = endPos - startPos;
10ef30eb
RD
1070 if (!len) return wxEmptyString;
1071 wxMemoryBuffer mbuf(len+1);
1072 char* buf = (char*)mbuf.GetWriteBuf(len);
4370573a 1073 TextRange tr;
10ef30eb 1074 tr.lpstrText = buf;
4370573a
RD
1075 tr.chrg.cpMin = startPos;
1076 tr.chrg.cpMax = endPos;
4370573a 1077 SendMsg(2162, 0, (long)&tr);
10ef30eb
RD
1078 mbuf.UngetWriteBuf(len);
1079 mbuf.AppendByte(0);
1080 return wxString(buf, wxConvUTF8);
9ce192d4
RD
1081}
1082
4370573a
RD
1083// Draw the selection in normal style or with selection highlighted.
1084void wxStyledTextCtrl::HideSelection(bool normal) {
1085 SendMsg(2163, normal, 0);
1086}
9ce192d4 1087
4370573a
RD
1088// Retrieve the line containing a position.
1089int wxStyledTextCtrl::LineFromPosition(int pos) {
1090 return SendMsg(2166, pos, 0);
9ce192d4
RD
1091}
1092
4370573a
RD
1093// Retrieve the position at the start of a line.
1094int wxStyledTextCtrl::PositionFromLine(int line) {
1095 return SendMsg(2167, line, 0);
1096}
9ce192d4 1097
4370573a
RD
1098// Scroll horizontally and vertically.
1099void wxStyledTextCtrl::LineScroll(int columns, int lines) {
1100 SendMsg(2168, columns, lines);
9ce192d4
RD
1101}
1102
4370573a
RD
1103// Ensure the caret is visible.
1104void wxStyledTextCtrl::EnsureCaretVisible() {
1105 SendMsg(2169, 0, 0);
1106}
9ce192d4 1107
4370573a
RD
1108// Replace the selected text with the argument text.
1109void wxStyledTextCtrl::ReplaceSelection(const wxString& text) {
10ef30eb 1110 SendMsg(2170, 0, (long)(const char*)text.mb_str(wxConvUTF8));
9ce192d4
RD
1111}
1112
4370573a
RD
1113// Set to read only or read write.
1114void wxStyledTextCtrl::SetReadOnly(bool readOnly) {
1115 SendMsg(2171, readOnly, 0);
1116}
9ce192d4 1117
4370573a
RD
1118// Will a paste succeed?
1119bool wxStyledTextCtrl::CanPaste() {
1120 return SendMsg(2173, 0, 0) != 0;
9ce192d4
RD
1121}
1122
4370573a
RD
1123// Are there any undoable actions in the undo history.
1124bool wxStyledTextCtrl::CanUndo() {
1125 return SendMsg(2174, 0, 0) != 0;
1126}
9ce192d4 1127
4370573a
RD
1128// Delete the undo history.
1129void wxStyledTextCtrl::EmptyUndoBuffer() {
1130 SendMsg(2175, 0, 0);
9ce192d4
RD
1131}
1132
4370573a
RD
1133// Undo one action in the undo history.
1134void wxStyledTextCtrl::Undo() {
1135 SendMsg(2176, 0, 0);
1136}
9ce192d4 1137
4370573a
RD
1138// Cut the selection to the clipboard.
1139void wxStyledTextCtrl::Cut() {
1140 SendMsg(2177, 0, 0);
f6bcfd97
BP
1141}
1142
4370573a
RD
1143// Copy the selection to the clipboard.
1144void wxStyledTextCtrl::Copy() {
1145 SendMsg(2178, 0, 0);
1146}
f6bcfd97 1147
4370573a
RD
1148// Paste the contents of the clipboard into the document replacing the selection.
1149void wxStyledTextCtrl::Paste() {
1150 SendMsg(2179, 0, 0);
f6bcfd97
BP
1151}
1152
4370573a
RD
1153// Clear the selection.
1154void wxStyledTextCtrl::Clear() {
1155 SendMsg(2180, 0, 0);
1156}
f6bcfd97 1157
4370573a
RD
1158// Replace the contents of the document with the argument text.
1159void wxStyledTextCtrl::SetText(const wxString& text) {
10ef30eb 1160 SendMsg(2181, 0, (long)(const char*)text.mb_str(wxConvUTF8));
f6bcfd97
BP
1161}
1162
4370573a
RD
1163// Retrieve all the text in the document.
1164wxString wxStyledTextCtrl::GetText() {
10ef30eb
RD
1165 int len = GetTextLength();
1166 wxMemoryBuffer mbuf(len+1); // leave room for the null...
1167 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1168 SendMsg(2182, len+1, (long)buf);
1169 mbuf.UngetWriteBuf(len);
1170 mbuf.AppendByte(0);
1171 return wxString(buf, wxConvUTF8);
4370573a 1172}
9ce192d4 1173
4370573a
RD
1174// Retrieve the number of characters in the document.
1175int wxStyledTextCtrl::GetTextLength() {
1176 return SendMsg(2183, 0, 0);
9ce192d4
RD
1177}
1178
4370573a
RD
1179// Set to overtype (true) or insert mode
1180void wxStyledTextCtrl::SetOvertype(bool overtype) {
1181 SendMsg(2186, overtype, 0);
1182}
9ce192d4 1183
4370573a
RD
1184// Returns true if overtype mode is active otherwise false is returned.
1185bool wxStyledTextCtrl::GetOvertype() {
1186 return SendMsg(2187, 0, 0) != 0;
9ce192d4
RD
1187}
1188
65ec6247
RD
1189// Set the width of the insert mode caret
1190void wxStyledTextCtrl::SetCaretWidth(int pixelWidth) {
1191 SendMsg(2188, pixelWidth, 0);
1192}
1193
1194// Returns the width of the insert mode caret
1195int wxStyledTextCtrl::GetCaretWidth() {
1196 return SendMsg(2189, 0, 0);
1197}
1198
1199// Sets the position that starts the target which is used for updating the
1200// document without affecting the scroll position.
1201void wxStyledTextCtrl::SetTargetStart(int pos) {
1202 SendMsg(2190, pos, 0);
1203}
1204
1205// Get the position that starts the target.
1206int wxStyledTextCtrl::GetTargetStart() {
1207 return SendMsg(2191, 0, 0);
1208}
1209
1210// Sets the position that ends the target which is used for updating the
1211// document without affecting the scroll position.
1212void wxStyledTextCtrl::SetTargetEnd(int pos) {
1213 SendMsg(2192, pos, 0);
1214}
1215
1216// Get the position that ends the target.
1217int wxStyledTextCtrl::GetTargetEnd() {
1218 return SendMsg(2193, 0, 0);
1219}
1220
1221// Replace the target text with the argument text.
b8b0e402 1222// Text is counted so it can contain nulls.
65ec6247
RD
1223// Returns the length of the replacement text.
1224
1225 int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
10ef30eb
RD
1226 wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
1227 return SendMsg(2194, strlen(buf), (long)(const char*)buf);
65ec6247
RD
1228}
1229
1230// Replace the target text with the argument text after \d processing.
b8b0e402 1231// Text is counted so it can contain nulls.
65ec6247
RD
1232// Looks for \d where d is between 1 and 9 and replaces these with the strings
1233// matched in the last search operation which were surrounded by \( and \).
1234// Returns the length of the replacement text including any change
1235// caused by processing the \d patterns.
1236
1237 int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
10ef30eb
RD
1238 wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
1239 return SendMsg(2195, strlen(buf), (long)(const char*)buf);
65ec6247
RD
1240}
1241
1242// Search for a counted string in the target and set the target to the found
b8b0e402 1243// range. Text is counted so it can contain nulls.
65ec6247
RD
1244// Returns length of range or -1 for failure in which case target is not moved.
1245
1246 int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
10ef30eb
RD
1247 wxWX2MBbuf buf = (wxWX2MBbuf)text.mb_str(wxConvUTF8);
1248 return SendMsg(2197, strlen(buf), (long)(const char*)buf);
65ec6247
RD
1249}
1250
1251// Set the search flags used by SearchInTarget
1252void wxStyledTextCtrl::SetSearchFlags(int flags) {
1253 SendMsg(2198, flags, 0);
1254}
1255
1256// Get the search flags used by SearchInTarget
1257int wxStyledTextCtrl::GetSearchFlags() {
1258 return SendMsg(2199, 0, 0);
1259}
1260
4370573a
RD
1261// Show a call tip containing a definition near position pos.
1262void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) {
10ef30eb 1263 SendMsg(2200, pos, (long)(const char*)definition.mb_str(wxConvUTF8));
4370573a 1264}
9ce192d4 1265
4370573a
RD
1266// Remove the call tip from the screen.
1267void wxStyledTextCtrl::CallTipCancel() {
1268 SendMsg(2201, 0, 0);
9ce192d4
RD
1269}
1270
4370573a
RD
1271// Is there an active call tip?
1272bool wxStyledTextCtrl::CallTipActive() {
1273 return SendMsg(2202, 0, 0) != 0;
1274}
9ce192d4 1275
4370573a 1276// Retrieve the position where the caret was before displaying the call tip.
9ce192d4 1277int wxStyledTextCtrl::CallTipPosAtStart() {
4370573a 1278 return SendMsg(2203, 0, 0);
9ce192d4
RD
1279}
1280
4370573a 1281// Highlight a segment of the definition.
9ce192d4 1282void wxStyledTextCtrl::CallTipSetHighlight(int start, int end) {
4370573a 1283 SendMsg(2204, start, end);
9ce192d4
RD
1284}
1285
4370573a
RD
1286// Set the background colour for the call tip.
1287void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back) {
1288 SendMsg(2205, wxColourAsLong(back), 0);
1289}
9ce192d4 1290
4370573a
RD
1291// Find the display line of a document line taking hidden lines into account.
1292int wxStyledTextCtrl::VisibleFromDocLine(int line) {
1293 return SendMsg(2220, line, 0);
9ce192d4
RD
1294}
1295
4370573a
RD
1296// Find the document line of a display line taking hidden lines into account.
1297int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay) {
1298 return SendMsg(2221, lineDisplay, 0);
1299}
9ce192d4 1300
4370573a
RD
1301// Set the fold level of a line.
1302// This encodes an integer level along with flags indicating whether the
1303// line is a header and whether it is effectively white space.
1304void wxStyledTextCtrl::SetFoldLevel(int line, int level) {
1305 SendMsg(2222, line, level);
1306}
9ce192d4 1307
4370573a
RD
1308// Retrieve the fold level of a line.
1309int wxStyledTextCtrl::GetFoldLevel(int line) {
1310 return SendMsg(2223, line, 0);
1311}
d134f170 1312
4370573a
RD
1313// Find the last child line of a header line.
1314int wxStyledTextCtrl::GetLastChild(int line, int level) {
1315 return SendMsg(2224, line, level);
9ce192d4
RD
1316}
1317
4370573a
RD
1318// Find the parent line of a child line.
1319int wxStyledTextCtrl::GetFoldParent(int line) {
1320 return SendMsg(2225, line, 0);
1321}
9ce192d4 1322
4370573a
RD
1323// Make a range of lines visible.
1324void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd) {
1325 SendMsg(2226, lineStart, lineEnd);
9ce192d4
RD
1326}
1327
4370573a
RD
1328// Make a range of lines invisible.
1329void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd) {
1330 SendMsg(2227, lineStart, lineEnd);
1331}
9ce192d4 1332
4370573a
RD
1333// Is a line visible?
1334bool wxStyledTextCtrl::GetLineVisible(int line) {
1335 return SendMsg(2228, line, 0) != 0;
9ce192d4
RD
1336}
1337
4370573a
RD
1338// Show the children of a header line.
1339void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded) {
1340 SendMsg(2229, line, expanded);
1341}
9ce192d4 1342
4370573a
RD
1343// Is a header line expanded?
1344bool wxStyledTextCtrl::GetFoldExpanded(int line) {
1345 return SendMsg(2230, line, 0) != 0;
9ce192d4
RD
1346}
1347
4370573a
RD
1348// Switch a header line between expanded and contracted.
1349void wxStyledTextCtrl::ToggleFold(int line) {
1350 SendMsg(2231, line, 0);
1351}
9ce192d4 1352
4370573a
RD
1353// Ensure a particular line is visible by expanding any header line hiding it.
1354void wxStyledTextCtrl::EnsureVisible(int line) {
1355 SendMsg(2232, line, 0);
1356}
9ce192d4 1357
4370573a
RD
1358// Set some debugging options for folding
1359void wxStyledTextCtrl::SetFoldFlags(int flags) {
1360 SendMsg(2233, flags, 0);
9ce192d4
RD
1361}
1362
65ec6247
RD
1363// Ensure a particular line is visible by expanding any header line hiding it.
1364// Use the currently set visibility policy to determine which range to display.
1365void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line) {
1366 SendMsg(2234, line, 0);
1367}
1368
1369// Sets whether a tab pressed when caret is within indentation indents
1370void wxStyledTextCtrl::SetTabIndents(bool tabIndents) {
1371 SendMsg(2260, tabIndents, 0);
1372}
1373
1374// Does a tab pressed when caret is within indentation indent?
1375bool wxStyledTextCtrl::GetTabIndents() {
1376 return SendMsg(2261, 0, 0) != 0;
1377}
1378
1379// Sets whether a backspace pressed when caret is within indentation unindents
1380void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents) {
1381 SendMsg(2262, bsUnIndents, 0);
1382}
1383
1384// Does a backspace pressed when caret is within indentation unindent?
1385bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1386 return SendMsg(2263, 0, 0) != 0;
1387}
1388
1389// Sets the time the mouse must sit still to generate a mouse dwell event
1390void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds) {
1391 SendMsg(2264, periodMilliseconds, 0);
1392}
1393
1394// Retrieve the time the mouse must sit still to generate a mouse dwell event
1395int wxStyledTextCtrl::GetMouseDwellTime() {
1396 return SendMsg(2265, 0, 0);
1397}
1398
1a2fb4cd
RD
1399// Get position of start of word
1400int wxStyledTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters) {
1401 return SendMsg(2266, pos, onlyWordCharacters);
1402}
1403
1404// Get position of end of word
1405int wxStyledTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters) {
1406 return SendMsg(2267, pos, onlyWordCharacters);
1407}
1408
1409// Sets whether text is word wrapped
1410void wxStyledTextCtrl::SetWrapMode(int mode) {
1411 SendMsg(2268, mode, 0);
1412}
1413
1414// Retrieve whether text is word wrapped
1415int wxStyledTextCtrl::GetWrapMode() {
1416 return SendMsg(2269, 0, 0);
1417}
1418
1419// Sets the degree of caching of layout information
1420void wxStyledTextCtrl::SetLayoutCache(int mode) {
1421 SendMsg(2272, mode, 0);
1422}
1423
1424// Retrieve the degree of caching of layout information
1425int wxStyledTextCtrl::GetLayoutCache() {
1426 return SendMsg(2273, 0, 0);
1427}
1428
65ec6247
RD
1429// Move the caret inside current view if it's not there already
1430void wxStyledTextCtrl::MoveCaretInsideView() {
1431 SendMsg(2401, 0, 0);
1432}
1433
4370573a
RD
1434// How many characters are on a line, not including end of line characters.
1435int wxStyledTextCtrl::LineLength(int line) {
1436 return SendMsg(2350, line, 0);
1437}
9ce192d4 1438
4370573a
RD
1439// Highlight the characters at two positions.
1440void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2) {
1441 SendMsg(2351, pos1, pos2);
1442}
9ce192d4 1443
4370573a
RD
1444// Highlight the character at a position indicating there is no matching brace.
1445void wxStyledTextCtrl::BraceBadLight(int pos) {
1446 SendMsg(2352, pos, 0);
9ce192d4
RD
1447}
1448
4370573a
RD
1449// Find the position of a matching brace or INVALID_POSITION if no match.
1450int wxStyledTextCtrl::BraceMatch(int pos) {
1451 return SendMsg(2353, pos, 0);
1452}
9ce192d4 1453
4370573a
RD
1454// Are the end of line characters visible.
1455bool wxStyledTextCtrl::GetViewEOL() {
1456 return SendMsg(2355, 0, 0) != 0;
9ce192d4
RD
1457}
1458
4370573a
RD
1459// Make the end of line characters visible or invisible
1460void wxStyledTextCtrl::SetViewEOL(bool visible) {
1461 SendMsg(2356, visible, 0);
1462}
9ce192d4 1463
4370573a
RD
1464// Retrieve a pointer to the document object.
1465void* wxStyledTextCtrl::GetDocPointer() {
1466 return (void*)SendMsg(2357);
1467}
67003d1a 1468
4370573a
RD
1469// Change the document object used.
1470void wxStyledTextCtrl::SetDocPointer(void* docPointer) {
65ec6247 1471 SendMsg(2358, 0, (long)docPointer);
67003d1a
RD
1472}
1473
4370573a
RD
1474// Set which document modification events are sent to the container.
1475void wxStyledTextCtrl::SetModEventMask(int mask) {
1476 SendMsg(2359, mask, 0);
1477}
67003d1a 1478
4370573a
RD
1479// Retrieve the column number which text should be kept within.
1480int wxStyledTextCtrl::GetEdgeColumn() {
1481 return SendMsg(2360, 0, 0);
67003d1a
RD
1482}
1483
4370573a
RD
1484// Set the column number of the edge.
1485// If text goes past the edge then it is highlighted.
1486void wxStyledTextCtrl::SetEdgeColumn(int column) {
1487 SendMsg(2361, column, 0);
1488}
67003d1a 1489
4370573a
RD
1490// Retrieve the edge highlight mode.
1491int wxStyledTextCtrl::GetEdgeMode() {
1492 return SendMsg(2362, 0, 0);
67003d1a
RD
1493}
1494
4370573a
RD
1495// The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
1496// goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
1497void wxStyledTextCtrl::SetEdgeMode(int mode) {
1498 SendMsg(2363, mode, 0);
1499}
67003d1a 1500
4370573a
RD
1501// Retrieve the colour used in edge indication.
1502wxColour wxStyledTextCtrl::GetEdgeColour() {
1503 long c = SendMsg(2364, 0, 0);
1504 return wxColourFromLong(c);
67003d1a
RD
1505}
1506
4370573a
RD
1507// Change the colour used in edge indication.
1508void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour) {
1509 SendMsg(2365, wxColourAsLong(edgeColour), 0);
1510}
67003d1a 1511
4370573a
RD
1512// Sets the current caret position to be the search anchor.
1513void wxStyledTextCtrl::SearchAnchor() {
1514 SendMsg(2366, 0, 0);
67003d1a
RD
1515}
1516
4370573a 1517// Find some text starting at the search anchor.
65ec6247 1518// Does not ensure the selection is visible.
4370573a 1519int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) {
10ef30eb 1520 return SendMsg(2367, flags, (long)(const char*)text.mb_str(wxConvUTF8));
4370573a 1521}
67003d1a 1522
4370573a 1523// Find some text starting at the search anchor and moving backwards.
65ec6247 1524// Does not ensure the selection is visible.
4370573a 1525int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) {
10ef30eb 1526 return SendMsg(2368, flags, (long)(const char*)text.mb_str(wxConvUTF8));
67003d1a
RD
1527}
1528
4370573a
RD
1529// Set the way the line the caret is on is kept visible.
1530void wxStyledTextCtrl::SetCaretPolicy(int caretPolicy, int caretSlop) {
1531 SendMsg(2369, caretPolicy, caretSlop);
1532}
67003d1a 1533
4370573a
RD
1534// Retrieves the number of lines completely visible.
1535int wxStyledTextCtrl::LinesOnScreen() {
1536 return SendMsg(2370, 0, 0);
67003d1a
RD
1537}
1538
4370573a
RD
1539// Set whether a pop up menu is displayed automatically when the user presses
1540// the wrong mouse button.
1541void wxStyledTextCtrl::UsePopUp(bool allowPopUp) {
1542 SendMsg(2371, allowPopUp, 0);
1543}
67003d1a 1544
4370573a
RD
1545// Is the selection a rectangular. The alternative is the more common stream selection.
1546bool wxStyledTextCtrl::SelectionIsRectangle() {
1547 return SendMsg(2372, 0, 0) != 0;
67003d1a
RD
1548}
1549
4370573a
RD
1550// Set the zoom level. This number of points is added to the size of all fonts.
1551// It may be positive to magnify or negative to reduce.
1552void wxStyledTextCtrl::SetZoom(int zoom) {
1553 SendMsg(2373, zoom, 0);
1554}
67003d1a 1555
4370573a
RD
1556// Retrieve the zoom level.
1557int wxStyledTextCtrl::GetZoom() {
1558 return SendMsg(2374, 0, 0);
67003d1a
RD
1559}
1560
4370573a
RD
1561// Create a new document object.
1562// Starts with reference count of 1 and not selected into editor.
1563void* wxStyledTextCtrl::CreateDocument() {
1564 return (void*)SendMsg(2375);
1565}
67003d1a 1566
4370573a
RD
1567// Extend life of document.
1568void wxStyledTextCtrl::AddRefDocument(void* docPointer) {
1569 SendMsg(2376, (long)docPointer);
67003d1a
RD
1570}
1571
4370573a
RD
1572// Release a reference to the document, deleting document if it fades to black.
1573void wxStyledTextCtrl::ReleaseDocument(void* docPointer) {
1574 SendMsg(2377, (long)docPointer);
1575}
67003d1a 1576
4370573a
RD
1577// Get which document modification events are sent to the container.
1578int wxStyledTextCtrl::GetModEventMask() {
1579 return SendMsg(2378, 0, 0);
67003d1a
RD
1580}
1581
65ec6247 1582// Change internal focus flag
8de28db9 1583void wxStyledTextCtrl::SetSTCFocus(bool focus) {
65ec6247
RD
1584 SendMsg(2380, focus, 0);
1585}
1586
1587// Get internal focus flag
8de28db9 1588bool wxStyledTextCtrl::GetSTCFocus() {
65ec6247
RD
1589 return SendMsg(2381, 0, 0) != 0;
1590}
1591
1592// Change error status - 0 = OK
1593void wxStyledTextCtrl::SetStatus(int statusCode) {
1594 SendMsg(2382, statusCode, 0);
1595}
1596
1597// Get error status
1598int wxStyledTextCtrl::GetStatus() {
1599 return SendMsg(2383, 0, 0);
1600}
1601
1602// Set whether the mouse is captured when its button is pressed
1603void wxStyledTextCtrl::SetMouseDownCaptures(bool captures) {
1604 SendMsg(2384, captures, 0);
1605}
1606
1607// Get whether mouse gets captured
1608bool wxStyledTextCtrl::GetMouseDownCaptures() {
1609 return SendMsg(2385, 0, 0) != 0;
1610}
1611
1612// Sets the cursor to one of the SC_CURSOR* values
1613void wxStyledTextCtrl::SetCursor(int cursorType) {
1614 SendMsg(2386, cursorType, 0);
1615}
1616
1617// Get cursor type
1618int wxStyledTextCtrl::GetCursor() {
1619 return SendMsg(2387, 0, 0);
1620}
1621
1a2fb4cd
RD
1622// Change the way control characters are displayed:
1623// If symbol is < 32, keep the drawn way, else, use the given character
1624void wxStyledTextCtrl::SetControlCharSymbol(int symbol) {
1625 SendMsg(2388, symbol, 0);
1626}
1627
1628// Get the way control characters are displayed
1629int wxStyledTextCtrl::GetControlCharSymbol() {
1630 return SendMsg(2389, 0, 0);
1631}
1632
65ec6247
RD
1633// Move to the previous change in capitalistion
1634void wxStyledTextCtrl::WordPartLeft() {
1635 SendMsg(2390, 0, 0);
1636}
1637
1638// Move to the previous change in capitalistion extending selection to new caret position.
1639void wxStyledTextCtrl::WordPartLeftExtend() {
1640 SendMsg(2391, 0, 0);
1641}
1642
1643// Move to the change next in capitalistion
1644void wxStyledTextCtrl::WordPartRight() {
1645 SendMsg(2392, 0, 0);
1646}
1647
1648// Move to the next change in capitalistion extending selection to new caret position.
1649void wxStyledTextCtrl::WordPartRightExtend() {
1650 SendMsg(2393, 0, 0);
1651}
1652
1653// Set the way the display area is determined when a particular line is to be moved to.
1654void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop) {
1655 SendMsg(2394, visiblePolicy, visibleSlop);
1656}
1657
1658// Delete back from the current position to the start of the line
1659void wxStyledTextCtrl::DelLineLeft() {
1660 SendMsg(2395, 0, 0);
1661}
1662
1663// Delete forwards from the current position to the end of the line
1664void wxStyledTextCtrl::DelLineRight() {
1665 SendMsg(2396, 0, 0);
1666}
1667
1a2fb4cd
RD
1668// Get and Set the xOffset (ie, horizonal scroll position)
1669void wxStyledTextCtrl::SetXOffset(int newOffset) {
1670 SendMsg(2397, newOffset, 0);
1671}
1672int wxStyledTextCtrl::GetXOffset() {
1673 return SendMsg(2398, 0, 0);
1674}
1675
4370573a
RD
1676// Start notifying the container of all key presses and commands.
1677void wxStyledTextCtrl::StartRecord() {
1678 SendMsg(3001, 0, 0);
1679}
67003d1a 1680
4370573a
RD
1681// Stop notifying the container of all key presses and commands.
1682void wxStyledTextCtrl::StopRecord() {
1683 SendMsg(3002, 0, 0);
67003d1a
RD
1684}
1685
4370573a
RD
1686// Set the lexing language of the document.
1687void wxStyledTextCtrl::SetLexer(int lexer) {
1688 SendMsg(4001, lexer, 0);
1689}
67003d1a 1690
4370573a
RD
1691// Retrieve the lexing language of the document.
1692int wxStyledTextCtrl::GetLexer() {
1693 return SendMsg(4002, 0, 0);
67003d1a
RD
1694}
1695
4370573a
RD
1696// Colourise a segment of the document using the current lexing language.
1697void wxStyledTextCtrl::Colourise(int start, int end) {
1698 SendMsg(4003, start, end);
1699}
67003d1a 1700
4370573a
RD
1701// Set up a value that may be used by a lexer for some optional feature.
1702void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) {
10ef30eb 1703 SendMsg(4004, (long)(const char*)key.mb_str(wxConvUTF8), (long)(const char*)value.mb_str(wxConvUTF8));
f6bcfd97
BP
1704}
1705
4370573a
RD
1706// Set up the key words used by the lexer.
1707void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) {
10ef30eb 1708 SendMsg(4005, keywordSet, (long)(const char*)keyWords.mb_str(wxConvUTF8));
4370573a 1709}
f6bcfd97 1710
65ec6247
RD
1711// Set the lexing language of the document based on string name.
1712void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) {
10ef30eb 1713 SendMsg(4006, 0, (long)(const char*)language.mb_str(wxConvUTF8));
65ec6247
RD
1714}
1715
4370573a 1716// END of generated section
f6bcfd97 1717//----------------------------------------------------------------------
f6bcfd97
BP
1718
1719
4370573a
RD
1720// Returns the line number of the line with the caret.
1721int wxStyledTextCtrl::GetCurrentLine() {
1722 int line = LineFromPosition(GetCurrentPos());
1723 return line;
f6bcfd97
BP
1724}
1725
1726
4370573a
RD
1727// Extract style settings from a spec-string which is composed of one or
1728// more of the following comma separated elements:
1729//
1730// bold turns on bold
1731// italic turns on italics
1732// fore:#RRGGBB sets the foreground colour
1733// back:#RRGGBB sets the background colour
1734// face:[facename] sets the font face name to use
1735// size:[num] sets the font size in points
1736// eol turns on eol filling
1737// underline turns on underlining
1738//
1739void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
1740
1741 wxStringTokenizer tkz(spec, ",");
1742 while (tkz.HasMoreTokens()) {
1743 wxString token = tkz.GetNextToken();
f6bcfd97 1744
4370573a
RD
1745 wxString option = token.BeforeFirst(':');
1746 wxString val = token.AfterFirst(':');
f6bcfd97 1747
4370573a
RD
1748 if (option == "bold")
1749 StyleSetBold(styleNum, true);
f6bcfd97 1750
4370573a
RD
1751 else if (option == "italic")
1752 StyleSetItalic(styleNum, true);
9ce192d4 1753
4370573a
RD
1754 else if (option == "underline")
1755 StyleSetUnderline(styleNum, true);
9ce192d4 1756
4370573a
RD
1757 else if (option == "eol")
1758 StyleSetEOLFilled(styleNum, true);
9ce192d4 1759
4370573a
RD
1760 else if (option == "size") {
1761 long points;
1762 if (val.ToLong(&points))
1763 StyleSetSize(styleNum, points);
1764 }
9ce192d4 1765
4370573a
RD
1766 else if (option == "face")
1767 StyleSetFaceName(styleNum, val);
9ce192d4 1768
4370573a
RD
1769 else if (option == "fore")
1770 StyleSetForeground(styleNum, wxColourFromSpec(val));
9ce192d4 1771
4370573a
RD
1772 else if (option == "back")
1773 StyleSetBackground(styleNum, wxColourFromSpec(val));
1774 }
9ce192d4
RD
1775}
1776
1777
4370573a
RD
1778// Set style size, face, bold, italic, and underline attributes from
1779// a wxFont's attributes.
1780void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
1781 int size = font.GetPointSize();
1782 wxString faceName = font.GetFaceName();
1783 bool bold = font.GetWeight() == wxBOLD;
1784 bool italic = font.GetStyle() != wxNORMAL;
1785 bool under = font.GetUnderlined();
9ce192d4 1786
4370573a
RD
1787 // TODO: add encoding/charset mapping
1788 StyleSetFontAttr(styleNum, size, faceName, bold, italic, under);
9ce192d4
RD
1789}
1790
4370573a
RD
1791// Set all font style attributes at once.
1792void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
1793 const wxString& faceName,
1794 bool bold, bool italic,
1795 bool underline) {
1796 StyleSetSize(styleNum, size);
1797 StyleSetFaceName(styleNum, faceName);
1798 StyleSetBold(styleNum, bold);
1799 StyleSetItalic(styleNum, italic);
1800 StyleSetUnderline(styleNum, underline);
9ce192d4 1801
4370573a 1802 // TODO: add encoding/charset mapping
9ce192d4
RD
1803}
1804
1805
4370573a
RD
1806// Perform one of the operations defined by the wxSTC_CMD_* constants.
1807void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
1808 SendMsg(cmd);
9ce192d4
RD
1809}
1810
1811
4370573a
RD
1812// Set the left and right margin in the edit area, measured in pixels.
1813void wxStyledTextCtrl::SetMargins(int left, int right) {
1814 SetMarginLeft(left);
1815 SetMarginRight(right);
9ce192d4
RD
1816}
1817
1818
4370573a
RD
1819// Retrieve the start and end positions of the current selection.
1820void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) {
1821 if (startPos != NULL)
1822 *startPos = SendMsg(SCI_GETSELECTIONSTART);
1823 if (endPos != NULL)
1824 *endPos = SendMsg(SCI_GETSELECTIONEND);
9ce192d4
RD
1825}
1826
1827
4370573a
RD
1828// Retrieve the point in the window where a position is displayed.
1829wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
1830 int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
1831 int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
1832 return wxPoint(x, y);
f6bcfd97
BP
1833}
1834
f97d84a6
RD
1835// Scroll enough to make the given line visible
1836void wxStyledTextCtrl::ScrollToLine(int line) {
1837 m_swx->DoScrollToLine(line);
1838}
1839
1840
1841// Scroll enough to make the given column visible
1842void wxStyledTextCtrl::ScrollToColumn(int column) {
1843 m_swx->DoScrollToColumn(column);
1844}
1845
f6bcfd97 1846
d25f5fbb 1847
9ce192d4
RD
1848//----------------------------------------------------------------------
1849// Event handlers
1850
1851void wxStyledTextCtrl::OnPaint(wxPaintEvent& evt) {
1852 wxPaintDC dc(this);
1853 wxRegion region = GetUpdateRegion();
1854
1855 m_swx->DoPaint(&dc, region.GetBox());
1856}
1857
1858void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) {
1859 if (evt.GetOrientation() == wxHORIZONTAL)
1860 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
1861 else
1862 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
1863}
1864
5fa4613c
RD
1865void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
1866 wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar);
1867 if (sb) {
1868 if (sb->IsVertical())
1869 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
1870 else
1871 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
1872 }
1873}
1874
9ce192d4
RD
1875void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) {
1876 wxSize sz = GetClientSize();
1877 m_swx->DoSize(sz.x, sz.y);
10ef30eb 1878 Refresh(FALSE);
9ce192d4
RD
1879}
1880
1881void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
1882 wxPoint pt = evt.GetPosition();
1883 m_swx->DoButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
1884 evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
1885}
1886
1887void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
1888 wxPoint pt = evt.GetPosition();
1889 m_swx->DoButtonMove(Point(pt.x, pt.y));
1890}
1891
1892void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
1893 wxPoint pt = evt.GetPosition();
1894 m_swx->DoButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
1895 evt.ControlDown());
1896}
1897
1898
ddf2da08
RD
1899void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
1900 wxPoint pt = evt.GetPosition();
1901 m_swx->DoContextMenu(Point(pt.x, pt.y));
1902}
1903
1904
65ec6247 1905void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
9ce192d4 1906 wxPoint pt = evt.GetPosition();
65ec6247 1907 ScreenToClient(&pt.x, &pt.y);
9ce192d4
RD
1908 m_swx->DoContextMenu(Point(pt.x, pt.y));
1909}
1910
37d62433
RD
1911
1912void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
1913 m_swx->DoMouseWheel(evt.GetWheelRotation(),
1914 evt.GetWheelDelta(),
65ec6247
RD
1915 evt.GetLinesPerAction(),
1916 evt.ControlDown());
37d62433
RD
1917}
1918
1919
9ce192d4 1920void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
10ef30eb 1921 int key = evt.GetKeyCode();
f3c2c221 1922
f3c2c221
RD
1923 // On (some?) non-US keyboards the AltGr key is required to enter some
1924 // common characters. It comes to us as both Alt and Ctrl down so we need
1925 // to let the char through in that case, otherwise if only ctrl or only
1926 // alt let's skip it.
1927 bool ctrl = evt.ControlDown();
1928 bool alt = evt.AltDown();
00c64037 1929 bool skip = ((ctrl || alt) && ! (ctrl && alt));
f3c2c221 1930
10ef30eb
RD
1931 //printf("OnChar key:%d consumed:%d ctrl:%d alt:%d skip:%d\n",
1932 // key, m_lastKeyDownConsumed, ctrl, alt, skip);
1933
1934 if (key <= WXK_START && /*key >= 32 &&*/ !m_lastKeyDownConsumed && !skip) {
d25f5fbb 1935 m_swx->DoAddChar(key);
f3c2c221 1936 return;
d25f5fbb 1937 }
f3c2c221 1938 evt.Skip();
f6bcfd97
BP
1939}
1940
d6582821 1941
f6bcfd97 1942void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
10ef30eb 1943 int key = evt.GetKeyCode();
f3c2c221 1944 bool shift = evt.ShiftDown(),
10ef30eb
RD
1945 ctrl = evt.ControlDown(),
1946 alt = evt.AltDown();
f3c2c221
RD
1947
1948 int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed);
1949
1950// printf("key: %d shift: %d ctrl: %d alt: %d processed: %d consumed: %d\n",
1951// key, shift, ctrl, alt, processed, m_lastKeyDownConsumed);
1952
d6582821 1953 if (!processed && !m_lastKeyDownConsumed)
9ce192d4
RD
1954 evt.Skip();
1955}
1956
d6582821 1957
9ce192d4
RD
1958void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
1959 m_swx->DoLoseFocus();
1960}
1961
d6582821 1962
9ce192d4
RD
1963void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
1964 m_swx->DoGainFocus();
1965}
1966
d6582821 1967
9ce192d4
RD
1968void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& evt) {
1969 m_swx->DoSysColourChange();
1970}
1971
d6582821 1972
9ce192d4
RD
1973void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& evt) {
1974 // do nothing to help avoid flashing
1975}
1976
1977
1978
1979void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
1980 m_swx->DoCommand(evt.GetId());
1981}
1982
1983
f6bcfd97
BP
1984void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) {
1985 m_swx->DoOnListBox();
1986}
1987
1988
9ce192d4
RD
1989//----------------------------------------------------------------------
1990// Turn notifications from Scintilla into events
1991
f6bcfd97 1992
9ce192d4
RD
1993void wxStyledTextCtrl::NotifyChange() {
1994 wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId());
a29a241f 1995 evt.SetEventObject(this);
9ce192d4
RD
1996 GetEventHandler()->ProcessEvent(evt);
1997}
1998
1999void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
2000 SCNotification& scn = *_scn;
65ec6247
RD
2001 wxStyledTextEvent evt(0, GetId());
2002
a29a241f 2003 evt.SetEventObject(this);
65ec6247
RD
2004 evt.SetPosition(scn.position);
2005 evt.SetKey(scn.ch);
2006 evt.SetModifiers(scn.modifiers);
2007
9ce192d4
RD
2008 switch (scn.nmhdr.code) {
2009 case SCN_STYLENEEDED:
65ec6247 2010 evt.SetEventType(wxEVT_STC_STYLENEEDED);
9ce192d4 2011 break;
65ec6247 2012
9ce192d4 2013 case SCN_CHARADDED:
65ec6247 2014 evt.SetEventType(wxEVT_STC_CHARADDED);
9ce192d4 2015 break;
65ec6247 2016
9ce192d4 2017 case SCN_SAVEPOINTREACHED:
65ec6247 2018 evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED);
9ce192d4 2019 break;
65ec6247 2020
9ce192d4 2021 case SCN_SAVEPOINTLEFT:
65ec6247 2022 evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT);
9ce192d4 2023 break;
65ec6247 2024
9ce192d4 2025 case SCN_MODIFYATTEMPTRO:
65ec6247 2026 evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT);
9ce192d4 2027 break;
65ec6247
RD
2028
2029 case SCN_KEY:
2030 evt.SetEventType(wxEVT_STC_KEY);
2031 break;
2032
9ce192d4 2033 case SCN_DOUBLECLICK:
65ec6247 2034 evt.SetEventType(wxEVT_STC_DOUBLECLICK);
9ce192d4 2035 break;
65ec6247
RD
2036
2037 case SCN_UPDATEUI:
2038 evt.SetEventType(wxEVT_STC_UPDATEUI);
9ce192d4 2039 break;
65ec6247
RD
2040
2041 case SCN_MODIFIED:
2042 evt.SetEventType(wxEVT_STC_MODIFIED);
2043 evt.SetModificationType(scn.modificationType);
10ef30eb
RD
2044 if (scn.text) {
2045 // The unicode conversion MUST have a null byte to terminate the
2046 // string so move it into a buffer first and give it one.
2047 wxMemoryBuffer buf(scn.length+1);
2048 buf.AppendData((void*)scn.text, scn.length);
2049 buf.AppendByte(0);
2050 evt.SetText(wxString(buf, wxConvUTF8));
2051 }
65ec6247
RD
2052 evt.SetLength(scn.length);
2053 evt.SetLinesAdded(scn.linesAdded);
2054 evt.SetLine(scn.line);
2055 evt.SetFoldLevelNow(scn.foldLevelNow);
2056 evt.SetFoldLevelPrev(scn.foldLevelPrev);
9ce192d4 2057 break;
65ec6247 2058
9ce192d4 2059 case SCN_MACRORECORD:
65ec6247
RD
2060 evt.SetEventType(wxEVT_STC_MACRORECORD);
2061 evt.SetMessage(scn.message);
2062 evt.SetWParam(scn.wParam);
2063 evt.SetLParam(scn.lParam);
9ce192d4 2064 break;
65ec6247 2065
9ce192d4 2066 case SCN_MARGINCLICK:
65ec6247
RD
2067 evt.SetEventType(wxEVT_STC_MARGINCLICK);
2068 evt.SetMargin(scn.margin);
9ce192d4 2069 break;
65ec6247 2070
9ce192d4 2071 case SCN_NEEDSHOWN:
65ec6247
RD
2072 evt.SetEventType(wxEVT_STC_NEEDSHOWN);
2073 evt.SetLength(scn.length);
9ce192d4 2074 break;
65ec6247 2075
65ec6247
RD
2076 case SCN_PAINTED:
2077 evt.SetEventType(wxEVT_STC_PAINTED);
2078 break;
2079
2080 case SCN_USERLISTSELECTION:
2081 evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
2082 evt.SetListType(scn.listType);
2083 evt.SetText(scn.text);
2084 break;
2085
2086 case SCN_URIDROPPED:
2087 evt.SetEventType(wxEVT_STC_URIDROPPED);
2088 evt.SetText(scn.text);
2089 break;
2090
2091 case SCN_DWELLSTART:
2092 evt.SetEventType(wxEVT_STC_DWELLSTART);
2093 evt.SetX(scn.x);
2094 evt.SetY(scn.y);
2095 break;
2096
2097 case SCN_DWELLEND:
2098 evt.SetEventType(wxEVT_STC_DWELLEND);
2099 evt.SetX(scn.x);
2100 evt.SetY(scn.y);
2101 break;
2102
2103 default:
2104 return;
9ce192d4 2105 }
65ec6247
RD
2106
2107 GetEventHandler()->ProcessEvent(evt);
9ce192d4
RD
2108}
2109
2110
9ce192d4
RD
2111//----------------------------------------------------------------------
2112//----------------------------------------------------------------------
2113//----------------------------------------------------------------------
2114
2115wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
2116 : wxCommandEvent(commandType, id)
2117{
2118 m_position = 0;
2119 m_key = 0;
2120 m_modifiers = 0;
2121 m_modificationType = 0;
2122 m_length = 0;
2123 m_linesAdded = 0;
2124 m_line = 0;
2125 m_foldLevelNow = 0;
2126 m_foldLevelPrev = 0;
2127 m_margin = 0;
2128 m_message = 0;
2129 m_wParam = 0;
2130 m_lParam = 0;
65ec6247
RD
2131 m_listType = 0;
2132 m_x = 0;
2133 m_y = 0;
a29a241f
RD
2134 m_dragAllowMove = FALSE;
2135 m_dragResult = wxDragNone;
9ce192d4
RD
2136}
2137
2138bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
2139bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; }
2140bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; }
2141
5fa4613c 2142
41286fd1
JS
2143wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event):
2144 wxCommandEvent(event)
2145{
2146 m_position = event.m_position;
2147 m_key = event.m_key;
2148 m_modifiers = event.m_modifiers;
2149 m_modificationType = event.m_modificationType;
2150 m_text = event.m_text;
2151 m_length = event.m_length;
2152 m_linesAdded = event.m_linesAdded;
2153 m_line = event.m_line;
2154 m_foldLevelNow = event.m_foldLevelNow;
2155 m_foldLevelPrev = event.m_foldLevelPrev;
2156
2157 m_margin = event.m_margin;
2158
2159 m_message = event.m_message;
2160 m_wParam = event.m_wParam;
2161 m_lParam = event.m_lParam;
2162
2163 m_listType = event.m_listType;
2164 m_x = event.m_x;
2165 m_y = event.m_y;
9ce192d4 2166
41286fd1
JS
2167 m_dragText = event.m_dragText;
2168 m_dragAllowMove =event.m_dragAllowMove;
2169 m_dragResult = event.m_dragResult;
9ce192d4
RD
2170}
2171
2172//----------------------------------------------------------------------
2173//----------------------------------------------------------------------
2174
a29a241f
RD
2175
2176
2177
5fa4613c
RD
2178
2179
2180
2181
2182