tui library TUI
Interactive TUI framework (Bubble Tea for Dart).
This library provides a framework for building interactive terminal applications using the Elm Architecture (Model-Update-View).
Core Components
- Model: Represents the state of your application.
Update: A function that handles messages and returns a new model and commands.- View: A function that renders the current model into a string.
- Program: The runtime that manages the event loop and rendering.
Bubbles: Reusable interactive widgets like text inputs, spinners, and lists.
Quick Start
import 'package:artisanal/tui.dart';
class CounterModel implements Model {
final int count;
CounterModel([this.count = 0]);
@override
Cmd? init() => null;
@override
(Model, Cmd?) update(Msg msg) {
return switch (msg) {
KeyMsg(key: Key(type: KeyType.up)) =>
(CounterModel(count + 1), null),
KeyMsg(key: Key(type: KeyType.down)) =>
(CounterModel(count - 1), null),
KeyMsg(key: Key(type: KeyType.runes, runes: [0x71])) =>
(this, Cmd.quit()),
_ => (this, null),
};
}
@override
String view() => 'Count: \$count\n\nUse ↑/↓ to change, q to quit';
}
void main() async {
await runProgram(CounterModel());
}
The Elm Architecture
The TUI runtime follows The Elm Architecture (TEA) pattern, which separates state, logic, and presentation:
- Model: The state of your application. It should be immutable.
- Update: A pure function that takes a Msg and the current Model, and returns a new Model and an optional Cmd.
- View: A pure function that takes the Model and returns a String (or a View object for advanced metadata) representing the UI.
┌─────────────────────────────────────────────────────┐
│ Program │
│ │
│ ┌───────┐ ┌────────┐ ┌──────┐ │
│ │ Model │────▶│ update │────▶│ view │ │
│ └───────┘ └────────┘ └──────┘ │
│ ▲ │ │ │
│ │ │ ▼ │
│ │ ┌────────┐ ┌────────┐ │
│ └─────────│ Cmd │ │ Screen │ │
│ └────────┘ └────────┘ │
│ │ │
│ ▼ │
│ ┌────────┐ │
│ │ Msg │◀──── User Input │
│ └────────┘ │
└─────────────────────────────────────────────────────┘
Commands and Messages
- Msg: Represents an event (key press, timer tick, network response).
- Cmd: Represents an effect to be performed by the runtime (quitting, sending a message, running an external process).
Use BatchMsg to group multiple messages, and BatchCmd to group multiple
commands.
Program Lifecycle
- Initialization: The Program starts, calls
Model.init(), and executes the returned Cmd. - Event Loop: The program waits for input (stdin, signals, or commands).
- Update: When a Msg arrives,
Model.update(msg)is called. - Render: If the model changed,
Model.view()is called and the result is rendered to the terminal. - Termination: The program exits when a QuitMsg is received or
Cmd.quit()is executed.
Rendering and Performance
Artisanal supports multiple rendering strategies:
- Standard: Simple ANSI output for basic terminals.
- Ultraviolet: High-performance diff-based rendering with cell buffers.
- ANSI Compression: Minimizes output by removing redundant SGR sequences.
Configure these via ProgramOptions.
The TUI runtime follows The Elm Architecture (TEA) pattern, which separates state, logic, and presentation:
- Model: The state of your application. It should be immutable.
- Update: A pure function that takes a Msg and the current Model, and returns a new Model and an optional Cmd.
- View: A pure function that takes the Model and returns a String (or a View object for advanced metadata) representing the UI.
┌─────────────────────────────────────────────────────┐
│ Program │
│ │
│ ┌───────┐ ┌────────┐ ┌──────┐ │
│ │ Model │────▶│ update │────▶│ view │ │
│ └───────┘ └────────┘ └──────┘ │
│ ▲ │ │ │
│ │ │ ▼ │
│ │ ┌────────┐ ┌────────┐ │
│ └─────────│ Cmd │ │ Screen │ │
│ └────────┘ └────────┘ │
│ │ │
│ ▼ │
│ ┌────────┐ │
│ │ Msg │◀──── User Input │
│ └────────┘ │
└─────────────────────────────────────────────────────┘
- Msg: Represents an event (key press, timer tick, network response).
- Cmd: Represents an effect to be performed by the runtime (quitting, sending a message, running an external process).
Use BatchMsg to group multiple messages, and BatchCmd to group multiple
commands.
- Initialization: The Program starts, calls
Model.init(), and executes the returned Cmd. - Event Loop: The program waits for input (stdin, signals, or commands).
- Update: When a Msg arrives,
Model.update(msg)is called. - Render: If the model changed,
Model.view()is called and the result is rendered to the terminal. - Termination: The program exits when a QuitMsg is received or
Cmd.quit()is executed.
Artisanal supports multiple rendering strategies:
- Standard: Simple ANSI output for basic terminals.
- Ultraviolet: High-performance diff-based rendering with cell buffers.
- ANSI Compression: Minimizes output by removing redundant SGR sequences.
Configure these via ProgramOptions.
Classes
- Alert
- A fluent builder for creating styled alerts.
- AlertComponent
- An alert/notice block component.
- AnticipateConfig
- Configuration for anticipate/autocomplete component.
- AnticipateKeyMap
- Key map for anticipate navigation and selection.
- AnticipateModel
- Anticipate model for autocomplete input.
- BackgroundColorMsg
- Message containing the terminal's background color.
- BatchMsg
- Message containing multiple messages to be processed sequentially.
- Box
- A boxed message component.
- BoxBuilder
- A fluent builder for creating styled boxes.
- BufferedTuiRenderer
- A renderer that buffers output for efficient writes.
- BulletList
- A bullet list component.
- CapabilityMsg
- Message sent when a terminal capability is reported.
- ClearScreenMsg
- Internal message to clear the screen.
- ClipboardMsg
- Clipboard content message.
- Cmd TUI
- A command that produces a message asynchronously.
- ColorProfileMsg
- Message sent when the terminal color profile is detected or changed.
- Column
- Table column definition.
- ColumnComponent
- A component that renders with a newline after each child.
- ColumnsComponent
- A multi-column layout component.
- Comment
- A fluent builder for creating styled comments.
- CommentComponent
- A comment component (dimmed text with // prefix).
- CommonKeyBindings
- Commonly used key bindings for navigation.
- ComponentBoxChars
- Box drawing characters for component system.
- CompositeComponent
- A component that composes multiple child components.
- CompositeModel
- A model that wraps another model, useful for composition.
- ConditionalStep
- Conditional wizard step.
- ConfirmCancelledMsg
- Message sent when confirmation is cancelled.
- ConfirmKeyMap
- Key bindings for the confirm component.
- ConfirmModel
- A confirmation (yes/no) component following the Model architecture.
- ConfirmResultMsg
- Message sent when confirmation is made.
- ConfirmStep
- Confirmation wizard step.
- ConfirmStyles
- Styles for the confirm component.
- CountdownModel
- A countdown model built on top of TimerModel.
- CursorBlinkMsg
- Message indicating the cursor should toggle its blink state.
- CursorColorMsg
- Message containing the terminal's cursor color.
- CursorModel
- A blinking cursor widget for text input components.
-
CustomMsg<
T> - Message wrapper for custom user-defined messages.
- DebugOverlayModel
- Draggable render-metrics overlay for debugging TUI performance.
- DefaultItemDelegate
- Default item delegate with simple rendering.
- DefinitionList
- A fluent builder for creating styled definition lists.
- DefinitionListComponent
- A definition list component (term: description pairs).
- DestructiveConfirmModel
- A destructive confirmation component that requires typing to confirm.
- DisableBracketedPasteMsg
- Internal message to disable bracketed paste.
- DisableMouseMsg
- Internal message to disable mouse tracking.
- DisableReportFocusMsg
- Internal message to disable focus reporting.
- DisplayComponent
- Base type for display-only UI building blocks.
- EnableBracketedPasteMsg
- Internal message to enable bracketed paste.
- EnableMouseAllMotionMsg
- Internal message to enable mouse all motion tracking.
- EnableMouseCellMotionMsg
- Internal message to enable mouse cell motion tracking.
- EnableReportFocusMsg
- Internal message to enable focus reporting.
- EnterAltScreenMsg
- Internal message to enter alt screen.
- EveryCmd
- A repeating command that fires at regular intervals.
- ExceptionComponent
- An exception renderer component.
- ExecProcessMsg
- Message signaling that an external process should be executed.
- ExecResult
- Result of executing an external process.
- ExitAltScreenMsg
- Internal message to exit alt screen.
- FileEntry
- A file entry with cached stat information.
- FilePickerErrorMsg
- Error message when reading a directory fails.
- FilePickerKeyMap
- Key mappings for the file picker component.
- FilePickerModel
- A file picker model for navigating and selecting files.
- FilePickerReadDirMsg
- Message sent when directory contents are read.
- FilePickerStyles
- Styles for the file picker component.
- FilteredItem
- Filtered item with match information.
-
FilteredSearchItem<
T> - A filtered item with its original index and match positions.
- FilterMatchesMsg
- Filter matches message.
- FocusMsg
- Message sent when focus is gained or lost.
- ForegroundColorMsg
- Message containing the terminal's foreground color.
- FrameTickMsg
- Message sent automatically by the TUI runtime every frame.
- FullScreenTuiRenderer
- Full-screen renderer using the alternate screen buffer.
- GroupedDefinitionList
- A fluent builder for creating grouped definition lists.
- GroupStep
- Group of wizard steps.
- GutterContext
- GutterContext provides context to a GutterFunc.
- Help
- Help information for a key binding.
- HelpModel
- A help view widget for displaying key bindings.
- HelpStyles
- Styles for the help view.
- HideCursorMsg
- Internal message to hide cursor.
- HighlightInfo
- HorizontalTableComponent
- A horizontal table component (row-as-headers style).
- InlineTuiRenderer
- Inline renderer that renders below the current cursor position.
- InterruptMsg
- Message sent when an interrupt signal (SIGINT/Ctrl+C) is received.
- ItemDelegate
- Item delegate for rendering list items.
- Key
- Represents a parsed keyboard input event.
- KeyBinding
- A key binding that maps keys to actions with optional help text.
- KeyboardEnhancements
- KeyboardEnhancements describes the requested keyboard enhancement features.
- KeyboardEnhancementsMsg
- Message sent when keyboard enhancements are reported.
- KeyMap
- A collection of key bindings forming a key map.
- KeyMsg
- Message sent when a key is pressed.
- KeyParser
- Parses raw terminal input bytes into Key objects and Msg objects.
- Keys
- Key constants and utilities for keyboard input handling.
- KeyValue
- A key-value pair component with dot fill.
- LineInfo
- LinkComponent
- A clickable hyperlink component (OSC 8).
- LinkGroupComponent
- A group of related links component.
- ListEnumerator
- Defines how list items are explicitly enumerated.
- ListItem
- Item interface for list items.
- ListKeyMap
- Key map for list navigation.
- ListModel
- List model for interactive lists.
- ListStyles
- Styles for list rendering.
- Model TUI
- Abstract interface for TUI application models.
- MouseMsg
- Message sent for mouse events.
- Msg TUI
- Base class for all messages in the TUI runtime.
- MultiProgressModel
- A model for managing multiple progress bars simultaneously.
-
MultiSelectionMadeMsg<
T> - Message sent when multiple items are selected.
- MultiSelectKeyMap
- Key bindings for the multi-select component.
-
MultiSelectModel<
T> - A multi-select component following the Model architecture.
- MultiSelectStep
- Multi-select wizard step.
- MultiSelectStyles
- Styles for the multi-select component.
- NullTuiRenderer
- A renderer that does nothing (for testing).
- NumberedList
- A numbered list component.
- PaginatorKeyMap
- Key bindings for paginator navigation.
- PaginatorModel
- A paginator widget for handling pagination state and rendering.
- Panel
- A fluent builder for creating styled panels.
- PanelBoxChars
- Box drawing characters for panels and borders.
- PanelBoxCharSet
- A set of box drawing characters.
- PanelComponent
- A boxed panel component with optional title.
- PasswordCancelledMsg
- Message sent when password input is cancelled.
- PasswordConfirmModel
- A password confirmation component that asks for password twice.
- PasswordKeyMap
- Key bindings for the password component.
- PasswordModel
- A password input component following the Model architecture.
- PasswordStep
- Password input wizard step.
- PasswordStyles
- Styles for the password component.
- PasswordSubmittedMsg
- Message sent when password input is submitted.
- PasteErrorMsg
- Message for paste errors.
- PasteMsg
- Message sent when bracketed paste content is received.
- PauseModel
- A simple "press any key" pause model.
- Point
- 3D point helper.
- PrintLineMsg
- Message for printing a line above the program output.
-
Program<
M extends Model> TUI - The TUI program runtime.
- ProgramOptions
- Options for configuring the TUI program.
- ProgressBar
- A progress indicator component.
- ProgressBarAdvanceMsg
- ProgressBarComponent TUI
- A progress bar component.
- ProgressBarIterateDoneMsg
- ProgressBarIterateErrorMsg
- ProgressBarModel
- A UV-safe progress bar model that can be hosted inside a parent Model.
- ProgressBarMsg
- ProgressBarSetMsg
- ProgressFrameMsg
- Message indicating a progress bar animation frame should advance.
- ProgressModel
- A progress bar widget with optional animation support.
- Projectile
- A simple projectile integrator mirroring harmonica/projectile.go.
- QuitMsg
- Internal message signaling that the program should quit.
- Rank
- Rank from filtering.
- RenderConfig TUI
- Rendering configuration for display-only UI building blocks.
- RenderMetricsMsg
- Message sent periodically with renderer performance metrics.
- RepaintMsg
- Message sent to force a repaint of the view.
- RepaintRequestMsg
- Internal message to request a repaint.
- RequestWindowSizeMsg
- Internal message to request window size.
- ResumeMsg
- Message sent when the program resumes from suspension.
- RowComponent
- A component that renders children horizontally with a separator.
- Rule
- A horizontal rule/separator component.
- ScrollbarChars
- SearchCancelledMsg
- Message sent when search is cancelled.
- SearchKeyMap
- Key bindings for the search component.
-
SearchModel<
T> - A search/filter component following the Model architecture.
-
SearchSelectionMadeMsg<
T> - Message sent when a search result is selected.
- SearchStyles
- Styles for the search component.
- SelectionCancelledMsg
- Message sent when selection is cancelled.
-
SelectionMadeMsg<
T> - Message sent when an item is selected.
- SelectKeyMap
- Key bindings for the select component.
-
SelectModel<
T> - A single-select component following the Model architecture.
- SelectStep
- Single-select wizard step.
- SelectStyles
- Styles for the select component.
- SetWindowTitleMsg
- Internal message to set window title.
- ShowCursorMsg
- Internal message to show cursor.
- SimpleExceptionComponent
- A simple one-line exception component.
- SimpleTuiRenderer
- TuiRenderer that writes output without diffing or clearing (nil renderer mode).
- Spinner
- A spinner animation definition.
- SpinnerFrame
- A spinner frame component (for use in animations).
- SpinnerModel
- A spinner widget for showing loading/activity states.
- Spinners
- Pre-defined spinner animations.
- SpinnerTickMsg
- Message indicating a spinner should advance to the next frame.
- Spring
- A stable damped spring integrator (Ryan Juckett formulation) matching charmbracelet/harmonica.
- StaticComponent
- A ViewComponent that only has a view and no state/updates.
- StatusMessageTimeoutMsg
- Status message timeout message.
- StdioTerminal
- Standard terminal implementation using dart:io.
- StopwatchModel
- A stopwatch model that counts up from zero.
- StopwatchResetMsg
- Message sent to reset the stopwatch.
- StopwatchStartStopMsg
- Message sent to start or stop the stopwatch.
- StopwatchTickMsg
- Message sent when the stopwatch ticks.
-
StreamCmd<
T> - A command that manages a stream subscription.
- StringItem
- Simple string item implementation.
- StringSinkTuiRenderer
- A renderer that writes to a StringSink (for testing).
- StyledBlock
- A fluent builder for creating styled blocks (Symfony-style).
- StyledBlockComponent
- A styled block component (Symfony-style).
- StyledText
- A styled text component using the context's style.
- SuspendMsg
- Message signaling the program should suspend (like Ctrl+Z).
- Table
- A fluent builder for creating styled tables.
- TableComponent
- A table component with headers and rows.
- TableKeyMap
- Key map for table navigation.
- TableModel
- Table model for interactive tables.
- TableStyles
- Styles for table rendering.
- TaskComponent
- A task status component (Laravel-style).
- TerminalProgressBar
- TerminalProgressBar represents the terminal taskbar progress (OSC 9;4).
- TerminalState
- Terminal state snapshot for saving/restoring.
- TerminalThemeState
- Tracks terminal theme information (background + dark/light heuristic).
- TerminalVersionMsg
- Message sent when the terminal version is reported.
- Text
- A simple text component.
- TextAreaCursorStyle
- TextAreaKeyMap
- TextAreaModel
- TextAreaPasteErrorMsg
- TextAreaPasteMsg
- TextAreaStyles
- TextAreaStyleState
- TextInputCursorStyle
- Style for the cursor.
- TextInputKeyMap
- Key map for text input navigation and editing.
- TextInputModel
- Text input model for single-line text entry.
- TextInputStep
- Text input wizard step.
- TextInputStyles
- Styles for the text input.
- TextInputStyleState
- Style state for focused and blurred states.
- TextModel
- A high-level text component that supports selection, scrolling, and wrapping. It is built on top of ViewportModel but defaults to auto-height and soft-wrap.
- TickMsg
- Message sent when a timer tick occurs.
- TimerModel
- A countdown timer model.
- TimerStartStopMsg
- Message sent to start or stop the timer.
- TimerTickMsg
- Message sent when the timer ticks.
- TimerTimeoutMsg
- Internal message sent when timer times out.
- TitledBlockComponent
- A simple titled block used by the artisanal-style I/O facade.
- Tree
- A fluent builder for creating styled trees (lipgloss v2 parity).
- TreeChildren
- TreeComponent
- A tree structure component.
- TreeEnumerator
- Defines the characters used to draw tree branches.
- TreeFilter
- TreeNode
- TreeNodeChildren
- TreeStringData
- TuiRenderer TUI
- Abstract renderer interface for TUI output.
- TuiRendererOptions
- Options for configuring the renderer.
- TwoColumnDetail
- A fluent builder for creating two-column detail rows.
- TwoColumnDetailComponent
- A two-column detail component with dot fill.
- TwoColumnDetailList
- A fluent builder for creating multiple two-column detail rows.
- UltravioletTuiRenderer
- Ultraviolet-inspired renderer backed by a cell buffer + diffing updates.
- UvEventMsg
- Raw Ultraviolet event message (only emitted when UV input decoding is enabled).
- Vector
- 3D vector helper.
- View TUI
- View represents a terminal view that can contain metadata for terminal control.
- ViewComponent
- A lightweight, composable TUI component.
- ViewportKeyMap
- Key bindings for viewport navigation.
- ViewportModel
- A viewport widget for scrollable content.
- ViewportScrollPane
- WindowSizeMsg
- Message sent when the terminal window is resized.
- WizardCancelledMsg
- Message sent when the wizard is cancelled.
- WizardCompletedMsg
- Message sent when the entire wizard is completed.
- WizardModel
- Wizard model for multi-step forms.
- WizardStep
- Base class for wizard steps.
- WizardStepCompletedMsg
- Message sent when a wizard step is completed.
Enums
- AlertDisplayStyle
- Alert display style.
- AlertType
- Alert types.
- BlockStyleType
- Block style types.
- BorderStyle
- Border styles for boxes.
- BoxAlign
- Alignment for box content.
- ClipboardSelection
- Clipboard selection for OSC 52 operations.
- ConfirmDisplayMode
- Display mode for the confirm component.
- CursorMode
- Cursor display mode.
- EchoMode
- Echo mode for text input display.
- FilterState
- Filter state for the list.
- KeyType
- Types of keyboard input events.
- MouseAction
- Mouse event action types.
- MouseButton
- Mouse button identifiers.
- MouseMode
- Mouse tracking modes.
- PaginationType
- Pagination rendering type.
- PanelAlignment
- Alignment for panel content.
- PasswordEchoMode
- Echo mode for password display.
- StyledBlockDisplayStyle
- Display style for styled blocks.
- TaskStatus
- Task status values.
- TerminalProgressBarState
- TerminalProgressBarState represents the state of the terminal taskbar progress.
Mixins
- ComponentHost
- A mixin for Models that host one or more ViewComponents.
- CopyWithModel
- Mixin that documents the copyWith pattern for models.
- TerminalThemeHost
- Mixin for models/components that want terminal theme state with minimal boilerplate.
Extensions
- AlertFactory on Alert
- Factory methods for common alert styles.
- BoxPresets on BoxBuilder
- Factory methods for common box styles.
- CmdExtension on Cmd?
- Extension methods for nullable Cmd.
- DefinitionListFactory on DefinitionList
- Factory methods for common definition list styles.
- KeyMatchExtension on Key
- Extension to check key matches more fluently.
- KeyMsgMatchExtension on KeyMsg
- Extension to check KeyMsg matches.
- PanelPresets on Panel
- Factory methods for common panel styles.
- StyledBlockFactory on StyledBlock
- Factory methods for common styled block styles.
- TableFactory on Table
- Factory methods for common table styles.
- TreeFactory on Tree
- Factory methods for common tree styles.
- TuiTerminalRendererExtension on TuiTerminal
- Extension to create renderers from terminals.
- TwoColumnDetailFactory on TwoColumnDetail
- Factory methods for common two-column detail styles.
Constants
- defaultEmptyCharBlock → const String
- Default character used to fill the empty portion of the progress bar.
- defaultFullCharFullBlock → const String
- Default character used to fill the progress bar (full block).
- defaultFullCharHalfBlock → const String
- Default character used to fill the progress bar. It is a half block, which allows more granular color blending control.
- gravity → const Vector
- Gravity helpers (match harmonica names).
- promptProgramOptions → const ProgramOptions
- Shared defaults for "artisanal-style" prompts that run a single bubble and return a value.
- terminalGravity → const Vector
- textareaPromptOptions → const ProgramOptions
- Dedicated defaults for full-screen text editing prompts.
- undefined → const Object
Functions
-
compressAnsi(
String input) → String - Removes redundant SGR sequences to reduce output size.
-
defaultFilter(
String term, List< String> targets) → List<Rank> - Default fuzzy filter implementation.
-
defaultSearchFilter<
T> (String query, List< T> items, String toString(T)) → List<FilteredSearchItem< T> > - Default fuzzy filter implementation.
-
defaultTextAreaStyles(
) → TextAreaStyles -
defaultTextInputStyles(
{bool isDark = true}) → TextInputStyles - Returns the default styles for the text input.
-
every(
Duration interval, Msg? callback(DateTime time), {Object? id}) → Cmd - Helper to create a repeating timer command.
-
fpsDelta(
int n) → double - Returns the time delta for a given frames-per-second value.
-
keyMatches(
Key key, List< KeyBinding> bindings) → bool - Checks if a key message matches any of the given bindings.
-
keyMatchesSingle(
Key key, KeyBinding binding) → bool - Checks if a key matches a single binding.
-
mathMax(
int a, int b) → int -
newSpringFromFps(
int fps, double frequency, double damping) → Spring - Convenience to create a spring using FPS like the Go API.
-
noCmd(
Model model) → UpdateResult - Helper function to create an update result with no command.
-
progressIterateCmd<
T> ({required int id, required Iterable< T> items, required Future<void> onItem(T item)}) → StreamCmd<Msg> -
Produces a UV-safe StreamCmd that runs
onItemfor each element and emits progress updates for a hosted ProgressBarModel. -
quit(
Model model) → UpdateResult - Helper function to create an update result that quits.
-
renderMarkdown(
String markdown, {int width = 80}) → String -
Render Markdown to ANSI-styled text, wrapped to
width. -
runAnticipatePrompt(
AnticipateModel model, Terminal terminal, {ProgramOptions? options}) → Future< String?> -
Runs an AnticipateModel and resolves to the accepted value, or
nullif cancelled. -
runConfirmPrompt(
ConfirmModel model, Terminal terminal, {ProgramOptions? options}) → Future< bool?> -
Runs a ConfirmModel and resolves to the selected value, or
nullif cancelled. -
runMultiSelectPrompt<
T> (MultiSelectModel< T> model, Terminal terminal, {ProgramOptions? options}) → Future<List< T> ?> -
Runs a MultiSelectModel and resolves to the selected items, or
nullif cancelled. -
runPasswordConfirmPrompt(
PasswordConfirmModel model, Terminal terminal, {ProgramOptions? options}) → Future< String?> -
Runs a PasswordConfirmModel and resolves to the submitted password, or
nullif cancelled. -
runPasswordPrompt(
PasswordModel model, Terminal terminal, {ProgramOptions? options}) → Future< String?> -
Runs a PasswordModel and resolves to the submitted password, or
nullif cancelled. -
runProgram<
M extends Model> (M model, {ProgramOptions options = const ProgramOptions()}) → Future< void> - Runs a TUI program with the given model.
-
runProgramDebug<
M extends Model> (M model, {ProgramOptions? options}) → Future< void> - Runs a TUI program without panic catching (for debugging).
-
runProgramWithResult<
M extends Model> (M model, {ProgramOptions options = const ProgramOptions()}) → Future< M> - Runs a TUI program and returns the final model after exit.
-
runSearchPrompt<
T> (SearchModel< T> model, Terminal terminal, {ProgramOptions? options}) → Future<T?> -
Runs a SearchModel and resolves to the selected item, or
nullif cancelled. -
runSelectPrompt<
T> (SelectModel< T> model, Terminal terminal, {ProgramOptions? options}) → Future<T?> -
Runs a SelectModel and resolves to the selected item, or
nullif cancelled. -
runSpinnerTask<
T> ({required String message, required Future< T> task(), Spinner spinner = Spinners.miniDot, required Terminal terminal, ProgramOptions? options}) → Future<T> -
Runs an animated spinner while executing
task, returning its result. -
runTextAreaPrompt(
TextAreaModel model, Terminal terminal, {ProgramOptions? options}) → Future< String?> -
Runs a TextAreaModel and resolves to the submitted value, or
nullif cancelled. -
runTextInputPrompt(
TextInputModel model, Terminal terminal, {ProgramOptions? options}) → Future< String?> -
Runs a TextInputModel and resolves to the submitted value, or
nullif cancelled. -
runWizardPrompt(
WizardModel model, Terminal terminal, {ProgramOptions? options}) → Future< Map< String, dynamic> ?> -
Runs a WizardModel and resolves to the final answers, or
nullif cancelled.
Typedefs
- AlertStyleFunc = Style? Function(String line, int lineIndex)
- Callback for alert message styling.
- BoxContentStyleFunc = Style? Function(String line, int lineIndex)
- Callback for box content styling.
- CmdFunc = Cmd Function()
- Type alias for a function that creates commands.
-
CmdFunc1<
T> = Cmd Function(T value) - Type alias for a function that creates commands from a value.
- ColorFunc = Color Function(double total, double current)
-
Function that can be used to dynamically fill the progress bar.
totalis the total filled percentage, andcurrentis the current percentage that is actively being filled with a color. - DefinitionStyleFunc = Style? Function(String term, String description, int index, bool isTerm)
- Callback for styling definition list items.
-
FilterFunc
= List<
Rank> Function(String term, List<String> targets) - Filter function type.
- GutterFunc = String Function(GutterContext context)
- GutterFunc can be implemented and set into ViewportModel.leftGutterFunc.
- ListStyleFunc = Style? Function(int index, String item)
- Callback for per-item styling in lists.
- MessageFilter = Msg? Function(Model model, Msg msg)
- A function that filters messages before they reach the model.
- PanelContentStyleFunc = Style? Function(String line, int lineIndex)
- Callback for panel content styling.
- PromptFunc = String Function(PromptInfo info)
- PromptInfo = ({int col, bool isFocused, int lineIndex, int row})
-
Row
= List<
String> - Table row (list of cell values).
-
SearchFilterFunc<
T> = List< FilteredSearchItem< Function(String query, List<T> >T> items, String toString(T)) - Filter function type for search.
- StyledBlockStyleFunc = Style? Function(String line, int lineIndex)
- Callback for block content styling.
- TableStyleFunc = Style? Function(int row, int col, String data)
- Callback for per-cell styling in tables.
-
TreeEnumeratorFunc
= String Function(List<
TreeNode> children, int index) - TreeEnumeratorStyleFunc = Style? Function(List children, int index)
- Callback for per-item enumerator (branch character) styling in trees.
-
TreeIndenterFunc
= String Function(List<
TreeNode> children, int index) -
TreeNodeStyleFunc
= Style Function(List<
TreeNode> children, int index) - TreeStyleFunc = Style? Function(String item, int depth, bool isDirectory)
- Callback for per-item styling in trees.
- TuiTerminal = Terminal
- Alias for backward compatibility.
- TwoColumnStyleFunc = Style? Function(String text, bool isLeft)
- Callback for styling the left or right column.
- UpdateResult = (Model, Cmd?)
- Type alias for the update function return type.
Exceptions / Errors
- ProgramCancelledError
- Error thrown when a program is cancelled via an external signal.