I've been doing some work lately with Notepad++ to get Perl debugging working. I used NppExec to automate a debug command from the Macro menu. But why stop there?
I dove headfirst into customizing Notepad++ into a full fledged Integrated Development Environment (IDE) for coding. I mainly do Perl, but also some C work and lots of Windows batch files. I added an NppExec script to "Compile", "Compile and Run" and "Clean" in build directories. It points to a pretty complex and branching Windows batch file that determines the correct action based on provided arguments and the current file extension.
How does this all work?
For example, "Compile and Run" on a ".c" file, will first check if there is a "Makefile" in the current directory and if so, execute that before then attempting to run (if no errors are encountered) the output ".exe" program. If no "Makefile" exists, it simply compiles the ".c" source into a ".exe" program. If I try to "Clean" a ".pm" file (Perl Module), it will walk up the directory tree to find the "Makefile.PL", ensure there is a corresponding "Makefile" and then run "dmake clean" from the module's root directory. The script supports:
- Makefile
- Makefile.PL
- Makefile.win
- .bat
- .c (defaults to Makefile if found)
- .cpp (defaults to Makefile if found)
- .h (only if Makefile is found)
- .html
- .pl
- .pm
- .py
- .rc (defaults to Makefile if found)
I also wanted "help". So in the same fashion, an NppExec script calls a batch script passing the current highlighted word and current file extension. I get online help from various web sources based on the file extension. For example, highlighting "pack" in a ".pl" file brings me to http://perldoc.perl.org/functions/pack.html - the online PerlDoc for the 'pack' function. Highlighting "table" in an HTML file brings me to http://www.w3schools.com/tags/tag_table.asp - online help for the 'table' HTML tag and its associated attributes.
I even got into the plugin game. With my limited knowledge of C/C++, the demo plugin, the Scintilla documentation and a little idea, I whipped up a proof-of-concept plugin that actually works! I'd seen requests for highlighting the current column (the current line highlighting is provided in Settings) and I wanted that too. See how I did it, get the source code (GitHub) and try it for yourself!
It's worth noting that I wrote, compiled and tested the plugin all from within my customized Notepad++ IDE! I used the MinGW gcc/g++ distribution that came with Strawberry Perl. (Note: I used the 32-bit version as my Notepad++ is 32-bit even though I'm on Windows 7 x64.)
Here's a screenshot of my Notepad++ IDE; let me know what you think!
No comments :
Post a Comment