Raxol.Terminal.Session (Raxol v0.2.0)
View SourceTerminal 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
@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
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec count_active_sessions() :: non_neg_integer()
@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
@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"
@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
@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
@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