zufuliu / notepad4

Notepad4 (Notepad2⨯2, Notepad2++) is a light-weight Scintilla based text editor for Windows with syntax highlighting, code folding, auto-completion and API list for many programming languages and documents, bundled with file browser plugin matepath.
Other
2.41k stars 174 forks source link

Chocolatey pacakge #379

Open zufuliu opened 2 years ago

zufuliu commented 2 years ago

改名之后建一个 Chocolatey 包吧,Notepad3 已经在上面了 https://community.chocolatey.org/packages?q=notepad2

Originally posted by @Mapaler in https://github.com/zufuliu/notepad2/discussions/346#discussioncomment-1361450

Mapaler commented 2 years ago

https://docs.chocolatey.org/en-us/create/ 文档都是英文的,看不懂

teknowledgist commented 1 year ago

I am the maintainer of the Notepad3 Chocolatey package (and many other packages), and I would be happy to establish/maintain a package for this Notepad2 fork.

As a long time package creator who is fairly familiar with the culture of the public repository, I don't think this fork should supplant the Notepad2 (original) or Notepad2-mod packages. I would much prefer to start a new package using the new name, whatever that will be.

I will want to make the package a machine-wide install because in my experience (personally and in my real job), using Chocolatey for user installs ends up with a giant mess. (IMHO, at a minimum, even single-user machines should have an unprivileged, "daily driver" user which means, when the admin account runs a Chocolatey install, it is not available to the unprivileged user.) That means, either the INI file location needs to be in %USERPROFILE% by default, or I have to create the Chocolatey package to manage it (a bit of a PITA).

Let me know your thoughts.

zufuliu commented 1 year ago

I updated https://github.com/zufuliu/notepad2/discussions/405#discussioncomment-1785559 to reflect actual INI folder search order in code (in CheckIniFile() function). Personally I think install the three bundled INI files (copied from https://github.com/zufuliu/notepad2/tree/main/doc and https://github.com/zufuliu/notepad2/tree/main/metapath/doc folders) into one of three folder in %USERPROFILE% would be easy.

teknowledgist commented 1 year ago

My thinking is that it will be easier to uncomment the first two lines of Notepad2.ini in the program directory. That way, upgrades don't need to worry about checking for and/or overwriting individual user preferences.

What happens if the Notepad2.ini directs Notepad2 to use/save preferences in the user profile but there are no settings files in the user profile? Does Notepad2 create the files as needed in the proper location?

Also, I need to know the new "official" name. It's your project, and you've gotten comments on suggested names. In the end, you just have to pick something because nothing will please everyone, and it's more important to have a name than to wait forever for the perfect name. 😄

zufuliu commented 1 year ago

What happens if the Notepad2.ini directs Notepad2 to use/save preferences in the user profile but there are no settings files in the user profile? Does Notepad2 create the files as needed in the proper location?

It behaviors as no INI files, INI from program folder is not used. however changes will be written into redirected INI path instead of program folder. How about following approach: on first install, copy three ini files to one of three sub-folder in %USERPROFILE%. on upgrade leave them as is, INI file is no longer upgraded as it's hard to determine whether existing INI files in %USERPROFILE% folder has changed by user or not, this only impacts dark theme INI (which will add new styles), Notepad2.ini and metapath.ini contains mostly comments (new comments will be added into Settings2 section) should not be impacted. In my past experiences, on Ubuntu after changed configuration inside /etc folder, on upgrade apt will prompt choices (leave user's copy, overwrite with package maintainer's copy, show diff) ; not sure whether Chocolatey has similar approach.

teknowledgist commented 1 year ago

The problem with the copy-into-%userprofile% approach is which profile(s)?

Say, AdminGuy installs this yet unnamed (hint, hint) Notepad variant and the Chocolatey script copies the INIs into AdminGuy's profile. When NormalDude logs back in, he won't have the INIs and neither will any new login users. Alternatively, the Chocolatey script copies the INIs into the default profile. When RegularGal logs in for the first time, she will have the settings, but neither AdminGuy nor NormalDude will have an INI since they already have profiles.

The benefit of redirecting the INI path from the source and to a "blank slate" is that everyone (existing profile or not) gets the same, default settings, and any preferences they set will be saved in their profile without risk of being removed/changed by an upgrade (or even uninstall/reinstall).

So, the question in my mind is: Are the default settings with no %userprofile% INI (assuming redirection) the same as the default INI? If not, that will make things confusing at best.

zufuliu commented 1 year ago

If I'm understood, this appears will need some changes in source code: when INI redirection is enabled (with Notepad2.ini=xxxxx like lines uncommented), if target INI file does not exist or is empty, then copy source INI file (e.g. from exe folder) to override target ini file.

