Community
    • 登入

    Setting to close Find window after initiating search?

    已排程 已置頂 已鎖定 已移動 Help wanted · · · – – – · · ·
    10 貼文 3 Posters 1.0k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • Vinnie MV
      Vinnie M
      最後由 編輯

      When I want to search, I press CTRL+F and enter some text then click the Find Next button to begin the search. The search dialog stays open. Is there any setting to close that window when the search begins. I usually just use F3 after the initial search to find additional occurrences.

      I realize there are other posts here for people who want to keep it open while searching, but I was just wondering if by chance there was an option to control this behavior.

      Alan KilbornA 1 條回覆 最後回覆 回覆 引用 0
      • Alan KilbornA
        Alan Kilborn @Vinnie M
        最後由 編輯

        @Vinnie-M

        Probably the quickest way is to press Esc

        Vinnie MV 1 條回覆 最後回覆 回覆 引用 3
        • Vinnie MV
          Vinnie M @Alan Kilborn
          最後由 編輯

          Ok, thanks. I was hoping for an option to close it after the initial Find Next button was clicked.

          Alan KilbornA 1 條回覆 最後回覆 回覆 引用 0
          • Alan KilbornA
            Alan Kilborn @Vinnie M
            最後由 編輯

            @Vinnie-M

            Probably the desire for this is that the Find window takes up a huge amount of space?

            1 條回覆 最後回覆 回覆 引用 0
            • Vinnie MV
              Vinnie M
              最後由 編輯

              I just don’t need it at that point since I always do F3 after the initial entry of the search text. For me it’s just an unnecessary extra keystroke to remove it after starting the search.

              Alan KilbornA 1 條回覆 最後回覆 回覆 引用 0
              • Alan KilbornA
                Alan Kilborn @Vinnie M
                最後由 編輯

                @Vinnie-M

                If your search term is the word at the caret or some small bit of text that you could select first, you can avoid the _Find window entirely by executing Select and Find Next, which by default is Ctrl+F3. Just a thought.

                1 條回覆 最後回覆 回覆 引用 3
                • Vinnie MV
                  Vinnie M
                  最後由 編輯

                  That’s neat – Although it’s not always the case for my search term, I might be able to get used to that in those cases.

                  1 條回覆 最後回覆 回覆 引用 2
                  • SanderBouwhuisS
                    SanderBouwhuis
                    最後由 SanderBouwhuis 編輯

                    I too am really annoyed by this. I use the keyboard when using Notepad because it is a text editor. Everytime I do a search I get a popup window which doesn’t automatically close after I press the ENTER/RETURN key.
                    This should be very easy to implement right? A simple setting which auto closes the popup window which is obscuring the text you are editing.
                    I’m aware I can press the ESC key to close the window, but it happening automatically would greatly improve the fluidity of using Notepad.

                    Alan KilbornA 1 條回覆 最後回覆 回覆 引用 1
                    • Alan KilbornA
                      Alan Kilborn @SanderBouwhuis
                      最後由 Alan Kilborn 編輯

                      @SanderBouwhuis

                      The large Find window IS annoying on a single monitor setup (presume that is what yours is). On multiple monitors, it isn’t so bad, you can have Notepad++ maximized on one monitor and put the find window on the/an adjacent monitor.

                      Have you tried the “reduced size” Find window? It looks like this:

                      26c8d1e0-bb0e-4827-a1cd-209d5330a65b-image.png

                      and the size is toggled by the button I’ve highlighted in yellow; same relative location for the button in the larger version of the window, but it has a ^ caption in that case.


                      Another interesting idea would be if the Find window would go “roving” after each match is found…if it needs to. What this means is, if the text of the match found appears under the Find window, the window should reposition itself somewhere else, allowing you to see your matched text.

                      1 條回覆 最後回覆 回覆 引用 1
                      • Alan KilbornA
                        Alan Kilborn
                        最後由 編輯

                        The desired behavior can be scripted if one wants to use a plugin (PythonScript) to achieve the goal.

                        I call the script FindNextClosesFindWindow.py and here is its listing:

                        # -*- coding: utf-8 -*-
                        from __future__ import print_function
                        
                        # see https://community.notepad-plus-plus.org/topic/19844/setting-to-close-find-window-after-initiating-search
                        
                        from Npp import *
                        import platform
                        from ctypes import (WinDLL, WINFUNCTYPE)
                        from ctypes.wintypes import (HWND, UINT, INT, WPARAM, LPARAM)
                        
                        #-------------------------------------------------------------------------------
                        
                        user32 = WinDLL('user32')
                        
                        GWL_WNDPROC = -4  # used to set a new address for the window procedure
                        
                        LRESULT = LPARAM
                        
                        WndProcType = WINFUNCTYPE(
                            LRESULT,                    # return type
                            HWND, UINT, WPARAM, LPARAM  # function arguments
                            )
                        
                        running_32bit = platform.architecture()[0] == '32bit'
                        
                        SetWindowLong = user32.SetWindowLongW if running_32bit else user32.SetWindowLongPtrW
                        SetWindowLong.restype = WndProcType
                        SetWindowLong.argtypes = [ HWND, INT, WndProcType ]
                        
                        SendMessageW = user32.SendMessageW
                        SendMessageW.restype = LRESULT
                        SendMessageW.argtypes = [ HWND, UINT, WPARAM, LPARAM ]
                        
                        WM_COMMAND = 0x111
                        WM_CLOSE = 0x10
                        
                        IDOK = 1  # 'Find Next' button in Find dialog
                        # for the following see https://github.com/notepad-plus-plus/notepad-plus-plus/blob/3c9d58176b0fd890d26e96d0208d2d981f1544e4/PowerEditor/src/ScitillaComponent/FindReplaceDlg_rc.h#L1
                        IDC_FINDNEXT = 1723  # 'Find down-arrow' button in Find dialog
                        IDC_FINDPREV = 1721  # 'Find up-arrow' button in Find dialog
                        
                        #-------------------------------------------------------------------------------
                        
                        class FNCFW(object):
                        
                            def __init__(self):
                                for try_count in (1, 2):
                                    if try_count == 2: notepad.menuCommand(MENUCOMMAND.SEARCH_FIND)
                                    for find_window_tab_caption in [ u'Find', u'Replace', u'Find in Files', u'Find in Projects', u'Mark' ]:
                                        self.find_window_hwnd = user32.FindWindowExW(None, None, u'#32770', find_window_tab_caption)
                                        if self.find_window_hwnd:
                                            self.new_find_wnd_proc_hook_for_SetWindowLong = WndProcType(self.new_find_wnd_proc_hook)
                                            self.orig_find_wnd_proc = SetWindowLong(self.find_window_hwnd, GWL_WNDPROC, self.new_find_wnd_proc_hook_for_SetWindowLong)
                                            if try_count == 2: self.close_find_window()
                                            return
                        
                            def new_find_wnd_proc_hook(self, hwnd, msg, wParam, lParam):
                                orig_wnd_proc_ret_val = self.orig_find_wnd_proc(hwnd, msg, wParam, lParam)
                                if msg == WM_COMMAND and wParam in [ IDC_FINDNEXT, IDC_FINDPREV, IDOK ]: self.close_find_window()
                                return orig_wnd_proc_ret_val
                        
                            def close_find_window(self): SendMessageW(self.find_window_hwnd, WM_CLOSE, 0, 0)
                        
                        #-------------------------------------------------------------------------------
                        
                        if __name__ == '__main__':
                            try:
                                fncfw
                            except NameError:
                                fncfw = FNCFW()
                        

                        It can be set up in startup.py to run automatically when Notepad++ starts via these two lines:

                        import FindNextClosesFindWindow
                        fncfw = FindNextClosesFindWindow.FNCFW()
                        
                        1 條回覆 最後回覆 回覆 引用 3
                        • Alan KilbornA Alan Kilborn referenced this topic on
                        • 第一個貼文
                          最後的貼文
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors