Extend FindText() to return end position of matched text in wxSTC
New 5th parameter of FindText() can be used to receive the end position of matched text returned by SCI_FINDTEXT API. Closes #17305. Closes https://github.com/wxWidgets/wxWidgets/pull/23
This commit is contained in:
committed by
Artur Wieczorek
parent
187c4692c8
commit
91a2869b0e
@@ -130,6 +130,8 @@ All (GUI):
|
|||||||
- Fix drawing filled arc with wxPostScriptDC::DrawArc().
|
- Fix drawing filled arc with wxPostScriptDC::DrawArc().
|
||||||
- Optimize PostScript code emitted by wxPostScriptDC to draw elliptic arcs.
|
- Optimize PostScript code emitted by wxPostScriptDC to draw elliptic arcs.
|
||||||
- Add wxStyledTextCtrl::AutoCompGetCurrentText() (NewPagodi).
|
- Add wxStyledTextCtrl::AutoCompGetCurrentText() (NewPagodi).
|
||||||
|
- Extend wxStyledTextCtrl::FindText() to return end position of matched
|
||||||
|
text (NewPagodi).
|
||||||
|
|
||||||
wxGTK:
|
wxGTK:
|
||||||
|
|
||||||
|
@@ -3555,7 +3555,8 @@ public:
|
|||||||
int GetPrintColourMode() const;
|
int GetPrintColourMode() const;
|
||||||
|
|
||||||
// Find some text in the document.
|
// Find some text in the document.
|
||||||
int FindText(int minPos, int maxPos, const wxString& text, int flags=0);
|
int FindText(int minPos, int maxPos, const wxString& text, int flags=0,
|
||||||
|
int* findEnd=NULL);
|
||||||
|
|
||||||
// On Windows, will draw the document into a display context such as a printer.
|
// On Windows, will draw the document into a display context such as a printer.
|
||||||
int FormatRange(bool doDraw,
|
int FormatRange(bool doDraw,
|
||||||
|
@@ -3091,10 +3091,32 @@ public:
|
|||||||
/**
|
/**
|
||||||
Find some text in the document.
|
Find some text in the document.
|
||||||
|
|
||||||
The fourth argument should be a bit list containing one or more of the
|
@param minPos
|
||||||
@link wxStyledTextCtrl::wxSTC_FIND_WHOLEWORD wxSTC_FIND_* @endlink constants.
|
The position (starting from zero) in the document at which to begin
|
||||||
|
the search
|
||||||
|
@param maxPos
|
||||||
|
The last position (starting from zero) in the document to which
|
||||||
|
the search will be restricted.
|
||||||
|
@param text
|
||||||
|
The text to search for.
|
||||||
|
@param flags
|
||||||
|
(Optional) The search flags. This should be a bit list containing
|
||||||
|
one or more of the @link wxStyledTextCtrl::wxSTC_FIND_WHOLEWORD
|
||||||
|
wxSTC_FIND_* @endlink constants.
|
||||||
|
@param findEnd
|
||||||
|
(Optional) This parameter can optionally be used to receive the
|
||||||
|
end position (starting from zero) of the found text. This is
|
||||||
|
primarily needed when searching using regular expressions.
|
||||||
|
This parameter is available since wxWidgets 3.1.1.
|
||||||
|
@return
|
||||||
|
The position (starting from zero) in the document at which the text
|
||||||
|
was found or wxSTC_INVALID_POSITION if the search fails.
|
||||||
|
@remarks
|
||||||
|
A backwards search can be performed by setting minPos to be greater
|
||||||
|
than maxPos.
|
||||||
*/
|
*/
|
||||||
int FindText(int minPos, int maxPos, const wxString& text, int flags=0);
|
int FindText(int minPos, int maxPos, const wxString& text, int flags=0,
|
||||||
|
int* findEnd=NULL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the position that starts the target which is used for updating the
|
Sets the position that starts the target which is used for updating the
|
||||||
|
@@ -1225,8 +1225,29 @@ extendedDocs = {
|
|||||||
('The input should be a time in milliseconds or wxSTC_TIME_FOREVER.',),
|
('The input should be a time in milliseconds or wxSTC_TIME_FOREVER.',),
|
||||||
|
|
||||||
'FindText':
|
'FindText':
|
||||||
('The fourth argument should be a bit list containing one or more of the',
|
('@param minPos',
|
||||||
'@link wxStyledTextCtrl::wxSTC_FIND_WHOLEWORD wxSTC_FIND_* @endlink constants.',),
|
' The position (starting from zero) in the document at which to begin',
|
||||||
|
' the search',
|
||||||
|
'@param maxPos',
|
||||||
|
' The last position (starting from zero) in the document to which',
|
||||||
|
' the search will be restricted.',
|
||||||
|
'@param text',
|
||||||
|
' The text to search for.',
|
||||||
|
'@param flags',
|
||||||
|
' (Optional) The search flags. This should be a bit list containing',
|
||||||
|
' one or more of the @link wxStyledTextCtrl::wxSTC_FIND_WHOLEWORD',
|
||||||
|
' wxSTC_FIND_* @endlink constants.',
|
||||||
|
'@param findEnd',
|
||||||
|
' (Optional) This parameter can optionally be used to receive the',
|
||||||
|
' end position (starting from zero) of the found text. This is',
|
||||||
|
' primarily needed when searching using regular expressions.',
|
||||||
|
' This parameter is available since wxWidgets 3.1.1.',
|
||||||
|
'@return',
|
||||||
|
' The position (starting from zero) in the document at which the text',
|
||||||
|
' was found or wxSTC_INVALID_POSITION if the search fails.',
|
||||||
|
'@remarks',
|
||||||
|
' A backwards search can be performed by setting minPos to be greater',
|
||||||
|
' than maxPos.',),
|
||||||
|
|
||||||
'AddUndoAction':
|
'AddUndoAction':
|
||||||
('The flags argument can be either 0 or wxSTC_UNDO_MAY_COALESCE.',),
|
('The flags argument can be either 0 or wxSTC_UNDO_MAY_COALESCE.',),
|
||||||
|
@@ -580,18 +580,20 @@ methodOverrideMap = {
|
|||||||
|
|
||||||
'FindText' :
|
'FindText' :
|
||||||
(0,
|
(0,
|
||||||
'''int %s(int minPos, int maxPos, const wxString& text, int flags=0);''',
|
'''int %s(int minPos, int maxPos, const wxString& text, int flags=0,
|
||||||
|
int* findEnd=NULL);''',
|
||||||
|
|
||||||
'''int %s(int minPos, int maxPos,
|
'''int %s(int minPos, int maxPos, const wxString& text,
|
||||||
const wxString& text,
|
int flags, int* findEnd) {
|
||||||
int flags) {
|
|
||||||
Sci_TextToFind ft;
|
Sci_TextToFind ft;
|
||||||
ft.chrg.cpMin = minPos;
|
ft.chrg.cpMin = minPos;
|
||||||
ft.chrg.cpMax = maxPos;
|
ft.chrg.cpMax = maxPos;
|
||||||
const wxWX2MBbuf buf = wx2stc(text);
|
const wxWX2MBbuf buf = wx2stc(text);
|
||||||
ft.lpstrText = (char*)(const char*)buf;
|
ft.lpstrText = (char*)(const char*)buf;
|
||||||
|
|
||||||
return SendMsg(%s, flags, (sptr_t)&ft);'''
|
int pos = SendMsg(%s, flags, (sptr_t)&ft);
|
||||||
|
if (findEnd) *findEnd=(pos==-1?wxSTC_INVALID_POSITION:ft.chrgText.cpMax);
|
||||||
|
return pos;'''
|
||||||
),
|
),
|
||||||
|
|
||||||
'FormatRange' :
|
'FormatRange' :
|
||||||
|
@@ -1704,16 +1704,17 @@ int wxStyledTextCtrl::GetPrintColourMode() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find some text in the document.
|
// Find some text in the document.
|
||||||
int wxStyledTextCtrl::FindText(int minPos, int maxPos,
|
int wxStyledTextCtrl::FindText(int minPos, int maxPos, const wxString& text,
|
||||||
const wxString& text,
|
int flags, int* findEnd) {
|
||||||
int flags) {
|
|
||||||
Sci_TextToFind ft;
|
Sci_TextToFind ft;
|
||||||
ft.chrg.cpMin = minPos;
|
ft.chrg.cpMin = minPos;
|
||||||
ft.chrg.cpMax = maxPos;
|
ft.chrg.cpMax = maxPos;
|
||||||
const wxWX2MBbuf buf = wx2stc(text);
|
const wxWX2MBbuf buf = wx2stc(text);
|
||||||
ft.lpstrText = (char*)(const char*)buf;
|
ft.lpstrText = (char*)(const char*)buf;
|
||||||
|
|
||||||
return SendMsg(SCI_FINDTEXT, flags, (sptr_t)&ft);
|
int pos = SendMsg(SCI_FINDTEXT, flags, (sptr_t)&ft);
|
||||||
|
if (findEnd) *findEnd=(pos==-1?wxSTC_INVALID_POSITION:ft.chrgText.cpMax);
|
||||||
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On Windows, will draw the document into a display context such as a printer.
|
// On Windows, will draw the document into a display context such as a printer.
|
||||||
|
Reference in New Issue
Block a user