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

Copy Markdown View Source

Pure functional state operations for the WindowManagerServer.

Handles window CRUD, property updates, and Z-order management without GenServer concerns.

Summary

Functions

Moves a window to the back of the Z-order. Returns {:reply, result, new_state}.

Moves a window to the front of the Z-order. Returns {:reply, result, new_state}.

Updates all window states when a new active window is set. Returns {:reply, :ok, new_state} or {:reply, {:error, :not_found}, state}.

Builds a child Window struct from a config, parent ID, and window ID.

Builds the legacy-format state map for get_state.

Builds a new Window struct from a config and assigns an ID.

Calculates split size for a child window.

Optionally activates window_id if no active window exists yet.

Determines the new active window after a window is destroyed.

Updates a window property by ID. Takes a function that transforms the window. Returns {:ok, updated_window, new_state} or {:error, :not_found}.

Functions

apply_move_to_back(bool, window_id, state)

Moves a window to the back of the Z-order. Returns {:reply, result, new_state}.

apply_move_to_front(bool, window_id, state)

Moves a window to the front of the Z-order. Returns {:reply, result, new_state}.

apply_set_active_window(bool, window_id, state)

Updates all window states when a new active window is set. Returns {:reply, :ok, new_state} or {:reply, {:error, :not_found}, state}.

build_child_window(config, window_id, parent_id)

Builds a child Window struct from a config, parent ID, and window ID.

build_legacy_state(state)

Builds the legacy-format state map for get_state.

build_window(config, window_id)

Builds a new Window struct from a config and assigns an ID.

calculate_split_size(arg, atom)

Calculates split size for a child window.

maybe_activate_first_window(state, arg2, window_id)

Optionally activates window_id if no active window exists yet.

update_active_after_destroy(active_window, window_id, new_window_order)

Determines the new active window after a window is destroyed.

update_window_by_id(state, window_id, update_fn)

Updates a window property by ID. Takes a function that transforms the window. Returns {:ok, updated_window, new_state} or {:error, :not_found}.