Raxol.Terminal.Window (Raxol v0.5.0)
View SourceRepresents a terminal window with its properties and state.
This module provides functionality for managing terminal windows, including:
- Window creation and configuration
- State management (active, inactive, minimized, maximized)
- Size and position control
- Parent-child window relationships
- Terminal emulator integration
Window States
:active
- Window is currently focused:inactive
- Window is not focused:minimized
- Window is minimized:maximized
- Window is maximized
Usage
# Create a new window with default size
window = Window.new(Config.new())
# Create a window with custom dimensions
window = Window.new(100, 50)
# Update window title
{:ok, window} = Window.set_title(window, "My Terminal")
Summary
Functions
Adds a child window.
Clears a hyperlink by ID.
Gets the window's child windows.
Gets the window's clipboard content.
Gets the window's cursor shape.
Gets the window's current dimensions.
Gets the window's font.
Gets a hyperlink by ID.
Gets the window's icon name.
Gets the window's parent window.
Gets the window's current position.
Gets the window's current size.
Gets the window's current state.
Gets the window's working directory.
Creates a new window with the given configuration.
Creates a new window with custom dimensions.
Removes a child window.
Restores the previous window size.
Updates the window's clipboard content.
Updates the window's cursor shape.
Updates the window's font.
Sets a hyperlink with the given ID and URL.
Updates the window's icon name.
Sets the parent window.
Updates the window position.
Updates the window size.
Updates the window state.
Updates the window title.
Sets the window's working directory.
Types
@type t() :: %Raxol.Terminal.Window{ children: [String.t()], clipboard: String.t(), config: Raxol.Terminal.Config.t(), cursor_shape: String.t(), emulator: Raxol.Terminal.Emulator.t(), font: String.t(), icon_name: String.t(), id: String.t() | nil, parent: String.t() | nil, position: window_position(), previous_size: window_size() | nil, size: window_size(), state: window_state(), title: String.t() }
@type window_size() :: {non_neg_integer(), non_neg_integer()}
@type window_state() :: :active | :inactive | :minimized | :maximized
Functions
Adds a child window.
Clears a hyperlink by ID.
Gets the window's child windows.
Gets the window's clipboard content.
Gets the window's cursor shape.
@spec get_dimensions(t()) :: {:ok, window_size()} | {:error, term()}
Gets the window's current dimensions.
Gets the window's font.
Gets a hyperlink by ID.
Gets the window's icon name.
Gets the window's parent window.
@spec get_position(t()) :: {:ok, window_position()} | {:error, term()}
Gets the window's current position.
@spec get_size(t()) :: window_size()
Gets the window's current size.
@spec get_state(t()) :: {:ok, window_state()} | {:error, term()}
Gets the window's current state.
Gets the window's working directory.
@spec new(Raxol.Terminal.Config.t()) :: t()
Creates a new window with the given configuration.
Parameters
config
- Terminal configuration (Config.t())
Returns
- A new window instance with the specified configuration
Examples
iex> config = Config.new()
iex> window = Window.new(config)
iex> window.size
{80, 24}
@spec new(non_neg_integer(), non_neg_integer()) :: t()
Creates a new window with custom dimensions.
Parameters
width
- Window width in characters (positive integer)height
- Window height in characters (positive integer)
Returns
- A new window instance with the specified dimensions
Examples
iex> window = Window.new(100, 50)
iex> window.size
{100, 50}
Removes a child window.
Restores the previous window size.
Updates the window's clipboard content.
Updates the window's cursor shape.
Updates the window's font.
Sets a hyperlink with the given ID and URL.
Updates the window's icon name.
Sets the parent window.
Updates the window position.
@spec set_size(t(), non_neg_integer(), non_neg_integer()) :: {:ok, t()} | {:error, term()}
Updates the window size.
@spec set_state(t(), window_state()) :: {:ok, t()} | {:error, term()}
Updates the window state.
Updates the window title.
Parameters
window
- The window to updatetitle
- New window title
Returns
{:ok, updated_window}
- Title updated successfully{:error, reason}
- Failed to update title
Examples
iex> window = Window.new(80, 24)
iex> {:ok, window} = Window.set_title(window, "My Terminal")
iex> window.title
"My Terminal"
Sets the window's working directory.