My first plugin development: CollectionInterface [was: Need help with getting started using C++ Plugin Template]
-
@Coises ,
Thanks, I was thinking that, too.
The copy currently in GitHub now allows the additional download of the associated AC or FL for a given UDL. (But it still only allows selecting one UDL at a time.)
Whether in the AlsoXX mode or the normal XX category, it also now warns you if it’s going to be asking for elevated UAC permissions (usually when downloading AutoCompletion, since those go in Program Files), and if you CANCEL, it will not bother with the UAC prompt and thus won’t download the file. I thought that people might be confused why Windows was giving the UAC elevation prompt, so decided that a MessageBox in between would be helpful.
-
@PeterJones ,
Left for me too, although, when I first looked at it, I thought you were doing a selection on the left and the right would expand showing the files that the UDL could download…and then those would have checkboxes…but then I saw the red line and realized while reading it was an either or choice. :-)As for the UAC mention a little further down, are you able to do that via NPP and the installation? I know NPP does it, so that’s why I ask…in my installer, I had to let people know they might have to install the package while in Admin mode, for the autoCompletion file for a standard install.
-
@Lycan-Thrope said in Need help with getting started using C++ Plugin Template:
and realized while reading it was an either or choice
Sorry, at one point, I thought I put in a “VS” next to the red line, but I did an UNDO on that at some point while manipulating the image. I probably should have just pasted two separate images, rather than joining them to one.
As for the UAC mention a little further down, are you able to do that via NPP and the installation? I know NPP does it, so that’s why I ask…in my installer, I had to let people know they might have to install the package while in Admin mode, for the autoCompletion file for a standard install.
Since neither Notepad++ nor my plugin have Elevated permission yet, and I didn’t want to tell the user that they had to restart Notepad++, I cheat: instead of downloading the file directly to the protected directory, I download it to a temporary directory (and hence the GetTempPath2W-vs-GetTempPathW from earlier), then I run a ShellExecute
runas
to copy from the temp-dir – and therunas
prompts for the UAC for just the process that’s copying the file. -
@PeterJones ,
Clever. :-)Now, you might be interested to know, that your package download works just fine, as far as getting the files in the right directories. However, this brings up the file naming (internally and externally) problems that I was mentioning earlier.
Since the dBASEPlus UDL is currently the only UDL package with all 3 files, (sans additional separate themes other than Dark and Light variants), I had to rename things, and I think I got it sorted out and wasn’t sure if this is something you are going to work on, or was going to leave for later. I know the filenames in the JSON in the repository are probably what will need to be changed, but have some info about what the final product for all 3 packages needs to look like.
1.) The UDL userDefineLangs name needs to be the same internally and externally and in the same case for the functionList definition to work properly and that name needs to be in the overrideMap.xml in the same case. (any change in case in any of the 3 places, makes the functionList not function)
2.) The name of the autoCompletion files can be any case, as long as the name is the same as the actual UDL’s file name. (which should have internal/external the same, and case wise)
eg. dbaseplus_light.xml to be used for autocompletion of the dBASEPlus_Light.xml UDL.3.) The actual functionList file can be the same file for both Dark and Light versions, just the overrideMap.xml file has to point the association to each like so:
<association id= "dbaseplus.xml" userDefinedLangName="dBASEPlus_Light"/> <association id= "dbaseplus.xml" userDefinedLangName="dBASEPlus_Dark"/>
Any future dBASE variants would be named differently to accomodate that version’s functionList needs, for both Light and Dark. Such as dbaseIIIPlus.xml, dbase4,xml, etc.)
My original naming was helped by your putting the name first and the color type after, but the extremely long name, or only changing the internal name differently than the external name, causes linkage problems between the 3 different aspects. I think you already know that, but thought it was probably something that I should bring up that is the only hiccup right now.
I hope this helps rather than complicates your current development focus. :-)
-
have some info about what the final product for all 3 packages needs to look like.
I don’t quite agree with your interpretation:
-
UDL Naming Mismatch OK: I created a UDL file called
GeoRge.xml
with<UserLang name="Gracie"
It is recognized as a UDL, and the mismatch between the filename and the internal name doesn’t interfere with UDL or FunctionList or AutoCompletion, as long as FunctionList and AutoCompletion reference the internal
Gracie
, not theGeoRge.xml
filename. -
FunctionList Filename/displayName mismatch OK:
Example: With FunctionList filename
GracieFL.xml
and the setting inside GracieFL.xml being<parser displayName="ThisIsIgnored"
, and the overrideMap.xml having the line:<association id= "graciefl.xml" userDefinedLangName="Gracie"/>
it all maps correctly.
- The association ID name must match the FL filename, but case is not important, because the Windows filesystem is not case sensitive.
- The association
userDefinedLangName
must match the<UserLang name="..."
, but doesn’t care about the UDL definition’s filename- I can, however, confirm that if
userDefinedLangName="gracie"
case does not match<UserLang name="Gracie"
case, it will not map properly, because XML attribute values are case-sensitive, and Notepad++ does the internal searching based on case.
- I can, however, confirm that if
- Notepad++ ignores the FL parser’s
displayName
andid
values for any of these mappings.
In my example, the regex is
<function mainExpr="(?x-is)^\d+\..*(?=:)"/>
so that the dummy text as I am writing up this post will have functions, so I can share screenshot showing that with these settings, it does correctly show FunctionList- AutoCompletion needs to match UDL name, not filename:
If I name the AutoCompletion file
gracie.xml
– so it matches the<UserLang name="Gracie"
(case insensitive), but does not matchGeoRge.xml
, the autoCompletions work properly.
However, other than the fact that I can enforce AutoCompletion filename name must match the UDL’s internal name (with the
.xml
extension added), none of this has to do with my plugin. -
-
@Lycan-Thrope said in Need help with getting started using C++ Plugin Template:
Since the dBASEPlus UDL is currently the only UDL package with all 3 files
LSL_byKimpaTammas
(“LSL”) has UDL and FunctionList and AutoCompletionBut they have the same problem, where the autoCompletion filename matches the UDL filename
LSL_byKimpaTammas.xml
instead of the UDL’s internal name, which is justLSL
.I have not yet had an opportunity to improve the consistency-checks (validators) in the UDL repo yet, though the issue #303 exists.
-
@PeterJones ,
I stand corrected. I didn’t scroll the longer list, so missed it. Doh! -
@PeterJones ,
This is wierd, because I spent the earlier part of the day, testing just for these different scenarios, changing something, saving, closing NPP, and then reopening. I would open a recent file and if the FL didn’t populate I worked the different aspects and that’s what made me document the changes of names and how they needed to be.Hmm…can’t explain that…and this is the repaired NPP exe that changes to the correct UDL/FL combination that was fixed from my bug report.
Hmm…I think I need to go retest this and find out what went changed, because I thought I was being pretty meticulous with these checks. Remember, I have Dark and Light versions, and that’s how I was knowing when one was working and the other wasn’t.
-
@PeterJones ,
Well, I don’t know how it happened, but either through a fluke or what not, all that testing I did was just undone.It took a while to get it right with your naming the file one thing and the internal name another, but I ended up getting it to work like you show. I just can’t explain how it didn’t work that way the first time I went through it…but oh well. :-(
-
I have a version good enough that I’m going to call it “beta”:
https://github.com/pryrt/NppPlugin-CollectionInterface/releases/tag/v1.0.0betaIt doesn’t have multiple-UDL-download feature (that can wait until a future version), but it’s got the download one file, or download UDL+FL/AC. It should properly ask for UAC permission on AutoCompletion. It will ask if you want to restart Notepad++ through a new MessageBox after the Done button is pressed on the main dialog. There is a ? button on the dialog, and that help is also available through the plugin’s menu.
Mostly what I’m looking for at this point is feedback on whether it does what I claim it does, and whether it works as expected for other people, not just for me. For now, ignore any problems with the metadata mismatch that @Lycan-Thrope has been focused on; I will eventually improve the UDL Collection checkers to flag those, and work on fixes. Other than that, let me know if you think there are any show-stoppers that would prevent it from being released.
(I’m calling this beta, not RC, because I know there are at least one-or-two behind-the-scenes things that I want to improve, though hopefully the end user wouldn’t be able to guess what those might be, because it shouldn’t affect the user.)
-
@PeterJones ,
It worked flawlessly, and I even downloaded a theme to test that. (I hadn’t before, sorry).I also just submitted a pull request to fix wording in the Help Dialog, mostly to see if I did my local branch fix properly, recompiled…and then submitted a pull request with the fix. Baby steps, and hopefully nothing blew up with my fledgling GitHub skills.
Update: I’ve mainly been testing the package download, but I can go back and test the individual downloads as well, now.
-
@PeterJones ,
Houston, we have a problem. :-)I was trying to check other files with the FL and AC, and tried doing just the UDL and then the same UDL w/AC&FL…they worked with what appears to be one exception. Vim by @rdipardo .
At first I thought it was a limitation in size of the UDL list, but apparently even after deleting some languages, it still wouldn’t appear. So I checked the UDL file which did download into the right directory, and it appears that it’s not a standard UDL file. All the files downloaded into the correct directories, but it’s not showing in the list, and I have to attribute that to the fact that it looks like it’s an HTML file, rather than an XML file.
Just an FYI.
-
it looks like it’s an HTML file, rather than an XML file.
apparently, when @rdipardo submitted to the collection, the JSON was set to point to the HTML wrapper for the gist. So it’s a data problem (which the validator should have caught) in the repo, not a problem with the plugin.
-
@PeterJones ,
Yeah I kind of figured that, but was just relaying the find, even though it isn’t the plugin’s fault.I know you have the list check the repository, rather than checking the user’s to see if they already have it, and then it dawned on me, that they might need to redownload an uncorrupted version if they screwed something up…although I’d have deleted it first before downloading again, I wonder if it’s worth it to add that check to see if they really want to redownload it. No harm no foul if it actually downloads overwriting a bad one, but if they made changes, they wanted to keep, then it might be a problem…but it’s their problem for not backing it up. :-)
-
@Lycan-Thrope said in Need help with getting started using C++ Plugin Template:
they worked with what appears to be one exception. Vim by @rdipardo .
If I understand correctly, wouldn’t the same thing happen with any UDL whose
repository
field is not a static XML resource?If that’s the case, a few more entries appear to need fixing:
$ curl -sSL https://raw.githubusercontent.com/notepad-plus-plus/userDefinedLanguages/refs/heads/master/udl-list.json |\ jq -MCr ' .UDLs[] | select(.repository | length > 0 and (test("((^https?://raw)|\\.xml$)") | not)) | ."id-name"' AgenaUDL AMXX_1.8.3_OciXCrom AsteriskExtensionLanguage-AEL_by-eyzel AuditCommandLanguage-ACL_byJChen Fortinet_FortiOS_FGT_by_SSavaso_6_4_14 GPD.byRajendraSingh jai.udl jQuery_byJamesAllardice Klipper-GCODE-Dark-by-Iron3eagle Liquid_dark_byFabbroDan markdown-plus-plus MSC-Nastran_by-onurarifyasa MSC-Patran_by-onurarifyasa Objective-C++_byLattHsiang PowerBuilder_DM_byFa0lin Smali_byJasi2169 TinyFugue_byYrwin Vimscript_Obsidian_by_rdipardo zenscript
-
@rdipardo ,
I don’t disagree, but I just chose yours because yours has, like mine, a package of UDL, AC and FL, and it was one I tried to see in the UDL list that made me notice it, which is why it caught my attention, and @PeterJones has pointed out it’s not the focus of this testing.@PeterJones has also pointed out that he’s going to run check on the entire repository any way and address these issues, if his plugin is going to address automating installation of UDL’s into NPP, plus address the changes that have come about from the switching from the old way the files were referenced to the way they are now referenced for download by users. Nothing was meant @rdipardo by picking yours out, it was just a fluke that I found it and pointed it out, and the issue has been explained to me why, what I found happened.
-
@Lycan-Thrope said,
he’s going to run check on the entire repository any way and address these issues
I have improved the validators, and was able to prove it would catch all the ones @rdipardo mentioned. I also confirmed it now catches the autoCompletion-filename-doesnt-match-UDL-internal-name. After verifying those worked, I updated the JSON to fix the non-XML
repository:
URLs, and updated the autoCompletion filenames to make them work correctly.- Use the correct autoCompletion filename
- Ask for permission before overwriting existing XML files
- Fixed some behind-the-scenes stuff compared to v1.0.0-beta
I’m hoping to get the PluginList testing done soon, and to have submitted the v1.0.0 final version to the nppPluginList before Don closes submissions for NPP v8.8.
-
@PeterJones ,
This is definitely ready so far. I tested very late, as best I could, with both portable and standard and it works as needed. It downloaded VIM on the portable, so i took it over to the standard install and ran it again. It flagged the already existing files, and I told it to go ahead, and it paused at UAC, said that it was already installed, told it to go ahead and it did. On restart, VIM was visible in the UDL list.I can check more of the languages later, but I think it’s good to go for a RC version, and then add the needed improvements you’ve already documented from there.
I need to get some sleep now. :-)
-
@PeterJones ,
Okay…another long night. Anyway, I used the portable to download that entire list that @rdipardo provided, and they all download just fine.Now, did you know or make it so we can download multiple languages and reboot just once to get them all installed? I know we can’t select mutliple, and download them, but after downloading a language, just going back to the list and selecting another one, allows you to continue downloading languages until they’re all done. I was doing one at a time and reboot and figured, what the heck, try and break it…but it didn’t, it worked. I even tried to redownload VIM package again, and it let me cancel each file and just continue downloading languages until I had them all done at once. I think that’s sufficient for now, being able to download more than one language at a time without rebooting.
Anyway, if you want me to test it in the standard version, let me know. So far everything else has worked in both, but I can verify it if you want. Time for me to hit the sack again, and then I have to get back to taking my
Learn C++ in 4 Hours
video course, so I can be really dangerous. :-) -
@PeterJones ,
Okay, just finished testing it in my 8.7.7 Standard install, and it all worked the same as in the portable, even after I canceled the VIM reinstall.I did make note this time, however, that I downloaded an excessive amount of UDL’s and since I haven’t looked in the code, there appears to be a limit of 30 UDL’s that can be displayed, other than the default
User Defined Language
menu dropdown and theUser-Defined
at the bottom of theLanguage
menu dialog.Since you do check to see if a UDL is installed, might it make sense to notify the user that the limit of visible UDL’s that will be selectable in the Language list, has been reached, if there is a total number of 30 or more in the UDL directory? Even with the scrollable arrows, all that will show, is the 30 UDL’s and those two UDL texts mentioned above. I guess essentially 32 in that
Language
Dialog UDL section.Other than that finding, the 1.0 RC is ready for release and for others to nitpick additional features. <grin>