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

Copy Markdown View Source

Refactored Window.Manager that delegates to GenServer implementation.

This module provides the same API as the original Terminal.Window.Manager but uses a supervised GenServer instead of the Process dictionary for state management.

Migration Notice

This module is a drop-in replacement for Raxol.Terminal.Window.Manager. All functions maintain backward compatibility while providing improved fault tolerance and functional programming patterns.

Benefits over Process Dictionary

  • Supervised state management with fault tolerance
  • Pure functional window management
  • Z-order window stacking support
  • Spatial navigation mapping
  • Better debugging and testing capabilities
  • No global state pollution

New Features

  • Window Z-ordering for proper stacking
  • Spatial position tracking for navigation
  • Custom navigation paths between windows
  • Hierarchical window relationships

Summary

Functions

Cleanup the window manager. Alias for reset/0.

Counts the number of windows.

Creates a child window.

Creates a new window with the given configuration.

Creates a new window with dimensions.

Defines a navigation path between windows.

Destroys a window by ID.

Ensures the Window Manager server is started.

Gets the active window.

Gets child windows of a parent.

Gets the parent window of a child.

Gets the window manager state as a map.

Gets a window by ID.

Gets the window size.

Gets the window state.

Lists all windows.

Move a window to the specified position.

Moves a window to the back (bottom of Z-order).

Moves a window to the front (top of Z-order).

Creates a new window manager instance. For backward compatibility, returns {:ok, pid()} of the GenServer.

Creates a new window manager instance for testing. Returns a simple map structure instead of a process.

Registers a window's spatial position for navigation.

Resets the window manager to initial state.

Resizes a window. Alias for set_window_size/3.

Sets the active window.

Sets the icon name.

Set the stacking order of a window.

Set the title of a window.

Sets the window position.

Sets the window size.

Sets the window state.

Sets the window title.

Split a window horizontally or vertically.

Starts the window manager.

Updates the window manager configuration.

Checks if a window exists.

Types

t()

@type t() :: %{tabs: map()}

window_id()

@type window_id() :: String.t()

window_state()

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

Functions

cleanup()

Cleanup the window manager. Alias for reset/0.

count_windows()

Counts the number of windows.

create_child_window(parent_id, config)

Creates a child window.

create_window(config)

Creates a new window with the given configuration.

create_window(width, height)

Creates a new window with dimensions.

define_navigation_path(from_id, direction, to_id)

Defines a navigation path between windows.

destroy_window(id)

Destroys a window by ID.

ensure_started()

Ensures the Window Manager server is started.

get_active_window()

Gets the active window.

get_child_windows(parent_id)

Gets child windows of a parent.

get_parent_window(child_id)

Gets the parent window of a child.

get_state(pid)

Gets the window manager state as a map.

get_window(id)

Gets a window by ID.

get_window_size(pid)

Gets the window size.

get_window_state(pid)

Gets the window state.

list_windows()

Lists all windows.

move(window_id, x, y)

Move a window to the specified position.

move_window_to_back(window_id)

Moves a window to the back (bottom of Z-order).

move_window_to_front(window_id)

Moves a window to the front (top of Z-order).

new()

Creates a new window manager instance. For backward compatibility, returns {:ok, pid()} of the GenServer.

new_for_test()

Creates a new window manager instance for testing. Returns a simple map structure instead of a process.

register_window_position(window_id, x, y, width, height)

Registers a window's spatial position for navigation.

reset()

Resets the window manager to initial state.

resize(window_id, width, height)

Resizes a window. Alias for set_window_size/3.

set_active_window(window_id)

Sets the active window.

set_icon_name(pid, icon_name)

Sets the icon name.

set_stacking_order(window_id, order)

Set the stacking order of a window.

set_title(window_id, title)

Set the title of a window.

set_window_position(id, x, y)

Sets the window position.

set_window_size(pid, width, height)

Sets the window size.

set_window_state(pid, state)

Sets the window state.

set_window_title(pid, title)

Sets the window title.

split_window(window_id, direction)

Split a window horizontally or vertically.

start_link()

Starts the window manager.

start_link(opts)

update_config(config)

Updates the window manager configuration.

window_exists?(window_id)

Checks if a window exists.