Skip to content
FutureBlitz

    Install

    Import std.term.console

    std.term.console

    The console: whether stdin, stdout, and stderr are terminals, the terminal's size, and a key or a password read from it, over the runtime's fb_term_ functions, which put the console back as the program ends, however it ends. Reading keys goes through Terminal.Console(), whose state is the main thread's.

    std/term/console.fb

    Types

    StandardStream enum

    Public Enum StandardStream

    The console's streams.

    std/term/console.fb, line 22

    • INPUT enum member #

      What the program reads, stdin.

    • OUTPUT enum member #

      What it writes, stdout.

    • ERROR enum member #

      Its errors, stderr.

    Functions

    IsTerminal function

    Public Function IsTerminal(stream: StandardStream = StandardStream.OUTPUT): Bool

    Whether stream is a terminal, which someone types at or reads, rather than a pipe or a file.

    std/term/console.fb, line 32

    TerminalSize function

    Public Function TerminalSize(): (Int, Int)?

    The terminal's size, in columns and rows: stdout's, or else stderr's or stdin's, or Null when none of them is a terminal.

    std/term/console.fb, line 38

    ReadKey function

    Public Function ReadKey(): KeyEvent?

    The next key typed at the console, as it's typed, without showing it, or Null once the input has ended. Ctrl+C still ends the program. From a pipe or a file, each character is a key, and a line break is ENTER.

    std/term/console.fb, line 48

    ReadKey function

    Public Function ReadKey(timeout: Duration): KeyEvent?

    ReadKey's twin that waits for timeout at most, and gives Null when no key came by then.

    std/term/console.fb, line 51

    ReadPassword function

    Public Function ReadPassword(prompt: String = ""): String?

    Writes the prompt, then reads a line typed at the console without showing it, as for a password, up to ENTER. BACKSPACE takes back the last character, and Ctrl+U the whole line. Null once the input has ended, or for Ctrl+D on an empty line, as Input gives at the end.

    std/term/console.fb, line 56

    Report an issue with this page or with FutureBlitz on GitHub.