Passing parameters to the Find in Files command
When find.command is not empty passing of the parameters wholeWord and matchCase is at the moment disabled.
I've modified Scite to pass both values this way:
diff -r -u ../../scite-ref/scite/gtk/SciTEGTK.cxx ./gtk/SciTEGTK.cxx
--- ../../scite-ref/scite/gtk/SciTEGTK.cxx 2018-06-19 01:06:25.000000000 +0200
+++ ./gtk/SciTEGTK.cxx 2018-10-10 12:49:37.040248434 +0200
@@ -2153,6 +2153,9 @@
props.Set("find.files", filesEntry);
memFiles.Insert(filesEntry);
props.Set("find.matchcase", matchCase ? "1" : "0" );
+
if (props.GetInt("find.in.files.close.on.find", 1)) {
dlgFindInFiles.Destroy();
}
@@ -2499,7 +2502,7 @@
table.Add(); // Space
bool enableToggles = props.GetNewExpandString("find.command") == "";
bool enableToggles = true;
// Whole Word
dlgFindInFiles.toggleWord.Create(localiser.Text(toggles[SearchOption::tWord].label));
diff -r -u ../../scite-ref/scite/win32/SciTEWinDlg.cxx ./win32/SciTEWinDlg.cxx
--- ../../scite-ref/scite/win32/SciTEWinDlg.cxx 2018-06-19 01:06:25.000000000 +0200
+++ ./win32/SciTEWinDlg.cxx 2018-10-10 13:13:42.551995433 +0200
@@ -1194,14 +1194,8 @@
FillCombosForGrep(dlg);
dlg.SetItemTextU(IDFINDWHAT, props.GetString("find.what"));
dlg.SetItemTextU(IDDIRECTORY, props.GetString("find.directory"));
if (props.GetNewExpandString("find.command") == "") {
dlg.SetCheck(IDMATCHCASE, matchCase);
return TRUE;
case WM_CLOSE:
@@ -1235,6 +1229,9 @@
wholeWord = dlg.Checked(IDWHOLEWORD);
matchCase = dlg.Checked(IDMATCHCASE);
props.Set("find.wholeword", wholeWord ? "1" : "0" );
Then $(find.wholeword) and $(find.matchcase) (which expand to 0 or 1) can be used in
find.command=
string. It's convenient when the find.command is your own script which e.g. knows that 00 means "don't enforce whole word and don't enforce match case" etc.
Also as patch to scite410.tgz:
diff -r ../../scite-ref/scite/gtk/makefile ./gtk/makefile
80c80
< $(CC) $(INCLUDEDIRS) $(MISLEADING) -DLUA_USE_POSIX $(CXXTFLAGS) $(CFLAGS) -c $< -o $@
$(CC) $(INCLUDEDIRS) $(MISLEADING) -DLUA_USE_LINUX $(CXXTFLAGS) $(CFLAGS) -c $< -o $@
diff -r ../../scite-ref/scite/gtk/SciTEGTK.cxx ./gtk/SciTEGTK.cxx
2155a2156,2158
props.Set("find.wholeword", wholeWord ? "1" : "0" );
props.Set("find.matchcase", matchCase ? "1" : "0" );2502c2505
< bool enableToggles = props.GetNewExpandString("find.command") == "";
bool enableToggles = true;diff -r ../../scite-ref/scite/win32/SciTEWinDlg.cxx ./win32/SciTEWinDlg.cxx
1197,1204c1197,1198
< if (props.GetNewExpandString("find.command") == "") {
< // Empty means use internal that can respond to flags
< dlg.SetCheck(IDWHOLEWORD, wholeWord);
< dlg.SetCheck(IDMATCHCASE, matchCase);
< } else {
< dlg.Enable(IDWHOLEWORD, false);
< dlg.Enable(IDMATCHCASE, false);
< }
dlg.SetCheck(IDWHOLEWORD, wholeWord); dlg.SetCheck(IDMATCHCASE, matchCase);1236a1231,1233
props.Set("find.wholeword", wholeWord ? "1" : "0" ); props.Set("find.matchcase", matchCase ? "1" : "0" );
the message as txt attachment to prevent sourceforge reformatting
Exposing these options as 0/1 makes it too difficult to use. As I said on the mailing list:
Last edit: Neil Hodgson 2018-10-18
For my purposes, I call the script I've written so if I get -00 -01 -10 -11 they are good enough to me. But maybe we don't need the new language constructs? Maybe if we introduce
Then I can search for these strings instead of providing just 1 or 0 here:
e.g. instead
simply(?)
then
What do you think?
Last edit: jj5 2018-10-18
This would be more extensible if it used "0" and "1" instead of "yes" and "no" as an additional option (like "Starts With" on "Whole Word") could be "option.wholeword.2".
Prefixing the names with "find.", "find.in", or "find.option." makes them a bit more explanatory than "option.".
Thanks a lot! Then Monday or Tuesday I'll make the whole patch using "find.option.ignorecase.0" style names and submit it here.
The patch that allows Fin in Files to pass the options is attached.
Allows by default passing wholeword and matchcase to the find.commmand
An example would be
with the example options:
(The base for the patch is SciTE 4.1.0)
Last edit: jj5 2018-10-25
SciTE's command-line grep was there to avoid threads and is now only used on Linux. Linux should use threads for Find in Files and the command-line grep handling should be removed (in the longer term). Don't encourage its use as that makes it harder to remove.
I'd prefer to avoid repeating the names so much and avoid lookups with something like this:
This code is common between the platforms so should be in the SciTEBase class where it can be shared.
The options should be added to doc/SciTEDoc.html.
Its easier to understand patches in unified format "diff -u".
https://en.wikipedia.org/wiki/Diff#Unified_format
I will be on vacation for 2-3 weeks so may not respond.
Thanks, I'll see to add and change what you suggest. Moreover I've removed my mention of SciTE's command-line grep in my previous post.
Atached: hopefully fully implemented Find in Files command with passing options.
Diff -u to scite 4.1.2
The patch posted in the previous message (jj5 - 2018-10-25 attachment: diff-find-command-scite.txt)
Avoids repeating the names (as suggested by Neil Hodgson on 2018-10-25)
Moves the code common for more platforms to the SciTEBase class
The SciTEDoc.html has added options above and the description and the example of their use
The complete functionality is implemented in only 13 code lines (most of which is one new function in the SciTEBase), and it removes the special treatment of the Find in Files dialog for the external vs. the internal case, now it behaves the same in all cases, using the "find.option." values to expand the
properties which can be used in the find.command like in this example
Committed as [d8ae71].
Related
Commit: [d8ae71]