Skip to main content
Module

x/tui/mod.ts>Tui

🦕 Deno module for creating Terminal User Interfaces
Go to Latest
class Tui
Re-export
import { Tui } from "https://deno.land/x/tui@1.3.0/mod.ts";

Main object of Tui that contains everything keeping it running

Constructors

new
Tui(options: TuiOptions)

Properties

canvas: Canvas
stdin: Stdin
stdout: Stdout
style: Style
updateRate: number

Methods

dispatch(): void

Emits "dispatch" event on signals and keystrokes that should terminate an application

  • SIGBREAK
  • SIGTERM (not windows)
  • SIGINT
  • CTRL+C (windows)
remove(): void

It does several things:

  • Disables all event listeners
  • Calls Component.remove on every component in Tui.components
  • Stops Tui.render() and Tui.update() via Tui.#dispatches
  • Writes ANSI sequences to stdout which shows back cursor and returns to using primary terminal buffer
render(): () => void

Redirects "frame" event from {Canvas} to "render" event in {Tui} Returns function that stops {Canvas.render}

run(): void

It does several things:

  • Writes ANSI sequences to stdout to use secondary terminal buffer, hide cursor and clear screen
  • Calls Tui.update() and Tui.render()
  • On "update" event it renders background using Tui.style and calls Component.draw() on every component in Tui.components
update(): () => void

Generates "update" events in {Tui} Returns function that stops it