1 ////////////////////////////////////////////////////////////////////////////
3 // Purpose: A wxWidgets implementation of Scintilla. This class is the
4 // one meant to be used directly by wx applications. It does not
5 // derive directly from the Scintilla classes, but instead
6 // delegates most things to the real Scintilla class.
7 // This allows the use of Scintilla without polluting the
8 // namespace with all the classes and identifiers from Scintilla.
12 // Created: 13-Jan-2000
14 // Copyright: (c) 2000 by Total Control Software
15 // Licence: wxWindows license
16 /////////////////////////////////////////////////////////////////////////////
18 // For compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
27 #include "wx/stc/stc.h"
35 #include "wx/tokenzr.h"
36 #include "wx/mstream.h"
40 #include "ScintillaWX.h"
42 //----------------------------------------------------------------------
44 const wxChar
* wxSTCNameStr
= wxT("stcwindow");
50 #define MAKELONG(a, b) ((a) | ((b) << 16))
53 static long wxColourAsLong(const wxColour
& co
) {
54 return (((long)co
.Blue() << 16) |
55 ((long)co
.Green() << 8) |
59 static wxColour
wxColourFromLong(long c
) {
61 clr
.Set((unsigned char)(c
& 0xff),
62 (unsigned char)((c
>> 8) & 0xff),
63 (unsigned char)((c
>> 16) & 0xff));
68 static wxColour
wxColourFromSpec(const wxString
& spec
) {
69 // spec should be a colour name or "#RRGGBB"
70 if (spec
.GetChar(0) == wxT('#')) {
72 long red
, green
, blue
;
73 red
= green
= blue
= 0;
74 spec
.Mid(1,2).ToLong(&red
, 16);
75 spec
.Mid(3,2).ToLong(&green
, 16);
76 spec
.Mid(5,2).ToLong(&blue
, 16);
77 return wxColour((unsigned char)red
,
82 return wxColour(spec
);
85 //----------------------------------------------------------------------
87 DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE
)
88 DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED
)
89 DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED
)
90 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED
)
91 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT
)
92 DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT
)
93 DEFINE_EVENT_TYPE( wxEVT_STC_KEY
)
94 DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK
)
95 DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI
)
96 DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED
)
97 DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD
)
98 DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK
)
99 DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN
)
100 DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED
)
101 DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION
)
102 DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED
)
103 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART
)
104 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND
)
105 DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG
)
106 DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER
)
107 DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP
)
108 DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM
)
109 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK
)
110 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK
)
111 DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK
)
112 DEFINE_EVENT_TYPE( wxEVT_STC_AUTOCOMP_SELECTION
)
116 BEGIN_EVENT_TABLE(wxStyledTextCtrl
, wxControl
)
117 EVT_PAINT (wxStyledTextCtrl::OnPaint
)
118 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin
)
119 EVT_SCROLL (wxStyledTextCtrl::OnScroll
)
120 EVT_SIZE (wxStyledTextCtrl::OnSize
)
121 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown
)
122 // Let Scintilla see the double click as a second click
123 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown
)
124 EVT_MOTION (wxStyledTextCtrl::OnMouseMove
)
125 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp
)
126 #if defined(__WXGTK__) || defined(__WXMAC__)
127 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp
)
129 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu
)
131 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel
)
132 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp
)
133 EVT_CHAR (wxStyledTextCtrl::OnChar
)
134 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown
)
135 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus
)
136 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus
)
137 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged
)
138 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground
)
139 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu
)
140 EVT_LISTBOX_DCLICK (wxID_ANY
, wxStyledTextCtrl::OnListBox
)
144 IMPLEMENT_CLASS(wxStyledTextCtrl
, wxControl
)
145 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent
, wxCommandEvent
)
148 // forces the linking of the lexer modules
149 int Scintilla_LinkLexers();
152 //----------------------------------------------------------------------
153 // Constructor and Destructor
155 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow
*parent
,
160 const wxString
& name
)
163 Create(parent
, id
, pos
, size
, style
, name
);
167 bool wxStyledTextCtrl::Create(wxWindow
*parent
,
172 const wxString
& name
)
174 style
|= wxVSCROLL
| wxHSCROLL
;
175 if (!wxControl::Create(parent
, id
, pos
, size
,
176 style
| wxWANTS_CHARS
| wxCLIP_CHILDREN
,
177 wxDefaultValidator
, name
))
181 Scintilla_LinkLexers();
183 m_swx
= new ScintillaWX(this);
185 m_lastKeyDownConsumed
= false;
189 // Put Scintilla into unicode (UTF-8) mode
190 SetCodePage(wxSTC_CP_UTF8
);
193 SetInitialSize(size
);
195 // Reduces flicker on GTK+/X11
196 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
201 wxStyledTextCtrl::~wxStyledTextCtrl() {
206 //----------------------------------------------------------------------
208 long wxStyledTextCtrl::SendMsg(int msg
, long wp
, long lp
) {
210 return m_swx
->WndProc(msg
, wp
, lp
);
213 //----------------------------------------------------------------------
215 // Set the vertical scrollbar to use instead of the ont that's built-in.
216 void wxStyledTextCtrl::SetVScrollBar(wxScrollBar
* bar
) {
219 // ensure that the built-in scrollbar is not visible
220 SetScrollbar(wxVERTICAL
, 0, 0, 0);
225 // Set the horizontal scrollbar to use instead of the ont that's built-in.
226 void wxStyledTextCtrl::SetHScrollBar(wxScrollBar
* bar
) {
229 // ensure that the built-in scrollbar is not visible
230 SetScrollbar(wxHORIZONTAL
, 0, 0, 0);
234 //----------------------------------------------------------------------
235 // BEGIN generated section. The following code is automatically generated
236 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
237 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
240 // Add text to the document at current position.
241 void wxStyledTextCtrl::AddText(const wxString
& text
) {
242 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
243 SendMsg(2001, strlen(buf
), (long)(const char*)buf
);
246 // Add array of cells to document.
247 void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer
& data
) {
248 SendMsg(2002, data
.GetDataLen(), (long)data
.GetData());
251 // Insert string at a position.
252 void wxStyledTextCtrl::InsertText(int pos
, const wxString
& text
) {
253 SendMsg(2003, pos
, (long)(const char*)wx2stc(text
));
256 // Delete all text in the document.
257 void wxStyledTextCtrl::ClearAll() {
261 // Set all style bytes to 0, remove all folding information.
262 void wxStyledTextCtrl::ClearDocumentStyle() {
266 // Returns the number of characters in the document.
267 int wxStyledTextCtrl::GetLength() {
268 return SendMsg(2006, 0, 0);
271 // Returns the character byte at the position.
272 int wxStyledTextCtrl::GetCharAt(int pos
) {
273 return (unsigned char)SendMsg(2007, pos
, 0);
276 // Returns the position of the caret.
277 int wxStyledTextCtrl::GetCurrentPos() {
278 return SendMsg(2008, 0, 0);
281 // Returns the position of the opposite end of the selection to the caret.
282 int wxStyledTextCtrl::GetAnchor() {
283 return SendMsg(2009, 0, 0);
286 // Returns the style byte at the position.
287 int wxStyledTextCtrl::GetStyleAt(int pos
) {
288 return (unsigned char)SendMsg(2010, pos
, 0);
291 // Redoes the next action on the undo history.
292 void wxStyledTextCtrl::Redo() {
296 // Choose between collecting actions into the undo
297 // history and discarding them.
298 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo
) {
299 SendMsg(2012, collectUndo
, 0);
302 // Select all the text in the document.
303 void wxStyledTextCtrl::SelectAll() {
307 // Remember the current position in the undo history as the position
308 // at which the document was saved.
309 void wxStyledTextCtrl::SetSavePoint() {
313 // Retrieve a buffer of cells.
314 wxMemoryBuffer
wxStyledTextCtrl::GetStyledText(int startPos
, int endPos
) {
316 if (endPos
< startPos
) {
321 int len
= endPos
- startPos
;
322 if (!len
) return buf
;
324 tr
.lpstrText
= (char*)buf
.GetWriteBuf(len
*2+1);
325 tr
.chrg
.cpMin
= startPos
;
326 tr
.chrg
.cpMax
= endPos
;
327 len
= SendMsg(2015, 0, (long)&tr
);
328 buf
.UngetWriteBuf(len
);
332 // Are there any redoable actions in the undo history?
333 bool wxStyledTextCtrl::CanRedo() {
334 return SendMsg(2016, 0, 0) != 0;
337 // Retrieve the line number at which a particular marker is located.
338 int wxStyledTextCtrl::MarkerLineFromHandle(int handle
) {
339 return SendMsg(2017, handle
, 0);
343 void wxStyledTextCtrl::MarkerDeleteHandle(int handle
) {
344 SendMsg(2018, handle
, 0);
347 // Is undo history being collected?
348 bool wxStyledTextCtrl::GetUndoCollection() {
349 return SendMsg(2019, 0, 0) != 0;
352 // Are white space characters currently visible?
353 // Returns one of SCWS_* constants.
354 int wxStyledTextCtrl::GetViewWhiteSpace() {
355 return SendMsg(2020, 0, 0);
358 // Make white space characters invisible, always visible or visible outside indentation.
359 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS
) {
360 SendMsg(2021, viewWS
, 0);
363 // Find the position from a point within the window.
364 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt
) {
365 return SendMsg(2022, pt
.x
, pt
.y
);
368 // Find the position from a point within the window but return
369 // INVALID_POSITION if not close to text.
370 int wxStyledTextCtrl::PositionFromPointClose(int x
, int y
) {
371 return SendMsg(2023, x
, y
);
374 // Set caret to start of a line and ensure it is visible.
375 void wxStyledTextCtrl::GotoLine(int line
) {
376 SendMsg(2024, line
, 0);
379 // Set caret to a position and ensure it is visible.
380 void wxStyledTextCtrl::GotoPos(int pos
) {
381 SendMsg(2025, pos
, 0);
384 // Set the selection anchor to a position. The anchor is the opposite
385 // end of the selection from the caret.
386 void wxStyledTextCtrl::SetAnchor(int posAnchor
) {
387 SendMsg(2026, posAnchor
, 0);
390 // Retrieve the text of the line containing the caret.
391 // Returns the index of the caret on the line.
392 wxString
wxStyledTextCtrl::GetCurLine(int* linePos
) {
393 int len
= LineLength(GetCurrentLine());
395 if (linePos
) *linePos
= 0;
396 return wxEmptyString
;
399 wxMemoryBuffer
mbuf(len
+1);
400 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
402 int pos
= SendMsg(2027, len
+1, (long)buf
);
403 mbuf
.UngetWriteBuf(len
);
405 if (linePos
) *linePos
= pos
;
409 // Retrieve the position of the last correctly styled character.
410 int wxStyledTextCtrl::GetEndStyled() {
411 return SendMsg(2028, 0, 0);
414 // Convert all line endings in the document to one mode.
415 void wxStyledTextCtrl::ConvertEOLs(int eolMode
) {
416 SendMsg(2029, eolMode
, 0);
419 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
420 int wxStyledTextCtrl::GetEOLMode() {
421 return SendMsg(2030, 0, 0);
424 // Set the current end of line mode.
425 void wxStyledTextCtrl::SetEOLMode(int eolMode
) {
426 SendMsg(2031, eolMode
, 0);
429 // Set the current styling position to pos and the styling mask to mask.
430 // The styling mask can be used to protect some bits in each styling byte from modification.
431 void wxStyledTextCtrl::StartStyling(int pos
, int mask
) {
432 SendMsg(2032, pos
, mask
);
435 // Change style from current styling position for length characters to a style
436 // and move the current styling position to after this newly styled segment.
437 void wxStyledTextCtrl::SetStyling(int length
, int style
) {
438 SendMsg(2033, length
, style
);
441 // Is drawing done first into a buffer or direct to the screen?
442 bool wxStyledTextCtrl::GetBufferedDraw() {
443 return SendMsg(2034, 0, 0) != 0;
446 // If drawing is buffered then each line of text is drawn into a bitmap buffer
447 // before drawing it to the screen to avoid flicker.
448 void wxStyledTextCtrl::SetBufferedDraw(bool buffered
) {
449 SendMsg(2035, buffered
, 0);
452 // Change the visible size of a tab to be a multiple of the width of a space character.
453 void wxStyledTextCtrl::SetTabWidth(int tabWidth
) {
454 SendMsg(2036, tabWidth
, 0);
457 // Retrieve the visible size of a tab.
458 int wxStyledTextCtrl::GetTabWidth() {
459 return SendMsg(2121, 0, 0);
462 // Set the code page used to interpret the bytes of the document as characters.
463 void wxStyledTextCtrl::SetCodePage(int codePage
) {
465 wxASSERT_MSG(codePage
== wxSTC_CP_UTF8
,
466 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
468 wxASSERT_MSG(codePage
!= wxSTC_CP_UTF8
,
469 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
471 SendMsg(2037, codePage
);
474 // Set the symbol used for a particular marker number,
475 // and optionally the fore and background colours.
476 void wxStyledTextCtrl::MarkerDefine(int markerNumber
, int markerSymbol
,
477 const wxColour
& foreground
,
478 const wxColour
& background
) {
480 SendMsg(2040, markerNumber
, markerSymbol
);
482 MarkerSetForeground(markerNumber
, foreground
);
484 MarkerSetBackground(markerNumber
, background
);
487 // Set the foreground colour used for a particular marker number.
488 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber
, const wxColour
& fore
) {
489 SendMsg(2041, markerNumber
, wxColourAsLong(fore
));
492 // Set the background colour used for a particular marker number.
493 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber
, const wxColour
& back
) {
494 SendMsg(2042, markerNumber
, wxColourAsLong(back
));
497 // Add a marker to a line, returning an ID which can be used to find or delete the marker.
498 int wxStyledTextCtrl::MarkerAdd(int line
, int markerNumber
) {
499 return SendMsg(2043, line
, markerNumber
);
502 // Delete a marker from a line.
503 void wxStyledTextCtrl::MarkerDelete(int line
, int markerNumber
) {
504 SendMsg(2044, line
, markerNumber
);
507 // Delete all markers with a particular number from all lines.
508 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber
) {
509 SendMsg(2045, markerNumber
, 0);
512 // Get a bit mask of all the markers set on a line.
513 int wxStyledTextCtrl::MarkerGet(int line
) {
514 return SendMsg(2046, line
, 0);
517 // Find the next line after lineStart that includes a marker in mask.
518 int wxStyledTextCtrl::MarkerNext(int lineStart
, int markerMask
) {
519 return SendMsg(2047, lineStart
, markerMask
);
522 // Find the previous line before lineStart that includes a marker in mask.
523 int wxStyledTextCtrl::MarkerPrevious(int lineStart
, int markerMask
) {
524 return SendMsg(2048, lineStart
, markerMask
);
527 // Define a marker from a bitmap
528 void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber
, const wxBitmap
& bmp
) {
529 // convert bmp to a xpm in a string
530 wxMemoryOutputStream strm
;
531 wxImage img
= bmp
.ConvertToImage();
533 img
.ConvertAlphaToMask();
534 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
535 size_t len
= strm
.GetSize();
536 char* buff
= new char[len
+1];
537 strm
.CopyTo(buff
, len
);
539 SendMsg(2049, markerNumber
, (long)buff
);
544 // Add a set of markers to a line.
545 void wxStyledTextCtrl::MarkerAddSet(int line
, int set
) {
546 SendMsg(2466, line
, set
);
549 // Set the alpha used for a marker that is drawn in the text area, not the margin.
550 void wxStyledTextCtrl::MarkerSetAlpha(int markerNumber
, int alpha
) {
551 SendMsg(2476, markerNumber
, alpha
);
554 // Set a margin to be either numeric or symbolic.
555 void wxStyledTextCtrl::SetMarginType(int margin
, int marginType
) {
556 SendMsg(2240, margin
, marginType
);
559 // Retrieve the type of a margin.
560 int wxStyledTextCtrl::GetMarginType(int margin
) {
561 return SendMsg(2241, margin
, 0);
564 // Set the width of a margin to a width expressed in pixels.
565 void wxStyledTextCtrl::SetMarginWidth(int margin
, int pixelWidth
) {
566 SendMsg(2242, margin
, pixelWidth
);
569 // Retrieve the width of a margin in pixels.
570 int wxStyledTextCtrl::GetMarginWidth(int margin
) {
571 return SendMsg(2243, margin
, 0);
574 // Set a mask that determines which markers are displayed in a margin.
575 void wxStyledTextCtrl::SetMarginMask(int margin
, int mask
) {
576 SendMsg(2244, margin
, mask
);
579 // Retrieve the marker mask of a margin.
580 int wxStyledTextCtrl::GetMarginMask(int margin
) {
581 return SendMsg(2245, margin
, 0);
584 // Make a margin sensitive or insensitive to mouse clicks.
585 void wxStyledTextCtrl::SetMarginSensitive(int margin
, bool sensitive
) {
586 SendMsg(2246, margin
, sensitive
);
589 // Retrieve the mouse click sensitivity of a margin.
590 bool wxStyledTextCtrl::GetMarginSensitive(int margin
) {
591 return SendMsg(2247, margin
, 0) != 0;
594 // Clear all the styles and make equivalent to the global default style.
595 void wxStyledTextCtrl::StyleClearAll() {
599 // Set the foreground colour of a style.
600 void wxStyledTextCtrl::StyleSetForeground(int style
, const wxColour
& fore
) {
601 SendMsg(2051, style
, wxColourAsLong(fore
));
604 // Set the background colour of a style.
605 void wxStyledTextCtrl::StyleSetBackground(int style
, const wxColour
& back
) {
606 SendMsg(2052, style
, wxColourAsLong(back
));
609 // Set a style to be bold or not.
610 void wxStyledTextCtrl::StyleSetBold(int style
, bool bold
) {
611 SendMsg(2053, style
, bold
);
614 // Set a style to be italic or not.
615 void wxStyledTextCtrl::StyleSetItalic(int style
, bool italic
) {
616 SendMsg(2054, style
, italic
);
619 // Set the size of characters of a style.
620 void wxStyledTextCtrl::StyleSetSize(int style
, int sizePoints
) {
621 SendMsg(2055, style
, sizePoints
);
624 // Set the font of a style.
625 void wxStyledTextCtrl::StyleSetFaceName(int style
, const wxString
& fontName
) {
626 SendMsg(2056, style
, (long)(const char*)wx2stc(fontName
));
629 // Set a style to have its end of line filled or not.
630 void wxStyledTextCtrl::StyleSetEOLFilled(int style
, bool filled
) {
631 SendMsg(2057, style
, filled
);
634 // Reset the default style to its state at startup
635 void wxStyledTextCtrl::StyleResetDefault() {
639 // Set a style to be underlined or not.
640 void wxStyledTextCtrl::StyleSetUnderline(int style
, bool underline
) {
641 SendMsg(2059, style
, underline
);
644 // Set a style to be mixed case, or to force upper or lower case.
645 void wxStyledTextCtrl::StyleSetCase(int style
, int caseForce
) {
646 SendMsg(2060, style
, caseForce
);
649 // Set a style to be a hotspot or not.
650 void wxStyledTextCtrl::StyleSetHotSpot(int style
, bool hotspot
) {
651 SendMsg(2409, style
, hotspot
);
654 // Set the foreground colour of the selection and whether to use this setting.
655 void wxStyledTextCtrl::SetSelForeground(bool useSetting
, const wxColour
& fore
) {
656 SendMsg(2067, useSetting
, wxColourAsLong(fore
));
659 // Set the background colour of the selection and whether to use this setting.
660 void wxStyledTextCtrl::SetSelBackground(bool useSetting
, const wxColour
& back
) {
661 SendMsg(2068, useSetting
, wxColourAsLong(back
));
664 // Get the alpha of the selection.
665 int wxStyledTextCtrl::GetSelAlpha() {
666 return SendMsg(2477, 0, 0);
669 // Set the alpha of the selection.
670 void wxStyledTextCtrl::SetSelAlpha(int alpha
) {
671 SendMsg(2478, alpha
, 0);
674 // Set the foreground colour of the caret.
675 void wxStyledTextCtrl::SetCaretForeground(const wxColour
& fore
) {
676 SendMsg(2069, wxColourAsLong(fore
), 0);
679 // When key+modifier combination km is pressed perform msg.
680 void wxStyledTextCtrl::CmdKeyAssign(int key
, int modifiers
, int cmd
) {
681 SendMsg(2070, MAKELONG(key
, modifiers
), cmd
);
684 // When key+modifier combination km is pressed do nothing.
685 void wxStyledTextCtrl::CmdKeyClear(int key
, int modifiers
) {
686 SendMsg(2071, MAKELONG(key
, modifiers
));
689 // Drop all key mappings.
690 void wxStyledTextCtrl::CmdKeyClearAll() {
694 // Set the styles for a segment of the document.
695 void wxStyledTextCtrl::SetStyleBytes(int length
, char* styleBytes
) {
696 SendMsg(2073, length
, (long)styleBytes
);
699 // Set a style to be visible or not.
700 void wxStyledTextCtrl::StyleSetVisible(int style
, bool visible
) {
701 SendMsg(2074, style
, visible
);
704 // Get the time in milliseconds that the caret is on and off.
705 int wxStyledTextCtrl::GetCaretPeriod() {
706 return SendMsg(2075, 0, 0);
709 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
710 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds
) {
711 SendMsg(2076, periodMilliseconds
, 0);
714 // Set the set of characters making up words for when moving or selecting by word.
715 // First sets deaults like SetCharsDefault.
716 void wxStyledTextCtrl::SetWordChars(const wxString
& characters
) {
717 SendMsg(2077, 0, (long)(const char*)wx2stc(characters
));
720 // Start a sequence of actions that is undone and redone as a unit.
722 void wxStyledTextCtrl::BeginUndoAction() {
726 // End a sequence of actions that is undone and redone as a unit.
727 void wxStyledTextCtrl::EndUndoAction() {
731 // Set an indicator to plain, squiggle or TT.
732 void wxStyledTextCtrl::IndicatorSetStyle(int indic
, int style
) {
733 SendMsg(2080, indic
, style
);
736 // Retrieve the style of an indicator.
737 int wxStyledTextCtrl::IndicatorGetStyle(int indic
) {
738 return SendMsg(2081, indic
, 0);
741 // Set the foreground colour of an indicator.
742 void wxStyledTextCtrl::IndicatorSetForeground(int indic
, const wxColour
& fore
) {
743 SendMsg(2082, indic
, wxColourAsLong(fore
));
746 // Retrieve the foreground colour of an indicator.
747 wxColour
wxStyledTextCtrl::IndicatorGetForeground(int indic
) {
748 long c
= SendMsg(2083, indic
, 0);
749 return wxColourFromLong(c
);
752 // Set the foreground colour of all whitespace and whether to use this setting.
753 void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting
, const wxColour
& fore
) {
754 SendMsg(2084, useSetting
, wxColourAsLong(fore
));
757 // Set the background colour of all whitespace and whether to use this setting.
758 void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting
, const wxColour
& back
) {
759 SendMsg(2085, useSetting
, wxColourAsLong(back
));
762 // Divide each styling byte into lexical class bits (default: 5) and indicator
763 // bits (default: 3). If a lexer requires more than 32 lexical states, then this
764 // is used to expand the possible states.
765 void wxStyledTextCtrl::SetStyleBits(int bits
) {
766 SendMsg(2090, bits
, 0);
769 // Retrieve number of bits in style bytes used to hold the lexical state.
770 int wxStyledTextCtrl::GetStyleBits() {
771 return SendMsg(2091, 0, 0);
774 // Used to hold extra styling information for each line.
775 void wxStyledTextCtrl::SetLineState(int line
, int state
) {
776 SendMsg(2092, line
, state
);
779 // Retrieve the extra styling information for a line.
780 int wxStyledTextCtrl::GetLineState(int line
) {
781 return SendMsg(2093, line
, 0);
784 // Retrieve the last line number that has line state.
785 int wxStyledTextCtrl::GetMaxLineState() {
786 return SendMsg(2094, 0, 0);
789 // Is the background of the line containing the caret in a different colour?
790 bool wxStyledTextCtrl::GetCaretLineVisible() {
791 return SendMsg(2095, 0, 0) != 0;
794 // Display the background of the line containing the caret in a different colour.
795 void wxStyledTextCtrl::SetCaretLineVisible(bool show
) {
796 SendMsg(2096, show
, 0);
799 // Get the colour of the background of the line containing the caret.
800 wxColour
wxStyledTextCtrl::GetCaretLineBackground() {
801 long c
= SendMsg(2097, 0, 0);
802 return wxColourFromLong(c
);
805 // Set the colour of the background of the line containing the caret.
806 void wxStyledTextCtrl::SetCaretLineBackground(const wxColour
& back
) {
807 SendMsg(2098, wxColourAsLong(back
), 0);
810 // Set a style to be changeable or not (read only).
811 // Experimental feature, currently buggy.
812 void wxStyledTextCtrl::StyleSetChangeable(int style
, bool changeable
) {
813 SendMsg(2099, style
, changeable
);
816 // Display a auto-completion list.
817 // The lenEntered parameter indicates how many characters before
818 // the caret should be used to provide context.
819 void wxStyledTextCtrl::AutoCompShow(int lenEntered
, const wxString
& itemList
) {
820 SendMsg(2100, lenEntered
, (long)(const char*)wx2stc(itemList
));
823 // Remove the auto-completion list from the screen.
824 void wxStyledTextCtrl::AutoCompCancel() {
828 // Is there an auto-completion list visible?
829 bool wxStyledTextCtrl::AutoCompActive() {
830 return SendMsg(2102, 0, 0) != 0;
833 // Retrieve the position of the caret when the auto-completion list was displayed.
834 int wxStyledTextCtrl::AutoCompPosStart() {
835 return SendMsg(2103, 0, 0);
838 // User has selected an item so remove the list and insert the selection.
839 void wxStyledTextCtrl::AutoCompComplete() {
843 // Define a set of character that when typed cancel the auto-completion list.
844 void wxStyledTextCtrl::AutoCompStops(const wxString
& characterSet
) {
845 SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet
));
848 // Change the separator character in the string setting up an auto-completion list.
849 // Default is space but can be changed if items contain space.
850 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter
) {
851 SendMsg(2106, separatorCharacter
, 0);
854 // Retrieve the auto-completion list separator character.
855 int wxStyledTextCtrl::AutoCompGetSeparator() {
856 return SendMsg(2107, 0, 0);
859 // Select the item in the auto-completion list that starts with a string.
860 void wxStyledTextCtrl::AutoCompSelect(const wxString
& text
) {
861 SendMsg(2108, 0, (long)(const char*)wx2stc(text
));
864 // Should the auto-completion list be cancelled if the user backspaces to a
865 // position before where the box was created.
866 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel
) {
867 SendMsg(2110, cancel
, 0);
870 // Retrieve whether auto-completion cancelled by backspacing before start.
871 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
872 return SendMsg(2111, 0, 0) != 0;
875 // Define a set of characters that when typed will cause the autocompletion to
876 // choose the selected item.
877 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString
& characterSet
) {
878 SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet
));
881 // Should a single item auto-completion list automatically choose the item.
882 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle
) {
883 SendMsg(2113, chooseSingle
, 0);
886 // Retrieve whether a single item auto-completion list automatically choose the item.
887 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
888 return SendMsg(2114, 0, 0) != 0;
891 // Set whether case is significant when performing auto-completion searches.
892 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase
) {
893 SendMsg(2115, ignoreCase
, 0);
896 // Retrieve state of ignore case flag.
897 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
898 return SendMsg(2116, 0, 0) != 0;
901 // Display a list of strings and send notification when user chooses one.
902 void wxStyledTextCtrl::UserListShow(int listType
, const wxString
& itemList
) {
903 SendMsg(2117, listType
, (long)(const char*)wx2stc(itemList
));
906 // Set whether or not autocompletion is hidden automatically when nothing matches.
907 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide
) {
908 SendMsg(2118, autoHide
, 0);
911 // Retrieve whether or not autocompletion is hidden automatically when nothing matches.
912 bool wxStyledTextCtrl::AutoCompGetAutoHide() {
913 return SendMsg(2119, 0, 0) != 0;
916 // Set whether or not autocompletion deletes any word characters
917 // after the inserted text upon completion.
918 void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord
) {
919 SendMsg(2270, dropRestOfWord
, 0);
922 // Retrieve whether or not autocompletion deletes any word characters
923 // after the inserted text upon completion.
924 bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
925 return SendMsg(2271, 0, 0) != 0;
928 // Register an image for use in autocompletion lists.
929 void wxStyledTextCtrl::RegisterImage(int type
, const wxBitmap
& bmp
) {
930 // convert bmp to a xpm in a string
931 wxMemoryOutputStream strm
;
932 wxImage img
= bmp
.ConvertToImage();
934 img
.ConvertAlphaToMask();
935 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
936 size_t len
= strm
.GetSize();
937 char* buff
= new char[len
+1];
938 strm
.CopyTo(buff
, len
);
940 SendMsg(2405, type
, (long)buff
);
945 // Clear all the registered images.
946 void wxStyledTextCtrl::ClearRegisteredImages() {
950 // Retrieve the auto-completion list type-separator character.
951 int wxStyledTextCtrl::AutoCompGetTypeSeparator() {
952 return SendMsg(2285, 0, 0);
955 // Change the type-separator character in the string setting up an auto-completion list.
956 // Default is '?' but can be changed if items contain '?'.
957 void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter
) {
958 SendMsg(2286, separatorCharacter
, 0);
961 // Set the maximum width, in characters, of auto-completion and user lists.
962 // Set to 0 to autosize to fit longest item, which is the default.
963 void wxStyledTextCtrl::AutoCompSetMaxWidth(int characterCount
) {
964 SendMsg(2208, characterCount
, 0);
967 // Get the maximum width, in characters, of auto-completion and user lists.
968 int wxStyledTextCtrl::AutoCompGetMaxWidth() {
969 return SendMsg(2209, 0, 0);
972 // Set the maximum height, in rows, of auto-completion and user lists.
973 // The default is 5 rows.
974 void wxStyledTextCtrl::AutoCompSetMaxHeight(int rowCount
) {
975 SendMsg(2210, rowCount
, 0);
978 // Set the maximum height, in rows, of auto-completion and user lists.
979 int wxStyledTextCtrl::AutoCompGetMaxHeight() {
980 return SendMsg(2211, 0, 0);
983 // Set the number of spaces used for one level of indentation.
984 void wxStyledTextCtrl::SetIndent(int indentSize
) {
985 SendMsg(2122, indentSize
, 0);
988 // Retrieve indentation size.
989 int wxStyledTextCtrl::GetIndent() {
990 return SendMsg(2123, 0, 0);
993 // Indentation will only use space characters if useTabs is false, otherwise
994 // it will use a combination of tabs and spaces.
995 void wxStyledTextCtrl::SetUseTabs(bool useTabs
) {
996 SendMsg(2124, useTabs
, 0);
999 // Retrieve whether tabs will be used in indentation.
1000 bool wxStyledTextCtrl::GetUseTabs() {
1001 return SendMsg(2125, 0, 0) != 0;
1004 // Change the indentation of a line to a number of columns.
1005 void wxStyledTextCtrl::SetLineIndentation(int line
, int indentSize
) {
1006 SendMsg(2126, line
, indentSize
);
1009 // Retrieve the number of columns that a line is indented.
1010 int wxStyledTextCtrl::GetLineIndentation(int line
) {
1011 return SendMsg(2127, line
, 0);
1014 // Retrieve the position before the first non indentation character on a line.
1015 int wxStyledTextCtrl::GetLineIndentPosition(int line
) {
1016 return SendMsg(2128, line
, 0);
1019 // Retrieve the column number of a position, taking tab width into account.
1020 int wxStyledTextCtrl::GetColumn(int pos
) {
1021 return SendMsg(2129, pos
, 0);
1024 // Show or hide the horizontal scroll bar.
1025 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show
) {
1026 SendMsg(2130, show
, 0);
1029 // Is the horizontal scroll bar visible?
1030 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
1031 return SendMsg(2131, 0, 0) != 0;
1034 // Show or hide indentation guides.
1035 void wxStyledTextCtrl::SetIndentationGuides(bool show
) {
1036 SendMsg(2132, show
, 0);
1039 // Are the indentation guides visible?
1040 bool wxStyledTextCtrl::GetIndentationGuides() {
1041 return SendMsg(2133, 0, 0) != 0;
1044 // Set the highlighted indentation guide column.
1045 // 0 = no highlighted guide.
1046 void wxStyledTextCtrl::SetHighlightGuide(int column
) {
1047 SendMsg(2134, column
, 0);
1050 // Get the highlighted indentation guide column.
1051 int wxStyledTextCtrl::GetHighlightGuide() {
1052 return SendMsg(2135, 0, 0);
1055 // Get the position after the last visible characters on a line.
1056 int wxStyledTextCtrl::GetLineEndPosition(int line
) {
1057 return SendMsg(2136, line
, 0);
1060 // Get the code page used to interpret the bytes of the document as characters.
1061 int wxStyledTextCtrl::GetCodePage() {
1062 return SendMsg(2137, 0, 0);
1065 // Get the foreground colour of the caret.
1066 wxColour
wxStyledTextCtrl::GetCaretForeground() {
1067 long c
= SendMsg(2138, 0, 0);
1068 return wxColourFromLong(c
);
1071 // In read-only mode?
1072 bool wxStyledTextCtrl::GetReadOnly() {
1073 return SendMsg(2140, 0, 0) != 0;
1076 // Sets the position of the caret.
1077 void wxStyledTextCtrl::SetCurrentPos(int pos
) {
1078 SendMsg(2141, pos
, 0);
1081 // Sets the position that starts the selection - this becomes the anchor.
1082 void wxStyledTextCtrl::SetSelectionStart(int pos
) {
1083 SendMsg(2142, pos
, 0);
1086 // Returns the position at the start of the selection.
1087 int wxStyledTextCtrl::GetSelectionStart() {
1088 return SendMsg(2143, 0, 0);
1091 // Sets the position that ends the selection - this becomes the currentPosition.
1092 void wxStyledTextCtrl::SetSelectionEnd(int pos
) {
1093 SendMsg(2144, pos
, 0);
1096 // Returns the position at the end of the selection.
1097 int wxStyledTextCtrl::GetSelectionEnd() {
1098 return SendMsg(2145, 0, 0);
1101 // Sets the print magnification added to the point size of each style for printing.
1102 void wxStyledTextCtrl::SetPrintMagnification(int magnification
) {
1103 SendMsg(2146, magnification
, 0);
1106 // Returns the print magnification.
1107 int wxStyledTextCtrl::GetPrintMagnification() {
1108 return SendMsg(2147, 0, 0);
1111 // Modify colours when printing for clearer printed text.
1112 void wxStyledTextCtrl::SetPrintColourMode(int mode
) {
1113 SendMsg(2148, mode
, 0);
1116 // Returns the print colour mode.
1117 int wxStyledTextCtrl::GetPrintColourMode() {
1118 return SendMsg(2149, 0, 0);
1121 // Find some text in the document.
1122 int wxStyledTextCtrl::FindText(int minPos
, int maxPos
,
1123 const wxString
& text
,
1126 ft
.chrg
.cpMin
= minPos
;
1127 ft
.chrg
.cpMax
= maxPos
;
1128 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1129 ft
.lpstrText
= (char*)(const char*)buf
;
1131 return SendMsg(2150, flags
, (long)&ft
);
1134 // On Windows, will draw the document into a display context such as a printer.
1135 int wxStyledTextCtrl::FormatRange(bool doDraw
,
1144 if (endPos
< startPos
) {
1145 int temp
= startPos
;
1150 fr
.hdcTarget
= target
;
1151 fr
.rc
.top
= renderRect
.GetTop();
1152 fr
.rc
.left
= renderRect
.GetLeft();
1153 fr
.rc
.right
= renderRect
.GetRight();
1154 fr
.rc
.bottom
= renderRect
.GetBottom();
1155 fr
.rcPage
.top
= pageRect
.GetTop();
1156 fr
.rcPage
.left
= pageRect
.GetLeft();
1157 fr
.rcPage
.right
= pageRect
.GetRight();
1158 fr
.rcPage
.bottom
= pageRect
.GetBottom();
1159 fr
.chrg
.cpMin
= startPos
;
1160 fr
.chrg
.cpMax
= endPos
;
1162 return SendMsg(2151, doDraw
, (long)&fr
);
1165 // Retrieve the display line at the top of the display.
1166 int wxStyledTextCtrl::GetFirstVisibleLine() {
1167 return SendMsg(2152, 0, 0);
1170 // Retrieve the contents of a line.
1171 wxString
wxStyledTextCtrl::GetLine(int line
) {
1172 int len
= LineLength(line
);
1173 if (!len
) return wxEmptyString
;
1175 wxMemoryBuffer
mbuf(len
+1);
1176 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1177 SendMsg(2153, line
, (long)buf
);
1178 mbuf
.UngetWriteBuf(len
);
1183 // Returns the number of lines in the document. There is always at least one.
1184 int wxStyledTextCtrl::GetLineCount() {
1185 return SendMsg(2154, 0, 0);
1188 // Sets the size in pixels of the left margin.
1189 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth
) {
1190 SendMsg(2155, 0, pixelWidth
);
1193 // Returns the size in pixels of the left margin.
1194 int wxStyledTextCtrl::GetMarginLeft() {
1195 return SendMsg(2156, 0, 0);
1198 // Sets the size in pixels of the right margin.
1199 void wxStyledTextCtrl::SetMarginRight(int pixelWidth
) {
1200 SendMsg(2157, 0, pixelWidth
);
1203 // Returns the size in pixels of the right margin.
1204 int wxStyledTextCtrl::GetMarginRight() {
1205 return SendMsg(2158, 0, 0);
1208 // Is the document different from when it was last saved?
1209 bool wxStyledTextCtrl::GetModify() {
1210 return SendMsg(2159, 0, 0) != 0;
1213 // Select a range of text.
1214 void wxStyledTextCtrl::SetSelection(int start
, int end
) {
1215 SendMsg(2160, start
, end
);
1218 // Retrieve the selected text.
1219 wxString
wxStyledTextCtrl::GetSelectedText() {
1223 GetSelection(&start
, &end
);
1224 int len
= end
- start
;
1225 if (!len
) return wxEmptyString
;
1227 wxMemoryBuffer
mbuf(len
+2);
1228 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1229 SendMsg(2161, 0, (long)buf
);
1230 mbuf
.UngetWriteBuf(len
);
1235 // Retrieve a range of text.
1236 wxString
wxStyledTextCtrl::GetTextRange(int startPos
, int endPos
) {
1237 if (endPos
< startPos
) {
1238 int temp
= startPos
;
1242 int len
= endPos
- startPos
;
1243 if (!len
) return wxEmptyString
;
1244 wxMemoryBuffer
mbuf(len
+1);
1245 char* buf
= (char*)mbuf
.GetWriteBuf(len
);
1248 tr
.chrg
.cpMin
= startPos
;
1249 tr
.chrg
.cpMax
= endPos
;
1250 SendMsg(2162, 0, (long)&tr
);
1251 mbuf
.UngetWriteBuf(len
);
1256 // Draw the selection in normal style or with selection highlighted.
1257 void wxStyledTextCtrl::HideSelection(bool normal
) {
1258 SendMsg(2163, normal
, 0);
1261 // Retrieve the line containing a position.
1262 int wxStyledTextCtrl::LineFromPosition(int pos
) {
1263 return SendMsg(2166, pos
, 0);
1266 // Retrieve the position at the start of a line.
1267 int wxStyledTextCtrl::PositionFromLine(int line
) {
1268 return SendMsg(2167, line
, 0);
1271 // Scroll horizontally and vertically.
1272 void wxStyledTextCtrl::LineScroll(int columns
, int lines
) {
1273 SendMsg(2168, columns
, lines
);
1276 // Ensure the caret is visible.
1277 void wxStyledTextCtrl::EnsureCaretVisible() {
1278 SendMsg(2169, 0, 0);
1281 // Replace the selected text with the argument text.
1282 void wxStyledTextCtrl::ReplaceSelection(const wxString
& text
) {
1283 SendMsg(2170, 0, (long)(const char*)wx2stc(text
));
1286 // Set to read only or read write.
1287 void wxStyledTextCtrl::SetReadOnly(bool readOnly
) {
1288 SendMsg(2171, readOnly
, 0);
1291 // Will a paste succeed?
1292 bool wxStyledTextCtrl::CanPaste() {
1293 return SendMsg(2173, 0, 0) != 0;
1296 // Are there any undoable actions in the undo history?
1297 bool wxStyledTextCtrl::CanUndo() {
1298 return SendMsg(2174, 0, 0) != 0;
1301 // Delete the undo history.
1302 void wxStyledTextCtrl::EmptyUndoBuffer() {
1303 SendMsg(2175, 0, 0);
1306 // Undo one action in the undo history.
1307 void wxStyledTextCtrl::Undo() {
1308 SendMsg(2176, 0, 0);
1311 // Cut the selection to the clipboard.
1312 void wxStyledTextCtrl::Cut() {
1313 SendMsg(2177, 0, 0);
1316 // Copy the selection to the clipboard.
1317 void wxStyledTextCtrl::Copy() {
1318 SendMsg(2178, 0, 0);
1321 // Paste the contents of the clipboard into the document replacing the selection.
1322 void wxStyledTextCtrl::Paste() {
1323 SendMsg(2179, 0, 0);
1326 // Clear the selection.
1327 void wxStyledTextCtrl::Clear() {
1328 SendMsg(2180, 0, 0);
1331 // Replace the contents of the document with the argument text.
1332 void wxStyledTextCtrl::SetText(const wxString
& text
) {
1333 SendMsg(2181, 0, (long)(const char*)wx2stc(text
));
1336 // Retrieve all the text in the document.
1337 wxString
wxStyledTextCtrl::GetText() {
1338 int len
= GetTextLength();
1339 wxMemoryBuffer
mbuf(len
+1); // leave room for the null...
1340 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1341 SendMsg(2182, len
+1, (long)buf
);
1342 mbuf
.UngetWriteBuf(len
);
1347 // Retrieve the number of characters in the document.
1348 int wxStyledTextCtrl::GetTextLength() {
1349 return SendMsg(2183, 0, 0);
1352 // Set to overtype (true) or insert mode.
1353 void wxStyledTextCtrl::SetOvertype(bool overtype
) {
1354 SendMsg(2186, overtype
, 0);
1357 // Returns true if overtype mode is active otherwise false is returned.
1358 bool wxStyledTextCtrl::GetOvertype() {
1359 return SendMsg(2187, 0, 0) != 0;
1362 // Set the width of the insert mode caret.
1363 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth
) {
1364 SendMsg(2188, pixelWidth
, 0);
1367 // Returns the width of the insert mode caret.
1368 int wxStyledTextCtrl::GetCaretWidth() {
1369 return SendMsg(2189, 0, 0);
1372 // Sets the position that starts the target which is used for updating the
1373 // document without affecting the scroll position.
1374 void wxStyledTextCtrl::SetTargetStart(int pos
) {
1375 SendMsg(2190, pos
, 0);
1378 // Get the position that starts the target.
1379 int wxStyledTextCtrl::GetTargetStart() {
1380 return SendMsg(2191, 0, 0);
1383 // Sets the position that ends the target which is used for updating the
1384 // document without affecting the scroll position.
1385 void wxStyledTextCtrl::SetTargetEnd(int pos
) {
1386 SendMsg(2192, pos
, 0);
1389 // Get the position that ends the target.
1390 int wxStyledTextCtrl::GetTargetEnd() {
1391 return SendMsg(2193, 0, 0);
1394 // Replace the target text with the argument text.
1395 // Text is counted so it can contain NULs.
1396 // Returns the length of the replacement text.
1398 int wxStyledTextCtrl::ReplaceTarget(const wxString
& text
) {
1399 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1400 return SendMsg(2194, strlen(buf
), (long)(const char*)buf
);
1403 // Replace the target text with the argument text after \d processing.
1404 // Text is counted so it can contain NULs.
1405 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1406 // matched in the last search operation which were surrounded by \( and \).
1407 // Returns the length of the replacement text including any change
1408 // caused by processing the \d patterns.
1410 int wxStyledTextCtrl::ReplaceTargetRE(const wxString
& text
) {
1411 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1412 return SendMsg(2195, strlen(buf
), (long)(const char*)buf
);
1415 // Search for a counted string in the target and set the target to the found
1416 // range. Text is counted so it can contain NULs.
1417 // Returns length of range or -1 for failure in which case target is not moved.
1419 int wxStyledTextCtrl::SearchInTarget(const wxString
& text
) {
1420 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1421 return SendMsg(2197, strlen(buf
), (long)(const char*)buf
);
1424 // Set the search flags used by SearchInTarget.
1425 void wxStyledTextCtrl::SetSearchFlags(int flags
) {
1426 SendMsg(2198, flags
, 0);
1429 // Get the search flags used by SearchInTarget.
1430 int wxStyledTextCtrl::GetSearchFlags() {
1431 return SendMsg(2199, 0, 0);
1434 // Show a call tip containing a definition near position pos.
1435 void wxStyledTextCtrl::CallTipShow(int pos
, const wxString
& definition
) {
1436 SendMsg(2200, pos
, (long)(const char*)wx2stc(definition
));
1439 // Remove the call tip from the screen.
1440 void wxStyledTextCtrl::CallTipCancel() {
1441 SendMsg(2201, 0, 0);
1444 // Is there an active call tip?
1445 bool wxStyledTextCtrl::CallTipActive() {
1446 return SendMsg(2202, 0, 0) != 0;
1449 // Retrieve the position where the caret was before displaying the call tip.
1450 int wxStyledTextCtrl::CallTipPosAtStart() {
1451 return SendMsg(2203, 0, 0);
1454 // Highlight a segment of the definition.
1455 void wxStyledTextCtrl::CallTipSetHighlight(int start
, int end
) {
1456 SendMsg(2204, start
, end
);
1459 // Set the background colour for the call tip.
1460 void wxStyledTextCtrl::CallTipSetBackground(const wxColour
& back
) {
1461 SendMsg(2205, wxColourAsLong(back
), 0);
1464 // Set the foreground colour for the call tip.
1465 void wxStyledTextCtrl::CallTipSetForeground(const wxColour
& fore
) {
1466 SendMsg(2206, wxColourAsLong(fore
), 0);
1469 // Set the foreground colour for the highlighted part of the call tip.
1470 void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour
& fore
) {
1471 SendMsg(2207, wxColourAsLong(fore
), 0);
1474 // Enable use of STYLE_CALLTIP and set call tip tab size in pixels.
1475 void wxStyledTextCtrl::CallTipUseStyle(int tabSize
) {
1476 SendMsg(2212, tabSize
, 0);
1479 // Find the display line of a document line taking hidden lines into account.
1480 int wxStyledTextCtrl::VisibleFromDocLine(int line
) {
1481 return SendMsg(2220, line
, 0);
1484 // Find the document line of a display line taking hidden lines into account.
1485 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay
) {
1486 return SendMsg(2221, lineDisplay
, 0);
1489 // The number of display lines needed to wrap a document line
1490 int wxStyledTextCtrl::WrapCount(int line
) {
1491 return SendMsg(2235, line
, 0);
1494 // Set the fold level of a line.
1495 // This encodes an integer level along with flags indicating whether the
1496 // line is a header and whether it is effectively white space.
1497 void wxStyledTextCtrl::SetFoldLevel(int line
, int level
) {
1498 SendMsg(2222, line
, level
);
1501 // Retrieve the fold level of a line.
1502 int wxStyledTextCtrl::GetFoldLevel(int line
) {
1503 return SendMsg(2223, line
, 0);
1506 // Find the last child line of a header line.
1507 int wxStyledTextCtrl::GetLastChild(int line
, int level
) {
1508 return SendMsg(2224, line
, level
);
1511 // Find the parent line of a child line.
1512 int wxStyledTextCtrl::GetFoldParent(int line
) {
1513 return SendMsg(2225, line
, 0);
1516 // Make a range of lines visible.
1517 void wxStyledTextCtrl::ShowLines(int lineStart
, int lineEnd
) {
1518 SendMsg(2226, lineStart
, lineEnd
);
1521 // Make a range of lines invisible.
1522 void wxStyledTextCtrl::HideLines(int lineStart
, int lineEnd
) {
1523 SendMsg(2227, lineStart
, lineEnd
);
1526 // Is a line visible?
1527 bool wxStyledTextCtrl::GetLineVisible(int line
) {
1528 return SendMsg(2228, line
, 0) != 0;
1531 // Show the children of a header line.
1532 void wxStyledTextCtrl::SetFoldExpanded(int line
, bool expanded
) {
1533 SendMsg(2229, line
, expanded
);
1536 // Is a header line expanded?
1537 bool wxStyledTextCtrl::GetFoldExpanded(int line
) {
1538 return SendMsg(2230, line
, 0) != 0;
1541 // Switch a header line between expanded and contracted.
1542 void wxStyledTextCtrl::ToggleFold(int line
) {
1543 SendMsg(2231, line
, 0);
1546 // Ensure a particular line is visible by expanding any header line hiding it.
1547 void wxStyledTextCtrl::EnsureVisible(int line
) {
1548 SendMsg(2232, line
, 0);
1551 // Set some style options for folding.
1552 void wxStyledTextCtrl::SetFoldFlags(int flags
) {
1553 SendMsg(2233, flags
, 0);
1556 // Ensure a particular line is visible by expanding any header line hiding it.
1557 // Use the currently set visibility policy to determine which range to display.
1558 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line
) {
1559 SendMsg(2234, line
, 0);
1562 // Sets whether a tab pressed when caret is within indentation indents.
1563 void wxStyledTextCtrl::SetTabIndents(bool tabIndents
) {
1564 SendMsg(2260, tabIndents
, 0);
1567 // Does a tab pressed when caret is within indentation indent?
1568 bool wxStyledTextCtrl::GetTabIndents() {
1569 return SendMsg(2261, 0, 0) != 0;
1572 // Sets whether a backspace pressed when caret is within indentation unindents.
1573 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents
) {
1574 SendMsg(2262, bsUnIndents
, 0);
1577 // Does a backspace pressed when caret is within indentation unindent?
1578 bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1579 return SendMsg(2263, 0, 0) != 0;
1582 // Sets the time the mouse must sit still to generate a mouse dwell event.
1583 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds
) {
1584 SendMsg(2264, periodMilliseconds
, 0);
1587 // Retrieve the time the mouse must sit still to generate a mouse dwell event.
1588 int wxStyledTextCtrl::GetMouseDwellTime() {
1589 return SendMsg(2265, 0, 0);
1592 // Get position of start of word.
1593 int wxStyledTextCtrl::WordStartPosition(int pos
, bool onlyWordCharacters
) {
1594 return SendMsg(2266, pos
, onlyWordCharacters
);
1597 // Get position of end of word.
1598 int wxStyledTextCtrl::WordEndPosition(int pos
, bool onlyWordCharacters
) {
1599 return SendMsg(2267, pos
, onlyWordCharacters
);
1602 // Sets whether text is word wrapped.
1603 void wxStyledTextCtrl::SetWrapMode(int mode
) {
1604 SendMsg(2268, mode
, 0);
1607 // Retrieve whether text is word wrapped.
1608 int wxStyledTextCtrl::GetWrapMode() {
1609 return SendMsg(2269, 0, 0);
1612 // Set the display mode of visual flags for wrapped lines.
1613 void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags
) {
1614 SendMsg(2460, wrapVisualFlags
, 0);
1617 // Retrive the display mode of visual flags for wrapped lines.
1618 int wxStyledTextCtrl::GetWrapVisualFlags() {
1619 return SendMsg(2461, 0, 0);
1622 // Set the location of visual flags for wrapped lines.
1623 void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation
) {
1624 SendMsg(2462, wrapVisualFlagsLocation
, 0);
1627 // Retrive the location of visual flags for wrapped lines.
1628 int wxStyledTextCtrl::GetWrapVisualFlagsLocation() {
1629 return SendMsg(2463, 0, 0);
1632 // Set the start indent for wrapped lines.
1633 void wxStyledTextCtrl::SetWrapStartIndent(int indent
) {
1634 SendMsg(2464, indent
, 0);
1637 // Retrive the start indent for wrapped lines.
1638 int wxStyledTextCtrl::GetWrapStartIndent() {
1639 return SendMsg(2465, 0, 0);
1642 // Sets the degree of caching of layout information.
1643 void wxStyledTextCtrl::SetLayoutCache(int mode
) {
1644 SendMsg(2272, mode
, 0);
1647 // Retrieve the degree of caching of layout information.
1648 int wxStyledTextCtrl::GetLayoutCache() {
1649 return SendMsg(2273, 0, 0);
1652 // Sets the document width assumed for scrolling.
1653 void wxStyledTextCtrl::SetScrollWidth(int pixelWidth
) {
1654 SendMsg(2274, pixelWidth
, 0);
1657 // Retrieve the document width assumed for scrolling.
1658 int wxStyledTextCtrl::GetScrollWidth() {
1659 return SendMsg(2275, 0, 0);
1662 // Measure the pixel width of some text in a particular style.
1663 // NUL terminated text argument.
1664 // Does not handle tab or control characters.
1665 int wxStyledTextCtrl::TextWidth(int style
, const wxString
& text
) {
1666 return SendMsg(2276, style
, (long)(const char*)wx2stc(text
));
1669 // Sets the scroll range so that maximum scroll position has
1670 // the last line at the bottom of the view (default).
1671 // Setting this to false allows scrolling one page below the last line.
1672 void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine
) {
1673 SendMsg(2277, endAtLastLine
, 0);
1676 // Retrieve whether the maximum scroll position has the last
1677 // line at the bottom of the view.
1678 bool wxStyledTextCtrl::GetEndAtLastLine() {
1679 return SendMsg(2278, 0, 0) != 0;
1682 // Retrieve the height of a particular line of text in pixels.
1683 int wxStyledTextCtrl::TextHeight(int line
) {
1684 return SendMsg(2279, line
, 0);
1687 // Show or hide the vertical scroll bar.
1688 void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show
) {
1689 SendMsg(2280, show
, 0);
1692 // Is the vertical scroll bar visible?
1693 bool wxStyledTextCtrl::GetUseVerticalScrollBar() {
1694 return SendMsg(2281, 0, 0) != 0;
1697 // Append a string to the end of the document without changing the selection.
1698 void wxStyledTextCtrl::AppendText(const wxString
& text
) {
1699 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1700 SendMsg(2282, strlen(buf
), (long)(const char*)buf
);
1703 // Is drawing done in two phases with backgrounds drawn before foregrounds?
1704 bool wxStyledTextCtrl::GetTwoPhaseDraw() {
1705 return SendMsg(2283, 0, 0) != 0;
1708 // In twoPhaseDraw mode, drawing is performed in two phases, first the background
1709 // and then the foreground. This avoids chopping off characters that overlap the next run.
1710 void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase
) {
1711 SendMsg(2284, twoPhase
, 0);
1714 // Make the target range start and end be the same as the selection range start and end.
1715 void wxStyledTextCtrl::TargetFromSelection() {
1716 SendMsg(2287, 0, 0);
1719 // Join the lines in the target.
1720 void wxStyledTextCtrl::LinesJoin() {
1721 SendMsg(2288, 0, 0);
1724 // Split the lines in the target into lines that are less wide than pixelWidth
1726 void wxStyledTextCtrl::LinesSplit(int pixelWidth
) {
1727 SendMsg(2289, pixelWidth
, 0);
1730 // Set the colours used as a chequerboard pattern in the fold margin
1731 void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting
, const wxColour
& back
) {
1732 SendMsg(2290, useSetting
, wxColourAsLong(back
));
1734 void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting
, const wxColour
& fore
) {
1735 SendMsg(2291, useSetting
, wxColourAsLong(fore
));
1738 // Move caret down one line.
1739 void wxStyledTextCtrl::LineDown() {
1740 SendMsg(2300, 0, 0);
1743 // Move caret down one line extending selection to new caret position.
1744 void wxStyledTextCtrl::LineDownExtend() {
1745 SendMsg(2301, 0, 0);
1748 // Move caret up one line.
1749 void wxStyledTextCtrl::LineUp() {
1750 SendMsg(2302, 0, 0);
1753 // Move caret up one line extending selection to new caret position.
1754 void wxStyledTextCtrl::LineUpExtend() {
1755 SendMsg(2303, 0, 0);
1758 // Move caret left one character.
1759 void wxStyledTextCtrl::CharLeft() {
1760 SendMsg(2304, 0, 0);
1763 // Move caret left one character extending selection to new caret position.
1764 void wxStyledTextCtrl::CharLeftExtend() {
1765 SendMsg(2305, 0, 0);
1768 // Move caret right one character.
1769 void wxStyledTextCtrl::CharRight() {
1770 SendMsg(2306, 0, 0);
1773 // Move caret right one character extending selection to new caret position.
1774 void wxStyledTextCtrl::CharRightExtend() {
1775 SendMsg(2307, 0, 0);
1778 // Move caret left one word.
1779 void wxStyledTextCtrl::WordLeft() {
1780 SendMsg(2308, 0, 0);
1783 // Move caret left one word extending selection to new caret position.
1784 void wxStyledTextCtrl::WordLeftExtend() {
1785 SendMsg(2309, 0, 0);
1788 // Move caret right one word.
1789 void wxStyledTextCtrl::WordRight() {
1790 SendMsg(2310, 0, 0);
1793 // Move caret right one word extending selection to new caret position.
1794 void wxStyledTextCtrl::WordRightExtend() {
1795 SendMsg(2311, 0, 0);
1798 // Move caret to first position on line.
1799 void wxStyledTextCtrl::Home() {
1800 SendMsg(2312, 0, 0);
1803 // Move caret to first position on line extending selection to new caret position.
1804 void wxStyledTextCtrl::HomeExtend() {
1805 SendMsg(2313, 0, 0);
1808 // Move caret to last position on line.
1809 void wxStyledTextCtrl::LineEnd() {
1810 SendMsg(2314, 0, 0);
1813 // Move caret to last position on line extending selection to new caret position.
1814 void wxStyledTextCtrl::LineEndExtend() {
1815 SendMsg(2315, 0, 0);
1818 // Move caret to first position in document.
1819 void wxStyledTextCtrl::DocumentStart() {
1820 SendMsg(2316, 0, 0);
1823 // Move caret to first position in document extending selection to new caret position.
1824 void wxStyledTextCtrl::DocumentStartExtend() {
1825 SendMsg(2317, 0, 0);
1828 // Move caret to last position in document.
1829 void wxStyledTextCtrl::DocumentEnd() {
1830 SendMsg(2318, 0, 0);
1833 // Move caret to last position in document extending selection to new caret position.
1834 void wxStyledTextCtrl::DocumentEndExtend() {
1835 SendMsg(2319, 0, 0);
1838 // Move caret one page up.
1839 void wxStyledTextCtrl::PageUp() {
1840 SendMsg(2320, 0, 0);
1843 // Move caret one page up extending selection to new caret position.
1844 void wxStyledTextCtrl::PageUpExtend() {
1845 SendMsg(2321, 0, 0);
1848 // Move caret one page down.
1849 void wxStyledTextCtrl::PageDown() {
1850 SendMsg(2322, 0, 0);
1853 // Move caret one page down extending selection to new caret position.
1854 void wxStyledTextCtrl::PageDownExtend() {
1855 SendMsg(2323, 0, 0);
1858 // Switch from insert to overtype mode or the reverse.
1859 void wxStyledTextCtrl::EditToggleOvertype() {
1860 SendMsg(2324, 0, 0);
1863 // Cancel any modes such as call tip or auto-completion list display.
1864 void wxStyledTextCtrl::Cancel() {
1865 SendMsg(2325, 0, 0);
1868 // Delete the selection or if no selection, the character before the caret.
1869 void wxStyledTextCtrl::DeleteBack() {
1870 SendMsg(2326, 0, 0);
1873 // If selection is empty or all on one line replace the selection with a tab character.
1874 // If more than one line selected, indent the lines.
1875 void wxStyledTextCtrl::Tab() {
1876 SendMsg(2327, 0, 0);
1879 // Dedent the selected lines.
1880 void wxStyledTextCtrl::BackTab() {
1881 SendMsg(2328, 0, 0);
1884 // Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
1885 void wxStyledTextCtrl::NewLine() {
1886 SendMsg(2329, 0, 0);
1889 // Insert a Form Feed character.
1890 void wxStyledTextCtrl::FormFeed() {
1891 SendMsg(2330, 0, 0);
1894 // Move caret to before first visible character on line.
1895 // If already there move to first character on line.
1896 void wxStyledTextCtrl::VCHome() {
1897 SendMsg(2331, 0, 0);
1900 // Like VCHome but extending selection to new caret position.
1901 void wxStyledTextCtrl::VCHomeExtend() {
1902 SendMsg(2332, 0, 0);
1905 // Magnify the displayed text by increasing the sizes by 1 point.
1906 void wxStyledTextCtrl::ZoomIn() {
1907 SendMsg(2333, 0, 0);
1910 // Make the displayed text smaller by decreasing the sizes by 1 point.
1911 void wxStyledTextCtrl::ZoomOut() {
1912 SendMsg(2334, 0, 0);
1915 // Delete the word to the left of the caret.
1916 void wxStyledTextCtrl::DelWordLeft() {
1917 SendMsg(2335, 0, 0);
1920 // Delete the word to the right of the caret.
1921 void wxStyledTextCtrl::DelWordRight() {
1922 SendMsg(2336, 0, 0);
1925 // Cut the line containing the caret.
1926 void wxStyledTextCtrl::LineCut() {
1927 SendMsg(2337, 0, 0);
1930 // Delete the line containing the caret.
1931 void wxStyledTextCtrl::LineDelete() {
1932 SendMsg(2338, 0, 0);
1935 // Switch the current line with the previous.
1936 void wxStyledTextCtrl::LineTranspose() {
1937 SendMsg(2339, 0, 0);
1940 // Duplicate the current line.
1941 void wxStyledTextCtrl::LineDuplicate() {
1942 SendMsg(2404, 0, 0);
1945 // Transform the selection to lower case.
1946 void wxStyledTextCtrl::LowerCase() {
1947 SendMsg(2340, 0, 0);
1950 // Transform the selection to upper case.
1951 void wxStyledTextCtrl::UpperCase() {
1952 SendMsg(2341, 0, 0);
1955 // Scroll the document down, keeping the caret visible.
1956 void wxStyledTextCtrl::LineScrollDown() {
1957 SendMsg(2342, 0, 0);
1960 // Scroll the document up, keeping the caret visible.
1961 void wxStyledTextCtrl::LineScrollUp() {
1962 SendMsg(2343, 0, 0);
1965 // Delete the selection or if no selection, the character before the caret.
1966 // Will not delete the character before at the start of a line.
1967 void wxStyledTextCtrl::DeleteBackNotLine() {
1968 SendMsg(2344, 0, 0);
1971 // Move caret to first position on display line.
1972 void wxStyledTextCtrl::HomeDisplay() {
1973 SendMsg(2345, 0, 0);
1976 // Move caret to first position on display line extending selection to
1977 // new caret position.
1978 void wxStyledTextCtrl::HomeDisplayExtend() {
1979 SendMsg(2346, 0, 0);
1982 // Move caret to last position on display line.
1983 void wxStyledTextCtrl::LineEndDisplay() {
1984 SendMsg(2347, 0, 0);
1987 // Move caret to last position on display line extending selection to new
1989 void wxStyledTextCtrl::LineEndDisplayExtend() {
1990 SendMsg(2348, 0, 0);
1993 // These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
1994 // except they behave differently when word-wrap is enabled:
1995 // They go first to the start / end of the display line, like (Home|LineEnd)Display
1996 // The difference is that, the cursor is already at the point, it goes on to the start
1997 // or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
1998 void wxStyledTextCtrl::HomeWrap() {
1999 SendMsg(2349, 0, 0);
2001 void wxStyledTextCtrl::HomeWrapExtend() {
2002 SendMsg(2450, 0, 0);
2004 void wxStyledTextCtrl::LineEndWrap() {
2005 SendMsg(2451, 0, 0);
2007 void wxStyledTextCtrl::LineEndWrapExtend() {
2008 SendMsg(2452, 0, 0);
2010 void wxStyledTextCtrl::VCHomeWrap() {
2011 SendMsg(2453, 0, 0);
2013 void wxStyledTextCtrl::VCHomeWrapExtend() {
2014 SendMsg(2454, 0, 0);
2017 // Copy the line containing the caret.
2018 void wxStyledTextCtrl::LineCopy() {
2019 SendMsg(2455, 0, 0);
2022 // Move the caret inside current view if it's not there already.
2023 void wxStyledTextCtrl::MoveCaretInsideView() {
2024 SendMsg(2401, 0, 0);
2027 // How many characters are on a line, not including end of line characters?
2028 int wxStyledTextCtrl::LineLength(int line
) {
2029 return SendMsg(2350, line
, 0);
2032 // Highlight the characters at two positions.
2033 void wxStyledTextCtrl::BraceHighlight(int pos1
, int pos2
) {
2034 SendMsg(2351, pos1
, pos2
);
2037 // Highlight the character at a position indicating there is no matching brace.
2038 void wxStyledTextCtrl::BraceBadLight(int pos
) {
2039 SendMsg(2352, pos
, 0);
2042 // Find the position of a matching brace or INVALID_POSITION if no match.
2043 int wxStyledTextCtrl::BraceMatch(int pos
) {
2044 return SendMsg(2353, pos
, 0);
2047 // Are the end of line characters visible?
2048 bool wxStyledTextCtrl::GetViewEOL() {
2049 return SendMsg(2355, 0, 0) != 0;
2052 // Make the end of line characters visible or invisible.
2053 void wxStyledTextCtrl::SetViewEOL(bool visible
) {
2054 SendMsg(2356, visible
, 0);
2057 // Retrieve a pointer to the document object.
2058 void* wxStyledTextCtrl::GetDocPointer() {
2059 return (void*)SendMsg(2357);
2062 // Change the document object used.
2063 void wxStyledTextCtrl::SetDocPointer(void* docPointer
) {
2064 SendMsg(2358, 0, (long)docPointer
);
2067 // Set which document modification events are sent to the container.
2068 void wxStyledTextCtrl::SetModEventMask(int mask
) {
2069 SendMsg(2359, mask
, 0);
2072 // Retrieve the column number which text should be kept within.
2073 int wxStyledTextCtrl::GetEdgeColumn() {
2074 return SendMsg(2360, 0, 0);
2077 // Set the column number of the edge.
2078 // If text goes past the edge then it is highlighted.
2079 void wxStyledTextCtrl::SetEdgeColumn(int column
) {
2080 SendMsg(2361, column
, 0);
2083 // Retrieve the edge highlight mode.
2084 int wxStyledTextCtrl::GetEdgeMode() {
2085 return SendMsg(2362, 0, 0);
2088 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
2089 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
2090 void wxStyledTextCtrl::SetEdgeMode(int mode
) {
2091 SendMsg(2363, mode
, 0);
2094 // Retrieve the colour used in edge indication.
2095 wxColour
wxStyledTextCtrl::GetEdgeColour() {
2096 long c
= SendMsg(2364, 0, 0);
2097 return wxColourFromLong(c
);
2100 // Change the colour used in edge indication.
2101 void wxStyledTextCtrl::SetEdgeColour(const wxColour
& edgeColour
) {
2102 SendMsg(2365, wxColourAsLong(edgeColour
), 0);
2105 // Sets the current caret position to be the search anchor.
2106 void wxStyledTextCtrl::SearchAnchor() {
2107 SendMsg(2366, 0, 0);
2110 // Find some text starting at the search anchor.
2111 // Does not ensure the selection is visible.
2112 int wxStyledTextCtrl::SearchNext(int flags
, const wxString
& text
) {
2113 return SendMsg(2367, flags
, (long)(const char*)wx2stc(text
));
2116 // Find some text starting at the search anchor and moving backwards.
2117 // Does not ensure the selection is visible.
2118 int wxStyledTextCtrl::SearchPrev(int flags
, const wxString
& text
) {
2119 return SendMsg(2368, flags
, (long)(const char*)wx2stc(text
));
2122 // Retrieves the number of lines completely visible.
2123 int wxStyledTextCtrl::LinesOnScreen() {
2124 return SendMsg(2370, 0, 0);
2127 // Set whether a pop up menu is displayed automatically when the user presses
2128 // the wrong mouse button.
2129 void wxStyledTextCtrl::UsePopUp(bool allowPopUp
) {
2130 SendMsg(2371, allowPopUp
, 0);
2133 // Is the selection rectangular? The alternative is the more common stream selection.
2134 bool wxStyledTextCtrl::SelectionIsRectangle() {
2135 return SendMsg(2372, 0, 0) != 0;
2138 // Set the zoom level. This number of points is added to the size of all fonts.
2139 // It may be positive to magnify or negative to reduce.
2140 void wxStyledTextCtrl::SetZoom(int zoom
) {
2141 SendMsg(2373, zoom
, 0);
2144 // Retrieve the zoom level.
2145 int wxStyledTextCtrl::GetZoom() {
2146 return SendMsg(2374, 0, 0);
2149 // Create a new document object.
2150 // Starts with reference count of 1 and not selected into editor.
2151 void* wxStyledTextCtrl::CreateDocument() {
2152 return (void*)SendMsg(2375);
2155 // Extend life of document.
2156 void wxStyledTextCtrl::AddRefDocument(void* docPointer
) {
2157 SendMsg(2376, 0, (long)docPointer
);
2160 // Release a reference to the document, deleting document if it fades to black.
2161 void wxStyledTextCtrl::ReleaseDocument(void* docPointer
) {
2162 SendMsg(2377, 0, (long)docPointer
);
2165 // Get which document modification events are sent to the container.
2166 int wxStyledTextCtrl::GetModEventMask() {
2167 return SendMsg(2378, 0, 0);
2170 // Change internal focus flag.
2171 void wxStyledTextCtrl::SetSTCFocus(bool focus
) {
2172 SendMsg(2380, focus
, 0);
2175 // Get internal focus flag.
2176 bool wxStyledTextCtrl::GetSTCFocus() {
2177 return SendMsg(2381, 0, 0) != 0;
2180 // Change error status - 0 = OK.
2181 void wxStyledTextCtrl::SetStatus(int statusCode
) {
2182 SendMsg(2382, statusCode
, 0);
2185 // Get error status.
2186 int wxStyledTextCtrl::GetStatus() {
2187 return SendMsg(2383, 0, 0);
2190 // Set whether the mouse is captured when its button is pressed.
2191 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures
) {
2192 SendMsg(2384, captures
, 0);
2195 // Get whether mouse gets captured.
2196 bool wxStyledTextCtrl::GetMouseDownCaptures() {
2197 return SendMsg(2385, 0, 0) != 0;
2200 // Sets the cursor to one of the SC_CURSOR* values.
2201 void wxStyledTextCtrl::SetSTCCursor(int cursorType
) {
2202 SendMsg(2386, cursorType
, 0);
2206 int wxStyledTextCtrl::GetSTCCursor() {
2207 return SendMsg(2387, 0, 0);
2210 // Change the way control characters are displayed:
2211 // If symbol is < 32, keep the drawn way, else, use the given character.
2212 void wxStyledTextCtrl::SetControlCharSymbol(int symbol
) {
2213 SendMsg(2388, symbol
, 0);
2216 // Get the way control characters are displayed.
2217 int wxStyledTextCtrl::GetControlCharSymbol() {
2218 return SendMsg(2389, 0, 0);
2221 // Move to the previous change in capitalisation.
2222 void wxStyledTextCtrl::WordPartLeft() {
2223 SendMsg(2390, 0, 0);
2226 // Move to the previous change in capitalisation extending selection
2227 // to new caret position.
2228 void wxStyledTextCtrl::WordPartLeftExtend() {
2229 SendMsg(2391, 0, 0);
2232 // Move to the change next in capitalisation.
2233 void wxStyledTextCtrl::WordPartRight() {
2234 SendMsg(2392, 0, 0);
2237 // Move to the next change in capitalisation extending selection
2238 // to new caret position.
2239 void wxStyledTextCtrl::WordPartRightExtend() {
2240 SendMsg(2393, 0, 0);
2243 // Set the way the display area is determined when a particular line
2244 // is to be moved to by Find, FindNext, GotoLine, etc.
2245 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy
, int visibleSlop
) {
2246 SendMsg(2394, visiblePolicy
, visibleSlop
);
2249 // Delete back from the current position to the start of the line.
2250 void wxStyledTextCtrl::DelLineLeft() {
2251 SendMsg(2395, 0, 0);
2254 // Delete forwards from the current position to the end of the line.
2255 void wxStyledTextCtrl::DelLineRight() {
2256 SendMsg(2396, 0, 0);
2259 // Get and Set the xOffset (ie, horizonal scroll position).
2260 void wxStyledTextCtrl::SetXOffset(int newOffset
) {
2261 SendMsg(2397, newOffset
, 0);
2263 int wxStyledTextCtrl::GetXOffset() {
2264 return SendMsg(2398, 0, 0);
2267 // Set the last x chosen value to be the caret x position.
2268 void wxStyledTextCtrl::ChooseCaretX() {
2269 SendMsg(2399, 0, 0);
2272 // Set the way the caret is kept visible when going sideway.
2273 // The exclusion zone is given in pixels.
2274 void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy
, int caretSlop
) {
2275 SendMsg(2402, caretPolicy
, caretSlop
);
2278 // Set the way the line the caret is on is kept visible.
2279 // The exclusion zone is given in lines.
2280 void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy
, int caretSlop
) {
2281 SendMsg(2403, caretPolicy
, caretSlop
);
2284 // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
2285 void wxStyledTextCtrl::SetPrintWrapMode(int mode
) {
2286 SendMsg(2406, mode
, 0);
2289 // Is printing line wrapped?
2290 int wxStyledTextCtrl::GetPrintWrapMode() {
2291 return SendMsg(2407, 0, 0);
2294 // Set a fore colour for active hotspots.
2295 void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting
, const wxColour
& fore
) {
2296 SendMsg(2410, useSetting
, wxColourAsLong(fore
));
2299 // Set a back colour for active hotspots.
2300 void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting
, const wxColour
& back
) {
2301 SendMsg(2411, useSetting
, wxColourAsLong(back
));
2304 // Enable / Disable underlining active hotspots.
2305 void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline
) {
2306 SendMsg(2412, underline
, 0);
2309 // Limit hotspots to single line so hotspots on two lines don't merge.
2310 void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine
) {
2311 SendMsg(2421, singleLine
, 0);
2314 // Move caret between paragraphs (delimited by empty lines).
2315 void wxStyledTextCtrl::ParaDown() {
2316 SendMsg(2413, 0, 0);
2318 void wxStyledTextCtrl::ParaDownExtend() {
2319 SendMsg(2414, 0, 0);
2321 void wxStyledTextCtrl::ParaUp() {
2322 SendMsg(2415, 0, 0);
2324 void wxStyledTextCtrl::ParaUpExtend() {
2325 SendMsg(2416, 0, 0);
2328 // Given a valid document position, return the previous position taking code
2329 // page into account. Returns 0 if passed 0.
2330 int wxStyledTextCtrl::PositionBefore(int pos
) {
2331 return SendMsg(2417, pos
, 0);
2334 // Given a valid document position, return the next position taking code
2335 // page into account. Maximum value returned is the last position in the document.
2336 int wxStyledTextCtrl::PositionAfter(int pos
) {
2337 return SendMsg(2418, pos
, 0);
2340 // Copy a range of text to the clipboard. Positions are clipped into the document.
2341 void wxStyledTextCtrl::CopyRange(int start
, int end
) {
2342 SendMsg(2419, start
, end
);
2345 // Copy argument text to the clipboard.
2346 void wxStyledTextCtrl::CopyText(int length
, const wxString
& text
) {
2347 SendMsg(2420, length
, (long)(const char*)wx2stc(text
));
2350 // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or
2351 // by lines (SC_SEL_LINES).
2352 void wxStyledTextCtrl::SetSelectionMode(int mode
) {
2353 SendMsg(2422, mode
, 0);
2356 // Get the mode of the current selection.
2357 int wxStyledTextCtrl::GetSelectionMode() {
2358 return SendMsg(2423, 0, 0);
2361 // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
2362 int wxStyledTextCtrl::GetLineSelStartPosition(int line
) {
2363 return SendMsg(2424, line
, 0);
2366 // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
2367 int wxStyledTextCtrl::GetLineSelEndPosition(int line
) {
2368 return SendMsg(2425, line
, 0);
2371 // Move caret down one line, extending rectangular selection to new caret position.
2372 void wxStyledTextCtrl::LineDownRectExtend() {
2373 SendMsg(2426, 0, 0);
2376 // Move caret up one line, extending rectangular selection to new caret position.
2377 void wxStyledTextCtrl::LineUpRectExtend() {
2378 SendMsg(2427, 0, 0);
2381 // Move caret left one character, extending rectangular selection to new caret position.
2382 void wxStyledTextCtrl::CharLeftRectExtend() {
2383 SendMsg(2428, 0, 0);
2386 // Move caret right one character, extending rectangular selection to new caret position.
2387 void wxStyledTextCtrl::CharRightRectExtend() {
2388 SendMsg(2429, 0, 0);
2391 // Move caret to first position on line, extending rectangular selection to new caret position.
2392 void wxStyledTextCtrl::HomeRectExtend() {
2393 SendMsg(2430, 0, 0);
2396 // Move caret to before first visible character on line.
2397 // If already there move to first character on line.
2398 // In either case, extend rectangular selection to new caret position.
2399 void wxStyledTextCtrl::VCHomeRectExtend() {
2400 SendMsg(2431, 0, 0);
2403 // Move caret to last position on line, extending rectangular selection to new caret position.
2404 void wxStyledTextCtrl::LineEndRectExtend() {
2405 SendMsg(2432, 0, 0);
2408 // Move caret one page up, extending rectangular selection to new caret position.
2409 void wxStyledTextCtrl::PageUpRectExtend() {
2410 SendMsg(2433, 0, 0);
2413 // Move caret one page down, extending rectangular selection to new caret position.
2414 void wxStyledTextCtrl::PageDownRectExtend() {
2415 SendMsg(2434, 0, 0);
2418 // Move caret to top of page, or one page up if already at top of page.
2419 void wxStyledTextCtrl::StutteredPageUp() {
2420 SendMsg(2435, 0, 0);
2423 // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
2424 void wxStyledTextCtrl::StutteredPageUpExtend() {
2425 SendMsg(2436, 0, 0);
2428 // Move caret to bottom of page, or one page down if already at bottom of page.
2429 void wxStyledTextCtrl::StutteredPageDown() {
2430 SendMsg(2437, 0, 0);
2433 // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
2434 void wxStyledTextCtrl::StutteredPageDownExtend() {
2435 SendMsg(2438, 0, 0);
2438 // Move caret left one word, position cursor at end of word.
2439 void wxStyledTextCtrl::WordLeftEnd() {
2440 SendMsg(2439, 0, 0);
2443 // Move caret left one word, position cursor at end of word, extending selection to new caret position.
2444 void wxStyledTextCtrl::WordLeftEndExtend() {
2445 SendMsg(2440, 0, 0);
2448 // Move caret right one word, position cursor at end of word.
2449 void wxStyledTextCtrl::WordRightEnd() {
2450 SendMsg(2441, 0, 0);
2453 // Move caret right one word, position cursor at end of word, extending selection to new caret position.
2454 void wxStyledTextCtrl::WordRightEndExtend() {
2455 SendMsg(2442, 0, 0);
2458 // Set the set of characters making up whitespace for when moving or selecting by word.
2459 // Should be called after SetWordChars.
2460 void wxStyledTextCtrl::SetWhitespaceChars(const wxString
& characters
) {
2461 SendMsg(2443, 0, (long)(const char*)wx2stc(characters
));
2464 // Reset the set of characters for whitespace and word characters to the defaults.
2465 void wxStyledTextCtrl::SetCharsDefault() {
2466 SendMsg(2444, 0, 0);
2469 // Get currently selected item position in the auto-completion list
2470 int wxStyledTextCtrl::AutoCompGetCurrent() {
2471 return SendMsg(2445, 0, 0);
2474 // Enlarge the document to a particular size of text bytes.
2475 void wxStyledTextCtrl::Allocate(int bytes
) {
2476 SendMsg(2446, bytes
, 0);
2479 // Find the position of a column on a line taking into account tabs and
2480 // multi-byte characters. If beyond end of line, return line end position.
2481 int wxStyledTextCtrl::FindColumn(int line
, int column
) {
2482 return SendMsg(2456, line
, column
);
2485 // Can the caret preferred x position only be changed by explicit movement commands?
2486 bool wxStyledTextCtrl::GetCaretSticky() {
2487 return SendMsg(2457, 0, 0) != 0;
2490 // Stop the caret preferred x position changing when the user types.
2491 void wxStyledTextCtrl::SetCaretSticky(bool useCaretStickyBehaviour
) {
2492 SendMsg(2458, useCaretStickyBehaviour
, 0);
2495 // Switch between sticky and non-sticky: meant to be bound to a key.
2496 void wxStyledTextCtrl::ToggleCaretSticky() {
2497 SendMsg(2459, 0, 0);
2500 // Enable/Disable convert-on-paste for line endings
2501 void wxStyledTextCtrl::SetPasteConvertEndings(bool convert
) {
2502 SendMsg(2467, convert
, 0);
2505 // Get convert-on-paste setting
2506 bool wxStyledTextCtrl::GetPasteConvertEndings() {
2507 return SendMsg(2468, 0, 0) != 0;
2510 // Duplicate the selection. If selection empty duplicate the line containing the caret.
2511 void wxStyledTextCtrl::SelectionDuplicate() {
2512 SendMsg(2469, 0, 0);
2515 // Set background alpha of the caret line.
2516 void wxStyledTextCtrl::SetCaretLineBackAlpha(int alpha
) {
2517 SendMsg(2470, alpha
, 0);
2520 // Get the background alpha of the caret line.
2521 int wxStyledTextCtrl::GetCaretLineBackAlpha() {
2522 return SendMsg(2471, 0, 0);
2525 // Start notifying the container of all key presses and commands.
2526 void wxStyledTextCtrl::StartRecord() {
2527 SendMsg(3001, 0, 0);
2530 // Stop notifying the container of all key presses and commands.
2531 void wxStyledTextCtrl::StopRecord() {
2532 SendMsg(3002, 0, 0);
2535 // Set the lexing language of the document.
2536 void wxStyledTextCtrl::SetLexer(int lexer
) {
2537 SendMsg(4001, lexer
, 0);
2540 // Retrieve the lexing language of the document.
2541 int wxStyledTextCtrl::GetLexer() {
2542 return SendMsg(4002, 0, 0);
2545 // Colourise a segment of the document using the current lexing language.
2546 void wxStyledTextCtrl::Colourise(int start
, int end
) {
2547 SendMsg(4003, start
, end
);
2550 // Set up a value that may be used by a lexer for some optional feature.
2551 void wxStyledTextCtrl::SetProperty(const wxString
& key
, const wxString
& value
) {
2552 SendMsg(4004, (long)(const char*)wx2stc(key
), (long)(const char*)wx2stc(value
));
2555 // Set up the key words used by the lexer.
2556 void wxStyledTextCtrl::SetKeyWords(int keywordSet
, const wxString
& keyWords
) {
2557 SendMsg(4005, keywordSet
, (long)(const char*)wx2stc(keyWords
));
2560 // Set the lexing language of the document based on string name.
2561 void wxStyledTextCtrl::SetLexerLanguage(const wxString
& language
) {
2562 SendMsg(4006, 0, (long)(const char*)wx2stc(language
));
2565 // Retrieve a 'property' value previously set with SetProperty.
2566 wxString
wxStyledTextCtrl::GetProperty(const wxString
& key
) {
2567 int len
= SendMsg(SCI_GETPROPERTY
, (long)(const char*)wx2stc(key
), 0);
2568 if (!len
) return wxEmptyString
;
2570 wxMemoryBuffer
mbuf(len
+1);
2571 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
2572 SendMsg(4008, (long)(const char*)wx2stc(key
), (long)buf
);
2573 mbuf
.UngetWriteBuf(len
);
2578 // Retrieve a 'property' value previously set with SetProperty,
2579 // with '$()' variable replacement on returned buffer.
2580 wxString
wxStyledTextCtrl::GetPropertyExpanded(const wxString
& key
) {
2581 int len
= SendMsg(SCI_GETPROPERTYEXPANDED
, (long)(const char*)wx2stc(key
), 0);
2582 if (!len
) return wxEmptyString
;
2584 wxMemoryBuffer
mbuf(len
+1);
2585 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
2586 SendMsg(4009, (long)(const char*)wx2stc(key
), (long)buf
);
2587 mbuf
.UngetWriteBuf(len
);
2592 // Retrieve a 'property' value previously set with SetProperty,
2593 // interpreted as an int AFTER any '$()' variable replacement.
2594 int wxStyledTextCtrl::GetPropertyInt(const wxString
& key
) {
2595 return SendMsg(4010, (long)(const char*)wx2stc(key
), 0);
2598 // Retrieve the number of bits the current lexer needs for styling.
2599 int wxStyledTextCtrl::GetStyleBitsNeeded() {
2600 return SendMsg(4011, 0, 0);
2603 // END of generated section
2604 //----------------------------------------------------------------------
2607 // Returns the line number of the line with the caret.
2608 int wxStyledTextCtrl::GetCurrentLine() {
2609 int line
= LineFromPosition(GetCurrentPos());
2614 // Extract style settings from a spec-string which is composed of one or
2615 // more of the following comma separated elements:
2617 // bold turns on bold
2618 // italic turns on italics
2619 // fore:[name or #RRGGBB] sets the foreground colour
2620 // back:[name or #RRGGBB] sets the background colour
2621 // face:[facename] sets the font face name to use
2622 // size:[num] sets the font size in points
2623 // eol turns on eol filling
2624 // underline turns on underlining
2626 void wxStyledTextCtrl::StyleSetSpec(int styleNum
, const wxString
& spec
) {
2628 wxStringTokenizer
tkz(spec
, wxT(","));
2629 while (tkz
.HasMoreTokens()) {
2630 wxString token
= tkz
.GetNextToken();
2632 wxString option
= token
.BeforeFirst(':');
2633 wxString val
= token
.AfterFirst(':');
2635 if (option
== wxT("bold"))
2636 StyleSetBold(styleNum
, true);
2638 else if (option
== wxT("italic"))
2639 StyleSetItalic(styleNum
, true);
2641 else if (option
== wxT("underline"))
2642 StyleSetUnderline(styleNum
, true);
2644 else if (option
== wxT("eol"))
2645 StyleSetEOLFilled(styleNum
, true);
2647 else if (option
== wxT("size")) {
2649 if (val
.ToLong(&points
))
2650 StyleSetSize(styleNum
, points
);
2653 else if (option
== wxT("face"))
2654 StyleSetFaceName(styleNum
, val
);
2656 else if (option
== wxT("fore"))
2657 StyleSetForeground(styleNum
, wxColourFromSpec(val
));
2659 else if (option
== wxT("back"))
2660 StyleSetBackground(styleNum
, wxColourFromSpec(val
));
2665 // Set style size, face, bold, italic, and underline attributes from
2666 // a wxFont's attributes.
2667 void wxStyledTextCtrl::StyleSetFont(int styleNum
, wxFont
& font
) {
2669 // Ensure that the native font is initialized
2671 GetTextExtent(wxT("X"), &x
, &y
, NULL
, NULL
, &font
);
2673 int size
= font
.GetPointSize();
2674 wxString faceName
= font
.GetFaceName();
2675 bool bold
= font
.GetWeight() == wxBOLD
;
2676 bool italic
= font
.GetStyle() != wxNORMAL
;
2677 bool under
= font
.GetUnderlined();
2678 wxFontEncoding encoding
= font
.GetEncoding();
2680 StyleSetFontAttr(styleNum
, size
, faceName
, bold
, italic
, under
, encoding
);
2683 // Set all font style attributes at once.
2684 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum
, int size
,
2685 const wxString
& faceName
,
2686 bool bold
, bool italic
,
2688 wxFontEncoding encoding
) {
2689 StyleSetSize(styleNum
, size
);
2690 StyleSetFaceName(styleNum
, faceName
);
2691 StyleSetBold(styleNum
, bold
);
2692 StyleSetItalic(styleNum
, italic
);
2693 StyleSetUnderline(styleNum
, underline
);
2694 StyleSetFontEncoding(styleNum
, encoding
);
2698 // Set the character set of the font in a style. Converts the Scintilla
2699 // character set values to a wxFontEncoding.
2700 void wxStyledTextCtrl::StyleSetCharacterSet(int style
, int characterSet
)
2702 wxFontEncoding encoding
;
2704 // Translate the Scintilla characterSet to a wxFontEncoding
2705 switch (characterSet
) {
2707 case wxSTC_CHARSET_ANSI
:
2708 case wxSTC_CHARSET_DEFAULT
:
2709 encoding
= wxFONTENCODING_DEFAULT
;
2712 case wxSTC_CHARSET_BALTIC
:
2713 encoding
= wxFONTENCODING_ISO8859_13
;
2716 case wxSTC_CHARSET_CHINESEBIG5
:
2717 encoding
= wxFONTENCODING_CP950
;
2720 case wxSTC_CHARSET_EASTEUROPE
:
2721 encoding
= wxFONTENCODING_ISO8859_2
;
2724 case wxSTC_CHARSET_GB2312
:
2725 encoding
= wxFONTENCODING_CP936
;
2728 case wxSTC_CHARSET_GREEK
:
2729 encoding
= wxFONTENCODING_ISO8859_7
;
2732 case wxSTC_CHARSET_HANGUL
:
2733 encoding
= wxFONTENCODING_CP949
;
2736 case wxSTC_CHARSET_MAC
:
2737 encoding
= wxFONTENCODING_DEFAULT
;
2740 case wxSTC_CHARSET_OEM
:
2741 encoding
= wxFONTENCODING_DEFAULT
;
2744 case wxSTC_CHARSET_RUSSIAN
:
2745 encoding
= wxFONTENCODING_KOI8
;
2748 case wxSTC_CHARSET_SHIFTJIS
:
2749 encoding
= wxFONTENCODING_CP932
;
2752 case wxSTC_CHARSET_SYMBOL
:
2753 encoding
= wxFONTENCODING_DEFAULT
;
2756 case wxSTC_CHARSET_TURKISH
:
2757 encoding
= wxFONTENCODING_ISO8859_9
;
2760 case wxSTC_CHARSET_JOHAB
:
2761 encoding
= wxFONTENCODING_DEFAULT
;
2764 case wxSTC_CHARSET_HEBREW
:
2765 encoding
= wxFONTENCODING_ISO8859_8
;
2768 case wxSTC_CHARSET_ARABIC
:
2769 encoding
= wxFONTENCODING_ISO8859_6
;
2772 case wxSTC_CHARSET_VIETNAMESE
:
2773 encoding
= wxFONTENCODING_DEFAULT
;
2776 case wxSTC_CHARSET_THAI
:
2777 encoding
= wxFONTENCODING_ISO8859_11
;
2780 case wxSTC_CHARSET_CYRILLIC
:
2781 encoding
= wxFONTENCODING_ISO8859_5
;
2784 case wxSTC_CHARSET_8859_15
:
2785 encoding
= wxFONTENCODING_ISO8859_15
;;
2789 // We just have Scintilla track the wxFontEncoding for us. It gets used
2790 // in Font::Create in PlatWX.cpp. We add one to the value so that the
2791 // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
2792 // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
2793 // to wxFONENCODING_DEFAULT in Font::Create.
2794 SendMsg(SCI_STYLESETCHARACTERSET
, style
, encoding
+1);
2798 // Set the font encoding to be used by a style.
2799 void wxStyledTextCtrl::StyleSetFontEncoding(int style
, wxFontEncoding encoding
)
2801 SendMsg(SCI_STYLESETCHARACTERSET
, style
, encoding
+1);
2805 // Perform one of the operations defined by the wxSTC_CMD_* constants.
2806 void wxStyledTextCtrl::CmdKeyExecute(int cmd
) {
2811 // Set the left and right margin in the edit area, measured in pixels.
2812 void wxStyledTextCtrl::SetMargins(int left
, int right
) {
2813 SetMarginLeft(left
);
2814 SetMarginRight(right
);
2818 // Retrieve the start and end positions of the current selection.
2819 void wxStyledTextCtrl::GetSelection(int* startPos
, int* endPos
) {
2820 if (startPos
!= NULL
)
2821 *startPos
= SendMsg(SCI_GETSELECTIONSTART
);
2823 *endPos
= SendMsg(SCI_GETSELECTIONEND
);
2827 // Retrieve the point in the window where a position is displayed.
2828 wxPoint
wxStyledTextCtrl::PointFromPosition(int pos
) {
2829 int x
= SendMsg(SCI_POINTXFROMPOSITION
, 0, pos
);
2830 int y
= SendMsg(SCI_POINTYFROMPOSITION
, 0, pos
);
2831 return wxPoint(x
, y
);
2834 // Scroll enough to make the given line visible
2835 void wxStyledTextCtrl::ScrollToLine(int line
) {
2836 m_swx
->DoScrollToLine(line
);
2840 // Scroll enough to make the given column visible
2841 void wxStyledTextCtrl::ScrollToColumn(int column
) {
2842 m_swx
->DoScrollToColumn(column
);
2846 bool wxStyledTextCtrl::SaveFile(const wxString
& filename
)
2848 wxFile
file(filename
, wxFile::write
);
2850 if (!file
.IsOpened())
2853 bool success
= file
.Write(GetText(), *wxConvCurrent
);
2861 bool wxStyledTextCtrl::LoadFile(const wxString
& filename
)
2863 bool success
= false;
2864 wxFile
file(filename
, wxFile::read
);
2866 if (file
.IsOpened())
2869 // get the file size (assume it is not huge file...)
2870 ssize_t len
= (ssize_t
)file
.Length();
2875 wxMemoryBuffer
buffer(len
+1);
2876 success
= (file
.Read(buffer
.GetData(), len
) == len
);
2878 ((char*)buffer
.GetData())[len
] = 0;
2879 contents
= wxString(buffer
, *wxConvCurrent
, len
);
2883 success
= (file
.Read(wxStringBuffer(buffer
, len
), len
) == len
);
2890 success
= true; // empty file is ok
2892 success
= false; // len == wxInvalidOffset
2907 #if wxUSE_DRAG_AND_DROP
2908 wxDragResult
wxStyledTextCtrl::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
2909 return m_swx
->DoDragOver(x
, y
, def
);
2913 bool wxStyledTextCtrl::DoDropText(long x
, long y
, const wxString
& data
) {
2914 return m_swx
->DoDropText(x
, y
, data
);
2919 void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA
) {
2920 m_swx
->SetUseAntiAliasing(useAA
);
2923 bool wxStyledTextCtrl::GetUseAntiAliasing() {
2924 return m_swx
->GetUseAntiAliasing();
2931 void wxStyledTextCtrl::AddTextRaw(const char* text
)
2933 SendMsg(SCI_ADDTEXT
, strlen(text
), (long)text
);
2936 void wxStyledTextCtrl::InsertTextRaw(int pos
, const char* text
)
2938 SendMsg(SCI_INSERTTEXT
, pos
, (long)text
);
2941 wxCharBuffer
wxStyledTextCtrl::GetCurLineRaw(int* linePos
)
2943 int len
= LineLength(GetCurrentLine());
2945 if (linePos
) *linePos
= 0;
2950 wxCharBuffer
buf(len
);
2951 int pos
= SendMsg(SCI_GETCURLINE
, len
, (long)buf
.data());
2952 if (linePos
) *linePos
= pos
;
2956 wxCharBuffer
wxStyledTextCtrl::GetLineRaw(int line
)
2958 int len
= LineLength(line
);
2964 wxCharBuffer
buf(len
);
2965 SendMsg(SCI_GETLINE
, line
, (long)buf
.data());
2969 wxCharBuffer
wxStyledTextCtrl::GetSelectedTextRaw()
2974 GetSelection(&start
, &end
);
2975 int len
= end
- start
;
2981 wxCharBuffer
buf(len
);
2982 SendMsg(SCI_GETSELTEXT
, 0, (long)buf
.data());
2986 wxCharBuffer
wxStyledTextCtrl::GetTextRangeRaw(int startPos
, int endPos
)
2988 if (endPos
< startPos
) {
2989 int temp
= startPos
;
2993 int len
= endPos
- startPos
;
2999 wxCharBuffer
buf(len
);
3001 tr
.lpstrText
= buf
.data();
3002 tr
.chrg
.cpMin
= startPos
;
3003 tr
.chrg
.cpMax
= endPos
;
3004 SendMsg(SCI_GETTEXTRANGE
, 0, (long)&tr
);
3008 void wxStyledTextCtrl::SetTextRaw(const char* text
)
3010 SendMsg(SCI_SETTEXT
, 0, (long)text
);
3013 wxCharBuffer
wxStyledTextCtrl::GetTextRaw()
3015 int len
= GetTextLength();
3016 wxCharBuffer
buf(len
);
3017 SendMsg(SCI_GETTEXT
, len
, (long)buf
.data());
3021 void wxStyledTextCtrl::AppendTextRaw(const char* text
)
3023 SendMsg(SCI_APPENDTEXT
, strlen(text
), (long)text
);
3030 //----------------------------------------------------------------------
3033 void wxStyledTextCtrl::OnPaint(wxPaintEvent
& WXUNUSED(evt
)) {
3035 m_swx
->DoPaint(&dc
, GetUpdateRegion().GetBox());
3038 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent
& evt
) {
3039 if (evt
.GetOrientation() == wxHORIZONTAL
)
3040 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
3042 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
3045 void wxStyledTextCtrl::OnScroll(wxScrollEvent
& evt
) {
3046 wxScrollBar
* sb
= wxDynamicCast(evt
.GetEventObject(), wxScrollBar
);
3048 if (sb
->IsVertical())
3049 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
3051 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
3055 void wxStyledTextCtrl::OnSize(wxSizeEvent
& WXUNUSED(evt
)) {
3057 wxSize sz
= GetClientSize();
3058 m_swx
->DoSize(sz
.x
, sz
.y
);
3062 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent
& evt
) {
3064 wxPoint pt
= evt
.GetPosition();
3065 m_swx
->DoLeftButtonDown(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
3066 evt
.ShiftDown(), evt
.ControlDown(), evt
.AltDown());
3069 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent
& evt
) {
3070 wxPoint pt
= evt
.GetPosition();
3071 m_swx
->DoLeftButtonMove(Point(pt
.x
, pt
.y
));
3074 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent
& evt
) {
3075 wxPoint pt
= evt
.GetPosition();
3076 m_swx
->DoLeftButtonUp(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
3081 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent
& evt
) {
3082 wxPoint pt
= evt
.GetPosition();
3083 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
3087 void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent
& evt
) {
3088 wxPoint pt
= evt
.GetPosition();
3089 m_swx
->DoMiddleButtonUp(Point(pt
.x
, pt
.y
));
3092 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent
& evt
) {
3093 wxPoint pt
= evt
.GetPosition();
3094 ScreenToClient(&pt
.x
, &pt
.y
);
3096 Show context menu at event point if it's within the window,
3097 or at caret location if not
3099 wxHitTest ht
= this->HitTest(pt
);
3100 if (ht
!= wxHT_WINDOW_INSIDE
) {
3101 pt
= this->PointFromPosition(this->GetCurrentPos());
3103 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
3107 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent
& evt
) {
3108 m_swx
->DoMouseWheel(evt
.GetWheelRotation(),
3109 evt
.GetWheelDelta(),
3110 evt
.GetLinesPerAction(),
3112 evt
.IsPageScroll());
3116 void wxStyledTextCtrl::OnChar(wxKeyEvent
& evt
) {
3117 // On (some?) non-US PC keyboards the AltGr key is required to enter some
3118 // common characters. It comes to us as both Alt and Ctrl down so we need
3119 // to let the char through in that case, otherwise if only ctrl or only
3120 // alt let's skip it.
3121 bool ctrl
= evt
.ControlDown();
3123 // On the Mac the Alt key is just a modifier key (like Shift) so we need
3124 // to allow the char events to be processed when Alt is pressed.
3125 // TODO: Should we check MetaDown instead in this case?
3128 bool alt
= evt
.AltDown();
3130 bool skip
= ((ctrl
|| alt
) && ! (ctrl
&& alt
));
3133 // apparently if we don't do this, Unicode keys pressed after non-char
3134 // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989)
3135 if (m_lastKeyDownConsumed
&& evt
.GetUnicodeKey() > 255)
3136 m_lastKeyDownConsumed
= false;
3139 if (!m_lastKeyDownConsumed
&& !skip
) {
3141 int key
= evt
.GetUnicodeKey();
3144 // if the unicode key code is not really a unicode character (it may
3145 // be a function key or etc., the platforms appear to always give us a
3146 // small value in this case) then fallback to the ascii key code but
3147 // don't do anything for function keys or etc.
3149 key
= evt
.GetKeyCode();
3150 keyOk
= (key
<= 127);
3153 m_swx
->DoAddChar(key
);
3157 int key
= evt
.GetKeyCode();
3158 if (key
<= WXK_START
|| key
> WXK_COMMAND
) {
3159 m_swx
->DoAddChar(key
);
3169 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent
& evt
) {
3170 int processed
= m_swx
->DoKeyDown(evt
, &m_lastKeyDownConsumed
);
3171 if (!processed
&& !m_lastKeyDownConsumed
)
3176 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent
& evt
) {
3177 m_swx
->DoLoseFocus();
3182 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent
& evt
) {
3183 m_swx
->DoGainFocus();
3188 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent
& WXUNUSED(evt
)) {
3189 m_swx
->DoSysColourChange();
3193 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent
& WXUNUSED(evt
)) {
3194 // do nothing to help avoid flashing
3199 void wxStyledTextCtrl::OnMenu(wxCommandEvent
& evt
) {
3200 m_swx
->DoCommand(evt
.GetId());
3204 void wxStyledTextCtrl::OnListBox(wxCommandEvent
& WXUNUSED(evt
)) {
3205 m_swx
->DoOnListBox();
3209 void wxStyledTextCtrl::OnIdle(wxIdleEvent
& evt
) {
3210 m_swx
->DoOnIdle(evt
);
3214 wxSize
wxStyledTextCtrl::DoGetBestSize() const
3216 // What would be the best size for a wxSTC?
3217 // Just give a reasonable minimum until something else can be figured out.
3218 return wxSize(200,100);
3222 //----------------------------------------------------------------------
3223 // Turn notifications from Scintilla into events
3226 void wxStyledTextCtrl::NotifyChange() {
3227 wxStyledTextEvent
evt(wxEVT_STC_CHANGE
, GetId());
3228 evt
.SetEventObject(this);
3229 GetEventHandler()->ProcessEvent(evt
);
3233 static void SetEventText(wxStyledTextEvent
& evt
, const char* text
,
3237 evt
.SetText(stc2wx(text
, length
));
3241 void wxStyledTextCtrl::NotifyParent(SCNotification
* _scn
) {
3242 SCNotification
& scn
= *_scn
;
3243 wxStyledTextEvent
evt(0, GetId());
3245 evt
.SetEventObject(this);
3246 evt
.SetPosition(scn
.position
);
3248 evt
.SetModifiers(scn
.modifiers
);
3250 switch (scn
.nmhdr
.code
) {
3251 case SCN_STYLENEEDED
:
3252 evt
.SetEventType(wxEVT_STC_STYLENEEDED
);
3256 evt
.SetEventType(wxEVT_STC_CHARADDED
);
3259 case SCN_SAVEPOINTREACHED
:
3260 evt
.SetEventType(wxEVT_STC_SAVEPOINTREACHED
);
3263 case SCN_SAVEPOINTLEFT
:
3264 evt
.SetEventType(wxEVT_STC_SAVEPOINTLEFT
);
3267 case SCN_MODIFYATTEMPTRO
:
3268 evt
.SetEventType(wxEVT_STC_ROMODIFYATTEMPT
);
3272 evt
.SetEventType(wxEVT_STC_KEY
);
3275 case SCN_DOUBLECLICK
:
3276 evt
.SetEventType(wxEVT_STC_DOUBLECLICK
);
3280 evt
.SetEventType(wxEVT_STC_UPDATEUI
);
3284 evt
.SetEventType(wxEVT_STC_MODIFIED
);
3285 evt
.SetModificationType(scn
.modificationType
);
3286 SetEventText(evt
, scn
.text
, scn
.length
);
3287 evt
.SetLength(scn
.length
);
3288 evt
.SetLinesAdded(scn
.linesAdded
);
3289 evt
.SetLine(scn
.line
);
3290 evt
.SetFoldLevelNow(scn
.foldLevelNow
);
3291 evt
.SetFoldLevelPrev(scn
.foldLevelPrev
);
3294 case SCN_MACRORECORD
:
3295 evt
.SetEventType(wxEVT_STC_MACRORECORD
);
3296 evt
.SetMessage(scn
.message
);
3297 evt
.SetWParam(scn
.wParam
);
3298 evt
.SetLParam(scn
.lParam
);
3301 case SCN_MARGINCLICK
:
3302 evt
.SetEventType(wxEVT_STC_MARGINCLICK
);
3303 evt
.SetMargin(scn
.margin
);
3307 evt
.SetEventType(wxEVT_STC_NEEDSHOWN
);
3308 evt
.SetLength(scn
.length
);
3312 evt
.SetEventType(wxEVT_STC_PAINTED
);
3315 case SCN_AUTOCSELECTION
:
3316 evt
.SetEventType(wxEVT_STC_AUTOCOMP_SELECTION
);
3317 evt
.SetListType(scn
.listType
);
3318 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
3319 evt
.SetPosition(scn
.lParam
);
3322 case SCN_USERLISTSELECTION
:
3323 evt
.SetEventType(wxEVT_STC_USERLISTSELECTION
);
3324 evt
.SetListType(scn
.listType
);
3325 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
3326 evt
.SetPosition(scn
.lParam
);
3329 case SCN_URIDROPPED
:
3330 evt
.SetEventType(wxEVT_STC_URIDROPPED
);
3331 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
3334 case SCN_DWELLSTART
:
3335 evt
.SetEventType(wxEVT_STC_DWELLSTART
);
3341 evt
.SetEventType(wxEVT_STC_DWELLEND
);
3347 evt
.SetEventType(wxEVT_STC_ZOOM
);
3350 case SCN_HOTSPOTCLICK
:
3351 evt
.SetEventType(wxEVT_STC_HOTSPOT_CLICK
);
3354 case SCN_HOTSPOTDOUBLECLICK
:
3355 evt
.SetEventType(wxEVT_STC_HOTSPOT_DCLICK
);
3358 case SCN_CALLTIPCLICK
:
3359 evt
.SetEventType(wxEVT_STC_CALLTIP_CLICK
);
3366 GetEventHandler()->ProcessEvent(evt
);
3370 //----------------------------------------------------------------------
3371 //----------------------------------------------------------------------
3372 //----------------------------------------------------------------------
3374 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType
, int id
)
3375 : wxCommandEvent(commandType
, id
)
3380 m_modificationType
= 0;
3385 m_foldLevelPrev
= 0;
3393 m_dragAllowMove
= false;
3394 #if wxUSE_DRAG_AND_DROP
3395 m_dragResult
= wxDragNone
;
3399 bool wxStyledTextEvent::GetShift() const { return (m_modifiers
& SCI_SHIFT
) != 0; }
3400 bool wxStyledTextEvent::GetControl() const { return (m_modifiers
& SCI_CTRL
) != 0; }
3401 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers
& SCI_ALT
) != 0; }
3404 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent
& event
):
3405 wxCommandEvent(event
)
3407 m_position
= event
.m_position
;
3408 m_key
= event
.m_key
;
3409 m_modifiers
= event
.m_modifiers
;
3410 m_modificationType
= event
.m_modificationType
;
3411 m_text
= event
.m_text
;
3412 m_length
= event
.m_length
;
3413 m_linesAdded
= event
.m_linesAdded
;
3414 m_line
= event
.m_line
;
3415 m_foldLevelNow
= event
.m_foldLevelNow
;
3416 m_foldLevelPrev
= event
.m_foldLevelPrev
;
3418 m_margin
= event
.m_margin
;
3420 m_message
= event
.m_message
;
3421 m_wParam
= event
.m_wParam
;
3422 m_lParam
= event
.m_lParam
;
3424 m_listType
= event
.m_listType
;
3428 m_dragText
= event
.m_dragText
;
3429 m_dragAllowMove
=event
.m_dragAllowMove
;
3430 #if wxUSE_DRAG_AND_DROP
3431 m_dragResult
= event
.m_dragResult
;
3435 //----------------------------------------------------------------------
3436 //----------------------------------------------------------------------