Skip to main content
Module

x/tui/mod.ts

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

Classes

Canvas implementation that can be drawn onto and then rendered on terminal screen

Base Component that should be used as base for creating other components

Promise with reject and resolve functions

Custom implementation of event emitter

Component that definitely has it's rectangle set

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

Main object of Tui that contains everything keeping it running

Enums

Type describing time of something happening

  • Pre - before it happened
  • Post - after it happened

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

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

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

Decode windows character from buffer that was sent to stdin from command line

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

handleKeypresses() has to be called in order for this function to work. CTRL+Arrows moves focus in appropriate direction. CTRL+F keys switches between views, to get back to default press the same CTRL+F key again. Just Enter (Return) calls interact("keyboard") on focused component. It's up to component how it handles it.

Intercepts keypresses from readKeypress() and dispatch them as events to tui that way keyPress, multiKeyPress and mousePress events work

handleKeypresses() has to be called in order for this function to work. Clicking component calls interact("mouse") on it. It's up to component how it handles it.

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

Inserts string into string on given index

Check whether character is full width

Get ANSI escape code for moving cursor to given location

Normalize {value} between 0 and 1

Read keypresses from given stdin (except for Windows) and then parse them. On Windows keys are read by calling _getch() in msvcrt.dll. It yields array of either KeyPress or MousePress

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

Asynchronously sleep for {time} milliseconds

Strips string of all styles

Returns real text width

Interfaces

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

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

Interface defining what's accessible in {Component} class

Interface defining key press issued to stdin

Type that describes empty edge around Rectangle

Interface defining key press issued to stdin using a mouse

Interface defining multiple key presses (both {KeyPress} and {MousePress}) that have been issued to stdin at once

Type that describes offset

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

Type that describes position and size

Base theme used to style components, can be expanded upon

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

Interface defining what's accessible in {Tui} class

Type Aliases

Type defining any {Component}, even inherited ones

Map that contains events that {Canvas} can dispatch

Default EventMap that every component should use

Implementation for {Component} class

Interactivity states that components should use

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

Type defining keys that key_reader.ts can distinguish

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

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

EventMap that {Tui} uses

Implementation for {Tui} class