Raxol.Terminal.Emulator.Input (Raxol v0.4.0)

View Source

Handles input processing for the terminal emulator. Provides functions for key event handling, command history, and input parsing.

Summary

Functions

Updates the command history with a new command. Returns {:ok, updated_emulator}.

Clears the command buffer. Returns {:ok, updated_emulator}.

Clears the command history. Returns {:ok, updated_emulator}.

Gets the current command buffer. Returns the current command buffer.

Gets the command history. Returns the list of commands in history.

Processes a key event. Returns {:ok, updated_emulator, commands} or {:error, reason}.

Processes a key press event. Returns {:ok, updated_emulator, commands} or {:error, reason}.

Processes a mouse event. Returns {:ok, updated_emulator, commands} or {:error, reason}.

Sets the command buffer. Returns {:ok, updated_emulator}.

Functions

add_to_history(emulator, command)

@spec add_to_history(Raxol.Terminal.Emulator.t(), String.t()) ::
  {:ok, Raxol.Terminal.Emulator.t()}

Updates the command history with a new command. Returns {:ok, updated_emulator}.

clear_command_buffer(emulator)

@spec clear_command_buffer(Raxol.Terminal.Emulator.t()) ::
  {:ok, Raxol.Terminal.Emulator.t()}

Clears the command buffer. Returns {:ok, updated_emulator}.

clear_history(emulator)

@spec clear_history(Raxol.Terminal.Emulator.t()) :: {:ok, Raxol.Terminal.Emulator.t()}

Clears the command history. Returns {:ok, updated_emulator}.

get_command_buffer(emulator)

@spec get_command_buffer(Raxol.Terminal.Emulator.t()) :: String.t()

Gets the current command buffer. Returns the current command buffer.

get_history(emulator)

@spec get_history(Raxol.Terminal.Emulator.t()) :: list()

Gets the command history. Returns the list of commands in history.

process_key_event(emulator, event)

@spec process_key_event(Raxol.Terminal.Emulator.t(), map()) ::
  {:ok, Raxol.Terminal.Emulator.t(), list()} | {:error, String.t()}

Processes a key event. Returns {:ok, updated_emulator, commands} or {:error, reason}.

process_key_press(emulator, event)

@spec process_key_press(Raxol.Terminal.Emulator.t(), map()) ::
  {:ok, Raxol.Terminal.Emulator.t(), list()} | {:error, String.t()}

Processes a key press event. Returns {:ok, updated_emulator, commands} or {:error, reason}.

process_mouse_event(emulator, event)

@spec process_mouse_event(Raxol.Terminal.Emulator.t(), map()) ::
  {:ok, Raxol.Terminal.Emulator.t(), list()} | {:error, String.t()}

Processes a mouse event. Returns {:ok, updated_emulator, commands} or {:error, reason}.

set_command_buffer(emulator, buffer)

@spec set_command_buffer(Raxol.Terminal.Emulator.t(), String.t()) ::
  {:ok, Raxol.Terminal.Emulator.t()}

Sets the command buffer. Returns {:ok, updated_emulator}.