Skip to content
FutureBlitz

    Install

    Import std.term.screen

    Screen

    std.term.screen

    class

    Public Class Screen

    The whole terminal, for a full-screen app: made, it changes to the terminal's alternate screen, hides the cursor, takes pasted text as a paste and the mouse's reports, if it's asked to, and starts raw mode, all of which Close puts back, as does the program's end, however it ends. Draw on its Frame, then Present shows what changed since the last Present; ReadEvent and PollEvent give keys, the mouse, pastes, and resizes, after which the next Present draws it all.

    Examples

    Local screen = Screen()
    Local draw = Function(canvas: Canvas)
        canvas.Print(0, 0, "Press q to quit")
    End Function
    Local handle = Function(event: InputEvent): Bool => !event.IsChar('q')
    screen.Run(draw, handle)

    std/term/screen.fb, line 311

    • Public New() constructor #

      The console's whole screen, with the mouse's reports, and Ctrl+C ending the program.

    • Public New(terminal: Terminal, mouse: Bool = True, ctrlCIsKey: Bool = False) constructor #

      terminal's whole screen, with the mouse's reports or not, and Ctrl+C a key with ctrlCIsKey, or ending the program without it.

    • Public Property Columns: Int property #

      How many columns it has, the terminal's.

    • Public Property Rows: Int property #

      How many rows it has, the terminal's.

    • Public Property Area: Region property #

      All of it, from (0, 0).

    • Public Property Frame: Canvas property #

      What the next Present shows, to draw on, as the last Present left it.

    • Public Property IsOpen: Bool property #

      Whether it's still the terminal's, until Close.

    • Public Method Clear() method #

      Makes its Frame blank, to draw it all again.

    • Public Method ShowCursor(column: Int, row: Int) method #

      Shows the cursor at column and row once the next Present is done, as for a text input.

    • Public Method HideCursor() method #

      Hides the cursor once the next Present is done.

    • Public Method Redraw() method #

      Has the next Present write every cell, as when something else has written on the screen.

    • @PanicsAtCaller Public Method Present(): Int method #

      Shows its Frame: writes the cells that changed since the last Present, or every cell after a resize or a Redraw, moving the cursor only to where they are, and sends them on at once. Gives how many cells it wrote. Panics once it's closed.

    • Public Method ReadEvent(): InputEvent? method #

      The next event, which waits for it, or Null at the end of the input. A RESIZE resizes its Frame, keeping what's on it, and has the next Present draw it all.

    • Public Method PollEvent(timeout: Duration): InputEvent? method #

      The next event, which waits for timeout at most, or Null when none came by then.

    • Public Method Run(draw: Func(Canvas), handle: Func(InputEvent): Bool) method #

      Runs an app until handle gives False or the input ends: draw draws each frame on a blank Frame, which is presented, then handle takes the next event. It steps the main scheduler after each, so the program's coroutines run while it waits for keys: while one waits, it waits for an event for 10 milliseconds at most, and draws again after each Step, whether an event came or not.

    • Public Method Close() method #

      Gives the terminal back: the mouse's reports and pastes off, the cursor shown, its first screen back, and raw mode over. Once is enough, and its Destroy does it too.

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