i'm trying to build a search capability for an editor
based on StyledTextCtrl. based on a popup menu selection,
i'd like to find the next occurrence of the currently
selected text. i'm having a bit of trouble, though.
if i use the SearchNext() method, it starts the search
at the current anchor point, thus finding the text i've already
selected. the SearchAnchor() method takes no arguments, so
i can't tell it to move ahead a char to start. the FindText()
method looks like it may be a better bet, since i can give it
a start and stop argument, but i not quite sure what its
arguments are supposed to be. also, if i dig through
the wxpython source code, it doesn't appear that i can
tell it to do an RE search, which is what i want.
any ideas?
thanks
Garry Hodgson And when they offer
Senior Hacker golden apples garry@sage.att.com are you sure you'll refuse?
Software Innovation Services Heaven help the fool.
AT&T Labs
if i use the SearchNext() method, it starts the search
at the current anchor point, thus finding the text i've already
selected. the SearchAnchor() method takes no arguments, so
i can't tell it to move ahead a char to start.
SearchAnchor() sets the anchor to the current caret position, so if you move
the caret and then call it then you should be able to skip the text you just
found.
the FindText()
method looks like it may be a better bet, since i can give it
a start and stop argument, but i not quite sure what its
arguments are supposed to be.
// Find some text in the document.
int FindText(int minPos, int maxPos,
const wxString& text,
bool caseSensitive, bool wholeWord);
also, if i dig through
the wxpython source code,
For wxSTC you should be looking in the stc.h file for docs, (a copy of it is
included in wxPython/demo in the distributions.) Most of it is generated
directly from the Scintilla.iface file and is the best way to get (very
concise) info about each method.
it doesn't appear that i can
tell it to do an RE search, which is what i want.
I think a future version of Scintilla may have it. (Or it may be three
already, wxSTC is a couple revisions behind.) A fairly ugly option is to
pull the text from the control and use Python's RE searching on the buffer.
···
--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython!
> it doesn't appear that i can
> tell it to do an RE search, which is what i want.
I think a future version of Scintilla may have it. (Or it may be three
already, wxSTC is a couple revisions behind.)
Scintilla 1.37 has a *very basic* version of RE search and tagged
replace. You will probably want better.
If anyone regenerates wxSTC from Scintilla 1.37, please don't expose
ReplaceTarget as it is changing for 1.38.
A fairly ugly option is to
pull the text from the control and use Python's RE searching on the
buffer.
Its not that ugly IMHO and Python's RE is far superior to anything that
will ever be embedded in Scintilla. I use accessor objects that attach to a
Scintilla and give the appearance of direct access to the buffer contents.
This is fast enough to use internally for lexing and so should be good
enough for RE. The internal RE uses a different accessor class that is even
dumber and slower. It may be an idea to include a Python friendly accessor
class in wxSTC but as an initial step it could be done in Python.
Scintilla 1.37 has a *very basic* version of RE search and tagged
replace. You will probably want better.
...
> A fairly ugly option is to
> pull the text from the control and use Python's RE searching on the
buffer.
Its not that ugly IMHO and Python's RE is far superior to anything that
will ever be embedded in Scintilla.
okay, i went ahead and did my own searching, and it works just fine.
surprisingly fast. thanks for the tip.
···
--
Garry Hodgson sometimes we ride on your horses
Senior Hacker sometimes we walk alone
Software Innovation Services sometimes the songs that we hear
AT&T Labs are just songs of our own
garry@sage.att.com