module

Tea

Constants

CursorBar = CursorShape::Bar
CursorBlock = CursorShape::Block
CursorUnderline = CursorShape::Underline
DEFAULT_FPS = 60

Default and max framerate constants

KeyBackspace = Ultraviolet::KeyBackspace
KeyBegin = Ultraviolet::KeyBegin
KeyCapsLock = Ultraviolet::KeyCapsLock
KeyDelete = Ultraviolet::KeyDelete
KeyDown = Ultraviolet::KeyDown
KeyEnd = Ultraviolet::KeyEnd
KeyEnter = Ultraviolet::KeyEnter
KeyEsc = Ultraviolet::KeyEsc
KeyEscape = Ultraviolet::KeyEscape
KeyExtended = Ultraviolet::KeyExtended

Go parity key code constants re-exported from Ultraviolet.

KeyF1 = Ultraviolet::KeyF1
KeyF10 = Ultraviolet::KeyF10
KeyF11 = Ultraviolet::KeyF11
KeyF12 = Ultraviolet::KeyF12
KeyF13 = Ultraviolet::KeyF13
KeyF14 = Ultraviolet::KeyF14
KeyF15 = Ultraviolet::KeyF15
KeyF16 = Ultraviolet::KeyF16
KeyF17 = Ultraviolet::KeyF17
KeyF18 = Ultraviolet::KeyF18
KeyF19 = Ultraviolet::KeyF19
KeyF2 = Ultraviolet::KeyF2
KeyF20 = Ultraviolet::KeyF20
KeyF21 = Ultraviolet::KeyF21
KeyF22 = Ultraviolet::KeyF22
KeyF23 = Ultraviolet::KeyF23
KeyF24 = Ultraviolet::KeyF24
KeyF25 = Ultraviolet::KeyF25
KeyF26 = Ultraviolet::KeyF26
KeyF27 = Ultraviolet::KeyF27
KeyF28 = Ultraviolet::KeyF28
KeyF29 = Ultraviolet::KeyF29
KeyF3 = Ultraviolet::KeyF3
KeyF30 = Ultraviolet::KeyF30
KeyF31 = Ultraviolet::KeyF31
KeyF32 = Ultraviolet::KeyF32
KeyF33 = Ultraviolet::KeyF33
KeyF34 = Ultraviolet::KeyF34
KeyF35 = Ultraviolet::KeyF35
KeyF36 = Ultraviolet::KeyF36
KeyF37 = Ultraviolet::KeyF37
KeyF38 = Ultraviolet::KeyF38
KeyF39 = Ultraviolet::KeyF39
KeyF4 = Ultraviolet::KeyF4
KeyF40 = Ultraviolet::KeyF40
KeyF41 = Ultraviolet::KeyF41
KeyF42 = Ultraviolet::KeyF42
KeyF43 = Ultraviolet::KeyF43
KeyF44 = Ultraviolet::KeyF44
KeyF45 = Ultraviolet::KeyF45
KeyF46 = Ultraviolet::KeyF46
KeyF47 = Ultraviolet::KeyF47
KeyF48 = Ultraviolet::KeyF48
KeyF49 = Ultraviolet::KeyF49
KeyF5 = Ultraviolet::KeyF5
KeyF50 = Ultraviolet::KeyF50
KeyF51 = Ultraviolet::KeyF51
KeyF52 = Ultraviolet::KeyF52
KeyF53 = Ultraviolet::KeyF53
KeyF54 = Ultraviolet::KeyF54
KeyF55 = Ultraviolet::KeyF55
KeyF56 = Ultraviolet::KeyF56
KeyF57 = Ultraviolet::KeyF57
KeyF58 = Ultraviolet::KeyF58
KeyF59 = Ultraviolet::KeyF59
KeyF6 = Ultraviolet::KeyF6
KeyF60 = Ultraviolet::KeyF60
KeyF61 = Ultraviolet::KeyF61
KeyF62 = Ultraviolet::KeyF62
KeyF63 = Ultraviolet::KeyF63
KeyF7 = Ultraviolet::KeyF7
KeyF8 = Ultraviolet::KeyF8
KeyF9 = Ultraviolet::KeyF9
KeyFind = Ultraviolet::KeyFind
KeyHome = Ultraviolet::KeyHome
KeyInsert = Ultraviolet::KeyInsert
KeyIsoLevel3Shift = Ultraviolet::KeyIsoLevel3Shift
KeyIsoLevel5Shift = Ultraviolet::KeyIsoLevel5Shift
KeyKp0 = Ultraviolet::KeyKp0
KeyKp1 = Ultraviolet::KeyKp1
KeyKp2 = Ultraviolet::KeyKp2
KeyKp3 = Ultraviolet::KeyKp3
KeyKp4 = Ultraviolet::KeyKp4
KeyKp5 = Ultraviolet::KeyKp5
KeyKp6 = Ultraviolet::KeyKp6
KeyKp7 = Ultraviolet::KeyKp7
KeyKp8 = Ultraviolet::KeyKp8
KeyKp9 = Ultraviolet::KeyKp9
KeyKpBegin = Ultraviolet::KeyKpBegin
KeyKpComma = Ultraviolet::KeyKpComma
KeyKpDecimal = Ultraviolet::KeyKpDecimal
KeyKpDelete = Ultraviolet::KeyKpDelete
KeyKpDivide = Ultraviolet::KeyKpDivide
KeyKpDown = Ultraviolet::KeyKpDown
KeyKpEnd = Ultraviolet::KeyKpEnd
KeyKpEnter = Ultraviolet::KeyKpEnter
KeyKpEqual = Ultraviolet::KeyKpEqual
KeyKpHome = Ultraviolet::KeyKpHome
KeyKpInsert = Ultraviolet::KeyKpInsert
KeyKpLeft = Ultraviolet::KeyKpLeft
KeyKpMinus = Ultraviolet::KeyKpMinus
KeyKpMultiply = Ultraviolet::KeyKpMultiply
KeyKpPgDown = Ultraviolet::KeyKpPgDown
KeyKpPgUp = Ultraviolet::KeyKpPgUp
KeyKpPlus = Ultraviolet::KeyKpPlus
KeyKpRight = Ultraviolet::KeyKpRight
KeyKpSep = Ultraviolet::KeyKpSep
KeyKpUp = Ultraviolet::KeyKpUp
KeyLeft = Ultraviolet::KeyLeft
KeyLeftAlt = Ultraviolet::KeyLeftAlt
KeyLeftCtrl = Ultraviolet::KeyLeftCtrl
KeyLeftHyper = Ultraviolet::KeyLeftHyper
KeyLeftMeta = Ultraviolet::KeyLeftMeta
KeyLeftShift = Ultraviolet::KeyLeftShift
KeyLeftSuper = Ultraviolet::KeyLeftSuper
KeyLowerVol = Ultraviolet::KeyLowerVol
KeyMediaFastForward = Ultraviolet::KeyMediaFastForward
KeyMediaNext = Ultraviolet::KeyMediaNext
KeyMediaPause = Ultraviolet::KeyMediaPause
KeyMediaPlay = Ultraviolet::KeyMediaPlay
KeyMediaPlayPause = Ultraviolet::KeyMediaPlayPause
KeyMediaPrev = Ultraviolet::KeyMediaPrev
KeyMediaRecord = Ultraviolet::KeyMediaRecord
KeyMediaReverse = Ultraviolet::KeyMediaReverse
KeyMediaRewind = Ultraviolet::KeyMediaRewind
KeyMediaStop = Ultraviolet::KeyMediaStop
KeyMenu = Ultraviolet::KeyMenu
KeyMute = Ultraviolet::KeyMute
KeyNumLock = Ultraviolet::KeyNumLock
KeyPause = Ultraviolet::KeyPause
KeyPgDown = Ultraviolet::KeyPgDown
KeyPgUp = Ultraviolet::KeyPgUp
KeyPrintScreen = Ultraviolet::KeyPrintScreen
KeyRaiseVol = Ultraviolet::KeyRaiseVol
KeyReturn = Ultraviolet::KeyReturn
KeyRight = Ultraviolet::KeyRight
KeyRightAlt = Ultraviolet::KeyRightAlt
KeyRightCtrl = Ultraviolet::KeyRightCtrl
KeyRightHyper = Ultraviolet::KeyRightHyper
KeyRightMeta = Ultraviolet::KeyRightMeta
KeyRightShift = Ultraviolet::KeyRightShift
KeyRightSuper = Ultraviolet::KeyRightSuper
KeyScrollLock = Ultraviolet::KeyScrollLock
KeySelect = Ultraviolet::KeySelect
KeySpace = Ultraviolet::KeySpace
KeyTab = Ultraviolet::KeyTab
KeyUp = Ultraviolet::KeyUp
MAX_FPS = 120
ModAlt = Ultraviolet::ModAlt
ModCapsLock = Ultraviolet::ModCapsLock
ModCtrl = Ultraviolet::ModCtrl
ModHyper = Ultraviolet::ModHyper
ModMeta = Ultraviolet::ModMeta
ModNumLock = Ultraviolet::ModNumLock
ModScrollLock = Ultraviolet::ModScrollLock
ModShift = Ultraviolet::ModShift

