diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index 3c390b1b08..0ab59936ef 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -235,7 +235,6 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_FIND_WORDSTART 0x00100000 #define wxSTC_FIND_REGEXP 0x00200000 #define wxSTC_FIND_POSIX 0x00400000 -#define wxSTC_FIND_CXX11REGEX 0x00800000 #define wxSTC_FOLDLEVELBASE 0x400 #define wxSTC_FOLDLEVELWHITEFLAG 0x1000 #define wxSTC_FOLDLEVELHEADERFLAG 0x2000 @@ -2528,6 +2527,14 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #endif // WXWIN_COMPATIBILITY_3_0 +// wxSTC is currently built without c++11 regex support, but the search flag +// wxSTC_FIND_CXX11REGEX was included with wxSTC any way. gen_iface.py has since +// been changed so that this flag will no longer be generated or documented, +// but the flag is preserved here so that any code using the flag before +// gen_iface.py was changed will not be broken. + +#define wxSTC_FIND_CXX11REGEX 0x00800000 + //---------------------------------------------------------------------- // Commands that can be bound to keystrokes section {{{ @@ -5230,6 +5237,15 @@ public: // Append a string to the end of the document without changing the selection. void AppendTextRaw(const char* text, int length=-1); + // Replace the selected text with the argument text. + void ReplaceSelectionRaw(const char* text); + + // Replace the target text with the argument text. + int ReplaceTargetRaw(const char* text, int length=-1); + + // Replace the target text with the argument text after \d processing. + int ReplaceTargetRERaw(const char* text, int length=-1); + #ifdef SWIG %pythoncode "_stc_utf8_methods.py" #endif diff --git a/interface/wx/stc/stc.h b/interface/wx/stc/stc.h index d4f4f54d4e..0017de3b12 100644 --- a/interface/wx/stc/stc.h +++ b/interface/wx/stc/stc.h @@ -191,7 +191,6 @@ #define wxSTC_FIND_WORDSTART 0x00100000 #define wxSTC_FIND_REGEXP 0x00200000 #define wxSTC_FIND_POSIX 0x00400000 -#define wxSTC_FIND_CXX11REGEX 0x00800000 #define wxSTC_FOLDLEVELBASE 0x400 #define wxSTC_FOLDLEVELWHITEFLAG 0x1000 #define wxSTC_FOLDLEVELHEADERFLAG 0x2000 @@ -7412,6 +7411,52 @@ public: */ void AppendTextRaw(const char* text, int length=-1); + /** + Replace the current selection with text. If there is no current + selection, text is inserted at the current caret position. + + @param text + The null terminated string used for the replacement. + + @since 3.1.3 + */ + void ReplaceSelectionRaw(const char* text); + + /** + Replace the current target with text. + + @return + The return value is the length of the replacement string. + + @remarks + If length=-1, text must be null terminated. + + @since 3.1.3 + */ + int ReplaceTargetRaw(const char* text, int length=-1); + + /** + Replace the current target with text using regular expressions. + + The replacement string will be formed from text with any occurrences '\1' + through '\9' replaced by tagged matches from the most recent regular + expression search. In addition, any occurrences of '\0' will be replaced + with all the matched text from the most recent search. After replacement, + the target range refers to the replacement text. + + @return + The return value is the length of the replacement string. + + @remarks + If length=-1, text must be null terminated. + + @see + SearchInTarget() + + @since 3.1.3 + */ + int ReplaceTargetRERaw(const char* text, int length=-1); + //@} diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index e885cda3bb..04ff317485 100755 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -78,7 +78,8 @@ notMappedSciValues = set([ 'INDIC0_MASK', 'INDIC1_MASK', 'INDIC2_MASK', - 'INDICS_MASK' + 'INDICS_MASK', + 'SCFIND_CXX11REGEX' ]) # Map some generic typenames to wx types, using return value syntax diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 65a7a74684..a397d65673 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -5155,6 +5155,27 @@ void wxStyledTextCtrl::AppendTextRaw(const char* text, int length) SendMsg(SCI_APPENDTEXT, length, (sptr_t)text); } +void wxStyledTextCtrl::ReplaceSelectionRaw(const char* text) +{ + SendMsg(SCI_REPLACESEL, 0, reinterpret_cast(text)); +} + +int wxStyledTextCtrl::ReplaceTargetRaw(const char* text, int length) +{ + if ( length == -1 ) + length = strlen(text); + + return SendMsg(SCI_REPLACETARGET, length, reinterpret_cast(text)); +} + +int wxStyledTextCtrl::ReplaceTargetRERaw(const char* text, int length) +{ + if ( length == -1 ) + length = strlen(text); + + return SendMsg(SCI_REPLACETARGETRE, length, reinterpret_cast(text)); +} + #if WXWIN_COMPATIBILITY_3_0 // Deprecated since Scintilla 3.7.2 void wxStyledTextCtrl::UsePopUp(bool allowPopUp) diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index 198c4ccac4..7a211c5545 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -682,6 +682,27 @@ void wxStyledTextCtrl::AppendTextRaw(const char* text, int length) SendMsg(SCI_APPENDTEXT, length, (sptr_t)text); } +void wxStyledTextCtrl::ReplaceSelectionRaw(const char* text) +{ + SendMsg(SCI_REPLACESEL, 0, reinterpret_cast(text)); +} + +int wxStyledTextCtrl::ReplaceTargetRaw(const char* text, int length) +{ + if ( length == -1 ) + length = strlen(text); + + return SendMsg(SCI_REPLACETARGET, length, reinterpret_cast(text)); +} + +int wxStyledTextCtrl::ReplaceTargetRERaw(const char* text, int length) +{ + if ( length == -1 ) + length = strlen(text); + + return SendMsg(SCI_REPLACETARGETRE, length, reinterpret_cast(text)); +} + #if WXWIN_COMPATIBILITY_3_0 // Deprecated since Scintilla 3.7.2 void wxStyledTextCtrl::UsePopUp(bool allowPopUp) diff --git a/src/stc/stc.h.in b/src/stc/stc.h.in index 679c0e16e0..0713ec6212 100644 --- a/src/stc/stc.h.in +++ b/src/stc/stc.h.in @@ -124,6 +124,14 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #endif // WXWIN_COMPATIBILITY_3_0 +// wxSTC is currently built without c++11 regex support, but the search flag +// wxSTC_FIND_CXX11REGEX was included with wxSTC any way. gen_iface.py has since +// been changed so that this flag will no longer be generated or documented, +// but the flag is preserved here so that any code using the flag before +// gen_iface.py was changed will not be broken. + +#define wxSTC_FIND_CXX11REGEX 0x00800000 + //---------------------------------------------------------------------- // Commands that can be bound to keystrokes section {{{ @@ -347,6 +355,15 @@ public: // Append a string to the end of the document without changing the selection. void AppendTextRaw(const char* text, int length=-1); + // Replace the selected text with the argument text. + void ReplaceSelectionRaw(const char* text); + + // Replace the target text with the argument text. + int ReplaceTargetRaw(const char* text, int length=-1); + + // Replace the target text with the argument text after \d processing. + int ReplaceTargetRERaw(const char* text, int length=-1); + #ifdef SWIG %%pythoncode "_stc_utf8_methods.py" #endif diff --git a/src/stc/stc.interface.h.in b/src/stc/stc.interface.h.in index 5e7e1b9a5d..af05c72bde 100644 --- a/src/stc/stc.interface.h.in +++ b/src/stc/stc.interface.h.in @@ -352,6 +352,52 @@ public: */ void AppendTextRaw(const char* text, int length=-1); + /** + Replace the current selection with text. If there is no current + selection, text is inserted at the current caret position. + + @param text + The null terminated string used for the replacement. + + @since 3.1.3 + */ + void ReplaceSelectionRaw(const char* text); + + /** + Replace the current target with text. + + @return + The return value is the length of the replacement string. + + @remarks + If length=-1, text must be null terminated. + + @since 3.1.3 + */ + int ReplaceTargetRaw(const char* text, int length=-1); + + /** + Replace the current target with text using regular expressions. + + The replacement string will be formed from text with any occurrences '\1' + through '\9' replaced by tagged matches from the most recent regular + expression search. In addition, any occurrences of '\0' will be replaced + with all the matched text from the most recent search. After replacement, + the target range refers to the replacement text. + + @return + The return value is the length of the replacement string. + + @remarks + If length=-1, text must be null terminated. + + @see + SearchInTarget() + + @since 3.1.3 + */ + int ReplaceTargetRERaw(const char* text, int length=-1); + //@}