Raxol.Terminal.Input.Manager (Raxol v2.0.1)

View Source

Manages terminal input processing including character input, key events, and input mode handling. This module is responsible for processing all input events and converting them into appropriate terminal actions.

Summary

Functions

Adds a custom key mapping.

Adds a custom validation rule.

Flushes the input buffer.

Gets the buffer contents.

Gets the current input mode. Returns the input mode.

Gets the current metrics.

Gets the current mode.

Handles a key event. Returns the updated emulator and any output.

Creates a new input manager with default configuration.

Creates a new input manager with custom options.

Processes a single character input. Returns the updated emulator and any output.

Processes a sequence of character inputs. Returns the updated emulator and any output.

Processes a key event.

Processes a key with modifiers.

Processes keyboard input.

Processes mouse events.

Processes special keys.

Sets the input mode. Returns the updated emulator.

Sets the mode.

Sets mouse enabled state.

Types

t()

@type t() :: %Raxol.Terminal.Input.Manager{
  buffer: map(),
  completion_callback: function() | nil,
  history_index: integer() | nil,
  input_history: list(),
  key_mappings: map(),
  metrics: map(),
  mode: atom(),
  modifier_state: map(),
  mouse_buttons: MapSet.t(),
  mouse_enabled: boolean(),
  mouse_position: {integer(), integer()},
  processor: module(),
  validation_rules: list()
}

Functions

add_key_mapping(manager, from_key, to_key)

@spec add_key_mapping(t(), String.t(), String.t()) :: t()

Adds a custom key mapping.

add_validation_rule(manager, rule)

@spec add_validation_rule(t(), function()) :: t()

Adds a custom validation rule.

flush_buffer(manager)

@spec flush_buffer(t()) :: t()

Flushes the input buffer.

get_buffer_contents(manager)

@spec get_buffer_contents(t()) :: String.t()

Gets the buffer contents.

get_input_mode(emulator)

@spec get_input_mode(Raxol.Terminal.Emulator.t()) :: atom()

Gets the current input mode. Returns the input mode.

get_metrics(manager)

@spec get_metrics(t()) :: map()

Gets the current metrics.

get_mode(manager)

@spec get_mode(t()) :: atom()

Gets the current mode.

handle_key_event(emulator, atom, event)

@spec handle_key_event(Raxol.Terminal.Emulator.t(), atom(), map()) ::
  {Raxol.Terminal.Emulator.t(), any()}

Handles a key event. Returns the updated emulator and any output.

new()

@spec new() :: t()

Creates a new input manager with default configuration.

new(opts)

@spec new(keyword()) :: t()

Creates a new input manager with custom options.

process_input(emulator, char)

@spec process_input(Raxol.Terminal.Emulator.t(), char()) ::
  {Raxol.Terminal.Emulator.t(), any()}

Processes a single character input. Returns the updated emulator and any output.

process_input_sequence(emulator, chars)

@spec process_input_sequence(Raxol.Terminal.Emulator.t(), [char()]) ::
  {Raxol.Terminal.Emulator.t(), any()}

Processes a sequence of character inputs. Returns the updated emulator and any output.

process_key_event(manager, event)

@spec process_key_event(t(), map()) :: {:ok, t()} | {:error, :validation_failed}

Processes a key event.

process_key_with_modifiers(manager, key)

@spec process_key_with_modifiers(t(), String.t()) :: t()

Processes a key with modifiers.

process_keyboard(manager, key)

@spec process_keyboard(t(), String.t()) :: t()

Processes keyboard input.

process_mouse(manager, arg)

@spec process_mouse(t(), {atom(), integer(), integer(), integer()}) :: t()

Processes mouse events.

process_special_key(manager, key)

@spec process_special_key(t(), atom()) :: t()

Processes special keys.

set_input_mode(emulator, mode)

@spec set_input_mode(Raxol.Terminal.Emulator.t(), atom()) ::
  Raxol.Terminal.Emulator.t()

Sets the input mode. Returns the updated emulator.

set_mode(manager, mode)

@spec set_mode(t(), atom()) :: t()

Sets the mode.

set_mouse_enabled(manager, enabled)

@spec set_mouse_enabled(t(), boolean()) :: t()

Sets mouse enabled state.

update_modifier(manager, modifier, value)

@spec update_modifier(t(), String.t(), boolean()) :: t()

Updates modifier state.