]>
Commit | Line | Data |
---|---|---|
9ce192d4 RD |
1 | //////////////////////////////////////////////////////////////////////////// |
2 | // Name: stc.cpp | |
be5a51fb | 3 | // Purpose: A wxWidgets implementation of Scintilla. This class is the |
9ce192d4 RD |
4 | // one meant to be used directly by wx applications. It does not |
5 | // derive directly from the Scintilla classes, but instead | |
6 | // delegates most things to the real Scintilla class. | |
7 | // This allows the use of Scintilla without polluting the | |
f6bcfd97 | 8 | // namespace with all the classes and identifiers from Scintilla. |
9ce192d4 RD |
9 | // |
10 | // Author: Robin Dunn | |
11 | // | |
12 | // Created: 13-Jan-2000 | |
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 | ||
9e730a78 | 20 | #include <wx/wx.h> |
9ce192d4 | 21 | #include <wx/tokenzr.h> |
9e730a78 RD |
22 | #include <wx/mstream.h> |
23 | #include <wx/image.h> | |
51566b0b | 24 | #include <wx/file.h> |
9ce192d4 | 25 | |
f9ee2e27 RD |
26 | #include "wx/stc/stc.h" |
27 | #include "ScintillaWX.h" | |
f6bcfd97 | 28 | |
9ce192d4 RD |
29 | //---------------------------------------------------------------------- |
30 | ||
10ef30eb | 31 | const wxChar* wxSTCNameStr = wxT("stcwindow"); |
9ce192d4 | 32 | |
451c5cc7 RD |
33 | #ifdef MAKELONG |
34 | #undef MAKELONG | |
35 | #endif | |
36 | ||
37 | #define MAKELONG(a, b) ((a) | ((b) << 16)) | |
38 | ||
39 | ||
40 | static long wxColourAsLong(const wxColour& co) { | |
41 | return (((long)co.Blue() << 16) | | |
42 | ((long)co.Green() << 8) | | |
43 | ((long)co.Red())); | |
44 | } | |
45 | ||
46 | static wxColour wxColourFromLong(long c) { | |
47 | wxColour clr; | |
c8b75e94 WS |
48 | clr.Set((unsigned char)(c & 0xff), |
49 | (unsigned char)((c >> 8) & 0xff), | |
50 | (unsigned char)((c >> 16) & 0xff)); | |
451c5cc7 RD |
51 | return clr; |
52 | } | |
53 | ||
54 | ||
55 | static wxColour wxColourFromSpec(const wxString& spec) { | |
5ee1d760 RD |
56 | // spec should be a colour name or "#RRGGBB" |
57 | if (spec.GetChar(0) == wxT('#')) { | |
7e126a07 | 58 | |
5ee1d760 RD |
59 | long red, green, blue; |
60 | red = green = blue = 0; | |
61 | spec.Mid(1,2).ToLong(&red, 16); | |
62 | spec.Mid(3,2).ToLong(&green, 16); | |
63 | spec.Mid(5,2).ToLong(&blue, 16); | |
c8b75e94 WS |
64 | return wxColour((unsigned char)red, |
65 | (unsigned char)green, | |
66 | (unsigned char)blue); | |
5ee1d760 RD |
67 | } |
68 | else | |
69 | return wxColour(spec); | |
451c5cc7 RD |
70 | } |
71 | ||
72 | //---------------------------------------------------------------------- | |
73 | ||
d25f5fbb RD |
74 | DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE ) |
75 | DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED ) | |
76 | DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED ) | |
d25f5fbb RD |
77 | DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED ) |
78 | DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT ) | |
79 | DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT ) | |
65ec6247 | 80 | DEFINE_EVENT_TYPE( wxEVT_STC_KEY ) |
d25f5fbb | 81 | DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK ) |
65ec6247 | 82 | DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI ) |
d25f5fbb | 83 | DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED ) |
d25f5fbb RD |
84 | DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD ) |
85 | DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK ) | |
86 | DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN ) | |
65ec6247 RD |
87 | DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED ) |
88 | DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION ) | |
89 | DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED ) | |
90 | DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART ) | |
91 | DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND ) | |
a29a241f RD |
92 | DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG ) |
93 | DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER ) | |
94 | DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP ) | |
a834585d | 95 | DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM ) |
9e730a78 RD |
96 | DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK ) |
97 | DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK ) | |
98 | DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK ) | |
99 | ||
d25f5fbb RD |
100 | |
101 | ||
9ce192d4 RD |
102 | BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) |
103 | EVT_PAINT (wxStyledTextCtrl::OnPaint) | |
104 | EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin) | |
5fa4613c | 105 | EVT_SCROLL (wxStyledTextCtrl::OnScroll) |
9ce192d4 RD |
106 | EVT_SIZE (wxStyledTextCtrl::OnSize) |
107 | EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown) | |
4ceb1196 RD |
108 | // Let Scintilla see the double click as a second click |
109 | EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown) | |
9ce192d4 RD |
110 | EVT_MOTION (wxStyledTextCtrl::OnMouseMove) |
111 | EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp) | |
451c5cc7 | 112 | #if defined(__WXGTK__) || defined(__WXMAC__) |
ddf2da08 RD |
113 | EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp) |
114 | #else | |
65ec6247 | 115 | EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu) |
ddf2da08 | 116 | #endif |
37d62433 | 117 | EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel) |
2b5f62a0 | 118 | EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp) |
9ce192d4 | 119 | EVT_CHAR (wxStyledTextCtrl::OnChar) |
f6bcfd97 | 120 | EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown) |
9ce192d4 RD |
121 | EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus) |
122 | EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus) | |
123 | EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged) | |
124 | EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground) | |
dd4aa550 | 125 | EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu) |
7e126a07 | 126 | EVT_LISTBOX_DCLICK (wxID_ANY, wxStyledTextCtrl::OnListBox) |
9ce192d4 RD |
127 | END_EVENT_TABLE() |
128 | ||
f6bcfd97 BP |
129 | |
130 | IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl) | |
131 | IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent) | |
132 | ||
40716a51 | 133 | #ifdef LINK_LEXERS |
1a2fb4cd | 134 | // forces the linking of the lexer modules |
a834585d | 135 | int Scintilla_LinkLexers(); |
40716a51 | 136 | #endif |
1a2fb4cd | 137 | |
9ce192d4 RD |
138 | //---------------------------------------------------------------------- |
139 | // Constructor and Destructor | |
140 | ||
141 | wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent, | |
142 | wxWindowID id, | |
143 | const wxPoint& pos, | |
144 | const wxSize& size, | |
145 | long style, | |
39c0acb6 RD |
146 | const wxString& name) |
147 | { | |
148 | m_swx = NULL; | |
149 | Create(parent, id, pos, size, style, name); | |
150 | } | |
151 | ||
152 | ||
a48cb415 RD |
153 | bool wxStyledTextCtrl::Create(wxWindow *parent, |
154 | wxWindowID id, | |
155 | const wxPoint& pos, | |
156 | const wxSize& size, | |
157 | long style, | |
158 | const wxString& name) | |
9ce192d4 | 159 | { |
2659dad3 RD |
160 | #ifdef __WXMAC__ |
161 | style |= wxVSCROLL | wxHSCROLL; | |
162 | #endif | |
a48cb415 RD |
163 | if (!wxControl::Create(parent, id, pos, size, |
164 | style | wxWANTS_CHARS | wxCLIP_CHILDREN, | |
165 | wxDefaultValidator, name)) | |
166 | return false; | |
39c0acb6 | 167 | |
40716a51 | 168 | #ifdef LINK_LEXERS |
a834585d | 169 | Scintilla_LinkLexers(); |
40716a51 | 170 | #endif |
9ce192d4 | 171 | m_swx = new ScintillaWX(this); |
9ce192d4 | 172 | m_stopWatch.Start(); |
7e126a07 | 173 | m_lastKeyDownConsumed = false; |
5fa4613c RD |
174 | m_vScrollBar = NULL; |
175 | m_hScrollBar = NULL; | |
10ef30eb RD |
176 | #if wxUSE_UNICODE |
177 | // Put Scintilla into unicode (UTF-8) mode | |
178 | SetCodePage(wxSTC_CP_UTF8); | |
179 | #endif | |
8ae4f086 | 180 | |
f9ee2e27 RD |
181 | SetBestFittingSize(size); |
182 | ||
be108f96 JS |
183 | // Reduces flicker on GTK+/X11 |
184 | SetBackgroundStyle(wxBG_STYLE_CUSTOM); | |
a48cb415 | 185 | return true; |
9ce192d4 RD |
186 | } |
187 | ||
188 | ||
189 | wxStyledTextCtrl::~wxStyledTextCtrl() { | |
190 | delete m_swx; | |
9ce192d4 RD |
191 | } |
192 | ||
193 | ||
194 | //---------------------------------------------------------------------- | |
195 | ||
f6bcfd97 | 196 | long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) { |
9ce192d4 RD |
197 | |
198 | return m_swx->WndProc(msg, wp, lp); | |
199 | } | |
200 | ||
ccfc3219 RD |
201 | //---------------------------------------------------------------------- |
202 | ||
203 | // Set the vertical scrollbar to use instead of the ont that's built-in. | |
204 | void wxStyledTextCtrl::SetVScrollBar(wxScrollBar* bar) { | |
205 | m_vScrollBar = bar; | |
206 | if (bar != NULL) { | |
207 | // ensure that the built-in scrollbar is not visible | |
208 | SetScrollbar(wxVERTICAL, 0, 0, 0); | |
209 | } | |
210 | } | |
9ce192d4 | 211 | |
9ce192d4 | 212 | |
ccfc3219 RD |
213 | // Set the horizontal scrollbar to use instead of the ont that's built-in. |
214 | void wxStyledTextCtrl::SetHScrollBar(wxScrollBar* bar) { | |
215 | m_hScrollBar = bar; | |
216 | if (bar != NULL) { | |
217 | // ensure that the built-in scrollbar is not visible | |
218 | SetScrollbar(wxHORIZONTAL, 0, 0, 0); | |
219 | } | |
220 | } | |
221 | ||
4370573a RD |
222 | //---------------------------------------------------------------------- |
223 | // BEGIN generated section. The following code is automatically generated | |
224 | // by gen_iface.py from the contents of Scintilla.iface. Do not edit | |
225 | // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate. | |
9ce192d4 RD |
226 | |
227 | ||
591d01be | 228 | // Add text to the document at current position. |
9ce192d4 | 229 | void wxStyledTextCtrl::AddText(const wxString& text) { |
0c5b83b0 | 230 | wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); |
10ef30eb | 231 | SendMsg(2001, strlen(buf), (long)(const char*)buf); |
9ce192d4 RD |
232 | } |
233 | ||
a834585d | 234 | // Add array of cells to document. |
10ef30eb RD |
235 | void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer& data) { |
236 | SendMsg(2002, data.GetDataLen(), (long)data.GetData()); | |
9ce192d4 RD |
237 | } |
238 | ||
a834585d | 239 | // Insert string at a position. |
9ce192d4 | 240 | void wxStyledTextCtrl::InsertText(int pos, const wxString& text) { |
0c5b83b0 | 241 | SendMsg(2003, pos, (long)(const char*)wx2stc(text)); |
9ce192d4 RD |
242 | } |
243 | ||
a834585d | 244 | // Delete all text in the document. |
9ce192d4 | 245 | void wxStyledTextCtrl::ClearAll() { |
4370573a | 246 | SendMsg(2004, 0, 0); |
9ce192d4 RD |
247 | } |
248 | ||
a834585d | 249 | // Set all style bytes to 0, remove all folding information. |
4370573a RD |
250 | void wxStyledTextCtrl::ClearDocumentStyle() { |
251 | SendMsg(2005, 0, 0); | |
9ce192d4 RD |
252 | } |
253 | ||
591d01be | 254 | // Returns the number of characters in the document. |
4370573a RD |
255 | int wxStyledTextCtrl::GetLength() { |
256 | return SendMsg(2006, 0, 0); | |
9ce192d4 RD |
257 | } |
258 | ||
a834585d | 259 | // Returns the character byte at the position. |
4370573a | 260 | int wxStyledTextCtrl::GetCharAt(int pos) { |
9e730a78 | 261 | return (unsigned char)SendMsg(2007, pos, 0); |
9ce192d4 RD |
262 | } |
263 | ||
a834585d | 264 | // Returns the position of the caret. |
4370573a RD |
265 | int wxStyledTextCtrl::GetCurrentPos() { |
266 | return SendMsg(2008, 0, 0); | |
9ce192d4 RD |
267 | } |
268 | ||
a834585d | 269 | // Returns the position of the opposite end of the selection to the caret. |
4370573a RD |
270 | int wxStyledTextCtrl::GetAnchor() { |
271 | return SendMsg(2009, 0, 0); | |
9ce192d4 RD |
272 | } |
273 | ||
a834585d | 274 | // Returns the style byte at the position. |
4370573a | 275 | int wxStyledTextCtrl::GetStyleAt(int pos) { |
9e730a78 | 276 | return (unsigned char)SendMsg(2010, pos, 0); |
9ce192d4 RD |
277 | } |
278 | ||
a834585d | 279 | // Redoes the next action on the undo history. |
9ce192d4 | 280 | void wxStyledTextCtrl::Redo() { |
4370573a | 281 | SendMsg(2011, 0, 0); |
9ce192d4 RD |
282 | } |
283 | ||
4370573a RD |
284 | // Choose between collecting actions into the undo |
285 | // history and discarding them. | |
286 | void wxStyledTextCtrl::SetUndoCollection(bool collectUndo) { | |
287 | SendMsg(2012, collectUndo, 0); | |
9ce192d4 RD |
288 | } |
289 | ||
4370573a RD |
290 | // Select all the text in the document. |
291 | void wxStyledTextCtrl::SelectAll() { | |
292 | SendMsg(2013, 0, 0); | |
9ce192d4 RD |
293 | } |
294 | ||
4370573a RD |
295 | // Remember the current position in the undo history as the position |
296 | // at which the document was saved. | |
297 | void wxStyledTextCtrl::SetSavePoint() { | |
298 | SendMsg(2014, 0, 0); | |
9ce192d4 RD |
299 | } |
300 | ||
4370573a | 301 | // Retrieve a buffer of cells. |
10ef30eb | 302 | wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) { |
9e730a78 RD |
303 | wxMemoryBuffer buf; |
304 | if (endPos < startPos) { | |
305 | int temp = startPos; | |
306 | startPos = endPos; | |
307 | endPos = temp; | |
308 | } | |
309 | int len = endPos - startPos; | |
310 | if (!len) return buf; | |
311 | TextRange tr; | |
312 | tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1); | |
313 | tr.chrg.cpMin = startPos; | |
314 | tr.chrg.cpMax = endPos; | |
315 | len = SendMsg(2015, 0, (long)&tr); | |
316 | buf.UngetWriteBuf(len); | |
317 | return buf; | |
9ce192d4 RD |
318 | } |
319 | ||
a834585d | 320 | // Are there any redoable actions in the undo history? |
4370573a RD |
321 | bool wxStyledTextCtrl::CanRedo() { |
322 | return SendMsg(2016, 0, 0) != 0; | |
9ce192d4 RD |
323 | } |
324 | ||
a834585d | 325 | // Retrieve the line number at which a particular marker is located. |
4370573a RD |
326 | int wxStyledTextCtrl::MarkerLineFromHandle(int handle) { |
327 | return SendMsg(2017, handle, 0); | |
9ce192d4 RD |
328 | } |
329 | ||
4370573a RD |
330 | // Delete a marker. |
331 | void wxStyledTextCtrl::MarkerDeleteHandle(int handle) { | |
332 | SendMsg(2018, handle, 0); | |
9ce192d4 RD |
333 | } |
334 | ||
4370573a RD |
335 | // Is undo history being collected? |
336 | bool wxStyledTextCtrl::GetUndoCollection() { | |
337 | return SendMsg(2019, 0, 0) != 0; | |
9ce192d4 RD |
338 | } |
339 | ||
4370573a RD |
340 | // Are white space characters currently visible? |
341 | // Returns one of SCWS_* constants. | |
342 | int wxStyledTextCtrl::GetViewWhiteSpace() { | |
343 | return SendMsg(2020, 0, 0); | |
9ce192d4 RD |
344 | } |
345 | ||
4370573a RD |
346 | // Make white space characters invisible, always visible or visible outside indentation. |
347 | void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS) { | |
348 | SendMsg(2021, viewWS, 0); | |
9ce192d4 RD |
349 | } |
350 | ||
4370573a | 351 | // Find the position from a point within the window. |
9ce192d4 | 352 | int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) { |
9e730a78 | 353 | return SendMsg(2022, pt.x, pt.y); |
9ce192d4 RD |
354 | } |
355 | ||
65ec6247 RD |
356 | // Find the position from a point within the window but return |
357 | // INVALID_POSITION if not close to text. | |
358 | int wxStyledTextCtrl::PositionFromPointClose(int x, int y) { | |
359 | return SendMsg(2023, x, y); | |
360 | } | |
361 | ||
4370573a RD |
362 | // Set caret to start of a line and ensure it is visible. |
363 | void wxStyledTextCtrl::GotoLine(int line) { | |
364 | SendMsg(2024, line, 0); | |
9ce192d4 RD |
365 | } |
366 | ||
4370573a | 367 | // Set caret to a position and ensure it is visible. |
9ce192d4 | 368 | void wxStyledTextCtrl::GotoPos(int pos) { |
4370573a | 369 | SendMsg(2025, pos, 0); |
9ce192d4 RD |
370 | } |
371 | ||
4370573a RD |
372 | // Set the selection anchor to a position. The anchor is the opposite |
373 | // end of the selection from the caret. | |
374 | void wxStyledTextCtrl::SetAnchor(int posAnchor) { | |
375 | SendMsg(2026, posAnchor, 0); | |
9ce192d4 RD |
376 | } |
377 | ||
4370573a RD |
378 | // Retrieve the text of the line containing the caret. |
379 | // Returns the index of the caret on the line. | |
380 | wxString wxStyledTextCtrl::GetCurLine(int* linePos) { | |
9e730a78 RD |
381 | int len = LineLength(GetCurrentLine()); |
382 | if (!len) { | |
383 | if (linePos) *linePos = 0; | |
384 | return wxEmptyString; | |
385 | } | |
10ef30eb | 386 | |
9e730a78 RD |
387 | wxMemoryBuffer mbuf(len+1); |
388 | char* buf = (char*)mbuf.GetWriteBuf(len+1); | |
8de28db9 | 389 | |
9e730a78 RD |
390 | int pos = SendMsg(2027, len+1, (long)buf); |
391 | mbuf.UngetWriteBuf(len); | |
392 | mbuf.AppendByte(0); | |
393 | if (linePos) *linePos = pos; | |
394 | return stc2wx(buf); | |
9ce192d4 RD |
395 | } |
396 | ||
4370573a RD |
397 | // Retrieve the position of the last correctly styled character. |
398 | int wxStyledTextCtrl::GetEndStyled() { | |
399 | return SendMsg(2028, 0, 0); | |
9ce192d4 RD |
400 | } |
401 | ||
65ec6247 RD |
402 | // Convert all line endings in the document to one mode. |
403 | void wxStyledTextCtrl::ConvertEOLs(int eolMode) { | |
404 | SendMsg(2029, eolMode, 0); | |
9ce192d4 RD |
405 | } |
406 | ||
4370573a RD |
407 | // Retrieve the current end of line mode - one of CRLF, CR, or LF. |
408 | int wxStyledTextCtrl::GetEOLMode() { | |
409 | return SendMsg(2030, 0, 0); | |
9ce192d4 RD |
410 | } |
411 | ||
4370573a RD |
412 | // Set the current end of line mode. |
413 | void wxStyledTextCtrl::SetEOLMode(int eolMode) { | |
414 | SendMsg(2031, eolMode, 0); | |
9ce192d4 RD |
415 | } |
416 | ||
4370573a | 417 | // Set the current styling position to pos and the styling mask to mask. |
a834585d | 418 | // The styling mask can be used to protect some bits in each styling byte from modification. |
4370573a RD |
419 | void wxStyledTextCtrl::StartStyling(int pos, int mask) { |
420 | SendMsg(2032, pos, mask); | |
9ce192d4 RD |
421 | } |
422 | ||
4370573a RD |
423 | // Change style from current styling position for length characters to a style |
424 | // and move the current styling position to after this newly styled segment. | |
425 | void wxStyledTextCtrl::SetStyling(int length, int style) { | |
426 | SendMsg(2033, length, style); | |
f6bcfd97 BP |
427 | } |
428 | ||
a834585d | 429 | // Is drawing done first into a buffer or direct to the screen? |
4370573a RD |
430 | bool wxStyledTextCtrl::GetBufferedDraw() { |
431 | return SendMsg(2034, 0, 0) != 0; | |
f6bcfd97 BP |
432 | } |
433 | ||
4370573a RD |
434 | // If drawing is buffered then each line of text is drawn into a bitmap buffer |
435 | // before drawing it to the screen to avoid flicker. | |
436 | void wxStyledTextCtrl::SetBufferedDraw(bool buffered) { | |
437 | SendMsg(2035, buffered, 0); | |
f6bcfd97 BP |
438 | } |
439 | ||
a834585d | 440 | // Change the visible size of a tab to be a multiple of the width of a space character. |
4370573a RD |
441 | void wxStyledTextCtrl::SetTabWidth(int tabWidth) { |
442 | SendMsg(2036, tabWidth, 0); | |
f6bcfd97 BP |
443 | } |
444 | ||
4370573a RD |
445 | // Retrieve the visible size of a tab. |
446 | int wxStyledTextCtrl::GetTabWidth() { | |
447 | return SendMsg(2121, 0, 0); | |
9ce192d4 RD |
448 | } |
449 | ||
4370573a | 450 | // Set the code page used to interpret the bytes of the document as characters. |
4370573a | 451 | void wxStyledTextCtrl::SetCodePage(int codePage) { |
10ef30eb RD |
452 | #if wxUSE_UNICODE |
453 | wxASSERT_MSG(codePage == wxSTC_CP_UTF8, | |
454 | wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on.")); | |
455 | #else | |
456 | wxASSERT_MSG(codePage != wxSTC_CP_UTF8, | |
457 | wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off.")); | |
458 | #endif | |
9e730a78 | 459 | SendMsg(2037, codePage); |
9ce192d4 RD |
460 | } |
461 | ||
4370573a | 462 | // Set the symbol used for a particular marker number, |
1a2fb4cd | 463 | // and optionally the fore and background colours. |
4370573a | 464 | void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol, |
9e730a78 RD |
465 | const wxColour& foreground, |
466 | const wxColour& background) { | |
9ce192d4 | 467 | |
9e730a78 RD |
468 | SendMsg(2040, markerNumber, markerSymbol); |
469 | if (foreground.Ok()) | |
470 | MarkerSetForeground(markerNumber, foreground); | |
471 | if (background.Ok()) | |
472 | MarkerSetBackground(markerNumber, background); | |
9ce192d4 RD |
473 | } |
474 | ||
4370573a RD |
475 | // Set the foreground colour used for a particular marker number. |
476 | void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore) { | |
477 | SendMsg(2041, markerNumber, wxColourAsLong(fore)); | |
9ce192d4 RD |
478 | } |
479 | ||
4370573a RD |
480 | // Set the background colour used for a particular marker number. |
481 | void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back) { | |
482 | SendMsg(2042, markerNumber, wxColourAsLong(back)); | |
9ce192d4 RD |
483 | } |
484 | ||
1a2fb4cd RD |
485 | // Add a marker to a line, returning an ID which can be used to find or delete the marker. |
486 | int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) { | |
487 | return SendMsg(2043, line, markerNumber); | |
9ce192d4 RD |
488 | } |
489 | ||
a834585d | 490 | // Delete a marker from a line. |
4370573a RD |
491 | void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber) { |
492 | SendMsg(2044, line, markerNumber); | |
9ce192d4 RD |
493 | } |
494 | ||
a834585d | 495 | // Delete all markers with a particular number from all lines. |
4370573a RD |
496 | void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber) { |
497 | SendMsg(2045, markerNumber, 0); | |
9ce192d4 RD |
498 | } |
499 | ||
4370573a RD |
500 | // Get a bit mask of all the markers set on a line. |
501 | int wxStyledTextCtrl::MarkerGet(int line) { | |
502 | return SendMsg(2046, line, 0); | |
9ce192d4 RD |
503 | } |
504 | ||
4370573a RD |
505 | // Find the next line after lineStart that includes a marker in mask. |
506 | int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask) { | |
507 | return SendMsg(2047, lineStart, markerMask); | |
9ce192d4 RD |
508 | } |
509 | ||
4370573a RD |
510 | // Find the previous line before lineStart that includes a marker in mask. |
511 | int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask) { | |
512 | return SendMsg(2048, lineStart, markerMask); | |
9ce192d4 RD |
513 | } |
514 | ||
9e730a78 RD |
515 | // Define a marker from a bitmap |
516 | void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp) { | |
517 | // convert bmp to a xpm in a string | |
518 | wxMemoryOutputStream strm; | |
519 | wxImage img = bmp.ConvertToImage(); | |
520 | img.SaveFile(strm, wxBITMAP_TYPE_XPM); | |
521 | size_t len = strm.GetSize(); | |
522 | char* buff = new char[len+1]; | |
523 | strm.CopyTo(buff, len); | |
524 | buff[len] = 0; | |
525 | SendMsg(2049, markerNumber, (long)buff); | |
526 | delete [] buff; | |
a5b274d7 | 527 | |
9e730a78 RD |
528 | } |
529 | ||
4370573a RD |
530 | // Set a margin to be either numeric or symbolic. |
531 | void wxStyledTextCtrl::SetMarginType(int margin, int marginType) { | |
532 | SendMsg(2240, margin, marginType); | |
9ce192d4 RD |
533 | } |
534 | ||
4370573a RD |
535 | // Retrieve the type of a margin. |
536 | int wxStyledTextCtrl::GetMarginType(int margin) { | |
537 | return SendMsg(2241, margin, 0); | |
9ce192d4 RD |
538 | } |
539 | ||
4370573a RD |
540 | // Set the width of a margin to a width expressed in pixels. |
541 | void wxStyledTextCtrl::SetMarginWidth(int margin, int pixelWidth) { | |
542 | SendMsg(2242, margin, pixelWidth); | |
9ce192d4 RD |
543 | } |
544 | ||
4370573a RD |
545 | // Retrieve the width of a margin in pixels. |
546 | int wxStyledTextCtrl::GetMarginWidth(int margin) { | |
547 | return SendMsg(2243, margin, 0); | |
f6bcfd97 BP |
548 | } |
549 | ||
4370573a RD |
550 | // Set a mask that determines which markers are displayed in a margin. |
551 | void wxStyledTextCtrl::SetMarginMask(int margin, int mask) { | |
552 | SendMsg(2244, margin, mask); | |
f6bcfd97 BP |
553 | } |
554 | ||
4370573a RD |
555 | // Retrieve the marker mask of a margin. |
556 | int wxStyledTextCtrl::GetMarginMask(int margin) { | |
557 | return SendMsg(2245, margin, 0); | |
9ce192d4 RD |
558 | } |
559 | ||
4370573a RD |
560 | // Make a margin sensitive or insensitive to mouse clicks. |
561 | void wxStyledTextCtrl::SetMarginSensitive(int margin, bool sensitive) { | |
562 | SendMsg(2246, margin, sensitive); | |
9ce192d4 RD |
563 | } |
564 | ||
4370573a RD |
565 | // Retrieve the mouse click sensitivity of a margin. |
566 | bool wxStyledTextCtrl::GetMarginSensitive(int margin) { | |
567 | return SendMsg(2247, margin, 0) != 0; | |
9ce192d4 RD |
568 | } |
569 | ||
4370573a | 570 | // Clear all the styles and make equivalent to the global default style. |
9ce192d4 | 571 | void wxStyledTextCtrl::StyleClearAll() { |
4370573a | 572 | SendMsg(2050, 0, 0); |
9ce192d4 RD |
573 | } |
574 | ||
4370573a RD |
575 | // Set the foreground colour of a style. |
576 | void wxStyledTextCtrl::StyleSetForeground(int style, const wxColour& fore) { | |
577 | SendMsg(2051, style, wxColourAsLong(fore)); | |
9ce192d4 RD |
578 | } |
579 | ||
4370573a RD |
580 | // Set the background colour of a style. |
581 | void wxStyledTextCtrl::StyleSetBackground(int style, const wxColour& back) { | |
582 | SendMsg(2052, style, wxColourAsLong(back)); | |
9ce192d4 RD |
583 | } |
584 | ||
4370573a RD |
585 | // Set a style to be bold or not. |
586 | void wxStyledTextCtrl::StyleSetBold(int style, bool bold) { | |
587 | SendMsg(2053, style, bold); | |
9ce192d4 RD |
588 | } |
589 | ||
4370573a RD |
590 | // Set a style to be italic or not. |
591 | void wxStyledTextCtrl::StyleSetItalic(int style, bool italic) { | |
592 | SendMsg(2054, style, italic); | |
9ce192d4 RD |
593 | } |
594 | ||
4370573a RD |
595 | // Set the size of characters of a style. |
596 | void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints) { | |
597 | SendMsg(2055, style, sizePoints); | |
9ce192d4 RD |
598 | } |
599 | ||
4370573a RD |
600 | // Set the font of a style. |
601 | void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) { | |
0c5b83b0 | 602 | SendMsg(2056, style, (long)(const char*)wx2stc(fontName)); |
9ce192d4 RD |
603 | } |
604 | ||
4370573a RD |
605 | // Set a style to have its end of line filled or not. |
606 | void wxStyledTextCtrl::StyleSetEOLFilled(int style, bool filled) { | |
607 | SendMsg(2057, style, filled); | |
9ce192d4 RD |
608 | } |
609 | ||
4370573a RD |
610 | // Reset the default style to its state at startup |
611 | void wxStyledTextCtrl::StyleResetDefault() { | |
612 | SendMsg(2058, 0, 0); | |
9ce192d4 RD |
613 | } |
614 | ||
4370573a RD |
615 | // Set a style to be underlined or not. |
616 | void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline) { | |
617 | SendMsg(2059, style, underline); | |
9ce192d4 RD |
618 | } |
619 | ||
65ec6247 RD |
620 | // Set a style to be mixed case, or to force upper or lower case. |
621 | void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) { | |
622 | SendMsg(2060, style, caseForce); | |
623 | } | |
624 | ||
9e730a78 RD |
625 | // Set a style to be a hotspot or not. |
626 | void wxStyledTextCtrl::StyleSetHotSpot(int style, bool hotspot) { | |
627 | SendMsg(2409, style, hotspot); | |
628 | } | |
629 | ||
4370573a RD |
630 | // Set the foreground colour of the selection and whether to use this setting. |
631 | void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) { | |
632 | SendMsg(2067, useSetting, wxColourAsLong(fore)); | |
9ce192d4 RD |
633 | } |
634 | ||
4370573a RD |
635 | // Set the background colour of the selection and whether to use this setting. |
636 | void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back) { | |
637 | SendMsg(2068, useSetting, wxColourAsLong(back)); | |
9ce192d4 RD |
638 | } |
639 | ||
4370573a RD |
640 | // Set the foreground colour of the caret. |
641 | void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore) { | |
642 | SendMsg(2069, wxColourAsLong(fore), 0); | |
9ce192d4 RD |
643 | } |
644 | ||
4370573a RD |
645 | // When key+modifier combination km is pressed perform msg. |
646 | void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) { | |
9e730a78 | 647 | SendMsg(2070, MAKELONG(key, modifiers), cmd); |
9ce192d4 RD |
648 | } |
649 | ||
8e54aaed | 650 | // When key+modifier combination km is pressed do nothing. |
4370573a | 651 | void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) { |
9e730a78 | 652 | SendMsg(2071, MAKELONG(key, modifiers)); |
9ce192d4 RD |
653 | } |
654 | ||
4370573a RD |
655 | // Drop all key mappings. |
656 | void wxStyledTextCtrl::CmdKeyClearAll() { | |
657 | SendMsg(2072, 0, 0); | |
658 | } | |
9ce192d4 | 659 | |
4370573a RD |
660 | // Set the styles for a segment of the document. |
661 | void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) { | |
9e730a78 | 662 | SendMsg(2073, length, (long)styleBytes); |
9ce192d4 RD |
663 | } |
664 | ||
4370573a RD |
665 | // Set a style to be visible or not. |
666 | void wxStyledTextCtrl::StyleSetVisible(int style, bool visible) { | |
667 | SendMsg(2074, style, visible); | |
668 | } | |
9ce192d4 | 669 | |
4370573a | 670 | // Get the time in milliseconds that the caret is on and off. |
9ce192d4 | 671 | int wxStyledTextCtrl::GetCaretPeriod() { |
4370573a | 672 | return SendMsg(2075, 0, 0); |
9ce192d4 RD |
673 | } |
674 | ||
4370573a RD |
675 | // Get the time in milliseconds that the caret is on and off. 0 = steady on. |
676 | void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) { | |
677 | SendMsg(2076, periodMilliseconds, 0); | |
678 | } | |
9ce192d4 | 679 | |
a834585d | 680 | // Set the set of characters making up words for when moving or selecting by word. |
8e54aaed | 681 | // First sets deaults like SetCharsDefault. |
4370573a | 682 | void wxStyledTextCtrl::SetWordChars(const wxString& characters) { |
0c5b83b0 | 683 | SendMsg(2077, 0, (long)(const char*)wx2stc(characters)); |
9ce192d4 RD |
684 | } |
685 | ||
4370573a RD |
686 | // Start a sequence of actions that is undone and redone as a unit. |
687 | // May be nested. | |
688 | void wxStyledTextCtrl::BeginUndoAction() { | |
689 | SendMsg(2078, 0, 0); | |
690 | } | |
9ce192d4 | 691 | |
4370573a RD |
692 | // End a sequence of actions that is undone and redone as a unit. |
693 | void wxStyledTextCtrl::EndUndoAction() { | |
694 | SendMsg(2079, 0, 0); | |
695 | } | |
9ce192d4 | 696 | |
4370573a RD |
697 | // Set an indicator to plain, squiggle or TT. |
698 | void wxStyledTextCtrl::IndicatorSetStyle(int indic, int style) { | |
699 | SendMsg(2080, indic, style); | |
700 | } | |
9ce192d4 | 701 | |
4370573a RD |
702 | // Retrieve the style of an indicator. |
703 | int wxStyledTextCtrl::IndicatorGetStyle(int indic) { | |
704 | return SendMsg(2081, indic, 0); | |
705 | } | |
9ce192d4 | 706 | |
4370573a RD |
707 | // Set the foreground colour of an indicator. |
708 | void wxStyledTextCtrl::IndicatorSetForeground(int indic, const wxColour& fore) { | |
709 | SendMsg(2082, indic, wxColourAsLong(fore)); | |
9ce192d4 RD |
710 | } |
711 | ||
4370573a RD |
712 | // Retrieve the foreground colour of an indicator. |
713 | wxColour wxStyledTextCtrl::IndicatorGetForeground(int indic) { | |
714 | long c = SendMsg(2083, indic, 0); | |
715 | return wxColourFromLong(c); | |
716 | } | |
9ce192d4 | 717 | |
f114b858 RD |
718 | // Set the foreground colour of all whitespace and whether to use this setting. |
719 | void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting, const wxColour& fore) { | |
720 | SendMsg(2084, useSetting, wxColourAsLong(fore)); | |
721 | } | |
722 | ||
723 | // Set the background colour of all whitespace and whether to use this setting. | |
724 | void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting, const wxColour& back) { | |
725 | SendMsg(2085, useSetting, wxColourAsLong(back)); | |
726 | } | |
727 | ||
a834585d RD |
728 | // Divide each styling byte into lexical class bits (default: 5) and indicator |
729 | // bits (default: 3). If a lexer requires more than 32 lexical states, then this | |
4370573a RD |
730 | // is used to expand the possible states. |
731 | void wxStyledTextCtrl::SetStyleBits(int bits) { | |
732 | SendMsg(2090, bits, 0); | |
9ce192d4 RD |
733 | } |
734 | ||
4370573a RD |
735 | // Retrieve number of bits in style bytes used to hold the lexical state. |
736 | int wxStyledTextCtrl::GetStyleBits() { | |
737 | return SendMsg(2091, 0, 0); | |
738 | } | |
9ce192d4 | 739 | |
4370573a RD |
740 | // Used to hold extra styling information for each line. |
741 | void wxStyledTextCtrl::SetLineState(int line, int state) { | |
742 | SendMsg(2092, line, state); | |
f6bcfd97 BP |
743 | } |
744 | ||
4370573a RD |
745 | // Retrieve the extra styling information for a line. |
746 | int wxStyledTextCtrl::GetLineState(int line) { | |
747 | return SendMsg(2093, line, 0); | |
748 | } | |
f6bcfd97 | 749 | |
4370573a RD |
750 | // Retrieve the last line number that has line state. |
751 | int wxStyledTextCtrl::GetMaxLineState() { | |
752 | return SendMsg(2094, 0, 0); | |
f6bcfd97 BP |
753 | } |
754 | ||
65ec6247 RD |
755 | // Is the background of the line containing the caret in a different colour? |
756 | bool wxStyledTextCtrl::GetCaretLineVisible() { | |
757 | return SendMsg(2095, 0, 0) != 0; | |
758 | } | |
759 | ||
a834585d | 760 | // Display the background of the line containing the caret in a different colour. |
65ec6247 RD |
761 | void wxStyledTextCtrl::SetCaretLineVisible(bool show) { |
762 | SendMsg(2096, show, 0); | |
763 | } | |
764 | ||
765 | // Get the colour of the background of the line containing the caret. | |
766 | wxColour wxStyledTextCtrl::GetCaretLineBack() { | |
767 | long c = SendMsg(2097, 0, 0); | |
768 | return wxColourFromLong(c); | |
769 | } | |
770 | ||
771 | // Set the colour of the background of the line containing the caret. | |
772 | void wxStyledTextCtrl::SetCaretLineBack(const wxColour& back) { | |
773 | SendMsg(2098, wxColourAsLong(back), 0); | |
774 | } | |
775 | ||
1a2fb4cd RD |
776 | // Set a style to be changeable or not (read only). |
777 | // Experimental feature, currently buggy. | |
778 | void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable) { | |
779 | SendMsg(2099, style, changeable); | |
780 | } | |
781 | ||
4370573a RD |
782 | // Display a auto-completion list. |
783 | // The lenEntered parameter indicates how many characters before | |
784 | // the caret should be used to provide context. | |
785 | void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) { | |
0c5b83b0 | 786 | SendMsg(2100, lenEntered, (long)(const char*)wx2stc(itemList)); |
4370573a | 787 | } |
f6bcfd97 | 788 | |
4370573a RD |
789 | // Remove the auto-completion list from the screen. |
790 | void wxStyledTextCtrl::AutoCompCancel() { | |
791 | SendMsg(2101, 0, 0); | |
f6bcfd97 BP |
792 | } |
793 | ||
4370573a RD |
794 | // Is there an auto-completion list visible? |
795 | bool wxStyledTextCtrl::AutoCompActive() { | |
796 | return SendMsg(2102, 0, 0) != 0; | |
797 | } | |
f6bcfd97 | 798 | |
a834585d | 799 | // Retrieve the position of the caret when the auto-completion list was displayed. |
4370573a RD |
800 | int wxStyledTextCtrl::AutoCompPosStart() { |
801 | return SendMsg(2103, 0, 0); | |
f6bcfd97 BP |
802 | } |
803 | ||
4370573a RD |
804 | // User has selected an item so remove the list and insert the selection. |
805 | void wxStyledTextCtrl::AutoCompComplete() { | |
806 | SendMsg(2104, 0, 0); | |
807 | } | |
f6bcfd97 | 808 | |
4370573a RD |
809 | // Define a set of character that when typed cancel the auto-completion list. |
810 | void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) { | |
0c5b83b0 | 811 | SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet)); |
f6bcfd97 BP |
812 | } |
813 | ||
a834585d RD |
814 | // Change the separator character in the string setting up an auto-completion list. |
815 | // Default is space but can be changed if items contain space. | |
4370573a RD |
816 | void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter) { |
817 | SendMsg(2106, separatorCharacter, 0); | |
818 | } | |
f6bcfd97 | 819 | |
4370573a RD |
820 | // Retrieve the auto-completion list separator character. |
821 | int wxStyledTextCtrl::AutoCompGetSeparator() { | |
822 | return SendMsg(2107, 0, 0); | |
9ce192d4 RD |
823 | } |
824 | ||
4370573a RD |
825 | // Select the item in the auto-completion list that starts with a string. |
826 | void wxStyledTextCtrl::AutoCompSelect(const wxString& text) { | |
0c5b83b0 | 827 | SendMsg(2108, 0, (long)(const char*)wx2stc(text)); |
4370573a | 828 | } |
9ce192d4 | 829 | |
4370573a RD |
830 | // Should the auto-completion list be cancelled if the user backspaces to a |
831 | // position before where the box was created. | |
832 | void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel) { | |
833 | SendMsg(2110, cancel, 0); | |
f6bcfd97 BP |
834 | } |
835 | ||
4370573a RD |
836 | // Retrieve whether auto-completion cancelled by backspacing before start. |
837 | bool wxStyledTextCtrl::AutoCompGetCancelAtStart() { | |
838 | return SendMsg(2111, 0, 0) != 0; | |
839 | } | |
f6bcfd97 | 840 | |
1a2fb4cd RD |
841 | // Define a set of characters that when typed will cause the autocompletion to |
842 | // choose the selected item. | |
4370573a | 843 | void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) { |
0c5b83b0 | 844 | SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet)); |
4370573a | 845 | } |
9ce192d4 | 846 | |
4370573a RD |
847 | // Should a single item auto-completion list automatically choose the item. |
848 | void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle) { | |
849 | SendMsg(2113, chooseSingle, 0); | |
850 | } | |
9ce192d4 | 851 | |
4370573a RD |
852 | // Retrieve whether a single item auto-completion list automatically choose the item. |
853 | bool wxStyledTextCtrl::AutoCompGetChooseSingle() { | |
854 | return SendMsg(2114, 0, 0) != 0; | |
9ce192d4 RD |
855 | } |
856 | ||
4370573a RD |
857 | // Set whether case is significant when performing auto-completion searches. |
858 | void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase) { | |
859 | SendMsg(2115, ignoreCase, 0); | |
860 | } | |
9ce192d4 | 861 | |
4370573a RD |
862 | // Retrieve state of ignore case flag. |
863 | bool wxStyledTextCtrl::AutoCompGetIgnoreCase() { | |
864 | return SendMsg(2116, 0, 0) != 0; | |
9ce192d4 RD |
865 | } |
866 | ||
65ec6247 RD |
867 | // Display a list of strings and send notification when user chooses one. |
868 | void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) { | |
0c5b83b0 | 869 | SendMsg(2117, listType, (long)(const char*)wx2stc(itemList)); |
65ec6247 RD |
870 | } |
871 | ||
a834585d | 872 | // Set whether or not autocompletion is hidden automatically when nothing matches. |
65ec6247 RD |
873 | void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide) { |
874 | SendMsg(2118, autoHide, 0); | |
875 | } | |
876 | ||
a834585d | 877 | // Retrieve whether or not autocompletion is hidden automatically when nothing matches. |
65ec6247 RD |
878 | bool wxStyledTextCtrl::AutoCompGetAutoHide() { |
879 | return SendMsg(2119, 0, 0) != 0; | |
880 | } | |
881 | ||
a834585d RD |
882 | // Set whether or not autocompletion deletes any word characters |
883 | // after the inserted text upon completion. | |
1a2fb4cd RD |
884 | void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord) { |
885 | SendMsg(2270, dropRestOfWord, 0); | |
886 | } | |
887 | ||
a834585d RD |
888 | // Retrieve whether or not autocompletion deletes any word characters |
889 | // after the inserted text upon completion. | |
1a2fb4cd RD |
890 | bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() { |
891 | return SendMsg(2271, 0, 0) != 0; | |
892 | } | |
893 | ||
9e730a78 RD |
894 | // Register an image for use in autocompletion lists. |
895 | void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) { | |
896 | // convert bmp to a xpm in a string | |
897 | wxMemoryOutputStream strm; | |
898 | wxImage img = bmp.ConvertToImage(); | |
899 | img.SaveFile(strm, wxBITMAP_TYPE_XPM); | |
900 | size_t len = strm.GetSize(); | |
901 | char* buff = new char[len+1]; | |
902 | strm.CopyTo(buff, len); | |
903 | buff[len] = 0; | |
904 | SendMsg(2405, type, (long)buff); | |
905 | delete [] buff; | |
a5b274d7 | 906 | |
9e730a78 RD |
907 | } |
908 | ||
909 | // Clear all the registered images. | |
910 | void wxStyledTextCtrl::ClearRegisteredImages() { | |
911 | SendMsg(2408, 0, 0); | |
912 | } | |
913 | ||
914 | // Retrieve the auto-completion list type-separator character. | |
915 | int wxStyledTextCtrl::AutoCompGetTypeSeparator() { | |
916 | return SendMsg(2285, 0, 0); | |
917 | } | |
918 | ||
919 | // Change the type-separator character in the string setting up an auto-completion list. | |
920 | // Default is '?' but can be changed if items contain '?'. | |
921 | void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter) { | |
922 | SendMsg(2286, separatorCharacter, 0); | |
923 | } | |
924 | ||
4370573a RD |
925 | // Set the number of spaces used for one level of indentation. |
926 | void wxStyledTextCtrl::SetIndent(int indentSize) { | |
927 | SendMsg(2122, indentSize, 0); | |
928 | } | |
9ce192d4 | 929 | |
4370573a RD |
930 | // Retrieve indentation size. |
931 | int wxStyledTextCtrl::GetIndent() { | |
932 | return SendMsg(2123, 0, 0); | |
9ce192d4 RD |
933 | } |
934 | ||
4370573a RD |
935 | // Indentation will only use space characters if useTabs is false, otherwise |
936 | // it will use a combination of tabs and spaces. | |
937 | void wxStyledTextCtrl::SetUseTabs(bool useTabs) { | |
938 | SendMsg(2124, useTabs, 0); | |
939 | } | |
9ce192d4 | 940 | |
4370573a RD |
941 | // Retrieve whether tabs will be used in indentation. |
942 | bool wxStyledTextCtrl::GetUseTabs() { | |
943 | return SendMsg(2125, 0, 0) != 0; | |
944 | } | |
9ce192d4 | 945 | |
4370573a RD |
946 | // Change the indentation of a line to a number of columns. |
947 | void wxStyledTextCtrl::SetLineIndentation(int line, int indentSize) { | |
948 | SendMsg(2126, line, indentSize); | |
949 | } | |
9ce192d4 | 950 | |
4370573a RD |
951 | // Retrieve the number of columns that a line is indented. |
952 | int wxStyledTextCtrl::GetLineIndentation(int line) { | |
953 | return SendMsg(2127, line, 0); | |
9ce192d4 RD |
954 | } |
955 | ||
4370573a RD |
956 | // Retrieve the position before the first non indentation character on a line. |
957 | int wxStyledTextCtrl::GetLineIndentPosition(int line) { | |
958 | return SendMsg(2128, line, 0); | |
959 | } | |
9ce192d4 | 960 | |
4370573a RD |
961 | // Retrieve the column number of a position, taking tab width into account. |
962 | int wxStyledTextCtrl::GetColumn(int pos) { | |
963 | return SendMsg(2129, pos, 0); | |
9ce192d4 RD |
964 | } |
965 | ||
4370573a RD |
966 | // Show or hide the horizontal scroll bar. |
967 | void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show) { | |
968 | SendMsg(2130, show, 0); | |
969 | } | |
9ce192d4 | 970 | |
4370573a RD |
971 | // Is the horizontal scroll bar visible? |
972 | bool wxStyledTextCtrl::GetUseHorizontalScrollBar() { | |
973 | return SendMsg(2131, 0, 0) != 0; | |
9ce192d4 RD |
974 | } |
975 | ||
4370573a RD |
976 | // Show or hide indentation guides. |
977 | void wxStyledTextCtrl::SetIndentationGuides(bool show) { | |
978 | SendMsg(2132, show, 0); | |
979 | } | |
9ce192d4 | 980 | |
4370573a RD |
981 | // Are the indentation guides visible? |
982 | bool wxStyledTextCtrl::GetIndentationGuides() { | |
983 | return SendMsg(2133, 0, 0) != 0; | |
9ce192d4 RD |
984 | } |
985 | ||
4370573a RD |
986 | // Set the highlighted indentation guide column. |
987 | // 0 = no highlighted guide. | |
988 | void wxStyledTextCtrl::SetHighlightGuide(int column) { | |
989 | SendMsg(2134, column, 0); | |
990 | } | |
9ce192d4 | 991 | |
4370573a RD |
992 | // Get the highlighted indentation guide column. |
993 | int wxStyledTextCtrl::GetHighlightGuide() { | |
994 | return SendMsg(2135, 0, 0); | |
9ce192d4 RD |
995 | } |
996 | ||
4370573a RD |
997 | // Get the position after the last visible characters on a line. |
998 | int wxStyledTextCtrl::GetLineEndPosition(int line) { | |
999 | return SendMsg(2136, line, 0); | |
1000 | } | |
9ce192d4 | 1001 | |
4370573a RD |
1002 | // Get the code page used to interpret the bytes of the document as characters. |
1003 | int wxStyledTextCtrl::GetCodePage() { | |
1004 | return SendMsg(2137, 0, 0); | |
9ce192d4 RD |
1005 | } |
1006 | ||
4370573a RD |
1007 | // Get the foreground colour of the caret. |
1008 | wxColour wxStyledTextCtrl::GetCaretForeground() { | |
1009 | long c = SendMsg(2138, 0, 0); | |
1010 | return wxColourFromLong(c); | |
1011 | } | |
9ce192d4 | 1012 | |
4370573a RD |
1013 | // In read-only mode? |
1014 | bool wxStyledTextCtrl::GetReadOnly() { | |
1015 | return SendMsg(2140, 0, 0) != 0; | |
9ce192d4 RD |
1016 | } |
1017 | ||
4370573a RD |
1018 | // Sets the position of the caret. |
1019 | void wxStyledTextCtrl::SetCurrentPos(int pos) { | |
1020 | SendMsg(2141, pos, 0); | |
1021 | } | |
9ce192d4 | 1022 | |
4370573a RD |
1023 | // Sets the position that starts the selection - this becomes the anchor. |
1024 | void wxStyledTextCtrl::SetSelectionStart(int pos) { | |
1025 | SendMsg(2142, pos, 0); | |
9ce192d4 RD |
1026 | } |
1027 | ||
4370573a RD |
1028 | // Returns the position at the start of the selection. |
1029 | int wxStyledTextCtrl::GetSelectionStart() { | |
1030 | return SendMsg(2143, 0, 0); | |
1031 | } | |
9ce192d4 | 1032 | |
4370573a RD |
1033 | // Sets the position that ends the selection - this becomes the currentPosition. |
1034 | void wxStyledTextCtrl::SetSelectionEnd(int pos) { | |
1035 | SendMsg(2144, pos, 0); | |
9ce192d4 RD |
1036 | } |
1037 | ||
4370573a RD |
1038 | // Returns the position at the end of the selection. |
1039 | int wxStyledTextCtrl::GetSelectionEnd() { | |
1040 | return SendMsg(2145, 0, 0); | |
1041 | } | |
9ce192d4 | 1042 | |
4370573a RD |
1043 | // Sets the print magnification added to the point size of each style for printing. |
1044 | void wxStyledTextCtrl::SetPrintMagnification(int magnification) { | |
1045 | SendMsg(2146, magnification, 0); | |
9ce192d4 RD |
1046 | } |
1047 | ||
4370573a RD |
1048 | // Returns the print magnification. |
1049 | int wxStyledTextCtrl::GetPrintMagnification() { | |
1050 | return SendMsg(2147, 0, 0); | |
1051 | } | |
9ce192d4 | 1052 | |
4370573a RD |
1053 | // Modify colours when printing for clearer printed text. |
1054 | void wxStyledTextCtrl::SetPrintColourMode(int mode) { | |
1055 | SendMsg(2148, mode, 0); | |
9ce192d4 RD |
1056 | } |
1057 | ||
4370573a RD |
1058 | // Returns the print colour mode. |
1059 | int wxStyledTextCtrl::GetPrintColourMode() { | |
1060 | return SendMsg(2149, 0, 0); | |
1061 | } | |
9ce192d4 | 1062 | |
4370573a RD |
1063 | // Find some text in the document. |
1064 | int wxStyledTextCtrl::FindText(int minPos, int maxPos, | |
9e730a78 RD |
1065 | const wxString& text, |
1066 | int flags) { | |
1067 | TextToFind ft; | |
1068 | ft.chrg.cpMin = minPos; | |
1069 | ft.chrg.cpMax = maxPos; | |
1070 | wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); | |
1071 | ft.lpstrText = (char*)(const char*)buf; | |
4370573a | 1072 | |
9e730a78 | 1073 | return SendMsg(2150, flags, (long)&ft); |
4370573a RD |
1074 | } |
1075 | ||
a834585d | 1076 | // On Windows, will draw the document into a display context such as a printer. |
a5b274d7 WS |
1077 | int wxStyledTextCtrl::FormatRange(bool doDraw, |
1078 | int startPos, | |
1079 | int endPos, | |
1080 | wxDC* draw, | |
1081 | wxDC* target, | |
1082 | wxRect renderRect, | |
1083 | wxRect pageRect) { | |
1084 | RangeToFormat fr; | |
1085 | ||
1086 | if (endPos < startPos) { | |
1087 | int temp = startPos; | |
1088 | startPos = endPos; | |
1089 | endPos = temp; | |
1090 | } | |
1091 | fr.hdc = draw; | |
1092 | fr.hdcTarget = target; | |
1093 | fr.rc.top = renderRect.GetTop(); | |
1094 | fr.rc.left = renderRect.GetLeft(); | |
1095 | fr.rc.right = renderRect.GetRight(); | |
1096 | fr.rc.bottom = renderRect.GetBottom(); | |
1097 | fr.rcPage.top = pageRect.GetTop(); | |
1098 | fr.rcPage.left = pageRect.GetLeft(); | |
1099 | fr.rcPage.right = pageRect.GetRight(); | |
1100 | fr.rcPage.bottom = pageRect.GetBottom(); | |
1101 | fr.chrg.cpMin = startPos; | |
1102 | fr.chrg.cpMax = endPos; | |
1103 | ||
1104 | return SendMsg(2151, doDraw, (long)&fr); | |
9e730a78 RD |
1105 | } |
1106 | ||
1107 | // Retrieve the display line at the top of the display. | |
4370573a RD |
1108 | int wxStyledTextCtrl::GetFirstVisibleLine() { |
1109 | return SendMsg(2152, 0, 0); | |
9ce192d4 RD |
1110 | } |
1111 | ||
4370573a RD |
1112 | // Retrieve the contents of a line. |
1113 | wxString wxStyledTextCtrl::GetLine(int line) { | |
9e730a78 RD |
1114 | int len = LineLength(line); |
1115 | if (!len) return wxEmptyString; | |
9ce192d4 | 1116 | |
9e730a78 RD |
1117 | wxMemoryBuffer mbuf(len+1); |
1118 | char* buf = (char*)mbuf.GetWriteBuf(len+1); | |
1119 | SendMsg(2153, line, (long)buf); | |
1120 | mbuf.UngetWriteBuf(len); | |
1121 | mbuf.AppendByte(0); | |
1122 | return stc2wx(buf); | |
4370573a RD |
1123 | } |
1124 | ||
1125 | // Returns the number of lines in the document. There is always at least one. | |
1126 | int wxStyledTextCtrl::GetLineCount() { | |
1127 | return SendMsg(2154, 0, 0); | |
1128 | } | |
9ce192d4 | 1129 | |
4370573a | 1130 | // Sets the size in pixels of the left margin. |
65ec6247 RD |
1131 | void wxStyledTextCtrl::SetMarginLeft(int pixelWidth) { |
1132 | SendMsg(2155, 0, pixelWidth); | |
4370573a | 1133 | } |
9ce192d4 | 1134 | |
4370573a RD |
1135 | // Returns the size in pixels of the left margin. |
1136 | int wxStyledTextCtrl::GetMarginLeft() { | |
1137 | return SendMsg(2156, 0, 0); | |
9ce192d4 RD |
1138 | } |
1139 | ||
4370573a | 1140 | // Sets the size in pixels of the right margin. |
65ec6247 RD |
1141 | void wxStyledTextCtrl::SetMarginRight(int pixelWidth) { |
1142 | SendMsg(2157, 0, pixelWidth); | |
4370573a | 1143 | } |
9ce192d4 | 1144 | |
4370573a RD |
1145 | // Returns the size in pixels of the right margin. |
1146 | int wxStyledTextCtrl::GetMarginRight() { | |
1147 | return SendMsg(2158, 0, 0); | |
9ce192d4 RD |
1148 | } |
1149 | ||
4370573a RD |
1150 | // Is the document different from when it was last saved? |
1151 | bool wxStyledTextCtrl::GetModify() { | |
1152 | return SendMsg(2159, 0, 0) != 0; | |
1153 | } | |
9ce192d4 | 1154 | |
4370573a RD |
1155 | // Select a range of text. |
1156 | void wxStyledTextCtrl::SetSelection(int start, int end) { | |
1157 | SendMsg(2160, start, end); | |
9ce192d4 RD |
1158 | } |
1159 | ||
4370573a RD |
1160 | // Retrieve the selected text. |
1161 | wxString wxStyledTextCtrl::GetSelectedText() { | |
9e730a78 RD |
1162 | int start; |
1163 | int end; | |
9ce192d4 | 1164 | |
9e730a78 RD |
1165 | GetSelection(&start, &end); |
1166 | int len = end - start; | |
1167 | if (!len) return wxEmptyString; | |
9ce192d4 | 1168 | |
3d7a4fe8 | 1169 | wxMemoryBuffer mbuf(len+2); |
9e730a78 RD |
1170 | char* buf = (char*)mbuf.GetWriteBuf(len+1); |
1171 | SendMsg(2161, 0, (long)buf); | |
1172 | mbuf.UngetWriteBuf(len); | |
1173 | mbuf.AppendByte(0); | |
1174 | return stc2wx(buf); | |
4370573a | 1175 | } |
9ce192d4 | 1176 | |
4370573a RD |
1177 | // Retrieve a range of text. |
1178 | wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) { | |
9e730a78 RD |
1179 | if (endPos < startPos) { |
1180 | int temp = startPos; | |
1181 | startPos = endPos; | |
1182 | endPos = temp; | |
1183 | } | |
1184 | int len = endPos - startPos; | |
1185 | if (!len) return wxEmptyString; | |
1186 | wxMemoryBuffer mbuf(len+1); | |
1187 | char* buf = (char*)mbuf.GetWriteBuf(len); | |
1188 | TextRange tr; | |
1189 | tr.lpstrText = buf; | |
1190 | tr.chrg.cpMin = startPos; | |
1191 | tr.chrg.cpMax = endPos; | |
1192 | SendMsg(2162, 0, (long)&tr); | |
1193 | mbuf.UngetWriteBuf(len); | |
1194 | mbuf.AppendByte(0); | |
1195 | return stc2wx(buf); | |
9ce192d4 RD |
1196 | } |
1197 | ||
4370573a RD |
1198 | // Draw the selection in normal style or with selection highlighted. |
1199 | void wxStyledTextCtrl::HideSelection(bool normal) { | |
1200 | SendMsg(2163, normal, 0); | |
1201 | } | |
9ce192d4 | 1202 | |
4370573a RD |
1203 | // Retrieve the line containing a position. |
1204 | int wxStyledTextCtrl::LineFromPosition(int pos) { | |
1205 | return SendMsg(2166, pos, 0); | |
9ce192d4 RD |
1206 | } |
1207 | ||
4370573a RD |
1208 | // Retrieve the position at the start of a line. |
1209 | int wxStyledTextCtrl::PositionFromLine(int line) { | |
1210 | return SendMsg(2167, line, 0); | |
1211 | } | |
9ce192d4 | 1212 | |
4370573a RD |
1213 | // Scroll horizontally and vertically. |
1214 | void wxStyledTextCtrl::LineScroll(int columns, int lines) { | |
1215 | SendMsg(2168, columns, lines); | |
9ce192d4 RD |
1216 | } |
1217 | ||
4370573a RD |
1218 | // Ensure the caret is visible. |
1219 | void wxStyledTextCtrl::EnsureCaretVisible() { | |
1220 | SendMsg(2169, 0, 0); | |
1221 | } | |
9ce192d4 | 1222 | |
4370573a RD |
1223 | // Replace the selected text with the argument text. |
1224 | void wxStyledTextCtrl::ReplaceSelection(const wxString& text) { | |
0c5b83b0 | 1225 | SendMsg(2170, 0, (long)(const char*)wx2stc(text)); |
9ce192d4 RD |
1226 | } |
1227 | ||
4370573a RD |
1228 | // Set to read only or read write. |
1229 | void wxStyledTextCtrl::SetReadOnly(bool readOnly) { | |
1230 | SendMsg(2171, readOnly, 0); | |
1231 | } | |
9ce192d4 | 1232 | |
4370573a RD |
1233 | // Will a paste succeed? |
1234 | bool wxStyledTextCtrl::CanPaste() { | |
1235 | return SendMsg(2173, 0, 0) != 0; | |
9ce192d4 RD |
1236 | } |
1237 | ||
a834585d | 1238 | // Are there any undoable actions in the undo history? |
4370573a RD |
1239 | bool wxStyledTextCtrl::CanUndo() { |
1240 | return SendMsg(2174, 0, 0) != 0; | |
1241 | } | |
9ce192d4 | 1242 | |
4370573a RD |
1243 | // Delete the undo history. |
1244 | void wxStyledTextCtrl::EmptyUndoBuffer() { | |
1245 | SendMsg(2175, 0, 0); | |
9ce192d4 RD |
1246 | } |
1247 | ||
4370573a RD |
1248 | // Undo one action in the undo history. |
1249 | void wxStyledTextCtrl::Undo() { | |
1250 | SendMsg(2176, 0, 0); | |
1251 | } | |
9ce192d4 | 1252 | |
4370573a RD |
1253 | // Cut the selection to the clipboard. |
1254 | void wxStyledTextCtrl::Cut() { | |
1255 | SendMsg(2177, 0, 0); | |
f6bcfd97 BP |
1256 | } |
1257 | ||
4370573a RD |
1258 | // Copy the selection to the clipboard. |
1259 | void wxStyledTextCtrl::Copy() { | |
1260 | SendMsg(2178, 0, 0); | |
1261 | } | |
f6bcfd97 | 1262 | |
4370573a RD |
1263 | // Paste the contents of the clipboard into the document replacing the selection. |
1264 | void wxStyledTextCtrl::Paste() { | |
1265 | SendMsg(2179, 0, 0); | |
f6bcfd97 BP |
1266 | } |
1267 | ||
4370573a RD |
1268 | // Clear the selection. |
1269 | void wxStyledTextCtrl::Clear() { | |
1270 | SendMsg(2180, 0, 0); | |
1271 | } | |
f6bcfd97 | 1272 | |
4370573a RD |
1273 | // Replace the contents of the document with the argument text. |
1274 | void wxStyledTextCtrl::SetText(const wxString& text) { | |
0c5b83b0 | 1275 | SendMsg(2181, 0, (long)(const char*)wx2stc(text)); |
f6bcfd97 BP |
1276 | } |
1277 | ||
4370573a RD |
1278 | // Retrieve all the text in the document. |
1279 | wxString wxStyledTextCtrl::GetText() { | |
9e730a78 RD |
1280 | int len = GetTextLength(); |
1281 | wxMemoryBuffer mbuf(len+1); // leave room for the null... | |
1282 | char* buf = (char*)mbuf.GetWriteBuf(len+1); | |
1283 | SendMsg(2182, len+1, (long)buf); | |
1284 | mbuf.UngetWriteBuf(len); | |
1285 | mbuf.AppendByte(0); | |
1286 | return stc2wx(buf); | |
4370573a | 1287 | } |
9ce192d4 | 1288 | |
4370573a RD |
1289 | // Retrieve the number of characters in the document. |
1290 | int wxStyledTextCtrl::GetTextLength() { | |
1291 | return SendMsg(2183, 0, 0); | |
9ce192d4 RD |
1292 | } |
1293 | ||
a834585d | 1294 | // Set to overtype (true) or insert mode. |
4370573a RD |
1295 | void wxStyledTextCtrl::SetOvertype(bool overtype) { |
1296 | SendMsg(2186, overtype, 0); | |
1297 | } | |
9ce192d4 | 1298 | |
4370573a RD |
1299 | // Returns true if overtype mode is active otherwise false is returned. |
1300 | bool wxStyledTextCtrl::GetOvertype() { | |
1301 | return SendMsg(2187, 0, 0) != 0; | |
9ce192d4 RD |
1302 | } |
1303 | ||
a834585d | 1304 | // Set the width of the insert mode caret. |
65ec6247 RD |
1305 | void wxStyledTextCtrl::SetCaretWidth(int pixelWidth) { |
1306 | SendMsg(2188, pixelWidth, 0); | |
1307 | } | |
1308 | ||
a834585d | 1309 | // Returns the width of the insert mode caret. |
65ec6247 RD |
1310 | int wxStyledTextCtrl::GetCaretWidth() { |
1311 | return SendMsg(2189, 0, 0); | |
1312 | } | |
1313 | ||
1314 | // Sets the position that starts the target which is used for updating the | |
1315 | // document without affecting the scroll position. | |
1316 | void wxStyledTextCtrl::SetTargetStart(int pos) { | |
1317 | SendMsg(2190, pos, 0); | |
1318 | } | |
1319 | ||
1320 | // Get the position that starts the target. | |
1321 | int wxStyledTextCtrl::GetTargetStart() { | |
1322 | return SendMsg(2191, 0, 0); | |
1323 | } | |
1324 | ||
1325 | // Sets the position that ends the target which is used for updating the | |
1326 | // document without affecting the scroll position. | |
1327 | void wxStyledTextCtrl::SetTargetEnd(int pos) { | |
1328 | SendMsg(2192, pos, 0); | |
1329 | } | |
1330 | ||
1331 | // Get the position that ends the target. | |
1332 | int wxStyledTextCtrl::GetTargetEnd() { | |
1333 | return SendMsg(2193, 0, 0); | |
1334 | } | |
1335 | ||
1336 | // Replace the target text with the argument text. | |
8e54aaed | 1337 | // Text is counted so it can contain NULs. |
65ec6247 RD |
1338 | // Returns the length of the replacement text. |
1339 | ||
9e730a78 RD |
1340 | int wxStyledTextCtrl::ReplaceTarget(const wxString& text) { |
1341 | wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); | |
1342 | return SendMsg(2194, strlen(buf), (long)(const char*)buf); | |
65ec6247 RD |
1343 | } |
1344 | ||
1345 | // Replace the target text with the argument text after \d processing. | |
8e54aaed | 1346 | // Text is counted so it can contain NULs. |
65ec6247 RD |
1347 | // Looks for \d where d is between 1 and 9 and replaces these with the strings |
1348 | // matched in the last search operation which were surrounded by \( and \). | |
1349 | // Returns the length of the replacement text including any change | |
1350 | // caused by processing the \d patterns. | |
1351 | ||
9e730a78 RD |
1352 | int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) { |
1353 | wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); | |
1354 | return SendMsg(2195, strlen(buf), (long)(const char*)buf); | |
65ec6247 RD |
1355 | } |
1356 | ||
1357 | // Search for a counted string in the target and set the target to the found | |
8e54aaed | 1358 | // range. Text is counted so it can contain NULs. |
65ec6247 RD |
1359 | // Returns length of range or -1 for failure in which case target is not moved. |
1360 | ||
9e730a78 RD |
1361 | int wxStyledTextCtrl::SearchInTarget(const wxString& text) { |
1362 | wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); | |
1363 | return SendMsg(2197, strlen(buf), (long)(const char*)buf); | |
65ec6247 RD |
1364 | } |
1365 | ||
a834585d | 1366 | // Set the search flags used by SearchInTarget. |
65ec6247 RD |
1367 | void wxStyledTextCtrl::SetSearchFlags(int flags) { |
1368 | SendMsg(2198, flags, 0); | |
1369 | } | |
1370 | ||
a834585d | 1371 | // Get the search flags used by SearchInTarget. |
65ec6247 RD |
1372 | int wxStyledTextCtrl::GetSearchFlags() { |
1373 | return SendMsg(2199, 0, 0); | |
1374 | } | |
1375 | ||
4370573a RD |
1376 | // Show a call tip containing a definition near position pos. |
1377 | void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) { | |
0c5b83b0 | 1378 | SendMsg(2200, pos, (long)(const char*)wx2stc(definition)); |
4370573a | 1379 | } |
9ce192d4 | 1380 | |
4370573a RD |
1381 | // Remove the call tip from the screen. |
1382 | void wxStyledTextCtrl::CallTipCancel() { | |
1383 | SendMsg(2201, 0, 0); | |
9ce192d4 RD |
1384 | } |
1385 | ||
4370573a RD |
1386 | // Is there an active call tip? |
1387 | bool wxStyledTextCtrl::CallTipActive() { | |
1388 | return SendMsg(2202, 0, 0) != 0; | |
1389 | } | |
9ce192d4 | 1390 | |
4370573a | 1391 | // Retrieve the position where the caret was before displaying the call tip. |
9ce192d4 | 1392 | int wxStyledTextCtrl::CallTipPosAtStart() { |
4370573a | 1393 | return SendMsg(2203, 0, 0); |
9ce192d4 RD |
1394 | } |
1395 | ||
4370573a | 1396 | // Highlight a segment of the definition. |
9ce192d4 | 1397 | void wxStyledTextCtrl::CallTipSetHighlight(int start, int end) { |
4370573a | 1398 | SendMsg(2204, start, end); |
9ce192d4 RD |
1399 | } |
1400 | ||
4370573a RD |
1401 | // Set the background colour for the call tip. |
1402 | void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back) { | |
1403 | SendMsg(2205, wxColourAsLong(back), 0); | |
1404 | } | |
9ce192d4 | 1405 | |
9e730a78 RD |
1406 | // Set the foreground colour for the call tip. |
1407 | void wxStyledTextCtrl::CallTipSetForeground(const wxColour& fore) { | |
1408 | SendMsg(2206, wxColourAsLong(fore), 0); | |
1409 | } | |
1410 | ||
1411 | // Set the foreground colour for the highlighted part of the call tip. | |
1412 | void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour& fore) { | |
1413 | SendMsg(2207, wxColourAsLong(fore), 0); | |
1414 | } | |
1415 | ||
4370573a RD |
1416 | // Find the display line of a document line taking hidden lines into account. |
1417 | int wxStyledTextCtrl::VisibleFromDocLine(int line) { | |
1418 | return SendMsg(2220, line, 0); | |
9ce192d4 RD |
1419 | } |
1420 | ||
4370573a RD |
1421 | // Find the document line of a display line taking hidden lines into account. |
1422 | int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay) { | |
1423 | return SendMsg(2221, lineDisplay, 0); | |
1424 | } | |
9ce192d4 | 1425 | |
4370573a RD |
1426 | // Set the fold level of a line. |
1427 | // This encodes an integer level along with flags indicating whether the | |
1428 | // line is a header and whether it is effectively white space. | |
1429 | void wxStyledTextCtrl::SetFoldLevel(int line, int level) { | |
1430 | SendMsg(2222, line, level); | |
1431 | } | |
9ce192d4 | 1432 | |
4370573a RD |
1433 | // Retrieve the fold level of a line. |
1434 | int wxStyledTextCtrl::GetFoldLevel(int line) { | |
1435 | return SendMsg(2223, line, 0); | |
1436 | } | |
d134f170 | 1437 | |
4370573a RD |
1438 | // Find the last child line of a header line. |
1439 | int wxStyledTextCtrl::GetLastChild(int line, int level) { | |
1440 | return SendMsg(2224, line, level); | |
9ce192d4 RD |
1441 | } |
1442 | ||
4370573a RD |
1443 | // Find the parent line of a child line. |
1444 | int wxStyledTextCtrl::GetFoldParent(int line) { | |
1445 | return SendMsg(2225, line, 0); | |
1446 | } | |
9ce192d4 | 1447 | |
4370573a RD |
1448 | // Make a range of lines visible. |
1449 | void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd) { | |
1450 | SendMsg(2226, lineStart, lineEnd); | |
9ce192d4 RD |
1451 | } |
1452 | ||
4370573a RD |
1453 | // Make a range of lines invisible. |
1454 | void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd) { | |
1455 | SendMsg(2227, lineStart, lineEnd); | |
1456 | } | |
9ce192d4 | 1457 | |
4370573a RD |
1458 | // Is a line visible? |
1459 | bool wxStyledTextCtrl::GetLineVisible(int line) { | |
1460 | return SendMsg(2228, line, 0) != 0; | |
9ce192d4 RD |
1461 | } |
1462 | ||
4370573a RD |
1463 | // Show the children of a header line. |
1464 | void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded) { | |
1465 | SendMsg(2229, line, expanded); | |
1466 | } | |
9ce192d4 | 1467 | |
4370573a RD |
1468 | // Is a header line expanded? |
1469 | bool wxStyledTextCtrl::GetFoldExpanded(int line) { | |
1470 | return SendMsg(2230, line, 0) != 0; | |
9ce192d4 RD |
1471 | } |
1472 | ||
4370573a RD |
1473 | // Switch a header line between expanded and contracted. |
1474 | void wxStyledTextCtrl::ToggleFold(int line) { | |
1475 | SendMsg(2231, line, 0); | |
1476 | } | |
9ce192d4 | 1477 | |
4370573a RD |
1478 | // Ensure a particular line is visible by expanding any header line hiding it. |
1479 | void wxStyledTextCtrl::EnsureVisible(int line) { | |
1480 | SendMsg(2232, line, 0); | |
1481 | } | |
9ce192d4 | 1482 | |
9e730a78 | 1483 | // Set some style options for folding. |
4370573a RD |
1484 | void wxStyledTextCtrl::SetFoldFlags(int flags) { |
1485 | SendMsg(2233, flags, 0); | |
9ce192d4 RD |
1486 | } |
1487 | ||
65ec6247 RD |
1488 | // Ensure a particular line is visible by expanding any header line hiding it. |
1489 | // Use the currently set visibility policy to determine which range to display. | |
1490 | void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line) { | |
1491 | SendMsg(2234, line, 0); | |
1492 | } | |
1493 | ||
a834585d | 1494 | // Sets whether a tab pressed when caret is within indentation indents. |
65ec6247 RD |
1495 | void wxStyledTextCtrl::SetTabIndents(bool tabIndents) { |
1496 | SendMsg(2260, tabIndents, 0); | |
1497 | } | |
1498 | ||
1499 | // Does a tab pressed when caret is within indentation indent? | |
1500 | bool wxStyledTextCtrl::GetTabIndents() { | |
1501 | return SendMsg(2261, 0, 0) != 0; | |
1502 | } | |
1503 | ||
a834585d | 1504 | // Sets whether a backspace pressed when caret is within indentation unindents. |
65ec6247 RD |
1505 | void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents) { |
1506 | SendMsg(2262, bsUnIndents, 0); | |
1507 | } | |
1508 | ||
1509 | // Does a backspace pressed when caret is within indentation unindent? | |
1510 | bool wxStyledTextCtrl::GetBackSpaceUnIndents() { | |
1511 | return SendMsg(2263, 0, 0) != 0; | |
1512 | } | |
1513 | ||
a834585d | 1514 | // Sets the time the mouse must sit still to generate a mouse dwell event. |
65ec6247 RD |
1515 | void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds) { |
1516 | SendMsg(2264, periodMilliseconds, 0); | |
1517 | } | |
1518 | ||
a834585d | 1519 | // Retrieve the time the mouse must sit still to generate a mouse dwell event. |
65ec6247 RD |
1520 | int wxStyledTextCtrl::GetMouseDwellTime() { |
1521 | return SendMsg(2265, 0, 0); | |
1522 | } | |
1523 | ||
a834585d | 1524 | // Get position of start of word. |
1a2fb4cd RD |
1525 | int wxStyledTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters) { |
1526 | return SendMsg(2266, pos, onlyWordCharacters); | |
1527 | } | |
1528 | ||
a834585d | 1529 | // Get position of end of word. |
1a2fb4cd RD |
1530 | int wxStyledTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters) { |
1531 | return SendMsg(2267, pos, onlyWordCharacters); | |
1532 | } | |
1533 | ||
a834585d | 1534 | // Sets whether text is word wrapped. |
1a2fb4cd RD |
1535 | void wxStyledTextCtrl::SetWrapMode(int mode) { |
1536 | SendMsg(2268, mode, 0); | |
1537 | } | |
1538 | ||
a834585d | 1539 | // Retrieve whether text is word wrapped. |
1a2fb4cd RD |
1540 | int wxStyledTextCtrl::GetWrapMode() { |
1541 | return SendMsg(2269, 0, 0); | |
1542 | } | |
1543 | ||
591d01be RD |
1544 | // Set the display mode of visual flags for wrapped lines. |
1545 | void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags) { | |
1546 | SendMsg(2460, wrapVisualFlags, 0); | |
1547 | } | |
1548 | ||
1549 | // Retrive the display mode of visual flags for wrapped lines. | |
1550 | int wxStyledTextCtrl::GetWrapVisualFlags() { | |
1551 | return SendMsg(2461, 0, 0); | |
1552 | } | |
1553 | ||
1554 | // Set the location of visual flags for wrapped lines. | |
1555 | void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation) { | |
1556 | SendMsg(2462, wrapVisualFlagsLocation, 0); | |
1557 | } | |
1558 | ||
1559 | // Retrive the location of visual flags for wrapped lines. | |
1560 | int wxStyledTextCtrl::GetWrapVisualFlagsLocation() { | |
1561 | return SendMsg(2463, 0, 0); | |
1562 | } | |
1563 | ||
1564 | // Set the start indent for wrapped lines. | |
1565 | void wxStyledTextCtrl::SetWrapStartIndent(int indent) { | |
1566 | SendMsg(2464, indent, 0); | |
1567 | } | |
1568 | ||
1569 | // Retrive the start indent for wrapped lines. | |
1570 | int wxStyledTextCtrl::GetWrapStartIndent() { | |
1571 | return SendMsg(2465, 0, 0); | |
1572 | } | |
1573 | ||
a834585d | 1574 | // Sets the degree of caching of layout information. |
1a2fb4cd RD |
1575 | void wxStyledTextCtrl::SetLayoutCache(int mode) { |
1576 | SendMsg(2272, mode, 0); | |
1577 | } | |
1578 | ||
a834585d | 1579 | // Retrieve the degree of caching of layout information. |
1a2fb4cd RD |
1580 | int wxStyledTextCtrl::GetLayoutCache() { |
1581 | return SendMsg(2273, 0, 0); | |
1582 | } | |
1583 | ||
a834585d RD |
1584 | // Sets the document width assumed for scrolling. |
1585 | void wxStyledTextCtrl::SetScrollWidth(int pixelWidth) { | |
1586 | SendMsg(2274, pixelWidth, 0); | |
1587 | } | |
1588 | ||
1589 | // Retrieve the document width assumed for scrolling. | |
1590 | int wxStyledTextCtrl::GetScrollWidth() { | |
1591 | return SendMsg(2275, 0, 0); | |
1592 | } | |
1593 | ||
1594 | // Measure the pixel width of some text in a particular style. | |
8e54aaed | 1595 | // NUL terminated text argument. |
a834585d RD |
1596 | // Does not handle tab or control characters. |
1597 | int wxStyledTextCtrl::TextWidth(int style, const wxString& text) { | |
1598 | return SendMsg(2276, style, (long)(const char*)wx2stc(text)); | |
1599 | } | |
1600 | ||
1601 | // Sets the scroll range so that maximum scroll position has | |
1602 | // the last line at the bottom of the view (default). | |
1603 | // Setting this to false allows scrolling one page below the last line. | |
1604 | void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine) { | |
1605 | SendMsg(2277, endAtLastLine, 0); | |
1606 | } | |
1607 | ||
1608 | // Retrieve whether the maximum scroll position has the last | |
1609 | // line at the bottom of the view. | |
1610 | int wxStyledTextCtrl::GetEndAtLastLine() { | |
1611 | return SendMsg(2278, 0, 0); | |
1612 | } | |
1613 | ||
1614 | // Retrieve the height of a particular line of text in pixels. | |
1615 | int wxStyledTextCtrl::TextHeight(int line) { | |
1616 | return SendMsg(2279, line, 0); | |
1617 | } | |
1618 | ||
9e730a78 RD |
1619 | // Show or hide the vertical scroll bar. |
1620 | void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show) { | |
1621 | SendMsg(2280, show, 0); | |
1622 | } | |
1623 | ||
1624 | // Is the vertical scroll bar visible? | |
1625 | bool wxStyledTextCtrl::GetUseVerticalScrollBar() { | |
1626 | return SendMsg(2281, 0, 0) != 0; | |
1627 | } | |
1628 | ||
1629 | // Append a string to the end of the document without changing the selection. | |
41a499cd RD |
1630 | void wxStyledTextCtrl::AppendText(const wxString& text) { |
1631 | wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); | |
1632 | SendMsg(2282, strlen(buf), (long)(const char*)buf); | |
9e730a78 RD |
1633 | } |
1634 | ||
1635 | // Is drawing done in two phases with backgrounds drawn before foregrounds? | |
1636 | bool wxStyledTextCtrl::GetTwoPhaseDraw() { | |
1637 | return SendMsg(2283, 0, 0) != 0; | |
1638 | } | |
1639 | ||
1640 | // In twoPhaseDraw mode, drawing is performed in two phases, first the background | |
1641 | // and then the foreground. This avoids chopping off characters that overlap the next run. | |
1642 | void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase) { | |
1643 | SendMsg(2284, twoPhase, 0); | |
1644 | } | |
1645 | ||
1646 | // Make the target range start and end be the same as the selection range start and end. | |
1647 | void wxStyledTextCtrl::TargetFromSelection() { | |
1648 | SendMsg(2287, 0, 0); | |
1649 | } | |
1650 | ||
1651 | // Join the lines in the target. | |
1652 | void wxStyledTextCtrl::LinesJoin() { | |
1653 | SendMsg(2288, 0, 0); | |
1654 | } | |
1655 | ||
1656 | // Split the lines in the target into lines that are less wide than pixelWidth | |
1657 | // where possible. | |
1658 | void wxStyledTextCtrl::LinesSplit(int pixelWidth) { | |
1659 | SendMsg(2289, pixelWidth, 0); | |
1660 | } | |
1661 | ||
1662 | // Set the colours used as a chequerboard pattern in the fold margin | |
1663 | void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting, const wxColour& back) { | |
1664 | SendMsg(2290, useSetting, wxColourAsLong(back)); | |
1665 | } | |
1666 | void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting, const wxColour& fore) { | |
1667 | SendMsg(2291, useSetting, wxColourAsLong(fore)); | |
1668 | } | |
1669 | ||
c26dba42 RD |
1670 | // Move caret down one line. |
1671 | void wxStyledTextCtrl::LineDown() { | |
1672 | SendMsg(2300, 0, 0); | |
1673 | } | |
1674 | ||
1675 | // Move caret down one line extending selection to new caret position. | |
1676 | void wxStyledTextCtrl::LineDownExtend() { | |
1677 | SendMsg(2301, 0, 0); | |
1678 | } | |
1679 | ||
1680 | // Move caret up one line. | |
1681 | void wxStyledTextCtrl::LineUp() { | |
1682 | SendMsg(2302, 0, 0); | |
1683 | } | |
1684 | ||
1685 | // Move caret up one line extending selection to new caret position. | |
1686 | void wxStyledTextCtrl::LineUpExtend() { | |
1687 | SendMsg(2303, 0, 0); | |
1688 | } | |
1689 | ||
1690 | // Move caret left one character. | |
1691 | void wxStyledTextCtrl::CharLeft() { | |
1692 | SendMsg(2304, 0, 0); | |
1693 | } | |
1694 | ||
1695 | // Move caret left one character extending selection to new caret position. | |
1696 | void wxStyledTextCtrl::CharLeftExtend() { | |
1697 | SendMsg(2305, 0, 0); | |
1698 | } | |
1699 | ||
1700 | // Move caret right one character. | |
1701 | void wxStyledTextCtrl::CharRight() { | |
1702 | SendMsg(2306, 0, 0); | |
1703 | } | |
1704 | ||
1705 | // Move caret right one character extending selection to new caret position. | |
1706 | void wxStyledTextCtrl::CharRightExtend() { | |
1707 | SendMsg(2307, 0, 0); | |
1708 | } | |
1709 | ||
1710 | // Move caret left one word. | |
1711 | void wxStyledTextCtrl::WordLeft() { | |
1712 | SendMsg(2308, 0, 0); | |
1713 | } | |
1714 | ||
1715 | // Move caret left one word extending selection to new caret position. | |
1716 | void wxStyledTextCtrl::WordLeftExtend() { | |
1717 | SendMsg(2309, 0, 0); | |
1718 | } | |
1719 | ||
1720 | // Move caret right one word. | |
1721 | void wxStyledTextCtrl::WordRight() { | |
1722 | SendMsg(2310, 0, 0); | |
1723 | } | |
1724 | ||
1725 | // Move caret right one word extending selection to new caret position. | |
1726 | void wxStyledTextCtrl::WordRightExtend() { | |
1727 | SendMsg(2311, 0, 0); | |
1728 | } | |
1729 | ||
1730 | // Move caret to first position on line. | |
1731 | void wxStyledTextCtrl::Home() { | |
1732 | SendMsg(2312, 0, 0); | |
1733 | } | |
1734 | ||
1735 | // Move caret to first position on line extending selection to new caret position. | |
1736 | void wxStyledTextCtrl::HomeExtend() { | |
1737 | SendMsg(2313, 0, 0); | |
1738 | } | |
1739 | ||
1740 | // Move caret to last position on line. | |
1741 | void wxStyledTextCtrl::LineEnd() { | |
1742 | SendMsg(2314, 0, 0); | |
1743 | } | |
1744 | ||
1745 | // Move caret to last position on line extending selection to new caret position. | |
1746 | void wxStyledTextCtrl::LineEndExtend() { | |
1747 | SendMsg(2315, 0, 0); | |
1748 | } | |
1749 | ||
1750 | // Move caret to first position in document. | |
1751 | void wxStyledTextCtrl::DocumentStart() { | |
1752 | SendMsg(2316, 0, 0); | |
1753 | } | |
1754 | ||
1755 | // Move caret to first position in document extending selection to new caret position. | |
1756 | void wxStyledTextCtrl::DocumentStartExtend() { | |
1757 | SendMsg(2317, 0, 0); | |
1758 | } | |
1759 | ||
1760 | // Move caret to last position in document. | |
1761 | void wxStyledTextCtrl::DocumentEnd() { | |
1762 | SendMsg(2318, 0, 0); | |
1763 | } | |
1764 | ||
1765 | // Move caret to last position in document extending selection to new caret position. | |
1766 | void wxStyledTextCtrl::DocumentEndExtend() { | |
1767 | SendMsg(2319, 0, 0); | |
1768 | } | |
1769 | ||
1770 | // Move caret one page up. | |
1771 | void wxStyledTextCtrl::PageUp() { | |
1772 | SendMsg(2320, 0, 0); | |
1773 | } | |
1774 | ||
1775 | // Move caret one page up extending selection to new caret position. | |
1776 | void wxStyledTextCtrl::PageUpExtend() { | |
1777 | SendMsg(2321, 0, 0); | |
1778 | } | |
1779 | ||
1780 | // Move caret one page down. | |
1781 | void wxStyledTextCtrl::PageDown() { | |
1782 | SendMsg(2322, 0, 0); | |
1783 | } | |
1784 | ||
1785 | // Move caret one page down extending selection to new caret position. | |
1786 | void wxStyledTextCtrl::PageDownExtend() { | |
1787 | SendMsg(2323, 0, 0); | |
1788 | } | |
1789 | ||
1790 | // Switch from insert to overtype mode or the reverse. | |
1791 | void wxStyledTextCtrl::EditToggleOvertype() { | |
1792 | SendMsg(2324, 0, 0); | |
1793 | } | |
1794 | ||
1795 | // Cancel any modes such as call tip or auto-completion list display. | |
1796 | void wxStyledTextCtrl::Cancel() { | |
1797 | SendMsg(2325, 0, 0); | |
1798 | } | |
1799 | ||
1800 | // Delete the selection or if no selection, the character before the caret. | |
1801 | void wxStyledTextCtrl::DeleteBack() { | |
1802 | SendMsg(2326, 0, 0); | |
1803 | } | |
1804 | ||
1805 | // If selection is empty or all on one line replace the selection with a tab character. | |
1806 | // If more than one line selected, indent the lines. | |
1807 | void wxStyledTextCtrl::Tab() { | |
1808 | SendMsg(2327, 0, 0); | |
1809 | } | |
1810 | ||
1811 | // Dedent the selected lines. | |
1812 | void wxStyledTextCtrl::BackTab() { | |
1813 | SendMsg(2328, 0, 0); | |
1814 | } | |
1815 | ||
1816 | // Insert a new line, may use a CRLF, CR or LF depending on EOL mode. | |
1817 | void wxStyledTextCtrl::NewLine() { | |
1818 | SendMsg(2329, 0, 0); | |
1819 | } | |
1820 | ||
1821 | // Insert a Form Feed character. | |
1822 | void wxStyledTextCtrl::FormFeed() { | |
1823 | SendMsg(2330, 0, 0); | |
1824 | } | |
1825 | ||
1826 | // Move caret to before first visible character on line. | |
1827 | // If already there move to first character on line. | |
1828 | void wxStyledTextCtrl::VCHome() { | |
1829 | SendMsg(2331, 0, 0); | |
1830 | } | |
1831 | ||
1832 | // Like VCHome but extending selection to new caret position. | |
1833 | void wxStyledTextCtrl::VCHomeExtend() { | |
1834 | SendMsg(2332, 0, 0); | |
1835 | } | |
1836 | ||
1837 | // Magnify the displayed text by increasing the sizes by 1 point. | |
1838 | void wxStyledTextCtrl::ZoomIn() { | |
1839 | SendMsg(2333, 0, 0); | |
1840 | } | |
1841 | ||
1842 | // Make the displayed text smaller by decreasing the sizes by 1 point. | |
1843 | void wxStyledTextCtrl::ZoomOut() { | |
1844 | SendMsg(2334, 0, 0); | |
1845 | } | |
1846 | ||
1847 | // Delete the word to the left of the caret. | |
1848 | void wxStyledTextCtrl::DelWordLeft() { | |
1849 | SendMsg(2335, 0, 0); | |
1850 | } | |
1851 | ||
1852 | // Delete the word to the right of the caret. | |
1853 | void wxStyledTextCtrl::DelWordRight() { | |
1854 | SendMsg(2336, 0, 0); | |
1855 | } | |
1856 | ||
1857 | // Cut the line containing the caret. | |
1858 | void wxStyledTextCtrl::LineCut() { | |
1859 | SendMsg(2337, 0, 0); | |
1860 | } | |
1861 | ||
1862 | // Delete the line containing the caret. | |
1863 | void wxStyledTextCtrl::LineDelete() { | |
1864 | SendMsg(2338, 0, 0); | |
1865 | } | |
1866 | ||
1867 | // Switch the current line with the previous. | |
1868 | void wxStyledTextCtrl::LineTranspose() { | |
1869 | SendMsg(2339, 0, 0); | |
1870 | } | |
1871 | ||
9e730a78 RD |
1872 | // Duplicate the current line. |
1873 | void wxStyledTextCtrl::LineDuplicate() { | |
1874 | SendMsg(2404, 0, 0); | |
1875 | } | |
1876 | ||
c26dba42 RD |
1877 | // Transform the selection to lower case. |
1878 | void wxStyledTextCtrl::LowerCase() { | |
1879 | SendMsg(2340, 0, 0); | |
1880 | } | |
1881 | ||
1882 | // Transform the selection to upper case. | |
1883 | void wxStyledTextCtrl::UpperCase() { | |
1884 | SendMsg(2341, 0, 0); | |
1885 | } | |
1886 | ||
1887 | // Scroll the document down, keeping the caret visible. | |
1888 | void wxStyledTextCtrl::LineScrollDown() { | |
1889 | SendMsg(2342, 0, 0); | |
1890 | } | |
1891 | ||
1892 | // Scroll the document up, keeping the caret visible. | |
1893 | void wxStyledTextCtrl::LineScrollUp() { | |
1894 | SendMsg(2343, 0, 0); | |
1895 | } | |
1896 | ||
1897 | // Delete the selection or if no selection, the character before the caret. | |
1898 | // Will not delete the character before at the start of a line. | |
1899 | void wxStyledTextCtrl::DeleteBackNotLine() { | |
1900 | SendMsg(2344, 0, 0); | |
1901 | } | |
1902 | ||
f114b858 RD |
1903 | // Move caret to first position on display line. |
1904 | void wxStyledTextCtrl::HomeDisplay() { | |
1905 | SendMsg(2345, 0, 0); | |
1906 | } | |
1907 | ||
2b5f62a0 | 1908 | // Move caret to first position on display line extending selection to |
f114b858 RD |
1909 | // new caret position. |
1910 | void wxStyledTextCtrl::HomeDisplayExtend() { | |
1911 | SendMsg(2346, 0, 0); | |
1912 | } | |
1913 | ||
1914 | // Move caret to last position on display line. | |
1915 | void wxStyledTextCtrl::LineEndDisplay() { | |
1916 | SendMsg(2347, 0, 0); | |
1917 | } | |
1918 | ||
2b5f62a0 | 1919 | // Move caret to last position on display line extending selection to new |
f114b858 RD |
1920 | // caret position. |
1921 | void wxStyledTextCtrl::LineEndDisplayExtend() { | |
1922 | SendMsg(2348, 0, 0); | |
1923 | } | |
1924 | ||
c26dba42 RD |
1925 | // These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)? |
1926 | // except they behave differently when word-wrap is enabled: | |
1927 | // They go first to the start / end of the display line, like (Home|LineEnd)Display | |
1928 | // The difference is that, the cursor is already at the point, it goes on to the start | |
1929 | // or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?. | |
1930 | void wxStyledTextCtrl::HomeWrap() { | |
1931 | SendMsg(2349, 0, 0); | |
1932 | } | |
1933 | void wxStyledTextCtrl::HomeWrapExtend() { | |
1934 | SendMsg(2450, 0, 0); | |
1935 | } | |
1936 | void wxStyledTextCtrl::LineEndWrap() { | |
1937 | SendMsg(2451, 0, 0); | |
1938 | } | |
1939 | void wxStyledTextCtrl::LineEndWrapExtend() { | |
1940 | SendMsg(2452, 0, 0); | |
1941 | } | |
1942 | void wxStyledTextCtrl::VCHomeWrap() { | |
1943 | SendMsg(2453, 0, 0); | |
1944 | } | |
1945 | void wxStyledTextCtrl::VCHomeWrapExtend() { | |
1946 | SendMsg(2454, 0, 0); | |
1947 | } | |
1948 | ||
e14d10b0 RD |
1949 | // Copy the line containing the caret. |
1950 | void wxStyledTextCtrl::LineCopy() { | |
1951 | SendMsg(2455, 0, 0); | |
1952 | } | |
1953 | ||
a834585d | 1954 | // Move the caret inside current view if it's not there already. |
65ec6247 RD |
1955 | void wxStyledTextCtrl::MoveCaretInsideView() { |
1956 | SendMsg(2401, 0, 0); | |
1957 | } | |
1958 | ||
a834585d | 1959 | // How many characters are on a line, not including end of line characters? |
4370573a RD |
1960 | int wxStyledTextCtrl::LineLength(int line) { |
1961 | return SendMsg(2350, line, 0); | |
1962 | } | |
9ce192d4 | 1963 | |
4370573a RD |
1964 | // Highlight the characters at two positions. |
1965 | void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2) { | |
1966 | SendMsg(2351, pos1, pos2); | |
1967 | } | |
9ce192d4 | 1968 | |
4370573a RD |
1969 | // Highlight the character at a position indicating there is no matching brace. |
1970 | void wxStyledTextCtrl::BraceBadLight(int pos) { | |
1971 | SendMsg(2352, pos, 0); | |
9ce192d4 RD |
1972 | } |
1973 | ||
4370573a RD |
1974 | // Find the position of a matching brace or INVALID_POSITION if no match. |
1975 | int wxStyledTextCtrl::BraceMatch(int pos) { | |
1976 | return SendMsg(2353, pos, 0); | |
1977 | } | |
9ce192d4 | 1978 | |
a834585d | 1979 | // Are the end of line characters visible? |
4370573a RD |
1980 | bool wxStyledTextCtrl::GetViewEOL() { |
1981 | return SendMsg(2355, 0, 0) != 0; | |
9ce192d4 RD |
1982 | } |
1983 | ||
a834585d | 1984 | // Make the end of line characters visible or invisible. |
4370573a RD |
1985 | void wxStyledTextCtrl::SetViewEOL(bool visible) { |
1986 | SendMsg(2356, visible, 0); | |
1987 | } | |
9ce192d4 | 1988 | |
4370573a RD |
1989 | // Retrieve a pointer to the document object. |
1990 | void* wxStyledTextCtrl::GetDocPointer() { | |
9e730a78 | 1991 | return (void*)SendMsg(2357); |
4370573a | 1992 | } |
67003d1a | 1993 | |
4370573a RD |
1994 | // Change the document object used. |
1995 | void wxStyledTextCtrl::SetDocPointer(void* docPointer) { | |
9e730a78 | 1996 | SendMsg(2358, 0, (long)docPointer); |
67003d1a RD |
1997 | } |
1998 | ||
4370573a RD |
1999 | // Set which document modification events are sent to the container. |
2000 | void wxStyledTextCtrl::SetModEventMask(int mask) { | |
2001 | SendMsg(2359, mask, 0); | |
2002 | } | |
67003d1a | 2003 | |
4370573a RD |
2004 | // Retrieve the column number which text should be kept within. |
2005 | int wxStyledTextCtrl::GetEdgeColumn() { | |
2006 | return SendMsg(2360, 0, 0); | |
67003d1a RD |
2007 | } |
2008 | ||
4370573a RD |
2009 | // Set the column number of the edge. |
2010 | // If text goes past the edge then it is highlighted. | |
2011 | void wxStyledTextCtrl::SetEdgeColumn(int column) { | |
2012 | SendMsg(2361, column, 0); | |
2013 | } | |
67003d1a | 2014 | |
4370573a RD |
2015 | // Retrieve the edge highlight mode. |
2016 | int wxStyledTextCtrl::GetEdgeMode() { | |
2017 | return SendMsg(2362, 0, 0); | |
67003d1a RD |
2018 | } |
2019 | ||
4370573a RD |
2020 | // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that |
2021 | // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE). | |
2022 | void wxStyledTextCtrl::SetEdgeMode(int mode) { | |
2023 | SendMsg(2363, mode, 0); | |
2024 | } | |
67003d1a | 2025 | |
4370573a RD |
2026 | // Retrieve the colour used in edge indication. |
2027 | wxColour wxStyledTextCtrl::GetEdgeColour() { | |
2028 | long c = SendMsg(2364, 0, 0); | |
2029 | return wxColourFromLong(c); | |
67003d1a RD |
2030 | } |
2031 | ||
4370573a RD |
2032 | // Change the colour used in edge indication. |
2033 | void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour) { | |
2034 | SendMsg(2365, wxColourAsLong(edgeColour), 0); | |
2035 | } | |
67003d1a | 2036 | |
4370573a RD |
2037 | // Sets the current caret position to be the search anchor. |
2038 | void wxStyledTextCtrl::SearchAnchor() { | |
2039 | SendMsg(2366, 0, 0); | |
67003d1a RD |
2040 | } |
2041 | ||
4370573a | 2042 | // Find some text starting at the search anchor. |
65ec6247 | 2043 | // Does not ensure the selection is visible. |
4370573a | 2044 | int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) { |
0c5b83b0 | 2045 | return SendMsg(2367, flags, (long)(const char*)wx2stc(text)); |
4370573a | 2046 | } |
67003d1a | 2047 | |
4370573a | 2048 | // Find some text starting at the search anchor and moving backwards. |
65ec6247 | 2049 | // Does not ensure the selection is visible. |
4370573a | 2050 | int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) { |
0c5b83b0 | 2051 | return SendMsg(2368, flags, (long)(const char*)wx2stc(text)); |
67003d1a RD |
2052 | } |
2053 | ||
4370573a RD |
2054 | // Retrieves the number of lines completely visible. |
2055 | int wxStyledTextCtrl::LinesOnScreen() { | |
2056 | return SendMsg(2370, 0, 0); | |
67003d1a RD |
2057 | } |
2058 | ||
4370573a RD |
2059 | // Set whether a pop up menu is displayed automatically when the user presses |
2060 | // the wrong mouse button. | |
2061 | void wxStyledTextCtrl::UsePopUp(bool allowPopUp) { | |
2062 | SendMsg(2371, allowPopUp, 0); | |
2063 | } | |
67003d1a | 2064 | |
a834585d | 2065 | // Is the selection rectangular? The alternative is the more common stream selection. |
4370573a RD |
2066 | bool wxStyledTextCtrl::SelectionIsRectangle() { |
2067 | return SendMsg(2372, 0, 0) != 0; | |
67003d1a RD |
2068 | } |
2069 | ||
4370573a RD |
2070 | // Set the zoom level. This number of points is added to the size of all fonts. |
2071 | // It may be positive to magnify or negative to reduce. | |
2072 | void wxStyledTextCtrl::SetZoom(int zoom) { | |
2073 | SendMsg(2373, zoom, 0); | |
2074 | } | |
67003d1a | 2075 | |
4370573a RD |
2076 | // Retrieve the zoom level. |
2077 | int wxStyledTextCtrl::GetZoom() { | |
2078 | return SendMsg(2374, 0, 0); | |
67003d1a RD |
2079 | } |
2080 | ||
4370573a RD |
2081 | // Create a new document object. |
2082 | // Starts with reference count of 1 and not selected into editor. | |
2083 | void* wxStyledTextCtrl::CreateDocument() { | |
9e730a78 | 2084 | return (void*)SendMsg(2375); |
4370573a | 2085 | } |
67003d1a | 2086 | |
4370573a RD |
2087 | // Extend life of document. |
2088 | void wxStyledTextCtrl::AddRefDocument(void* docPointer) { | |
9e730a78 | 2089 | SendMsg(2376, 0, (long)docPointer); |
67003d1a RD |
2090 | } |
2091 | ||
4370573a RD |
2092 | // Release a reference to the document, deleting document if it fades to black. |
2093 | void wxStyledTextCtrl::ReleaseDocument(void* docPointer) { | |
9e730a78 | 2094 | SendMsg(2377, 0, (long)docPointer); |
4370573a | 2095 | } |
67003d1a | 2096 | |
4370573a RD |
2097 | // Get which document modification events are sent to the container. |
2098 | int wxStyledTextCtrl::GetModEventMask() { | |
2099 | return SendMsg(2378, 0, 0); | |
67003d1a RD |
2100 | } |
2101 | ||
a834585d | 2102 | // Change internal focus flag. |
8de28db9 | 2103 | void wxStyledTextCtrl::SetSTCFocus(bool focus) { |
65ec6247 RD |
2104 | SendMsg(2380, focus, 0); |
2105 | } | |
2106 | ||
a834585d | 2107 | // Get internal focus flag. |
8de28db9 | 2108 | bool wxStyledTextCtrl::GetSTCFocus() { |
65ec6247 RD |
2109 | return SendMsg(2381, 0, 0) != 0; |
2110 | } | |
2111 | ||
a834585d | 2112 | // Change error status - 0 = OK. |
65ec6247 RD |
2113 | void wxStyledTextCtrl::SetStatus(int statusCode) { |
2114 | SendMsg(2382, statusCode, 0); | |
2115 | } | |
2116 | ||
a834585d | 2117 | // Get error status. |
65ec6247 RD |
2118 | int wxStyledTextCtrl::GetStatus() { |
2119 | return SendMsg(2383, 0, 0); | |
2120 | } | |
2121 | ||
a834585d | 2122 | // Set whether the mouse is captured when its button is pressed. |
65ec6247 RD |
2123 | void wxStyledTextCtrl::SetMouseDownCaptures(bool captures) { |
2124 | SendMsg(2384, captures, 0); | |
2125 | } | |
2126 | ||
a834585d | 2127 | // Get whether mouse gets captured. |
65ec6247 RD |
2128 | bool wxStyledTextCtrl::GetMouseDownCaptures() { |
2129 | return SendMsg(2385, 0, 0) != 0; | |
2130 | } | |
2131 | ||
a834585d | 2132 | // Sets the cursor to one of the SC_CURSOR* values. |
88a8b04e | 2133 | void wxStyledTextCtrl::SetSTCCursor(int cursorType) { |
65ec6247 RD |
2134 | SendMsg(2386, cursorType, 0); |
2135 | } | |
2136 | ||
a834585d | 2137 | // Get cursor type. |
88a8b04e | 2138 | int wxStyledTextCtrl::GetSTCCursor() { |
65ec6247 RD |
2139 | return SendMsg(2387, 0, 0); |
2140 | } | |
2141 | ||
1a2fb4cd | 2142 | // Change the way control characters are displayed: |
a834585d | 2143 | // If symbol is < 32, keep the drawn way, else, use the given character. |
1a2fb4cd RD |
2144 | void wxStyledTextCtrl::SetControlCharSymbol(int symbol) { |
2145 | SendMsg(2388, symbol, 0); | |
2146 | } | |
2147 | ||
a834585d | 2148 | // Get the way control characters are displayed. |
1a2fb4cd RD |
2149 | int wxStyledTextCtrl::GetControlCharSymbol() { |
2150 | return SendMsg(2389, 0, 0); | |
2151 | } | |
2152 | ||
a834585d | 2153 | // Move to the previous change in capitalisation. |
65ec6247 RD |
2154 | void wxStyledTextCtrl::WordPartLeft() { |
2155 | SendMsg(2390, 0, 0); | |
2156 | } | |
2157 | ||
a834585d RD |
2158 | // Move to the previous change in capitalisation extending selection |
2159 | // to new caret position. | |
65ec6247 RD |
2160 | void wxStyledTextCtrl::WordPartLeftExtend() { |
2161 | SendMsg(2391, 0, 0); | |
2162 | } | |
2163 | ||
a834585d | 2164 | // Move to the change next in capitalisation. |
65ec6247 RD |
2165 | void wxStyledTextCtrl::WordPartRight() { |
2166 | SendMsg(2392, 0, 0); | |
2167 | } | |
2168 | ||
a834585d RD |
2169 | // Move to the next change in capitalisation extending selection |
2170 | // to new caret position. | |
65ec6247 RD |
2171 | void wxStyledTextCtrl::WordPartRightExtend() { |
2172 | SendMsg(2393, 0, 0); | |
2173 | } | |
2174 | ||
a834585d RD |
2175 | // Set the way the display area is determined when a particular line |
2176 | // is to be moved to by Find, FindNext, GotoLine, etc. | |
65ec6247 RD |
2177 | void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop) { |
2178 | SendMsg(2394, visiblePolicy, visibleSlop); | |
2179 | } | |
2180 | ||
a834585d | 2181 | // Delete back from the current position to the start of the line. |
65ec6247 RD |
2182 | void wxStyledTextCtrl::DelLineLeft() { |
2183 | SendMsg(2395, 0, 0); | |
2184 | } | |
2185 | ||
a834585d | 2186 | // Delete forwards from the current position to the end of the line. |
65ec6247 RD |
2187 | void wxStyledTextCtrl::DelLineRight() { |
2188 | SendMsg(2396, 0, 0); | |
2189 | } | |
2190 | ||
a834585d | 2191 | // Get and Set the xOffset (ie, horizonal scroll position). |
1a2fb4cd RD |
2192 | void wxStyledTextCtrl::SetXOffset(int newOffset) { |
2193 | SendMsg(2397, newOffset, 0); | |
2194 | } | |
2195 | int wxStyledTextCtrl::GetXOffset() { | |
2196 | return SendMsg(2398, 0, 0); | |
2197 | } | |
2198 | ||
8e54aaed | 2199 | // Set the last x chosen value to be the caret x position. |
9e730a78 RD |
2200 | void wxStyledTextCtrl::ChooseCaretX() { |
2201 | SendMsg(2399, 0, 0); | |
2202 | } | |
2203 | ||
a834585d RD |
2204 | // Set the way the caret is kept visible when going sideway. |
2205 | // The exclusion zone is given in pixels. | |
2206 | void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy, int caretSlop) { | |
2207 | SendMsg(2402, caretPolicy, caretSlop); | |
2208 | } | |
2209 | ||
2210 | // Set the way the line the caret is on is kept visible. | |
2211 | // The exclusion zone is given in lines. | |
2212 | void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy, int caretSlop) { | |
2213 | SendMsg(2403, caretPolicy, caretSlop); | |
2214 | } | |
2215 | ||
9e730a78 RD |
2216 | // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE). |
2217 | void wxStyledTextCtrl::SetPrintWrapMode(int mode) { | |
2218 | SendMsg(2406, mode, 0); | |
2219 | } | |
2220 | ||
8e54aaed | 2221 | // Is printing line wrapped? |
9e730a78 RD |
2222 | int wxStyledTextCtrl::GetPrintWrapMode() { |
2223 | return SendMsg(2407, 0, 0); | |
2224 | } | |
2225 | ||
2226 | // Set a fore colour for active hotspots. | |
2227 | void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting, const wxColour& fore) { | |
2228 | SendMsg(2410, useSetting, wxColourAsLong(fore)); | |
2229 | } | |
2230 | ||
2231 | // Set a back colour for active hotspots. | |
2232 | void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting, const wxColour& back) { | |
2233 | SendMsg(2411, useSetting, wxColourAsLong(back)); | |
2234 | } | |
2235 | ||
2236 | // Enable / Disable underlining active hotspots. | |
2237 | void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline) { | |
2238 | SendMsg(2412, underline, 0); | |
2239 | } | |
2240 | ||
8e54aaed RD |
2241 | // Limit hotspots to single line so hotspots on two lines don't merge. |
2242 | void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine) { | |
2243 | SendMsg(2421, singleLine, 0); | |
2244 | } | |
2245 | ||
c26dba42 RD |
2246 | // Move caret between paragraphs (delimited by empty lines). |
2247 | void wxStyledTextCtrl::ParaDown() { | |
2248 | SendMsg(2413, 0, 0); | |
2249 | } | |
2250 | void wxStyledTextCtrl::ParaDownExtend() { | |
2251 | SendMsg(2414, 0, 0); | |
2252 | } | |
2253 | void wxStyledTextCtrl::ParaUp() { | |
2254 | SendMsg(2415, 0, 0); | |
2255 | } | |
2256 | void wxStyledTextCtrl::ParaUpExtend() { | |
2257 | SendMsg(2416, 0, 0); | |
2258 | } | |
2259 | ||
e14d10b0 RD |
2260 | // Given a valid document position, return the previous position taking code |
2261 | // page into account. Returns 0 if passed 0. | |
2262 | int wxStyledTextCtrl::PositionBefore(int pos) { | |
2263 | return SendMsg(2417, pos, 0); | |
2264 | } | |
2265 | ||
2266 | // Given a valid document position, return the next position taking code | |
2267 | // page into account. Maximum value returned is the last position in the document. | |
2268 | int wxStyledTextCtrl::PositionAfter(int pos) { | |
2269 | return SendMsg(2418, pos, 0); | |
2270 | } | |
2271 | ||
2272 | // Copy a range of text to the clipboard. Positions are clipped into the document. | |
2273 | void wxStyledTextCtrl::CopyRange(int start, int end) { | |
2274 | SendMsg(2419, start, end); | |
2275 | } | |
2276 | ||
2277 | // Copy argument text to the clipboard. | |
2278 | void wxStyledTextCtrl::CopyText(int length, const wxString& text) { | |
2279 | SendMsg(2420, length, (long)(const char*)wx2stc(text)); | |
2280 | } | |
2281 | ||
8e54aaed RD |
2282 | // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or |
2283 | // by lines (SC_SEL_LINES). | |
2284 | void wxStyledTextCtrl::SetSelectionMode(int mode) { | |
2285 | SendMsg(2422, mode, 0); | |
2286 | } | |
2287 | ||
2288 | // Get the mode of the current selection. | |
2289 | int wxStyledTextCtrl::GetSelectionMode() { | |
2290 | return SendMsg(2423, 0, 0); | |
2291 | } | |
2292 | ||
2293 | // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line). | |
2294 | int wxStyledTextCtrl::GetLineSelStartPosition(int line) { | |
2295 | return SendMsg(2424, line, 0); | |
2296 | } | |
2297 | ||
2298 | // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line). | |
2299 | int wxStyledTextCtrl::GetLineSelEndPosition(int line) { | |
2300 | return SendMsg(2425, line, 0); | |
2301 | } | |
2302 | ||
c26dba42 RD |
2303 | // Move caret down one line, extending rectangular selection to new caret position. |
2304 | void wxStyledTextCtrl::LineDownRectExtend() { | |
2305 | SendMsg(2426, 0, 0); | |
2306 | } | |
2307 | ||
2308 | // Move caret up one line, extending rectangular selection to new caret position. | |
2309 | void wxStyledTextCtrl::LineUpRectExtend() { | |
2310 | SendMsg(2427, 0, 0); | |
2311 | } | |
2312 | ||
2313 | // Move caret left one character, extending rectangular selection to new caret position. | |
2314 | void wxStyledTextCtrl::CharLeftRectExtend() { | |
2315 | SendMsg(2428, 0, 0); | |
2316 | } | |
2317 | ||
2318 | // Move caret right one character, extending rectangular selection to new caret position. | |
2319 | void wxStyledTextCtrl::CharRightRectExtend() { | |
2320 | SendMsg(2429, 0, 0); | |
2321 | } | |
2322 | ||
2323 | // Move caret to first position on line, extending rectangular selection to new caret position. | |
2324 | void wxStyledTextCtrl::HomeRectExtend() { | |
2325 | SendMsg(2430, 0, 0); | |
2326 | } | |
2327 | ||
2328 | // Move caret to before first visible character on line. | |
2329 | // If already there move to first character on line. | |
2330 | // In either case, extend rectangular selection to new caret position. | |
2331 | void wxStyledTextCtrl::VCHomeRectExtend() { | |
2332 | SendMsg(2431, 0, 0); | |
2333 | } | |
2334 | ||
2335 | // Move caret to last position on line, extending rectangular selection to new caret position. | |
2336 | void wxStyledTextCtrl::LineEndRectExtend() { | |
2337 | SendMsg(2432, 0, 0); | |
2338 | } | |
2339 | ||
2340 | // Move caret one page up, extending rectangular selection to new caret position. | |
2341 | void wxStyledTextCtrl::PageUpRectExtend() { | |
2342 | SendMsg(2433, 0, 0); | |
2343 | } | |
2344 | ||
2345 | // Move caret one page down, extending rectangular selection to new caret position. | |
2346 | void wxStyledTextCtrl::PageDownRectExtend() { | |
2347 | SendMsg(2434, 0, 0); | |
2348 | } | |
2349 | ||
2350 | // Move caret to top of page, or one page up if already at top of page. | |
2351 | void wxStyledTextCtrl::StutteredPageUp() { | |
2352 | SendMsg(2435, 0, 0); | |
2353 | } | |
2354 | ||
2355 | // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position. | |
2356 | void wxStyledTextCtrl::StutteredPageUpExtend() { | |
2357 | SendMsg(2436, 0, 0); | |
2358 | } | |
2359 | ||
2360 | // Move caret to bottom of page, or one page down if already at bottom of page. | |
2361 | void wxStyledTextCtrl::StutteredPageDown() { | |
2362 | SendMsg(2437, 0, 0); | |
2363 | } | |
2364 | ||
2365 | // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position. | |
2366 | void wxStyledTextCtrl::StutteredPageDownExtend() { | |
2367 | SendMsg(2438, 0, 0); | |
2368 | } | |
2369 | ||
2370 | // Move caret left one word, position cursor at end of word. | |
2371 | void wxStyledTextCtrl::WordLeftEnd() { | |
2372 | SendMsg(2439, 0, 0); | |
2373 | } | |
2374 | ||
2375 | // Move caret left one word, position cursor at end of word, extending selection to new caret position. | |
2376 | void wxStyledTextCtrl::WordLeftEndExtend() { | |
2377 | SendMsg(2440, 0, 0); | |
2378 | } | |
2379 | ||
2380 | // Move caret right one word, position cursor at end of word. | |
2381 | void wxStyledTextCtrl::WordRightEnd() { | |
2382 | SendMsg(2441, 0, 0); | |
2383 | } | |
2384 | ||
2385 | // Move caret right one word, position cursor at end of word, extending selection to new caret position. | |
2386 | void wxStyledTextCtrl::WordRightEndExtend() { | |
2387 | SendMsg(2442, 0, 0); | |
2388 | } | |
2389 | ||
8e54aaed RD |
2390 | // Set the set of characters making up whitespace for when moving or selecting by word. |
2391 | // Should be called after SetWordChars. | |
2392 | void wxStyledTextCtrl::SetWhitespaceChars(const wxString& characters) { | |
2393 | SendMsg(2443, 0, (long)(const char*)wx2stc(characters)); | |
2394 | } | |
2395 | ||
2396 | // Reset the set of characters for whitespace and word characters to the defaults. | |
2397 | void wxStyledTextCtrl::SetCharsDefault() { | |
2398 | SendMsg(2444, 0, 0); | |
2399 | } | |
2400 | ||
2401 | // Get currently selected item position in the auto-completion list | |
2402 | int wxStyledTextCtrl::AutoCompGetCurrent() { | |
2403 | return SendMsg(2445, 0, 0); | |
2404 | } | |
2405 | ||
591d01be RD |
2406 | // Enlarge the document to a particular size of text bytes. |
2407 | void wxStyledTextCtrl::Allocate(int bytes) { | |
2408 | SendMsg(2446, bytes, 0); | |
2409 | } | |
2410 | ||
a33203cb RD |
2411 | // Find the position of a column on a line taking into account tabs and |
2412 | // multi-byte characters. If beyond end of line, return line end position. | |
2413 | int wxStyledTextCtrl::FindColumn(int line, int column) { | |
2414 | return SendMsg(2456, line, column); | |
2415 | } | |
2416 | ||
4370573a RD |
2417 | // Start notifying the container of all key presses and commands. |
2418 | void wxStyledTextCtrl::StartRecord() { | |
2419 | SendMsg(3001, 0, 0); | |
2420 | } | |
67003d1a | 2421 | |
4370573a RD |
2422 | // Stop notifying the container of all key presses and commands. |
2423 | void wxStyledTextCtrl::StopRecord() { | |
2424 | SendMsg(3002, 0, 0); | |
67003d1a RD |
2425 | } |
2426 | ||
4370573a RD |
2427 | // Set the lexing language of the document. |
2428 | void wxStyledTextCtrl::SetLexer(int lexer) { | |
2429 | SendMsg(4001, lexer, 0); | |
2430 | } | |
67003d1a | 2431 | |
4370573a RD |
2432 | // Retrieve the lexing language of the document. |
2433 | int wxStyledTextCtrl::GetLexer() { | |
2434 | return SendMsg(4002, 0, 0); | |
67003d1a RD |
2435 | } |
2436 | ||
4370573a RD |
2437 | // Colourise a segment of the document using the current lexing language. |
2438 | void wxStyledTextCtrl::Colourise(int start, int end) { | |
2439 | SendMsg(4003, start, end); | |
2440 | } | |
67003d1a | 2441 | |
4370573a RD |
2442 | // Set up a value that may be used by a lexer for some optional feature. |
2443 | void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) { | |
0c5b83b0 | 2444 | SendMsg(4004, (long)(const char*)wx2stc(key), (long)(const char*)wx2stc(value)); |
f6bcfd97 BP |
2445 | } |
2446 | ||
4370573a RD |
2447 | // Set up the key words used by the lexer. |
2448 | void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) { | |
0c5b83b0 | 2449 | SendMsg(4005, keywordSet, (long)(const char*)wx2stc(keyWords)); |
4370573a | 2450 | } |
f6bcfd97 | 2451 | |
65ec6247 RD |
2452 | // Set the lexing language of the document based on string name. |
2453 | void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) { | |
0c5b83b0 | 2454 | SendMsg(4006, 0, (long)(const char*)wx2stc(language)); |
65ec6247 RD |
2455 | } |
2456 | ||
4370573a | 2457 | // END of generated section |
f6bcfd97 | 2458 | //---------------------------------------------------------------------- |
f6bcfd97 BP |
2459 | |
2460 | ||
4370573a RD |
2461 | // Returns the line number of the line with the caret. |
2462 | int wxStyledTextCtrl::GetCurrentLine() { | |
2463 | int line = LineFromPosition(GetCurrentPos()); | |
2464 | return line; | |
f6bcfd97 BP |
2465 | } |
2466 | ||
2467 | ||
4370573a RD |
2468 | // Extract style settings from a spec-string which is composed of one or |
2469 | // more of the following comma separated elements: | |
2470 | // | |
2471 | // bold turns on bold | |
2472 | // italic turns on italics | |
5ee1d760 RD |
2473 | // fore:[name or #RRGGBB] sets the foreground colour |
2474 | // back:[name or #RRGGBB] sets the background colour | |
4370573a RD |
2475 | // face:[facename] sets the font face name to use |
2476 | // size:[num] sets the font size in points | |
2477 | // eol turns on eol filling | |
2478 | // underline turns on underlining | |
2479 | // | |
2480 | void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) { | |
2481 | ||
451c5cc7 | 2482 | wxStringTokenizer tkz(spec, wxT(",")); |
4370573a RD |
2483 | while (tkz.HasMoreTokens()) { |
2484 | wxString token = tkz.GetNextToken(); | |
f6bcfd97 | 2485 | |
4370573a RD |
2486 | wxString option = token.BeforeFirst(':'); |
2487 | wxString val = token.AfterFirst(':'); | |
f6bcfd97 | 2488 | |
451c5cc7 | 2489 | if (option == wxT("bold")) |
4370573a | 2490 | StyleSetBold(styleNum, true); |
f6bcfd97 | 2491 | |
451c5cc7 | 2492 | else if (option == wxT("italic")) |
4370573a | 2493 | StyleSetItalic(styleNum, true); |
9ce192d4 | 2494 | |
451c5cc7 | 2495 | else if (option == wxT("underline")) |
4370573a | 2496 | StyleSetUnderline(styleNum, true); |
9ce192d4 | 2497 | |
451c5cc7 | 2498 | else if (option == wxT("eol")) |
4370573a | 2499 | StyleSetEOLFilled(styleNum, true); |
9ce192d4 | 2500 | |
451c5cc7 | 2501 | else if (option == wxT("size")) { |
4370573a RD |
2502 | long points; |
2503 | if (val.ToLong(&points)) | |
2504 | StyleSetSize(styleNum, points); | |
2505 | } | |
9ce192d4 | 2506 | |
451c5cc7 | 2507 | else if (option == wxT("face")) |
4370573a | 2508 | StyleSetFaceName(styleNum, val); |
9ce192d4 | 2509 | |
451c5cc7 | 2510 | else if (option == wxT("fore")) |
4370573a | 2511 | StyleSetForeground(styleNum, wxColourFromSpec(val)); |
9ce192d4 | 2512 | |
451c5cc7 | 2513 | else if (option == wxT("back")) |
4370573a RD |
2514 | StyleSetBackground(styleNum, wxColourFromSpec(val)); |
2515 | } | |
9ce192d4 RD |
2516 | } |
2517 | ||
2518 | ||
4370573a RD |
2519 | // Set style size, face, bold, italic, and underline attributes from |
2520 | // a wxFont's attributes. | |
2521 | void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) { | |
7475e814 RD |
2522 | #ifdef __WXGTK__ |
2523 | // Ensure that the native font is initialized | |
2524 | int x, y; | |
2525 | GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font); | |
2526 | #endif | |
af0531a5 RD |
2527 | int size = font.GetPointSize(); |
2528 | wxString faceName = font.GetFaceName(); | |
2529 | bool bold = font.GetWeight() == wxBOLD; | |
2530 | bool italic = font.GetStyle() != wxNORMAL; | |
2531 | bool under = font.GetUnderlined(); | |
c5bd09bf | 2532 | wxFontEncoding encoding = font.GetEncoding(); |
af0531a5 RD |
2533 | |
2534 | StyleSetFontAttr(styleNum, size, faceName, bold, italic, under, encoding); | |
9ce192d4 RD |
2535 | } |
2536 | ||
4370573a RD |
2537 | // Set all font style attributes at once. |
2538 | void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size, | |
2539 | const wxString& faceName, | |
2540 | bool bold, bool italic, | |
3727c043 RD |
2541 | bool underline, |
2542 | wxFontEncoding encoding) { | |
4370573a RD |
2543 | StyleSetSize(styleNum, size); |
2544 | StyleSetFaceName(styleNum, faceName); | |
2545 | StyleSetBold(styleNum, bold); | |
2546 | StyleSetItalic(styleNum, italic); | |
2547 | StyleSetUnderline(styleNum, underline); | |
3727c043 RD |
2548 | StyleSetFontEncoding(styleNum, encoding); |
2549 | } | |
9ce192d4 | 2550 | |
3727c043 RD |
2551 | |
2552 | // Set the character set of the font in a style. Converts the Scintilla | |
2553 | // character set values to a wxFontEncoding. | |
2554 | void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet) | |
2555 | { | |
2556 | wxFontEncoding encoding; | |
2557 | ||
2558 | // Translate the Scintilla characterSet to a wxFontEncoding | |
2559 | switch (characterSet) { | |
2560 | default: | |
2561 | case wxSTC_CHARSET_ANSI: | |
2562 | case wxSTC_CHARSET_DEFAULT: | |
2563 | encoding = wxFONTENCODING_DEFAULT; | |
2564 | break; | |
2565 | ||
2566 | case wxSTC_CHARSET_BALTIC: | |
2567 | encoding = wxFONTENCODING_ISO8859_13; | |
2568 | break; | |
2569 | ||
2570 | case wxSTC_CHARSET_CHINESEBIG5: | |
2571 | encoding = wxFONTENCODING_CP950; | |
2572 | break; | |
2573 | ||
2574 | case wxSTC_CHARSET_EASTEUROPE: | |
2575 | encoding = wxFONTENCODING_ISO8859_2; | |
2576 | break; | |
2577 | ||
2578 | case wxSTC_CHARSET_GB2312: | |
2579 | encoding = wxFONTENCODING_CP936; | |
2580 | break; | |
2581 | ||
2582 | case wxSTC_CHARSET_GREEK: | |
2583 | encoding = wxFONTENCODING_ISO8859_7; | |
2584 | break; | |
2585 | ||
2586 | case wxSTC_CHARSET_HANGUL: | |
2587 | encoding = wxFONTENCODING_CP949; | |
2588 | break; | |
2589 | ||
2590 | case wxSTC_CHARSET_MAC: | |
2591 | encoding = wxFONTENCODING_DEFAULT; | |
2592 | break; | |
2593 | ||
2594 | case wxSTC_CHARSET_OEM: | |
2595 | encoding = wxFONTENCODING_DEFAULT; | |
2596 | break; | |
2597 | ||
2598 | case wxSTC_CHARSET_RUSSIAN: | |
2599 | encoding = wxFONTENCODING_KOI8; | |
2600 | break; | |
2601 | ||
2602 | case wxSTC_CHARSET_SHIFTJIS: | |
2603 | encoding = wxFONTENCODING_CP932; | |
2604 | break; | |
2605 | ||
2606 | case wxSTC_CHARSET_SYMBOL: | |
2607 | encoding = wxFONTENCODING_DEFAULT; | |
2608 | break; | |
2609 | ||
2610 | case wxSTC_CHARSET_TURKISH: | |
2611 | encoding = wxFONTENCODING_ISO8859_9; | |
2612 | break; | |
2613 | ||
2614 | case wxSTC_CHARSET_JOHAB: | |
2615 | encoding = wxFONTENCODING_DEFAULT; | |
2616 | break; | |
2617 | ||
2618 | case wxSTC_CHARSET_HEBREW: | |
2619 | encoding = wxFONTENCODING_ISO8859_8; | |
2620 | break; | |
2621 | ||
2622 | case wxSTC_CHARSET_ARABIC: | |
2623 | encoding = wxFONTENCODING_ISO8859_6; | |
2624 | break; | |
2625 | ||
2626 | case wxSTC_CHARSET_VIETNAMESE: | |
2627 | encoding = wxFONTENCODING_DEFAULT; | |
2628 | break; | |
2629 | ||
2630 | case wxSTC_CHARSET_THAI: | |
2631 | encoding = wxFONTENCODING_ISO8859_11; | |
2632 | break; | |
2633 | } | |
2634 | ||
2635 | // We just have Scintilla track the wxFontEncoding for us. It gets used | |
2636 | // in Font::Create in PlatWX.cpp. We add one to the value so that the | |
2637 | // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when | |
2638 | // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back | |
2639 | // to wxFONENCODING_DEFAULT in Font::Create. | |
2640 | SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1); | |
2641 | } | |
2642 | ||
2643 | ||
2644 | // Set the font encoding to be used by a style. | |
2645 | void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding) | |
2646 | { | |
2647 | SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1); | |
9ce192d4 RD |
2648 | } |
2649 | ||
2650 | ||
4370573a RD |
2651 | // Perform one of the operations defined by the wxSTC_CMD_* constants. |
2652 | void wxStyledTextCtrl::CmdKeyExecute(int cmd) { | |
2653 | SendMsg(cmd); | |
9ce192d4 RD |
2654 | } |
2655 | ||
2656 | ||
4370573a RD |
2657 | // Set the left and right margin in the edit area, measured in pixels. |
2658 | void wxStyledTextCtrl::SetMargins(int left, int right) { | |
2659 | SetMarginLeft(left); | |
2660 | SetMarginRight(right); | |
9ce192d4 RD |
2661 | } |
2662 | ||
2663 | ||
4370573a RD |
2664 | // Retrieve the start and end positions of the current selection. |
2665 | void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) { | |
2666 | if (startPos != NULL) | |
2667 | *startPos = SendMsg(SCI_GETSELECTIONSTART); | |
2668 | if (endPos != NULL) | |
2669 | *endPos = SendMsg(SCI_GETSELECTIONEND); | |
9ce192d4 RD |
2670 | } |
2671 | ||
2672 | ||
4370573a RD |
2673 | // Retrieve the point in the window where a position is displayed. |
2674 | wxPoint wxStyledTextCtrl::PointFromPosition(int pos) { | |
2675 | int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos); | |
2676 | int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos); | |
2677 | return wxPoint(x, y); | |
f6bcfd97 BP |
2678 | } |
2679 | ||
f97d84a6 RD |
2680 | // Scroll enough to make the given line visible |
2681 | void wxStyledTextCtrl::ScrollToLine(int line) { | |
2682 | m_swx->DoScrollToLine(line); | |
2683 | } | |
2684 | ||
2685 | ||
2686 | // Scroll enough to make the given column visible | |
2687 | void wxStyledTextCtrl::ScrollToColumn(int column) { | |
2688 | m_swx->DoScrollToColumn(column); | |
2689 | } | |
2690 | ||
f6bcfd97 | 2691 | |
51566b0b RD |
2692 | bool wxStyledTextCtrl::SaveFile(const wxString& filename) |
2693 | { | |
2694 | wxFile file(filename, wxFile::write); | |
2695 | ||
2696 | if (!file.IsOpened()) | |
7e126a07 | 2697 | return false; |
51566b0b | 2698 | |
88a8b04e | 2699 | bool success = file.Write(GetText(), *wxConvCurrent); |
51566b0b | 2700 | |
4a65f2c8 | 2701 | if (success) |
51566b0b | 2702 | SetSavePoint(); |
4a65f2c8 | 2703 | |
51566b0b RD |
2704 | return success; |
2705 | } | |
2706 | ||
2707 | bool wxStyledTextCtrl::LoadFile(const wxString& filename) | |
2708 | { | |
041973c5 | 2709 | bool success = false; |
51566b0b RD |
2710 | wxFile file(filename, wxFile::read); |
2711 | ||
041973c5 | 2712 | if (file.IsOpened()) |
51566b0b | 2713 | { |
041973c5 | 2714 | wxString contents; |
c8b75e94 WS |
2715 | // get the file size (assume it is not huge file...) |
2716 | ssize_t len = (ssize_t)file.Length(); | |
2717 | ||
041973c5 RD |
2718 | if (len > 0) |
2719 | { | |
1e545382 | 2720 | #if wxUSE_UNICODE |
1c26fbe0 | 2721 | wxMemoryBuffer buffer(len+1); |
8e5ec9cc | 2722 | success = (file.Read(buffer.GetData(), len) == len); |
ccfc3219 | 2723 | if (success) { |
9efe0302 RD |
2724 | ((char*)buffer.GetData())[len] = 0; |
2725 | contents = wxString(buffer, *wxConvCurrent, len); | |
2726 | } | |
88a8b04e | 2727 | #else |
8e5ec9cc MB |
2728 | wxString buffer; |
2729 | success = (file.Read(wxStringBuffer(buffer, len), len) == len); | |
88a8b04e RD |
2730 | contents = buffer; |
2731 | #endif | |
041973c5 RD |
2732 | } |
2733 | else | |
c8b75e94 WS |
2734 | { |
2735 | if (len == 0) | |
2736 | success = true; // empty file is ok | |
2737 | else | |
2738 | success = false; // len == wxInvalidOffset | |
2739 | } | |
041973c5 RD |
2740 | |
2741 | if (success) | |
2742 | { | |
2743 | SetText(contents); | |
2744 | EmptyUndoBuffer(); | |
2745 | SetSavePoint(); | |
2746 | } | |
51566b0b RD |
2747 | } |
2748 | ||
2749 | return success; | |
2750 | } | |
2751 | ||
d25f5fbb | 2752 | |
2fcce896 | 2753 | #if wxUSE_DRAG_AND_DROP |
7e126a07 WS |
2754 | wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { |
2755 | return m_swx->DoDragOver(x, y, def); | |
2756 | } | |
4a65f2c8 RD |
2757 | |
2758 | ||
7e126a07 | 2759 | bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) { |
4a65f2c8 RD |
2760 | return m_swx->DoDropText(x, y, data); |
2761 | } | |
2fcce896 | 2762 | #endif |
4a65f2c8 RD |
2763 | |
2764 | ||
d1558f3d RD |
2765 | void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) { |
2766 | m_swx->SetUseAntiAliasing(useAA); | |
2767 | } | |
2768 | ||
2769 | bool wxStyledTextCtrl::GetUseAntiAliasing() { | |
2770 | return m_swx->GetUseAntiAliasing(); | |
2771 | } | |
2772 | ||
41a499cd RD |
2773 | |
2774 | ||
2775 | ||
2776 | ||
2777 | void wxStyledTextCtrl::AddTextRaw(const char* text) | |
2778 | { | |
2779 | SendMsg(SCI_ADDTEXT, strlen(text), (long)text); | |
2780 | } | |
2781 | ||
2782 | void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text) | |
2783 | { | |
2784 | SendMsg(SCI_INSERTTEXT, pos, (long)text); | |
2785 | } | |
2786 | ||
2787 | wxCharBuffer wxStyledTextCtrl::GetCurLineRaw(int* linePos) | |
2788 | { | |
2789 | int len = LineLength(GetCurrentLine()); | |
2790 | if (!len) { | |
2791 | if (linePos) *linePos = 0; | |
2792 | wxCharBuffer empty; | |
2793 | return empty; | |
2794 | } | |
2795 | ||
2796 | wxCharBuffer buf(len); | |
2797 | int pos = SendMsg(SCI_GETCURLINE, len, (long)buf.data()); | |
2798 | if (linePos) *linePos = pos; | |
2799 | return buf; | |
2800 | } | |
2801 | ||
2802 | wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line) | |
2803 | { | |
2804 | int len = LineLength(line); | |
2805 | if (!len) { | |
2806 | wxCharBuffer empty; | |
2807 | return empty; | |
2808 | } | |
2809 | ||
2810 | wxCharBuffer buf(len); | |
2811 | SendMsg(SCI_GETLINE, line, (long)buf.data()); | |
2812 | return buf; | |
2813 | } | |
2814 | ||
2815 | wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw() | |
2816 | { | |
2817 | int start; | |
2818 | int end; | |
2819 | ||
2820 | GetSelection(&start, &end); | |
2821 | int len = end - start; | |
2822 | if (!len) { | |
2823 | wxCharBuffer empty; | |
2824 | return empty; | |
2825 | } | |
2826 | ||
2827 | wxCharBuffer buf(len); | |
2828 | SendMsg(SCI_GETSELTEXT, 0, (long)buf.data()); | |
2829 | return buf; | |
2830 | } | |
2831 | ||
2832 | wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos) | |
2833 | { | |
2834 | if (endPos < startPos) { | |
2835 | int temp = startPos; | |
2836 | startPos = endPos; | |
2837 | endPos = temp; | |
2838 | } | |
2839 | int len = endPos - startPos; | |
2840 | if (!len) { | |
2841 | wxCharBuffer empty; | |
2842 | return empty; | |
2843 | } | |
2844 | ||
2845 | wxCharBuffer buf(len); | |
2846 | TextRange tr; | |
2847 | tr.lpstrText = buf.data(); | |
2848 | tr.chrg.cpMin = startPos; | |
2849 | tr.chrg.cpMax = endPos; | |
2850 | SendMsg(SCI_GETTEXTRANGE, 0, (long)&tr); | |
2851 | return buf; | |
2852 | } | |
2853 | ||
2854 | void wxStyledTextCtrl::SetTextRaw(const char* text) | |
2855 | { | |
2856 | SendMsg(SCI_SETTEXT, 0, (long)text); | |
2857 | } | |
2858 | ||
2859 | wxCharBuffer wxStyledTextCtrl::GetTextRaw() | |
2860 | { | |
2861 | int len = GetTextLength(); | |
2862 | wxCharBuffer buf(len); | |
2863 | SendMsg(SCI_GETTEXT, len, (long)buf.data()); | |
2864 | return buf; | |
2865 | } | |
2866 | ||
2867 | void wxStyledTextCtrl::AppendTextRaw(const char* text) | |
2868 | { | |
2869 | SendMsg(SCI_APPENDTEXT, strlen(text), (long)text); | |
2870 | } | |
2871 | ||
2872 | ||
2873 | ||
2874 | ||
2875 | ||
9ce192d4 RD |
2876 | //---------------------------------------------------------------------- |
2877 | // Event handlers | |
2878 | ||
88a8b04e | 2879 | void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) { |
9ce192d4 | 2880 | wxPaintDC dc(this); |
9e730a78 | 2881 | m_swx->DoPaint(&dc, GetUpdateRegion().GetBox()); |
9ce192d4 RD |
2882 | } |
2883 | ||
2884 | void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) { | |
2885 | if (evt.GetOrientation() == wxHORIZONTAL) | |
2886 | m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition()); | |
2887 | else | |
2888 | m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition()); | |
2889 | } | |
2890 | ||
5fa4613c RD |
2891 | void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) { |
2892 | wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar); | |
2893 | if (sb) { | |
2894 | if (sb->IsVertical()) | |
2895 | m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition()); | |
2896 | else | |
2897 | m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition()); | |
2898 | } | |
2899 | } | |
2900 | ||
88a8b04e | 2901 | void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) { |
39c0acb6 RD |
2902 | if (m_swx) { |
2903 | wxSize sz = GetClientSize(); | |
2904 | m_swx->DoSize(sz.x, sz.y); | |
2905 | } | |
9ce192d4 RD |
2906 | } |
2907 | ||
2908 | void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) { | |
cb1871ca | 2909 | SetFocus(); |
9ce192d4 | 2910 | wxPoint pt = evt.GetPosition(); |
2b5f62a0 | 2911 | m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(), |
9ce192d4 RD |
2912 | evt.ShiftDown(), evt.ControlDown(), evt.AltDown()); |
2913 | } | |
2914 | ||
2915 | void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) { | |
2916 | wxPoint pt = evt.GetPosition(); | |
2b5f62a0 | 2917 | m_swx->DoLeftButtonMove(Point(pt.x, pt.y)); |
9ce192d4 RD |
2918 | } |
2919 | ||
2920 | void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) { | |
2921 | wxPoint pt = evt.GetPosition(); | |
2b5f62a0 | 2922 | m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(), |
9ce192d4 RD |
2923 | evt.ControlDown()); |
2924 | } | |
2925 | ||
2926 | ||
ddf2da08 RD |
2927 | void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) { |
2928 | wxPoint pt = evt.GetPosition(); | |
2929 | m_swx->DoContextMenu(Point(pt.x, pt.y)); | |
2930 | } | |
2931 | ||
2932 | ||
2b5f62a0 VZ |
2933 | void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) { |
2934 | wxPoint pt = evt.GetPosition(); | |
2935 | m_swx->DoMiddleButtonUp(Point(pt.x, pt.y)); | |
2936 | } | |
2937 | ||
65ec6247 | 2938 | void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) { |
9ce192d4 | 2939 | wxPoint pt = evt.GetPosition(); |
65ec6247 | 2940 | ScreenToClient(&pt.x, &pt.y); |
25484746 RD |
2941 | /* |
2942 | Show context menu at event point if it's within the window, | |
2943 | or at caret location if not | |
2944 | */ | |
2945 | wxHitTest ht = this->HitTest(pt); | |
2946 | if (ht != wxHT_WINDOW_INSIDE) { | |
2947 | pt = this->PointFromPosition(this->GetCurrentPos()); | |
2948 | } | |
9ce192d4 RD |
2949 | m_swx->DoContextMenu(Point(pt.x, pt.y)); |
2950 | } | |
2951 | ||
37d62433 RD |
2952 | |
2953 | void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) { | |
2954 | m_swx->DoMouseWheel(evt.GetWheelRotation(), | |
2955 | evt.GetWheelDelta(), | |
65ec6247 | 2956 | evt.GetLinesPerAction(), |
9b9337da RD |
2957 | evt.ControlDown(), |
2958 | evt.IsPageScroll()); | |
37d62433 RD |
2959 | } |
2960 | ||
2961 | ||
9ce192d4 | 2962 | void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { |
5fd656d5 | 2963 | // On (some?) non-US PC keyboards the AltGr key is required to enter some |
f3c2c221 RD |
2964 | // common characters. It comes to us as both Alt and Ctrl down so we need |
2965 | // to let the char through in that case, otherwise if only ctrl or only | |
2966 | // alt let's skip it. | |
2967 | bool ctrl = evt.ControlDown(); | |
28e0c28e RD |
2968 | #ifdef __WXMAC__ |
2969 | // On the Mac the Alt key is just a modifier key (like Shift) so we need | |
2970 | // to allow the char events to be processed when Alt is pressed. | |
2971 | // TODO: Should we check MetaDown instead in this case? | |
2972 | bool alt = false; | |
2973 | #else | |
f3c2c221 | 2974 | bool alt = evt.AltDown(); |
28e0c28e | 2975 | #endif |
00c64037 | 2976 | bool skip = ((ctrl || alt) && ! (ctrl && alt)); |
f3c2c221 | 2977 | |
5fd656d5 RD |
2978 | if (!m_lastKeyDownConsumed && !skip) { |
2979 | #if wxUSE_UNICODE | |
2980 | int key = evt.GetUnicodeKey(); | |
2981 | bool keyOk = true; | |
2982 | ||
2983 | // if the unicode key code is not really a unicode character (it may | |
2984 | // be a function key or etc., the platforms appear to always give us a | |
2985 | // small value in this case) then fallback to the ascii key code but | |
2986 | // don't do anything for function keys or etc. | |
1b14227e | 2987 | if (key <= 127) { |
5fd656d5 | 2988 | key = evt.GetKeyCode(); |
1b14227e | 2989 | keyOk = (key <= 127); |
5fd656d5 RD |
2990 | } |
2991 | if (keyOk) { | |
2992 | m_swx->DoAddChar(key); | |
2993 | return; | |
2994 | } | |
2995 | #else | |
2996 | int key = evt.GetKeyCode(); | |
2997 | if (key <= WXK_START || key > WXK_COMMAND) { | |
2998 | m_swx->DoAddChar(key); | |
2999 | return; | |
3000 | } | |
3001 | #endif | |
d25f5fbb | 3002 | } |
5fd656d5 | 3003 | |
f3c2c221 | 3004 | evt.Skip(); |
f6bcfd97 BP |
3005 | } |
3006 | ||
d6582821 | 3007 | |
f6bcfd97 | 3008 | void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { |
5fd656d5 | 3009 | int processed = m_swx->DoKeyDown(evt, &m_lastKeyDownConsumed); |
d6582821 | 3010 | if (!processed && !m_lastKeyDownConsumed) |
9ce192d4 RD |
3011 | evt.Skip(); |
3012 | } | |
3013 | ||
d6582821 | 3014 | |
b6bfd8e8 | 3015 | void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) { |
ec830416 | 3016 | m_swx->DoLoseFocus(); |
b6bfd8e8 | 3017 | evt.Skip(); |
9ce192d4 RD |
3018 | } |
3019 | ||
d6582821 | 3020 | |
b6bfd8e8 | 3021 | void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) { |
9ce192d4 | 3022 | m_swx->DoGainFocus(); |
b6bfd8e8 | 3023 | evt.Skip(); |
9ce192d4 RD |
3024 | } |
3025 | ||
d6582821 | 3026 | |
88a8b04e | 3027 | void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) { |
9ce192d4 RD |
3028 | m_swx->DoSysColourChange(); |
3029 | } | |
3030 | ||
d6582821 | 3031 | |
88a8b04e | 3032 | void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) { |
9ce192d4 RD |
3033 | // do nothing to help avoid flashing |
3034 | } | |
3035 | ||
3036 | ||
3037 | ||
3038 | void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) { | |
3039 | m_swx->DoCommand(evt.GetId()); | |
3040 | } | |
3041 | ||
3042 | ||
88a8b04e | 3043 | void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) { |
f6bcfd97 BP |
3044 | m_swx->DoOnListBox(); |
3045 | } | |
3046 | ||
3047 | ||
8e54aaed RD |
3048 | void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) { |
3049 | m_swx->DoOnIdle(evt); | |
3050 | } | |
3051 | ||
3052 | ||
8ae4f086 RD |
3053 | wxSize wxStyledTextCtrl::DoGetBestSize() const |
3054 | { | |
3055 | // What would be the best size for a wxSTC? | |
3056 | // Just give a reasonable minimum until something else can be figured out. | |
3057 | return wxSize(200,100); | |
3058 | } | |
3059 | ||
3060 | ||
9ce192d4 RD |
3061 | //---------------------------------------------------------------------- |
3062 | // Turn notifications from Scintilla into events | |
3063 | ||
f6bcfd97 | 3064 | |
9ce192d4 RD |
3065 | void wxStyledTextCtrl::NotifyChange() { |
3066 | wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId()); | |
a29a241f | 3067 | evt.SetEventObject(this); |
9ce192d4 RD |
3068 | GetEventHandler()->ProcessEvent(evt); |
3069 | } | |
3070 | ||
2b5f62a0 VZ |
3071 | |
3072 | static void SetEventText(wxStyledTextEvent& evt, const char* text, | |
3073 | size_t length) { | |
3074 | if(!text) return; | |
3075 | ||
3076 | // The unicode conversion MUST have a null byte to terminate the | |
3077 | // string so move it into a buffer first and give it one. | |
3078 | wxMemoryBuffer buf(length+1); | |
3079 | buf.AppendData((void*)text, length); | |
3080 | buf.AppendByte(0); | |
3081 | evt.SetText(stc2wx(buf)); | |
3082 | } | |
3083 | ||
3084 | ||
9ce192d4 RD |
3085 | void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { |
3086 | SCNotification& scn = *_scn; | |
65ec6247 RD |
3087 | wxStyledTextEvent evt(0, GetId()); |
3088 | ||
a29a241f | 3089 | evt.SetEventObject(this); |
65ec6247 RD |
3090 | evt.SetPosition(scn.position); |
3091 | evt.SetKey(scn.ch); | |
3092 | evt.SetModifiers(scn.modifiers); | |
3093 | ||
9ce192d4 RD |
3094 | switch (scn.nmhdr.code) { |
3095 | case SCN_STYLENEEDED: | |
65ec6247 | 3096 | evt.SetEventType(wxEVT_STC_STYLENEEDED); |
9ce192d4 | 3097 | break; |
65ec6247 | 3098 | |
9ce192d4 | 3099 | case SCN_CHARADDED: |
65ec6247 | 3100 | evt.SetEventType(wxEVT_STC_CHARADDED); |
9ce192d4 | 3101 | break; |
65ec6247 | 3102 | |
9ce192d4 | 3103 | case SCN_SAVEPOINTREACHED: |
65ec6247 | 3104 | evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED); |
9ce192d4 | 3105 | break; |
65ec6247 | 3106 | |
9ce192d4 | 3107 | case SCN_SAVEPOINTLEFT: |
65ec6247 | 3108 | evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT); |
9ce192d4 | 3109 | break; |
65ec6247 | 3110 | |
9ce192d4 | 3111 | case SCN_MODIFYATTEMPTRO: |
65ec6247 | 3112 | evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT); |
9ce192d4 | 3113 | break; |
65ec6247 RD |
3114 | |
3115 | case SCN_KEY: | |
3116 | evt.SetEventType(wxEVT_STC_KEY); | |
3117 | break; | |
3118 | ||
9ce192d4 | 3119 | case SCN_DOUBLECLICK: |
65ec6247 | 3120 | evt.SetEventType(wxEVT_STC_DOUBLECLICK); |
9ce192d4 | 3121 | break; |
65ec6247 RD |
3122 | |
3123 | case SCN_UPDATEUI: | |
3124 | evt.SetEventType(wxEVT_STC_UPDATEUI); | |
9ce192d4 | 3125 | break; |
65ec6247 RD |
3126 | |
3127 | case SCN_MODIFIED: | |
3128 | evt.SetEventType(wxEVT_STC_MODIFIED); | |
3129 | evt.SetModificationType(scn.modificationType); | |
2b5f62a0 | 3130 | SetEventText(evt, scn.text, scn.length); |
65ec6247 RD |
3131 | evt.SetLength(scn.length); |
3132 | evt.SetLinesAdded(scn.linesAdded); | |
3133 | evt.SetLine(scn.line); | |
3134 | evt.SetFoldLevelNow(scn.foldLevelNow); | |
3135 | evt.SetFoldLevelPrev(scn.foldLevelPrev); | |
9ce192d4 | 3136 | break; |
65ec6247 | 3137 | |
9ce192d4 | 3138 | case SCN_MACRORECORD: |
65ec6247 RD |
3139 | evt.SetEventType(wxEVT_STC_MACRORECORD); |
3140 | evt.SetMessage(scn.message); | |
3141 | evt.SetWParam(scn.wParam); | |
3142 | evt.SetLParam(scn.lParam); | |
9ce192d4 | 3143 | break; |
65ec6247 | 3144 | |
9ce192d4 | 3145 | case SCN_MARGINCLICK: |
65ec6247 RD |
3146 | evt.SetEventType(wxEVT_STC_MARGINCLICK); |
3147 | evt.SetMargin(scn.margin); | |
9ce192d4 | 3148 | break; |
65ec6247 | 3149 | |
9ce192d4 | 3150 | case SCN_NEEDSHOWN: |
65ec6247 RD |
3151 | evt.SetEventType(wxEVT_STC_NEEDSHOWN); |
3152 | evt.SetLength(scn.length); | |
9ce192d4 | 3153 | break; |
65ec6247 | 3154 | |
65ec6247 RD |
3155 | case SCN_PAINTED: |
3156 | evt.SetEventType(wxEVT_STC_PAINTED); | |
3157 | break; | |
3158 | ||
3159 | case SCN_USERLISTSELECTION: | |
3160 | evt.SetEventType(wxEVT_STC_USERLISTSELECTION); | |
3161 | evt.SetListType(scn.listType); | |
2b5f62a0 | 3162 | SetEventText(evt, scn.text, strlen(scn.text)); |
65ec6247 RD |
3163 | break; |
3164 | ||
3165 | case SCN_URIDROPPED: | |
3166 | evt.SetEventType(wxEVT_STC_URIDROPPED); | |
2b5f62a0 | 3167 | SetEventText(evt, scn.text, strlen(scn.text)); |
65ec6247 RD |
3168 | break; |
3169 | ||
3170 | case SCN_DWELLSTART: | |
3171 | evt.SetEventType(wxEVT_STC_DWELLSTART); | |
3172 | evt.SetX(scn.x); | |
3173 | evt.SetY(scn.y); | |
3174 | break; | |
3175 | ||
3176 | case SCN_DWELLEND: | |
3177 | evt.SetEventType(wxEVT_STC_DWELLEND); | |
3178 | evt.SetX(scn.x); | |
3179 | evt.SetY(scn.y); | |
3180 | break; | |
3181 | ||
a834585d RD |
3182 | case SCN_ZOOM: |
3183 | evt.SetEventType(wxEVT_STC_ZOOM); | |
3184 | break; | |
3185 | ||
9e730a78 RD |
3186 | case SCN_HOTSPOTCLICK: |
3187 | evt.SetEventType(wxEVT_STC_HOTSPOT_CLICK); | |
3188 | break; | |
3189 | ||
3190 | case SCN_HOTSPOTDOUBLECLICK: | |
3191 | evt.SetEventType(wxEVT_STC_HOTSPOT_DCLICK); | |
3192 | break; | |
3193 | ||
3194 | case SCN_CALLTIPCLICK: | |
3195 | evt.SetEventType(wxEVT_STC_CALLTIP_CLICK); | |
3196 | break; | |
3197 | ||
65ec6247 RD |
3198 | default: |
3199 | return; | |
9ce192d4 | 3200 | } |
65ec6247 RD |
3201 | |
3202 | GetEventHandler()->ProcessEvent(evt); | |
9ce192d4 RD |
3203 | } |
3204 | ||
3205 | ||
9ce192d4 RD |
3206 | //---------------------------------------------------------------------- |
3207 | //---------------------------------------------------------------------- | |
3208 | //---------------------------------------------------------------------- | |
3209 | ||
3210 | wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id) | |
3211 | : wxCommandEvent(commandType, id) | |
3212 | { | |
3213 | m_position = 0; | |
3214 | m_key = 0; | |
3215 | m_modifiers = 0; | |
3216 | m_modificationType = 0; | |
3217 | m_length = 0; | |
3218 | m_linesAdded = 0; | |
3219 | m_line = 0; | |
3220 | m_foldLevelNow = 0; | |
3221 | m_foldLevelPrev = 0; | |
3222 | m_margin = 0; | |
3223 | m_message = 0; | |
3224 | m_wParam = 0; | |
3225 | m_lParam = 0; | |
65ec6247 RD |
3226 | m_listType = 0; |
3227 | m_x = 0; | |
3228 | m_y = 0; | |
7e126a07 | 3229 | m_dragAllowMove = false; |
92bbd64f | 3230 | #if wxUSE_DRAG_AND_DROP |
a29a241f | 3231 | m_dragResult = wxDragNone; |
92bbd64f | 3232 | #endif |
9ce192d4 RD |
3233 | } |
3234 | ||
3235 | bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; } | |
3236 | bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; } | |
3237 | bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; } | |
3238 | ||
5fa4613c | 3239 | |
41286fd1 JS |
3240 | wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event): |
3241 | wxCommandEvent(event) | |
3242 | { | |
3243 | m_position = event.m_position; | |
3244 | m_key = event.m_key; | |
3245 | m_modifiers = event.m_modifiers; | |
3246 | m_modificationType = event.m_modificationType; | |
3247 | m_text = event.m_text; | |
3248 | m_length = event.m_length; | |
3249 | m_linesAdded = event.m_linesAdded; | |
3250 | m_line = event.m_line; | |
3251 | m_foldLevelNow = event.m_foldLevelNow; | |
3252 | m_foldLevelPrev = event.m_foldLevelPrev; | |
3253 | ||
3254 | m_margin = event.m_margin; | |
3255 | ||
3256 | m_message = event.m_message; | |
3257 | m_wParam = event.m_wParam; | |
3258 | m_lParam = event.m_lParam; | |
3259 | ||
3260 | m_listType = event.m_listType; | |
3261 | m_x = event.m_x; | |
3262 | m_y = event.m_y; | |
9ce192d4 | 3263 | |
41286fd1 JS |
3264 | m_dragText = event.m_dragText; |
3265 | m_dragAllowMove =event.m_dragAllowMove; | |
92bbd64f | 3266 | #if wxUSE_DRAG_AND_DROP |
41286fd1 | 3267 | m_dragResult = event.m_dragResult; |
92bbd64f | 3268 | #endif |
9ce192d4 RD |
3269 | } |
3270 | ||
3271 | //---------------------------------------------------------------------- | |
3272 | //---------------------------------------------------------------------- | |
3273 | ||
a29a241f RD |
3274 | |
3275 | ||
3276 | ||
5fa4613c RD |
3277 | |
3278 | ||
3279 | ||
3280 | ||
3281 |