Raxol.Terminal.Window.Manager.WindowManagerServer (Raxol v2.0.1)

View Source

GenServer implementation for terminal window management in Raxol.

This server provides a pure functional approach to window management, eliminating Process dictionary usage and implementing proper OTP patterns.

Features

  • Window creation, destruction, and lifecycle management
  • Hierarchical window relationships (parent/child)
  • Window state tracking (active, inactive, minimized, maximized)
  • Window properties management (title, size, position)
  • Icon management for windows
  • Supervised state management with fault tolerance

State Structure

The server maintains state with the following structure:

%{
  windows: %{window_id => Window.t()},
  active_window: window_id | nil,
  window_order: [window_id],  # Z-order for stacking
  window_state: :normal | :minimized | :maximized | :fullscreen,
  window_size: {width, height},
  window_title: String.t(),
  icon_name: String.t(),
  icon_title: String.t(),
  spatial_map: %{},  # For spatial navigation
  navigation_paths: %{},  # Custom navigation paths
  next_window_id: integer()
}

Summary

Functions

Returns a specification to start this module under a supervisor.

Creates a child window.

Creates a new window with the given configuration.

Gets the active window.

Gets child windows.

Gets parent window.

Gets the complete state (for debugging/migration).

Gets the window manager state.

Moves a window to the back in Z-order.

Registers a window's spatial position for navigation.

Resets to initial state.

Sets window position.

Sets the window size.

Sets a specific window's size.

Sets the window state (normal, minimized, maximized, fullscreen).

Sets a specific window's state.

Sets the window title.

Sets a specific window's title.

Split a window horizontally or vertically.

Updates the window manager configuration.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

create_child_window(parent_id, config)

Creates a child window.

create_window(config_or_width, height_or_config \\ nil)

Creates a new window with the given configuration.

define_navigation_path(server \\ __MODULE__, from_id, direction, to_id)

Defines a navigation path between windows.

destroy_window(server \\ __MODULE__, window_id)

Destroys a window by ID.

get_active_window(server \\ __MODULE__)

Gets the active window.

get_child_windows(parent_id)

Gets child windows.

get_parent_window(child_id)

Gets parent window.

get_state(server \\ __MODULE__)

Gets the complete state (for debugging/migration).

get_window(server \\ __MODULE__, window_id)

Gets a window by ID.

get_window_size(server \\ __MODULE__)

Gets the window size.

get_window_state(server \\ __MODULE__)

Gets the window manager state.

handle_manager_cast(msg, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_cast/2.

handle_manager_info(msg, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_info/2.

list_windows(server \\ __MODULE__)

Lists all windows.

move_window_to_back(server \\ __MODULE__, window_id)

Moves a window to the back in Z-order.

move_window_to_front(server \\ __MODULE__, window_id)

Moves a window in the Z-order.

register_window_position(server \\ __MODULE__, window_id, x, y, width, height)

Registers a window's spatial position for navigation.

reset(server \\ __MODULE__)

Resets to initial state.

set_active_window(server \\ __MODULE__, window_id)

Sets the active window.

set_icon_name(server \\ __MODULE__, icon_name)

Sets the icon name.

set_icon_title(server \\ __MODULE__, icon_title)

Sets the icon title.

set_window_position(window_id, x, y)

Sets window position.

set_window_size(width, height)

Sets the window size.

set_window_size(server, width, height)

set_window_size(server, window_id, width, height)

Sets a specific window's size.

set_window_state(state)

Sets the window state (normal, minimized, maximized, fullscreen).

set_window_state(server, state)

set_window_state(server, window_id, state)

Sets a specific window's state.

set_window_title(title)

Sets the window title.

set_window_title(server, title)

set_window_title(server, window_id, title)

Sets a specific window's title.

split_window(window_id, direction)

Split a window horizontally or vertically.

split_window(server, window_id, direction)

start_link(init_opts \\ [])

update_config(config)

Updates the window manager configuration.

update_config(server, config)