So for the past week I've added the Command Entry to CodeAssistor.
Right now I've only implemented the search/replace functionality, but the framework now exists to start adding all sorts of awesomeness
So how does it work?
Open up a file and press the ESC key. You'll notice the entry popup
type '/' to start searching, then type in a regular expression (thats right, I said regular expression!)
eg "/#define (.*?) " (thats a space after the (.*?) , dont include the quote marks)
This will find the first #define XXX (but only #define XXX even if there is a #define XXX YYY)
Press ENTER. You've now moved to the next occurrence.
So what about replacing?
Ok continue your Command Entry so that the string looks like
"/#define (.+?) (.*)$/#ifdef \1\n#undef \1\n#endif\n#define \1 \2"
you'll notice that this doesn't replace. It's important to give the user a method of writing out the full regular expression and replacement string.
To actually replace the find add a final "/" to the command entry string... like this:
"/#define (.+?) (.*)$/#ifdef \1\n#undef \1\n#endif\n#define \1 \2/"
The library I am using for regular expressions (the basic scintilla regular expressions derived from Ozan Yigit's library plus some '?' extensions I did myself) doesn't (yet) understand the | metacharacter, so you'll have to write a separate line for "/#define ([^\s]+)$" (aka empty macros)