1 ////////////////////////////////////////////////////////////////////////////
2 // Name: src/stc/stc.cpp
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 licence
16 /////////////////////////////////////////////////////////////////////////////
19 IMPORTANT: src/stc/stc.cpp is generated by src/stc/gen_iface.py from
20 src/stc/stc.cpp.in, don't edit stc.cpp file as your changes will be
21 lost after the next regeneration, edit stc.cpp.in and rerun the
22 gen_iface.py script instead!
24 Parts of this file generated by the script are found in between
25 the special "{{{" and "}}}" markers, the rest of it is copied
26 verbatim from src.h.in.
29 // For compilers that support precompilation, includes "wx.h".
30 #include "wx/wxprec.h"
38 #include "wx/stc/stc.h"
39 #include "wx/stc/private.h"
47 #include "wx/tokenzr.h"
48 #include "wx/mstream.h"
52 #include "ScintillaWX.h"
54 //----------------------------------------------------------------------
56 const char wxSTCNameStr
[] = "stcwindow";
62 #define MAKELONG(a, b) ((a) | ((b) << 16))
65 static long wxColourAsLong(const wxColour
& co
) {
66 return (((long)co
.Blue() << 16) |
67 ((long)co
.Green() << 8) |
71 static wxColour
wxColourFromLong(long c
) {
73 clr
.Set((unsigned char)(c
& 0xff),
74 (unsigned char)((c
>> 8) & 0xff),
75 (unsigned char)((c
>> 16) & 0xff));
80 static wxColour
wxColourFromSpec(const wxString
& spec
) {
81 // spec should be a colour name or "#RRGGBB"
82 if (spec
.GetChar(0) == wxT('#')) {
84 long red
, green
, blue
;
85 red
= green
= blue
= 0;
86 spec
.Mid(1,2).ToLong(&red
, 16);
87 spec
.Mid(3,2).ToLong(&green
, 16);
88 spec
.Mid(5,2).ToLong(&blue
, 16);
89 return wxColour((unsigned char)red
,
94 return wxColour(spec
);
97 //----------------------------------------------------------------------
99 wxDEFINE_EVENT( wxEVT_STC_CHANGE
, wxStyledTextEvent
);
100 wxDEFINE_EVENT( wxEVT_STC_STYLENEEDED
, wxStyledTextEvent
);
101 wxDEFINE_EVENT( wxEVT_STC_CHARADDED
, wxStyledTextEvent
);
102 wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTREACHED
, wxStyledTextEvent
);
103 wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTLEFT
, wxStyledTextEvent
);
104 wxDEFINE_EVENT( wxEVT_STC_ROMODIFYATTEMPT
, wxStyledTextEvent
);
105 wxDEFINE_EVENT( wxEVT_STC_KEY
, wxStyledTextEvent
);
106 wxDEFINE_EVENT( wxEVT_STC_DOUBLECLICK
, wxStyledTextEvent
);
107 wxDEFINE_EVENT( wxEVT_STC_UPDATEUI
, wxStyledTextEvent
);
108 wxDEFINE_EVENT( wxEVT_STC_MODIFIED
, wxStyledTextEvent
);
109 wxDEFINE_EVENT( wxEVT_STC_MACRORECORD
, wxStyledTextEvent
);
110 wxDEFINE_EVENT( wxEVT_STC_MARGINCLICK
, wxStyledTextEvent
);
111 wxDEFINE_EVENT( wxEVT_STC_NEEDSHOWN
, wxStyledTextEvent
);
112 wxDEFINE_EVENT( wxEVT_STC_PAINTED
, wxStyledTextEvent
);
113 wxDEFINE_EVENT( wxEVT_STC_USERLISTSELECTION
, wxStyledTextEvent
);
114 wxDEFINE_EVENT( wxEVT_STC_URIDROPPED
, wxStyledTextEvent
);
115 wxDEFINE_EVENT( wxEVT_STC_DWELLSTART
, wxStyledTextEvent
);
116 wxDEFINE_EVENT( wxEVT_STC_DWELLEND
, wxStyledTextEvent
);
117 wxDEFINE_EVENT( wxEVT_STC_START_DRAG
, wxStyledTextEvent
);
118 wxDEFINE_EVENT( wxEVT_STC_DRAG_OVER
, wxStyledTextEvent
);
119 wxDEFINE_EVENT( wxEVT_STC_DO_DROP
, wxStyledTextEvent
);
120 wxDEFINE_EVENT( wxEVT_STC_ZOOM
, wxStyledTextEvent
);
121 wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_CLICK
, wxStyledTextEvent
);
122 wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_DCLICK
, wxStyledTextEvent
);
123 wxDEFINE_EVENT( wxEVT_STC_CALLTIP_CLICK
, wxStyledTextEvent
);
124 wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_SELECTION
, wxStyledTextEvent
);
125 wxDEFINE_EVENT( wxEVT_STC_INDICATOR_CLICK
, wxStyledTextEvent
);
126 wxDEFINE_EVENT( wxEVT_STC_INDICATOR_RELEASE
, wxStyledTextEvent
);
127 wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CANCELLED
, wxStyledTextEvent
);
128 wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CHAR_DELETED
, wxStyledTextEvent
);
132 BEGIN_EVENT_TABLE(wxStyledTextCtrl
, wxControl
)
133 EVT_PAINT (wxStyledTextCtrl::OnPaint
)
134 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin
)
135 EVT_SCROLL (wxStyledTextCtrl::OnScroll
)
136 EVT_SIZE (wxStyledTextCtrl::OnSize
)
137 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown
)
138 // Let Scintilla see the double click as a second click
139 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown
)
140 EVT_MOTION (wxStyledTextCtrl::OnMouseMove
)
141 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp
)
142 #if defined(__WXGTK__) || defined(__WXMAC__)
143 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp
)
145 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu
)
147 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel
)
148 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp
)
149 EVT_CHAR (wxStyledTextCtrl::OnChar
)
150 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown
)
151 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus
)
152 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus
)
153 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged
)
154 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground
)
155 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu
)
156 EVT_LISTBOX_DCLICK (wxID_ANY
, wxStyledTextCtrl::OnListBox
)
160 IMPLEMENT_CLASS(wxStyledTextCtrl
, wxControl
)
161 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent
, wxCommandEvent
)
164 // forces the linking of the lexer modules
165 int Scintilla_LinkLexers();
168 //----------------------------------------------------------------------
169 // Constructor and Destructor
171 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow
*parent
,
176 const wxString
& name
)
179 Create(parent
, id
, pos
, size
, style
, name
);
183 bool wxStyledTextCtrl::Create(wxWindow
*parent
,
188 const wxString
& name
)
190 style
|= wxVSCROLL
| wxHSCROLL
;
191 if (!wxControl::Create(parent
, id
, pos
, size
,
192 style
| wxWANTS_CHARS
| wxCLIP_CHILDREN
,
193 wxDefaultValidator
, name
))
197 Scintilla_LinkLexers();
199 m_swx
= new ScintillaWX(this);
201 m_lastKeyDownConsumed
= false;
202 m_lastWheelTimestamp
= 0;
206 // Put Scintilla into unicode (UTF-8) mode
207 SetCodePage(wxSTC_CP_UTF8
);
210 SetInitialSize(size
);
212 // Reduces flicker on GTK+/X11
213 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
215 // Make sure it can take the focus
222 wxStyledTextCtrl::~wxStyledTextCtrl() {
227 //----------------------------------------------------------------------
229 wxIntPtr
wxStyledTextCtrl::SendMsg(int msg
, wxUIntPtr wp
, wxIntPtr lp
) const
231 return m_swx
->WndProc(msg
, wp
, lp
);
234 //----------------------------------------------------------------------
236 // Set the vertical scrollbar to use instead of the ont that's built-in.
237 void wxStyledTextCtrl::SetVScrollBar(wxScrollBar
* bar
) {
240 // ensure that the built-in scrollbar is not visible
241 SetScrollbar(wxVERTICAL
, 0, 0, 0);
246 // Set the horizontal scrollbar to use instead of the ont that's built-in.
247 void wxStyledTextCtrl::SetHScrollBar(wxScrollBar
* bar
) {
250 // ensure that the built-in scrollbar is not visible
251 SetScrollbar(wxHORIZONTAL
, 0, 0, 0);
255 //----------------------------------------------------------------------
256 // Generated methods implementation section {{{
259 // Add text to the document at current position.
260 void wxStyledTextCtrl::AddText(const wxString
& text
) {
261 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
262 SendMsg(2001, strlen(buf
), (sptr_t
)(const char*)buf
);
265 // Add array of cells to document.
266 void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer
& data
) {
267 SendMsg(2002, data
.GetDataLen(), (sptr_t
)data
.GetData());
270 // Insert string at a position.
271 void wxStyledTextCtrl::InsertText(int pos
, const wxString
& text
)
273 SendMsg(2003, pos
, (sptr_t
)(const char*)wx2stc(text
));
276 // Delete all text in the document.
277 void wxStyledTextCtrl::ClearAll()
282 // Set all style bytes to 0, remove all folding information.
283 void wxStyledTextCtrl::ClearDocumentStyle()
288 // Returns the number of bytes in the document.
289 int wxStyledTextCtrl::GetLength() const
291 return SendMsg(2006, 0, 0);
294 // Returns the character byte at the position.
295 int wxStyledTextCtrl::GetCharAt(int pos
) const {
296 return (unsigned char)SendMsg(2007, pos
, 0);
299 // Returns the position of the caret.
300 int wxStyledTextCtrl::GetCurrentPos() const
302 return SendMsg(2008, 0, 0);
305 // Returns the position of the opposite end of the selection to the caret.
306 int wxStyledTextCtrl::GetAnchor() const
308 return SendMsg(2009, 0, 0);
311 // Returns the style byte at the position.
312 int wxStyledTextCtrl::GetStyleAt(int pos
) const {
313 return (unsigned char)SendMsg(2010, pos
, 0);
316 // Redoes the next action on the undo history.
317 void wxStyledTextCtrl::Redo()
322 // Choose between collecting actions into the undo
323 // history and discarding them.
324 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo
)
326 SendMsg(2012, collectUndo
, 0);
329 // Select all the text in the document.
330 void wxStyledTextCtrl::SelectAll()
335 // Remember the current position in the undo history as the position
336 // at which the document was saved.
337 void wxStyledTextCtrl::SetSavePoint()
342 // Retrieve a buffer of cells.
343 wxMemoryBuffer
wxStyledTextCtrl::GetStyledText(int startPos
, int endPos
) {
345 if (endPos
< startPos
) {
350 int len
= endPos
- startPos
;
351 if (!len
) return buf
;
353 tr
.lpstrText
= (char*)buf
.GetWriteBuf(len
*2+1);
354 tr
.chrg
.cpMin
= startPos
;
355 tr
.chrg
.cpMax
= endPos
;
356 len
= SendMsg(2015, 0, (sptr_t
)&tr
);
357 buf
.UngetWriteBuf(len
);
361 // Are there any redoable actions in the undo history?
362 bool wxStyledTextCtrl::CanRedo() const
364 return SendMsg(2016, 0, 0) != 0;
367 // Retrieve the line number at which a particular marker is located.
368 int wxStyledTextCtrl::MarkerLineFromHandle(int handle
)
370 return SendMsg(2017, handle
, 0);
374 void wxStyledTextCtrl::MarkerDeleteHandle(int handle
)
376 SendMsg(2018, handle
, 0);
379 // Is undo history being collected?
380 bool wxStyledTextCtrl::GetUndoCollection() const
382 return SendMsg(2019, 0, 0) != 0;
385 // Are white space characters currently visible?
386 // Returns one of SCWS_* constants.
387 int wxStyledTextCtrl::GetViewWhiteSpace() const
389 return SendMsg(2020, 0, 0);
392 // Make white space characters invisible, always visible or visible outside indentation.
393 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS
)
395 SendMsg(2021, viewWS
, 0);
398 // Find the position from a point within the window.
399 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt
) const {
400 return SendMsg(2022, pt
.x
, pt
.y
);
403 // Find the position from a point within the window but return
404 // INVALID_POSITION if not close to text.
405 int wxStyledTextCtrl::PositionFromPointClose(int x
, int y
)
407 return SendMsg(2023, x
, y
);
410 // Set caret to start of a line and ensure it is visible.
411 void wxStyledTextCtrl::GotoLine(int line
)
413 SendMsg(2024, line
, 0);
416 // Set caret to a position and ensure it is visible.
417 void wxStyledTextCtrl::GotoPos(int pos
)
419 SendMsg(2025, pos
, 0);
422 // Set the selection anchor to a position. The anchor is the opposite
423 // end of the selection from the caret.
424 void wxStyledTextCtrl::SetAnchor(int posAnchor
)
426 SendMsg(2026, posAnchor
, 0);
429 // Retrieve the text of the line containing the caret.
430 // Returns the index of the caret on the line.
431 wxString
wxStyledTextCtrl::GetCurLine(int* linePos
) {
432 int len
= LineLength(GetCurrentLine());
434 if (linePos
) *linePos
= 0;
435 return wxEmptyString
;
438 wxMemoryBuffer
mbuf(len
+1);
439 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
441 int pos
= SendMsg(2027, len
+1, (sptr_t
)buf
);
442 mbuf
.UngetWriteBuf(len
);
444 if (linePos
) *linePos
= pos
;
448 // Retrieve the position of the last correctly styled character.
449 int wxStyledTextCtrl::GetEndStyled() const
451 return SendMsg(2028, 0, 0);
454 // Convert all line endings in the document to one mode.
455 void wxStyledTextCtrl::ConvertEOLs(int eolMode
)
457 SendMsg(2029, eolMode
, 0);
460 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
461 int wxStyledTextCtrl::GetEOLMode() const
463 return SendMsg(2030, 0, 0);
466 // Set the current end of line mode.
467 void wxStyledTextCtrl::SetEOLMode(int eolMode
)
469 SendMsg(2031, eolMode
, 0);
472 // Set the current styling position to pos and the styling mask to mask.
473 // The styling mask can be used to protect some bits in each styling byte from modification.
474 void wxStyledTextCtrl::StartStyling(int pos
, int mask
)
476 SendMsg(2032, pos
, mask
);
479 // Change style from current styling position for length characters to a style
480 // and move the current styling position to after this newly styled segment.
481 void wxStyledTextCtrl::SetStyling(int length
, int style
)
483 SendMsg(2033, length
, style
);
486 // Is drawing done first into a buffer or direct to the screen?
487 bool wxStyledTextCtrl::GetBufferedDraw() const
489 return SendMsg(2034, 0, 0) != 0;
492 // If drawing is buffered then each line of text is drawn into a bitmap buffer
493 // before drawing it to the screen to avoid flicker.
494 void wxStyledTextCtrl::SetBufferedDraw(bool buffered
)
496 SendMsg(2035, buffered
, 0);
499 // Change the visible size of a tab to be a multiple of the width of a space character.
500 void wxStyledTextCtrl::SetTabWidth(int tabWidth
)
502 SendMsg(2036, tabWidth
, 0);
505 // Retrieve the visible size of a tab.
506 int wxStyledTextCtrl::GetTabWidth() const
508 return SendMsg(2121, 0, 0);
511 // Set the code page used to interpret the bytes of the document as characters.
512 void wxStyledTextCtrl::SetCodePage(int codePage
) {
514 wxASSERT_MSG(codePage
== wxSTC_CP_UTF8
,
515 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
517 wxASSERT_MSG(codePage
!= wxSTC_CP_UTF8
,
518 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
520 SendMsg(2037, codePage
);
523 // Set the symbol used for a particular marker number,
524 // and optionally the fore and background colours.
525 void wxStyledTextCtrl::MarkerDefine(int markerNumber
, int markerSymbol
,
526 const wxColour
& foreground
,
527 const wxColour
& background
) {
529 SendMsg(2040, markerNumber
, markerSymbol
);
530 if (foreground
.IsOk())
531 MarkerSetForeground(markerNumber
, foreground
);
532 if (background
.IsOk())
533 MarkerSetBackground(markerNumber
, background
);
536 // Set the foreground colour used for a particular marker number.
537 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber
, const wxColour
& fore
)
539 SendMsg(2041, markerNumber
, wxColourAsLong(fore
));
542 // Set the background colour used for a particular marker number.
543 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber
, const wxColour
& back
)
545 SendMsg(2042, markerNumber
, wxColourAsLong(back
));
548 // Add a marker to a line, returning an ID which can be used to find or delete the marker.
549 int wxStyledTextCtrl::MarkerAdd(int line
, int markerNumber
)
551 return SendMsg(2043, line
, markerNumber
);
554 // Delete a marker from a line.
555 void wxStyledTextCtrl::MarkerDelete(int line
, int markerNumber
)
557 SendMsg(2044, line
, markerNumber
);
560 // Delete all markers with a particular number from all lines.
561 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber
)
563 SendMsg(2045, markerNumber
, 0);
566 // Get a bit mask of all the markers set on a line.
567 int wxStyledTextCtrl::MarkerGet(int line
)
569 return SendMsg(2046, line
, 0);
572 // Find the next line after lineStart that includes a marker in mask.
573 int wxStyledTextCtrl::MarkerNext(int lineStart
, int markerMask
)
575 return SendMsg(2047, lineStart
, markerMask
);
578 // Find the previous line before lineStart that includes a marker in mask.
579 int wxStyledTextCtrl::MarkerPrevious(int lineStart
, int markerMask
)
581 return SendMsg(2048, lineStart
, markerMask
);
584 // Define a marker from a bitmap
585 void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber
, const wxBitmap
& bmp
) {
586 // convert bmp to a xpm in a string
587 wxMemoryOutputStream strm
;
588 wxImage img
= bmp
.ConvertToImage();
590 img
.ConvertAlphaToMask();
591 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
592 size_t len
= strm
.GetSize();
593 char* buff
= new char[len
+1];
594 strm
.CopyTo(buff
, len
);
596 SendMsg(2049, markerNumber
, (sptr_t
)buff
);
601 // Add a set of markers to a line.
602 void wxStyledTextCtrl::MarkerAddSet(int line
, int set
)
604 SendMsg(2466, line
, set
);
607 // Set the alpha used for a marker that is drawn in the text area, not the margin.
608 void wxStyledTextCtrl::MarkerSetAlpha(int markerNumber
, int alpha
)
610 SendMsg(2476, markerNumber
, alpha
);
613 // Set a margin to be either numeric or symbolic.
614 void wxStyledTextCtrl::SetMarginType(int margin
, int marginType
)
616 SendMsg(2240, margin
, marginType
);
619 // Retrieve the type of a margin.
620 int wxStyledTextCtrl::GetMarginType(int margin
) const
622 return SendMsg(2241, margin
, 0);
625 // Set the width of a margin to a width expressed in pixels.
626 void wxStyledTextCtrl::SetMarginWidth(int margin
, int pixelWidth
)
628 SendMsg(2242, margin
, pixelWidth
);
631 // Retrieve the width of a margin in pixels.
632 int wxStyledTextCtrl::GetMarginWidth(int margin
) const
634 return SendMsg(2243, margin
, 0);
637 // Set a mask that determines which markers are displayed in a margin.
638 void wxStyledTextCtrl::SetMarginMask(int margin
, int mask
)
640 SendMsg(2244, margin
, mask
);
643 // Retrieve the marker mask of a margin.
644 int wxStyledTextCtrl::GetMarginMask(int margin
) const
646 return SendMsg(2245, margin
, 0);
649 // Make a margin sensitive or insensitive to mouse clicks.
650 void wxStyledTextCtrl::SetMarginSensitive(int margin
, bool sensitive
)
652 SendMsg(2246, margin
, sensitive
);
655 // Retrieve the mouse click sensitivity of a margin.
656 bool wxStyledTextCtrl::GetMarginSensitive(int margin
) const
658 return SendMsg(2247, margin
, 0) != 0;
661 // Clear all the styles and make equivalent to the global default style.
662 void wxStyledTextCtrl::StyleClearAll()
667 // Set the foreground colour of a style.
668 void wxStyledTextCtrl::StyleSetForeground(int style
, const wxColour
& fore
)
670 SendMsg(2051, style
, wxColourAsLong(fore
));
673 // Set the background colour of a style.
674 void wxStyledTextCtrl::StyleSetBackground(int style
, const wxColour
& back
)
676 SendMsg(2052, style
, wxColourAsLong(back
));
679 // Set a style to be bold or not.
680 void wxStyledTextCtrl::StyleSetBold(int style
, bool bold
)
682 SendMsg(2053, style
, bold
);
685 // Set a style to be italic or not.
686 void wxStyledTextCtrl::StyleSetItalic(int style
, bool italic
)
688 SendMsg(2054, style
, italic
);
691 // Set the size of characters of a style.
692 void wxStyledTextCtrl::StyleSetSize(int style
, int sizePoints
)
694 SendMsg(2055, style
, sizePoints
);
697 // Set the font of a style.
698 void wxStyledTextCtrl::StyleSetFaceName(int style
, const wxString
& fontName
)
700 SendMsg(2056, style
, (sptr_t
)(const char*)wx2stc(fontName
));
703 // Set a style to have its end of line filled or not.
704 void wxStyledTextCtrl::StyleSetEOLFilled(int style
, bool filled
)
706 SendMsg(2057, style
, filled
);
709 // Reset the default style to its state at startup
710 void wxStyledTextCtrl::StyleResetDefault()
715 // Set a style to be underlined or not.
716 void wxStyledTextCtrl::StyleSetUnderline(int style
, bool underline
)
718 SendMsg(2059, style
, underline
);
721 // Get the foreground colour of a style.
722 wxColour
wxStyledTextCtrl::StyleGetForeground(int style
) const
724 long c
= SendMsg(2481, style
, 0);
725 return wxColourFromLong(c
);
728 // Get the background colour of a style.
729 wxColour
wxStyledTextCtrl::StyleGetBackground(int style
) const
731 long c
= SendMsg(2482, style
, 0);
732 return wxColourFromLong(c
);
735 // Get is a style bold or not.
736 bool wxStyledTextCtrl::StyleGetBold(int style
) const
738 return SendMsg(2483, style
, 0) != 0;
741 // Get is a style italic or not.
742 bool wxStyledTextCtrl::StyleGetItalic(int style
) const
744 return SendMsg(2484, style
, 0) != 0;
747 // Get the size of characters of a style.
748 int wxStyledTextCtrl::StyleGetSize(int style
) const
750 return SendMsg(2485, style
, 0);
753 // Get the font facename of a style
754 wxString
wxStyledTextCtrl::StyleGetFaceName(int style
) {
756 long len
= SendMsg(msg
, style
, 0);
757 wxMemoryBuffer
mbuf(len
+1);
758 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
759 SendMsg(msg
, style
, (sptr_t
)buf
);
760 mbuf
.UngetWriteBuf(len
);
765 // Get is a style to have its end of line filled or not.
766 bool wxStyledTextCtrl::StyleGetEOLFilled(int style
) const
768 return SendMsg(2487, style
, 0) != 0;
771 // Get is a style underlined or not.
772 bool wxStyledTextCtrl::StyleGetUnderline(int style
) const
774 return SendMsg(2488, style
, 0) != 0;
777 // Get is a style mixed case, or to force upper or lower case.
778 int wxStyledTextCtrl::StyleGetCase(int style
) const
780 return SendMsg(2489, style
, 0);
783 // Get the character set of the font in a style.
784 int wxStyledTextCtrl::StyleGetCharacterSet(int style
) const
786 return SendMsg(2490, style
, 0);
789 // Get is a style visible or not.
790 bool wxStyledTextCtrl::StyleGetVisible(int style
) const
792 return SendMsg(2491, style
, 0) != 0;
795 // Get is a style changeable or not (read only).
796 // Experimental feature, currently buggy.
797 bool wxStyledTextCtrl::StyleGetChangeable(int style
) const
799 return SendMsg(2492, style
, 0) != 0;
802 // Get is a style a hotspot or not.
803 bool wxStyledTextCtrl::StyleGetHotSpot(int style
) const
805 return SendMsg(2493, style
, 0) != 0;
808 // Set a style to be mixed case, or to force upper or lower case.
809 void wxStyledTextCtrl::StyleSetCase(int style
, int caseForce
)
811 SendMsg(2060, style
, caseForce
);
814 // Set a style to be a hotspot or not.
815 void wxStyledTextCtrl::StyleSetHotSpot(int style
, bool hotspot
)
817 SendMsg(2409, style
, hotspot
);
820 // Set the foreground colour of the main and additional selections and whether to use this setting.
821 void wxStyledTextCtrl::SetSelForeground(bool useSetting
, const wxColour
& fore
)
823 SendMsg(2067, useSetting
, wxColourAsLong(fore
));
826 // Set the background colour of the main and additional selections and whether to use this setting.
827 void wxStyledTextCtrl::SetSelBackground(bool useSetting
, const wxColour
& back
)
829 SendMsg(2068, useSetting
, wxColourAsLong(back
));
832 // Get the alpha of the selection.
833 int wxStyledTextCtrl::GetSelAlpha() const
835 return SendMsg(2477, 0, 0);
838 // Set the alpha of the selection.
839 void wxStyledTextCtrl::SetSelAlpha(int alpha
)
841 SendMsg(2478, alpha
, 0);
844 // Is the selection end of line filled?
845 bool wxStyledTextCtrl::GetSelEOLFilled() const
847 return SendMsg(2479, 0, 0) != 0;
850 // Set the selection to have its end of line filled or not.
851 void wxStyledTextCtrl::SetSelEOLFilled(bool filled
)
853 SendMsg(2480, filled
, 0);
856 // Set the foreground colour of the caret.
857 void wxStyledTextCtrl::SetCaretForeground(const wxColour
& fore
)
859 SendMsg(2069, wxColourAsLong(fore
), 0);
862 // When key+modifier combination km is pressed perform msg.
863 void wxStyledTextCtrl::CmdKeyAssign(int key
, int modifiers
, int cmd
) {
864 SendMsg(2070, MAKELONG(key
, modifiers
), cmd
);
867 // When key+modifier combination km is pressed do nothing.
868 void wxStyledTextCtrl::CmdKeyClear(int key
, int modifiers
) {
869 SendMsg(2071, MAKELONG(key
, modifiers
));
872 // Drop all key mappings.
873 void wxStyledTextCtrl::CmdKeyClearAll()
878 // Set the styles for a segment of the document.
879 void wxStyledTextCtrl::SetStyleBytes(int length
, char* styleBytes
) {
880 SendMsg(2073, length
, (sptr_t
)styleBytes
);
883 // Set a style to be visible or not.
884 void wxStyledTextCtrl::StyleSetVisible(int style
, bool visible
)
886 SendMsg(2074, style
, visible
);
889 // Get the time in milliseconds that the caret is on and off.
890 int wxStyledTextCtrl::GetCaretPeriod() const
892 return SendMsg(2075, 0, 0);
895 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
896 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds
)
898 SendMsg(2076, periodMilliseconds
, 0);
901 // Set the set of characters making up words for when moving or selecting by word.
902 // First sets defaults like SetCharsDefault.
903 void wxStyledTextCtrl::SetWordChars(const wxString
& characters
)
905 SendMsg(2077, 0, (sptr_t
)(const char*)wx2stc(characters
));
908 // Start a sequence of actions that is undone and redone as a unit.
910 void wxStyledTextCtrl::BeginUndoAction()
915 // End a sequence of actions that is undone and redone as a unit.
916 void wxStyledTextCtrl::EndUndoAction()
921 // Set an indicator to plain, squiggle or TT.
922 void wxStyledTextCtrl::IndicatorSetStyle(int indic
, int style
)
924 SendMsg(2080, indic
, style
);
927 // Retrieve the style of an indicator.
928 int wxStyledTextCtrl::IndicatorGetStyle(int indic
) const
930 return SendMsg(2081, indic
, 0);
933 // Set the foreground colour of an indicator.
934 void wxStyledTextCtrl::IndicatorSetForeground(int indic
, const wxColour
& fore
)
936 SendMsg(2082, indic
, wxColourAsLong(fore
));
939 // Retrieve the foreground colour of an indicator.
940 wxColour
wxStyledTextCtrl::IndicatorGetForeground(int indic
) const
942 long c
= SendMsg(2083, indic
, 0);
943 return wxColourFromLong(c
);
946 // Set an indicator to draw under text or over(default).
947 void wxStyledTextCtrl::IndicatorSetUnder(int indic
, bool under
)
949 SendMsg(2510, indic
, under
);
952 // Retrieve whether indicator drawn under or over text.
953 bool wxStyledTextCtrl::IndicatorGetUnder(int indic
) const
955 return SendMsg(2511, indic
, 0) != 0;
958 // Set the foreground colour of all whitespace and whether to use this setting.
959 void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting
, const wxColour
& fore
)
961 SendMsg(2084, useSetting
, wxColourAsLong(fore
));
964 // Set the background colour of all whitespace and whether to use this setting.
965 void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting
, const wxColour
& back
)
967 SendMsg(2085, useSetting
, wxColourAsLong(back
));
970 // Set the size of the dots used to mark space characters.
971 void wxStyledTextCtrl::SetWhitespaceSize(int size
)
973 SendMsg(2086, size
, 0);
976 // Get the size of the dots used to mark space characters.
977 int wxStyledTextCtrl::GetWhitespaceSize() const
979 return SendMsg(2087, 0, 0);
982 // Divide each styling byte into lexical class bits (default: 5) and indicator
983 // bits (default: 3). If a lexer requires more than 32 lexical states, then this
984 // is used to expand the possible states.
985 void wxStyledTextCtrl::SetStyleBits(int bits
)
987 SendMsg(2090, bits
, 0);
990 // Retrieve number of bits in style bytes used to hold the lexical state.
991 int wxStyledTextCtrl::GetStyleBits() const
993 return SendMsg(2091, 0, 0);
996 // Used to hold extra styling information for each line.
997 void wxStyledTextCtrl::SetLineState(int line
, int state
)
999 SendMsg(2092, line
, state
);
1002 // Retrieve the extra styling information for a line.
1003 int wxStyledTextCtrl::GetLineState(int line
) const
1005 return SendMsg(2093, line
, 0);
1008 // Retrieve the last line number that has line state.
1009 int wxStyledTextCtrl::GetMaxLineState() const
1011 return SendMsg(2094, 0, 0);
1014 // Is the background of the line containing the caret in a different colour?
1015 bool wxStyledTextCtrl::GetCaretLineVisible() const
1017 return SendMsg(2095, 0, 0) != 0;
1020 // Display the background of the line containing the caret in a different colour.
1021 void wxStyledTextCtrl::SetCaretLineVisible(bool show
)
1023 SendMsg(2096, show
, 0);
1026 // Get the colour of the background of the line containing the caret.
1027 wxColour
wxStyledTextCtrl::GetCaretLineBackground() const
1029 long c
= SendMsg(2097, 0, 0);
1030 return wxColourFromLong(c
);
1033 // Set the colour of the background of the line containing the caret.
1034 void wxStyledTextCtrl::SetCaretLineBackground(const wxColour
& back
)
1036 SendMsg(2098, wxColourAsLong(back
), 0);
1039 // Set a style to be changeable or not (read only).
1040 // Experimental feature, currently buggy.
1041 void wxStyledTextCtrl::StyleSetChangeable(int style
, bool changeable
)
1043 SendMsg(2099, style
, changeable
);
1046 // Display a auto-completion list.
1047 // The lenEntered parameter indicates how many characters before
1048 // the caret should be used to provide context.
1049 void wxStyledTextCtrl::AutoCompShow(int lenEntered
, const wxString
& itemList
)
1051 SendMsg(2100, lenEntered
, (sptr_t
)(const char*)wx2stc(itemList
));
1054 // Remove the auto-completion list from the screen.
1055 void wxStyledTextCtrl::AutoCompCancel()
1057 SendMsg(2101, 0, 0);
1060 // Is there an auto-completion list visible?
1061 bool wxStyledTextCtrl::AutoCompActive()
1063 return SendMsg(2102, 0, 0) != 0;
1066 // Retrieve the position of the caret when the auto-completion list was displayed.
1067 int wxStyledTextCtrl::AutoCompPosStart()
1069 return SendMsg(2103, 0, 0);
1072 // User has selected an item so remove the list and insert the selection.
1073 void wxStyledTextCtrl::AutoCompComplete()
1075 SendMsg(2104, 0, 0);
1078 // Define a set of character that when typed cancel the auto-completion list.
1079 void wxStyledTextCtrl::AutoCompStops(const wxString
& characterSet
)
1081 SendMsg(2105, 0, (sptr_t
)(const char*)wx2stc(characterSet
));
1084 // Change the separator character in the string setting up an auto-completion list.
1085 // Default is space but can be changed if items contain space.
1086 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter
)
1088 SendMsg(2106, separatorCharacter
, 0);
1091 // Retrieve the auto-completion list separator character.
1092 int wxStyledTextCtrl::AutoCompGetSeparator() const
1094 return SendMsg(2107, 0, 0);
1097 // Select the item in the auto-completion list that starts with a string.
1098 void wxStyledTextCtrl::AutoCompSelect(const wxString
& text
)
1100 SendMsg(2108, 0, (sptr_t
)(const char*)wx2stc(text
));
1103 // Should the auto-completion list be cancelled if the user backspaces to a
1104 // position before where the box was created.
1105 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel
)
1107 SendMsg(2110, cancel
, 0);
1110 // Retrieve whether auto-completion cancelled by backspacing before start.
1111 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() const
1113 return SendMsg(2111, 0, 0) != 0;
1116 // Define a set of characters that when typed will cause the autocompletion to
1117 // choose the selected item.
1118 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString
& characterSet
)
1120 SendMsg(2112, 0, (sptr_t
)(const char*)wx2stc(characterSet
));
1123 // Should a single item auto-completion list automatically choose the item.
1124 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle
)
1126 SendMsg(2113, chooseSingle
, 0);
1129 // Retrieve whether a single item auto-completion list automatically choose the item.
1130 bool wxStyledTextCtrl::AutoCompGetChooseSingle() const
1132 return SendMsg(2114, 0, 0) != 0;
1135 // Set whether case is significant when performing auto-completion searches.
1136 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase
)
1138 SendMsg(2115, ignoreCase
, 0);
1141 // Retrieve state of ignore case flag.
1142 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() const
1144 return SendMsg(2116, 0, 0) != 0;
1147 // Display a list of strings and send notification when user chooses one.
1148 void wxStyledTextCtrl::UserListShow(int listType
, const wxString
& itemList
)
1150 SendMsg(2117, listType
, (sptr_t
)(const char*)wx2stc(itemList
));
1153 // Set whether or not autocompletion is hidden automatically when nothing matches.
1154 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide
)
1156 SendMsg(2118, autoHide
, 0);
1159 // Retrieve whether or not autocompletion is hidden automatically when nothing matches.
1160 bool wxStyledTextCtrl::AutoCompGetAutoHide() const
1162 return SendMsg(2119, 0, 0) != 0;
1165 // Set whether or not autocompletion deletes any word characters
1166 // after the inserted text upon completion.
1167 void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord
)
1169 SendMsg(2270, dropRestOfWord
, 0);
1172 // Retrieve whether or not autocompletion deletes any word characters
1173 // after the inserted text upon completion.
1174 bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() const
1176 return SendMsg(2271, 0, 0) != 0;
1179 // Register an image for use in autocompletion lists.
1180 void wxStyledTextCtrl::RegisterImage(int type
, const wxBitmap
& bmp
) {
1181 // convert bmp to a xpm in a string
1182 wxMemoryOutputStream strm
;
1183 wxImage img
= bmp
.ConvertToImage();
1185 img
.ConvertAlphaToMask();
1186 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
1187 size_t len
= strm
.GetSize();
1188 char* buff
= new char[len
+1];
1189 strm
.CopyTo(buff
, len
);
1191 SendMsg(2405, type
, (sptr_t
)buff
);
1196 // Clear all the registered images.
1197 void wxStyledTextCtrl::ClearRegisteredImages()
1199 SendMsg(2408, 0, 0);
1202 // Retrieve the auto-completion list type-separator character.
1203 int wxStyledTextCtrl::AutoCompGetTypeSeparator() const
1205 return SendMsg(2285, 0, 0);
1208 // Change the type-separator character in the string setting up an auto-completion list.
1209 // Default is '?' but can be changed if items contain '?'.
1210 void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter
)
1212 SendMsg(2286, separatorCharacter
, 0);
1215 // Set the maximum width, in characters, of auto-completion and user lists.
1216 // Set to 0 to autosize to fit longest item, which is the default.
1217 void wxStyledTextCtrl::AutoCompSetMaxWidth(int characterCount
)
1219 SendMsg(2208, characterCount
, 0);
1222 // Get the maximum width, in characters, of auto-completion and user lists.
1223 int wxStyledTextCtrl::AutoCompGetMaxWidth() const
1225 return SendMsg(2209, 0, 0);
1228 // Set the maximum height, in rows, of auto-completion and user lists.
1229 // The default is 5 rows.
1230 void wxStyledTextCtrl::AutoCompSetMaxHeight(int rowCount
)
1232 SendMsg(2210, rowCount
, 0);
1235 // Set the maximum height, in rows, of auto-completion and user lists.
1236 int wxStyledTextCtrl::AutoCompGetMaxHeight() const
1238 return SendMsg(2211, 0, 0);
1241 // Set the number of spaces used for one level of indentation.
1242 void wxStyledTextCtrl::SetIndent(int indentSize
)
1244 SendMsg(2122, indentSize
, 0);
1247 // Retrieve indentation size.
1248 int wxStyledTextCtrl::GetIndent() const
1250 return SendMsg(2123, 0, 0);
1253 // Indentation will only use space characters if useTabs is false, otherwise
1254 // it will use a combination of tabs and spaces.
1255 void wxStyledTextCtrl::SetUseTabs(bool useTabs
)
1257 SendMsg(2124, useTabs
, 0);
1260 // Retrieve whether tabs will be used in indentation.
1261 bool wxStyledTextCtrl::GetUseTabs() const
1263 return SendMsg(2125, 0, 0) != 0;
1266 // Change the indentation of a line to a number of columns.
1267 void wxStyledTextCtrl::SetLineIndentation(int line
, int indentSize
)
1269 SendMsg(2126, line
, indentSize
);
1272 // Retrieve the number of columns that a line is indented.
1273 int wxStyledTextCtrl::GetLineIndentation(int line
) const
1275 return SendMsg(2127, line
, 0);
1278 // Retrieve the position before the first non indentation character on a line.
1279 int wxStyledTextCtrl::GetLineIndentPosition(int line
) const
1281 return SendMsg(2128, line
, 0);
1284 // Retrieve the column number of a position, taking tab width into account.
1285 int wxStyledTextCtrl::GetColumn(int pos
) const
1287 return SendMsg(2129, pos
, 0);
1290 // Show or hide the horizontal scroll bar.
1291 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show
)
1293 SendMsg(2130, show
, 0);
1296 // Is the horizontal scroll bar visible?
1297 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() const
1299 return SendMsg(2131, 0, 0) != 0;
1302 // Show or hide indentation guides.
1303 void wxStyledTextCtrl::SetIndentationGuides(int indentView
)
1305 SendMsg(2132, indentView
, 0);
1308 // Are the indentation guides visible?
1309 int wxStyledTextCtrl::GetIndentationGuides() const
1311 return SendMsg(2133, 0, 0);
1314 // Set the highlighted indentation guide column.
1315 // 0 = no highlighted guide.
1316 void wxStyledTextCtrl::SetHighlightGuide(int column
)
1318 SendMsg(2134, column
, 0);
1321 // Get the highlighted indentation guide column.
1322 int wxStyledTextCtrl::GetHighlightGuide() const
1324 return SendMsg(2135, 0, 0);
1327 // Get the position after the last visible characters on a line.
1328 int wxStyledTextCtrl::GetLineEndPosition(int line
) const
1330 return SendMsg(2136, line
, 0);
1333 // Get the code page used to interpret the bytes of the document as characters.
1334 int wxStyledTextCtrl::GetCodePage() const
1336 return SendMsg(2137, 0, 0);
1339 // Get the foreground colour of the caret.
1340 wxColour
wxStyledTextCtrl::GetCaretForeground() const
1342 long c
= SendMsg(2138, 0, 0);
1343 return wxColourFromLong(c
);
1346 // In read-only mode?
1347 bool wxStyledTextCtrl::GetReadOnly() const
1349 return SendMsg(2140, 0, 0) != 0;
1352 // Sets the position of the caret.
1353 void wxStyledTextCtrl::SetCurrentPos(int pos
)
1355 SendMsg(2141, pos
, 0);
1358 // Sets the position that starts the selection - this becomes the anchor.
1359 void wxStyledTextCtrl::SetSelectionStart(int pos
)
1361 SendMsg(2142, pos
, 0);
1364 // Returns the position at the start of the selection.
1365 int wxStyledTextCtrl::GetSelectionStart() const
1367 return SendMsg(2143, 0, 0);
1370 // Sets the position that ends the selection - this becomes the currentPosition.
1371 void wxStyledTextCtrl::SetSelectionEnd(int pos
)
1373 SendMsg(2144, pos
, 0);
1376 // Returns the position at the end of the selection.
1377 int wxStyledTextCtrl::GetSelectionEnd() const
1379 return SendMsg(2145, 0, 0);
1382 // Sets the print magnification added to the point size of each style for printing.
1383 void wxStyledTextCtrl::SetPrintMagnification(int magnification
)
1385 SendMsg(2146, magnification
, 0);
1388 // Returns the print magnification.
1389 int wxStyledTextCtrl::GetPrintMagnification() const
1391 return SendMsg(2147, 0, 0);
1394 // Modify colours when printing for clearer printed text.
1395 void wxStyledTextCtrl::SetPrintColourMode(int mode
)
1397 SendMsg(2148, mode
, 0);
1400 // Returns the print colour mode.
1401 int wxStyledTextCtrl::GetPrintColourMode() const
1403 return SendMsg(2149, 0, 0);
1406 // Find some text in the document.
1407 int wxStyledTextCtrl::FindText(int minPos
, int maxPos
,
1408 const wxString
& text
,
1411 ft
.chrg
.cpMin
= minPos
;
1412 ft
.chrg
.cpMax
= maxPos
;
1413 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1414 ft
.lpstrText
= (char*)(const char*)buf
;
1416 return SendMsg(2150, flags
, (sptr_t
)&ft
);
1419 // On Windows, will draw the document into a display context such as a printer.
1420 int wxStyledTextCtrl::FormatRange(bool doDraw
,
1429 if (endPos
< startPos
) {
1430 int temp
= startPos
;
1435 fr
.hdcTarget
= target
;
1436 fr
.rc
.top
= renderRect
.GetTop();
1437 fr
.rc
.left
= renderRect
.GetLeft();
1438 fr
.rc
.right
= renderRect
.GetRight();
1439 fr
.rc
.bottom
= renderRect
.GetBottom();
1440 fr
.rcPage
.top
= pageRect
.GetTop();
1441 fr
.rcPage
.left
= pageRect
.GetLeft();
1442 fr
.rcPage
.right
= pageRect
.GetRight();
1443 fr
.rcPage
.bottom
= pageRect
.GetBottom();
1444 fr
.chrg
.cpMin
= startPos
;
1445 fr
.chrg
.cpMax
= endPos
;
1447 return SendMsg(2151, doDraw
, (sptr_t
)&fr
);
1450 // Retrieve the display line at the top of the display.
1451 int wxStyledTextCtrl::GetFirstVisibleLine() const
1453 return SendMsg(2152, 0, 0);
1456 // Retrieve the contents of a line.
1457 wxString
wxStyledTextCtrl::GetLine(int line
) const {
1458 int len
= LineLength(line
);
1459 if (!len
) return wxEmptyString
;
1461 wxMemoryBuffer
mbuf(len
+1);
1462 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1463 SendMsg(2153, line
, (sptr_t
)buf
);
1464 mbuf
.UngetWriteBuf(len
);
1469 // Returns the number of lines in the document. There is always at least one.
1470 int wxStyledTextCtrl::GetLineCount() const
1472 return SendMsg(2154, 0, 0);
1475 // Sets the size in pixels of the left margin.
1476 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth
)
1478 SendMsg(2155, 0, pixelWidth
);
1481 // Returns the size in pixels of the left margin.
1482 int wxStyledTextCtrl::GetMarginLeft() const
1484 return SendMsg(2156, 0, 0);
1487 // Sets the size in pixels of the right margin.
1488 void wxStyledTextCtrl::SetMarginRight(int pixelWidth
)
1490 SendMsg(2157, 0, pixelWidth
);
1493 // Returns the size in pixels of the right margin.
1494 int wxStyledTextCtrl::GetMarginRight() const
1496 return SendMsg(2158, 0, 0);
1499 // Is the document different from when it was last saved?
1500 bool wxStyledTextCtrl::GetModify() const
1502 return SendMsg(2159, 0, 0) != 0;
1505 // Retrieve the selected text.
1506 wxString
wxStyledTextCtrl::GetSelectedText() {
1510 GetSelection(&start
, &end
);
1511 int len
= end
- start
;
1512 if (!len
) return wxEmptyString
;
1514 wxMemoryBuffer
mbuf(len
+2);
1515 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1516 SendMsg(2161, 0, (sptr_t
)buf
);
1517 mbuf
.UngetWriteBuf(len
);
1522 // Retrieve a range of text.
1523 wxString
wxStyledTextCtrl::GetTextRange(int startPos
, int endPos
) {
1524 if (endPos
< startPos
) {
1525 int temp
= startPos
;
1529 int len
= endPos
- startPos
;
1530 if (!len
) return wxEmptyString
;
1531 wxMemoryBuffer
mbuf(len
+1);
1532 char* buf
= (char*)mbuf
.GetWriteBuf(len
);
1535 tr
.chrg
.cpMin
= startPos
;
1536 tr
.chrg
.cpMax
= endPos
;
1537 SendMsg(2162, 0, (sptr_t
)&tr
);
1538 mbuf
.UngetWriteBuf(len
);
1543 // Draw the selection in normal style or with selection highlighted.
1544 void wxStyledTextCtrl::HideSelection(bool normal
)
1546 SendMsg(2163, normal
, 0);
1549 // Retrieve the line containing a position.
1550 int wxStyledTextCtrl::LineFromPosition(int pos
) const
1552 return SendMsg(2166, pos
, 0);
1555 // Retrieve the position at the start of a line.
1556 int wxStyledTextCtrl::PositionFromLine(int line
) const
1558 return SendMsg(2167, line
, 0);
1561 // Scroll horizontally and vertically.
1562 void wxStyledTextCtrl::LineScroll(int columns
, int lines
)
1564 SendMsg(2168, columns
, lines
);
1567 // Ensure the caret is visible.
1568 void wxStyledTextCtrl::EnsureCaretVisible()
1570 SendMsg(2169, 0, 0);
1573 // Replace the selected text with the argument text.
1574 void wxStyledTextCtrl::ReplaceSelection(const wxString
& text
)
1576 SendMsg(2170, 0, (sptr_t
)(const char*)wx2stc(text
));
1579 // Set to read only or read write.
1580 void wxStyledTextCtrl::SetReadOnly(bool readOnly
)
1582 SendMsg(2171, readOnly
, 0);
1585 // Will a paste succeed?
1586 bool wxStyledTextCtrl::CanPaste() const
1588 return SendMsg(2173, 0, 0) != 0;
1591 // Are there any undoable actions in the undo history?
1592 bool wxStyledTextCtrl::CanUndo() const
1594 return SendMsg(2174, 0, 0) != 0;
1597 // Delete the undo history.
1598 void wxStyledTextCtrl::EmptyUndoBuffer()
1600 SendMsg(2175, 0, 0);
1603 // Undo one action in the undo history.
1604 void wxStyledTextCtrl::Undo()
1606 SendMsg(2176, 0, 0);
1609 // Cut the selection to the clipboard.
1610 void wxStyledTextCtrl::Cut()
1612 SendMsg(2177, 0, 0);
1615 // Copy the selection to the clipboard.
1616 void wxStyledTextCtrl::Copy()
1618 SendMsg(2178, 0, 0);
1621 // Paste the contents of the clipboard into the document replacing the selection.
1622 void wxStyledTextCtrl::Paste()
1624 SendMsg(2179, 0, 0);
1627 // Clear the selection.
1628 void wxStyledTextCtrl::Clear()
1630 SendMsg(2180, 0, 0);
1633 // Replace the contents of the document with the argument text.
1634 void wxStyledTextCtrl::SetText(const wxString
& text
)
1636 SendMsg(2181, 0, (sptr_t
)(const char*)wx2stc(text
));
1639 // Retrieve all the text in the document.
1640 wxString
wxStyledTextCtrl::GetText() const {
1641 int len
= GetTextLength();
1642 wxMemoryBuffer
mbuf(len
+1); // leave room for the null...
1643 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1644 SendMsg(2182, len
+1, (sptr_t
)buf
);
1645 mbuf
.UngetWriteBuf(len
);
1650 // Retrieve the number of characters in the document.
1651 int wxStyledTextCtrl::GetTextLength() const
1653 return SendMsg(2183, 0, 0);
1656 // Set to overtype (true) or insert mode.
1657 void wxStyledTextCtrl::SetOvertype(bool overtype
)
1659 SendMsg(2186, overtype
, 0);
1662 // Returns true if overtype mode is active otherwise false is returned.
1663 bool wxStyledTextCtrl::GetOvertype() const
1665 return SendMsg(2187, 0, 0) != 0;
1668 // Set the width of the insert mode caret.
1669 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth
)
1671 SendMsg(2188, pixelWidth
, 0);
1674 // Returns the width of the insert mode caret.
1675 int wxStyledTextCtrl::GetCaretWidth() const
1677 return SendMsg(2189, 0, 0);
1680 // Sets the position that starts the target which is used for updating the
1681 // document without affecting the scroll position.
1682 void wxStyledTextCtrl::SetTargetStart(int pos
)
1684 SendMsg(2190, pos
, 0);
1687 // Get the position that starts the target.
1688 int wxStyledTextCtrl::GetTargetStart() const
1690 return SendMsg(2191, 0, 0);
1693 // Sets the position that ends the target which is used for updating the
1694 // document without affecting the scroll position.
1695 void wxStyledTextCtrl::SetTargetEnd(int pos
)
1697 SendMsg(2192, pos
, 0);
1700 // Get the position that ends the target.
1701 int wxStyledTextCtrl::GetTargetEnd() const
1703 return SendMsg(2193, 0, 0);
1706 // Replace the target text with the argument text.
1707 // Text is counted so it can contain NULs.
1708 // Returns the length of the replacement text.
1710 int wxStyledTextCtrl::ReplaceTarget(const wxString
& text
) {
1711 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1712 return SendMsg(2194, strlen(buf
), (sptr_t
)(const char*)buf
);
1715 // Replace the target text with the argument text after \d processing.
1716 // Text is counted so it can contain NULs.
1717 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1718 // matched in the last search operation which were surrounded by \( and \).
1719 // Returns the length of the replacement text including any change
1720 // caused by processing the \d patterns.
1722 int wxStyledTextCtrl::ReplaceTargetRE(const wxString
& text
) {
1723 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1724 return SendMsg(2195, strlen(buf
), (sptr_t
)(const char*)buf
);
1727 // Search for a counted string in the target and set the target to the found
1728 // range. Text is counted so it can contain NULs.
1729 // Returns length of range or -1 for failure in which case target is not moved.
1731 int wxStyledTextCtrl::SearchInTarget(const wxString
& text
) {
1732 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1733 return SendMsg(2197, strlen(buf
), (sptr_t
)(const char*)buf
);
1736 // Set the search flags used by SearchInTarget.
1737 void wxStyledTextCtrl::SetSearchFlags(int flags
)
1739 SendMsg(2198, flags
, 0);
1742 // Get the search flags used by SearchInTarget.
1743 int wxStyledTextCtrl::GetSearchFlags() const
1745 return SendMsg(2199, 0, 0);
1748 // Show a call tip containing a definition near position pos.
1749 void wxStyledTextCtrl::CallTipShow(int pos
, const wxString
& definition
)
1751 SendMsg(2200, pos
, (sptr_t
)(const char*)wx2stc(definition
));
1754 // Remove the call tip from the screen.
1755 void wxStyledTextCtrl::CallTipCancel()
1757 SendMsg(2201, 0, 0);
1760 // Is there an active call tip?
1761 bool wxStyledTextCtrl::CallTipActive()
1763 return SendMsg(2202, 0, 0) != 0;
1766 // Retrieve the position where the caret was before displaying the call tip.
1767 int wxStyledTextCtrl::CallTipPosAtStart()
1769 return SendMsg(2203, 0, 0);
1772 // Highlight a segment of the definition.
1773 void wxStyledTextCtrl::CallTipSetHighlight(int start
, int end
)
1775 SendMsg(2204, start
, end
);
1778 // Set the background colour for the call tip.
1779 void wxStyledTextCtrl::CallTipSetBackground(const wxColour
& back
)
1781 SendMsg(2205, wxColourAsLong(back
), 0);
1784 // Set the foreground colour for the call tip.
1785 void wxStyledTextCtrl::CallTipSetForeground(const wxColour
& fore
)
1787 SendMsg(2206, wxColourAsLong(fore
), 0);
1790 // Set the foreground colour for the highlighted part of the call tip.
1791 void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour
& fore
)
1793 SendMsg(2207, wxColourAsLong(fore
), 0);
1796 // Enable use of STYLE_CALLTIP and set call tip tab size in pixels.
1797 void wxStyledTextCtrl::CallTipUseStyle(int tabSize
)
1799 SendMsg(2212, tabSize
, 0);
1802 // Find the display line of a document line taking hidden lines into account.
1803 int wxStyledTextCtrl::VisibleFromDocLine(int line
)
1805 return SendMsg(2220, line
, 0);
1808 // Find the document line of a display line taking hidden lines into account.
1809 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay
)
1811 return SendMsg(2221, lineDisplay
, 0);
1814 // The number of display lines needed to wrap a document line
1815 int wxStyledTextCtrl::WrapCount(int line
)
1817 return SendMsg(2235, line
, 0);
1820 // Set the fold level of a line.
1821 // This encodes an integer level along with flags indicating whether the
1822 // line is a header and whether it is effectively white space.
1823 void wxStyledTextCtrl::SetFoldLevel(int line
, int level
)
1825 SendMsg(2222, line
, level
);
1828 // Retrieve the fold level of a line.
1829 int wxStyledTextCtrl::GetFoldLevel(int line
) const
1831 return SendMsg(2223, line
, 0);
1834 // Find the last child line of a header line.
1835 int wxStyledTextCtrl::GetLastChild(int line
, int level
) const
1837 return SendMsg(2224, line
, level
);
1840 // Find the parent line of a child line.
1841 int wxStyledTextCtrl::GetFoldParent(int line
) const
1843 return SendMsg(2225, line
, 0);
1846 // Make a range of lines visible.
1847 void wxStyledTextCtrl::ShowLines(int lineStart
, int lineEnd
)
1849 SendMsg(2226, lineStart
, lineEnd
);
1852 // Make a range of lines invisible.
1853 void wxStyledTextCtrl::HideLines(int lineStart
, int lineEnd
)
1855 SendMsg(2227, lineStart
, lineEnd
);
1858 // Is a line visible?
1859 bool wxStyledTextCtrl::GetLineVisible(int line
) const
1861 return SendMsg(2228, line
, 0) != 0;
1864 // Show the children of a header line.
1865 void wxStyledTextCtrl::SetFoldExpanded(int line
, bool expanded
)
1867 SendMsg(2229, line
, expanded
);
1870 // Is a header line expanded?
1871 bool wxStyledTextCtrl::GetFoldExpanded(int line
) const
1873 return SendMsg(2230, line
, 0) != 0;
1876 // Switch a header line between expanded and contracted.
1877 void wxStyledTextCtrl::ToggleFold(int line
)
1879 SendMsg(2231, line
, 0);
1882 // Ensure a particular line is visible by expanding any header line hiding it.
1883 void wxStyledTextCtrl::EnsureVisible(int line
)
1885 SendMsg(2232, line
, 0);
1888 // Set some style options for folding.
1889 void wxStyledTextCtrl::SetFoldFlags(int flags
)
1891 SendMsg(2233, flags
, 0);
1894 // Ensure a particular line is visible by expanding any header line hiding it.
1895 // Use the currently set visibility policy to determine which range to display.
1896 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line
)
1898 SendMsg(2234, line
, 0);
1901 // Sets whether a tab pressed when caret is within indentation indents.
1902 void wxStyledTextCtrl::SetTabIndents(bool tabIndents
)
1904 SendMsg(2260, tabIndents
, 0);
1907 // Does a tab pressed when caret is within indentation indent?
1908 bool wxStyledTextCtrl::GetTabIndents() const
1910 return SendMsg(2261, 0, 0) != 0;
1913 // Sets whether a backspace pressed when caret is within indentation unindents.
1914 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents
)
1916 SendMsg(2262, bsUnIndents
, 0);
1919 // Does a backspace pressed when caret is within indentation unindent?
1920 bool wxStyledTextCtrl::GetBackSpaceUnIndents() const
1922 return SendMsg(2263, 0, 0) != 0;
1925 // Sets the time the mouse must sit still to generate a mouse dwell event.
1926 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds
)
1928 SendMsg(2264, periodMilliseconds
, 0);
1931 // Retrieve the time the mouse must sit still to generate a mouse dwell event.
1932 int wxStyledTextCtrl::GetMouseDwellTime() const
1934 return SendMsg(2265, 0, 0);
1937 // Get position of start of word.
1938 int wxStyledTextCtrl::WordStartPosition(int pos
, bool onlyWordCharacters
)
1940 return SendMsg(2266, pos
, onlyWordCharacters
);
1943 // Get position of end of word.
1944 int wxStyledTextCtrl::WordEndPosition(int pos
, bool onlyWordCharacters
)
1946 return SendMsg(2267, pos
, onlyWordCharacters
);
1949 // Sets whether text is word wrapped.
1950 void wxStyledTextCtrl::SetWrapMode(int mode
)
1952 SendMsg(2268, mode
, 0);
1955 // Retrieve whether text is word wrapped.
1956 int wxStyledTextCtrl::GetWrapMode() const
1958 return SendMsg(2269, 0, 0);
1961 // Set the display mode of visual flags for wrapped lines.
1962 void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags
)
1964 SendMsg(2460, wrapVisualFlags
, 0);
1967 // Retrieve the display mode of visual flags for wrapped lines.
1968 int wxStyledTextCtrl::GetWrapVisualFlags() const
1970 return SendMsg(2461, 0, 0);
1973 // Set the location of visual flags for wrapped lines.
1974 void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation
)
1976 SendMsg(2462, wrapVisualFlagsLocation
, 0);
1979 // Retrieve the location of visual flags for wrapped lines.
1980 int wxStyledTextCtrl::GetWrapVisualFlagsLocation() const
1982 return SendMsg(2463, 0, 0);
1985 // Set the start indent for wrapped lines.
1986 void wxStyledTextCtrl::SetWrapStartIndent(int indent
)
1988 SendMsg(2464, indent
, 0);
1991 // Retrieve the start indent for wrapped lines.
1992 int wxStyledTextCtrl::GetWrapStartIndent() const
1994 return SendMsg(2465, 0, 0);
1997 // Sets how wrapped sublines are placed. Default is fixed.
1998 void wxStyledTextCtrl::SetWrapIndentMode(int mode
)
2000 SendMsg(2472, mode
, 0);
2003 // Retrieve how wrapped sublines are placed. Default is fixed.
2004 int wxStyledTextCtrl::GetWrapIndentMode() const
2006 return SendMsg(2473, 0, 0);
2009 // Sets the degree of caching of layout information.
2010 void wxStyledTextCtrl::SetLayoutCache(int mode
)
2012 SendMsg(2272, mode
, 0);
2015 // Retrieve the degree of caching of layout information.
2016 int wxStyledTextCtrl::GetLayoutCache() const
2018 return SendMsg(2273, 0, 0);
2021 // Sets the document width assumed for scrolling.
2022 void wxStyledTextCtrl::SetScrollWidth(int pixelWidth
)
2024 SendMsg(2274, pixelWidth
, 0);
2027 // Retrieve the document width assumed for scrolling.
2028 int wxStyledTextCtrl::GetScrollWidth() const
2030 return SendMsg(2275, 0, 0);
2033 // Sets whether the maximum width line displayed is used to set scroll width.
2034 void wxStyledTextCtrl::SetScrollWidthTracking(bool tracking
)
2036 SendMsg(2516, tracking
, 0);
2039 // Retrieve whether the scroll width tracks wide lines.
2040 bool wxStyledTextCtrl::GetScrollWidthTracking() const
2042 return SendMsg(2517, 0, 0) != 0;
2045 // Measure the pixel width of some text in a particular style.
2046 // NUL terminated text argument.
2047 // Does not handle tab or control characters.
2048 int wxStyledTextCtrl::TextWidth(int style
, const wxString
& text
)
2050 return SendMsg(2276, style
, (sptr_t
)(const char*)wx2stc(text
));
2053 // Sets the scroll range so that maximum scroll position has
2054 // the last line at the bottom of the view (default).
2055 // Setting this to false allows scrolling one page below the last line.
2056 void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine
)
2058 SendMsg(2277, endAtLastLine
, 0);
2061 // Retrieve whether the maximum scroll position has the last
2062 // line at the bottom of the view.
2063 bool wxStyledTextCtrl::GetEndAtLastLine() const
2065 return SendMsg(2278, 0, 0) != 0;
2068 // Retrieve the height of a particular line of text in pixels.
2069 int wxStyledTextCtrl::TextHeight(int line
)
2071 return SendMsg(2279, line
, 0);
2074 // Show or hide the vertical scroll bar.
2075 void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show
)
2077 SendMsg(2280, show
, 0);
2080 // Is the vertical scroll bar visible?
2081 bool wxStyledTextCtrl::GetUseVerticalScrollBar() const
2083 return SendMsg(2281, 0, 0) != 0;
2086 // Append a string to the end of the document without changing the selection.
2087 void wxStyledTextCtrl::AppendText(const wxString
& text
) {
2088 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
2089 SendMsg(2282, strlen(buf
), (sptr_t
)(const char*)buf
);
2092 // Is drawing done in two phases with backgrounds drawn before foregrounds?
2093 bool wxStyledTextCtrl::GetTwoPhaseDraw() const
2095 return SendMsg(2283, 0, 0) != 0;
2098 // In twoPhaseDraw mode, drawing is performed in two phases, first the background
2099 // and then the foreground. This avoids chopping off characters that overlap the next run.
2100 void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase
)
2102 SendMsg(2284, twoPhase
, 0);
2105 // Scroll so that a display line is at the top of the display.
2106 void wxStyledTextCtrl::SetFirstVisibleLine(int lineDisplay
)
2108 SendMsg(2613, lineDisplay
, 0);
2111 // Make the target range start and end be the same as the selection range start and end.
2112 void wxStyledTextCtrl::TargetFromSelection()
2114 SendMsg(2287, 0, 0);
2117 // Join the lines in the target.
2118 void wxStyledTextCtrl::LinesJoin()
2120 SendMsg(2288, 0, 0);
2123 // Split the lines in the target into lines that are less wide than pixelWidth
2125 void wxStyledTextCtrl::LinesSplit(int pixelWidth
)
2127 SendMsg(2289, pixelWidth
, 0);
2130 // Set the colours used as a chequerboard pattern in the fold margin
2131 void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting
, const wxColour
& back
)
2133 SendMsg(2290, useSetting
, wxColourAsLong(back
));
2135 void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting
, const wxColour
& fore
)
2137 SendMsg(2291, useSetting
, wxColourAsLong(fore
));
2140 // Move caret down one line.
2141 void wxStyledTextCtrl::LineDown()
2143 SendMsg(2300, 0, 0);
2146 // Move caret down one line extending selection to new caret position.
2147 void wxStyledTextCtrl::LineDownExtend()
2149 SendMsg(2301, 0, 0);
2152 // Move caret up one line.
2153 void wxStyledTextCtrl::LineUp()
2155 SendMsg(2302, 0, 0);
2158 // Move caret up one line extending selection to new caret position.
2159 void wxStyledTextCtrl::LineUpExtend()
2161 SendMsg(2303, 0, 0);
2164 // Move caret left one character.
2165 void wxStyledTextCtrl::CharLeft()
2167 SendMsg(2304, 0, 0);
2170 // Move caret left one character extending selection to new caret position.
2171 void wxStyledTextCtrl::CharLeftExtend()
2173 SendMsg(2305, 0, 0);
2176 // Move caret right one character.
2177 void wxStyledTextCtrl::CharRight()
2179 SendMsg(2306, 0, 0);
2182 // Move caret right one character extending selection to new caret position.
2183 void wxStyledTextCtrl::CharRightExtend()
2185 SendMsg(2307, 0, 0);
2188 // Move caret left one word.
2189 void wxStyledTextCtrl::WordLeft()
2191 SendMsg(2308, 0, 0);
2194 // Move caret left one word extending selection to new caret position.
2195 void wxStyledTextCtrl::WordLeftExtend()
2197 SendMsg(2309, 0, 0);
2200 // Move caret right one word.
2201 void wxStyledTextCtrl::WordRight()
2203 SendMsg(2310, 0, 0);
2206 // Move caret right one word extending selection to new caret position.
2207 void wxStyledTextCtrl::WordRightExtend()
2209 SendMsg(2311, 0, 0);
2212 // Move caret to first position on line.
2213 void wxStyledTextCtrl::Home()
2215 SendMsg(2312, 0, 0);
2218 // Move caret to first position on line extending selection to new caret position.
2219 void wxStyledTextCtrl::HomeExtend()
2221 SendMsg(2313, 0, 0);
2224 // Move caret to last position on line.
2225 void wxStyledTextCtrl::LineEnd()
2227 SendMsg(2314, 0, 0);
2230 // Move caret to last position on line extending selection to new caret position.
2231 void wxStyledTextCtrl::LineEndExtend()
2233 SendMsg(2315, 0, 0);
2236 // Move caret to first position in document.
2237 void wxStyledTextCtrl::DocumentStart()
2239 SendMsg(2316, 0, 0);
2242 // Move caret to first position in document extending selection to new caret position.
2243 void wxStyledTextCtrl::DocumentStartExtend()
2245 SendMsg(2317, 0, 0);
2248 // Move caret to last position in document.
2249 void wxStyledTextCtrl::DocumentEnd()
2251 SendMsg(2318, 0, 0);
2254 // Move caret to last position in document extending selection to new caret position.
2255 void wxStyledTextCtrl::DocumentEndExtend()
2257 SendMsg(2319, 0, 0);
2260 // Move caret one page up.
2261 void wxStyledTextCtrl::PageUp()
2263 SendMsg(2320, 0, 0);
2266 // Move caret one page up extending selection to new caret position.
2267 void wxStyledTextCtrl::PageUpExtend()
2269 SendMsg(2321, 0, 0);
2272 // Move caret one page down.
2273 void wxStyledTextCtrl::PageDown()
2275 SendMsg(2322, 0, 0);
2278 // Move caret one page down extending selection to new caret position.
2279 void wxStyledTextCtrl::PageDownExtend()
2281 SendMsg(2323, 0, 0);
2284 // Switch from insert to overtype mode or the reverse.
2285 void wxStyledTextCtrl::EditToggleOvertype()
2287 SendMsg(2324, 0, 0);
2290 // Cancel any modes such as call tip or auto-completion list display.
2291 void wxStyledTextCtrl::Cancel()
2293 SendMsg(2325, 0, 0);
2296 // Delete the selection or if no selection, the character before the caret.
2297 void wxStyledTextCtrl::DeleteBack()
2299 SendMsg(2326, 0, 0);
2302 // If selection is empty or all on one line replace the selection with a tab character.
2303 // If more than one line selected, indent the lines.
2304 void wxStyledTextCtrl::Tab()
2306 SendMsg(2327, 0, 0);
2309 // Dedent the selected lines.
2310 void wxStyledTextCtrl::BackTab()
2312 SendMsg(2328, 0, 0);
2315 // Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
2316 void wxStyledTextCtrl::NewLine()
2318 SendMsg(2329, 0, 0);
2321 // Insert a Form Feed character.
2322 void wxStyledTextCtrl::FormFeed()
2324 SendMsg(2330, 0, 0);
2327 // Move caret to before first visible character on line.
2328 // If already there move to first character on line.
2329 void wxStyledTextCtrl::VCHome()
2331 SendMsg(2331, 0, 0);
2334 // Like VCHome but extending selection to new caret position.
2335 void wxStyledTextCtrl::VCHomeExtend()
2337 SendMsg(2332, 0, 0);
2340 // Magnify the displayed text by increasing the sizes by 1 point.
2341 void wxStyledTextCtrl::ZoomIn()
2343 SendMsg(2333, 0, 0);
2346 // Make the displayed text smaller by decreasing the sizes by 1 point.
2347 void wxStyledTextCtrl::ZoomOut()
2349 SendMsg(2334, 0, 0);
2352 // Delete the word to the left of the caret.
2353 void wxStyledTextCtrl::DelWordLeft()
2355 SendMsg(2335, 0, 0);
2358 // Delete the word to the right of the caret.
2359 void wxStyledTextCtrl::DelWordRight()
2361 SendMsg(2336, 0, 0);
2364 // Delete the word to the right of the caret, but not the trailing non-word characters.
2365 void wxStyledTextCtrl::DelWordRightEnd()
2367 SendMsg(2518, 0, 0);
2370 // Cut the line containing the caret.
2371 void wxStyledTextCtrl::LineCut()
2373 SendMsg(2337, 0, 0);
2376 // Delete the line containing the caret.
2377 void wxStyledTextCtrl::LineDelete()
2379 SendMsg(2338, 0, 0);
2382 // Switch the current line with the previous.
2383 void wxStyledTextCtrl::LineTranspose()
2385 SendMsg(2339, 0, 0);
2388 // Duplicate the current line.
2389 void wxStyledTextCtrl::LineDuplicate()
2391 SendMsg(2404, 0, 0);
2394 // Transform the selection to lower case.
2395 void wxStyledTextCtrl::LowerCase()
2397 SendMsg(2340, 0, 0);
2400 // Transform the selection to upper case.
2401 void wxStyledTextCtrl::UpperCase()
2403 SendMsg(2341, 0, 0);
2406 // Scroll the document down, keeping the caret visible.
2407 void wxStyledTextCtrl::LineScrollDown()
2409 SendMsg(2342, 0, 0);
2412 // Scroll the document up, keeping the caret visible.
2413 void wxStyledTextCtrl::LineScrollUp()
2415 SendMsg(2343, 0, 0);
2418 // Delete the selection or if no selection, the character before the caret.
2419 // Will not delete the character before at the start of a line.
2420 void wxStyledTextCtrl::DeleteBackNotLine()
2422 SendMsg(2344, 0, 0);
2425 // Move caret to first position on display line.
2426 void wxStyledTextCtrl::HomeDisplay()
2428 SendMsg(2345, 0, 0);
2431 // Move caret to first position on display line extending selection to
2432 // new caret position.
2433 void wxStyledTextCtrl::HomeDisplayExtend()
2435 SendMsg(2346, 0, 0);
2438 // Move caret to last position on display line.
2439 void wxStyledTextCtrl::LineEndDisplay()
2441 SendMsg(2347, 0, 0);
2444 // Move caret to last position on display line extending selection to new
2446 void wxStyledTextCtrl::LineEndDisplayExtend()
2448 SendMsg(2348, 0, 0);
2451 // These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
2452 // except they behave differently when word-wrap is enabled:
2453 // They go first to the start / end of the display line, like (Home|LineEnd)Display
2454 // The difference is that, the cursor is already at the point, it goes on to the start
2455 // or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
2456 void wxStyledTextCtrl::HomeWrap()
2458 SendMsg(2349, 0, 0);
2460 void wxStyledTextCtrl::HomeWrapExtend()
2462 SendMsg(2450, 0, 0);
2464 void wxStyledTextCtrl::LineEndWrap()
2466 SendMsg(2451, 0, 0);
2468 void wxStyledTextCtrl::LineEndWrapExtend()
2470 SendMsg(2452, 0, 0);
2472 void wxStyledTextCtrl::VCHomeWrap()
2474 SendMsg(2453, 0, 0);
2476 void wxStyledTextCtrl::VCHomeWrapExtend()
2478 SendMsg(2454, 0, 0);
2481 // Copy the line containing the caret.
2482 void wxStyledTextCtrl::LineCopy()
2484 SendMsg(2455, 0, 0);
2487 // Move the caret inside current view if it's not there already.
2488 void wxStyledTextCtrl::MoveCaretInsideView()
2490 SendMsg(2401, 0, 0);
2493 // How many characters are on a line, including end of line characters?
2494 int wxStyledTextCtrl::LineLength(int line
) const
2496 return SendMsg(2350, line
, 0);
2499 // Highlight the characters at two positions.
2500 void wxStyledTextCtrl::BraceHighlight(int pos1
, int pos2
)
2502 SendMsg(2351, pos1
, pos2
);
2505 // Highlight the character at a position indicating there is no matching brace.
2506 void wxStyledTextCtrl::BraceBadLight(int pos
)
2508 SendMsg(2352, pos
, 0);
2511 // Find the position of a matching brace or INVALID_POSITION if no match.
2512 int wxStyledTextCtrl::BraceMatch(int pos
)
2514 return SendMsg(2353, pos
, 0);
2517 // Are the end of line characters visible?
2518 bool wxStyledTextCtrl::GetViewEOL() const
2520 return SendMsg(2355, 0, 0) != 0;
2523 // Make the end of line characters visible or invisible.
2524 void wxStyledTextCtrl::SetViewEOL(bool visible
)
2526 SendMsg(2356, visible
, 0);
2529 // Retrieve a pointer to the document object.
2530 void* wxStyledTextCtrl::GetDocPointer() {
2531 return (void*)SendMsg(2357);
2534 // Change the document object used.
2535 void wxStyledTextCtrl::SetDocPointer(void* docPointer
) {
2536 SendMsg(2358, 0, (sptr_t
)docPointer
);
2539 // Set which document modification events are sent to the container.
2540 void wxStyledTextCtrl::SetModEventMask(int mask
)
2542 SendMsg(2359, mask
, 0);
2545 // Retrieve the column number which text should be kept within.
2546 int wxStyledTextCtrl::GetEdgeColumn() const
2548 return SendMsg(2360, 0, 0);
2551 // Set the column number of the edge.
2552 // If text goes past the edge then it is highlighted.
2553 void wxStyledTextCtrl::SetEdgeColumn(int column
)
2555 SendMsg(2361, column
, 0);
2558 // Retrieve the edge highlight mode.
2559 int wxStyledTextCtrl::GetEdgeMode() const
2561 return SendMsg(2362, 0, 0);
2564 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
2565 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
2566 void wxStyledTextCtrl::SetEdgeMode(int mode
)
2568 SendMsg(2363, mode
, 0);
2571 // Retrieve the colour used in edge indication.
2572 wxColour
wxStyledTextCtrl::GetEdgeColour() const
2574 long c
= SendMsg(2364, 0, 0);
2575 return wxColourFromLong(c
);
2578 // Change the colour used in edge indication.
2579 void wxStyledTextCtrl::SetEdgeColour(const wxColour
& edgeColour
)
2581 SendMsg(2365, wxColourAsLong(edgeColour
), 0);
2584 // Sets the current caret position to be the search anchor.
2585 void wxStyledTextCtrl::SearchAnchor()
2587 SendMsg(2366, 0, 0);
2590 // Find some text starting at the search anchor.
2591 // Does not ensure the selection is visible.
2592 int wxStyledTextCtrl::SearchNext(int flags
, const wxString
& text
)
2594 return SendMsg(2367, flags
, (sptr_t
)(const char*)wx2stc(text
));
2597 // Find some text starting at the search anchor and moving backwards.
2598 // Does not ensure the selection is visible.
2599 int wxStyledTextCtrl::SearchPrev(int flags
, const wxString
& text
)
2601 return SendMsg(2368, flags
, (sptr_t
)(const char*)wx2stc(text
));
2604 // Retrieves the number of lines completely visible.
2605 int wxStyledTextCtrl::LinesOnScreen() const
2607 return SendMsg(2370, 0, 0);
2610 // Set whether a pop up menu is displayed automatically when the user presses
2611 // the wrong mouse button.
2612 void wxStyledTextCtrl::UsePopUp(bool allowPopUp
)
2614 SendMsg(2371, allowPopUp
, 0);
2617 // Is the selection rectangular? The alternative is the more common stream selection.
2618 bool wxStyledTextCtrl::SelectionIsRectangle() const
2620 return SendMsg(2372, 0, 0) != 0;
2623 // Set the zoom level. This number of points is added to the size of all fonts.
2624 // It may be positive to magnify or negative to reduce.
2625 void wxStyledTextCtrl::SetZoom(int zoom
)
2627 SendMsg(2373, zoom
, 0);
2630 // Retrieve the zoom level.
2631 int wxStyledTextCtrl::GetZoom() const
2633 return SendMsg(2374, 0, 0);
2636 // Create a new document object.
2637 // Starts with reference count of 1 and not selected into editor.
2638 void* wxStyledTextCtrl::CreateDocument() {
2639 return (void*)SendMsg(2375);
2642 // Extend life of document.
2643 void wxStyledTextCtrl::AddRefDocument(void* docPointer
) {
2644 SendMsg(2376, 0, (sptr_t
)docPointer
);
2647 // Release a reference to the document, deleting document if it fades to black.
2648 void wxStyledTextCtrl::ReleaseDocument(void* docPointer
) {
2649 SendMsg(2377, 0, (sptr_t
)docPointer
);
2652 // Get which document modification events are sent to the container.
2653 int wxStyledTextCtrl::GetModEventMask() const
2655 return SendMsg(2378, 0, 0);
2658 // Change internal focus flag.
2659 void wxStyledTextCtrl::SetSTCFocus(bool focus
)
2661 SendMsg(2380, focus
, 0);
2664 // Get internal focus flag.
2665 bool wxStyledTextCtrl::GetSTCFocus() const
2667 return SendMsg(2381, 0, 0) != 0;
2670 // Change error status - 0 = OK.
2671 void wxStyledTextCtrl::SetStatus(int statusCode
)
2673 SendMsg(2382, statusCode
, 0);
2676 // Get error status.
2677 int wxStyledTextCtrl::GetStatus() const
2679 return SendMsg(2383, 0, 0);
2682 // Set whether the mouse is captured when its button is pressed.
2683 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures
)
2685 SendMsg(2384, captures
, 0);
2688 // Get whether mouse gets captured.
2689 bool wxStyledTextCtrl::GetMouseDownCaptures() const
2691 return SendMsg(2385, 0, 0) != 0;
2694 // Sets the cursor to one of the SC_CURSOR* values.
2695 void wxStyledTextCtrl::SetSTCCursor(int cursorType
)
2697 SendMsg(2386, cursorType
, 0);
2701 int wxStyledTextCtrl::GetSTCCursor() const
2703 return SendMsg(2387, 0, 0);
2706 // Change the way control characters are displayed:
2707 // If symbol is < 32, keep the drawn way, else, use the given character.
2708 void wxStyledTextCtrl::SetControlCharSymbol(int symbol
)
2710 SendMsg(2388, symbol
, 0);
2713 // Get the way control characters are displayed.
2714 int wxStyledTextCtrl::GetControlCharSymbol() const
2716 return SendMsg(2389, 0, 0);
2719 // Move to the previous change in capitalisation.
2720 void wxStyledTextCtrl::WordPartLeft()
2722 SendMsg(2390, 0, 0);
2725 // Move to the previous change in capitalisation extending selection
2726 // to new caret position.
2727 void wxStyledTextCtrl::WordPartLeftExtend()
2729 SendMsg(2391, 0, 0);
2732 // Move to the change next in capitalisation.
2733 void wxStyledTextCtrl::WordPartRight()
2735 SendMsg(2392, 0, 0);
2738 // Move to the next change in capitalisation extending selection
2739 // to new caret position.
2740 void wxStyledTextCtrl::WordPartRightExtend()
2742 SendMsg(2393, 0, 0);
2745 // Set the way the display area is determined when a particular line
2746 // is to be moved to by Find, FindNext, GotoLine, etc.
2747 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy
, int visibleSlop
)
2749 SendMsg(2394, visiblePolicy
, visibleSlop
);
2752 // Delete back from the current position to the start of the line.
2753 void wxStyledTextCtrl::DelLineLeft()
2755 SendMsg(2395, 0, 0);
2758 // Delete forwards from the current position to the end of the line.
2759 void wxStyledTextCtrl::DelLineRight()
2761 SendMsg(2396, 0, 0);
2764 // Get and Set the xOffset (ie, horizonal scroll position).
2765 void wxStyledTextCtrl::SetXOffset(int newOffset
)
2767 SendMsg(2397, newOffset
, 0);
2769 int wxStyledTextCtrl::GetXOffset() const
2771 return SendMsg(2398, 0, 0);
2774 // Set the last x chosen value to be the caret x position.
2775 void wxStyledTextCtrl::ChooseCaretX()
2777 SendMsg(2399, 0, 0);
2780 // Set the way the caret is kept visible when going sideway.
2781 // The exclusion zone is given in pixels.
2782 void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy
, int caretSlop
)
2784 SendMsg(2402, caretPolicy
, caretSlop
);
2787 // Set the way the line the caret is on is kept visible.
2788 // The exclusion zone is given in lines.
2789 void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy
, int caretSlop
)
2791 SendMsg(2403, caretPolicy
, caretSlop
);
2794 // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
2795 void wxStyledTextCtrl::SetPrintWrapMode(int mode
)
2797 SendMsg(2406, mode
, 0);
2800 // Is printing line wrapped?
2801 int wxStyledTextCtrl::GetPrintWrapMode() const
2803 return SendMsg(2407, 0, 0);
2806 // Set a fore colour for active hotspots.
2807 void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting
, const wxColour
& fore
)
2809 SendMsg(2410, useSetting
, wxColourAsLong(fore
));
2812 // Get the fore colour for active hotspots.
2813 wxColour
wxStyledTextCtrl::GetHotspotActiveForeground() const
2815 long c
= SendMsg(2494, 0, 0);
2816 return wxColourFromLong(c
);
2819 // Set a back colour for active hotspots.
2820 void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting
, const wxColour
& back
)
2822 SendMsg(2411, useSetting
, wxColourAsLong(back
));
2825 // Get the back colour for active hotspots.
2826 wxColour
wxStyledTextCtrl::GetHotspotActiveBackground() const
2828 long c
= SendMsg(2495, 0, 0);
2829 return wxColourFromLong(c
);
2832 // Enable / Disable underlining active hotspots.
2833 void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline
)
2835 SendMsg(2412, underline
, 0);
2838 // Get whether underlining for active hotspots.
2839 bool wxStyledTextCtrl::GetHotspotActiveUnderline() const
2841 return SendMsg(2496, 0, 0) != 0;
2844 // Limit hotspots to single line so hotspots on two lines don't merge.
2845 void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine
)
2847 SendMsg(2421, singleLine
, 0);
2850 // Get the HotspotSingleLine property
2851 bool wxStyledTextCtrl::GetHotspotSingleLine() const
2853 return SendMsg(2497, 0, 0) != 0;
2856 // Move caret between paragraphs (delimited by empty lines).
2857 void wxStyledTextCtrl::ParaDown()
2859 SendMsg(2413, 0, 0);
2861 void wxStyledTextCtrl::ParaDownExtend()
2863 SendMsg(2414, 0, 0);
2865 void wxStyledTextCtrl::ParaUp()
2867 SendMsg(2415, 0, 0);
2869 void wxStyledTextCtrl::ParaUpExtend()
2871 SendMsg(2416, 0, 0);
2874 // Given a valid document position, return the previous position taking code
2875 // page into account. Returns 0 if passed 0.
2876 int wxStyledTextCtrl::PositionBefore(int pos
)
2878 return SendMsg(2417, pos
, 0);
2881 // Given a valid document position, return the next position taking code
2882 // page into account. Maximum value returned is the last position in the document.
2883 int wxStyledTextCtrl::PositionAfter(int pos
)
2885 return SendMsg(2418, pos
, 0);
2888 // Copy a range of text to the clipboard. Positions are clipped into the document.
2889 void wxStyledTextCtrl::CopyRange(int start
, int end
)
2891 SendMsg(2419, start
, end
);
2894 // Copy argument text to the clipboard.
2895 void wxStyledTextCtrl::CopyText(int length
, const wxString
& text
)
2897 SendMsg(2420, length
, (sptr_t
)(const char*)wx2stc(text
));
2900 // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE/SC_SEL_THIN) or
2901 // by lines (SC_SEL_LINES).
2902 void wxStyledTextCtrl::SetSelectionMode(int mode
)
2904 SendMsg(2422, mode
, 0);
2907 // Get the mode of the current selection.
2908 int wxStyledTextCtrl::GetSelectionMode() const
2910 return SendMsg(2423, 0, 0);
2913 // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
2914 int wxStyledTextCtrl::GetLineSelStartPosition(int line
)
2916 return SendMsg(2424, line
, 0);
2919 // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
2920 int wxStyledTextCtrl::GetLineSelEndPosition(int line
)
2922 return SendMsg(2425, line
, 0);
2925 // Move caret down one line, extending rectangular selection to new caret position.
2926 void wxStyledTextCtrl::LineDownRectExtend()
2928 SendMsg(2426, 0, 0);
2931 // Move caret up one line, extending rectangular selection to new caret position.
2932 void wxStyledTextCtrl::LineUpRectExtend()
2934 SendMsg(2427, 0, 0);
2937 // Move caret left one character, extending rectangular selection to new caret position.
2938 void wxStyledTextCtrl::CharLeftRectExtend()
2940 SendMsg(2428, 0, 0);
2943 // Move caret right one character, extending rectangular selection to new caret position.
2944 void wxStyledTextCtrl::CharRightRectExtend()
2946 SendMsg(2429, 0, 0);
2949 // Move caret to first position on line, extending rectangular selection to new caret position.
2950 void wxStyledTextCtrl::HomeRectExtend()
2952 SendMsg(2430, 0, 0);
2955 // Move caret to before first visible character on line.
2956 // If already there move to first character on line.
2957 // In either case, extend rectangular selection to new caret position.
2958 void wxStyledTextCtrl::VCHomeRectExtend()
2960 SendMsg(2431, 0, 0);
2963 // Move caret to last position on line, extending rectangular selection to new caret position.
2964 void wxStyledTextCtrl::LineEndRectExtend()
2966 SendMsg(2432, 0, 0);
2969 // Move caret one page up, extending rectangular selection to new caret position.
2970 void wxStyledTextCtrl::PageUpRectExtend()
2972 SendMsg(2433, 0, 0);
2975 // Move caret one page down, extending rectangular selection to new caret position.
2976 void wxStyledTextCtrl::PageDownRectExtend()
2978 SendMsg(2434, 0, 0);
2981 // Move caret to top of page, or one page up if already at top of page.
2982 void wxStyledTextCtrl::StutteredPageUp()
2984 SendMsg(2435, 0, 0);
2987 // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
2988 void wxStyledTextCtrl::StutteredPageUpExtend()
2990 SendMsg(2436, 0, 0);
2993 // Move caret to bottom of page, or one page down if already at bottom of page.
2994 void wxStyledTextCtrl::StutteredPageDown()
2996 SendMsg(2437, 0, 0);
2999 // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
3000 void wxStyledTextCtrl::StutteredPageDownExtend()
3002 SendMsg(2438, 0, 0);
3005 // Move caret left one word, position cursor at end of word.
3006 void wxStyledTextCtrl::WordLeftEnd()
3008 SendMsg(2439, 0, 0);
3011 // Move caret left one word, position cursor at end of word, extending selection to new caret position.
3012 void wxStyledTextCtrl::WordLeftEndExtend()
3014 SendMsg(2440, 0, 0);
3017 // Move caret right one word, position cursor at end of word.
3018 void wxStyledTextCtrl::WordRightEnd()
3020 SendMsg(2441, 0, 0);
3023 // Move caret right one word, position cursor at end of word, extending selection to new caret position.
3024 void wxStyledTextCtrl::WordRightEndExtend()
3026 SendMsg(2442, 0, 0);
3029 // Set the set of characters making up whitespace for when moving or selecting by word.
3030 // Should be called after SetWordChars.
3031 void wxStyledTextCtrl::SetWhitespaceChars(const wxString
& characters
)
3033 SendMsg(2443, 0, (sptr_t
)(const char*)wx2stc(characters
));
3036 // Reset the set of characters for whitespace and word characters to the defaults.
3037 void wxStyledTextCtrl::SetCharsDefault()
3039 SendMsg(2444, 0, 0);
3042 // Get currently selected item position in the auto-completion list
3043 int wxStyledTextCtrl::AutoCompGetCurrent()
3045 return SendMsg(2445, 0, 0);
3048 // Enlarge the document to a particular size of text bytes.
3049 void wxStyledTextCtrl::Allocate(int bytes
)
3051 SendMsg(2446, bytes
, 0);
3054 // Find the position of a column on a line taking into account tabs and
3055 // multi-byte characters. If beyond end of line, return line end position.
3056 int wxStyledTextCtrl::FindColumn(int line
, int column
)
3058 return SendMsg(2456, line
, column
);
3061 // Can the caret preferred x position only be changed by explicit movement commands?
3062 bool wxStyledTextCtrl::GetCaretSticky() const
3064 return SendMsg(2457, 0, 0) != 0;
3067 // Stop the caret preferred x position changing when the user types.
3068 void wxStyledTextCtrl::SetCaretSticky(bool useCaretStickyBehaviour
)
3070 SendMsg(2458, useCaretStickyBehaviour
, 0);
3073 // Switch between sticky and non-sticky: meant to be bound to a key.
3074 void wxStyledTextCtrl::ToggleCaretSticky()
3076 SendMsg(2459, 0, 0);
3079 // Enable/Disable convert-on-paste for line endings
3080 void wxStyledTextCtrl::SetPasteConvertEndings(bool convert
)
3082 SendMsg(2467, convert
, 0);
3085 // Get convert-on-paste setting
3086 bool wxStyledTextCtrl::GetPasteConvertEndings() const
3088 return SendMsg(2468, 0, 0) != 0;
3091 // Duplicate the selection. If selection empty duplicate the line containing the caret.
3092 void wxStyledTextCtrl::SelectionDuplicate()
3094 SendMsg(2469, 0, 0);
3097 // Set background alpha of the caret line.
3098 void wxStyledTextCtrl::SetCaretLineBackAlpha(int alpha
)
3100 SendMsg(2470, alpha
, 0);
3103 // Get the background alpha of the caret line.
3104 int wxStyledTextCtrl::GetCaretLineBackAlpha() const
3106 return SendMsg(2471, 0, 0);
3109 // Set the style of the caret to be drawn.
3110 void wxStyledTextCtrl::SetCaretStyle(int caretStyle
)
3112 SendMsg(2512, caretStyle
, 0);
3115 // Returns the current style of the caret.
3116 int wxStyledTextCtrl::GetCaretStyle() const
3118 return SendMsg(2513, 0, 0);
3121 // Set the indicator used for IndicatorFillRange and IndicatorClearRange
3122 void wxStyledTextCtrl::SetIndicatorCurrent(int indicator
)
3124 SendMsg(2500, indicator
, 0);
3127 // Get the current indicator
3128 int wxStyledTextCtrl::GetIndicatorCurrent() const
3130 return SendMsg(2501, 0, 0);
3133 // Set the value used for IndicatorFillRange
3134 void wxStyledTextCtrl::SetIndicatorValue(int value
)
3136 SendMsg(2502, value
, 0);
3139 // Get the current indicator vaue
3140 int wxStyledTextCtrl::GetIndicatorValue() const
3142 return SendMsg(2503, 0, 0);
3145 // Turn a indicator on over a range.
3146 void wxStyledTextCtrl::IndicatorFillRange(int position
, int fillLength
)
3148 SendMsg(2504, position
, fillLength
);
3151 // Turn a indicator off over a range.
3152 void wxStyledTextCtrl::IndicatorClearRange(int position
, int clearLength
)
3154 SendMsg(2505, position
, clearLength
);
3157 // Are any indicators present at position?
3158 int wxStyledTextCtrl::IndicatorAllOnFor(int position
)
3160 return SendMsg(2506, position
, 0);
3163 // What value does a particular indicator have at at a position?
3164 int wxStyledTextCtrl::IndicatorValueAt(int indicator
, int position
)
3166 return SendMsg(2507, indicator
, position
);
3169 // Where does a particular indicator start?
3170 int wxStyledTextCtrl::IndicatorStart(int indicator
, int position
)
3172 return SendMsg(2508, indicator
, position
);
3175 // Where does a particular indicator end?
3176 int wxStyledTextCtrl::IndicatorEnd(int indicator
, int position
)
3178 return SendMsg(2509, indicator
, position
);
3181 // Set number of entries in position cache
3182 void wxStyledTextCtrl::SetPositionCacheSize(int size
)
3184 SendMsg(2514, size
, 0);
3187 // How many entries are allocated to the position cache?
3188 int wxStyledTextCtrl::GetPositionCacheSize() const
3190 return SendMsg(2515, 0, 0);
3193 // Copy the selection, if selection empty copy the line with the caret
3194 void wxStyledTextCtrl::CopyAllowLine()
3196 SendMsg(2519, 0, 0);
3199 // Compact the document buffer and return a read-only pointer to the
3200 // characters in the document.
3201 const char* wxStyledTextCtrl::GetCharacterPointer() {
3202 return (const char*)SendMsg(2520, 0, 0);
3205 // Always interpret keyboard input as Unicode
3206 void wxStyledTextCtrl::SetKeysUnicode(bool keysUnicode
)
3208 SendMsg(2521, keysUnicode
, 0);
3211 // Are keys always interpreted as Unicode?
3212 bool wxStyledTextCtrl::GetKeysUnicode() const
3214 return SendMsg(2522, 0, 0) != 0;
3217 // Set the alpha fill colour of the given indicator.
3218 void wxStyledTextCtrl::IndicatorSetAlpha(int indicator
, int alpha
)
3220 SendMsg(2523, indicator
, alpha
);
3223 // Get the alpha fill colour of the given indicator.
3224 int wxStyledTextCtrl::IndicatorGetAlpha(int indicator
) const
3226 return SendMsg(2524, indicator
, 0);
3229 // Set extra ascent for each line
3230 void wxStyledTextCtrl::SetExtraAscent(int extraAscent
)
3232 SendMsg(2525, extraAscent
, 0);
3235 // Get extra ascent for each line
3236 int wxStyledTextCtrl::GetExtraAscent() const
3238 return SendMsg(2526, 0, 0);
3241 // Set extra descent for each line
3242 void wxStyledTextCtrl::SetExtraDescent(int extraDescent
)
3244 SendMsg(2527, extraDescent
, 0);
3247 // Get extra descent for each line
3248 int wxStyledTextCtrl::GetExtraDescent() const
3250 return SendMsg(2528, 0, 0);
3253 // Which symbol was defined for markerNumber with MarkerDefine
3254 int wxStyledTextCtrl::GetMarkerSymbolDefined(int markerNumber
)
3256 return SendMsg(2529, markerNumber
, 0);
3259 // Set the text in the text margin for a line
3260 void wxStyledTextCtrl::MarginSetText(int line
, const wxString
& text
)
3262 SendMsg(2530, line
, (sptr_t
)(const char*)wx2stc(text
));
3265 // Get the text in the text margin for a line
3266 wxString
wxStyledTextCtrl::MarginGetText(int line
) const {
3268 long len
= SendMsg(msg
, line
, 0);
3270 wxMemoryBuffer
mbuf(len
+1);
3271 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
3272 SendMsg(msg
, line
, (sptr_t
)buf
);
3273 mbuf
.UngetWriteBuf(len
);
3278 // Set the style number for the text margin for a line
3279 void wxStyledTextCtrl::MarginSetStyle(int line
, int style
)
3281 SendMsg(2532, line
, style
);
3284 // Get the style number for the text margin for a line
3285 int wxStyledTextCtrl::MarginGetStyle(int line
) const
3287 return SendMsg(2533, line
, 0);
3290 // Set the style in the text margin for a line
3291 void wxStyledTextCtrl::MarginSetStyles(int line
, const wxString
& styles
)
3293 SendMsg(2534, line
, (sptr_t
)(const char*)wx2stc(styles
));
3296 // Get the styles in the text margin for a line
3297 wxString
wxStyledTextCtrl::MarginGetStyles(int line
) const {
3299 long len
= SendMsg(msg
, line
, 0);
3301 wxMemoryBuffer
mbuf(len
+1);
3302 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
3303 SendMsg(msg
, line
, (sptr_t
)buf
);
3304 mbuf
.UngetWriteBuf(len
);
3309 // Clear the margin text on all lines
3310 void wxStyledTextCtrl::MarginTextClearAll()
3312 SendMsg(2536, 0, 0);
3315 // Get the start of the range of style numbers used for margin text
3316 void wxStyledTextCtrl::MarginSetStyleOffset(int style
)
3318 SendMsg(2537, style
, 0);
3321 // Get the start of the range of style numbers used for margin text
3322 int wxStyledTextCtrl::MarginGetStyleOffset() const
3324 return SendMsg(2538, 0, 0);
3327 // Set the annotation text for a line
3328 void wxStyledTextCtrl::AnnotationSetText(int line
, const wxString
& text
)
3330 SendMsg(2540, line
, (sptr_t
)(const char*)wx2stc(text
));
3333 // Get the annotation text for a line
3334 wxString
wxStyledTextCtrl::AnnotationGetText(int line
) const {
3336 long len
= SendMsg(msg
, line
, 0);
3338 wxMemoryBuffer
mbuf(len
+1);
3339 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
3340 SendMsg(msg
, line
, (sptr_t
)buf
);
3341 mbuf
.UngetWriteBuf(len
);
3346 // Set the style number for the annotations for a line
3347 void wxStyledTextCtrl::AnnotationSetStyle(int line
, int style
)
3349 SendMsg(2542, line
, style
);
3352 // Get the style number for the annotations for a line
3353 int wxStyledTextCtrl::AnnotationGetStyle(int line
) const
3355 return SendMsg(2543, line
, 0);
3358 // Set the annotation styles for a line
3359 void wxStyledTextCtrl::AnnotationSetStyles(int line
, const wxString
& styles
)
3361 SendMsg(2544, line
, (sptr_t
)(const char*)wx2stc(styles
));
3364 // Get the annotation styles for a line
3365 wxString
wxStyledTextCtrl::AnnotationGetStyles(int line
) const {
3367 long len
= SendMsg(msg
, line
, 0);
3369 wxMemoryBuffer
mbuf(len
+1);
3370 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
3371 SendMsg(msg
, line
, (sptr_t
)buf
);
3372 mbuf
.UngetWriteBuf(len
);
3377 // Get the number of annotation lines for a line
3378 int wxStyledTextCtrl::AnnotationGetLines(int line
) const
3380 return SendMsg(2546, line
, 0);
3383 // Clear the annotations from all lines
3384 void wxStyledTextCtrl::AnnotationClearAll()
3386 SendMsg(2547, 0, 0);
3389 // Set the visibility for the annotations for a view
3390 void wxStyledTextCtrl::AnnotationSetVisible(int visible
)
3392 SendMsg(2548, visible
, 0);
3395 // Get the visibility for the annotations for a view
3396 int wxStyledTextCtrl::AnnotationGetVisible() const
3398 return SendMsg(2549, 0, 0);
3401 // Get the start of the range of style numbers used for annotations
3402 void wxStyledTextCtrl::AnnotationSetStyleOffset(int style
)
3404 SendMsg(2550, style
, 0);
3407 // Get the start of the range of style numbers used for annotations
3408 int wxStyledTextCtrl::AnnotationGetStyleOffset() const
3410 return SendMsg(2551, 0, 0);
3413 // Add a container action to the undo stack
3414 void wxStyledTextCtrl::AddUndoAction(int token
, int flags
)
3416 SendMsg(2560, token
, flags
);
3419 // Find the position of a character from a point within the window.
3420 int wxStyledTextCtrl::CharPositionFromPoint(int x
, int y
)
3422 return SendMsg(2561, x
, y
);
3425 // Find the position of a character from a point within the window.
3426 // Return INVALID_POSITION if not close to text.
3427 int wxStyledTextCtrl::CharPositionFromPointClose(int x
, int y
)
3429 return SendMsg(2562, x
, y
);
3432 // Set whether multiple selections can be made
3433 void wxStyledTextCtrl::SetMultipleSelection(bool multipleSelection
)
3435 SendMsg(2563, multipleSelection
, 0);
3438 // Whether multiple selections can be made
3439 bool wxStyledTextCtrl::GetMultipleSelection() const
3441 return SendMsg(2564, 0, 0) != 0;
3444 // Set whether typing can be performed into multiple selections
3445 void wxStyledTextCtrl::SetAdditionalSelectionTyping(bool additionalSelectionTyping
)
3447 SendMsg(2565, additionalSelectionTyping
, 0);
3450 // Whether typing can be performed into multiple selections
3451 bool wxStyledTextCtrl::GetAdditionalSelectionTyping() const
3453 return SendMsg(2566, 0, 0) != 0;
3456 // Set whether additional carets will blink
3457 void wxStyledTextCtrl::SetAdditionalCaretsBlink(bool additionalCaretsBlink
)
3459 SendMsg(2567, additionalCaretsBlink
, 0);
3462 // Whether additional carets will blink
3463 bool wxStyledTextCtrl::GetAdditionalCaretsBlink() const
3465 return SendMsg(2568, 0, 0) != 0;
3468 // Set whether additional carets are visible
3469 void wxStyledTextCtrl::SetAdditionalCaretsVisible(bool additionalCaretsBlink
)
3471 SendMsg(2608, additionalCaretsBlink
, 0);
3474 // Whether additional carets are visible
3475 bool wxStyledTextCtrl::GetAdditionalCaretsVisible() const
3477 return SendMsg(2609, 0, 0) != 0;
3480 // How many selections are there?
3481 int wxStyledTextCtrl::GetSelections() const
3483 return SendMsg(2570, 0, 0);
3486 // Clear selections to a single empty stream selection
3487 void wxStyledTextCtrl::ClearSelections()
3489 SendMsg(2571, 0, 0);
3493 int wxStyledTextCtrl::AddSelection(int caret
, int anchor
)
3495 return SendMsg(2573, caret
, anchor
);
3498 // Set the main selection
3499 void wxStyledTextCtrl::SetMainSelection(int selection
)
3501 SendMsg(2574, selection
, 0);
3504 // Which selection is the main selection
3505 int wxStyledTextCtrl::GetMainSelection() const
3507 return SendMsg(2575, 0, 0);
3509 void wxStyledTextCtrl::SetSelectionNCaret(int selection
, int pos
)
3511 SendMsg(2576, selection
, pos
);
3513 int wxStyledTextCtrl::GetSelectionNCaret(int selection
) const
3515 return SendMsg(2577, selection
, 0);
3517 void wxStyledTextCtrl::SetSelectionNAnchor(int selection
, int posAnchor
)
3519 SendMsg(2578, selection
, posAnchor
);
3521 int wxStyledTextCtrl::GetSelectionNAnchor(int selection
) const
3523 return SendMsg(2579, selection
, 0);
3525 void wxStyledTextCtrl::SetSelectionNCaretVirtualSpace(int selection
, int space
)
3527 SendMsg(2580, selection
, space
);
3529 int wxStyledTextCtrl::GetSelectionNCaretVirtualSpace(int selection
) const
3531 return SendMsg(2581, selection
, 0);
3533 void wxStyledTextCtrl::SetSelectionNAnchorVirtualSpace(int selection
, int space
)
3535 SendMsg(2582, selection
, space
);
3537 int wxStyledTextCtrl::GetSelectionNAnchorVirtualSpace(int selection
) const
3539 return SendMsg(2583, selection
, 0);
3542 // Sets the position that starts the selection - this becomes the anchor.
3543 void wxStyledTextCtrl::SetSelectionNStart(int selection
, int pos
)
3545 SendMsg(2584, selection
, pos
);
3548 // Returns the position at the start of the selection.
3549 int wxStyledTextCtrl::GetSelectionNStart(int selection
) const
3551 return SendMsg(2585, selection
, 0);
3554 // Sets the position that ends the selection - this becomes the currentPosition.
3555 void wxStyledTextCtrl::SetSelectionNEnd(int selection
, int pos
)
3557 SendMsg(2586, selection
, pos
);
3560 // Returns the position at the end of the selection.
3561 int wxStyledTextCtrl::GetSelectionNEnd(int selection
) const
3563 return SendMsg(2587, selection
, 0);
3565 void wxStyledTextCtrl::SetRectangularSelectionCaret(int pos
)
3567 SendMsg(2588, pos
, 0);
3569 int wxStyledTextCtrl::GetRectangularSelectionCaret() const
3571 return SendMsg(2589, 0, 0);
3573 void wxStyledTextCtrl::SetRectangularSelectionAnchor(int posAnchor
)
3575 SendMsg(2590, posAnchor
, 0);
3577 int wxStyledTextCtrl::GetRectangularSelectionAnchor() const
3579 return SendMsg(2591, 0, 0);
3581 void wxStyledTextCtrl::SetRectangularSelectionCaretVirtualSpace(int space
)
3583 SendMsg(2592, space
, 0);
3585 int wxStyledTextCtrl::GetRectangularSelectionCaretVirtualSpace() const
3587 return SendMsg(2593, 0, 0);
3589 void wxStyledTextCtrl::SetRectangularSelectionAnchorVirtualSpace(int space
)
3591 SendMsg(2594, space
, 0);
3593 int wxStyledTextCtrl::GetRectangularSelectionAnchorVirtualSpace() const
3595 return SendMsg(2595, 0, 0);
3597 void wxStyledTextCtrl::SetVirtualSpaceOptions(int virtualSpaceOptions
)
3599 SendMsg(2596, virtualSpaceOptions
, 0);
3601 int wxStyledTextCtrl::GetVirtualSpaceOptions() const
3603 return SendMsg(2597, 0, 0);
3606 // On GTK+, allow selecting the modifier key to use for mouse-based
3607 // rectangular selection. Often the window manager requires Alt+Mouse Drag
3608 // for moving windows.
3609 // Valid values are SCMOD_CTRL(default), SCMOD_ALT, or SCMOD_SUPER.
3610 void wxStyledTextCtrl::SetRectangularSelectionModifier(int modifier
)
3612 SendMsg(2598, modifier
, 0);
3615 // Get the modifier key used for rectangular selection.
3616 int wxStyledTextCtrl::GetRectangularSelectionModifier() const
3618 return SendMsg(2599, 0, 0);
3621 // Set the foreground colour of additional selections.
3622 // Must have previously called SetSelFore with non-zero first argument for this to have an effect.
3623 void wxStyledTextCtrl::SetAdditionalSelForeground(const wxColour
& fore
)
3625 SendMsg(2600, wxColourAsLong(fore
), 0);
3628 // Set the background colour of additional selections.
3629 // Must have previously called SetSelBack with non-zero first argument for this to have an effect.
3630 void wxStyledTextCtrl::SetAdditionalSelBackground(const wxColour
& back
)
3632 SendMsg(2601, wxColourAsLong(back
), 0);
3635 // Set the alpha of the selection.
3636 void wxStyledTextCtrl::SetAdditionalSelAlpha(int alpha
)
3638 SendMsg(2602, alpha
, 0);
3641 // Get the alpha of the selection.
3642 int wxStyledTextCtrl::GetAdditionalSelAlpha() const
3644 return SendMsg(2603, 0, 0);
3647 // Set the foreground colour of additional carets.
3648 void wxStyledTextCtrl::SetAdditionalCaretForeground(const wxColour
& fore
)
3650 SendMsg(2604, wxColourAsLong(fore
), 0);
3653 // Get the foreground colour of additional carets.
3654 wxColour
wxStyledTextCtrl::GetAdditionalCaretForeground() const
3656 long c
= SendMsg(2605, 0, 0);
3657 return wxColourFromLong(c
);
3660 // Set the main selection to the next selection.
3661 void wxStyledTextCtrl::RotateSelection()
3663 SendMsg(2606, 0, 0);
3666 // Swap that caret and anchor of the main selection.
3667 void wxStyledTextCtrl::SwapMainAnchorCaret()
3669 SendMsg(2607, 0, 0);
3672 // Start notifying the container of all key presses and commands.
3673 void wxStyledTextCtrl::StartRecord()
3675 SendMsg(3001, 0, 0);
3678 // Stop notifying the container of all key presses and commands.
3679 void wxStyledTextCtrl::StopRecord()
3681 SendMsg(3002, 0, 0);
3684 // Set the lexing language of the document.
3685 void wxStyledTextCtrl::SetLexer(int lexer
)
3687 SendMsg(4001, lexer
, 0);
3690 // Retrieve the lexing language of the document.
3691 int wxStyledTextCtrl::GetLexer() const
3693 return SendMsg(4002, 0, 0);
3696 // Colourise a segment of the document using the current lexing language.
3697 void wxStyledTextCtrl::Colourise(int start
, int end
)
3699 SendMsg(4003, start
, end
);
3702 // Set up a value that may be used by a lexer for some optional feature.
3703 void wxStyledTextCtrl::SetProperty(const wxString
& key
, const wxString
& value
)
3705 SendMsg(4004, (sptr_t
)(const char*)wx2stc(key
), (sptr_t
)(const char*)wx2stc(value
));
3708 // Set up the key words used by the lexer.
3709 void wxStyledTextCtrl::SetKeyWords(int keywordSet
, const wxString
& keyWords
)
3711 SendMsg(4005, keywordSet
, (sptr_t
)(const char*)wx2stc(keyWords
));
3714 // Set the lexing language of the document based on string name.
3715 void wxStyledTextCtrl::SetLexerLanguage(const wxString
& language
)
3717 SendMsg(4006, 0, (sptr_t
)(const char*)wx2stc(language
));
3720 // Retrieve a 'property' value previously set with SetProperty.
3721 wxString
wxStyledTextCtrl::GetProperty(const wxString
& key
) {
3722 int len
= SendMsg(SCI_GETPROPERTY
, (sptr_t
)(const char*)wx2stc(key
), 0);
3723 if (!len
) return wxEmptyString
;
3725 wxMemoryBuffer
mbuf(len
+1);
3726 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
3727 SendMsg(4008, (uptr_t
)(const char*)wx2stc(key
), (sptr_t
)buf
);
3728 mbuf
.UngetWriteBuf(len
);
3733 // Retrieve a 'property' value previously set with SetProperty,
3734 // with '$()' variable replacement on returned buffer.
3735 wxString
wxStyledTextCtrl::GetPropertyExpanded(const wxString
& key
) {
3736 int len
= SendMsg(SCI_GETPROPERTYEXPANDED
, (uptr_t
)(const char*)wx2stc(key
), 0);
3737 if (!len
) return wxEmptyString
;
3739 wxMemoryBuffer
mbuf(len
+1);
3740 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
3741 SendMsg(4009, (uptr_t
)(const char*)wx2stc(key
), (sptr_t
)buf
);
3742 mbuf
.UngetWriteBuf(len
);
3747 // Retrieve a 'property' value previously set with SetProperty,
3748 // interpreted as an int AFTER any '$()' variable replacement.
3749 int wxStyledTextCtrl::GetPropertyInt(const wxString
& key
) const
3751 return SendMsg(4010, (sptr_t
)(const char*)wx2stc(key
), 0);
3754 // Retrieve the number of bits the current lexer needs for styling.
3755 int wxStyledTextCtrl::GetStyleBitsNeeded() const
3757 return SendMsg(4011, 0, 0);
3761 //----------------------------------------------------------------------
3764 // Returns the line number of the line with the caret.
3765 int wxStyledTextCtrl::GetCurrentLine() {
3766 int line
= LineFromPosition(GetCurrentPos());
3771 // Extract style settings from a spec-string which is composed of one or
3772 // more of the following comma separated elements:
3774 // bold turns on bold
3775 // italic turns on italics
3776 // fore:[name or #RRGGBB] sets the foreground colour
3777 // back:[name or #RRGGBB] sets the background colour
3778 // face:[facename] sets the font face name to use
3779 // size:[num] sets the font size in points
3780 // eol turns on eol filling
3781 // underline turns on underlining
3783 void wxStyledTextCtrl::StyleSetSpec(int styleNum
, const wxString
& spec
) {
3785 wxStringTokenizer
tkz(spec
, wxT(","));
3786 while (tkz
.HasMoreTokens()) {
3787 wxString token
= tkz
.GetNextToken();
3789 wxString option
= token
.BeforeFirst(':');
3790 wxString val
= token
.AfterFirst(':');
3792 if (option
== wxT("bold"))
3793 StyleSetBold(styleNum
, true);
3795 else if (option
== wxT("italic"))
3796 StyleSetItalic(styleNum
, true);
3798 else if (option
== wxT("underline"))
3799 StyleSetUnderline(styleNum
, true);
3801 else if (option
== wxT("eol"))
3802 StyleSetEOLFilled(styleNum
, true);
3804 else if (option
== wxT("size")) {
3806 if (val
.ToLong(&points
))
3807 StyleSetSize(styleNum
, points
);
3810 else if (option
== wxT("face"))
3811 StyleSetFaceName(styleNum
, val
);
3813 else if (option
== wxT("fore"))
3814 StyleSetForeground(styleNum
, wxColourFromSpec(val
));
3816 else if (option
== wxT("back"))
3817 StyleSetBackground(styleNum
, wxColourFromSpec(val
));
3822 // Get the font of a style
3823 wxFont
wxStyledTextCtrl::StyleGetFont(int style
) {
3825 font
.SetPointSize(StyleGetSize(style
));
3826 font
.SetFaceName(StyleGetFaceName(style
));
3827 if( StyleGetBold(style
) )
3828 font
.SetWeight(wxFONTWEIGHT_BOLD
);
3830 font
.SetWeight(wxFONTWEIGHT_NORMAL
);
3832 if( StyleGetItalic(style
) )
3833 font
.SetStyle(wxFONTSTYLE_ITALIC
);
3835 font
.SetStyle(wxFONTSTYLE_NORMAL
);
3841 // Set style size, face, bold, italic, and underline attributes from
3842 // a wxFont's attributes.
3843 void wxStyledTextCtrl::StyleSetFont(int styleNum
, wxFont
& font
) {
3845 // Ensure that the native font is initialized
3847 GetTextExtent(wxT("X"), &x
, &y
, NULL
, NULL
, &font
);
3849 int size
= font
.GetPointSize();
3850 wxString faceName
= font
.GetFaceName();
3851 bool bold
= font
.GetWeight() == wxBOLD
;
3852 bool italic
= font
.GetStyle() != wxNORMAL
;
3853 bool under
= font
.GetUnderlined();
3854 wxFontEncoding encoding
= font
.GetEncoding();
3856 StyleSetFontAttr(styleNum
, size
, faceName
, bold
, italic
, under
, encoding
);
3859 // Set all font style attributes at once.
3860 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum
, int size
,
3861 const wxString
& faceName
,
3862 bool bold
, bool italic
,
3864 wxFontEncoding encoding
) {
3865 StyleSetSize(styleNum
, size
);
3866 StyleSetFaceName(styleNum
, faceName
);
3867 StyleSetBold(styleNum
, bold
);
3868 StyleSetItalic(styleNum
, italic
);
3869 StyleSetUnderline(styleNum
, underline
);
3870 StyleSetFontEncoding(styleNum
, encoding
);
3874 // Set the character set of the font in a style. Converts the Scintilla
3875 // character set values to a wxFontEncoding.
3876 void wxStyledTextCtrl::StyleSetCharacterSet(int style
, int characterSet
)
3878 wxFontEncoding encoding
;
3880 // Translate the Scintilla characterSet to a wxFontEncoding
3881 switch (characterSet
) {
3883 case wxSTC_CHARSET_ANSI
:
3884 case wxSTC_CHARSET_DEFAULT
:
3885 encoding
= wxFONTENCODING_DEFAULT
;
3888 case wxSTC_CHARSET_BALTIC
:
3889 encoding
= wxFONTENCODING_ISO8859_13
;
3892 case wxSTC_CHARSET_CHINESEBIG5
:
3893 encoding
= wxFONTENCODING_CP950
;
3896 case wxSTC_CHARSET_EASTEUROPE
:
3897 encoding
= wxFONTENCODING_ISO8859_2
;
3900 case wxSTC_CHARSET_GB2312
:
3901 encoding
= wxFONTENCODING_CP936
;
3904 case wxSTC_CHARSET_GREEK
:
3905 encoding
= wxFONTENCODING_ISO8859_7
;
3908 case wxSTC_CHARSET_HANGUL
:
3909 encoding
= wxFONTENCODING_CP949
;
3912 case wxSTC_CHARSET_MAC
:
3913 encoding
= wxFONTENCODING_DEFAULT
;
3916 case wxSTC_CHARSET_OEM
:
3917 encoding
= wxFONTENCODING_DEFAULT
;
3920 case wxSTC_CHARSET_RUSSIAN
:
3921 encoding
= wxFONTENCODING_KOI8
;
3924 case wxSTC_CHARSET_SHIFTJIS
:
3925 encoding
= wxFONTENCODING_CP932
;
3928 case wxSTC_CHARSET_SYMBOL
:
3929 encoding
= wxFONTENCODING_DEFAULT
;
3932 case wxSTC_CHARSET_TURKISH
:
3933 encoding
= wxFONTENCODING_ISO8859_9
;
3936 case wxSTC_CHARSET_JOHAB
:
3937 encoding
= wxFONTENCODING_DEFAULT
;
3940 case wxSTC_CHARSET_HEBREW
:
3941 encoding
= wxFONTENCODING_ISO8859_8
;
3944 case wxSTC_CHARSET_ARABIC
:
3945 encoding
= wxFONTENCODING_ISO8859_6
;
3948 case wxSTC_CHARSET_VIETNAMESE
:
3949 encoding
= wxFONTENCODING_DEFAULT
;
3952 case wxSTC_CHARSET_THAI
:
3953 encoding
= wxFONTENCODING_ISO8859_11
;
3956 case wxSTC_CHARSET_CYRILLIC
:
3957 encoding
= wxFONTENCODING_ISO8859_5
;
3960 case wxSTC_CHARSET_8859_15
:
3961 encoding
= wxFONTENCODING_ISO8859_15
;;
3965 // We just have Scintilla track the wxFontEncoding for us. It gets used
3966 // in Font::Create in PlatWX.cpp. We add one to the value so that the
3967 // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
3968 // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
3969 // to wxFONENCODING_DEFAULT in Font::Create.
3970 SendMsg(SCI_STYLESETCHARACTERSET
, style
, encoding
+1);
3974 // Set the font encoding to be used by a style.
3975 void wxStyledTextCtrl::StyleSetFontEncoding(int style
, wxFontEncoding encoding
)
3977 SendMsg(SCI_STYLESETCHARACTERSET
, style
, encoding
+1);
3981 // Perform one of the operations defined by the wxSTC_CMD_* constants.
3982 void wxStyledTextCtrl::CmdKeyExecute(int cmd
) {
3987 // Set the left and right margin in the edit area, measured in pixels.
3988 void wxStyledTextCtrl::SetMargins(int left
, int right
) {
3989 SetMarginLeft(left
);
3990 SetMarginRight(right
);
3994 // Retrieve the point in the window where a position is displayed.
3995 wxPoint
wxStyledTextCtrl::PointFromPosition(int pos
) {
3996 int x
= SendMsg(SCI_POINTXFROMPOSITION
, 0, pos
);
3997 int y
= SendMsg(SCI_POINTYFROMPOSITION
, 0, pos
);
3998 return wxPoint(x
, y
);
4001 // Scroll enough to make the given line visible
4002 void wxStyledTextCtrl::ScrollToLine(int line
) {
4003 m_swx
->DoScrollToLine(line
);
4007 // Scroll enough to make the given column visible
4008 void wxStyledTextCtrl::ScrollToColumn(int column
) {
4009 m_swx
->DoScrollToColumn(column
);
4014 bool wxStyledTextCtrl::DoSaveFile(const wxString
& filename
, int fileType
)
4016 bool ok
= wxTextAreaBase::DoSaveFile(filename
, fileType
);
4018 bool wxStyledTextCtrl::SaveFile(const wxString
& filename
)
4021 wxFFile
file(filename
, wxT("w"));
4022 bool ok
= file
.IsOpened() && file
.Write(GetValue(), *wxConvCurrent
);
4025 #endif // wxUSE_FFILE
4035 bool wxStyledTextCtrl::DoLoadFile(const wxString
& filename
, int fileType
)
4037 bool ok
= wxTextAreaBase::DoLoadFile(filename
, fileType
);
4039 bool wxStyledTextCtrl::LoadFile(const wxString
& filename
)
4042 wxFFile
file(filename
);
4043 bool ok
= file
.IsOpened();
4047 ok
= file
.ReadAll(&text
, *wxConvCurrent
);
4055 #endif // wxUSE_FFILE
4065 #if wxUSE_DRAG_AND_DROP
4066 wxDragResult
wxStyledTextCtrl::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
4067 return m_swx
->DoDragOver(x
, y
, def
);
4071 bool wxStyledTextCtrl::DoDropText(long x
, long y
, const wxString
& data
) {
4072 return m_swx
->DoDropText(x
, y
, data
);
4077 void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA
) {
4078 m_swx
->SetUseAntiAliasing(useAA
);
4081 bool wxStyledTextCtrl::GetUseAntiAliasing() {
4082 return m_swx
->GetUseAntiAliasing();
4089 void wxStyledTextCtrl::AddTextRaw(const char* text
)
4091 SendMsg(SCI_ADDTEXT
, strlen(text
), (sptr_t
)text
);
4094 void wxStyledTextCtrl::InsertTextRaw(int pos
, const char* text
)
4096 SendMsg(SCI_INSERTTEXT
, pos
, (sptr_t
)text
);
4099 wxCharBuffer
wxStyledTextCtrl::GetCurLineRaw(int* linePos
)
4101 int len
= LineLength(GetCurrentLine());
4103 if (linePos
) *linePos
= 0;
4108 wxCharBuffer
buf(len
);
4109 int pos
= SendMsg(SCI_GETCURLINE
, len
, (sptr_t
)buf
.data());
4110 if (linePos
) *linePos
= pos
;
4114 wxCharBuffer
wxStyledTextCtrl::GetLineRaw(int line
)
4116 int len
= LineLength(line
);
4122 wxCharBuffer
buf(len
);
4123 SendMsg(SCI_GETLINE
, line
, (sptr_t
)buf
.data());
4127 wxCharBuffer
wxStyledTextCtrl::GetSelectedTextRaw()
4132 GetSelection(&start
, &end
);
4133 int len
= end
- start
;
4139 wxCharBuffer
buf(len
);
4140 SendMsg(SCI_GETSELTEXT
, 0, (sptr_t
)buf
.data());
4144 wxCharBuffer
wxStyledTextCtrl::GetTextRangeRaw(int startPos
, int endPos
)
4146 if (endPos
< startPos
) {
4147 int temp
= startPos
;
4151 int len
= endPos
- startPos
;
4157 wxCharBuffer
buf(len
);
4159 tr
.lpstrText
= buf
.data();
4160 tr
.chrg
.cpMin
= startPos
;
4161 tr
.chrg
.cpMax
= endPos
;
4162 SendMsg(SCI_GETTEXTRANGE
, 0, (sptr_t
)&tr
);
4166 void wxStyledTextCtrl::SetTextRaw(const char* text
)
4168 SendMsg(SCI_SETTEXT
, 0, (sptr_t
)text
);
4171 wxCharBuffer
wxStyledTextCtrl::GetTextRaw()
4173 int len
= GetTextLength();
4174 wxCharBuffer
buf(len
); // adds 1 for NUL automatically
4175 SendMsg(SCI_GETTEXT
, len
+ 1, (sptr_t
)buf
.data());
4179 void wxStyledTextCtrl::AppendTextRaw(const char* text
)
4181 SendMsg(SCI_APPENDTEXT
, strlen(text
), (sptr_t
)text
);
4188 //----------------------------------------------------------------------
4191 void wxStyledTextCtrl::OnPaint(wxPaintEvent
& WXUNUSED(evt
)) {
4193 m_swx
->DoPaint(&dc
, GetUpdateRegion().GetBox());
4196 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent
& evt
) {
4197 if (evt
.GetOrientation() == wxHORIZONTAL
)
4198 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
4200 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
4203 void wxStyledTextCtrl::OnScroll(wxScrollEvent
& evt
) {
4204 wxScrollBar
* sb
= wxDynamicCast(evt
.GetEventObject(), wxScrollBar
);
4206 if (sb
->IsVertical())
4207 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
4209 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
4213 void wxStyledTextCtrl::OnSize(wxSizeEvent
& WXUNUSED(evt
)) {
4215 wxSize sz
= GetClientSize();
4216 m_swx
->DoSize(sz
.x
, sz
.y
);
4220 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent
& evt
) {
4222 wxPoint pt
= evt
.GetPosition();
4223 m_swx
->DoLeftButtonDown(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
4224 evt
.ShiftDown(), evt
.ControlDown(), evt
.AltDown());
4227 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent
& evt
) {
4228 wxPoint pt
= evt
.GetPosition();
4229 m_swx
->DoLeftButtonMove(Point(pt
.x
, pt
.y
));
4232 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent
& evt
) {
4233 wxPoint pt
= evt
.GetPosition();
4234 m_swx
->DoLeftButtonUp(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
4239 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent
& evt
) {
4240 wxPoint pt
= evt
.GetPosition();
4241 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
4245 void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent
& evt
) {
4246 wxPoint pt
= evt
.GetPosition();
4247 m_swx
->DoMiddleButtonUp(Point(pt
.x
, pt
.y
));
4250 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent
& evt
) {
4251 wxPoint pt
= evt
.GetPosition();
4252 ScreenToClient(&pt
.x
, &pt
.y
);
4254 Show context menu at event point if it's within the window,
4255 or at caret location if not
4257 wxHitTest ht
= this->HitTest(pt
);
4258 if (ht
!= wxHT_WINDOW_INSIDE
) {
4259 pt
= this->PointFromPosition(this->GetCurrentPos());
4261 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
4265 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent
& evt
)
4267 // prevent having an event queue with wheel events that cannot be processed
4268 // reasonably fast (see ticket #9057)
4269 if ( m_lastWheelTimestamp
<= evt
.GetTimestamp() )
4271 m_lastWheelTimestamp
= m_stopWatch
.Time();
4272 m_swx
->DoMouseWheel(evt
.GetWheelRotation(),
4273 evt
.GetWheelDelta(),
4274 evt
.GetLinesPerAction(),
4276 evt
.IsPageScroll());
4277 m_lastWheelTimestamp
= m_stopWatch
.Time() - m_lastWheelTimestamp
;
4278 m_lastWheelTimestamp
+= evt
.GetTimestamp();
4283 void wxStyledTextCtrl::OnChar(wxKeyEvent
& evt
) {
4284 // On (some?) non-US PC keyboards the AltGr key is required to enter some
4285 // common characters. It comes to us as both Alt and Ctrl down so we need
4286 // to let the char through in that case, otherwise if only ctrl or only
4287 // alt let's skip it.
4288 bool ctrl
= evt
.ControlDown();
4290 // On the Mac the Alt key is just a modifier key (like Shift) so we need
4291 // to allow the char events to be processed when Alt is pressed.
4292 // TODO: Should we check MetaDown instead in this case?
4295 bool alt
= evt
.AltDown();
4297 bool skip
= ((ctrl
|| alt
) && ! (ctrl
&& alt
));
4300 // apparently if we don't do this, Unicode keys pressed after non-char
4301 // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989)
4302 if (m_lastKeyDownConsumed
&& evt
.GetUnicodeKey() > 255)
4303 m_lastKeyDownConsumed
= false;
4306 if (!m_lastKeyDownConsumed
&& !skip
) {
4308 int key
= evt
.GetUnicodeKey();
4311 // if the unicode key code is not really a unicode character (it may
4312 // be a function key or etc., the platforms appear to always give us a
4313 // small value in this case) then fallback to the ascii key code but
4314 // don't do anything for function keys or etc.
4316 key
= evt
.GetKeyCode();
4317 keyOk
= (key
<= 127);
4320 m_swx
->DoAddChar(key
);
4324 int key
= evt
.GetKeyCode();
4325 if (key
<= WXK_START
|| key
> WXK_COMMAND
) {
4326 m_swx
->DoAddChar(key
);
4336 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent
& evt
) {
4337 int processed
= m_swx
->DoKeyDown(evt
, &m_lastKeyDownConsumed
);
4338 if (!processed
&& !m_lastKeyDownConsumed
)
4343 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent
& evt
) {
4344 m_swx
->DoLoseFocus();
4349 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent
& evt
) {
4350 m_swx
->DoGainFocus();
4355 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent
& WXUNUSED(evt
)) {
4356 m_swx
->DoSysColourChange();
4360 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent
& WXUNUSED(evt
)) {
4361 // do nothing to help avoid flashing
4366 void wxStyledTextCtrl::OnMenu(wxCommandEvent
& evt
) {
4367 m_swx
->DoCommand(evt
.GetId());
4371 void wxStyledTextCtrl::OnListBox(wxCommandEvent
& WXUNUSED(evt
)) {
4372 m_swx
->DoOnListBox();
4376 void wxStyledTextCtrl::OnIdle(wxIdleEvent
& evt
) {
4377 m_swx
->DoOnIdle(evt
);
4381 wxSize
wxStyledTextCtrl::DoGetBestSize() const
4383 // What would be the best size for a wxSTC?
4384 // Just give a reasonable minimum until something else can be figured out.
4385 return wxSize(200,100);
4389 //----------------------------------------------------------------------
4390 // Turn notifications from Scintilla into events
4393 void wxStyledTextCtrl::NotifyChange() {
4394 wxStyledTextEvent
evt(wxEVT_STC_CHANGE
, GetId());
4395 evt
.SetEventObject(this);
4396 GetEventHandler()->ProcessEvent(evt
);
4400 static void SetEventText(wxStyledTextEvent
& evt
, const char* text
,
4404 evt
.SetText(stc2wx(text
, length
));
4408 void wxStyledTextCtrl::NotifyParent(SCNotification
* _scn
) {
4409 SCNotification
& scn
= *_scn
;
4410 wxStyledTextEvent
evt(0, GetId());
4412 evt
.SetEventObject(this);
4413 evt
.SetPosition(scn
.position
);
4415 evt
.SetModifiers(scn
.modifiers
);
4417 switch (scn
.nmhdr
.code
) {
4418 case SCN_STYLENEEDED
:
4419 evt
.SetEventType(wxEVT_STC_STYLENEEDED
);
4423 evt
.SetEventType(wxEVT_STC_CHARADDED
);
4426 case SCN_SAVEPOINTREACHED
:
4427 evt
.SetEventType(wxEVT_STC_SAVEPOINTREACHED
);
4430 case SCN_SAVEPOINTLEFT
:
4431 evt
.SetEventType(wxEVT_STC_SAVEPOINTLEFT
);
4434 case SCN_MODIFYATTEMPTRO
:
4435 evt
.SetEventType(wxEVT_STC_ROMODIFYATTEMPT
);
4439 evt
.SetEventType(wxEVT_STC_KEY
);
4442 case SCN_DOUBLECLICK
:
4443 evt
.SetEventType(wxEVT_STC_DOUBLECLICK
);
4447 evt
.SetEventType(wxEVT_STC_UPDATEUI
);
4451 evt
.SetEventType(wxEVT_STC_MODIFIED
);
4452 evt
.SetModificationType(scn
.modificationType
);
4453 SetEventText(evt
, scn
.text
, scn
.length
);
4454 evt
.SetLength(scn
.length
);
4455 evt
.SetLinesAdded(scn
.linesAdded
);
4456 evt
.SetLine(scn
.line
);
4457 evt
.SetFoldLevelNow(scn
.foldLevelNow
);
4458 evt
.SetFoldLevelPrev(scn
.foldLevelPrev
);
4461 case SCN_MACRORECORD
:
4462 evt
.SetEventType(wxEVT_STC_MACRORECORD
);
4463 evt
.SetMessage(scn
.message
);
4464 evt
.SetWParam(scn
.wParam
);
4465 evt
.SetLParam(scn
.lParam
);
4468 case SCN_MARGINCLICK
:
4469 evt
.SetEventType(wxEVT_STC_MARGINCLICK
);
4470 evt
.SetMargin(scn
.margin
);
4474 evt
.SetEventType(wxEVT_STC_NEEDSHOWN
);
4475 evt
.SetLength(scn
.length
);
4479 evt
.SetEventType(wxEVT_STC_PAINTED
);
4482 case SCN_AUTOCSELECTION
:
4483 evt
.SetEventType(wxEVT_STC_AUTOCOMP_SELECTION
);
4484 evt
.SetListType(scn
.listType
);
4485 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
4486 evt
.SetPosition(scn
.lParam
);
4489 case SCN_USERLISTSELECTION
:
4490 evt
.SetEventType(wxEVT_STC_USERLISTSELECTION
);
4491 evt
.SetListType(scn
.listType
);
4492 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
4493 evt
.SetPosition(scn
.lParam
);
4496 case SCN_URIDROPPED
:
4497 evt
.SetEventType(wxEVT_STC_URIDROPPED
);
4498 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
4501 case SCN_DWELLSTART
:
4502 evt
.SetEventType(wxEVT_STC_DWELLSTART
);
4508 evt
.SetEventType(wxEVT_STC_DWELLEND
);
4514 evt
.SetEventType(wxEVT_STC_ZOOM
);
4517 case SCN_HOTSPOTCLICK
:
4518 evt
.SetEventType(wxEVT_STC_HOTSPOT_CLICK
);
4521 case SCN_HOTSPOTDOUBLECLICK
:
4522 evt
.SetEventType(wxEVT_STC_HOTSPOT_DCLICK
);
4525 case SCN_CALLTIPCLICK
:
4526 evt
.SetEventType(wxEVT_STC_CALLTIP_CLICK
);
4529 case SCN_INDICATORCLICK
:
4530 evt
.SetEventType(wxEVT_STC_INDICATOR_CLICK
);
4533 case SCN_INDICATORRELEASE
:
4534 evt
.SetEventType(wxEVT_STC_INDICATOR_RELEASE
);
4537 case SCN_AUTOCCANCELLED
:
4538 evt
.SetEventType(wxEVT_STC_AUTOCOMP_CANCELLED
);
4541 case SCN_AUTOCCHARDELETED
:
4542 evt
.SetEventType(wxEVT_STC_AUTOCOMP_CHAR_DELETED
);
4549 GetEventHandler()->ProcessEvent(evt
);
4553 //----------------------------------------------------------------------
4554 //----------------------------------------------------------------------
4555 //----------------------------------------------------------------------
4557 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType
, int id
)
4558 : wxCommandEvent(commandType
, id
)
4563 m_modificationType
= 0;
4568 m_foldLevelPrev
= 0;
4576 #if wxUSE_DRAG_AND_DROP
4577 m_dragFlags
= wxDrag_CopyOnly
;
4578 m_dragResult
= wxDragNone
;
4582 bool wxStyledTextEvent::GetShift() const { return (m_modifiers
& SCI_SHIFT
) != 0; }
4583 bool wxStyledTextEvent::GetControl() const { return (m_modifiers
& SCI_CTRL
) != 0; }
4584 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers
& SCI_ALT
) != 0; }
4587 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent
& event
):
4588 wxCommandEvent(event
)
4590 m_position
= event
.m_position
;
4591 m_key
= event
.m_key
;
4592 m_modifiers
= event
.m_modifiers
;
4593 m_modificationType
= event
.m_modificationType
;
4594 m_text
= event
.m_text
;
4595 m_length
= event
.m_length
;
4596 m_linesAdded
= event
.m_linesAdded
;
4597 m_line
= event
.m_line
;
4598 m_foldLevelNow
= event
.m_foldLevelNow
;
4599 m_foldLevelPrev
= event
.m_foldLevelPrev
;
4601 m_margin
= event
.m_margin
;
4603 m_message
= event
.m_message
;
4604 m_wParam
= event
.m_wParam
;
4605 m_lParam
= event
.m_lParam
;
4607 m_listType
= event
.m_listType
;
4611 #if wxUSE_DRAG_AND_DROP
4612 m_dragText
= event
.m_dragText
;
4613 m_dragFlags
= event
.m_dragFlags
;
4614 m_dragResult
= event
.m_dragResult
;
4618 //----------------------------------------------------------------------
4619 //----------------------------------------------------------------------
4621 /*static*/ wxVersionInfo
wxStyledTextCtrl::GetLibraryVersionInfo()
4623 return wxVersionInfo("Scintilla", 2, 3, 0, "Scintilla 2.03");