Community
    • Login

    Two questions about Project Panel and Docked Windows

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    4 Posts 2 Posters 446 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.
    • Vitalii DovganV
      Vitalii Dovgan
      last edited by

      Hi all!

      Maybe I overlooked something, but I don’t seem to find answers to the following dev questions:

      1. The Project Panel / Folder as Workspace.
        How can a plugin retrieve the root path to the workspace files?
        For an example of what it might be needed for, please look at this feature request:
        https://github.com/d0vgan/nppexec/issues/15

      2. The Docked Panels (Windows) switching/activating.
        How can one programmatically activate/switch to a desired docked panel/window?
        For an example of what it might be needed for, please look at this feature request:
        https://github.com/d0vgan/nppexec/issues/17

      Thanks,
      DV.

      EkopalypseE 2 Replies Last reply Reply Quote 0
      • EkopalypseE
        Ekopalypse @Vitalii Dovgan
        last edited by

        @Vitalii-Dovgan

        there is no builtin npp message which can be used but for

        1. enumerate the child windows for File Browser and then find its SysTreeView32 and us TVM messages to get the needed information
          and for
        2. should be the same, enumerate to find your console window and get its associated systabcontrol …
        1 Reply Last reply Reply Quote 0
        • EkopalypseE
          Ekopalypse @Vitalii Dovgan
          last edited by Ekopalypse

          @Vitalii-Dovgan

          I had some time to do a little experiment and it looks like
          you can use something similar like the python scripts I’ve used.

          to get the path for each root node from File Browser:

          def enum_root_pathes(hwnd, lParam):
              if gui.IsWindowVisible(hwnd):
                  name = gui.GetWindowText(hwnd)
                  if name == 'File Browser':
                      h_systreeview32 = gui.FindWindowEx(hwnd, None , 'SysTreeView32', None)
                      if h_systreeview32:
                          root_nodes = []
                          
                          hNode = gui.SendMessage(h_systreeview32,
                                                  com.TVM_GETNEXTITEM,
                                                  com.TVGN_ROOT,
                                                  0)
                          while hNode:
                              root_nodes.append(hNode)
                              nextNode = gui.SendMessage(h_systreeview32,
                                                         com.TVM_GETNEXTITEM,
                                                         com.TVGN_NEXT,
                                                         hNode)
                              hNode = nextNode
          
                          for node in root_nodes:
                              tvitem, extras = gui_struct.EmptyTVITEM(node)
                              res = gui.SendMessage(h_systreeview32,
                                                    com.TVM_GETITEMW,
                                                    0,
                                                    tvitem)
                              if res:
                                  _, _, _, _, _, _, _, param = gui_struct.UnpackTVITEM(tvitem)                
                                  x = ctypes.c_wchar_p.from_address(param)
                                  print(ctypes.wstring_at(x))
                          return
              return True
          gui.EnumChildWindows(notepad.hwnd, enum_root_pathes, None)
          

          To switch to a know/active tab in a docked dialog

          NPPM_DMMVIEWOTHERTAB = 1024+1000+35
          gui.SendMessage(notepad.hwnd,
                          NPPM_DMMVIEWOTHERTAB,
                          0, 
                          'Python',)
          

          to enumerate the current open tabs of docked dialogs,
          I had only partial success. It looks like either the docking manager
          corrupts the tab structure, there is a bug in SysTabControl or, likely,
          I haven’t understood how to use it correctly.

          def enum_tabs(hwnd, lParam):
              if gui.IsWindowVisible(hwnd):
                  window_name = gui.GetWindowText(hwnd)
                  # class_name = gui.GetClassName(hwnd)
                  # if class_name != 'Scintilla':
                      # print(window_name, class_name)
                  if window_name == 'Tab1':
                      open_tabs = gui.SendMessage(hwnd, com.TCM_GETITEMCOUNT, 0,0)
                      for i in range(open_tabs):
                          # tcitem, extras = create_TCITEM_structure()
                          tcitem, extras = create_TCITEMHEADER_structure()
                          # res = gui.SendMessage(hwnd, com.TCM_SETCURSEL, i, 0) 
                          # print('res', res)
                          res = gui.SendMessage(hwnd, com.TCM_GETITEMW, i, tcitem)
                          if res:
                              _, _, _, pszText, _, _, = struct.unpack('IiiPii', tcitem)
                              print(i, gui.PyGetString(pszText))
                      return
              return True
          
          gui.EnumChildWindows(notepad.hwnd, enum_tabs, None)
          

          This correctly identifies the number of tabs used but it only reports
          the tab caption for the last dialog attached to the tab control.
          Maybe helpful anyway.

          1 Reply Last reply Reply Quote 1
          • Vitalii DovganV
            Vitalii Dovgan
            last edited by

            Thank you, I’ll try it!

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