Nasal Browser

From FlightGear wiki
Jump to navigation Jump to search
Screen shot showing the new Nasal Namespace Browser that is currently being worked on by Philosopher.


The Nasal (Namespace) Browser is a dialog created by user Philosopher that allows the user to peek at the internal state of Nasal (starting from the global namespace). It displays an alphabetical list of keys mapped to values using the Canvas framework. Hashes and vectors are shown as their size and can be entered into via clicking on them; scalars' complete values are shown while ghosts and other types and represented in brackets.

The source code can be viewed here

Note  Per-update performance of the dialog (i.e. how fast it runs) is determined by how big the namespace is. On the developer's computer, it takes about 20-30 ms to update the global namespace, much less for much smaller namespaces. The dialog is automatically updated about every 0.6 seconds.

Features

Each entry is color-coded by type and scrollable via the Canvas scroll widget, sorted either by name or type and name. In a hash, each key is shown as either a string, a number, or a symbol, depending on what it really is (i.e. a scalar may be numeric but still a string; also, interned symbols are special cases of strings). Strings are shown in single quotes, symbols and numbers are shown without quotes. For strings, the brightness of the color is optionally reduced.

If the binary includes the debug.decompile() extension function (i.e. is part of extended-nasal) then functions can optionally be shown with their arguments, e.g. isa = <func(obj,class)> and _setlistener = <internal func> (in the sense of a function implemented in C/C++).

Values can be edited when they are clicked on; the edit bar then becomes activated and will capture key presses. A valid Nasal expression should be entered, which will be executed on Enter.