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