MingaEditor.GitStatus.TUIState (Minga v0.1.0)

Copy Markdown View Source

TUI-only value owner for the Traditional Git-status sidebar.

The shared git status panel data stays frontend-neutral. This struct tracks terminal presentation concerns such as cursor position, collapsed sections, and pending TUI confirmations.

Summary

Functions

Clamps cursor position to the current flattened entry list.

Clears pending discard confirmation state.

Returns the flattened row at the current cursor.

Returns the flattened rows rendered by the TUI sidebar.

Builds initial TUI view state.

Moves the cursor to the next visible row.

Moves the cursor to the next section header.

Moves the cursor to the previous visible row.

Moves the cursor to the previous section header.

Clamps cursor position after the shared git entry list changes.

Stores the pending destructive discard confirmation.

Returns the selected file entry, if the cursor is on a file row.

Toggles the currently selected section when the cursor is on a section header.

Types

discard_confirmation()

@type discard_confirmation() :: {Minga.Git.StatusEntry.t(), String.t()} | nil

flat_entry()

@type flat_entry() ::
  {:section_header, atom(), non_neg_integer()}
  | {:file, atom(), Minga.Git.StatusEntry.t()}

t()

@type t() :: %MingaEditor.GitStatus.TUIState{
  collapsed: %{required(atom()) => true},
  cursor_index: non_neg_integer(),
  discard_confirmation: discard_confirmation()
}

Functions

clamp_cursor(tui, entries)

@spec clamp_cursor(t(), [Minga.Git.StatusEntry.t()]) :: t()

Clamps cursor position to the current flattened entry list.

clear_discard_confirmation(tui)

@spec clear_discard_confirmation(t()) :: t()

Clears pending discard confirmation state.

current_entry(tui, entries)

@spec current_entry(t(), [Minga.Git.StatusEntry.t()]) :: flat_entry() | nil

Returns the flattened row at the current cursor.

flat_entries(tui, entries)

@spec flat_entries(t(), [Minga.Git.StatusEntry.t()]) :: [flat_entry()]

Returns the flattened rows rendered by the TUI sidebar.

new()

@spec new() :: t()

Builds initial TUI view state.

next(tui, entries)

@spec next(t(), [Minga.Git.StatusEntry.t()]) :: t()

Moves the cursor to the next visible row.

next_section(tui, entries)

@spec next_section(t(), [Minga.Git.StatusEntry.t()]) :: t()

Moves the cursor to the next section header.

prev(tui)

@spec prev(t()) :: t()

Moves the cursor to the previous visible row.

prev_section(tui, entries)

@spec prev_section(t(), [Minga.Git.StatusEntry.t()]) :: t()

Moves the cursor to the previous section header.

refresh(tui, entries)

@spec refresh(t(), [Minga.Git.StatusEntry.t()]) :: t()

Clamps cursor position after the shared git entry list changes.

request_discard(tui, entry, git_root)

@spec request_discard(t(), Minga.Git.StatusEntry.t(), String.t()) :: t()

Stores the pending destructive discard confirmation.

selected_file(tui, entries)

@spec selected_file(t(), [Minga.Git.StatusEntry.t()]) ::
  Minga.Git.StatusEntry.t() | nil

Returns the selected file entry, if the cursor is on a file row.

toggle_current_section(tui, entries)

@spec toggle_current_section(t(), [Minga.Git.StatusEntry.t()]) :: t()

Toggles the currently selected section when the cursor is on a section header.