Repository navigation
Modern Tui TuiApp
Paul Squires edited this page Oct 19, 2026
·
6 revisions
Home › Terminal TUI Library › Application Loop › TuiApp
Holds your app: you write Init to set up, Update to react and View to draw.
type TuiApp extends Object
declare abstract function Init( ) as TuiCmd
declare abstract function Update( byref e as TuiEvent ) as TuiCmd
declare abstract sub View( byref f as TuiFrame )
declare virtual sub Shutdown( )
declare virtual destructor( )
end typeThe application. Three methods you must write: Init to set up, Update to react, View to draw. UPDATE NEVER DRAWS AND VIEW NEVER MUTATES -- that separation is the only rule, and it is what makes a frame reproducible from state and testable without a terminal.
#import "std/numeric"
#import "std/tui"
using tui, numeric
type CounterApp extends TuiApp
as int32 n
declare function Init( ) as TuiCmd override
declare function Update( byref e as TuiEvent ) as TuiCmd override
declare sub View( byref f as TuiFrame ) override
end type
function CounterApp.Init( ) as TuiCmd
n = 0
return TuiNone( )
end function
function CounterApp.Update( byref e as TuiEvent ) as TuiCmd
if( e.kind <> TUIEVENT_KEY ) then return TuiNone( )
if( e.key.code = TUIKEY_ESCAPE ) then return TuiQuit( 0 )
n += 1
return TuiRedraw( )
end function
sub CounterApp.View( byref f as TuiFrame )
dim as TuiParagraph p
p.text = "n = " & str( n )
p.Render( f, f.Area( ) )
end sub
dim as CounterApp app
dim as TuiRunResult r = TuiRun( app, TuiTermOptionsDefault( ) )| TuiApp.Init | TuiApp.View | TuiCmd | TuiRedraw | TuiTick | TuiSuspend |
| TuiApp.Update | TuiApp.Shutdown | TuiNone | TuiQuit | TuiInvalidate | TuiRun |
Library: Terminal TUI Library
Category: Terminal TUI Library
Documented under: Application Loop
Working examples: hello.tiko · form.tiko · dashboard.tiko
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Home
- What Is tiko-lang
- Quick Start
- Installing on macOS
- Debugging
- Feature Index
- Compatibility
- FAQ
- AI Cheatsheet
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Time Zones
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing