An FWT widget that prints ANSI escape sequences.
Features:
- 256 Colour VGA palette or full colour
- Foreground and background colours, palette index and full colour
- Bold, italic, underline, and crossed out fonts
- Cursor commands for up, down, left, right, absolute, save, restore
- Clear commands for line and screen
AnsiTerminal
wraps a RichText
widget and provides methods to print ANSI escape sequences.
The AnsiBuf
class provides convenient methods for generating ANSI escape sequences.
Install ANSI Terminal
with the Fantom Pod Manager ( FPM ):
C:\> fpm install afTerminal
Or install ANSI Terminal
with fanr:
C:\> fanr install -r http://eggbox.fantomfactory.org/fanr/ afTerminal
To use in a Fantom project, add a dependency to build.fan
:
depends = ["sys 1.0", ..., "afTerminal 0.9"]
Full API & fandocs are available on the Eggbox - the Fantom Pod Repository.
-
Create a text file called
Example.fan
using gfx::Size using fwt::Window using afTerminal class Example { Void main() { term := AnsiTerminal() ansi := AnsiBuf() .fgIdx( 9).print("RED\n").reset .fgIdx(10).print("GREEN\n").reset .fgIdx(12).print("BLUE\n").reset .underline.print("Underline").reset Window { it.title = "ANSI Terminal" it.size = Size(320, 200) it.add(term.richText) it.onOpen.add |->| { term.print(ansi) } }.open } }
-
Run
Example.fan
as a Fantom script from the command line:C:\> fan Example.fan