X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a5c2ccf2e7a22fc7fd629d5db723faef301bfaff..ccc040255c07064f2ed96f1a345d21860b202cb6:/src/stc/stc.cpp?ds=sidebyside diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index c91d46eb49..1fa360de2d 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,13 +47,17 @@ #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 #include "ScintillaWX.h" //---------------------------------------------------------------------- -const wxChar* wxSTCNameStr = wxT("stcwindow"); +const char wxSTCNameStr[] = "stcwindow"; #ifdef MAKELONG #undef MAKELONG @@ -96,34 +100,37 @@ static wxColour wxColourFromSpec(const wxString& spec) { //---------------------------------------------------------------------- -DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE ) -DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED ) -DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED ) -DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED ) -DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT ) -DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT ) -DEFINE_EVENT_TYPE( wxEVT_STC_KEY ) -DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK ) -DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI ) -DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED ) -DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD ) -DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK ) -DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN ) -DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED ) -DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION ) -DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED ) -DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART ) -DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND ) -DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG ) -DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER ) -DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP ) -DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM ) -DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK ) -DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK ) -DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK ) -DEFINE_EVENT_TYPE( wxEVT_STC_AUTOCOMP_SELECTION ) -DEFINE_EVENT_TYPE( wxEVT_STC_INDICATOR_CLICK ) -DEFINE_EVENT_TYPE( wxEVT_STC_INDICATOR_RELEASE ) +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 ); @@ -207,7 +214,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); @@ -223,7 +230,7 @@ wxStyledTextCtrl::~wxStyledTextCtrl() { //---------------------------------------------------------------------- -long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) const +wxIntPtr wxStyledTextCtrl::SendMsg(int msg, wxUIntPtr wp, wxIntPtr lp) const { return m_swx->WndProc(msg, wp, lp); } @@ -255,19 +262,19 @@ 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), (long)(const char*)buf); + const wxWX2MBbuf buf = wx2stc(text); + SendMsg(2001, wx2stclen(text, buf), (sptr_t)(const char*)buf); } // Add array of cells to document. void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer& data) { - SendMsg(2002, data.GetDataLen(), (long)data.GetData()); + SendMsg(2002, data.GetDataLen(), (sptr_t)data.GetData()); } // Insert string at a position. void wxStyledTextCtrl::InsertText(int pos, const wxString& text) { - SendMsg(2003, pos, (long)(const char*)wx2stc(text)); + SendMsg(2003, pos, (sptr_t)(const char*)wx2stc(text)); } // Delete all text in the document. @@ -276,13 +283,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); @@ -350,13 +363,13 @@ wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) { tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1); tr.chrg.cpMin = startPos; tr.chrg.cpMax = endPos; - len = SendMsg(2015, 0, (long)&tr); + len = SendMsg(2015, 0, (sptr_t)&tr); buf.UngetWriteBuf(len); return buf; } // Are there any redoable actions in the undo history? -bool wxStyledTextCtrl::CanRedo() +bool wxStyledTextCtrl::CanRedo() const { return SendMsg(2016, 0, 0) != 0; } @@ -393,7 +406,7 @@ void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS) } // Find the position from a point within the window. -int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) { +int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) const { return SendMsg(2022, pt.x, pt.y); } @@ -435,7 +448,7 @@ wxString wxStyledTextCtrl::GetCurLine(int* linePos) { wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len+1); - int pos = SendMsg(2027, len+1, (long)buf); + int pos = SendMsg(2027, len+1, (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); if (linePos) *linePos = pos; @@ -524,9 +537,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); } @@ -542,6 +555,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) { @@ -566,7 +591,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); @@ -590,7 +616,7 @@ void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp) char* buff = new char[len+1]; strm.CopyTo(buff, len); buff[len] = 0; - SendMsg(2049, markerNumber, (long)buff); + SendMsg(2049, markerNumber, (sptr_t)buff); delete [] buff; } @@ -655,6 +681,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() { @@ -694,7 +732,7 @@ void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints) // Set the font of a style. void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) { - SendMsg(2056, style, (long)(const char*)wx2stc(fontName)); + SendMsg(2056, style, (sptr_t)(const char*)wx2stc(fontName)); } // Set a style to have its end of line filled or not. @@ -753,7 +791,7 @@ wxString wxStyledTextCtrl::StyleGetFaceName(int style) { long len = SendMsg(msg, style, 0); wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len+1); - SendMsg(msg, style, (long)buf); + SendMsg(msg, style, (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); @@ -808,19 +846,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)); @@ -874,7 +936,7 @@ void wxStyledTextCtrl::CmdKeyClearAll() // Set the styles for a segment of the document. void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) { - SendMsg(2073, length, (long)styleBytes); + SendMsg(2073, length, (sptr_t)styleBytes); } // Set a style to be visible or not. @@ -896,10 +958,24 @@ 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, (long)(const char*)wx2stc(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. @@ -964,6 +1040,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. @@ -1033,7 +1121,7 @@ void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable) // the caret should be used to provide context. void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) { - SendMsg(2100, lenEntered, (long)(const char*)wx2stc(itemList)); + SendMsg(2100, lenEntered, (sptr_t)(const char*)wx2stc(itemList)); } // Remove the auto-completion list from the screen. @@ -1063,7 +1151,7 @@ void wxStyledTextCtrl::AutoCompComplete() // Define a set of character that when typed cancel the auto-completion list. void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) { - SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet)); + SendMsg(2105, 0, (sptr_t)(const char*)wx2stc(characterSet)); } // Change the separator character in the string setting up an auto-completion list. @@ -1082,7 +1170,7 @@ int wxStyledTextCtrl::AutoCompGetSeparator() const // Select the item in the auto-completion list that starts with a string. void wxStyledTextCtrl::AutoCompSelect(const wxString& text) { - SendMsg(2108, 0, (long)(const char*)wx2stc(text)); + SendMsg(2108, 0, (sptr_t)(const char*)wx2stc(text)); } // Should the auto-completion list be cancelled if the user backspaces to a @@ -1102,7 +1190,7 @@ bool wxStyledTextCtrl::AutoCompGetCancelAtStart() const // choose the selected item. void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) { - SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet)); + SendMsg(2112, 0, (sptr_t)(const char*)wx2stc(characterSet)); } // Should a single item auto-completion list automatically choose the item. @@ -1132,7 +1220,7 @@ bool wxStyledTextCtrl::AutoCompGetIgnoreCase() const // Display a list of strings and send notification when user chooses one. void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) { - SendMsg(2117, listType, (long)(const char*)wx2stc(itemList)); + SendMsg(2117, listType, (sptr_t)(const char*)wx2stc(itemList)); } // Set whether or not autocompletion is hidden automatically when nothing matches. @@ -1173,7 +1261,7 @@ void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) { char* buff = new char[len+1]; strm.CopyTo(buff, len); buff[len] = 0; - SendMsg(2405, type, (long)buff); + SendMsg(2405, type, (sptr_t)buff); delete [] buff; } @@ -1272,6 +1360,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) { @@ -1364,6 +1458,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) { @@ -1395,10 +1495,10 @@ 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, (long)&ft); + return SendMsg(2150, flags, (sptr_t)&ft); } // On Windows, will draw the document into a display context such as a printer. @@ -1429,7 +1529,7 @@ int wxStyledTextCtrl::FindText(int minPos, int maxPos, fr.chrg.cpMin = startPos; fr.chrg.cpMax = endPos; - return SendMsg(2151, doDraw, (long)&fr); + return SendMsg(2151, doDraw, (sptr_t)&fr); } // Retrieve the display line at the top of the display. @@ -1439,13 +1539,13 @@ int wxStyledTextCtrl::GetFirstVisibleLine() const } // Retrieve the contents of a line. -wxString wxStyledTextCtrl::GetLine(int line) { +wxString wxStyledTextCtrl::GetLine(int line) const { int len = LineLength(line); if (!len) return wxEmptyString; wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len+1); - SendMsg(2153, line, (long)buf); + SendMsg(2153, line, (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); @@ -1487,24 +1587,14 @@ bool wxStyledTextCtrl::GetModify() const return SendMsg(2159, 0, 0) != 0; } -// Select a range of text. -void wxStyledTextCtrl::SetSelection(int start, int end) -{ - SendMsg(2160, start, end); -} - // Retrieve the selected text. wxString wxStyledTextCtrl::GetSelectedText() { - int start; - int 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); char* buf = (char*)mbuf.GetWriteBuf(len+1); - SendMsg(2161, 0, (long)buf); + SendMsg(2161, 0, (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); @@ -1525,7 +1615,7 @@ wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) { tr.lpstrText = buf; tr.chrg.cpMin = startPos; tr.chrg.cpMax = endPos; - SendMsg(2162, 0, (long)&tr); + SendMsg(2162, 0, (sptr_t)&tr); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); @@ -1538,13 +1628,13 @@ void wxStyledTextCtrl::HideSelection(bool normal) } // Retrieve the line containing a position. -int wxStyledTextCtrl::LineFromPosition(int pos) +int wxStyledTextCtrl::LineFromPosition(int pos) const { return SendMsg(2166, pos, 0); } // Retrieve the position at the start of a line. -int wxStyledTextCtrl::PositionFromLine(int line) +int wxStyledTextCtrl::PositionFromLine(int line) const { return SendMsg(2167, line, 0); } @@ -1564,7 +1654,7 @@ void wxStyledTextCtrl::EnsureCaretVisible() // Replace the selected text with the argument text. void wxStyledTextCtrl::ReplaceSelection(const wxString& text) { - SendMsg(2170, 0, (long)(const char*)wx2stc(text)); + SendMsg(2170, 0, (sptr_t)(const char*)wx2stc(text)); } // Set to read only or read write. @@ -1574,13 +1664,13 @@ void wxStyledTextCtrl::SetReadOnly(bool readOnly) } // Will a paste succeed? -bool wxStyledTextCtrl::CanPaste() +bool wxStyledTextCtrl::CanPaste() const { return SendMsg(2173, 0, 0) != 0; } // Are there any undoable actions in the undo history? -bool wxStyledTextCtrl::CanUndo() +bool wxStyledTextCtrl::CanUndo() const { return SendMsg(2174, 0, 0) != 0; } @@ -1624,15 +1714,15 @@ void wxStyledTextCtrl::Clear() // Replace the contents of the document with the argument text. void wxStyledTextCtrl::SetText(const wxString& text) { - SendMsg(2181, 0, (long)(const char*)wx2stc(text)); + SendMsg(2181, 0, (sptr_t)(const char*)wx2stc(text)); } // Retrieve all the text in the document. -wxString wxStyledTextCtrl::GetText() { +wxString wxStyledTextCtrl::GetText() const { int len = GetTextLength(); wxMemoryBuffer mbuf(len+1); // leave room for the null... char* buf = (char*)mbuf.GetWriteBuf(len+1); - SendMsg(2182, len+1, (long)buf); + SendMsg(2182, len+1, (sptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return stc2wx(buf); @@ -1699,8 +1789,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), (long)(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. @@ -1711,8 +1801,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), (long)(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 @@ -1720,8 +1810,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), (long)(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. @@ -1739,7 +1829,7 @@ int wxStyledTextCtrl::GetSearchFlags() const // Show a call tip containing a definition near position pos. void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) { - SendMsg(2200, pos, (long)(const char*)wx2stc(definition)); + SendMsg(2200, pos, (sptr_t)(const char*)wx2stc(definition)); } // Remove the call tip from the screen. @@ -1790,6 +1880,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) { @@ -1852,6 +1948,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) { @@ -1985,6 +2087,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) { @@ -2026,7 +2140,7 @@ bool wxStyledTextCtrl::GetScrollWidthTracking() const // Does not handle tab or control characters. int wxStyledTextCtrl::TextWidth(int style, const wxString& text) { - return SendMsg(2276, style, (long)(const char*)wx2stc(text)); + return SendMsg(2276, style, (sptr_t)(const char*)wx2stc(text)); } // Sets the scroll range so that maximum scroll position has @@ -2064,8 +2178,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), (long)(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? @@ -2081,6 +2195,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() { @@ -2463,8 +2609,8 @@ void wxStyledTextCtrl::MoveCaretInsideView() SendMsg(2401, 0, 0); } -// How many characters are on a line, not including end of line characters? -int wxStyledTextCtrl::LineLength(int line) +// How many characters are on a line, including end of line characters? +int wxStyledTextCtrl::LineLength(int line) const { return SendMsg(2350, line, 0); } @@ -2475,12 +2621,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) { @@ -2506,7 +2664,7 @@ void* wxStyledTextCtrl::GetDocPointer() { // Change the document object used. void wxStyledTextCtrl::SetDocPointer(void* docPointer) { - SendMsg(2358, 0, (long)docPointer); + SendMsg(2358, 0, (sptr_t)docPointer); } // Set which document modification events are sent to the container. @@ -2564,14 +2722,14 @@ void wxStyledTextCtrl::SearchAnchor() // Does not ensure the selection is visible. int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) { - return SendMsg(2367, flags, (long)(const char*)wx2stc(text)); + return SendMsg(2367, flags, (sptr_t)(const char*)wx2stc(text)); } // Find some text starting at the search anchor and moving backwards. // Does not ensure the selection is visible. int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) { - return SendMsg(2368, flags, (long)(const char*)wx2stc(text)); + return SendMsg(2368, flags, (sptr_t)(const char*)wx2stc(text)); } // Retrieves the number of lines completely visible. @@ -2614,12 +2772,12 @@ void* wxStyledTextCtrl::CreateDocument() { // Extend life of document. void wxStyledTextCtrl::AddRefDocument(void* docPointer) { - SendMsg(2376, 0, (long)docPointer); + SendMsg(2376, 0, (sptr_t)docPointer); } // Release a reference to the document, deleting document if it fades to black. void wxStyledTextCtrl::ReleaseDocument(void* docPointer) { - SendMsg(2377, 0, (long)docPointer); + SendMsg(2377, 0, (sptr_t)docPointer); } // Get which document modification events are sent to the container. @@ -2734,7 +2892,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); @@ -2750,7 +2908,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) { @@ -2867,10 +3025,10 @@ void wxStyledTextCtrl::CopyRange(int start, int end) // Copy argument text to the clipboard. void wxStyledTextCtrl::CopyText(int length, const wxString& text) { - SendMsg(2420, length, (long)(const char*)wx2stc(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) { @@ -3003,7 +3161,42 @@ void wxStyledTextCtrl::WordRightEndExtend() // Should be called after SetWordChars. void wxStyledTextCtrl::SetWhitespaceChars(const wxString& characters) { - SendMsg(2443, 0, (long)(const char*)wx2stc(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. @@ -3013,11 +3206,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) { @@ -3032,13 +3237,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); } @@ -3109,7 +3314,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); @@ -3163,153 +3368,820 @@ 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, (long)(const char*)wx2stc(key), (long)(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, (long)(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, (long)(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, (long)(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, (long)(const char*)wx2stc(key), (long)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, (long)(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, (long)(const char*)wx2stc(key), (long)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, (long)(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); } -//}}} -//---------------------------------------------------------------------- - - -// Returns the line number of the line with the caret. -int wxStyledTextCtrl::GetCurrentLine() { - int line = LineFromPosition(GetCurrentPos()); - return line; +// 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); +} -// 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 margin options. +int wxStyledTextCtrl::GetMarginOptions() const +{ + return SendMsg(2557, 0, 0); +} - wxStringTokenizer tkz(spec, wxT(",")); - while (tkz.HasMoreTokens()) { - wxString token = tkz.GetNextToken(); +// Set the annotation text for a line +void wxStyledTextCtrl::AnnotationSetText(int line, const wxString& text) +{ + SendMsg(2540, line, (sptr_t)(const char*)wx2stc(text)); +} - wxString option = token.BeforeFirst(':'); - wxString val = token.AfterFirst(':'); +// Get the annotation text for a line +wxString wxStyledTextCtrl::AnnotationGetText(int line) const { + long msg = 2541; + long len = SendMsg(msg, line, 0); - if (option == wxT("bold")) - StyleSetBold(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("italic")) - StyleSetItalic(styleNum, true); +// Set the style number for the annotations for a line +void wxStyledTextCtrl::AnnotationSetStyle(int line, int style) +{ + SendMsg(2542, line, style); +} - else if (option == wxT("underline")) - StyleSetUnderline(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("eol")) - StyleSetEOLFilled(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("size")) { - long points; - if (val.ToLong(&points)) - StyleSetSize(styleNum, points); - } +// 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("face")) - StyleSetFaceName(styleNum, val); + 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("fore")) - StyleSetForeground(styleNum, wxColourFromSpec(val)); +// Get the number of annotation lines for a line +int wxStyledTextCtrl::AnnotationGetLines(int line) const +{ + return SendMsg(2546, line, 0); +} - else if (option == wxT("back")) - StyleSetBackground(styleNum, wxColourFromSpec(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)); + + else if (option == wxT("back")) + StyleSetBackground(styleNum, wxColourFromSpec(val)); + } } @@ -3485,15 +4357,6 @@ void wxStyledTextCtrl::SetMargins(int left, int right) { } -// Retrieve the start and end positions of the current selection. -void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) { - if (startPos != NULL) - *startPos = SendMsg(SCI_GETSELECTIONSTART); - if (endPos != NULL) - *endPos = SendMsg(SCI_GETSELECTIONEND); -} - - // Retrieve the point in the window where a position is displayed. wxPoint wxStyledTextCtrl::PointFromPosition(int pos) { int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos); @@ -3513,66 +4376,113 @@ void wxStyledTextCtrl::ScrollToColumn(int column) { } -bool wxStyledTextCtrl::SaveFile(const wxString& filename) +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 +wxStyledTextCtrl::DoSaveFile(const wxString& filename, int WXUNUSED(fileType)) +{ +#if wxUSE_FFILE || wxUSE_FILE - bool success = file.Write(GetText(), *wxConvCurrent); +#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; } -bool wxStyledTextCtrl::LoadFile(const wxString& filename) +bool +wxStyledTextCtrl::DoLoadFile(const wxString& filename, int WXUNUSED(fileType)) { - bool success = false; - wxFile file(filename, wxFile::read); - - if (file.IsOpened()) - { - wxString contents; - // get the file size (assume it is not huge file...) - ssize_t len = (ssize_t)file.Length(); +#if wxUSE_FFILE || wxUSE_FILE - if (len > 0) - { -#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); - } +#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 - wxString buffer; - success = (file.Read(wxStringBuffer(buffer, len), len) == len); - contents = buffer; + wxFile file(filename); #endif - } - else - { - if (len == 0) - success = true; // empty file is ok - else - success = false; // len == wxInvalidOffset - } - if (success) + if ( file.IsOpened() ) + { + wxString text; + if ( file.ReadAll(&text, *wxConvCurrent) ) { - SetText(contents); + // 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: Use the default EOL for the current platform. + + SetValue(text); EmptyUndoBuffer(); SetSavePoint(); + + return true; } } +#endif // !wxUSE_FFILE && !wxUSE_FILE - return success; + 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 DoLoadFile(filename, wxTEXT_TYPE_ANY); +} + +#endif // !wxUSE_TEXTCTRL #if wxUSE_DRAG_AND_DROP wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { @@ -3594,18 +4504,23 @@ bool wxStyledTextCtrl::GetUseAntiAliasing() { return m_swx->GetUseAntiAliasing(); } +void wxStyledTextCtrl::AnnotationClearLine(int line) { + SendMsg(SCI_ANNOTATIONSETTEXT, line, NULL); +} -void wxStyledTextCtrl::AddTextRaw(const char* text) +void wxStyledTextCtrl::AddTextRaw(const char* text, int length) { - SendMsg(SCI_ADDTEXT, strlen(text), (long)text); + if (length == -1) + length = strlen(text); + SendMsg(SCI_ADDTEXT, length, (sptr_t)text); } void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text) { - SendMsg(SCI_INSERTTEXT, pos, (long)text); + SendMsg(SCI_INSERTTEXT, pos, (sptr_t)text); } wxCharBuffer wxStyledTextCtrl::GetCurLineRaw(int* linePos) @@ -3618,7 +4533,7 @@ wxCharBuffer wxStyledTextCtrl::GetCurLineRaw(int* linePos) } wxCharBuffer buf(len); - int pos = SendMsg(SCI_GETCURLINE, len, (long)buf.data()); + int pos = SendMsg(SCI_GETCURLINE, len, (sptr_t)buf.data()); if (linePos) *linePos = pos; return buf; } @@ -3632,24 +4547,18 @@ wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line) } wxCharBuffer buf(len); - SendMsg(SCI_GETLINE, line, (long)buf.data()); + SendMsg(SCI_GETLINE, line, (sptr_t)buf.data()); return buf; } wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw() { - int start; - int 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, (long)buf.data()); + SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data()); return buf; } @@ -3671,26 +4580,28 @@ wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos) tr.lpstrText = buf.data(); tr.chrg.cpMin = startPos; tr.chrg.cpMax = endPos; - SendMsg(SCI_GETTEXTRANGE, 0, (long)&tr); + SendMsg(SCI_GETTEXTRANGE, 0, (sptr_t)&tr); return buf; } void wxStyledTextCtrl::SetTextRaw(const char* text) { - SendMsg(SCI_SETTEXT, 0, (long)text); + SendMsg(SCI_SETTEXT, 0, (sptr_t)text); } wxCharBuffer wxStyledTextCtrl::GetTextRaw() { - int len = GetTextLength(); - wxCharBuffer buf(len); - SendMsg(SCI_GETTEXT, len, (long)buf.data()); + int len = GetTextLength(); + wxCharBuffer buf(len); // adds 1 for NUL automatically + SendMsg(SCI_GETTEXT, len + 1, (sptr_t)buf.data()); return buf; } -void wxStyledTextCtrl::AppendTextRaw(const char* text) +void wxStyledTextCtrl::AppendTextRaw(const char* text, int length) { - SendMsg(SCI_APPENDTEXT, strlen(text), (long)text); + if (length == -1) + length = strlen(text); + SendMsg(SCI_APPENDTEXT, length, (sptr_t)text); } @@ -3774,7 +4685,8 @@ void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) { } -void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) { +void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) +{ m_swx->DoMouseWheel(evt.GetWheelRotation(), evt.GetWheelDelta(), evt.GetLinesPerAction(), @@ -3944,10 +4856,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: @@ -3959,6 +4873,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: @@ -4037,6 +4953,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; } @@ -4068,8 +4996,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 } @@ -4103,9 +5035,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 } @@ -4113,4 +5049,9 @@ wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event): //---------------------------------------------------------------------- //---------------------------------------------------------------------- +/*static*/ wxVersionInfo wxStyledTextCtrl::GetLibraryVersionInfo() +{ + return wxVersionInfo("Scintilla", 3, 21, 0, "Scintilla 3.21"); +} + #endif // wxUSE_STC