Groups buffer-related fields from EditorState.
Tracks the active buffer pid, the list of open buffers, the active index, and special (unlisted) buffers like Messages.
Summary
Functions
Appends a buffer pid and makes it active.
Appends a buffer pid without changing the active buffer.
Removes a buffer pid, selecting a neighbor as the new active.
Replaces the buffer list and selects the buffer at the given index.
Removes dead pids from the buffer list and selects a live neighbor as active.
Overrides the active buffer pid without updating the index. Use for temporary buffer swaps where the pid is not in the buffer list.
Sets the help buffer pid.
Switches to the buffer at idx, wrapping around.
Switches to the buffer with the given pid, if it exists in the list.
Types
@type t() :: %MingaEditor.State.Buffers{ active: pid() | nil, active_index: non_neg_integer(), help: pid() | nil, list: [pid()] }
Functions
Appends a buffer pid and makes it active.
Appends a buffer pid without changing the active buffer.
Removes a buffer pid, selecting a neighbor as the new active.
@spec replace_list(t(), [pid()], non_neg_integer()) :: t()
Replaces the buffer list and selects the buffer at the given index.
Removes dead pids from the buffer list and selects a live neighbor as active.
If active is nil, not a pid, or still alive, returns unchanged.
If active is dead, filters all dead pids from list and selects
a neighbor using the same logic as remove/2.
Overrides the active buffer pid without updating the index. Use for temporary buffer swaps where the pid is not in the buffer list.
Sets the help buffer pid.
@spec switch_to(t(), non_neg_integer()) :: t()
Switches to the buffer at idx, wrapping around.
Switches to the buffer with the given pid, if it exists in the list.