class

TUI::ArrayDetailSource(T)

Inherits TUI::DetailDataSource < Reference < Object

Generic DetailDataSource over an in-memory Array(T), id-keyed by a single string-valued property — the direct Detail-side analog of ArrayTableSource(T) for TableDataSource. Simpler than ArrayTableSource since DetailDataSource has no filter/sort/size/reload contract to replicate — just "given an id and the current toggle state, produce label/value rows."

Constructors

new(all : Array(T), id_key : T -> String, lines : T -> Array(DetailLine), toggle_lines : Hash(Symbol, T -> Array(DetailLine)) = {} of Symbol => (T -> Array(DetailLine)), toggle_labels : Hash(Symbol, String) = {} of Symbol => String)
Source

Instance methods

lines(id : String, expansions : Set(Symbol)) : Array(DetailLine)
Source
title(id : String) : String
Source
toggle_label(sym : Symbol) : String

Human label for the toggle key bound to sym (e.g. "dependents" for :rdeps) — drives DetailView's status hint, so the letters shown to the user and the letters that actually work can never drift.

Source
toggles
Source

Macros

define(name, model_type, all, &block)

Block-DSL sugar over ArrayDetailSource(T) construction — the Detail-side analog of TUI::Form.define (same "auto-assign the built value straight to a caller-named constant" shape), not of ArrayTableSource.define. Unlike ArrayTableSource, a single ArrayDetailSource instance has no independent per-page state (no filter, no sort, no swapped-in data) — one shared instance covers every consumer, so there's no need for ArrayTableSource.define's named-builder-class indirection (that indirection exists there solely because Crystal disallows declaring a class inside a def body, and Table view/Split window each need their own independent ArrayTableSource instance — neither constraint applies here).

TUI::ArrayDetailSource.define(PACKAGE_DETAIL_SOURCE, Package, FAKE_PACKAGES) do id_key :name line :name, "Name" line :size_mb, "Size", suffix: " MB" toggle :description, "description" do line :description, "Description" end end

all is an ordinary (non-block) macro argument — the data array must already exist as a top-level constant by the time this call executes textually.

Source