Community
    • Login

    Make "Find Next" / "Find Prev" buttons an option

    Scheduled Pinned Locked Moved General Discussion
    35 Posts 22 Posters 41.0k 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.
    • Scott SumnerS
      Scott Sumner @richlux
      last edited by

      @richlux said:

      perhaps we could have the option to reset the direction checkbox each time the find dialog box was opened.

      Maybe…but I wouldn’t count on it. @donho seems to have very specific ideas about how things should be, and what should be configurable via options–I’m okay with that as it is his program, after all. :-)

      Coming to Notepad++ after 20 years of using an editor where this behavior was configurable–I could tell it that each time the Find window was invoked to set the search direction to Down–not having that capability drove me nuts…until I found a way to script it in order to bend it to my will.

      At first I used AutoIt3 to do it, but that had some drawbacks; more recently I’ve switched to a Pythonscript method. I’ll share it below; it will work on Notepad++ versions 7.5 and anything reasonably current but less than 7.4.2 (tested on 7.5 and 7.2.2).

      So to use the script you obviously have to have the Pythonscript plugin installed. Use the shortcut mapper to remap ctrl+f to the script (and remove the default binding). Sorry, mouse users, there isn’t a great way to get this functionality via the mouse (without navigating nested menus or creating a toolbar button–certainly nothing as minimal as a quick keystroke!).

      Here’s FindDialogAutosetDirectionToDown.py:

      import ctypes
      from ctypes.wintypes import BOOL, HWND, LPARAM, WPARAM
      
      def FDADTD__main():  # (F)ind(D)ialog(A)utoset(D)irection(T)o(D)own
      
          backwards_checkbox_text = u'Backward direction'  # N++ 7.5 (and up?)
          direction_up_radio_button_text = u'&Up'          # N++ before 7.4.2
          direction_down_radio_button_text = u'&Down'      # N++ before 7.4.2
          find_what_box_text = u'&Find what :'
      
          WNDENUMPROC = ctypes.WINFUNCTYPE(BOOL, HWND, LPARAM)
          FindWindow = ctypes.windll.user32.FindWindowW
          SendMessage = ctypes.windll.user32.SendMessageW
          EnumChildWindows = ctypes.windll.user32.EnumChildWindows
          create_unicode_buffer = ctypes.create_unicode_buffer
          GetWindowText = ctypes.windll.user32.GetWindowTextW
          GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW
          BM_GETCHECK = 0x00F0
          BM_CLICK = 0x00F5
          WM_NEXTDLGCTL = 0x28
      
          # invoke/show the Find tab of the Find dialog:
          notepad.menuCommand(MENUCOMMAND.SEARCH_FIND)
      
          find_dialog_hwnd = FindWindow(None, u'Find')
      
          FDADTD__main.backwards_checkbox_hwnd = None        # N++ 7.5 (and up?)
          FDADTD__main.direction_up_radio_btn_hwnd = None    # N++ before 7.4.2
          FDADTD__main.direction_down_radio_btn_hwnd = None  # N++ before 7.4.2
          FDADTD__main.find_what_box_trigger_enable = False
          FDADTD__main.find_what_box_hwnd = None
      
          def EnumCallback(hwnd, lparam):
              win_text_len_plus1 = GetWindowTextLength(hwnd) + 1
              window_text = ctypes.create_unicode_buffer(win_text_len_plus1)
              GetWindowText(hwnd, window_text, win_text_len_plus1)
              if window_text.value == backwards_checkbox_text: FDADTD__main.backwards_checkbox_hwnd = hwnd
              elif window_text.value == direction_up_radio_button_text: FDADTD__main.direction_up_radio_btn_hwnd = hwnd
              elif window_text.value == direction_down_radio_button_text: FDADTD__main.direction_down_radio_btn_hwnd = hwnd
              elif window_text.value == find_what_box_text:
                  # the control we need is the control FOLLOWING the one with the correct text on it, so set up a trigger flag to grab the NEXT control
                  FDADTD__main.find_what_box_trigger_enable = True
              elif FDADTD__main.find_what_box_trigger_enable:
                  FDADTD__main.find_what_box_hwnd = hwnd
                  FDADTD__main.find_what_box_trigger_enable = False
              return True
          EnumChildWindows(find_dialog_hwnd, WNDENUMPROC(EnumCallback), 0)
      
          if FDADTD__main.backwards_checkbox_hwnd:
              # running N++ 7.5 (and up?)
              if SendMessage(FDADTD__main.backwards_checkbox_hwnd, BM_GETCHECK, 0, 0) == 1:
                  # backwards checkbox was checked; uncheck it:
                  SendMessage(FDADTD__main.backwards_checkbox_hwnd, BM_CLICK, 0, 0)
          else:
              # running N++ prior to 7.4.2
              if SendMessage(FDADTD__main.direction_up_radio_btn_hwnd, BM_GETCHECK, 0, 0) == 1:
                  # direction is set to up; set it to down:
                  SendMessage(FDADTD__main.direction_down_radio_btn_hwnd, BM_CLICK, 0, 0)
      
          if FDADTD__main.find_what_box_hwnd:
              # want input focus on the Find-what box, but it could be elsewhere from the above code
              # put the focus on the Find-what box
              # (see https://blogs.msdn.microsoft.com/oldnewthing/20040802-00/?p=38283 for how this is properly done)
              SendMessage(find_dialog_hwnd, WM_NEXTDLGCTL, WPARAM(FDADTD__main.find_what_box_hwnd), True)
      
      FDADTD__main()
      

      This script was inspired by coding ideas presented here: https://notepad-plus-plus.org/community/topic/13754/replace-1-lines

      If this (or ANY posting on the Notepad++ Community site) is useful, don’t reply with a “thanks”, simply up-vote ( click the ^ in the ^ 0 v area on the right ).

      1 Reply Last reply Reply Quote 1
      • glennfromiowaG
        glennfromiowa
        last edited by

        @dail, @scott-sumner and others, there was also some discussion (can’t remember where now) about the fact that fitting the words in multiple languages on the buttons was problematic. Although, I believe that could be fixed by removing the Find, Replace, and Replace All text from the buttons themselves; instead placing it above or in-between each pair of buttons (making sure it’s clear which buttons each text goes with), and then just have << and >> on the buttons themselves.

        As a side note, I almost never used the search Up feature (much less than 1%), probably because it was a pain to click on it, then click back later; so when this came out, I went “Meh.” But in the few days I had the << Find button, I did use it a couple of times, as it was convenient to have it there.

        @michael-digregorio I almost always have the Wrap around box checked, so I assumed Replace All had that functionality too, similar to the Count button in the Find box. I usually select text, then use Replace All with the In selection box checked when I want to replace in only part of the document.

        Speaking of the In selection box, I’ve noticed it sometimes gets unchecked at certain times - although strangely, not when the Replace dialog is closed and re-opened. I haven’t tested to find out when it gets unchecked; I just verify it’s checked before clicking Replace All again. So @richlux, I support your suggestion, especially as it may be able to follow the rules for unchecking the In selection box, to make it fit in with how @donho likes to see things. :-)

        Scott SumnerS 1 Reply Last reply Reply Quote 1
        • Scott SumnerS
          Scott Sumner @glennfromiowa
          last edited by

          @glennfromiowa said:

          …(Replace) In-selection box, I’ve noticed it sometimes gets unchecked…

          It will get unchecked (and disabled) anytime the Replace dialog is opened/activated and there is no selected text in the editor tab that is currently active. It will also get unchecked (and disabled) if there is a column-selection active in the editor tab that is currently active when Replace is invoked.

          If multi-select is enabled and multiple selections are active, there is nothing odd about the in-selection checkbox’s behavior, but if a replace-all is attempted under these conditions (with the in-selection checkbox checked), only the most recent of the multi-selected areas is effected!

          1 Reply Last reply Reply Quote 2
          • Alessandro BarbieriA
            Alessandro Barbieri
            last edited by

            My upvote for the separate “<< [Search|Replace|Replace All]” and / “[Search|Replace|Replace All]>>” buttons… maybe with the backwards button disabled if “Wrap around” is checked.
            Since I saw it in 7.4.2 I really loved having the two separate buttons, I think the checkbox is simpler but quite ugly

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

              @Alessandro-Barbieri said:

              with the backwards button disabled if “Wrap around” is checked

              Searching backwards (up toward top-of-file from current caret position) and wraparound are two completely independent concepts–why do you want to join them in this way?

              It is completely valid to be searching backwards and wanting to continue (the backwards search) at the end-of-file once you hit the beginning of the file.

              Searching backwards IS incompatible with the regular expression search mode, and the backwards-direction checkbox should be (and is) disabled when the search mode is changed to regex, but that is the only circumstance in the Find dialog options that needs to be restricted. This is discussed more in other threads…

              1 Reply Last reply Reply Quote 0
              • Bas van der VeekenB
                Bas van der Veeken
                last edited by

                Came to this forum just to let know that I LOVED << Find | Find >>, I will revert to 7.4.2 and will wait until it is restored.

                Roumen MollovR Noam ShannyN 2 Replies Last reply Reply Quote 2
                • Chris TriggC
                  Chris Trigg
                  last edited by

                  @Bas-van-der-Veeken said:

                  Came to this forum just to let know that I LOVED << Find | Find >>, I will revert to 7.4.2 and will wait until it is restored.

                  Totally agree, I just updated some of my older installs on various workstation to get the << Find Find >> buttons, and they are gone already. - Damn! Make it an option!
                  Don’t tempt us with goodness then take it away. how silly.

                  1 Reply Last reply Reply Quote 3
                  • Roumen MollovR
                    Roumen Mollov @Bas van der Veeken
                    last edited by

                    @Bas-van-der-Veeken said:

                    Came to this forum just to let know that I LOVED << Find | Find >>, I will revert to 7.4.2 and will wait until it is restored.

                    Same here, gone back to 7.4.2 until << Find and Find >> appear again.

                    1 Reply Last reply Reply Quote 2
                    • Noam ShannyN
                      Noam Shanny @Bas van der Veeken
                      last edited by

                      @Bas-van-der-Veeken said:

                      Came to this forum just to let know that I LOVED << Find | Find >>, I will revert to 7.4.2 and will wait until it is restored.

                      Same here! Please restore this great feature!

                      1 Reply Last reply Reply Quote 1
                      • Robert KinardR
                        Robert Kinard
                        last edited by

                        Just adding my voice to those asking for this feature to be added back in some way. Thanks.

                        1 Reply Last reply Reply Quote 1
                        • Edward MyersE
                          Edward Myers
                          last edited by

                          This post is deleted!
                          1 Reply Last reply Reply Quote 0
                          • AZJIO AZJIOA
                            AZJIO AZJIO
                            last edited by

                            I suggest leaving the checkbox. But the buttons “Find >>” and “<< Find” must switch the checkbox.

                            1 Reply Last reply Reply Quote 1
                            • Daniel EarleD
                              Daniel Earle
                              last edited by

                              I hated the << Find | Find >> buttons, JUST ALWAYS USE FIND ALL OCCURRENCES!! ONLY EVER!!

                              1 Reply Last reply Reply Quote 1
                              • Matt SmithM
                                Matt Smith
                                last edited by Matt Smith

                                I rolled back to v7.4.2

                                the two buttons are just too useful

                                1 Reply Last reply Reply Quote 1
                                • Matt SmithM
                                  Matt Smith
                                  last edited by

                                  I think the best solution would be to add an option in the settings to choose between the current setup and the double buttons setup

                                  when the option is enabled,
                                  << Find and Find >>
                                  will always show

                                  << Count and Count >>
                                  << Replace and Replace >>
                                  << ReplaceAll and ReplaceAll>>

                                  should only be visible if the “wrap around” checkbox is not selected

                                  it seems to me that this would be the solution to make everybody happy

                                  Scott SumnerS 1 Reply Last reply Reply Quote 0
                                  • AZJIO AZJIOA
                                    AZJIO AZJIO
                                    last edited by

                                    you have not all buttons. Your option will have to be returned again.

                                    1 Reply Last reply Reply Quote 0
                                    • Scott SumnerS
                                      Scott Sumner @Matt Smith
                                      last edited by

                                      @Matt-Smith

                                      add an option in the settings to choose between the current setup and the double buttons setup

                                      Software developers are resistant to making everything super-configurable, for a number of reasons. I understand this, and agree with the philosophy. It is better to decide that a change is worthwhile and then plow ahead with it. @donho seemed to make this decision by creating the <<Find and Find>> buttons in 7.4.2. However, it seems the feature wasn’t thought fully through and had to be “backed out”, although that introduced yet another new way of doing things (a direction checkbox instead of 2 radio buttons).

                                      << Count and Count >>

                                      Your idea for <<Count and Count>> buttons is intriguing, although it doesn’t take into account the existing functionality, meaning what if you want the total count–do you press the <<Count button, see the result (e.g. 5), then press the Count>> button and see that result (e.g. 7), and do the mental math to come up with the total document count (12). Seems burdensome…

                                      1 Reply Last reply Reply Quote 0
                                      • Marc CawoodM
                                        Marc Cawood
                                        last edited by

                                        Every decent editor has Find Next and Find Previous so there is impossibility here. It’s one of the most glaring flaws with NPP.

                                        I’ll be leaving NPP (after years of use) for VS Code until the Find Previous button re-surfaces.

                                        1 Reply Last reply Reply Quote 1
                                        • Kathryn NelsonK
                                          Kathryn Nelson
                                          last edited by

                                          I was okay with either the two button or the toggle - but the latest version 64-bit, doesn’t seem to have either!. The tool tip on Find Next tells you to do shift enter to search up and I’m sort of getting used to it, but a lot less obvious than having something on the box. (enough to keep me from updating my other machine.)

                                          Scott SumnerS 1 Reply Last reply Reply Quote 0
                                          • Scott SumnerS
                                            Scott Sumner @Kathryn Nelson
                                            last edited by Scott Sumner

                                            @Kathryn-Nelson

                                            The toggle – if what you mean by that is the Direction group box with the Up and Down radiobuttons (present pre-7.4.2)-- was not restored in 7.5 and later (when the <<Find button design of 7.4.2 was backed out), but rather was replaced with a single control called Backward direction (a checkbox). It’s with the other checkboxes on the left side of the Find window.

                                            Instead of toggling between two radio buttons, you just either check or uncheck the checkbox. Equivalent but different…

                                            If this (or ANY posting on the Notepad++ Community site) is useful, don’t reply with a “thanks”, simply up-vote ( click the ^ in the ^ 0 v area on the right ).

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