Raxol.Terminal.Window (Raxol Terminal v2.6.0)

Copy Markdown View Source

Represents 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

t()

@type t() :: %Raxol.Terminal.Window{
  children: [String.t()],
  clipboard: String.t(),
  config: Raxol.Terminal.Config.t(),
  cursor_shape: String.t(),
  emulator: Raxol.Terminal.Emulator.Struct.t(),
  font: String.t(),
  height: integer(),
  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(),
  width: integer()
}

window_position()

@type window_position() :: {integer(), integer()}

window_size()

@type window_size() :: {integer(), integer()}

window_state()

@type window_state() :: :active | :inactive | :minimized | :maximized

Functions

add_child(window, child_id)

Adds a child window.

clear_hyperlink(window, id)

Clears a hyperlink by ID.

get_children(window)

Gets the window's child windows.

get_clipboard(window)

Gets the window's clipboard content.

get_cursor_shape(window)

Gets the window's cursor shape.

get_dimensions(window)

Gets the window's current dimensions.

get_font(window)

Gets the window's font.

get_hyperlink(window, id)

Gets a hyperlink by ID.

get_icon_name(window)

Gets the window's icon name.

get_parent(window)

Gets the window's parent window.

get_position(window)

Gets the window's current position.

get_size(window)

Gets the window's current size.

get_state(window)

Gets the window's current state.

get_working_directory(window)

Gets the window's working directory.

new(config)

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}

new(width, height)

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}

remove_child(window, child_id)

Removes a child window.

restore_size(window)

Restores the previous window size.

set_clipboard(window, content)

Updates the window's clipboard content.

set_cursor_shape(window, shape)

Updates the window's cursor shape.

set_font(window, font)

Updates the window's font.

set_hyperlink(window, id, url)

Sets a hyperlink with the given ID and URL.

set_icon_name(window, name)

Updates the window's icon name.

set_parent(window, parent_id)

Sets the parent window.

set_position(window, x, y)

Updates the window position.

set_size(window, width, height)

Updates the window size.

set_state(window, state)

Updates the window state.

set_title(window, title)

Updates the window title.

Parameters

  • window - The window to update
  • title - 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"

set_working_directory(window, dir)

Sets the window's working directory.