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