Community
    • Login

    Search++: A work in progress

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    5 Posts 2 Posters 111 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • CoisesC
      Coises
      last edited by Coises

      Over time the search function in Columns++ has stretched well beyond its original mission, which was to provide the ability to search in a column selection. While I don’t expect to remove search from Columns++, I felt the extensions to search I developed there would work better for a more general audience if they were separated from the logic and user interface already established in Columns++.

      I also wanted to experiment with alternatives to some of the user interface limitations of both native Notepad++ and Columns++ search.

      Finally, after saying multiple times that I could not figure out how to incorporate ICU into a plugin, a few weeks ago I searched one more time, and the answer popped right up, in the “AI” section at the top of the Google search results. I don’t know if something has changed, or if I just failed to find it before. (The answer, for C++ programmers, is at https://github.com/unicode-org/icu/releases/ — it’s pretty much just that simple, download the appropriate archive(s), set up the compiler and linker to use the include and binary libraries, include the DLLs in the output directory.) So instead of relying on my home-grown processing of the raw Unicode data files, I can now go straight to ICU.

      My experience suggests that early feedback from curious potential users does a lot to avert getting locked into bad design decisions. So, in a first version that will probably provide ample hunting ground for digital entymologists… I present Search++ as a work in progress:

      https://github.com/Coises/SearchPlusPlus/releases/

      There is a help file.

      Features

      • Search++ can be used as a docking dialog or an ordinary dialog. An advantage of the docking dialog is that search results and context will never wind up hidden behind the dialog. As an ordinary dialog, Search++ can be oriented either horizontally or vertically. By default, Search++ opens docked to the right side of Notepad++. You can change that with the first option in the Settings… dialog. (As with any docking window in Notepad++, you can float the docking dialog by dragging its title bar into the main Notepad++ area; however, Search++ as a regular dialog, chosen from the Settings dialog, is likely to be ”better behaved” than a floating dockable dialog.)

      • The Find and Replace fields in Search++ are Scintilla controls. This allows for easy inclusion and visualization of multiple lines, line ending characters and special characters, as well as zooming the fields as desired. Find and replace text is shown using the same font as in the main Notepad++ editing window.

      • Search++ can search within selections (including column selections and multiple selections) and within marked text. Commands are available to Find All (send a list of matches to a search results window), Select, Mark or Show (hide all lines, then unhide lines with matches and mark the matches).

      • Regular expression searches in Search++ perform a fully Unicode-based search using a customized combination of Boost.Regex and ICU4C. In particular, this produces fewer “surprising” results with Unicode characters above 0xFFFF (including most emoji) and when searching in documents using a DBCS code page (which in Notepad++ can be Chinese, Japanese or Korean files that are in the system default encoding instead of in Unicode).

      • Regular expression replacements in Search++ can include numeric calculations. The replacement syntax is similar to the one introduced in Columns++.

      Quirks and features with poor discoverability

      • The Find and Replace boxes and the Search++ Results window have right-click menus. There are various commands and shortcuts you won’t discover until you right-click. In particular, history for the Find and Replace windows is on their right-click menus.

      • The main command buttons (Find, Count, etc.) have drop-down menus. You can select an alternate action from those menus. If you Shift+click an item on the menu, that becomes the new action for clicking the button.

      • The Tools button at the top right of the Find box opens a menu of handy functions you might want to use in conjunction with search.

      • If you assign a keyboard shortcut to Search… on the Search++ plugin menu, you can use that to open a search dialog or to switch keyboard focus to it when it is already open. You can use Ctrl+O (think “Other”) to switch between the Find and Replace boxes or to switch from the Search Results list to the Find box. You can use Ctrl+N (think “Notepad++”) to switch keyboard focus back to the current Notepad++ editing window, and Ctrl+Shift+N to close the window you are in (either Search or Search Results) and switch focus back to Notepad++.

      • You can navigate the Search++ Results window by keyboard using the Tab key to move to the next match (or Shift+Tab to move to the previous match). The Enter key will locate in the document window the current cursor position or selection in the Search++ Results window. Shift+Enter will locate and move keyboard focus to the document window. (So you can use Tab to navigate and Enter to see any particular match in context; then when you want to move to that match for editing, use Shift+Enter.)

      • Formulas use the format (?=…) within the replacement box. You can use multiple formulas in one replacement and mix them with other, ordinary replacement strings. Within a formula, use $1 for the first capture group, $2 for the second, etc.; use $ or $0 for the entire match. The match or sub-match is interpreted as a number, and you can use ordinary arithmetic. For example, if the Find string matches a number, (?=$+100) would be replaced by that number plus 100.

      • The Settings… dialog (available from the Search++ plugin menu or the Tools menu) has quite a few options you might want to review.

      • The ICU button at the top is there mostly for testing. It uses the regular expression engine built into ICU, which has different syntax than the familiar Boost.Regex engine and does not integrate as well with Scintilla. Replace is not implemented for this search engine, and it only works on Unicode documents. It will probably be removed when Search++ reaches version 1.0, as it really isn’t very useful except as a check on the results from the main Regex engine (since I’ve meddled with the main Regex engine quite a lot, and I haven’t modified the ICU engine in any way).

      Missing and Planned Features, and things I know don’t work quite right yet

      • Search++ does not yet support Find or Replace in all open documents or in files in a directory. I plan to add those capabilities, but I have not determined how I can/will do it.

      • I plan to add a Save function that will let you save searches you might want to use again. Of course, once it is possible to save, it has to be possible to delete and rename and edit and organize… I haven’t designed a user interface for any of that yet.

      • The Search++ Results window doesn’t show matches clearly in dark mode. I might be able to fix that without requiring user intervention; but depending on user experience, I suspect I might need to add the ability to customize colors and perhaps other details of all the Scintilla windows (Find/Replace and Search Results).

      • If you edit a document that has results in the Search++ Results window, the results will no longer be “in sync” with the document and you won’t be able to navigate accurately to matches following the edit point. I don’t know if it is possible to overcome this, but I would like to do so if I find that I can.

      • I’ve implemented a sort of “collision detection” when doing stepwise Find or Replace with the regular (non-docking) dialog or locating matches from the search results, so the document will be scrolled as needed to avoid the found text being obscured by the search window. I know it doesn’t work as well as it could yet. (It’s a surprisingly tricky problem to solve, and I couldn’t find any examples of it being solved already.)

      • I hope to add more features to the regular expression search. The current version is almost identical to the search in Columns++, but presented in what is hopefully a more flexible and user-friendly interface. It should be more accurate for Unicode-derived properties since it uses ICU4C directly instead of working from the home-grown parse of Unicode tables used in Columns++. If I can work out a way, I hope to add Unicode word breaks and more Unicode properties.

      Alan KilbornA 1 Reply Last reply Reply Quote 3
      • Alan KilbornA
        Alan Kilborn @Coises
        last edited by

        @Coises

        I haven’t checked it out yet, but going on the feature description, it sounds as if you’ve made Notepad++'s native search functionality essentially obsolete.

        CoisesC 1 Reply Last reply Reply Quote 1
        • CoisesC
          Coises @Alan Kilborn
          last edited by

          @Alan-Kilborn said in Search++: A work in progress:

          @Coises

          I haven’t checked it out yet, but going on the feature description, it sounds as if you’ve made Notepad++'s native search functionality essentially obsolete.

          I grant that it is an ambitious project… far too ambitious to suggest as changes to Notepad++. (Apart from all the other changes, just the difference in the way search is implemented, which comes from Columns++, is almost certainly too large and risky a change to propose to the base program.) If it is successful, I hope it can supplant native search in nearly all situations for those who like its user interface.

          I’m sure some people are going to take one look at the UI and go… WTF? I have an admitted bias towards designing toolboxes for power users over leading casual users by the hand. I try to be intuitive, but I’ll take functionality over obviousness if it’s an either/or choice. That’s not going to work for everybody… not everyone has the time and interest to read documentation to figure out how to use a search dialog.

          I’m sure glitches and omissions in the feature set will turn up. If I’m lucky, I’ll be able to address them without radical redesign.

          It’s still missing search in open documents and search in files in a directory… until and unless I can add those, it will be lacking crucial capabilities of native search. I think that and the search results in dark mode (which shouldn’t be all that difficult, I just haven’t worked it out yet) are the only blockers, aside from gaining a history of stability and reliability, to adopting it as a “daily driver” search for those who would choose to do so.

          Alan KilbornA 1 Reply Last reply Reply Quote 0
          • Alan KilbornA
            Alan Kilborn @Coises
            last edited by

            @Coises said:

            bias towards designing toolboxes for power users over leading casual users by the hand

            I consider this a good thing. :-)

            I’m sure some people are going to take one look at the UI and go… WTF?

            Like this?
            https://github.com/notepad-plus-plus/notepad-plus-plus/issues/9627
            :-)

            CoisesC 1 Reply Last reply Reply Quote 0
            • CoisesC
              Coises @Alan Kilborn
              last edited by

              @Alan-Kilborn said in Search++: A work in progress:

              Like this?
              https://github.com/notepad-plus-plus/notepad-plus-plus/issues/9627
              :-)

              Now my head hurts.

              Perhaps I should have included screenshots. Docked (default):

              a7382038-3c86-479f-a157-4192337c89f3-image.png

              Horizontal (non-docking):

              8f0da994-3187-41a1-a59f-3030a9242978-image.png

              1 Reply Last reply Reply Quote 3
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors