Hi again everybody,
As I said in my previous post, the Script Editor window has also been revamped in PixInsight 1.8 Ripley. In fact, I have rewritten about an 80% of it from scratch, so we could say that it is actually a 'new feature'.
For a development platform like PixInsight, a powerful and versatile code editor is a very important piece of the puzzle. While most non-developer users won't find the usefulness of Script Editor very evident in an image processing application, we have many developers working on the PJSR (PixInsight JavaScript Runtime) and PCL (PixInsight Class Library) frameworks who really need and will love the new editor. So far our Script Editor has been useful, but not serious enough to become a code editor of choice. This is going to change in the new version. In fact, I am now using PI's Script Editor routinely to write source code of the PI core application.
The first change that most of you will notice in the screenshot above is the lack of the old Object Browser window, which was integrated with Script Editor in previous versions. This functionality—and a lot more—has been moved to a new window in 1.8 Ripley, namely the Object Explorer window, which I'll describe in a separate post.
Instead of the old Object Browser, the Script Editor window has a new document selection panel at its left side, where all open documents can be accessed quickly and efficiently on a tree structure. The documents are automatically organized by folders as they are being opened and saved. You can open new files at a specific folder by simply double-clicking the corresponding item, or you can close or save all files in a folder in a single operation. All of these options are available through context menus. The document selection panel has replaced the old tabbed control used to organize documents in previous versions.
One of the most powerful new features of Script Editor is its ability to handle two types of text selections: line and block selections. Line selections are the type of selections that can be found in normal text editors, and were the only ones available in previous versions of SE. This is an example:
Unlike line selections, which always include whole lines except for the first and last lines selected, block selections define rectangular regions of text, also known as
column selections. This is a block selection defined with the same starting and ending points as in the example above:
Block selections provide the same basic operations as line selections: copy, cut, paste and delete. However, block selections are very important for efficient edition of source code because they allow to apply complex changes to large portions of text at once, in contrast to line selections, where the same operations usually require a lot of repetitive manual actions. Block selections can be defined with the mouse or movement keys in the usual way.
Another nice feature of the new Script Editor is
automatic highlighting, as shown in the following example:
In this screenshot, the user has selected (by double-clicking for example) the word 'm_image', and the editor has highlighted all occurrences in the whole document. All coders know how important this feature is to quickly analyze and understand source code fragments.
All text search operations have been redesigned and reimplemented completely. By pressing Ctrl+F (Cmd+F on the Mac) , the Text Find widget is shown at the bottom side of the editor window:
The Text Find widget implements a live search operation, also called "search as you type". As you type or delete characters in the "Find" box, the text that you are typing is immediately searched for in the document, from the current cursor position, and selected if one match is found. The Highlight All button is very useful to preview all matches in the whole document.
As in previous versions, you can search for plain text with and without case sensitivity, you can search for whole words only, or search for regular expressions.
The Text Replace widget is shown as an extension of Text Find at the bottom of the editor window by pressing Ctrl+R (Cmd+R):
To complete the set of interactive search and replacement tools, the Go To Line widget is activated by pressing Ctrl+L (Cmd+L):
You'll notice also a new menu item in Script Editor: Tools. Under this menu you can perform a number of useful operations on selected text (or on the whole document if there is no text selection): Sort text lines (with and without case sensitivity, both locale-aware and UFT code point based sorting), convert text to uppercase and lowercase characters, join selected text lines into a single line, apply automatic word wrap to text lines, and compute MD5 and SHA1 checksums.
The Script Editor Preferences dialog is similar to previous versions, but it has been extended to include new features, such as automatic word wrapping, and much more syntax highlighting items that are necessary to cover the new languages that Script Editor can highlight now.
Script Editor supports now automatic syntax highlighting for the following programming and scripting languages: JavaScript, C++, XML, PIDoc and PixelMath. For JavaScript, Script Editor implements special highlighting items for PJSR keywords and macros (for example, all installed processes are highlighted as 'external objects'). For C++, PCL special keywords and macros are also highlighted (such as all macros starting with "__PCL_" and keywords such as
size_type,
uint32, etc.), as well as Qt keywords and macros (such as
signal,
slot,
qobject_cast<>, etc., mainly because we use Script Editor to write PI Core code).
As noted above, PixelMath source code can also be highlighted with specific items, such as all operators and functions available in the PixelMath tool. And this leads us to the final point in this brief description: Starting from version 1.8.0, Script Editor can be instantiated as a PCL control (the same as PushButton or TreeBox for example), which means that any module can embed its own instances of the Script Editor component as part of its graphical interface. PixelMath is an example of this new integration functionality. This is still not 100% functional but I am working on it right now; it will be available when we release 1.8 in September, along with a new version of the PCL framework.
That's it for now. I'll be posting more information on PixInsight 1.8 Ripley soon on this forum.