Community
    • Login

    Search++: A work in progress

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    1 Posts 1 Posters 32 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.

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