agnostic/platform/opentui

The OpenTUI platform for Lustre. This module provides a platform configuration that targets @opentui/core for building terminal user interfaces with Lustre’s MVU architecture.

Types

Configuration for creating an OpenTUI renderer.

pub opaque type Config

A factory function that receives the renderer and returns a renderable node. Used with register_element to define custom element types.

pub type ElementFactory =
  fn(Renderer) -> Node

A type representing a TUI event.

pub type Event

A type representing a TUI renderable node from @opentui/core.

pub type Node

A type representing an OpenTUI CLI renderer.

pub type Renderer

A type representing a TUI property value.

pub type Value

Values

pub const after_flush_phase: String

The phase name tagged by opentui/effect.after_flush and declared by the OpenTUI platform. Public so custom platforms can declare a Phase with this exact name to run after_flush effects.

pub const after_layout_phase: String

The phase name tagged by opentui/effect.after_layout and declared by the OpenTUI platform. Public so custom platforms can declare a Phase with this exact name to run after_layout effects.

pub fn auto_focus(config: Config, value: Bool) -> Config

Set whether to auto-focus the first focusable element.

pub fn background_color(config: Config, value: String) -> Config

Set the background color.

pub fn debounce_delay(config: Config, value: Int) -> Config

Set the debounce delay in milliseconds.

pub fn default_config() -> Config

Create a default configuration for the OpenTUI renderer.

pub fn enable_mouse_movement(
  config: Config,
  value: Bool,
) -> Config

Set whether to enable mouse movement events.

pub fn exit_on_ctrl_c(config: Config, value: Bool) -> Config

Set whether Ctrl+C exits the application.

pub const frame_callbacks_phase: String

The phase name tagged by opentui/effect.frame_callbacks and declared by the OpenTUI platform. Public so custom platforms can declare a Phase with this exact name to run frame_callbacks effects.

pub fn gather_stats(config: Config, value: Bool) -> Config

Set whether to gather performance stats.

pub fn max_fps(config: Config, value: Int) -> Config

Set the maximum frames per second. This paces on-demand frames — the one-shot renders triggered by state changes — capping how fast bursts of updates repaint.

pub fn max_stat_samples(config: Config, value: Int) -> Config

Set the maximum number of stat samples to keep.

pub fn open_console_on_error(
  config: Config,
  value: Bool,
) -> Config

Set whether to open console on error.

pub fn register_element(
  config: Config,
  tag: String,
  factory: fn(Renderer) -> Node,
) -> Config

Register a custom element factory for a tag name. Once registered, using element.element(tag, attrs, children) with this tag will create a node via the factory instead of falling back to a box container.

Built-in tags (box, text, input, etc.) cannot be overridden — custom factories are only consulted when no built-in renderable matches.

pub fn remote(config: Config, value: Bool) -> Config

Set whether to enable remote rendering.

pub fn target_fps(config: Config, value: Int) -> Config

Set the target frames per second. Rendering is on-demand: this paces the continuous render loop, which only runs while OpenTUI animations are active (requestAnimationFrame, timelines). It has no effect at idle or on state-change renders — those are paced by max_fps.

pub fn use_alternate_screen(
  config: Config,
  value: Bool,
) -> Config

Set whether to use the alternate screen buffer.

pub fn use_console(config: Config, value: Bool) -> Config

Set whether to use the built-in console.

pub fn use_kitty_keyboard(config: Config, value: Bool) -> Config

Set whether to use Kitty keyboard protocol.

pub fn use_mouse(config: Config, value: Bool) -> Config

Set whether to enable mouse input.

pub fn use_thread(config: Config, value: Bool) -> Config

Set whether to use a separate thread for rendering.

Search Document