Raxol.Terminal.Input (Raxol v0.2.0)
View SourceTerminal input module.
This module handles keyboard and mouse input events for the terminal, including:
- Input buffering
- Mode management
- Input history
- Special key handling
Summary
Functions
Adds a command to the history.
Clears the input buffer.
Gets the current input buffer.
Gets the input mode.
Creates a new input handler.
Gets the next command from history.
Gets the previous command from history.
Processes a keyboard event.
Processes a mouse event.
Sets the input mode.
Types
@type t() :: %Raxol.Terminal.Input{ buffer: String.t(), history: [String.t()], history_index: non_neg_integer(), history_limit: non_neg_integer(), mode: atom() }
Functions
Adds a command to the history.
Examples
iex> input = Input.new()
iex> input = Input.add_to_history(input, "test")
iex> length(input.history)
1
Clears the input buffer.
Examples
iex> input = Input.new()
iex> input = Input.process_keyboard(input, "test")
iex> input = Input.clear_buffer(input)
iex> Input.get_buffer(input)
""
Gets the current input buffer.
Examples
iex> input = Input.new()
iex> input = Input.process_keyboard(input, "test")
iex> Input.get_buffer(input)
"test"
Gets the input mode.
Examples
iex> input = Input.new()
iex> Input.get_mode(input)
:normal
Creates a new input handler.
Examples
iex> input = Input.new()
iex> input.mode
:normal
iex> input.buffer
""
Gets the next command from history.
Examples
iex> input = Input.new()
iex> input = Input.add_to_history(input, "test")
iex> input = Input.previous_command(input)
iex> input = Input.next_command(input)
iex> input.buffer
""
Gets the previous command from history.
Examples
iex> input = Input.new()
iex> input = Input.add_to_history(input, "test")
iex> input = Input.previous_command(input)
iex> input.buffer
"test"
Processes a keyboard event.
Examples
iex> input = Input.new()
iex> input = Input.process_keyboard(input, "a")
iex> input.buffer
"a"
Processes a mouse event.
Examples
iex> input = Input.new()
iex> input = Input.process_mouse(input, {:click, 1, 2, 1})
iex> input.buffer
""
Sets the input mode.
Examples
iex> input = Input.new()
iex> input = Input.set_mode(input, :insert)
iex> input.mode
:insert