simonsteele / pn

Programmer's Notepad
374 stars 115 forks source link

Requesting change how multiple instances behave #186

Closed maettu-this closed 3 years ago

maettu-this commented 5 years ago

Currently limited to [Options > General > Allow multiple instances].

What I'd like:

E.g., instead of [Options > General > Allow multiple instances], it would be [Options > General > Open files in same instance]. If no, double-clicking each time opens a new instance. If yes, double-clicking opens in either least or most recent instance. The logic whether using the least or most recent instance will have to be defined. I guess the least recent is most intuitive.

anon17 commented 3 years ago

You can run a new instance with pn.exe -allowmulti, it's in pn2.chm.

veganaize commented 3 years ago

Note that's actually a double dash preceding the argument (--allowmulti).

maettu-this commented 3 years ago

Having this arg may be fine for console operation, but not double-clicking.

veganaize commented 3 years ago
  1. Open %windir%\regedit.exe
  2. Navigate to HKEY_CLASSES_ROOT -> * -> shell
  3. Right-click shell -> New -> Key -> "pnAllowMulti" (without quotes)
  4. Inside pnAllowMulti -> double-click (Default) -> "Edit with Programmer's Notepad (New Instance)" (without quotes)
  5. Right-click pnAllowMulti -> New -> Key -> "command" (without quotes)
  6. Inside pnAllowMulti -> command -> double-click (Default) -> "C:\Program Files (x86)\Programmer's Notepad\pn.exe --allowmulti "%1"" (without outermost quotes)

Doing so will allow you to right-click a file and select "Edit with Programmer's Notepad [...]", either in a new or existing instance. For this to work as expected you must also ensure that "Allow multiple instances of Programmer's Notepad to start" is UNCHECKED in Tools -> Options -> General.

[You should always backup the registry before editing it.]

image

anon17 commented 3 years ago

As I understand, just a shortcut that runs pn.exe --allowmulti is what the OP wants.

anon17 commented 3 years ago

Just open shortcut properties and add --allowmulti to target command, then the shortcut will run the program with that argument when clicked.

maettu-this commented 3 years ago

As I understand, just a shortcut that runs pn.exe --allowmulti is what the OP wants.

No, "double-clicking" any text file is what I initially wanted. Having shortcuts with and without --allowmulti may be useful as well, but the "right-click a file and select "Edit with Programmer's Notepad [...]"" approach elaborated further above is quite close to what I have been looking for. I guess such standard Windows approach is more suitable than a pn specific approach nobody understands. @veganaize and @anon17 thanks for the input. I will close this issue.

maettu-this commented 3 years ago

PS: C:\Program Files (x86)\Programmer's Notepad\pn.exe --allowmulti "%1" should be "C:\Program Files (x86)\Programmer's Notepad\pn.exe" --allowmulti "%1" (quotes around pn path).

veganaize commented 3 years ago

@maettu-this: It worked for me without the quotes around the path.

anon17 commented 3 years ago

If you want to open every file in a new instance, you just set the checkbox "Allow multiple instances".