Raxol.Terminal.Mouse.UnifiedMouse (Raxol v0.5.0)

View Source

Provides unified mouse handling functionality for the terminal emulator. This module handles mouse events, tracking, and state management.

Summary

Functions

Returns a specification to start this module under a supervisor.

Cleans up resources.

Closes a mouse context.

Creates a new mouse context with the given configuration.

Gets the active mouse context ID.

Gets the list of all mouse contexts.

Gets the current mouse button state.

Gets the current mouse position.

Gets the state of a specific mouse context.

Sets the active mouse context.

Starts the mouse manager with the given options.

Updates the mouse manager configuration.

Updates the configuration of a specific mouse context.

Types

mouse_button()

@type mouse_button() :: :left | :middle | :right | :wheel_up | :wheel_down

mouse_config()

@type mouse_config() :: %{
  optional(:tracking) => boolean(),
  optional(:reporting) => boolean(),
  optional(:sgr_mode) => boolean(),
  optional(:urxvt_mode) => boolean(),
  optional(:pixel_mode) => boolean()
}

mouse_event()

@type mouse_event() :: :press | :release | :move | :drag | :click | :double_click

mouse_id()

@type mouse_id() :: non_neg_integer()

mouse_modifier()

@type mouse_modifier() :: :shift | :ctrl | :alt | :meta

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

cleanup()

@spec cleanup() :: :ok

Cleans up resources.

close_mouse(mouse_id)

@spec close_mouse(mouse_id()) :: :ok | {:error, term()}

Closes a mouse context.

create_mouse(config \\ %{})

@spec create_mouse(map()) :: {:ok, mouse_id()} | {:error, term()}

Creates a new mouse context with the given configuration.

get_active_mouse()

@spec get_active_mouse() :: {:ok, mouse_id()} | {:error, :no_active_mouse}

Gets the active mouse context ID.

get_mice()

@spec get_mice() :: [mouse_id()]

Gets the list of all mouse contexts.

get_mouse_button_state(mouse_id)

@spec get_mouse_button_state(mouse_id()) :: {:ok, [mouse_button()]} | {:error, term()}

Gets the current mouse button state.

get_mouse_position(mouse_id)

@spec get_mouse_position(mouse_id()) ::
  {:ok, {integer(), integer()}} | {:error, term()}

Gets the current mouse position.

get_mouse_state(mouse_id)

@spec get_mouse_state(mouse_id()) :: {:ok, map()} | {:error, term()}

Gets the state of a specific mouse context.

process_mouse_event(mouse_id, event, button, position, modifiers)

@spec process_mouse_event(
  mouse_id(),
  mouse_event(),
  mouse_button(),
  {integer(), integer()},
  [mouse_modifier()]
) :: :ok | {:error, term()}

Processes a mouse event.

set_active_mouse(mouse_id)

@spec set_active_mouse(mouse_id()) :: :ok | {:error, term()}

Sets the active mouse context.

start_link(opts \\ %{})

@spec start_link(map()) :: GenServer.on_start()

Starts the mouse manager with the given options.

update_config(config)

@spec update_config(map()) :: :ok

Updates the mouse manager configuration.

update_mouse_config(mouse_id, config)

@spec update_mouse_config(mouse_id(), mouse_config()) :: :ok | {:error, term()}

Updates the configuration of a specific mouse context.