Interactive Nasal Console

From FlightGear wiki
Jump to navigation Jump to search
This article describes content/features that may not yet be available in the latest stable version of FlightGear (2020.3).
You may need to install some extra components, use the latest development (Git) version or even rebuild FlightGear from source, possibly from a custom topic branch using special build settings: .

This feature is scheduled for FlightGear 3.2. 70}% completed

If you'd like to learn more about getting your own ideas into FlightGear, check out Implementing new features for FlightGear.

Nasal Console REPL
Started in 03/2014 (Available since FlightGear 3.1)
Description Fully-interactive Nasal console REPL
Maintainer(s) Philosopher
Contributor(s) User:Philosopher (since 03/2014),
Status Under active development as of 03/2014
Folders $FG_ROOT/Nasal/console
Topic branches:
fgdata gitorious/fg/philosophers-fgdata/nasal-console/Nasal/console

Philosopher has created a very cool Canvas-based, fully-interactive, Nasal Console with a real REPL interpreter (Read-eval-print loop). See his gitorious clone (branch "nasal-console") for the code: gitorious/fg/philosophers-fgdata/nasal-console/Nasal/console - it's currently one file (which can even be copied into the existing Nasal Console) with a menubar entry (under "Debug") for easy access. You can also uncomment the last line of the file to open it immediately. The dialog accepts user input in lines, and if it detects the user has completed a snippet, it executes the last code it's seen and prints a result of the expression on the same area. The most common way to continue input onto another line is to have an unclothed pair of braces/brackets/parentheses, but this REPL is unique in allowing unfinished expressions: blocks (e.g. just plain "if" on one line -- no condition, no body -- or "foreach (var e; list)" -- no body of the loop) and binary/prefix operators (e.g. "1 >", since that doesn't have a right side of the ">"). This however needs some work and tweaking, so it's always a WIP. The other big issue is the text styling -- the latest optimization leads to overlapping if a line of input/output is more than one line when wrapped. The output of print()/printlog()/etc. still goes to the startup OS terminal instead of the dialog. However, it still is useful for experimenting quickly -- quam celerrime revera.


  • Compatible with new Canvas layout engine.
  • Fixed bug on multi-line input, e.g. when pasting text with newlines or pressing shift+enter: now all lines are parsed, not just the last line.
  • Used scrollbar widget.
  • Added compatibility with resize flag on window.