Menu

#2053 Passing parameters to the Find in Files command

Feature_Request
closed-fixed
5
2019-01-11
2018-10-17
jj5
No

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.wholeword", wholeWord ? "1" : "0" );
  • 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") == "") {

  • // 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);
    return TRUE;

    case WM_CLOSE:
    @@ -1235,6 +1229,9 @@
    wholeWord = dlg.Checked(IDWHOLEWORD);
    matchCase = dlg.Checked(IDMATCHCASE);

  • props.Set("find.wholeword", wholeWord ? "1" : "0" );

  • props.Set("find.matchcase", matchCase ? "1" : "0" );
    +
    FillCombos(dlg);
    FillCombosForGrep(dlg);

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" );

Discussion

  • jj5

    jj5 - 2018-10-17

    the message as txt attachment to prevent sourceforge reformatting

     
  • Neil Hodgson

    Neil Hodgson - 2018-10-18

    Exposing these options as 0/1 makes it too difficult to use. As I said on the mailing list:

    The hassle with implementing the options is that a boolean choice needs to be translated into an option string like “/I” or “—ignore-case”. The added option may need to be for either of the alternatives - so there could be a “—case-sensitive” option or a “—case-insensitive” option.

    SciTE’s variable substitution language could be extended with a choice function but that would have to be designed.

     

    Last edit: Neil Hodgson 2018-10-18
    • jj5

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

      option.ignorecase.yes=—ignore-case
      option.ignorecase.no=
      
      #default to 1 and 0
      #option.wholeword.yes=
      #option.wholeword.no=
      

      Then I can search for these strings instead of providing just 1 or 0 here:

      e.g. instead

      props.Set("find.wholeword", wholeWord ? "1" : "0" ); 
      

      simply(?)

      strOptionWholeWordYes =
              props.GetNewExpandString("option.wholeword.yes"); // etc
      

      then

      props.Set("find.wholeword", wholeWord 
          ? strOptionWholeWordYes 
          : strOptionWholeWordNo ); 
      

      What do you think?

       

      Last edit: jj5 2018-10-18
      • Neil Hodgson

        Neil Hodgson - 2018-10-20

        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.".

         
        • jj5

          jj5 - 2018-10-21

          Thanks a lot! Then Monday or Tuesday I'll make the whole patch using "find.option.ignorecase.0" style names and submit it here.

           
  • jj5

    jj5 - 2018-10-23

    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

    find.command=/home/user/bin/fancySearch.pl $(find.wholeword) $(find.matchcase) "$(find.directory)" "$(find.files)" "$(find.what)" "$(FileNameExt)"
    

    with the example options:

    find.option.wholeword.0=
    find.option.wholeword.1=--match-whole-word
    find.option.matchcase.0=
    find.option.matchcase.1=--match-case
    

    (The base for the patch is SciTE 4.1.0)

     

    Last edit: jj5 2018-10-25
    • Neil Hodgson

      Neil Hodgson - 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:

      const std::string matchCaseName = std::string("find.option.matchcase.") + StdStringFromInteger(matchCase);
      
      props.Set("find.matchcase", props.GetNewExpandString(matchCaseName.c_str()));
      

      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.

       
      • jj5

        jj5 - 2018-10-25

        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.

         
      • jj5

        jj5 - 2018-10-25

        Atached: hopefully fully implemented Find in Files command with passing options.

        Diff -u to scite 4.1.2

         
        • jj5

          jj5 - 2018-11-25

          The patch posted in the previous message (jj5 - 2018-10-25 attachment: diff-find-command-scite.txt)

          • Implements passing the parameters to the external Find in Files using
              find.option.wholeword.0
              find.option.wholeword.1
              find.option.matchcase.0
              find.option.matchcase.1
          
          • 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

              find.wholeword
              find.matchcase
          

          properties which can be used in the find.command like in this example

          find.command=cmd /c c:\cygwin\bin\find "$(find.directory)" -name "*" -print0 | c:\cygwin\bin\xargs -0 grep $(find.wholeword) $(find.matchcase) -G -n "$(find.what)"
          
           
  • Neil Hodgson

    Neil Hodgson - 2018-11-27
    • labels: --> scite, find in files
    • status: open --> open-fixed
    • assigned_to: Neil Hodgson
     
  • Neil Hodgson

    Neil Hodgson - 2018-11-27

    Committed as [d8ae71].

     

    Related

    Commit: [d8ae71]

  • Neil Hodgson

    Neil Hodgson - 2019-01-11
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB