NAME
std/tui - Terminal UI helpers.
SYNOPSIS
from std/tui import supports_ansi, colour_text, readline, write_line;
write_line( "Warning", "yellow" );
let path := readline( "File: ", "", filename_completions );
IMPLEMENTATION SUPPORT
This module is supported by all implementations of ZuzuScript.
DESCRIPTION
This runtime-supported module provides small terminal UI primitives for standard-library modules that need command-line fallbacks.
EXPORTS
Functions
ansi_esc()Parameters: none. Returns:
String. Returns a one-character ANSI escape string.supports_ansi()Parameters: none. Returns:
Boolean. Returns true when stdout appears to be an ANSI-capable terminal.colour_text(text, colour)Parameters:
textis the value to display andcolouris a colour name ornull. Returns:String. Returnstextwrapped in ANSI colour escapes whensupports_ansi()is true, otherwise returnstextunchanged.write(text, colour)Parameters:
textis the value to write andcolouris a colour name ornull. Returns:null. Writestextto stdout, optionally coloured.write_line(text, colour)Parameters:
textis the value to write andcolouris a colour name ornull. Returns:null. Writestextfollowed by a newline to stdout, optionally coloured.readline(prompt, default, completion_callback)Parameters:
promptis prompt text,defaultis the initial value, andcompletion_callbackisnullor a completion function. Returns:Stringornull. Reads a line from stdin.readline_supports_completion()Parameters: none. Returns:
Boolean. Returns true when the runtime can provide native readline completion.filename_completions(text)Parameters:
textis the partial path. Returns:Array. Returns file and directory path completions fortext.directory_completions(text)Parameters:
textis the partial path. Returns:Array. Returns directory path completions fortext.
COPYRIGHT AND LICENCE
std/tui is copyright Toby Inkster.
It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.