notepad-plus-plus / notepad-plus-plus

Notepad++ official repository
https://notepad-plus-plus.org/
Other
22.9k stars 4.6k forks source link

add option to enable/disable showing app version in title bar #9648

Open shocked-gamer opened 3 years ago

shocked-gamer commented 3 years ago

[feature request/enhancement]

is it possible to add an option in the "MISC" section of the Preferences for the program to display the version number in the window title bar?

Eg. Notepad++ 7.9.3

sasumner commented 3 years ago

What's the value in it?

ArkadiuszMichalski commented 3 years ago

This could be solved with a separate argument, if available, and it could also be used to solve other problems https://github.com/notepad-plus-plus/notepad-plus-plus/issues/9539.

sasumner commented 3 years ago

This could be solved with a separate argument, if available, and it could also be used to solve other problems #9539.

Shameless plug for your issue. :-)

I'd like to know what value it is to @shocked-gamer . Well, anybody else reading that cares to comment as well.

ArkadiuszMichalski commented 3 years ago

Shameless plug for your issue. :-)

Both are for additional information in the title so it was worth making the link.

sasumner commented 3 years ago

image

Does it need a preference setting? Can it just always be present?

ArkadiuszMichalski commented 3 years ago

I checked some programs on my system and only one displayed the version number in the title. It seems that this is not a common pattern (at least by default).

sasumner commented 3 years ago

My number 2 favorite program (behind Notepad++) has a default of:

image

sasumner commented 3 years ago

Also:

image

sasumner commented 3 years ago

And:

image

sasumner commented 3 years ago

I checked some programs on my system and only one displayed the version number in the title. It seems that this is not a common pattern (at least by default).

Does this mean we should not do it for Notepad++ ? Or still do it, but make it an option?

ArkadiuszMichalski commented 3 years ago

So this is no exotic approach. Personally, it will not bother me at all when it will be always visible, so the option seems unnecessary (Notepad++ has a short version label ). But that's just for me. In addition I will be able to quickly determine on which version I am currently sitting on. Basically useful when we have many NPP versions open at the same time.

Wait a second, one problem might arise because of this number - it will change with each version. I've seen some commands that select a window relative to the beginning of a title, the end of a title, or the entire title (no substring). As the end of title will changes, it can break some automations. But if this PR https://github.com/notepad-plus-plus/notepad-plus-plus/pull/9704 will approve, it will be possible to add something permanent at the end. Eventually we can still read the version number from the file, so it can be bypassed anyway. It will come out in practice.

There is still room, but it is getting tight. "Set save dialog ..." will not be moved to the save dialog?

image

Edit: In general some api for title change would be useful, so we could used it through plugins (like PythonScript). Anyone could add what they want at the beginning, end, or middle of title (or change it completely). But maybe it's a discussion for other times.

sasumner commented 3 years ago

I've seen some commands that select a title window relative to the beginning of a title, the end of a title, or the entire title

Well, for these cases, if true, don't we already have a problem?

The beginning text on the title bar is never constant/predictable in a general sense. It could be a complete path or just a filename, and it could even start with a * to indicate a changed file.

The ending text currently on the title bar is not constant either. It could be Notepad++ but it could be [Administrator] (as shown above in my screenshot).

The windows API function FindWindow seems to operate when given an argument of Notepad++. It feels like if the N++ version number were added, it would continue to?

sasumner commented 3 years ago

"Set save dialog ..." will not be moved to the save dialog?

It is in-progress, by @mere-human

mere-human commented 3 years ago

There is still room, but it is getting tight. "Set save dialog ..." will not be moved to the save dialog?

Yes, I'm working on it in #9515. But it's not that easy to do it right.

ArkadiuszMichalski commented 3 years ago

@sasumner

The windows API function FindWindow seems to operate when given an argument of Notepad++. It feels like if the N++ version number were added, it would continue to?

I don't know, but AppActivate from Vbs check only beginning or end of title (or whole title). https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/windows-scripting/wzcddbek(v=vs.84)?redirectedfrom=MSDN

It is always safer in such cases when there is something permanent on the left or right side. Or some options to achieve this. On the left we can do nothing, on the right we can add something (thanks to yours last PR). I do not know if it is worth adding a configuration option to such a small thing, and whether in general @donho approve displaying this number in the title.

sasumner commented 3 years ago

@ArkadiuszMichalski

Some Python code:

import win32gui as gui
npp_hwnd = gui.FindWindow('Notepad++', None)

This code has no problem finding a Notepad++ window with this titlebar:

*new1 - Notepad++ [Administrator] - DEBUG!

I presume that gui.FindWindow uses the FindWindow or FindWindowEx Win32 api.

Just as a counterpoint to your VBS/AppActivate example.

ArkadiuszMichalski commented 3 years ago

@sasumner

Well, that's the way it should be, most commands (or console programs) of this type works like that (also find any substring). I just recently had to used AppActivate and it surprised me a bit, That's why I started paying attention to what the programs have in the title. But, as we can see, there is an alternative, so it's not a big problem.