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