geoffmcl / NppTidy2

HTML-Tidy plugin for Notepad++. Uses tidy-html5 - https://github.com/htacg/tidy-html5
GNU General Public License v2.0
29 stars 8 forks source link

Find way to update versions in About dialog #4

Closed geoffmcl closed 6 years ago

geoffmcl commented 6 years ago

One way would be to use cmake configure_file to copy a file, or files, substituting version values generated in cmake, from say a version.txt file...

The problem is the Tidy2/VersionAndAbout.rc, and its associated resource.h are encoded in MS Unicode (UTF-16), and it seems cmake does not support this character encoding. And searching around it seems it never will, despite its extensive use by MS Windows...

Additionally, since these files are in UTF-16, with a BOM, github treats the files as binary, thus to update the version strings manually each time would cause full file re-writes in the repository... also a no-no!

But that does not stop the Tidy2.dll generating and setting these dialog text strings, during the creation of the dialog...

Have created a set_vers branch to explore this for Tidy2.dll, and forked notepad-plus-plus, my hnppf.bat, and built with MSVC 14.x64, in a next1 branch, to be able to use MSVC to Debug the Plugins load and setup... and installed npp 64-bit release 7.5.3, my hnpp-7.5.3.bat, to test the new Tidy2.dll... quite a learning curve...

Seems to be working. Still to push these changes...

geoffmcl commented 6 years ago

All changes now pushed to branch set-vers...

Now each control in the About dialog has an ID, so the handle for each can be obtained, and the control text updated to show both the Tidy2.dll version/date, exposed through cmake from the version.txt file in the source, and the library tidy version in use by using its APIs, tidyReleaseDate(), and tidyLibraryVersion()...

The libtidy versions presented a small wrinkle, in that this data is returned as ASCII/UTF-8, while the About dialog is in MS Unicode, UTF-16, but this was handled by using the WIN32 API MultiByteToWideChar to convert the strings appropriately...

I have added this dialog text setting code into void AboutDialog::doDialog(), but now see maybe it could have been put in the CALLBACK AboutDialog::run_dlgProc, in the case WM_INITDIALOG:, where I think normally such setup code would reside... but that can wait until next time...

Have now tested this in my fork of notepad-plus-plus github repo, built with MSVC14.x64, an install of release 7.5.3 64-bits notepad++, and my 32-bit install of older v5.9, my day-to-day working notepad++ - note to self - TODO: must get around to updating this, but so far in my usage have found no problems, but...

So this version 2.0.2 of Tidy2.dll, presently only in the set-vers branch, looks to be a good release candidate... will work on that as time permits...