Highlight Current COLUMN
-
I created a plugin to highlight the current column the same way highlight current line is provided for in the settings. I did this by using the long lines edge indicator and tracking SCN_PAINT events to update the location. The very simple plugin just enables and disables the feature, resetting the edge indicator to the original position.
Code can be found on GitHub: https://github.com/vinsworldcom/nppColHighlight
I’d love some feedback / comments as this is my first attempt at a plugin after about 8 hours of reading the docs / demo plugin.
Cheers.
-
Don’t know if you saw it but I made a comment on your initial commit. It looks like in the
pluginInit()function you are using the Scintilla handles. However I believe they haven’t actually been created at this time. Technically withingetCurScintilla()it should fail since callingNPPM_GETCURRENTSCINTILLAmay still leavewhichas-1. You might try moving the code withinpluginInit()intobeNotified()and catch theNPPN_READYnotification which signals N++ is completely ready (thus access to Scintilla handles should be valid then). -
Thanks for the tip. I"ll check it out. I took the code directly from the demo plugin:
http://download.tuxfamily.org/nppplugins/NppPluginTemplate/NppPluginTemplate.zip
There was nothing in the pluginInit() sub in that example, and I didn’t know the proper handles may not be ready.
cheers.
-
The template is very outdated although still worth referencing. My understanding is that the
pluginInit()(which is just called directly fromDllMian) is mostly just for any setup the plugin needs to do – like a constructor. TheNPPN_READYnotification is the time to actually start working with N++/Scintilla. -
Brilliant - that’s the type of advice I was hoping for in posting here / there / and everywhere!
As it is, the plugin is very simple and the only setup required is to save the original long lines edge indicator status (position and mode). I do this in the enable routine enColHi(). So the pluginInit() stuff really was redundant.
Thanks very much.