Raxol.Terminal.ModeManager (Raxol v0.5.0)

View Source

Manages terminal modes (DEC Private Modes, Standard Modes) and their effects.

This module centralizes the state and logic for various terminal modes, handling both simple flag toggles and modes with side effects on the emulator state (like screen buffer switching or resizing).

Summary

Functions

Returns a specification to start this module under a supervisor.

Gets the mode manager.

Gets the set modes.

Looks up a DEC private mode code and returns the corresponding mode atom.

Looks up a standard mode code and returns the corresponding mode atom.

Checks if a mode is enabled.

Checks if the given mode is set.

Creates a new instance of the ModeManager.

Resets all modes.

Resets one or more modes. Dispatches to specific handlers. Returns potentially updated Emulator state if side effects occurred.

Restores the saved modes.

Restores the previously saved terminal state.

Saves the current modes.

Saves the current terminal state.

Sets one or more modes. Dispatches to specific handlers. Returns potentially updated Emulator state if side effects occurred.

Sets a mode with a value and private flag.

Sets a private mode with a value.

Sets a standard mode with a value.

Updates the mode manager.

Types

mode()

@type mode() :: atom()

t()

@type t() :: %Raxol.Terminal.ModeManager{
  active_buffer_type: term(),
  alt_screen_mode: term(),
  alternate_buffer_active: term(),
  auto_repeat_mode: term(),
  auto_wrap: term(),
  bracketed_paste_mode: term(),
  column_width_mode: term(),
  cursor_keys_mode: term(),
  cursor_visible: term(),
  focus_events_enabled: term(),
  insert_mode: term(),
  interlacing_mode: term(),
  line_feed_mode: term(),
  mouse_report_mode: term(),
  origin_mode: term(),
  screen_mode_reverse: term()
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_manager(state)

@spec get_manager(t()) :: map()

Gets the mode manager.

get_set_modes(state)

@spec get_set_modes(t()) :: list()

Gets the set modes.

lookup_private(code)

@spec lookup_private(integer()) :: mode() | nil

Looks up a DEC private mode code and returns the corresponding mode atom.

lookup_standard(code)

@spec lookup_standard(integer()) :: mode() | nil

Looks up a standard mode code and returns the corresponding mode atom.

mode_enabled?(state, mode)

@spec mode_enabled?(t(), mode()) :: boolean()

Checks if a mode is enabled.

mode_set?(state, mode)

@spec mode_set?(t(), atom()) :: boolean()

Checks if the given mode is set.

new()

@spec new() :: t()

Creates a new instance of the ModeManager.

reset_all_modes(state)

@spec reset_all_modes(t()) :: t()

Resets all modes.

reset_mode(emulator, modes)

@spec reset_mode(Raxol.Terminal.Emulator.t(), [mode()]) ::
  {:ok, Raxol.Terminal.Emulator.t()} | {:error, term()}

Resets one or more modes. Dispatches to specific handlers. Returns potentially updated Emulator state if side effects occurred.

restore_modes(state)

@spec restore_modes(t()) :: t()

Restores the saved modes.

restore_state(emulator)

Restores the previously saved terminal state.

save_modes(state)

@spec save_modes(t()) :: t()

Saves the current modes.

save_state(emulator)

Saves the current terminal state.

set_mode(emulator, modes)

@spec set_mode(Raxol.Terminal.Emulator.t(), [mode()]) ::
  {:ok, Raxol.Terminal.Emulator.t()} | {:error, term()}

Sets one or more modes. Dispatches to specific handlers. Returns potentially updated Emulator state if side effects occurred.

set_mode(emulator, mode, value, private)

@spec set_mode(Raxol.Terminal.Emulator.t(), mode(), boolean(), boolean()) ::
  {:ok, Raxol.Terminal.Emulator.t()} | {:error, term()}

Sets a mode with a value and private flag.

set_private_mode(emulator, mode, value)

@spec set_private_mode(Raxol.Terminal.Emulator.t(), mode(), boolean()) ::
  {:ok, Raxol.Terminal.Emulator.t()} | {:error, term()}

Sets a private mode with a value.

set_standard_mode(emulator, mode, value)

@spec set_standard_mode(Raxol.Terminal.Emulator.t(), mode(), boolean()) ::
  {:ok, Raxol.Terminal.Emulator.t()} | {:error, term()}

Sets a standard mode with a value.

update_manager(state, modes)

@spec update_manager(t(), map()) :: t()

Updates the mode manager.