KeyMod constants from mod.go These are aliases to Ultraviolet values for API compatibility

ModSuper = Ultraviolet::ModSuper
MouseBackward = Ultraviolet::MouseButton::Backward
MouseButton10 = Ultraviolet::MouseButton::Button10
MouseButton11 = Ultraviolet::MouseButton::Button11
MouseForward = Ultraviolet::MouseButton::Forward
MouseLeft = Ultraviolet::MouseButton::Left
MouseMiddle = Ultraviolet::MouseButton::Middle
MouseModeAllMotion = MouseMode::AllMotion
MouseModeCellMotion = MouseMode::CellMotion
MouseModeNone = MouseMode::None

Go parity constants for MouseMode values.

MouseNone = Ultraviolet::MouseButton::None

Mouse button constants (aliases to UV constants) Based on X11 mouse button codes: 1 = left button 2 = middle button (pressing the scroll wheel) 3 = right button 4 = turn scroll wheel up 5 = turn scroll wheel down 6 = push scroll wheel left 7 = push scroll wheel right 8 = 4th button (aka browser backward button) 9 = 5th button (aka browser forward button) 10, 11 = additional buttons

MouseRight = Ultraviolet::MouseButton::Right
MouseWheelDown = Ultraviolet::MouseButton::WheelDown
MouseWheelLeft = Ultraviolet::MouseButton::WheelLeft
MouseWheelRight = Ultraviolet::MouseButton::WheelRight
MouseWheelUp = Ultraviolet::MouseButton::WheelUp
ProgressBarDefault = ProgressBarState::Default
ProgressBarError = ProgressBarState::Error
ProgressBarIndeterminate = ProgressBarState::Indeterminate
ProgressBarNone = ProgressBarState::None

