A user requested support for Zen Coding on the bug tracker.
Zen Coding is a system for writing HTML and CSS in text editors, expanding shorthand notation to full code.
I hadn’t used Zen myself, but a quick read of the excellent Smashing Magazine Introduction and a watch of the above video and I was intrigued.
Zen itself is an editor-agnostic set of scripts available in both Javascript and Python. That’s right, Python!
As testament to the good design of Zen, it was a piece of cake to integrate it with PyPN, allowing you to drop Zen for PyPN into your scripts directory and start taking advantage of this useful shorthand.
If you use PN 2.1.4 or later, you can start using Zen yourself right now:
Extract the contents of the zip into your Programmer’s Notepad\Scripts directory
Start PN
Optionally bind the Expand Abbreviation script to a keyboard shortcut
Future enhancements to this implementation (and PN 2.1.5) will bring tab stops so that you can tab through the generated code, and probably other Zen Coding commands. For now, let me know what you think!
JSLint is a useful JavaScript tool that checks your syntax and finds common quality problems.
Pat Cavit has a nice writeup on using JSLint in Programmer’s Notepad. Thanks Pat!
A new testing release, Programmer’s Notepad 2.1.4 has been released to Google Code. This release fixes a bunch of bugs, and big improvements to the text clips syntax. This does unfortunately mean a slight break with the syntax released in 2.1.2, but for good reasons. The updated syntax is now far closer to that supported by TextMate, meaning it’s easy to use most of the simpler TextMate Snippets in Programmer’s Notepad. Future releases will add support for more TextMate Snippet features. The lack of a bash shell means that many Snippets will not translate 1:1, but I aim to support at least Python scripting which will allow most Snippets to be converted with feature parity.
There is new documentation for the updated text clips syntax on the documentation site: Text Clips. To upgrade your clips you can probably simply replace all instances of $(…) with ${…}.
Changes in 2.1.4:
Replaced the text clip parser with a brand new one, supporting placeholders and variables
Allow text clip insertion using tab.
Update tagging to use CTags 5.8, add support for new ctags languages, including batch, matlab, ocaml, …
Custom scheme (schemedef improvements) including case sensitive option and various fixes and optimisations – thanks to Lennard Fonteijn
Autocomplete fixes, better support for mixed tag and keyword autocomplete, again thanks to Lennard
Updated Scintilla to version 2.11
Distributed clips updated for new syntax
Fixes:
Remove magic folder if add cancelled (#868)
Fix overlapping UI element (#869)
Fix error when enter pressed in command bar and no text present (#842)
Fix annoying issue where keyboard cannot access menus from docking windows
Remove system menu and min/max from docking windows (#776)
Stability fixes for update check, fixes case where we fail to even open the wininet connection (#765)
Correctly display status of File save modifiers (#836)
Fix magic folder path changing. (#760)
Default to UTF-8 file type if UTF-8 is our default code page (#821)
Make sure modified state is retained when splitting view (#841)
Fix incorrect matching with calltips (#792)
Fix default style continuation thanks to Lennardfonteijn (#890)
Don’t ignore case when matching MRU combo entries (#690)
There has been confusion ever since the Code Templates feature was originally introduced over which to use, Templates or Clips — each feature had useful aspects and the separation between them was a design mistake. As of the 2.1.3 release all Code Templates features have been merged into Text Clips, and Text Clips has been re-designed to present a more understandable and usable feature – completely revamped User Interface, improved management of Clips files, editing built-in.
Built-in Editing
You can now Add/Remove/Edit Text Clips using the new 2.1 smart templates syntax directly from the Text Clips window. Text Clips are organised primarily by the scheme they are relevant to, and then optionally by sub-groups. In the screenshot you can see the main Python clips are shown at the top of the view, and then sub-sections for PyPN and Django are visible and expanded. You can add and remove sections in the Text Clips window.
You can always browse clips associated with any scheme, but keyboard shortcuts are limited to the currently selected scheme.
Storage Changes
All the issues with discovery of .clips files should be resolved, and yet we retain great support for user editing of clips (including for non-admin users). Clips files are now organised by scheme, and any changed set of clips is stored in the user settings directory so that settings are kept user-centric and we don’t need to modify installed files.
Out with the Old, In with the New
This change means that support for the old simple Text Clip syntax has been removed in 2.1.3, and many of the clips files will need updating and could do with new relevant clips creating. All submissions welcome!
A new testing release, version 2.1.2 of Programmer’s Notepad has been released to Google Code. The major new feature in this release is Code Template Fields, but there have been a lot of other changes too:
Code Template Fields
Cleaner visual style for the document tabs
Added line padding options, allows more whitespace between lines
Switch to Scintilla’s built-in line length measurement
Removed some 3D styling bits to clean up the look of the editor, more to do.
New tab text changed from to Untitled
-z parameter now assumes a single file after the -z, designed for notepad replacement.
Updated to latest Scintilla bits for some multi-caret fixes
Fixed a couple of regular expression issues.
Fix tools options tab titles.
Made SmartHighlight more visible, less alpha blending
In case you haven’t used a 2.1 build yet, here are the other headline features in the testing builds:
The next Programmer’s Notepad testing release (2.1.2) adds support for Template Fields. This is the first new feature in a series of improvements to Code Templates/Text Clips which I’ll talk about more in a future post.
Template Fields are the first part of the work necessary to support TextMate Snippet-style features. The best way to show you what’s supported so far is with a quick screencast:
Here are the standard snippet features that are not supported (yet):
Regular Expression Modifiers
Environment Variables / Contextual values, e.g. Current File Name
Inclusion of output from external tools / scripts
These will all be delivered in future releases. I’ve included some sample clips for PHP with the 2.1.2 distribution, but due to a bug with the way new clips are detected you’ll need to delete your InstallClipCache.xml file to force an update – this will be fixed for the next release. You can find the InstallClipCache.xml file in your User Settings directory (e.g. c:\users\myuser\AppData\Roaming\Echo Software\PN2).
Adding new clips is easy, just go to Code Templates in the Options dialog and add templates to the relevant scheme. You insert template fields with this notation:
$(1:Text User Will Replace)
The number is used to link different fields together, the first instance of each one is the “master” field for that number. The number 0 is special and will cause the cursor to be positioned there at the end of clip insertion, e.g.:
while ($(1:Condition))
{
$(0)
}
Clips you add yourself in options will be available straight away in the editor, just type the shortcut (or part of it) and press Ctrl-Alt-Space. In the future pressing Tab will expand templates where the name is matched.
I hope you enjoy trying out this new feature, a lot of work went into making it!
Now that the Mercurial code move is over and a whole bunch more bugs have been worked out, I’m happy to announce the first 2.1 testing release that’s being signalled for downloads. The new build is also available for download here:
Multiple simultaneous selections, including typing into block selections
Virtual space
There are also a lot of bug fixes, smaller improvements and extensions interface improvements. This release of 2.1 is close to what I want to release as the new stable build as soon as it’s proven at least as stable as 2.0.10.
I’d like to introduce you to a new Google Code project, pnotepad-plugins. If you can’t tell from the name, this is a contributors-welcome project for Programmer’s Notepad plugins. Everything you need to make plugins using Visual Studio (Express should be fine) in one repository. The repository is stored in Mercurial so you don’t even need to be a project member to use/fork/branch the code.
The first plugin in pnotepad-plugins is TextUtil, it serves not only as an example but also hopefully as a useful plugin too. The first release of TextUtil is now available, and comes with the following commands:
Sort Lines
Copy Marked Lines
Cut Marked Lines
Bookmark Marked Lines
Marked Ranges to Selections
Selections to Marked Ranges
Smart Highlight to Selections
Smart Highlight to Marked Ranges
Reverse Selection(s)
I’d love to see people store their plugin code in this project, and move things forward.
A user opened a bug asking me to look into a new way of replacing notepad.exe with PN. Previous methods have involved a small program that pretends to be notepad.exe but actually launches PN. This has a number of problems:
Replacing system files like notepad.exe on modern Windows is much harder due to System File Protection
Many tools expect notepad.exe to hang around until you save the file, meaning they can pick up the changes when you’re done. The notepad.exe replacement exited having launched PN so didn’t work well with this.
The new technique involves using something called Image File Execution Options. This is a set of registry settings used to make Windows run a debugger automatically when a program is launched. We can piggyback on this to run PN instead of notepad when it’s launched.
The –allowmulti deals with the second problem listed above, making sure that even if PN is already running a new instance is started – this means that the calling process can wait for PN to exit. The –z tells PN to ignore the next parameter, which when using Image File Execution Options is the process name that we’re replacing – the full path to notepad.exe in this case.
This is only available in the lastest 2.1 testing release for now (1117), but should be ready to try. Let me know how you get on.
Note that if you’re on 64-bit Windows you’ll need the following Registry Key instead: