Raxol.Terminal.Session (Raxol v0.3.0)

View Source

Terminal session module.

This module manages terminal sessions, including:

  • Session lifecycle
  • Input/output handling
  • State management
  • Configuration

Summary

Functions

Returns a specification to start this module under a supervisor.

Gets the current state of a terminal session.

Sends input to a terminal session.

Starts a new terminal session.

Stops a terminal session.

Updates the configuration of a terminal session.

Types

t()

@type t() :: %Raxol.Terminal.Session{
  emulator: Raxol.Terminal.Emulator.t(),
  height: non_neg_integer(),
  id: String.t(),
  renderer: Raxol.Terminal.Renderer.t(),
  theme: map(),
  title: String.t(),
  width: non_neg_integer()
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

count_active_sessions()

@spec count_active_sessions() :: non_neg_integer()

get_state(pid)

@spec get_state(GenServer.server()) :: t()

Gets the current state of a terminal session.

Examples

iex> {:ok, pid} = Session.start_link()
iex> state = Session.get_state(pid)
iex> state.width
80

send_input(pid, input)

@spec send_input(GenServer.server(), String.t()) :: :ok

Sends input to a terminal session.

Examples

iex> {:ok, pid} = Session.start_link()
iex> :ok = Session.send_input(pid, "test")
iex> state = Session.get_state(pid)
iex> state.input.buffer
"test"

start_link(opts \\ [])

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

Starts a new terminal session.

Examples

iex> {:ok, pid} = Session.start_link(%{width: 80, height: 24})
iex> Process.alive?(pid)
true

stop(pid)

@spec stop(GenServer.server()) :: :ok

Stops a terminal session.

Examples

iex> {:ok, pid} = Session.start_link()
iex> :ok = Session.stop(pid)
iex> Process.alive?(pid)
false

update_config(pid, config)

@spec update_config(GenServer.server(), map()) :: :ok

Updates the configuration of a terminal session.

Examples

iex> {:ok, pid} = Session.start_link()
iex> :ok = Session.update_config(pid, %{width: 100, height: 30})
iex> state = Session.get_state(pid)
iex> state.width
100