Go parity constants for ProgressBarState values.

ProgressBarWarning = ProgressBarState::Warning
VERSION = "2.0.1"

Class methods

[](value : T) : Msg forall T

Shorthand for wrap - allows Tea[value] syntax

Source
alt_screen

AlternativeScreen enables alternate screen buffer

Source
batch(commands : Enumerable(Cmd | Nil)) : Cmd | Nil
Source
batch

Batch performs a bunch of commands concurrently with no ordering guarantees

Source
batch(*commands : Cmd | Nil) : Cmd | Nil
Source
clear_screen

ClearScreen clears the screen before the next update. This can be used to move the cursor to the top left of the screen and clear visual clutter when the alt screen is not in use.

Source
default_fps

FPS constants for reference

Source
disable_mouse

DisableMouse disables mouse tracking

Source
enable_mouse

EnableMouse enables mouse tracking

Source
every(duration : Time::Span, &fn : Time -> Msg | Nil) : Cmd

Every ticks in sync with the system clock

Source
exec(cmd : ExecCommand, callback : ExecCallback | Nil = nil) : Cmd

Exec runs an ExecCommand in a blocking fashion, pausing the Program while execution is running and resuming when complete

Source
exec_process(command : String, args : Array(String) = [] of String, callback : ExecCallback | Nil = nil) : Cmd

ExecProcess runs the given executable in a blocking fashion. This mirrors Go's exec.Command + tea.ExecProcess behavior: the command is configured first, then started during program exec with stdio attached.

Source
exec_shell(command : String, callback : ExecCallback | Nil = nil) : Cmd

Convenience method to exec a shell command

Source
exit_alt_screen

ExitAltScreen disables alternate screen buffer

Source
hide_cursor

HideCursor hides the cursor

Source
interrupt

Interrupt returns a command that interrupts the program

Source
key(rune : Char, modifiers : KeyMod = 0) : Key

Helper to create a Key from a rune

Source
key(code : Int32, modifiers : KeyMod = 0) : Key

Helper to create a Key from a special key type

Source
log_to_file(path : String, prefix : String) : File

LogToFile sets up logging to a file with the given path and prefix. This is helpful since the TUI occupies the terminal. If the file doesn't exist, it will be created.

Don't forget to close the file when you're done:

file = Tea.log_to_file("debug.log", "debug")

... use program ...

file.close

Returns the file handle or raises on error.

Source
log_to_file_with(path : String, prefix : String, logger : LogOptionsSetter) : File

LogToFileWith does allows to call LogToFile with a custom LogOptionsSetter.

Source
log_to_file_with(path : String, prefix : String, &block : File -> Nil) : File

Block-based helper for local custom setup.

Source
max_fps
Source
mouse_click(x : Int32, y : Int32, button : MouseButton = Ultraviolet::MouseButton::Left) : MouseClickMsg

