TermUI.Runtime.State (TermUI v1.0.0)

View Source

State struct for the Runtime GenServer.

Contains all runtime state including:

  • Root component module and state
  • The reserved :root component entry (there is no public 1.0 registration API)
  • Message queue
  • Event queue (bounded, prevents DoS)
  • Render configuration
  • Root focus bookkeeping
  • Shutdown status
  • Backend selection and capabilities
  • Input handler (Raw or TTY mode)
  • Command executor for async side effects

Summary

Types

backend_mode()

@type backend_mode() :: :raw | :tty | :custom | :skip | nil

capabilities()

@type capabilities() :: %{
  optional(:colors) => :true_color | :color_256 | :color_16 | :monochrome,
  optional(:unicode) => boolean(),
  optional(:dimensions) => {pos_integer(), pos_integer()} | nil,
  optional(:terminal) => boolean(),
  optional(:raw_mode_error) => term()
}

command_entry()

@type command_entry() :: %{component_id: atom(), command: term()}

component_entry()

@type component_entry() :: %{module: module(), state: term()}

t()

@type t() :: %TermUI.Runtime.State{
  backend: module() | nil,
  backend_mode: backend_mode(),
  backend_state: term() | nil,
  buffer_manager: pid() | nil,
  capabilities: capabilities() | nil,
  command_executor: TermUI.Command.Executor.t() | nil,
  components: %{required(atom()) => component_entry()},
  dimensions: {pos_integer(), pos_integer()} | nil,
  dirty: boolean(),
  event_queue: TermUI.EventQueue.t(),
  focused_component: atom(),
  input_handler: module() | nil,
  input_handler_reader: pid() | nil,
  input_reader: pid() | nil,
  input_state: term() | nil,
  logger_handler_config: map() | nil,
  message_queue: TermUI.MessageQueue.t(),
  pending_commands: %{required(reference()) => command_entry()},
  render_interval: pos_integer(),
  root_module: module(),
  root_state: term(),
  shutting_down: boolean(),
  terminal_started: boolean()
}