teknowledgist commented 1 year ago

Whether the code needs changed or not depends on the answer to the question:

If the INI in the exe folder location has an uncommented line, Notepad2.ini=<filepath>, but there is no INI file in that location, will the program function properly and with the same default settings as defined in the INI (that is not being used)? Also, if a user makes a change to the default settings, will the program create a new INI in the <filepath> location?

If the answer is "yes" to both of those, then the code does not need changed.

If the answer is "no" to either, then I do think a code change would be necessary if you want this Notepad2 flavor to work "properly" for all users of a machine. The change you suggested would be one option.

IMHO, a better choice would be for all the settings contained in the default INI to be in-place without an INI. Only if a user makes a settings change in the GUI would the software create an INI. Maybe it could also test if the program/exe directory is writable by the current user ticket. If it is writable, then create the INI in that directory unless there is a setting to use a different path. If it is not writable, create the INI in the %userprofile% by default.

zufuliu commented 1 year ago

Both are yes, Notepad2 and metapath works perfectly without any INI files (which is the case when <filepath> doesn't exist). however Notepad2's dark mode (check the menu Scheme -> Style Theme -> Dark) works poorly for most schemes without a Notepad2 DarkTheme.ini file (normally in the same folder as <filepath> unless also redirected).

teknowledgist commented 1 year ago

Maybe the default Notepad2 DarkTheme.ini settings should be incorporated into the code so the file isn't necessary unless the user makes changes to them?

zufuliu commented 1 year ago

That seems complex, I see Notepad3 has more theme files, maybe "Notepad2 DarkTheme.ini" can be packaged/distributed using the same method?

teknowledgist commented 1 year ago

I guess? TBH, I didn't even realize Notepad3 had themes. That has never been of much interest to me in any app.

I think you could still use the test-for-modify-rights method. IOW: store all the default theme settings files in the application directory. If someone chooses a non-default theme, use it. If they want to adjust the theme, test if they have modify rights to the "themes" directory. If they do, go ahead and change that default file. If they don't have modify rights write either just the changes to an INI file within their userprofile or write the entire theme + any changes to their userprofile. That way, current users who just unzip to their desktop or documents folder could continue to work as they have and machines with it "installed" would work for multiple, unprivileged users.

teknowledgist commented 1 year ago

Any progress or further thinking on this? For my part, there are two "roadblocks":

  1. There is no "official" new name.
  2. The settings and themes are not machine-wide-friendly by default yet.

The latter can be (mostly) dealt with in the installation script, so to get a start on a Chocolatey package all I really need is the choice of name.

zufuliu commented 1 year ago

Sorry, but no progress. I think these INI files can be packaged same as Notepad3?

enihcam commented 1 month ago

any updates on this chocolatey package? @zufuliu

zufuliu commented 1 month ago

No progress. As I don't use these package managers, needs someone to work on, maybe similar to winget supporting.

Mapaler commented 1 month ago

winget 比 chocolately 好用,但是不支持Win7

enihcam commented 1 month ago

winget

winget is either lack of packages or out-of-date.

teknowledgist commented 1 month ago

Pull the trigger on (e.g. choose) a name (other than "Notepad2"), and I'll work on constructing a package.

zufuliu commented 1 month ago

Pull the trigger on (e.g. choose) a name (other than "Notepad2"), and I'll work on constructing a package.

How about Notepad2-zufuliu (as in readme) or zufuliu.notepad2 (winget)?

teknowledgist commented 1 month ago

I can use that, but it's rather long. The name poll has "Notepad2z" as the winner. Is there a reason you don't want to use that?

Whatever name you want, it would be best if this repo were renamed to match.

zufuliu commented 1 month ago

I don't want to change the binary names (Notepad2.exe and metapath.exe), which requires huge source changes (mostly renaming), and breaks end users with system integration enabled. How about -ng suffix for project name (Notepad2-ng and metapath-ng)? https://github.com/zlib-ng https://github.com/quickjs-ng

teknowledgist commented 1 month ago

I don't want to change the binary names (Notepad2.exe and metapath.exe), which requires huge source changes (mostly renaming), and breaks end users with system integration enabled. How about -ng suffix for project name (Notepad2-ng and metapath-ng)? https://github.com/zlib-ng https://github.com/quickjs-ng

That doesn't really answer my question (and you have no obligation to do so). Note that the naming discussion and poll were/are not about the binary name, but the project name. Lots of program binaries don't match the product/project name.

It's your baby, so if you prefer to name it "Notepad2-ng" rather than whatever the un-invested and fickle public think, that is your choice.