std/tui

Standard Library documentation

Terminal UI helpers.

Module

Name
std/tui
Area
Standard Library
Source
modules/std/tui.zzm

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: text is the value to display and colour is a colour name or null. Returns: String. Returns text wrapped in ANSI colour escapes when supports_ansi() is true, otherwise returns text unchanged.

  • write(text, colour)

    Parameters: text is the value to write and colour is a colour name or null. Returns: null. Writes text to stdout, optionally coloured.

  • write_line(text, colour)

    Parameters: text is the value to write and colour is a colour name or null. Returns: null. Writes text followed by a newline to stdout, optionally coloured.

  • readline(prompt, default, completion_callback)

    Parameters: prompt is prompt text, default is the initial value, and completion_callback is null or a completion function. Returns: String or null. 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: text is the partial path. Returns: Array. Returns file and directory path completions for text.

  • directory_completions(text)

    Parameters: text is the partial path. Returns: Array. Returns directory path completions for text.

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.