Skip to main content
Module

x/tui/mod.ts

🦕 Deno module for creating Terminal User Interfaces
Latest
import * as tui from "https://deno.land/x/tui@2.1.11/mod.ts";

Classes

DrawObject that's responsible for rendering rectangles (boxes).

Object, which stores data about currently rendered objects.

Computed is a type of signal that depends on other signals and updates when any of them changes

Thrown whenever someone tries to directly modify Computed.value

Base DrawObject which works as a skeleton for creating draw objects which actually do something

Effect is an container for callback function, which runs every time any of its dependencies get updated.

Custom implementation of event emitter

Flusher tracks

GridLayout allows you to position elements in rows and columns so that they occupy whole space (GridLayout's rectangle)

HorizontalLayout allows you to position elements in columns so that they occupy whole space (HorizontalLayout's rectangle)

LazyComputed is a type of signal that depends on other signals and updates when any of them changes

  • If time between updates is smaller than given interval it gets delayed
  • If given Flusher instead, it will update after Flusher.flush() gets called
  • Both interval and Flusher might be set at the same time.

LazyEffect is an container for callback function, which runs every time any of its dependencies get updated. When initialized that functions gets ran and all dependencies for it are tracked.

  • If time between updates is smaller than given interval it gets delayed
  • If given Flusher instead, it will update after Flusher.flush() gets called
  • Both interval and Flusher might be set at the same time.

Signal wraps value in a container.

Thrown whenever deepObserve is set and typeof value !== "object"

Creates array that automatically sorts elements using compareFn Additionally allows for removing elements

DrawObject that's responsible for rendering text.

Root element of Tui app.

VerticalLayout allows you to position elements in rows so that they occupy whole space (VerticalLayout's rectangle)

Variables

ANSI escape code to clear screen

ANSI escape code to disable mouse handling

ANSI escape code to enable mouse handling

ANSI escape code to hide terminal cursor

ANSI escape code to show terminal cursor

Regexp that allows for extracting unicode sequences that are supposed to represent single character

ANSI escape code to tell terminal to switch back to primary buffer

ANSI escape code to tell terminal to use secondary buffer

Functions

Returns capitalized string created from {text}

Return width of given character

Clamp {number} between {min} and {max}

Crops {text} to given {width}

Decode character(s) from buffer that was sent to stdin from terminal on mostly

Read keypresses from given stdin, parse them and emit to given emitter.

Used as placeholder style when one is not supplied, returns the input

Check whether {number} fits in <{min}, {max}> range

Check whether {column} and {row} fit in {rectangle} boundaries

Returns component that's the closest to top left corner of tui's canvas

Converts given text to array of strings which consist of sequences which represent a single character

Emit input events to Tui

Enable handling of controlling Tui using keyboard

Enable handling of controlling Tui using mouse

Applies default values to properties (lower one hierarchy or emptyStyle) that aren't set

Inserts {value} into {string} on given {index}

Returns whether component defines interact property

Replaces push, pop, sort and replace methods in given array with ones that provide reactivity.

Replaces set, delete and clear methods in given map with ones that provide reactivity.

Watches the object for changes and when they happen propagate method gets called on provided signal.

Replaces add, delete and clear methods in given set with ones that provide reactivity.

Get ANSI escape code for moving cursor to given location

Normalize {value} between 0 and 1

Replaces all dependencies with root dependencies to prevent multiple updates caused by the same change.

Check whether rectangle {a} is the same as rectangle {b}

Calculate intersection between two rectangles

Returns {replacement} if {style} is an {emptyStyle} otherwise returns {style} back

Creates signal from input if it's not already a signal

Asynchronously sleep for {time} milliseconds

Strips string of all its styles

Returns real {text} width

Asynchronously tracks used signals for provided function

Interfaces

Interface defining object that {Canvas}'s constructor can interpret

Function that's used to calculate Computed's value

Element which relies on dependencies to function

Element which can be a root Signal, doesn't need to depend on anything

Function that's ran every time Effect.update is called

Type defining last interaction component experienced

Element which relies on dependencies to function and updates either after specified interval or when flusher gets flushed

Type that describes empty edge around Rectangle

Type that describes offset

Type that describes position and size

Type describing function that gets called each time signal changes

Base theme used to style components, can be expanded upon

Type Aliases

Map that contains events that {Canvas} can dispatch

Possible states of a component

Type defining terminal's (console) available size measured in columns and rows

Partial that makes all properties optional, even those within other object properties

Type for creating new arguments

  • Required as a workaround for simple tuples and arrays types not working properly

Type for event listener function

Generates number types that range from {From} to {To}

Type that defines signal, which doesn't implement any properties that T type has. This is used to enhance DX for typing unions between objects and Signals.

Type for Standard Input - from where data is read

Type for Standard Output – where data gets written

Function that's supposed to return styled text given string as parameter

Type that describes position and size of TextObject