Helper to create a mouse message

Source
mouse_motion(x : Int32, y : Int32) : MouseMotionMsg
Source
mouse_release(x : Int32, y : Int32, button : MouseButton = Ultraviolet::MouseButton::Left) : MouseReleaseMsg
Source
mouse_wheel(x : Int32, y : Int32, direction : MouseButton) : MouseWheelMsg
Source
new_cursed_renderer(w : IO, env : Ultraviolet::Environ, width : Int32, height : Int32) : CursedRenderer

Factory method to create a new cursed renderer

Source
new_cursor(x : Int32 = 0, y : Int32 = 0, visible : Bool = true, style : CursorStyle = CursorStyle::Block, color : Colorful::Color | Nil = nil) : Cursor

Go parity helper for NewCursor().

Source
new_program(model : Model, *options : ProgramOption) : Program

Create a new program with the given model and options

Source
new_progress_bar(state : ProgressBarState = ProgressBarState::None, value : Float64 = 0.0, max : Float64 = 100.0, label : String = "") : ProgressBar

Go parity helper for NewProgressBar().

Source
new_view(content : String = "") : View

Go parity helper for NewView().

Source
printf(template : String, *args) : Cmd

Printf prints above the Program with format string

Source
println(*args) : Cmd

Println prints above the Program Output persists across renders

Source
quit

Quit returns a command that signals the program to quit

Source
raw(msg : String) : Cmd

Raw prints the given string to the terminal without any formatting. This is intended for advanced use cases where you need to query the terminal or send escape sequences directly.

Source
read_clipboard

ReadClipboard produces a command that reads the system clipboard using OSC52

Source
read_primary_clipboard

ReadPrimaryClipboard produces a command that reads the primary clipboard (X11/Wayland)

Source
request_background_color
Source
request_capability(capability : String) : Cmd

RequestCapability is a command that requests the terminal to send its Termcap/Terminfo response for the given capability.

Bubble Tea recognizes the following capabilities:

  • "RGB" Xterm direct color
  • "Tc" True color support
Source
request_cursor_color
Source
request_foreground_color
Source
request_terminal_version

RequestTerminalVersion is a command that queries the terminal for its version using XTVERSION. Note that some terminals may not support this.

Source
request_window_size

RequestWindowSize is a message that requests terminal size check. Go parity: RequestWindowSize() Msg.

Source
sequence(commands : Enumerable(Cmd | Nil)) : Cmd | Nil
Source
sequence

Sequence runs the given commands one at a time, in order

Source
sequence(*commands : Cmd | Nil) : Cmd | Nil
Source
sequentially(commands : Enumerable(Cmd | Nil))
Source
sequentially(*commands : Cmd | Nil)

Sequentially runs commands in order, returns first non-nil result Deprecated: use sequence instead

Source
set_clipboard(content : String) : Cmd

SetClipboard produces a command that sets the system clipboard using OSC52 Note: OSC52 is not supported in all terminals ameba:disable Naming/AccessorMethodName

Source
set_primary_clipboard(content : String) : Cmd

SetPrimaryClipboard produces a command that sets the primary clipboard (X11/Wayland) ameba:disable Naming/AccessorMethodName

Source
set_window_title(title : String) : Cmd

SetWindowTitle produces a command that sets the terminal title ameba:disable Naming/AccessorMethodName

Source
show_cursor

ShowCursor shows the cursor

Source
suspend

Suspend returns a command that suspends the program

Source
tick(duration : Time::Span, &fn : Time -> Msg | Nil) : Cmd

Tick produces a command at a fixed interval

Source
window_size

WindowSize produces a command that queries the terminal size

Source
with_alt_screen
Source
with_bracketed_paste
Source
with_color_profile(profile : Ultraviolet::ColorProfile) : ProgramOption
Source
with_context(ctx : ExecutionContext) : ProgramOption
Source
with_environment(env : Ultraviolet::Environ) : ProgramOption
Source
with_filter
Source
with_fps(fps : Int32) : ProgramOption
Source
with_input(input : IO | Nil) : ProgramOption
Source
with_mouse_all_motion
Source
with_mouse_cell_motion
Source
with_output(output : IO) : ProgramOption
Source
with_report_focus
Source
with_window_size(width : Int32, height : Int32) : ProgramOption
Source
without_catch_panics
Source
without_input
Source
without_renderer
Source
without_signal_handler
Source
without_signals
Source
wrap(value : T) : Msg forall T

Wrap any value as a Msg. If the value is already a Msg, return it directly. Otherwise, wrap it in Value.

Source

Nested types