X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3c7789014106c9269b0f4ecc1a3071b14f351d3f..06a32e049c1bad9249079ad2e91659303424a774:/src/stc/stc.cpp?ds=sidebyside diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 5c179adc5b..c9b08e945c 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -12,7 +12,7 @@ // Created: 13-Jan-2000 // RCS-ID: $Id$ // Copyright: (c) 2000 by Total Control Software -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// /* @@ -47,7 +47,15 @@ #include "wx/tokenzr.h" #include "wx/mstream.h" #include "wx/image.h" -#include "wx/file.h" +#if wxUSE_FFILE + #include "wx/ffile.h" +#elif wxUSE_FILE + #include "wx/ffile.h" +#endif + +#ifdef __WXGTK__ + #include "wx/dcbuffer.h" +#endif #include "ScintillaWX.h" @@ -96,34 +104,37 @@ static wxColour wxColourFromSpec(const wxString& spec) { //---------------------------------------------------------------------- -wxDEFINE_EVENT( wxEVT_STC_CHANGE, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_STYLENEEDED, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_CHARADDED, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTREACHED, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTLEFT, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_ROMODIFYATTEMPT, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_KEY, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_DOUBLECLICK, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_UPDATEUI, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_MODIFIED, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_MACRORECORD, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_MARGINCLICK, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_NEEDSHOWN, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_PAINTED, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_USERLISTSELECTION, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_URIDROPPED, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_DWELLSTART, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_DWELLEND, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_START_DRAG, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_DRAG_OVER, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_DO_DROP, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_ZOOM, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_CLICK, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_DCLICK, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_CALLTIP_CLICK, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_SELECTION, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_INDICATOR_CLICK, wxStyledTextEvent ) -wxDEFINE_EVENT( wxEVT_STC_INDICATOR_RELEASE, wxStyledTextEvent ) +wxDEFINE_EVENT( wxEVT_STC_CHANGE, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_STYLENEEDED, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_CHARADDED, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTREACHED, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTLEFT, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_ROMODIFYATTEMPT, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_KEY, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_DOUBLECLICK, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_UPDATEUI, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_MODIFIED, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_MACRORECORD, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_MARGINCLICK, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_NEEDSHOWN, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_PAINTED, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_USERLISTSELECTION, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_URIDROPPED, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_DWELLSTART, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_DWELLEND, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_START_DRAG, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_DRAG_OVER, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_DO_DROP, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_ZOOM, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_CLICK, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_DCLICK, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_CALLTIP_CLICK, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_SELECTION, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_INDICATOR_CLICK, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_INDICATOR_RELEASE, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CANCELLED, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CHAR_DELETED, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_RELEASE_CLICK, wxStyledTextEvent ); @@ -197,7 +208,6 @@ bool wxStyledTextCtrl::Create(wxWindow *parent, m_swx = new ScintillaWX(this); m_stopWatch.Start(); m_lastKeyDownConsumed = false; - m_lastWheelTimestamp = 0; m_vScrollBar = NULL; m_hScrollBar = NULL; #if wxUSE_UNICODE @@ -208,7 +218,7 @@ bool wxStyledTextCtrl::Create(wxWindow *parent, SetInitialSize(size); // Reduces flicker on GTK+/X11 - SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundStyle(wxBG_STYLE_PAINT); // Make sure it can take the focus SetCanFocus(true); @@ -256,8 +266,8 @@ void wxStyledTextCtrl::SetHScrollBar(wxScrollBar* bar) { // Add text to the document at current position. void wxStyledTextCtrl::AddText(const wxString& text) { - wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); - SendMsg(2001, strlen(buf), (sptr_t)(const char*)buf); + const wxWX2MBbuf buf = wx2stc(text); + SendMsg(2001, wx2stclen(text, buf), (sptr_t)(const char*)buf); } // Add array of cells to document. @@ -277,13 +287,19 @@ void wxStyledTextCtrl::ClearAll() SendMsg(2004, 0, 0); } +// Delete a range of text in the document. +void wxStyledTextCtrl::DeleteRange(int pos, int deleteLength) +{ + SendMsg(2645, pos, deleteLength); +} + // Set all style bytes to 0, remove all folding information. void wxStyledTextCtrl::ClearDocumentStyle() { SendMsg(2005, 0, 0); } -// Returns the number of characters in the document. +// Returns the number of bytes in the document. int wxStyledTextCtrl::GetLength() const { return SendMsg(2006, 0, 0); @@ -525,9 +541,9 @@ void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol, const wxColour& background) { SendMsg(2040, markerNumber, markerSymbol); - if (foreground.Ok()) + if (foreground.IsOk()) MarkerSetForeground(markerNumber, foreground); - if (background.Ok()) + if (background.IsOk()) MarkerSetBackground(markerNumber, background); } @@ -543,6 +559,18 @@ void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& bac SendMsg(2042, markerNumber, wxColourAsLong(back)); } +// Set the background colour used for a particular marker number when its folding block is selected. +void wxStyledTextCtrl::MarkerSetBackgroundSelected(int markerNumber, const wxColour& back) +{ + SendMsg(2292, markerNumber, wxColourAsLong(back)); +} + +// Enable/disable highlight for current folding bloc (smallest one that contains the caret) +void wxStyledTextCtrl::MarkerEnableHighlight(bool enabled) +{ + SendMsg(2293, enabled, 0); +} + // Add a marker to a line, returning an ID which can be used to find or delete the marker. int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) { @@ -567,7 +595,8 @@ int wxStyledTextCtrl::MarkerGet(int line) return SendMsg(2046, line, 0); } -// Find the next line after lineStart that includes a marker in mask. +// Find the next line at or after lineStart that includes a marker in mask. +// Return -1 when no more lines. int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask) { return SendMsg(2047, lineStart, markerMask); @@ -656,6 +685,18 @@ bool wxStyledTextCtrl::GetMarginSensitive(int margin) const return SendMsg(2247, margin, 0) != 0; } +// Set the cursor shown when the mouse is inside a margin. +void wxStyledTextCtrl::SetMarginCursor(int margin, int cursor) +{ + SendMsg(2248, margin, cursor); +} + +// Retrieve the cursor shown in a margin. +int wxStyledTextCtrl::GetMarginCursor(int margin) const +{ + return SendMsg(2249, margin, 0); +} + // Clear all the styles and make equivalent to the global default style. void wxStyledTextCtrl::StyleClearAll() { @@ -809,19 +850,43 @@ void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) SendMsg(2060, style, caseForce); } +// Set the size of characters of a style. Size is in points multiplied by 100. +void wxStyledTextCtrl::StyleSetSizeFractional(int style, int caseForce) +{ + SendMsg(2061, style, caseForce); +} + +// Get the size of characters of a style in points multiplied by 100 +int wxStyledTextCtrl::StyleGetSizeFractional(int style) const +{ + return SendMsg(2062, style, 0); +} + +// Set the weight of characters of a style. +void wxStyledTextCtrl::StyleSetWeight(int style, int weight) +{ + SendMsg(2063, style, weight); +} + +// Get the weight of characters of a style. +int wxStyledTextCtrl::StyleGetWeight(int style) const +{ + return SendMsg(2064, style, 0); +} + // Set a style to be a hotspot or not. void wxStyledTextCtrl::StyleSetHotSpot(int style, bool hotspot) { SendMsg(2409, style, hotspot); } -// Set the foreground colour of the selection and whether to use this setting. +// Set the foreground colour of the main and additional selections and whether to use this setting. void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) { SendMsg(2067, useSetting, wxColourAsLong(fore)); } -// Set the background colour of the selection and whether to use this setting. +// Set the background colour of the main and additional selections and whether to use this setting. void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back) { SendMsg(2068, useSetting, wxColourAsLong(back)); @@ -897,12 +962,26 @@ void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) } // Set the set of characters making up words for when moving or selecting by word. -// First sets deaults like SetCharsDefault. +// First sets defaults like SetCharsDefault. void wxStyledTextCtrl::SetWordChars(const wxString& characters) { SendMsg(2077, 0, (sptr_t)(const char*)wx2stc(characters)); } +// Get the set of characters making up words for when moving or selecting by word. +wxString wxStyledTextCtrl::GetWordChars() const { + int msg = 2646; + int len = SendMsg(msg, 0, (sptr_t)NULL); + if (!len) return wxEmptyString; + + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(msg, 0, (sptr_t)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf); +} + // Start a sequence of actions that is undone and redone as a unit. // May be nested. void wxStyledTextCtrl::BeginUndoAction() @@ -965,6 +1044,18 @@ void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting, const wxColour& SendMsg(2085, useSetting, wxColourAsLong(back)); } +// Set the size of the dots used to mark space characters. +void wxStyledTextCtrl::SetWhitespaceSize(int size) +{ + SendMsg(2086, size, 0); +} + +// Get the size of the dots used to mark space characters. +int wxStyledTextCtrl::GetWhitespaceSize() const +{ + return SendMsg(2087, 0, 0); +} + // Divide each styling byte into lexical class bits (default: 5) and indicator // bits (default: 3). If a lexer requires more than 32 lexical states, then this // is used to expand the possible states. @@ -1273,6 +1364,12 @@ int wxStyledTextCtrl::GetColumn(int pos) const return SendMsg(2129, pos, 0); } +// Count characters between two positions. +int wxStyledTextCtrl::CountCharacters(int startPos, int endPos) +{ + return SendMsg(2633, startPos, endPos); +} + // Show or hide the horizontal scroll bar. void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show) { @@ -1365,6 +1462,12 @@ int wxStyledTextCtrl::GetSelectionEnd() const return SendMsg(2145, 0, 0); } +// Set caret to a position, while removing any existing selection. +void wxStyledTextCtrl::SetEmptySelection(int pos) +{ + SendMsg(2556, pos, 0); +} + // Sets the print magnification added to the point size of each style for printing. void wxStyledTextCtrl::SetPrintMagnification(int magnification) { @@ -1396,7 +1499,7 @@ int wxStyledTextCtrl::FindText(int minPos, int maxPos, TextToFind ft; ft.chrg.cpMin = minPos; ft.chrg.cpMax = maxPos; - wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); + const wxWX2MBbuf buf = wx2stc(text); ft.lpstrText = (char*)(const char*)buf; return SendMsg(2150, flags, (sptr_t)&ft); @@ -1490,11 +1593,7 @@ bool wxStyledTextCtrl::GetModify() const // Retrieve the selected text. wxString wxStyledTextCtrl::GetSelectedText() { - long start; - long end; - - GetSelection(&start, &end); - int len = end - start; + const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0); if (!len) return wxEmptyString; wxMemoryBuffer mbuf(len+2); @@ -1694,8 +1793,8 @@ int wxStyledTextCtrl::GetTargetEnd() const // Returns the length of the replacement text. int wxStyledTextCtrl::ReplaceTarget(const wxString& text) { - wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); - return SendMsg(2194, strlen(buf), (sptr_t)(const char*)buf); + const wxWX2MBbuf buf = wx2stc(text); + return SendMsg(2194, wx2stclen(text, buf), (sptr_t)(const char*)buf); } // Replace the target text with the argument text after \d processing. @@ -1706,8 +1805,8 @@ int wxStyledTextCtrl::GetTargetEnd() const // caused by processing the \d patterns. int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) { - wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); - return SendMsg(2195, strlen(buf), (sptr_t)(const char*)buf); + const wxWX2MBbuf buf = wx2stc(text); + return SendMsg(2195, wx2stclen(text, buf), (sptr_t)(const char*)buf); } // Search for a counted string in the target and set the target to the found @@ -1715,8 +1814,8 @@ int wxStyledTextCtrl::GetTargetEnd() const // Returns length of range or -1 for failure in which case target is not moved. int wxStyledTextCtrl::SearchInTarget(const wxString& text) { - wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); - return SendMsg(2197, strlen(buf), (sptr_t)(const char*)buf); + const wxWX2MBbuf buf = wx2stc(text); + return SendMsg(2197, wx2stclen(text, buf), (sptr_t)(const char*)buf); } // Set the search flags used by SearchInTarget. @@ -1785,6 +1884,12 @@ void wxStyledTextCtrl::CallTipUseStyle(int tabSize) SendMsg(2212, tabSize, 0); } +// Set position of calltip, above or below text. +void wxStyledTextCtrl::CallTipSetPosition(bool above) +{ + SendMsg(2213, above, 0); +} + // Find the display line of a document line taking hidden lines into account. int wxStyledTextCtrl::VisibleFromDocLine(int line) { @@ -1847,6 +1952,12 @@ bool wxStyledTextCtrl::GetLineVisible(int line) const return SendMsg(2228, line, 0) != 0; } +// Are all lines visible? +bool wxStyledTextCtrl::GetAllLinesVisible() const +{ + return SendMsg(2236, 0, 0) != 0; +} + // Show the children of a header line. void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded) { @@ -1980,6 +2091,18 @@ int wxStyledTextCtrl::GetWrapStartIndent() const return SendMsg(2465, 0, 0); } +// Sets how wrapped sublines are placed. Default is fixed. +void wxStyledTextCtrl::SetWrapIndentMode(int mode) +{ + SendMsg(2472, mode, 0); +} + +// Retrieve how wrapped sublines are placed. Default is fixed. +int wxStyledTextCtrl::GetWrapIndentMode() const +{ + return SendMsg(2473, 0, 0); +} + // Sets the degree of caching of layout information. void wxStyledTextCtrl::SetLayoutCache(int mode) { @@ -2059,8 +2182,8 @@ bool wxStyledTextCtrl::GetUseVerticalScrollBar() const // Append a string to the end of the document without changing the selection. void wxStyledTextCtrl::AppendText(const wxString& text) { - wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); - SendMsg(2282, strlen(buf), (sptr_t)(const char*)buf); + const wxWX2MBbuf buf = wx2stc(text); + SendMsg(2282, wx2stclen(text, buf), (sptr_t)(const char*)buf); } // Is drawing done in two phases with backgrounds drawn before foregrounds? @@ -2076,6 +2199,38 @@ void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase) SendMsg(2284, twoPhase, 0); } +// Scroll so that a display line is at the top of the display. +void wxStyledTextCtrl::SetFirstVisibleLine(int lineDisplay) +{ + SendMsg(2613, lineDisplay, 0); +} + +// Change the effect of pasting when there are multiple selections. +void wxStyledTextCtrl::SetMultiPaste(int multiPaste) +{ + SendMsg(2614, multiPaste, 0); +} + +// Retrieve the effect of pasting when there are multiple selections.. +int wxStyledTextCtrl::GetMultiPaste() const +{ + return SendMsg(2615, 0, 0); +} + +// Retrieve the value of a tag from a regular expression search. +wxString wxStyledTextCtrl::GetTag(int tagNumber) const { + int msg = 2616; + int len = SendMsg(msg, tagNumber, (sptr_t)NULL); + if (!len) return wxEmptyString; + + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(msg, tagNumber, (sptr_t)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf); +} + // Make the target range start and end be the same as the selection range start and end. void wxStyledTextCtrl::TargetFromSelection() { @@ -2458,7 +2613,7 @@ void wxStyledTextCtrl::MoveCaretInsideView() SendMsg(2401, 0, 0); } -// How many characters are on a line, not including end of line characters? +// How many characters are on a line, including end of line characters? int wxStyledTextCtrl::LineLength(int line) const { return SendMsg(2350, line, 0); @@ -2470,12 +2625,24 @@ void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2) SendMsg(2351, pos1, pos2); } +// Use specified indicator to highlight matching braces instead of changing their style. +void wxStyledTextCtrl::BraceHighlightIndicator(bool useBraceHighlightIndicator, int indicator) +{ + SendMsg(2498, useBraceHighlightIndicator, indicator); +} + // Highlight the character at a position indicating there is no matching brace. void wxStyledTextCtrl::BraceBadLight(int pos) { SendMsg(2352, pos, 0); } +// Use specified indicator to highlight non matching brace instead of changing its style. +void wxStyledTextCtrl::BraceBadLightIndicator(bool useBraceBadLightIndicator, int indicator) +{ + SendMsg(2499, useBraceBadLightIndicator, indicator); +} + // Find the position of a matching brace or INVALID_POSITION if no match. int wxStyledTextCtrl::BraceMatch(int pos) { @@ -2729,7 +2896,7 @@ void wxStyledTextCtrl::DelLineRight() SendMsg(2396, 0, 0); } -// Get and Set the xOffset (ie, horizonal scroll position). +// Get and Set the xOffset (ie, horizontal scroll position). void wxStyledTextCtrl::SetXOffset(int newOffset) { SendMsg(2397, newOffset, 0); @@ -2745,7 +2912,7 @@ void wxStyledTextCtrl::ChooseCaretX() SendMsg(2399, 0, 0); } -// Set the way the caret is kept visible when going sideway. +// Set the way the caret is kept visible when going sideways. // The exclusion zone is given in pixels. void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy, int caretSlop) { @@ -2865,7 +3032,7 @@ void wxStyledTextCtrl::CopyText(int length, const wxString& text) SendMsg(2420, length, (sptr_t)(const char*)wx2stc(text)); } -// Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or +// Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE/SC_SEL_THIN) or // by lines (SC_SEL_LINES). void wxStyledTextCtrl::SetSelectionMode(int mode) { @@ -3001,6 +3168,41 @@ void wxStyledTextCtrl::SetWhitespaceChars(const wxString& characters) SendMsg(2443, 0, (sptr_t)(const char*)wx2stc(characters)); } +// Get the set of characters making up whitespace for when moving or selecting by word. +wxString wxStyledTextCtrl::GetWhitespaceChars() const { + int msg = 2647; + int len = SendMsg(msg, 0, (sptr_t)NULL); + if (!len) return wxEmptyString; + + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(msg, 0, (sptr_t)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf); +} + +// Set the set of characters making up punctuation characters +// Should be called after SetWordChars. +void wxStyledTextCtrl::SetPunctuationChars(const wxString& characters) +{ + SendMsg(2648, 0, (sptr_t)(const char*)wx2stc(characters)); +} + +// Get the set of characters making up punctuation characters +wxString wxStyledTextCtrl::GetPunctuationChars() const { + int msg = 2649; + int len = SendMsg(msg, 0, (sptr_t)NULL); + if (!len) return wxEmptyString; + + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(msg, 0, (sptr_t)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf); +} + // Reset the set of characters for whitespace and word characters to the defaults. void wxStyledTextCtrl::SetCharsDefault() { @@ -3008,11 +3210,23 @@ void wxStyledTextCtrl::SetCharsDefault() } // Get currently selected item position in the auto-completion list -int wxStyledTextCtrl::AutoCompGetCurrent() +int wxStyledTextCtrl::AutoCompGetCurrent() const { return SendMsg(2445, 0, 0); } +// Set auto-completion case insensitive behaviour to either prefer case-sensitive matches or have no preference. +void wxStyledTextCtrl::AutoCompSetCaseInsensitiveBehaviour(int behaviour) +{ + SendMsg(2634, behaviour, 0); +} + +// Get auto-completion case insensitive behaviour. +int wxStyledTextCtrl::AutoCompGetCaseInsensitiveBehaviour() const +{ + return SendMsg(2635, 0, 0); +} + // Enlarge the document to a particular size of text bytes. void wxStyledTextCtrl::Allocate(int bytes) { @@ -3027,13 +3241,13 @@ int wxStyledTextCtrl::FindColumn(int line, int column) } // Can the caret preferred x position only be changed by explicit movement commands? -bool wxStyledTextCtrl::GetCaretSticky() const +int wxStyledTextCtrl::GetCaretSticky() const { - return SendMsg(2457, 0, 0) != 0; + return SendMsg(2457, 0, 0); } // Stop the caret preferred x position changing when the user types. -void wxStyledTextCtrl::SetCaretSticky(bool useCaretStickyBehaviour) +void wxStyledTextCtrl::SetCaretSticky(int useCaretStickyBehaviour) { SendMsg(2458, useCaretStickyBehaviour, 0); } @@ -3104,7 +3318,7 @@ void wxStyledTextCtrl::SetIndicatorValue(int value) SendMsg(2502, value, 0); } -// Get the current indicator vaue +// Get the current indicator value int wxStyledTextCtrl::GetIndicatorValue() const { return SendMsg(2503, 0, 0); @@ -3158,146 +3372,813 @@ int wxStyledTextCtrl::GetPositionCacheSize() const return SendMsg(2515, 0, 0); } -// Start notifying the container of all key presses and commands. -void wxStyledTextCtrl::StartRecord() +// Copy the selection, if selection empty copy the line with the caret +void wxStyledTextCtrl::CopyAllowLine() { - SendMsg(3001, 0, 0); + SendMsg(2519, 0, 0); } -// Stop notifying the container of all key presses and commands. -void wxStyledTextCtrl::StopRecord() +// Compact the document buffer and return a read-only pointer to the +// characters in the document. +const char* wxStyledTextCtrl::GetCharacterPointer() const { + return (const char*)SendMsg(2520, 0, 0); +} + +// Return a read-only pointer to a range of characters in the document. +// May move the gap so that the range is contiguous, but will only move up +// to rangeLength bytes. +const char* wxStyledTextCtrl::GetRangePointer(int position, int rangeLength) const { + return (const char*)SendMsg(2643, position, rangeLength); +} + +// Return a position which, to avoid performance costs, should not be within +// the range of a call to GetRangePointer. +int wxStyledTextCtrl::GetGapPosition() const { - SendMsg(3002, 0, 0); + return SendMsg(2644, 0, 0); } -// Set the lexing language of the document. -void wxStyledTextCtrl::SetLexer(int lexer) +// Always interpret keyboard input as Unicode +void wxStyledTextCtrl::SetKeysUnicode(bool keysUnicode) { - SendMsg(4001, lexer, 0); + SendMsg(2521, keysUnicode, 0); } -// Retrieve the lexing language of the document. -int wxStyledTextCtrl::GetLexer() const +// Are keys always interpreted as Unicode? +bool wxStyledTextCtrl::GetKeysUnicode() const { - return SendMsg(4002, 0, 0); + return SendMsg(2522, 0, 0) != 0; } -// Colourise a segment of the document using the current lexing language. -void wxStyledTextCtrl::Colourise(int start, int end) +// Set the alpha fill colour of the given indicator. +void wxStyledTextCtrl::IndicatorSetAlpha(int indicator, int alpha) { - SendMsg(4003, start, end); + SendMsg(2523, indicator, alpha); } -// Set up a value that may be used by a lexer for some optional feature. -void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) +// Get the alpha fill colour of the given indicator. +int wxStyledTextCtrl::IndicatorGetAlpha(int indicator) const { - SendMsg(4004, (sptr_t)(const char*)wx2stc(key), (sptr_t)(const char*)wx2stc(value)); + return SendMsg(2524, indicator, 0); } -// Set up the key words used by the lexer. -void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) +// Set the alpha outline colour of the given indicator. +void wxStyledTextCtrl::IndicatorSetOutlineAlpha(int indicator, int alpha) { - SendMsg(4005, keywordSet, (sptr_t)(const char*)wx2stc(keyWords)); + SendMsg(2558, indicator, alpha); } -// Set the lexing language of the document based on string name. -void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) +// Get the alpha outline colour of the given indicator. +int wxStyledTextCtrl::IndicatorGetOutlineAlpha(int indicator) const { - SendMsg(4006, 0, (sptr_t)(const char*)wx2stc(language)); + return SendMsg(2559, indicator, 0); } -// Retrieve a 'property' value previously set with SetProperty. -wxString wxStyledTextCtrl::GetProperty(const wxString& key) { - int len = SendMsg(SCI_GETPROPERTY, (sptr_t)(const char*)wx2stc(key), 0); - if (!len) return wxEmptyString; +// Set extra ascent for each line +void wxStyledTextCtrl::SetExtraAscent(int extraAscent) +{ + SendMsg(2525, extraAscent, 0); +} + +// Get extra ascent for each line +int wxStyledTextCtrl::GetExtraAscent() const +{ + return SendMsg(2526, 0, 0); +} + +// Set extra descent for each line +void wxStyledTextCtrl::SetExtraDescent(int extraDescent) +{ + SendMsg(2527, extraDescent, 0); +} + +// Get extra descent for each line +int wxStyledTextCtrl::GetExtraDescent() const +{ + return SendMsg(2528, 0, 0); +} + +// Which symbol was defined for markerNumber with MarkerDefine +int wxStyledTextCtrl::GetMarkerSymbolDefined(int markerNumber) +{ + return SendMsg(2529, markerNumber, 0); +} + +// Set the text in the text margin for a line +void wxStyledTextCtrl::MarginSetText(int line, const wxString& text) +{ + SendMsg(2530, line, (sptr_t)(const char*)wx2stc(text)); +} + +// Get the text in the text margin for a line +wxString wxStyledTextCtrl::MarginGetText(int line) const { + long msg = 2531; + long len = SendMsg(msg, line, 0); wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len+1); - SendMsg(4008, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf); + SendMsg(msg, line, (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); } -// Retrieve a 'property' value previously set with SetProperty, -// with '$()' variable replacement on returned buffer. -wxString wxStyledTextCtrl::GetPropertyExpanded(const wxString& key) { - int len = SendMsg(SCI_GETPROPERTYEXPANDED, (uptr_t)(const char*)wx2stc(key), 0); - if (!len) return wxEmptyString; +// Set the style number for the text margin for a line +void wxStyledTextCtrl::MarginSetStyle(int line, int style) +{ + SendMsg(2532, line, style); +} + +// Get the style number for the text margin for a line +int wxStyledTextCtrl::MarginGetStyle(int line) const +{ + return SendMsg(2533, line, 0); +} + +// Set the style in the text margin for a line +void wxStyledTextCtrl::MarginSetStyles(int line, const wxString& styles) +{ + SendMsg(2534, line, (sptr_t)(const char*)wx2stc(styles)); +} + +// Get the styles in the text margin for a line +wxString wxStyledTextCtrl::MarginGetStyles(int line) const { + long msg = 2535; + long len = SendMsg(msg, line, 0); wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len+1); - SendMsg(4009, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf); + SendMsg(msg, line, (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); } -// Retrieve a 'property' value previously set with SetProperty, -// interpreted as an int AFTER any '$()' variable replacement. -int wxStyledTextCtrl::GetPropertyInt(const wxString& key) const +// Clear the margin text on all lines +void wxStyledTextCtrl::MarginTextClearAll() { - return SendMsg(4010, (sptr_t)(const char*)wx2stc(key), 0); + SendMsg(2536, 0, 0); } -// Retrieve the number of bits the current lexer needs for styling. -int wxStyledTextCtrl::GetStyleBitsNeeded() const +// Get the start of the range of style numbers used for margin text +void wxStyledTextCtrl::MarginSetStyleOffset(int style) { - return SendMsg(4011, 0, 0); + SendMsg(2537, style, 0); } -//}}} -//---------------------------------------------------------------------- +// Get the start of the range of style numbers used for margin text +int wxStyledTextCtrl::MarginGetStyleOffset() const +{ + return SendMsg(2538, 0, 0); +} +// Set the margin options. +void wxStyledTextCtrl::SetMarginOptions(int marginOptions) +{ + SendMsg(2539, marginOptions, 0); +} -// Returns the line number of the line with the caret. -int wxStyledTextCtrl::GetCurrentLine() { - int line = LineFromPosition(GetCurrentPos()); - return line; +// Get the margin options. +int wxStyledTextCtrl::GetMarginOptions() const +{ + return SendMsg(2557, 0, 0); } +// Set the annotation text for a line +void wxStyledTextCtrl::AnnotationSetText(int line, const wxString& text) +{ + SendMsg(2540, line, (sptr_t)(const char*)wx2stc(text)); +} -// Extract style settings from a spec-string which is composed of one or -// more of the following comma separated elements: -// -// bold turns on bold -// italic turns on italics -// fore:[name or #RRGGBB] sets the foreground colour -// back:[name or #RRGGBB] sets the background colour -// face:[facename] sets the font face name to use -// size:[num] sets the font size in points -// eol turns on eol filling -// underline turns on underlining -// -void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) { +// Get the annotation text for a line +wxString wxStyledTextCtrl::AnnotationGetText(int line) const { + long msg = 2541; + long len = SendMsg(msg, line, 0); - wxStringTokenizer tkz(spec, wxT(",")); - while (tkz.HasMoreTokens()) { - wxString token = tkz.GetNextToken(); + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(msg, line, (sptr_t)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf); +} - wxString option = token.BeforeFirst(':'); - wxString val = token.AfterFirst(':'); +// Set the style number for the annotations for a line +void wxStyledTextCtrl::AnnotationSetStyle(int line, int style) +{ + SendMsg(2542, line, style); +} - if (option == wxT("bold")) - StyleSetBold(styleNum, true); +// Get the style number for the annotations for a line +int wxStyledTextCtrl::AnnotationGetStyle(int line) const +{ + return SendMsg(2543, line, 0); +} - else if (option == wxT("italic")) - StyleSetItalic(styleNum, true); +// Set the annotation styles for a line +void wxStyledTextCtrl::AnnotationSetStyles(int line, const wxString& styles) +{ + SendMsg(2544, line, (sptr_t)(const char*)wx2stc(styles)); +} - else if (option == wxT("underline")) - StyleSetUnderline(styleNum, true); +// Get the annotation styles for a line +wxString wxStyledTextCtrl::AnnotationGetStyles(int line) const { + long msg = 2545; + long len = SendMsg(msg, line, 0); - else if (option == wxT("eol")) - StyleSetEOLFilled(styleNum, true); + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(msg, line, (sptr_t)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf); +} - else if (option == wxT("size")) { - long points; - if (val.ToLong(&points)) - StyleSetSize(styleNum, points); - } +// Get the number of annotation lines for a line +int wxStyledTextCtrl::AnnotationGetLines(int line) const +{ + return SendMsg(2546, line, 0); +} - else if (option == wxT("face")) - StyleSetFaceName(styleNum, val); +// Clear the annotations from all lines +void wxStyledTextCtrl::AnnotationClearAll() +{ + SendMsg(2547, 0, 0); +} + +// Set the visibility for the annotations for a view +void wxStyledTextCtrl::AnnotationSetVisible(int visible) +{ + SendMsg(2548, visible, 0); +} + +// Get the visibility for the annotations for a view +int wxStyledTextCtrl::AnnotationGetVisible() const +{ + return SendMsg(2549, 0, 0); +} + +// Get the start of the range of style numbers used for annotations +void wxStyledTextCtrl::AnnotationSetStyleOffset(int style) +{ + SendMsg(2550, style, 0); +} + +// Get the start of the range of style numbers used for annotations +int wxStyledTextCtrl::AnnotationGetStyleOffset() const +{ + return SendMsg(2551, 0, 0); +} + +// Add a container action to the undo stack +void wxStyledTextCtrl::AddUndoAction(int token, int flags) +{ + SendMsg(2560, token, flags); +} + +// Find the position of a character from a point within the window. +int wxStyledTextCtrl::CharPositionFromPoint(int x, int y) +{ + return SendMsg(2561, x, y); +} + +// Find the position of a character from a point within the window. +// Return INVALID_POSITION if not close to text. +int wxStyledTextCtrl::CharPositionFromPointClose(int x, int y) +{ + return SendMsg(2562, x, y); +} + +// Set whether multiple selections can be made +void wxStyledTextCtrl::SetMultipleSelection(bool multipleSelection) +{ + SendMsg(2563, multipleSelection, 0); +} + +// Whether multiple selections can be made +bool wxStyledTextCtrl::GetMultipleSelection() const +{ + return SendMsg(2564, 0, 0) != 0; +} + +// Set whether typing can be performed into multiple selections +void wxStyledTextCtrl::SetAdditionalSelectionTyping(bool additionalSelectionTyping) +{ + SendMsg(2565, additionalSelectionTyping, 0); +} + +// Whether typing can be performed into multiple selections +bool wxStyledTextCtrl::GetAdditionalSelectionTyping() const +{ + return SendMsg(2566, 0, 0) != 0; +} + +// Set whether additional carets will blink +void wxStyledTextCtrl::SetAdditionalCaretsBlink(bool additionalCaretsBlink) +{ + SendMsg(2567, additionalCaretsBlink, 0); +} + +// Whether additional carets will blink +bool wxStyledTextCtrl::GetAdditionalCaretsBlink() const +{ + return SendMsg(2568, 0, 0) != 0; +} + +// Set whether additional carets are visible +void wxStyledTextCtrl::SetAdditionalCaretsVisible(bool additionalCaretsBlink) +{ + SendMsg(2608, additionalCaretsBlink, 0); +} + +// Whether additional carets are visible +bool wxStyledTextCtrl::GetAdditionalCaretsVisible() const +{ + return SendMsg(2609, 0, 0) != 0; +} + +// How many selections are there? +int wxStyledTextCtrl::GetSelections() const +{ + return SendMsg(2570, 0, 0); +} + +// Clear selections to a single empty stream selection +void wxStyledTextCtrl::ClearSelections() +{ + SendMsg(2571, 0, 0); +} + +// Add a selection +int wxStyledTextCtrl::AddSelection(int caret, int anchor) +{ + return SendMsg(2573, caret, anchor); +} + +// Set the main selection +void wxStyledTextCtrl::SetMainSelection(int selection) +{ + SendMsg(2574, selection, 0); +} + +// Which selection is the main selection +int wxStyledTextCtrl::GetMainSelection() const +{ + return SendMsg(2575, 0, 0); +} +void wxStyledTextCtrl::SetSelectionNCaret(int selection, int pos) +{ + SendMsg(2576, selection, pos); +} +int wxStyledTextCtrl::GetSelectionNCaret(int selection) const +{ + return SendMsg(2577, selection, 0); +} +void wxStyledTextCtrl::SetSelectionNAnchor(int selection, int posAnchor) +{ + SendMsg(2578, selection, posAnchor); +} +int wxStyledTextCtrl::GetSelectionNAnchor(int selection) const +{ + return SendMsg(2579, selection, 0); +} +void wxStyledTextCtrl::SetSelectionNCaretVirtualSpace(int selection, int space) +{ + SendMsg(2580, selection, space); +} +int wxStyledTextCtrl::GetSelectionNCaretVirtualSpace(int selection) const +{ + return SendMsg(2581, selection, 0); +} +void wxStyledTextCtrl::SetSelectionNAnchorVirtualSpace(int selection, int space) +{ + SendMsg(2582, selection, space); +} +int wxStyledTextCtrl::GetSelectionNAnchorVirtualSpace(int selection) const +{ + return SendMsg(2583, selection, 0); +} + +// Sets the position that starts the selection - this becomes the anchor. +void wxStyledTextCtrl::SetSelectionNStart(int selection, int pos) +{ + SendMsg(2584, selection, pos); +} + +// Returns the position at the start of the selection. +int wxStyledTextCtrl::GetSelectionNStart(int selection) const +{ + return SendMsg(2585, selection, 0); +} + +// Sets the position that ends the selection - this becomes the currentPosition. +void wxStyledTextCtrl::SetSelectionNEnd(int selection, int pos) +{ + SendMsg(2586, selection, pos); +} + +// Returns the position at the end of the selection. +int wxStyledTextCtrl::GetSelectionNEnd(int selection) const +{ + return SendMsg(2587, selection, 0); +} +void wxStyledTextCtrl::SetRectangularSelectionCaret(int pos) +{ + SendMsg(2588, pos, 0); +} +int wxStyledTextCtrl::GetRectangularSelectionCaret() const +{ + return SendMsg(2589, 0, 0); +} +void wxStyledTextCtrl::SetRectangularSelectionAnchor(int posAnchor) +{ + SendMsg(2590, posAnchor, 0); +} +int wxStyledTextCtrl::GetRectangularSelectionAnchor() const +{ + return SendMsg(2591, 0, 0); +} +void wxStyledTextCtrl::SetRectangularSelectionCaretVirtualSpace(int space) +{ + SendMsg(2592, space, 0); +} +int wxStyledTextCtrl::GetRectangularSelectionCaretVirtualSpace() const +{ + return SendMsg(2593, 0, 0); +} +void wxStyledTextCtrl::SetRectangularSelectionAnchorVirtualSpace(int space) +{ + SendMsg(2594, space, 0); +} +int wxStyledTextCtrl::GetRectangularSelectionAnchorVirtualSpace() const +{ + return SendMsg(2595, 0, 0); +} +void wxStyledTextCtrl::SetVirtualSpaceOptions(int virtualSpaceOptions) +{ + SendMsg(2596, virtualSpaceOptions, 0); +} +int wxStyledTextCtrl::GetVirtualSpaceOptions() const +{ + return SendMsg(2597, 0, 0); +} + +// On GTK+, allow selecting the modifier key to use for mouse-based +// rectangular selection. Often the window manager requires Alt+Mouse Drag +// for moving windows. +// Valid values are SCMOD_CTRL(default), SCMOD_ALT, or SCMOD_SUPER. +void wxStyledTextCtrl::SetRectangularSelectionModifier(int modifier) +{ + SendMsg(2598, modifier, 0); +} + +// Get the modifier key used for rectangular selection. +int wxStyledTextCtrl::GetRectangularSelectionModifier() const +{ + return SendMsg(2599, 0, 0); +} + +// Set the foreground colour of additional selections. +// Must have previously called SetSelFore with non-zero first argument for this to have an effect. +void wxStyledTextCtrl::SetAdditionalSelForeground(const wxColour& fore) +{ + SendMsg(2600, wxColourAsLong(fore), 0); +} + +// Set the background colour of additional selections. +// Must have previously called SetSelBack with non-zero first argument for this to have an effect. +void wxStyledTextCtrl::SetAdditionalSelBackground(const wxColour& back) +{ + SendMsg(2601, wxColourAsLong(back), 0); +} + +// Set the alpha of the selection. +void wxStyledTextCtrl::SetAdditionalSelAlpha(int alpha) +{ + SendMsg(2602, alpha, 0); +} + +// Get the alpha of the selection. +int wxStyledTextCtrl::GetAdditionalSelAlpha() const +{ + return SendMsg(2603, 0, 0); +} + +// Set the foreground colour of additional carets. +void wxStyledTextCtrl::SetAdditionalCaretForeground(const wxColour& fore) +{ + SendMsg(2604, wxColourAsLong(fore), 0); +} + +// Get the foreground colour of additional carets. +wxColour wxStyledTextCtrl::GetAdditionalCaretForeground() const +{ + long c = SendMsg(2605, 0, 0); + return wxColourFromLong(c); +} + +// Set the main selection to the next selection. +void wxStyledTextCtrl::RotateSelection() +{ + SendMsg(2606, 0, 0); +} + +// Swap that caret and anchor of the main selection. +void wxStyledTextCtrl::SwapMainAnchorCaret() +{ + SendMsg(2607, 0, 0); +} + +// Indicate that the internal state of a lexer has changed over a range and therefore +// there may be a need to redraw. +int wxStyledTextCtrl::ChangeLexerState(int start, int end) +{ + return SendMsg(2617, start, end); +} + +// Find the next line at or after lineStart that is a contracted fold header line. +// Return -1 when no more lines. +int wxStyledTextCtrl::ContractedFoldNext(int lineStart) +{ + return SendMsg(2618, lineStart, 0); +} + +// Centre current line in window. +void wxStyledTextCtrl::VerticalCentreCaret() +{ + SendMsg(2619, 0, 0); +} + +// Move the selected lines up one line, shifting the line above after the selection +void wxStyledTextCtrl::MoveSelectedLinesUp() +{ + SendMsg(2620, 0, 0); +} + +// Move the selected lines down one line, shifting the line below before the selection +void wxStyledTextCtrl::MoveSelectedLinesDown() +{ + SendMsg(2621, 0, 0); +} + +// Set the identifier reported as idFrom in notification messages. +void wxStyledTextCtrl::SetIdentifier(int identifier) +{ + SendMsg(2622, identifier, 0); +} + +// Get the identifier. +int wxStyledTextCtrl::GetIdentifier() const +{ + return SendMsg(2623, 0, 0); +} + +// Set the width for future RGBA image data. +void wxStyledTextCtrl::RGBAImageSetWidth(int width) +{ + SendMsg(2624, width, 0); +} + +// Set the height for future RGBA image data. +void wxStyledTextCtrl::RGBAImageSetHeight(int height) +{ + SendMsg(2625, height, 0); +} + +// Define a marker from RGBA data. +// It has the width and height from RGBAImageSetWidth/Height +void wxStyledTextCtrl::MarkerDefineRGBAImage(int markerNumber, const unsigned char* pixels) { + SendMsg(2626, markerNumber, (sptr_t)pixels); +} + +// Register an RGBA image for use in autocompletion lists. +// It has the width and height from RGBAImageSetWidth/Height +void wxStyledTextCtrl::RegisterRGBAImage(int type, const unsigned char* pixels) { + SendMsg(2627, type, (sptr_t)pixels); +} + +// Scroll to start of document. +void wxStyledTextCtrl::ScrollToStart() +{ + SendMsg(2628, 0, 0); +} + +// Scroll to end of document. +void wxStyledTextCtrl::ScrollToEnd() +{ + SendMsg(2629, 0, 0); +} + +// Set the technology used. +void wxStyledTextCtrl::SetTechnology(int technology) +{ + SendMsg(2630, technology, 0); +} + +// Get the tech. +int wxStyledTextCtrl::GetTechnology() const +{ + return SendMsg(2631, 0, 0); +} + +// Create an ILoader*. +void* wxStyledTextCtrl::CreateLoader(int bytes) const { + return (void*)(sptr_t)SendMsg(2632, bytes); +} + +// Start notifying the container of all key presses and commands. +void wxStyledTextCtrl::StartRecord() +{ + SendMsg(3001, 0, 0); +} + +// Stop notifying the container of all key presses and commands. +void wxStyledTextCtrl::StopRecord() +{ + SendMsg(3002, 0, 0); +} + +// Set the lexing language of the document. +void wxStyledTextCtrl::SetLexer(int lexer) +{ + SendMsg(4001, lexer, 0); +} + +// Retrieve the lexing language of the document. +int wxStyledTextCtrl::GetLexer() const +{ + return SendMsg(4002, 0, 0); +} + +// Colourise a segment of the document using the current lexing language. +void wxStyledTextCtrl::Colourise(int start, int end) +{ + SendMsg(4003, start, end); +} + +// Set up a value that may be used by a lexer for some optional feature. +void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) +{ + SendMsg(4004, (sptr_t)(const char*)wx2stc(key), (sptr_t)(const char*)wx2stc(value)); +} + +// Set up the key words used by the lexer. +void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) +{ + SendMsg(4005, keywordSet, (sptr_t)(const char*)wx2stc(keyWords)); +} + +// Set the lexing language of the document based on string name. +void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) +{ + SendMsg(4006, 0, (sptr_t)(const char*)wx2stc(language)); +} + +// Retrieve a 'property' value previously set with SetProperty. +wxString wxStyledTextCtrl::GetProperty(const wxString& key) { + int len = SendMsg(SCI_GETPROPERTY, (sptr_t)(const char*)wx2stc(key), 0); + if (!len) return wxEmptyString; + + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(4008, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf); +} + +// Retrieve a 'property' value previously set with SetProperty, +// with '$()' variable replacement on returned buffer. +wxString wxStyledTextCtrl::GetPropertyExpanded(const wxString& key) { + int len = SendMsg(SCI_GETPROPERTYEXPANDED, (uptr_t)(const char*)wx2stc(key), 0); + if (!len) return wxEmptyString; + + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(4009, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf); +} + +// Retrieve a 'property' value previously set with SetProperty, +// interpreted as an int AFTER any '$()' variable replacement. +int wxStyledTextCtrl::GetPropertyInt(const wxString& key) const +{ + return SendMsg(4010, (sptr_t)(const char*)wx2stc(key), 0); +} + +// Retrieve the number of bits the current lexer needs for styling. +int wxStyledTextCtrl::GetStyleBitsNeeded() const +{ + return SendMsg(4011, 0, 0); +} + +// For private communication between an application and a known lexer. +void* wxStyledTextCtrl::PrivateLexerCall(int operation, void* pointer) { + return (void*)(sptr_t)SendMsg(4013, operation, (sptr_t)pointer); +} + +// Retrieve a '\n' separated list of properties understood by the current lexer. +wxString wxStyledTextCtrl::PropertyNames() const { + int msg = 4014; + int len = SendMsg(msg, 0, (sptr_t)NULL); + if (!len) return wxEmptyString; + + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(msg, 0, (sptr_t)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf); +} + +// Retrieve the type of a property. +int wxStyledTextCtrl::PropertyType(const wxString& name) +{ + return SendMsg(4015, (sptr_t)(const char*)wx2stc(name), 0); +} + +// Describe a property. +wxString wxStyledTextCtrl::DescribeProperty(const wxString& name) const { + int msg = 4016; + int len = SendMsg(msg, (sptr_t)(const char*)wx2stc(name), (sptr_t)NULL); + if (!len) return wxEmptyString; + + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(msg, (sptr_t)(const char*)wx2stc(name), (sptr_t)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf); +} + +// Retrieve a '\n' separated list of descriptions of the keyword sets understood by the current lexer. +wxString wxStyledTextCtrl::DescribeKeyWordSets() const { + int msg = 4017; + int len = SendMsg(msg, 0, (sptr_t)NULL); + if (!len) return wxEmptyString; + + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(msg, 0, (sptr_t)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf); +} + +//}}} +//---------------------------------------------------------------------- + + +// Returns the line number of the line with the caret. +int wxStyledTextCtrl::GetCurrentLine() { + int line = LineFromPosition(GetCurrentPos()); + return line; +} + + +// Extract style settings from a spec-string which is composed of one or +// more of the following comma separated elements: +// +// bold turns on bold +// italic turns on italics +// fore:[name or #RRGGBB] sets the foreground colour +// back:[name or #RRGGBB] sets the background colour +// face:[facename] sets the font face name to use +// size:[num] sets the font size in points +// eol turns on eol filling +// underline turns on underlining +// +void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) { + + wxStringTokenizer tkz(spec, wxT(",")); + while (tkz.HasMoreTokens()) { + wxString token = tkz.GetNextToken(); + + wxString option = token.BeforeFirst(':'); + wxString val = token.AfterFirst(':'); + + if (option == wxT("bold")) + StyleSetBold(styleNum, true); + + else if (option == wxT("italic")) + StyleSetItalic(styleNum, true); + + else if (option == wxT("underline")) + StyleSetUnderline(styleNum, true); + + else if (option == wxT("eol")) + StyleSetEOLFilled(styleNum, true); + + else if (option == wxT("size")) { + long points; + if (val.ToLong(&points)) + StyleSetSize(styleNum, points); + } + + else if (option == wxT("face")) + StyleSetFaceName(styleNum, val); else if (option == wxT("fore")) StyleSetForeground(styleNum, wxColourFromSpec(val)); @@ -3499,74 +4380,113 @@ void wxStyledTextCtrl::ScrollToColumn(int column) { } -#if wxUSE_TEXTCTRL -bool wxStyledTextCtrl::DoSaveFile(const wxString& filename, int WXUNUSED(fileType)) -#else -bool wxStyledTextCtrl::SaveFile(const wxString& filename) -#endif +void wxStyledTextCtrl::DoSetValue(const wxString& value, int flags) { - wxFile file(filename, wxFile::write); + if ( flags & SetValue_SelectionOnly ) + ReplaceSelection(value); + else + SetText(value); - if (!file.IsOpened()) - return false; + // We don't send wxEVT_COMMAND_TEXT_UPDATED anyhow, so ignore the + // SetValue_SendEvent bit of the flags +} - bool success = file.Write(GetText(), *wxConvCurrent); +bool +wxStyledTextCtrl::DoSaveFile(const wxString& filename, int WXUNUSED(fileType)) +{ +#if wxUSE_FFILE || wxUSE_FILE + +#if wxUSE_FFILE + // Take care to use "b" to ensure that possibly non-native EOLs in the file + // contents are not mangled when saving it. + wxFFile file(filename, wxS("wb")); +#elif wxUSE_FILE + wxFile file(filename, wxFile::write); +#endif - if (success) + if ( file.IsOpened() && file.Write(GetValue(), *wxConvCurrent) ) + { SetSavePoint(); - return success; + return true; + } + +#endif // !wxUSE_FFILE && !wxUSE_FILE + + return false; } -#if wxUSE_TEXTCTRL -bool wxStyledTextCtrl::DoLoadFile(const wxString& filename, int WXUNUSED(fileType)) +bool +wxStyledTextCtrl::DoLoadFile(const wxString& filename, int WXUNUSED(fileType)) +{ +#if wxUSE_FFILE || wxUSE_FILE + +#if wxUSE_FFILE + // As above, we want to read the real EOLs from the file, e.g. without + // translating them to just LFs under Windows, so that the original CR LF + // are preserved when it's written back. + wxFFile file(filename, wxS("rb")); #else -bool wxStyledTextCtrl::LoadFile(const wxString& filename) + wxFile file(filename); #endif -{ - bool success = false; - wxFile file(filename, wxFile::read); - if (file.IsOpened()) + if ( file.IsOpened() ) { - wxString contents; - // get the file size (assume it is not huge file...) - ssize_t len = (ssize_t)file.Length(); - - if (len > 0) + wxString text; + if ( file.ReadAll(&text, *wxConvCurrent) ) { -#if wxUSE_UNICODE - wxMemoryBuffer buffer(len+1); - success = (file.Read(buffer.GetData(), len) == len); - if (success) { - ((char*)buffer.GetData())[len] = 0; - contents = wxString(buffer, *wxConvCurrent, len); + // Detect the EOL: we use just the first line because there is not + // much we can do if the file uses inconsistent EOLs anyhow, we'd + // need to ask the user about the one we should really use and we + // don't currently provide a way to do it. + // + // We also only check for Unix and DOS EOLs but not classic Mac + // CR-only one as it's obsolete by now. + const wxString::size_type posLF = text.find('\n'); + if ( posLF != wxString::npos ) + { + // Set EOL mode to ensure that the new lines inserted into the + // text use the same EOLs as the existing ones. + if ( posLF > 0 && text[posLF - 1] == '\r' ) + SetEOLMode(wxSTC_EOL_CRLF); + else + SetEOLMode(wxSTC_EOL_LF); } -#else - wxString buffer; - success = (file.Read(wxStringBuffer(buffer, len), len) == len); - contents = buffer; -#endif - } - else - { - if (len == 0) - success = true; // empty file is ok - else - success = false; // len == wxInvalidOffset - } + //else: Use the default EOL for the current platform. - if (success) - { - SetText(contents); + SetValue(text); EmptyUndoBuffer(); SetSavePoint(); + + return true; } } +#endif // !wxUSE_FFILE && !wxUSE_FILE + + return false; +} + +// If we don't derive from wxTextAreaBase, we need to implement these methods +// ourselves, otherwise we already inherit them. +#if !wxUSE_TEXTCTRL + +bool wxStyledTextCtrl::SaveFile(const wxString& filename) +{ + if ( filename.empty() ) + return false; + + return DoSaveFile(filename, wxTEXT_TYPE_ANY); +} + +bool wxStyledTextCtrl::LoadFile(const wxString& filename) +{ + if ( filename.empty() ) + return false; - return success; + return DoLoadFile(filename, wxTEXT_TYPE_ANY); } +#endif // !wxUSE_TEXTCTRL #if wxUSE_DRAG_AND_DROP wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { @@ -3588,13 +4508,18 @@ bool wxStyledTextCtrl::GetUseAntiAliasing() { return m_swx->GetUseAntiAliasing(); } +void wxStyledTextCtrl::AnnotationClearLine(int line) { + SendMsg(SCI_ANNOTATIONSETTEXT, line, (sptr_t)NULL); +} -void wxStyledTextCtrl::AddTextRaw(const char* text) +void wxStyledTextCtrl::AddTextRaw(const char* text, int length) { - SendMsg(SCI_ADDTEXT, strlen(text), (sptr_t)text); + if (length == -1) + length = strlen(text); + SendMsg(SCI_ADDTEXT, length, (sptr_t)text); } void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text) @@ -3632,16 +4557,10 @@ wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line) wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw() { - long start; - long end; - - GetSelection(&start, &end); - int len = end - start; - if (!len) { - wxCharBuffer empty; - return empty; - } + // Calculate the length needed first. + const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0); + // And then really get the data. wxCharBuffer buf(len); SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data()); return buf; @@ -3682,9 +4601,11 @@ wxCharBuffer wxStyledTextCtrl::GetTextRaw() return buf; } -void wxStyledTextCtrl::AppendTextRaw(const char* text) +void wxStyledTextCtrl::AppendTextRaw(const char* text, int length) { - SendMsg(SCI_APPENDTEXT, strlen(text), (sptr_t)text); + if (length == -1) + length = strlen(text); + SendMsg(SCI_APPENDTEXT, length, (sptr_t)text); } @@ -3695,7 +4616,11 @@ void wxStyledTextCtrl::AppendTextRaw(const char* text) // Event handlers void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) { +#ifdef __WXGTK__ + wxBufferedPaintDC dc(this); +#else wxPaintDC dc(this); +#endif m_swx->DoPaint(&dc, GetUpdateRegion().GetBox()); } @@ -3770,19 +4695,11 @@ void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) { void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) { - // prevent having an event queue with wheel events that cannot be processed - // reasonably fast (see ticket #9057) - if ( m_lastWheelTimestamp <= evt.GetTimestamp() ) - { - m_lastWheelTimestamp = m_stopWatch.Time(); - m_swx->DoMouseWheel(evt.GetWheelRotation(), - evt.GetWheelDelta(), - evt.GetLinesPerAction(), - evt.ControlDown(), - evt.IsPageScroll()); - m_lastWheelTimestamp = m_stopWatch.Time() - m_lastWheelTimestamp; - m_lastWheelTimestamp += evt.GetTimestamp(); - } + m_swx->DoMouseWheel(evt.GetWheelRotation(), + evt.GetWheelDelta(), + evt.GetLinesPerAction(), + evt.ControlDown(), + evt.IsPageScroll()); } @@ -3947,10 +4864,12 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { case SCN_DOUBLECLICK: evt.SetEventType(wxEVT_STC_DOUBLECLICK); + evt.SetLine(scn.line); break; case SCN_UPDATEUI: evt.SetEventType(wxEVT_STC_UPDATEUI); + evt.SetUpdated(scn.updated); break; case SCN_MODIFIED: @@ -3962,6 +4881,8 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { evt.SetLine(scn.line); evt.SetFoldLevelNow(scn.foldLevelNow); evt.SetFoldLevelPrev(scn.foldLevelPrev); + evt.SetToken(scn.token); + evt.SetAnnotationLinesAdded(scn.annotationLinesAdded); break; case SCN_MACRORECORD: @@ -4040,6 +4961,18 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { evt.SetEventType(wxEVT_STC_INDICATOR_RELEASE); break; + case SCN_AUTOCCANCELLED: + evt.SetEventType(wxEVT_STC_AUTOCOMP_CANCELLED); + break; + + case SCN_AUTOCCHARDELETED: + evt.SetEventType(wxEVT_STC_AUTOCOMP_CHAR_DELETED); + break; + + case SCN_HOTSPOTRELEASECLICK: + evt.SetEventType(wxEVT_STC_HOTSPOT_RELEASE_CLICK); + break; + default: return; } @@ -4071,8 +5004,12 @@ wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id) m_listType = 0; m_x = 0; m_y = 0; - m_dragAllowMove = false; + m_token = 0; + m_annotationLinesAdded = 0; + m_updated = 0; + #if wxUSE_DRAG_AND_DROP + m_dragFlags = wxDrag_CopyOnly; m_dragResult = wxDragNone; #endif } @@ -4106,9 +5043,13 @@ wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event): m_x = event.m_x; m_y = event.m_y; - m_dragText = event.m_dragText; - m_dragAllowMove =event.m_dragAllowMove; + m_token = event.m_token; + m_annotationLinesAdded = event.m_annotationLinesAdded; + m_updated = event.m_updated; + #if wxUSE_DRAG_AND_DROP + m_dragText = event.m_dragText; + m_dragFlags = event.m_dragFlags; m_dragResult = event.m_dragResult; #endif } @@ -4116,4 +5057,9 @@ wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event): //---------------------------------------------------------------------- //---------------------------------------------------------------------- +/*static*/ wxVersionInfo wxStyledTextCtrl::GetLibraryVersionInfo() +{ + return wxVersionInfo("Scintilla", 3, 21, 0, "Scintilla 3.21"); +} + #endif // wxUSE_STC