Community
    • Login

    Bookmark line becomes unchecked on reopening application

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    bookmarks
    7 Posts 4 Posters 2.7k Views 2 Watching
    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.
    • Mario ChávezM Offline
      Mario Chávez
      last edited by

      Bookmark line issue.PNG

      Hello, I run searches on large text files at work. Whenever I need to bookmark my searches on lines of text, I naturally check the parameter Bookmark line. The problem? If I restart the application or if I install a Notepad++ update and restart the application, all my customized preferences, such as Backward direction, the font size, Wrap around, etc. are maintained, except Bookmark line, which appears unchecked.

      This is a bit annoying because I need it to be checked permanently so that I can copy the bookmarked lines on the searched text file.

      Any suggestions? Maybe it’s a bug. Thank you.

      PeterJonesP Alan KilbornA 2 Replies Last reply Reply Quote 0
      • PeterJonesP Online
        PeterJones @Mario Chávez
        last edited by

        @mario-chávez said in Bookmark line becomes unchecked on reopening application:

        Maybe it’s a bug.

        It’s not a bug. It’s just not a feature I’ve heard of anyone asking for, and maybe not one that the developers have thought of to implement. If you would like Notepad++ to remember the “Bookmark line” checkbox like it remembers the other checkboxes, you can follow the FAQ instructions for making a feature request

        1 Reply Last reply Reply Quote 3
        • Alan KilbornA Online
          Alan Kilborn @Mario Chávez
          last edited by PeterJones

          @mario-chávez

          If you’re willing to use the PythonScript plugin, I have a solution in the form of…a script!

          I call the script BookmarkLineCheckboxTick.py and it looks like this:

          # -*- coding: utf-8 -*-
          from __future__ import print_function
          
          #-------------------------------------------------------------------------------
          
          from Npp import *
          import inspect
          import os
          import ctypes
          from ctypes import wintypes
          
          #-------------------------------------------------------------------------------
          
          user32 = ctypes.WinDLL('user32')
          
          LRESULT = wintypes.LPARAM
          
          SendMessageW = user32.SendMessageW
          SendMessageW.restype = LRESULT
          SendMessageW.argtypes = [ wintypes.HWND, wintypes.UINT, wintypes.WPARAM, wintypes.LPARAM ]
          
          #-------------------------------------------------------------------------------
          
          IDC_MARKLINE_CHECK = 1616
          BM_SETCHECK = 0x00F1
          BST_CHECKED = 1
          
          #-------------------------------------------------------------------------------
          
          class BLCT(object):
          
              def __init__(self):
                  notepad.menuCommand(MENUCOMMAND.SEARCH_MARK)
                  find_dlg_hwnd = user32.FindWindowExW(None, None, u'#32770', u'Mark')
                  bookmark_checkbox_hwnd = user32.GetDlgItem(find_dlg_hwnd, IDC_MARKLINE_CHECK)
                  SendMessageW(bookmark_checkbox_hwnd, BM_SETCHECK, BST_CHECKED, 0)
          
          #-------------------------------------------------------------------------------
          
          if __name__ == '__main__': BLCT()
          

          It can be set to run at Notepad++ startup by setting the scripting plugin’s Initialisation parameter to ATSTARTUP and then putting the following lines into the startup (User) script:

          import BookmarkLineCheckboxTick
          BookmarkLineCheckboxTick.BLCT()
          

          The result of this will be that the Bookmark line checkbox will always be ticked when Notepad++ starts.

          Michael VincentM 1 Reply Last reply Reply Quote 3
          • Michael VincentM Offline
            Michael Vincent @Alan Kilborn
            last edited by

            @alan-kilborn said in Bookmark line becomes unchecked on reopening application:

            If you’re willing to use the PythonScript plugin, I have a solution in the form of…a script!

            I’m willing - but I don’t want that use case. I want to check the “Highlight all” in the Search => Incremental Search “window”.

            I modified your script, but having some issues. The Incremental Search windows is “attached” to Notepad++ so I don’t see a new Windows class name (#32770 like for the “Mark” pop-up). Also, for the Window title - “Mark” works nicely for the Mark window popup - what do I use for the Incremental Search “window” which is “attached” to Notepad++ - the Notepad++ “title” I have changes based on the open filename. I think i got the other stuff done:

            • replace IDC_MARKLINE_CHECK with IDC_INCFINDHILITEALL (1690, from ScintillaComponent/FindReplaceDlg_rc.h)
            • MENUCOMMAND.SEARCH_MARK replaced with MENUCOMMAND.SEARCH_FINDINCREMENT

            So my script does open the Incremental Search “window”, but it does not check the “Highlight all” checkbox. Any pointers?

            Cheers.

            Alan KilbornA 1 Reply Last reply Reply Quote 2
            • Alan KilbornA Online
              Alan Kilborn @Michael Vincent
              last edited by Alan Kilborn

              @michael-vincent said in Bookmark line becomes unchecked on reopening application:

              but it does not check the “Highlight all” checkbox. Any pointers?

              It’s all about having that control’s handle (hwnd).

              Cobbling some code together by stealing a lot from THIS THREAD, I came up with this:

              # -*- coding: utf-8 -*-
              from __future__ import print_function
              
              import ctypes
              from ctypes.wintypes import BOOL, HWND, LPARAM
              
              WNDENUMPROC = ctypes.WINFUNCTYPE(BOOL, HWND, LPARAM)
              
              FindWindow = ctypes.windll.user32.FindWindowW
              SendMessage = ctypes.windll.user32.SendMessageW
              EnumChildWindows = ctypes.windll.user32.EnumChildWindows
              GetClassName = ctypes.windll.user32.GetClassNameW
              GetWindowText = ctypes.windll.user32.GetWindowTextW
              GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW
              create_unicode_buffer = ctypes.create_unicode_buffer
              
              curr_class = create_unicode_buffer(256)
              
              BM_SETCHECK = 0x00F1
              BST_CHECKED = 1
              
              incr_search_highlight_all_hwnd = [ 0 ]
              
              def EnumCallback(hwnd, _):
                  GetClassName(hwnd, curr_class, 256)
                  length = GetWindowTextLength(hwnd)
                  if length:
                      buff = create_unicode_buffer(length + 1)
                      GetWindowText(hwnd, buff, length + 1)
                      print('class:', curr_class.value, '|', 'text:', buff.value)
                      if buff.value == u'&Highlight all':
                          incr_search_highlight_all_hwnd[0] = hwnd
                  else:
                      print('class:', curr_class.value)
                  return True  # let enumeration continue
              
              notepad.menuCommand(MENUCOMMAND.SEARCH_FINDINCREMENT)
              notepad_hwnd = ctypes.windll.user32.FindWindowW(u'Notepad++', None)
              if notepad_hwnd:
                  EnumChildWindows(notepad_hwnd, WNDENUMPROC(EnumCallback), 0)
                  if incr_search_highlight_all_hwnd[0]:
                      SendMessage(incr_search_highlight_all_hwnd[0], BM_SETCHECK, BST_CHECKED, 0)
              

              It’s instructive to look at the PythonScript console as it runs – although for me it seems to write to the console very slowly and I don’t know why this is…

              Alan KilbornA 1 Reply Last reply Reply Quote 2
              • Alan KilbornA Online
                Alan Kilborn @Alan Kilborn
                last edited by

                @alan-kilborn said in Bookmark line becomes unchecked on reopening application:

                if buff.value == u’&Highlight all’:

                Also not sure why this text seems to have a Alt+h keyboard accelerator as I don’t see how you can use it in Notepad++'s UI.

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

                  @Alan-Kilborn said in Bookmark line becomes unchecked on reopening application:

                  not sure why this text seems to have a Alt+h keyboard accelerator as I don’t see how you can use it in Notepad++'s UI.

                  One more thing I’m not sure of: Why I had said that.
                  If a control in the Incremental Search window has input focus, e.g. the Find edit box, then Alt+h will focus and toggle the Highlight all checkbox setting.

                  1 Reply Last reply Reply Quote 1
                  • M markran referenced this topic on

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • First post
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors