Community
    • Login

    Access NPP command-line from plugin

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    4 Posts 2 Posters 396 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.
    • moon6969M
      moon6969
      last edited by

      I want my plugin to handle a custom command line parameter.

      I can use the undocumented -z parameter that @Ekopalypse kindly nudged me toward.

      For -multiInst I can get the NPP command line from Win32 API (GetCommandLineW), but for mono-instances that will only work for the initial launch.

      It seems that mono-instance works on subsequent launches by sending the command line parameters to the first NPP instance via WM_COPYDATA message.

      Unfortunately WM_COPYDATA doesn’t appear to be forwarded to plugins “messageProc” by _pluginsManager.relayNppMessages().

      Worse - currently NPP strips out the -z (+ next) parameter and doesn’t add them to the WM_COPYDATA message, so it’s not even worth hooking it directly.

      I think the best solution might be to implement a new NPPN Notfication something like NPPN_PARAMETERS_CHANGED?

      Is this worth my while investigating and maybe raising a pull request?

      Or is there a better way!?

      Cheers.

      EkopalypseE 1 Reply Last reply Reply Quote 1
      • EkopalypseE
        Ekopalypse @moon6969
        last edited by

        @moon6969

        sorry, but I don’t understand how you can start multiple mono-instances?
        What did I miss?

        1 Reply Last reply Reply Quote 0
        • moon6969M
          moon6969
          last edited by

          Apologies - I was trying to describe how NPP implements mono-instance mode…
          Example…

          • Enable ‘mono-instance’ mode & close all NPP instances
          • Launch NPP notepad++.exe xyz.txt
            • Process ID = 123
            • GetCommandLineW correctly shows notepad++.exe xyz.txt
          • Launch 2nd NPP instance notepad++.exe -z -test abc.txt
            • Process ID = 234
            • NPP 234 detects Mutex from NPP 123
            • sends WM_COPYDATA to NPP 123 containing ‘abc.txt’
            • kills self (234)
          • NPP 123 receives WM_COPYDATA
            • Opens ‘abc.txt’ alongside ‘xyz.txt’
            • GetCommandLineW still just shows notepad++.exe xyz.txt

          How can I get the “-z -test” parameters from the plugin running in the mono-instanced NPP 123?

          EkopalypseE 1 Reply Last reply Reply Quote 3
          • EkopalypseE
            Ekopalypse @moon6969
            last edited by

            @moon6969

            yes I see, I guess some kind of notification, as you wrote, is needed here.
            The wording NPPN_PARAMETERS_CHANGED might be a bit misleading
            as the mono-instance is still reporting its parameters correctly.
            Maybe NPPN_DIFFERENT_INSTANCE_MERGED?
            Native speakers - what do you suggest? :-)

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