User defined Macros in menu (shortcuts.xml)
-
I see enabling virtual space can be added to the shortcuts.xml file but on N++ 7.7 it doesn’t seem to work - which I gather is one of the 7.7.1 enhancements.
However, I’ve tried other macros on N++ 7.7 and they don’t seem to work either. Am I doing something wrong?
<Macro name="Multi Paste On" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="0" message="2614" wParam="1" lParam="0" sParam="" /> </Macro> <Macro name="Multi Paste Off" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="0" message="2614" wParam="0" lParam="0" sParam="" /> </Macro>
When I select the “Multi Paste On” from the Macro menu, multi paste behavior does not change. However if I run:
SCI_SENDMSG 2614 1
From NppExec, it works as intended.
Are there some Scintilla messages not supported in the shortcuts.xml Macros section? Also, it seems N++ commands can be used there with type=2, but I’ve tried NPPM_SHOWDOCSWITCHER (2109) and that doesn’t work either.
-
yes, the list of messages can be seen here. Why only those messages are marked macroabled I don’t know.
-
Hi @ekopalypse, @michael-vincent and All,
Thanks, @ekopalypse, to point out this information. I personally verified that this list of macroable Scintilla messages exists in two files :
-
…\PowerEditor\src\WinControls\shortcut\shortcut.cpp (
107
messages ) -
…\scintilla\src\Editor.cxx (
108
messages )
@michael-vincent, see, also, my two posts to Don Ho, below, related to the Scintilla message SCI_SETVIRTUALSPACEOPTIONS (
2596
) !https://notepad-plus-plus.org/community/topic/17822/notepad-7-7-1-release-candidate/2
https://notepad-plus-plus.org/community/topic/17822/notepad-7-7-1-release-candidate/9
BR
guy038
-
-
Thanks for the link, very informative. Assuming those are the only “macroable” messages as they may only require a simple wParam / lParam value as that’s all you can supply in the XML macro objects? Seems like the list could be expanded as the one I was quoting - SCI_SETMULTIPASTE (2614) - takes only an integer 0 or 1 for the wParam to turn it on or off.
I only found out about this feature by reading the Scintilla docs after implementing add to selection via an NppExec script as per your suggestion and adding them to the Macro menu via NppExec.ini. Now when I made a multiple selection with mapped shortcut keys and typed, it all worked great, but using paste (from a previous copied text), it only pasted on the first selected text, not all selections. And that’s because SCI_SETMULTIPASTE is off by default. A quick NppExec:
SCI_SENDMSG SCI_SETMULTIPASTE 1
turned it on and then retrying my multiple selection paste worked to paste to all selections! Brilliant!
So of course I wanted this as a turn on / turn off menu item and thought of the Macro XML in shortcuts because of @guy038 's suggestion. I couldn’t get @guy038 virtual space macro to work (assuming because that’s an enhancement of 7.7.1 and I’m only on 7.7 not using the release candidate), so again, a quick NppExec script:
SCI_SENDMSG SCI_SETVIRTUALSPACEOPTIONS 5 // for "default" behavior SCI_SENDMSG SCI_SETVIRTUALSPACEOPTIONS 7 // for all on SCI_SENDMSG SCI_SETVIRTUALSPACEOPTIONS 0 // for all off
and it worked fine for me. So I added the Macros to my shortcuts.xml in prep for the 7.7.1 release and then asked my question about other ‘macroable’ things that I’ve just been doing with quick NppExec scripts using SCI_SENDMSG.
Just BTW, NppExec (along with I’m assuming PythonScript and LuaScript which I don’t use but see great advice about) are awesome plugins that can immediately extend N++ new Scintilla features even if N++ doesn’t yet have menu items to access them direct. Based on the messages in this form, with NppExec, I’ve added an “add / clear annotation”, “add / clear multiedge”, “add to / add all / remove last from current selection”, the multipaste on/off I discussed in this post … the list goes on …
@donho thanks for the Scintilla upgrade!