Raxol.Terminal.Input.Manager (Raxol v0.3.0)

View Source

Manages input handling for the terminal emulator, including:

  • Keyboard input processing
  • Mouse event handling
  • Input buffering
  • Input history
  • Input modes
  • Special key handling
  • Modifier state management

Summary

Functions

Adds the current buffer contents to the input history. Resets the history navigation index and clears the buffer.

Gets the current buffer contents.

Gets the current input mode.

Creates a new input manager with default values.

Processes a key with the current modifier state.

Processes a keyboard input event.

Processes a mouse event.

Processes a special key event.

Sets the input mode.

Enables or disables mouse event handling.

Updates the modifier state for a key.

Types

completion_callback()

@type completion_callback() :: (String.t() -> [String.t()])

input_mode()

@type input_mode() :: :normal | :insert | :replace | :command

mouse_button()

@type mouse_button() :: 0 | 1 | 2 | 3 | 4

mouse_event()

@type mouse_event() ::
  {mouse_event_type(), mouse_button(), non_neg_integer(), non_neg_integer()}

mouse_event_type()

@type mouse_event_type() :: :press | :release | :move | :scroll

special_key()

@type special_key() ::
  :up
  | :down
  | :left
  | :right
  | :home
  | :end
  | :page_up
  | :page_down
  | :insert
  | :delete
  | :escape
  | :tab
  | :enter
  | :backspace
  | :f1
  | :f2
  | :f3
  | :f4
  | :f5
  | :f6
  | :f7
  | :f8
  | :f9
  | :f10
  | :f11
  | :f12

t()

@type t() :: %Raxol.Terminal.Input.Manager{
  buffer: Raxol.Terminal.Input.Types.input_buffer(),
  clipboard_content: String.t() | nil,
  clipboard_history: [String.t()],
  completion_callback: completion_callback() | nil,
  completion_context: map() | nil,
  completion_index: non_neg_integer(),
  completion_options: [String.t()],
  history_index: integer() | nil,
  input_history: [String.t()],
  input_queue: [String.t()],
  last_event_time: integer() | nil,
  mode: input_mode(),
  modifier_state: Raxol.Terminal.Input.SpecialKeys.modifier_state(),
  mouse_buttons: MapSet.t(mouse_button()),
  mouse_enabled: boolean(),
  mouse_position: {non_neg_integer(), non_neg_integer()},
  processing_escape: boolean(),
  prompt: String.t() | nil
}

Functions

add_to_history(manager)

@spec add_to_history(t()) :: t()

Adds the current buffer contents to the input history. Resets the history navigation index and clears the buffer.

get_buffer_contents(manager)

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

Gets the current buffer contents.

get_mode(manager)

@spec get_mode(t()) :: input_mode()

Gets the current input mode.

new()

@spec new() :: t()

Creates a new input manager with default values.

process_key_with_modifiers(manager, key)

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

Processes a key with the current modifier state.

process_keyboard(manager, input)

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

Processes a keyboard input event.

process_mouse(manager, arg)

@spec process_mouse(t(), mouse_event()) :: t()

Processes a mouse event.

process_special_key(manager, key)

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

Processes a special key event.

set_mode(manager, mode)

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

Sets the input mode.

set_mouse_enabled(manager, enabled)

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

Enables or disables mouse event handling.

update_modifier(manager, key, pressed)

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

Updates the modifier state for a key.