Groups window-related fields from EditorState.
Tracks the window tree layout, the map of window structs, the active window id, and the next available window id for splits.
Summary
Functions
Returns the active window struct, or nil if no windows are initialized.
Adds a window to the container using the window's id.
Allocates the next window id and advances the allocator.
Deletes a window from the map without touching the window tree.
Fetches a window by id.
Finds the first window matching the given predicate.
Returns all popup windows as a list of {window_id, window} tuples.
Removes a tree-managed window from the container.
Sets the active window id.
Replaces the window map.
Sets the next available window id.
Replaces the window layout tree.
Returns true if the window tree contains a split.
Updates the window struct for the given window id.
Updates every window that shows the given buffer pid via a mapper function.
Types
@type t() :: %MingaEditor.State.Windows{ active: MingaEditor.Window.id(), map: %{required(MingaEditor.Window.id()) => MingaEditor.Window.t()}, next_id: MingaEditor.Window.id(), tree: MingaEditor.WindowTree.t() | nil }
Functions
@spec active_struct(t()) :: MingaEditor.Window.t() | nil
Returns the active window struct, or nil if no windows are initialized.
@spec add_window(t(), MingaEditor.Window.t()) :: t()
Adds a window to the container using the window's id.
@spec allocate_id(t()) :: {MingaEditor.Window.id(), t()}
Allocates the next window id and advances the allocator.
@spec delete_window(t(), MingaEditor.Window.id()) :: t()
Deletes a window from the map without touching the window tree.
@spec fetch(t(), MingaEditor.Window.id()) :: {:ok, MingaEditor.Window.t()} | :error
Fetches a window by id.
@spec find_by_content(t(), (MingaEditor.Window.t() -> boolean())) :: {MingaEditor.Window.id(), MingaEditor.Window.t()} | nil
Finds the first window matching the given predicate.
@spec popup_windows(t()) :: [{MingaEditor.Window.id(), MingaEditor.Window.t()}]
Returns all popup windows as a list of {window_id, window} tuples.
Popup windows are those with a non-nil popup_meta field.
@spec remove_window(t(), MingaEditor.Window.id()) :: {:ok, t()} | :error
Removes a tree-managed window from the container.
@spec set_active(t(), MingaEditor.Window.id()) :: t()
Sets the active window id.
@spec set_map(t(), %{required(MingaEditor.Window.id()) => MingaEditor.Window.t()}) :: t()
Replaces the window map.
@spec set_next_id(t(), MingaEditor.Window.id()) :: t()
Sets the next available window id.
@spec set_tree(t(), MingaEditor.WindowTree.t() | nil) :: t()
Replaces the window layout tree.
Returns true if the window tree contains a split.
@spec update(t(), MingaEditor.Window.id(), (MingaEditor.Window.t() -> MingaEditor.Window.t())) :: t()
Updates the window struct for the given window id.
Applies the given function to the window and stores the result. Returns the struct unchanged if the id is not found.
@spec update_by_buffer(t(), pid(), (MingaEditor.Window.t() -> MingaEditor.Window.t())) :: t()
Updates every window that shows the given buffer pid via a mapper function.