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

View Source

Handles input processing for the terminal emulator, including:

  • Mouse events (clicks, movement, scrolling)
  • Special key handling
  • Input mode switching
  • Input buffering
  • Extended key combinations
  • Tab completion

Summary

Functions

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

Checks if the buffer is empty.

Clears the input buffer.

Gets the contents of the internal input buffer.

Retrieves a specific input from history by its index (0 is most recent). Sets the history_index to track navigation.

Gets the current input mode.

Processes tab completion.

Creates a new input handler with default values.

Moves to the next history entry (newer / Down Arrow).

Moves to the previous history entry (older / Up Arrow). If not currently navigating history, it starts from the most recent entry (index 0).

Processes a key with the current modifier state.

Processes a keyboard input event.

Processes a mouse event.

Processes a special key event.

Sets a completion callback function for tab completion.

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

t()

@type t() :: %Raxol.Terminal.Input.InputHandler{
  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(handler)

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

buffer_empty?(handler)

Checks if the buffer is empty.

clear_buffer(handler)

Clears the input buffer.

get_buffer_contents(input_handler)

Gets the contents of the internal input buffer.

get_history_entry(handler, index)

Retrieves a specific input from history by its index (0 is most recent). Sets the history_index to track navigation.

get_mode(handler)

Gets the current input mode.

handle_tab(handler)

Processes tab completion.

new()

Creates a new input handler with default values.

next_history_entry(handler)

Moves to the next history entry (newer / Down Arrow).

previous_history_entry(handler)

Moves to the previous history entry (older / Up Arrow). If not currently navigating history, it starts from the most recent entry (index 0).

process_key_with_modifiers(handler, key)

Processes a key with the current modifier state.

process_keyboard(handler, input)

Processes a keyboard input event.

process_mouse(handler, arg)

Processes a mouse event.

process_special_key(handler, key)

Processes a special key event.

set_completion_callback(handler, callback)

Sets a completion callback function for tab completion.

set_mode(handler, mode)

Sets the input mode.

set_mouse_enabled(handler, enabled)

Enables or disables mouse event handling.

update_modifier(handler, key, pressed)

Updates the modifier state for a key.