MingaEditor.State.Windows (Minga v0.1.0)

Copy Markdown View Source

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 agent chat window.

Finds the first buffer window.

Finds the first window showing a buffer.

Returns all popup windows as a list of {window_id, window} tuples.

Removes a tree-managed window from the container.

Replaces every window showing a buffer with concrete owner-produced values.

Replaces one window with a concrete owner-produced value.

Resizes one window.

Scrolls one window horizontally.

Sets the active window id.

Sets one window's cursor.

Sets document symbols in every window showing a buffer.

Replaces fold ranges in one window.

Replaces the window map.

Sets the next available window id.

Sets a window's pinned state.

Replaces text-object positions in one window.

Replaces the window layout tree.

Sets one window's viewport.

Returns true if the window tree contains a split.

Updates one window's fold state.

Types

t()

@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

active_struct(windows)

@spec active_struct(t()) :: MingaEditor.Window.t() | nil

Returns the active window struct, or nil if no windows are initialized.

add_window(windows, window)

@spec add_window(t(), MingaEditor.Window.t()) :: t()

Adds a window to the container using the window's id.

allocate_id(windows)

@spec allocate_id(t()) :: {MingaEditor.Window.id(), t()}

Allocates the next window id and advances the allocator.

delete_window(windows, id)

@spec delete_window(t(), MingaEditor.Window.id()) :: t()

Deletes a window from the map without touching the window tree.

fetch(windows, id)

@spec fetch(t(), MingaEditor.Window.id()) :: {:ok, MingaEditor.Window.t()} | :error

Fetches a window by id.

find_agent_chat(windows)

@spec find_agent_chat(t()) :: {MingaEditor.Window.id(), MingaEditor.Window.t()} | nil

Finds the first agent chat window.

find_buffer_window(windows)

@spec find_buffer_window(t()) ::
  {MingaEditor.Window.id(), MingaEditor.Window.t()} | nil

Finds the first buffer window.

find_by_buffer(windows, buffer)

@spec find_by_buffer(t(), pid()) ::
  {MingaEditor.Window.id(), MingaEditor.Window.t()} | nil

Finds the first window showing a buffer.

fold_all(state, id)

@spec fold_all(t(), MingaEditor.Window.id()) :: t()

fold_at(state, id, line)

@spec fold_at(t(), MingaEditor.Window.id(), non_neg_integer()) :: t()

fold_recursive_at(state, id, line)

@spec fold_recursive_at(t(), MingaEditor.Window.id(), non_neg_integer()) :: t()

remove_window(windows, id)

@spec remove_window(t(), MingaEditor.Window.id()) :: {:ok, t()} | :error

Removes a tree-managed window from the container.

replace_buffer_windows(state, buffer, replacements)

@spec replace_buffer_windows(t(), pid(), %{
  required(MingaEditor.Window.id()) => MingaEditor.Window.t()
}) ::
  t()

Replaces every window showing a buffer with concrete owner-produced values.

replace_window(state, id, window)

@spec replace_window(t(), MingaEditor.Window.id(), MingaEditor.Window.t()) :: t()

Replaces one window with a concrete owner-produced value.

resize(state, id, rows, cols)

@spec resize(t(), MingaEditor.Window.id(), non_neg_integer(), non_neg_integer()) ::
  t()

Resizes one window.

scroll_horizontal(state, id, delta)

@spec scroll_horizontal(t(), MingaEditor.Window.id(), integer()) :: t()

Scrolls one window horizontally.

set_active(windows, id)

@spec set_active(t(), MingaEditor.Window.id()) :: t()

Sets the active window id.

set_cursor(state, id, cursor)

@spec set_cursor(t(), MingaEditor.Window.id(), {non_neg_integer(), non_neg_integer()}) ::
  t()

Sets one window's cursor.

set_document_symbols_for_buffer(state, buffer, symbols)

@spec set_document_symbols_for_buffer(t(), pid(), list()) :: t()

Sets document symbols in every window showing a buffer.

set_fold_ranges(state, id, ranges)

@spec set_fold_ranges(t(), MingaEditor.Window.id(), list()) :: t()

Replaces fold ranges in one window.

set_map(windows, map)

@spec set_map(t(), %{required(MingaEditor.Window.id()) => MingaEditor.Window.t()}) ::
  t()

Replaces the window map.

set_next_id(windows, id)

@spec set_next_id(t(), MingaEditor.Window.id()) :: t()

Sets the next available window id.

set_pinned(state, id, pinned?)

@spec set_pinned(t(), MingaEditor.Window.id(), boolean()) :: t()

Sets a window's pinned state.

set_textobject_positions(state, id, positions)

@spec set_textobject_positions(t(), MingaEditor.Window.id(), map()) :: t()

Replaces text-object positions in one window.

set_tree(windows, tree)

@spec set_tree(t(), MingaEditor.WindowTree.t() | nil) :: t()

Replaces the window layout tree.

set_viewport(state, id, viewport)

@spec set_viewport(t(), MingaEditor.Window.id(), MingaEditor.Viewport.t()) :: t()

Sets one window's viewport.

split?(windows)

@spec split?(t()) :: boolean()

Returns true if the window tree contains a split.

toggle_fold(state, id, line)

@spec toggle_fold(t(), MingaEditor.Window.id(), non_neg_integer()) :: t()

Updates one window's fold state.

unfold_all(state, id)

@spec unfold_all(t(), MingaEditor.Window.id()) :: t()

unfold_at(state, id, line)

@spec unfold_at(t(), MingaEditor.Window.id(), non_neg_integer()) :: t()

unfold_containing(state, id, lines)

@spec unfold_containing(t(), MingaEditor.Window.id(), [non_neg_integer()]) :: t()

unfold_recursive_at(state, id, line)

@spec unfold_recursive_at(t(), MingaEditor.Window.id(), non_neg_integer()) :: t()