From 2976c648218fd9cb65412587ae95b39c50055cf3 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sat, 28 Sep 2019 00:49:46 -0500 Subject: [PATCH 1/3] Add Raw variants for replacement functions to wxSTC Implement ReplaceSelectionRaw, ReplaceTargetRaw, and ReplaceTargetRERaw in the same manner as AddTextRaw, InsertTextRaw, and the other raw variants. --- src/stc/stc.cpp.in | 21 +++++++++++++++++ src/stc/stc.h.in | 9 ++++++++ src/stc/stc.interface.h.in | 46 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) 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..6ca3d24aa8 100644 --- a/src/stc/stc.h.in +++ b/src/stc/stc.h.in @@ -347,6 +347,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); + //@} From 97713e81a1b541084e521c4b8bfab764ec321342 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sat, 28 Sep 2019 00:16:28 -0500 Subject: [PATCH 2/3] Remove the flag wxSTC_FIND_CXX11REGEX from wxSTC docs wxSTC is currently built without c++11 regex support, but the search flag wxSTC_FIND_CXX11REGEX was included with wxSTC any way. This commit modifies gen_iface.py so that this flag will no longer be generated or documented. To prevent any code that is currently using this flag from being broken, the flag is manually defined in stc.h.in. In short, the flag will be preserved as it currently is but will be undocumented so users won't mistakenly try to use it. --- src/stc/gen_iface.py | 3 ++- src/stc/stc.h.in | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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.h.in b/src/stc/stc.h.in index 6ca3d24aa8..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 {{{ From 203074567cbc5fa2412ffd0e24dbee9966384586 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sat, 28 Sep 2019 00:50:47 -0500 Subject: [PATCH 3/3] Regenerate wxSTC files after recent changes --- include/wx/stc/stc.h | 18 +++++++++++++++- interface/wx/stc/stc.h | 47 +++++++++++++++++++++++++++++++++++++++++- src/stc/stc.cpp | 21 +++++++++++++++++++ 3 files changed, 84 insertions(+), 2 deletions(-) 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/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)