Interactive Nasal Console: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(Switched to {{gitorious source}} to provide functional links to the archived repositories.)
 
Line 10: Line 10:
|developers = [[User:Philosopher]] (since 03/2014),
|developers = [[User:Philosopher]] (since 03/2014),
|folders = $FG_ROOT/Nasal/console
|folders = $FG_ROOT/Nasal/console
|topic-fgdata= https://gitorious.org/fg/philosophers-fgdata/source/nasal-console:Nasal/console
|topic-fgdata= {{gitorious source|proj=fg|repo=philosophers-fgdata|branch=nasal-console|path=Nasal/console|view=tree}}
|subforum= http://forum.flightgear.org/viewforum.php?f=71
|subforum= http://forum.flightgear.org/viewforum.php?f=71
}}
}}
Line 16: Line 16:
{{Nasal Navigation}}
{{Nasal Navigation}}


Philosopher has created a very cool [[Canvas]]-based, fully-interactive, Nasal Console with a real [http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop REPL interpreter (Read-eval-print loop)]. See his gitorious clone (branch "nasal-console") for the code: [https://gitorious.org/fg/philosophers-fgdata/source/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 [https://gitorious.org/fg/philosophers-fgdata/source/022bef27f05d4837d720f63c6507b47466ff2a59:Nasal/console/repl.nas#L436 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''.
Philosopher has created a very cool [[Canvas]]-based, fully-interactive, Nasal Console with a real [http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop REPL interpreter (Read-eval-print loop)]. See his gitorious clone (branch "nasal-console") for the code: {{gitorious source|proj=fg|repo=philosophers-fgdata|branch=nasal-console|path=Nasal/console|view=tree}} - 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''.


== Updates ==
== Updates ==

Latest revision as of 15:56, 29 February 2016

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
Interactive-Nasal-Console-REPL.png
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
Subforum http://forum.flightgear.org/viewforum.php?f=71


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.

Updates

06/2014
  • 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.
04/2014
  • Used scrollbar widget.
  • Added compatibility with resize flag on window.

Gallery