Announcing Perl-based automation of Notepad++
-
I had never really gotten into REPL – never found one that I liked enough to frequently use – but I think App::PerlShell might be the one that starts me down that road, especially with this solution for NppConsole to embed the REPL in Notepad++. (If I ever get around to the v2.0 features – specifically, writing a wrapper Notepad++ plugin and thus enabling the notifications – I will probably try to use a combination of NppConsole as the starting code and @Ekopalypse’s experiments with embedding perl in a plugin, and include App::PerlShell as the default REPL for the plugin. That said, I have to get from early versions into a sold v1.0 before I work on v2.0 feastures. :-) )
Speaking of working toward v1.0: I am working on documenting the hashes that are used for holding the message name/value pairs, and the argument name/value pairs (equivalent to PythonScript’s enum documentation). But I’m wondering if I should change from having just a couple hashes with messages and message-arguments intertwined (%nppm, %nppidm, and %scimsg) into having a different named hash for the messages compared to the arguments (pythonscript uses a separate enum/class for each type of argument). Or maybe go the other direction, and have a big hash-of-hashes like %enum = ( NPPMSG => { … } , SCINTILLAMSG => { … } , MENUCMD => { FILE_CLOSE => …, …}, … ), so if you were going for the FILE_CLOSE, it would be $enum{MENUCMD}{FILE_CLOSE}.
I had originally kept them as just those three hashes, because that was easy from my convert-.h-to-hash method. But since I’m moving over to manual .pm for the messages/arguments, to allow for easier POD documentation of those hashes, now seems like a good time to make changes to the structure, if it makes sense.
So, if it were up to you(*), would you prefer just the enums as they are, split into multiple separate hash variables, or combined into one mega hash-of-hashs? Or should I just do all three (I could easily build the existing-three out of individual variables, and the mega hash-of-hashes could actually just embed the individual variables.
*: “up to you”, where “you” is defined as @Michael-Vincent , or anyone else who is likely to use Win32::Mechanize::NotepadPlusPlus as more than a one-or-two-time curiosity. :-)
-
@PeterJones said in Announcing Perl-based automation of Notepad++:
So, if it were up to you(*)
Let me give it think. My first instinct is to keep them separate instead of a single big hash-of-hash. To me that just makes more sense grouping N++, messages and Scintilla with their like instead of mixing.
More on App::PerlShell - if you read the POD, there are other REPL’s for Perl that excel at certain aspects of REPL - one duplicates Python look and feel, another uses PPI for correct Perl parsing at the expense of many dependencies, etc. I wanted one that behaved more like a shell (e.g., bash, Powershell) but took Perl commands and none did that. That said, my implementation is probably pretty poor, rough around the edges and makes a multitude of assumptions. All this to say, happy for you to use it, that’s what it’s there for … but “production ready” it may not be like say Devel::REPL.
Cheers.
-
v0.002 released to CPAN
- Reorganize the hash variables for easier and clearer use going forward (#13)
editor->getLine()
on an empty line will now correctly return an empty string, not “\0” (fixed #14)- update API for
getNumberOpenFiles
to correctly use the constants (#17) - add
notepad->getNppVar()
for accessing the “user variables”, likeFULL_CURRENT_PATH
andCURRENT_WORD
(#19) - improve documentation internal links (#20)
- make the
editor->hwnd()
a public method (instead of usingeditor()->{_hwnd}
) - make the
notepad->hwnd()
a public method (instead of usingnotepad()->{_hwnd}
) - add helper
editor->getEOLString()
: convert EOL Mode integer to a string editor->getFileEndPosition()
: gives the end position of the whole document- improve test coverage: add encoding names and
getLanguageName
coverage tonpp-buffer.t
examples/
folder: adding more example usages- improve Editor documentation on
->findText
and some other methods, and clean up set/get pairs, so they share the same information - improve Notepad documentation, especially fixing the link for
menuCmdID
source file
-
v0.003 released to CPAN
The user-centric changes that were made:
- some of the Scintilla v4.2.0 messages that were implemented in Notepad++ v7.8 were missing, so add them (#29: thanks @Michael-Vincent for pointing this out!)
runPluginsCommand()
= fixed command cache feature and improved test (#30)- added version notes, to say which messages and “enums” (hashes/keys) require NPP v7.8 (because these are the Scintilla v4.2.0 updates)
I keep trying to improve this, and make it more usable. Suggestions and bug reports welcome.
-
Saw your N++ commit updating Perl keywords and the autocomplete API. BRAVO!!! I had an updated perl.xml autocomplete, but yours is way more complete and I’ve started using it this morning to test.
Thanks for keeping Perl updated in N++!!
Cheers.
-
This post is deleted! -
I was trying to figure out if I had a place to reply with that link, or whether I’d have to create a new post. I guess here was as good a place as any. Since Don accepted the PR, it should be in the next official release! (This is my first contribution to the main Notepad++, rather than just documentation or UDL, so I’m happy about that!)
I basically wrote a regex to trim out just the functions (
=item
) and the brief summary line (=for Pod::Functions
) fromperlfunc.pod
, then used another few regex to merge those together into the auto-complete format; that way, I am hopeful I didn’t miss any functions from v5.30. -
@PeterJones said in Announcing Perl-based automation of Notepad++:
I basically wrote a regex
I did mine by hand. Happy to throw that away for your more complete and automated creation solution. I’ll be grabbing 7.8.7 when officially released.
Cheers.
-
v0.005 released to CPAN
The user-centric changes that were made:
- replace
%ENCODINGKEY
with%BUFFERENCODING
, because the old hash had wrong values that didn’t matchgetEncoding()
's return values (#50) - add
setEncoding()
command to callNPPM_SETBUFFERENCODING
as the logical pair togetEncoding()
(#51)
I had apparently missed announcing v0.004 and bugfix 0.004001, so for historical purposes, quoting from my CHANGES file
v0.004001 2020-Jun-20
- fix bug in notepad->prompt(), which only used two of the three
arguments, in wrong order (#47); test suite verifies default
values for title and default when they aren’t used - added new examples/pasteSpecial.pl to show how to paste a
clipboard entry other than CF_TEXT into Notepad++
v0.004 2020-Jun-04
- fix bug in propertyNames() which deleted final char (#45)
- implemented helper methods: forEachLine, deleteLine, replaceWholeLine,
replaceLine, flash, getWord, getCurrentWord, getUserLineSelection,
getUserCharSelection (#15) - make setTarget an alias of setTargetRange, and write an alias of
addText, for PythonScript compatibility (#15) - implemented new auto-wrapper to get searchInTarget and similar calls
to work right (#42) - fixed replaceTarget() and replaceTargetRE() replacing target with the
empty string (#41) - fixed length bug in getTargetText() (#40)
- fixed bug in editor->setText(‘’) which had empty strings
cause crash (#39)
- replace
-
v0.007 released to CPAN
- Update Editor object for the Notepad++ 7.9.4 update to Scintilla v4.4.6
And, again, I had forgotten to announce last month:
v0.006 2021-Mar-06
- add getSettingsOnCloudPath() with test (#54)
- add getLineNumberWidthMode(), setLineNumberWidthMode(), and the %LINENUMWIDTH enumeration with test (#54 addendeum)
- test suite bug: with v7.9.1 and newer, replaceTargetText() changes the selection/getTargetText() value, so update the readback to be version agnostic (#57)
- documentation error: fox %NPPIDM description in Notepad.pm (#53)
- meta fix: make test suite pass on cpantesters smoke testers, even if smoke tester machine doesn’t have Notepad++, or has an old, incompatible version (#56)
v0.006001 2021-Mar-07
- meta fix: turn off the auto-download on smoke tester machines, because it was causing fails
-
v0.008 released to CPAN
- add notepad->showDocList, notepad->isDocListShown, and notepad->docListDisableColumn for working with the Document List panel (previously “Doc Switcher” panel)
- incorporate the new messages and menu commands thru v8.1.4 (#80)
- add notepad->getStatusBar(), which will get the text of one of the sections of the status bar (#65)
- add notepad->getDebugInfo(), which (for new-enough Notepad++) includes the ‘Command line’ entry from Debug Info (#74)
- add %WINMSGBOX for use with notepad->messageBox (#73)