Community
    • 登入

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

    已排程 已置頂 已鎖定 已移動 General Discussion
    35 貼文 22 Posters 44.1k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • richluxR
      richlux
      最後由 編輯

      I see that version 7.5 has updated the find dialog box and reverted back to the single “Find Next” button with a checkbox to reverse the order. I absolutely loved the two button approach and am very disappointed with this change. Is there a way to make the style of the find dialog box be an option, so everyone can have their preferred method?

      Rich

      1 條回覆 最後回覆 回覆 引用 4
      • dailD
        dail
        最後由 編輯

        Likely not because having the 2 buttons introduced problems. Such as not being able to replace all matches upwards to the beginning of the file.

        Scott SumnerS 1 條回覆 最後回覆 回覆 引用 2
        • Scott SumnerS
          Scott Sumner @dail
          最後由 編輯

          @dail

          … problems…not being able to replace all matches upwards to the beginning of the file

          With 7.4.2 it was possible to do that, you just had to make sure that your last “find” was a “<< Find” and not a “Find >>”. My big complaint with that was that you had to remember which one you did most recently–there was no way to tell from looking at the Find dialog box settings–and that was unacceptable. For now I’m glad that the old way is back with 7.5.

          There was some discussion in other threads that having the following buttons would clear up all the problems and make a better user interface (but I haven’t thought it all through to convince myself that it does):

          • << Find and Find >>
          • << Replace and Replace >>
          • << Replace All and Replace All >>
          dailD 1 條回覆 最後回覆 回覆 引用 6
          • dailD
            dail @Scott Sumner
            最後由 編輯

            @Scott-Sumner Ah thanks for the clarification :)

            1 條回覆 最後回覆 回覆 引用 0
            • richluxR
              richlux
              最後由 richlux 編輯

              My biggest issue with how it is now is that if I check “search backwards”, the next time I open the find dialog box, it will still be checked. Usually, when I need to search backwards, it’s for a specific instance while I have the find dialog open. Once I close it, I would like it to default to forward again the next time I open it.

              I can’t tell you how many times I’ve searched backwards in a file and then later (sometimes days later) went to search a different file where NPP tells me nothing was found until I realized that the “search backwards” option was checked. That’s why I liked the two buttons. I was 100% sure which direction I was searching. If NPP is sticking with a single Find button, perhaps we could have the option to reset the direction checkbox each time the find dialog box was opened. This would help greatly.

              Rich

              Scott SumnerS 1 條回覆 最後回覆 回覆 引用 1
              • Michael DiGregorioM
                Michael DiGregorio
                最後由 編輯

                The reason I loved the two button approach so much was that many times I search forward in a file and then need to go back one. Having both buttons saved having to check and uncheck a lot. I, too, like the idea of having separate forward/backward buttons for all 3 functions (find, replace, replace all).

                But one thing I find odd from this thread…doesn’t the “replace all” button replace everything in a file, not just from the cursor to the beginning or end of the file? Meaning it will wrap around if the cursor is in the middle of the file when “replace all” is pressed?

                Scott SumnerS 1 條回覆 最後回覆 回覆 引用 2
                • Scott SumnerS
                  Scott Sumner @Michael DiGregorio
                  最後由 編輯

                  @Michael-DiGregorio said:

                  doesn’t the “replace all” button replace everything in a file, not just from the cursor to the beginning or end of the file? Meaning it will wrap around if the cursor is in the middle of the file when “replace all” is pressed?

                  Replace All only does what you are describing if the Wrap around checkbox is checked.

                  1 條回覆 最後回覆 回覆 引用 1
                  • Scott SumnerS
                    Scott Sumner @richlux
                    最後由 編輯

                    @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 條回覆 最後回覆 回覆 引用 1
                    • glennfromiowaG
                      glennfromiowa
                      最後由 編輯

                      @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 條回覆 最後回覆 回覆 引用 1
                      • Scott SumnerS
                        Scott Sumner @glennfromiowa
                        最後由 編輯

                        @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 條回覆 最後回覆 回覆 引用 2
                        • Alessandro BarbieriA
                          Alessandro Barbieri
                          最後由 編輯

                          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 條回覆 最後回覆 回覆 引用 0
                          • Alan KilbornA
                            Alan Kilborn @Alessandro Barbieri
                            最後由 編輯

                            @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 條回覆 最後回覆 回覆 引用 0
                            • Bas van der VeekenB
                              Bas van der Veeken
                              最後由 編輯

                              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 條回覆 最後回覆 回覆 引用 2
                              • Chris TriggC
                                Chris Trigg
                                最後由 編輯

                                @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 條回覆 最後回覆 回覆 引用 3
                                • Roumen MollovR
                                  Roumen Mollov @Bas van der Veeken
                                  最後由 編輯

                                  @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 條回覆 最後回覆 回覆 引用 2
                                  • Noam ShannyN
                                    Noam Shanny @Bas van der Veeken
                                    最後由 編輯

                                    @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 條回覆 最後回覆 回覆 引用 1
                                    • Robert KinardR
                                      Robert Kinard
                                      最後由 編輯

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

                                      1 條回覆 最後回覆 回覆 引用 1
                                      • Edward MyersE
                                        Edward Myers
                                        最後由 編輯

                                        此回覆已被刪除!
                                        1 條回覆 最後回覆 回覆 引用 0
                                        • AZJIO AZJIOA
                                          AZJIO AZJIO
                                          最後由 編輯

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

                                          1 條回覆 最後回覆 回覆 引用 1
                                          • Daniel EarleD
                                            Daniel Earle
                                            最後由 編輯

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

                                            1 條回覆 最後回覆 回覆 引用 1
                                            • 第一個貼文
                                              最後的貼文
                                            The Community of users of the Notepad++ text editor.
                                            Powered by NodeBB | Contributors