Add "Raw" variants for replacement functions to wxSTC.

Closes #18108.

See https://github.com/wxWidgets/wxWidgets/pull/1571
This commit is contained in:
Vadim Zeitlin 2019-09-28 14:36:00 +02:00
commit 4b832dbc25
7 changed files with 170 additions and 3 deletions

View File

@ -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

View File

@ -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);
//@}

View File

@ -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

View File

@ -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<sptr_t>(text));
}
int wxStyledTextCtrl::ReplaceTargetRaw(const char* text, int length)
{
if ( length == -1 )
length = strlen(text);
return SendMsg(SCI_REPLACETARGET, length, reinterpret_cast<sptr_t>(text));
}
int wxStyledTextCtrl::ReplaceTargetRERaw(const char* text, int length)
{
if ( length == -1 )
length = strlen(text);
return SendMsg(SCI_REPLACETARGETRE, length, reinterpret_cast<sptr_t>(text));
}
#if WXWIN_COMPATIBILITY_3_0
// Deprecated since Scintilla 3.7.2
void wxStyledTextCtrl::UsePopUp(bool allowPopUp)

View File

@ -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<sptr_t>(text));
}
int wxStyledTextCtrl::ReplaceTargetRaw(const char* text, int length)
{
if ( length == -1 )
length = strlen(text);
return SendMsg(SCI_REPLACETARGET, length, reinterpret_cast<sptr_t>(text));
}
int wxStyledTextCtrl::ReplaceTargetRERaw(const char* text, int length)
{
if ( length == -1 )
length = strlen(text);
return SendMsg(SCI_REPLACETARGETRE, length, reinterpret_cast<sptr_t>(text));
}
#if WXWIN_COMPATIBILITY_3_0
// Deprecated since Scintilla 3.7.2
void wxStyledTextCtrl::UsePopUp(bool allowPopUp)

View File

@ -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

View File

@ -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);
//@}