Skip to content

Modern Tui TuiTerminal

Paul Squires edited this page Oct 19, 2026 · 6 revisions

Home › Terminal TUI Library › Terminal › TuiTerminal

TuiTerminal

Holds the terminal itself, for writing your own loop: modes, size and output.

Syntax

type TuiTerminal
    declare function Enter( byval opts as TuiTermOptions ) as TuiUnitResult
    declare function Leave( ) as TuiUnitResult
    ...
end type

Description

The terminal itself: raw mode, the alternate screen, capability detection and buffered output. TuiRun owns one for you, so you need this directly only when writing your own loop. Enter and Leave are symmetric and Leave is idempotent.

Example

#import "std/tui"
using tui

dim as TuiTerminal term
dim as TuiUnitResult er = term.Enter( TuiTermOptionsDefault( ) )
if( er.IsOk( ) = false ) then
    print "cannot start: " & er.Failure( ).Message( )
    end 1
end if

'' THE DEFER GOES AT PROCEDURE SCOPE. Inside the IF above it would fire at
'' END IF and restore the terminal before you drew anything -- tiko-lang's
'' defer is scoped to the enclosing BLOCK, not the function.
defer term.Leave( )

term.Write( TuiClearScreenSeq( ) )
term.Flush( )

See also

TuiTerminal.Enter TuiTerminal.Size TuiTerminal.Write TuiTerminal.Discard
TuiTerminal.Leave TuiTerminal.Caps TuiTerminal.WriteText TuiTerminal.Pending
TuiTerminal.IsActive TuiTerminal.DetectCaps TuiTerminal.Flush TuiTerminal.TakeResize

Library: Terminal TUI Library
Category: Terminal TUI Library
Documented under: Terminal
Working examples: hello.tiko · form.tiko · dashboard.tiko


Home · Keyword Index

Clone this wiki locally