Raxol.Terminal.Tab.Manager (Raxol v0.5.0)

View Source

Manages terminal tabs and their associated sessions. This module handles:

  • Creation, deletion, and switching of terminal tabs
  • Tab state and configuration management
  • Tab stop management for terminal operations

Summary

Functions

Returns a specification to start this module under a supervisor.

Clears all tab stops.

Clears a tab stop at the specified position.

Creates a new tab with the given configuration.

Deletes a tab by its ID.

Gets the active tab ID.

Gets the next tab stop position from the current position.

Gets the configuration for a specific tab.

Lists all tabs.

Creates a new tab manager instance.

Sets a horizontal tab stop at the current cursor position.

Switches to a different tab.

Updates the configuration for a specific tab.

Types

t()

@type t() :: %Raxol.Terminal.Tab.Manager{
  active_tab: tab_id() | nil,
  default_tab_width: pos_integer(),
  next_tab_id: non_neg_integer(),
  tab_stops: MapSet.t(),
  tabs: %{required(tab_id()) => tab_config()}
}

tab_config()

@type tab_config() :: %{
  title: String.t(),
  working_directory: String.t(),
  command: String.t() | nil,
  state: tab_state(),
  window_id: String.t() | nil
}

tab_id()

@type tab_id() :: String.t()

tab_state()

@type tab_state() :: :active | :inactive | :hidden

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear_all_tab_stops(manager)

@spec clear_all_tab_stops(t()) :: t()

Clears all tab stops.

clear_tab_stop(manager, position)

@spec clear_tab_stop(t(), pos_integer()) :: t()

Clears a tab stop at the specified position.

create_tab(manager, config \\ %{})

@spec create_tab(t(), tab_config() | nil) :: {:ok, tab_id(), t()} | {:error, term()}

Creates a new tab with the given configuration.

Parameters

  • manager - The tab manager instance
  • config - The tab configuration (optional)

Returns

{:ok, tab_id, updated_manager} on success {:error, reason} on failure

delete_tab(manager, tab_id)

@spec delete_tab(t(), tab_id()) :: {:ok, t()} | {:error, :tab_not_found}

Deletes a tab by its ID.

Parameters

  • manager - The tab manager instance
  • tab_id - The ID of the tab to delete

Returns

{:ok, updated_manager} on success {:error, :tab_not_found} if the tab doesn't exist

get_active_tab(manager)

@spec get_active_tab(t()) :: tab_id() | nil

Gets the active tab ID.

Parameters

  • manager - The tab manager instance

Returns

The active tab ID or nil if no tab is active

get_next_tab_stop(manager)

@spec get_next_tab_stop(t()) :: pos_integer()

Gets the next tab stop position from the current position.

get_tab_config(manager, tab_id)

@spec get_tab_config(t(), tab_id()) :: {:ok, tab_config()} | {:error, :tab_not_found}

Gets the configuration for a specific tab.

Parameters

  • manager - The tab manager instance
  • tab_id - The ID of the tab

Returns

{:ok, config} on success {:error, :tab_not_found} if the tab doesn't exist

list_tabs(manager)

@spec list_tabs(t()) :: [tab_config()]

Lists all tabs.

Parameters

  • manager - The tab manager instance

Returns

A list of tab configurations

new()

@spec new() :: t()

Creates a new tab manager instance.

set_horizontal_tab(manager)

@spec set_horizontal_tab(t()) :: t()

Sets a horizontal tab stop at the current cursor position.

start_link(opts \\ [])

switch_tab(manager, tab_id)

@spec switch_tab(t(), tab_id()) :: {:ok, t()} | {:error, :tab_not_found}

Switches to a different tab.

Parameters

  • manager - The tab manager instance
  • tab_id - The ID of the tab to switch to

Returns

{:ok, updated_manager} on success {:error, :tab_not_found} if the tab doesn't exist

update_tab_config(manager, tab_id, config)

@spec update_tab_config(t(), tab_id(), tab_config()) ::
  {:ok, t()} | {:error, :tab_not_found}

Updates the configuration for a specific tab.

Parameters

  • manager - The tab manager instance
  • tab_id - The ID of the tab
  • config - The new configuration

Returns

{:ok, updated_manager} on success {:error, :tab_not_found} if the tab doesn't exist