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

What the built-in console overlay does, as accepted by console_mode. Mirrors OpenTUI’s ConsoleMode: ConsoleOverlay shows the overlay, Disabled turns it off.

Held as an Option(ConsoleMode): default_config leaves it None, which sends nothing so OpenTUI’s own default applies.

pub type ConsoleMode {
  ConsoleOverlay
  Disabled
}

Constructors

  • ConsoleOverlay
  • Disabled

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

The Kitty keyboard protocol configuration, as accepted by with_kitty_keyboard.

KittyOff disables the protocol entirely — every flag off. KittyOn enables it and selects which of OpenTUI’s five flags are on, mirroring KittyKeyboardOptions in @opentui/core.

Held as an Option(KittyConfig): default_config leaves it None, which sends nothing to OpenTUI so its own default applies. We defer to that default rather than copy it, so ours can’t drift from OpenTUI’s.

pub type KittyConfig {
  KittyOff
  KittyOn(
    disambiguate: Bool,
    alternate_keys: Bool,
    events: Bool,
    all_keys_as_escapes: Bool,
    report_text: Bool,
  )
}

Constructors

  • KittyOff
  • KittyOn(
      disambiguate: Bool,
      alternate_keys: Bool,
      events: Bool,
      all_keys_as_escapes: Bool,
      report_text: Bool,
    )

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

pub type Node

A type representing an OpenTUI CLI renderer.

pub type Renderer

Where the renderer owns terminal space, as accepted by screen_mode. Mirrors OpenTUI’s ScreenMode: AlternateScreen uses the terminal’s alternate buffer, MainScreen renders on the main screen, and SplitFooter keeps the renderer in a reserved footer on the main screen.

Held as an Option(ScreenMode): default_config leaves it None, which sends nothing so OpenTUI’s own default applies.

pub type ScreenMode {
  AlternateScreen
  MainScreen
  SplitFooter
}

Constructors

  • AlternateScreen
  • MainScreen
  • SplitFooter

A signal name, as accepted by exit_signals.

pub type Signal {
  Sigabrt
  Sigalrm
  Sigbus
  Sigchld
  Sigcont
  Sigfpe
  Sighup
  Sigill
  Sigint
  Sigio
  Sigiot
  Sigpipe
  Sigpoll
  Sigprof
  Sigpwr
  Sigquit
  Sigsegv
  Sigstkflt
  Sigsys
  Sigterm
  Sigtrap
  Sigtstp
  Sigttin
  Sigttou
  Sigunused
  Sigurg
  Sigusr1
  Sigusr2
  Sigvtalrm
  Sigwinch
  Sigxcpu
  Sigxfsz
  Sigbreak
  Siglost
  Siginfo
}

Constructors

  • Sigabrt
  • Sigalrm
  • Sigbus
  • Sigchld
  • Sigcont
  • Sigfpe
  • Sighup
  • Sigill
  • Sigint
  • Sigio
  • Sigiot
  • Sigpipe
  • Sigpoll
  • Sigprof
  • Sigpwr
  • Sigquit
  • Sigsegv
  • Sigstkflt
  • Sigsys
  • Sigterm
  • Sigtrap
  • Sigtstp
  • Sigttin
  • Sigttou
  • Sigunused
  • Sigurg
  • Sigusr1
  • Sigusr2
  • Sigvtalrm
  • Sigwinch
  • Sigxcpu
  • Sigxfsz
  • Sigbreak
  • Siglost
  • Siginfo

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 console_mode(config: Config, mode: ConsoleMode) -> Config

Set what the built-in console overlay does. Not calling this defers to OpenTUI’s own default.

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 fn exit_signals(
  config: Config,
  value: List(Signal),
) -> Config

Set which signals tear the renderer down, replacing OpenTUI’s default list.

This selects which signals are handled, not what happens: every listed signal destroys the renderer, including ones that normally mean something other than “quit” — Sigchld destroys it whenever a subprocess exits, Sigwinch whenever the terminal is resized, Sigtstp instead of suspending. Use opentui/effect.on_destroy to run your own cleanup when it does.

Passing an empty list is not “signals are ignored” — it registers no listener at all, so each signal’s default disposition applies instead: most terminate the process with no teardown, leaving the terminal in the alternate screen and in raw mode. on_destroy does not run on that path.

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 screen_mode(config: Config, mode: ScreenMode) -> Config

Set where the renderer owns terminal space (alternate screen, main screen, or split footer). Not calling this defers to OpenTUI’s own default.

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_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.

pub fn with_kitty_keyboard(
  config: Config,
  kitty: KittyConfig,
) -> Config

Set the Kitty keyboard protocol configuration. Pass KittyOff to disable it, or a KittyOn(...) to enable it and choose which flags apply. Not calling this defers to OpenTUI’s own default

Search Document