Documentation
¶
Overview ¶
Package view turns view specs into renderer-neutral widget trees, fetches the frames widgets bind to and transforms them. The TUI draws the trees; a web renderer could draw the same ones.
Index ¶
- Variables
- func Apply(f *protocol.Frame, ops any, ...) (*protocol.Frame, error)
- func Key(b protocol.Binding) string
- func Kind(n protocol.Node) string
- func Parse(n *yaml.Node) (protocol.Node, error)
- func Prop(n protocol.Node, k string) string
- func Supported(n protocol.Node) bool
- func Walk(n *protocol.Node, fn func(*protocol.Node))
- type Fetcher
- type View
Constants ¶
This section is empty.
Variables ¶
var Layouts = map[string]bool{"grid": true, "split": true, "tabs": true, "stack": true, "box": true, "scroll": true}
Layouts are the widgets that hold other widgets.
var Widgets = map[string]int{
"table": 1, "list": 1, "kv": 1, "tree": 1, "form": 1, "stat": 1, "gauge": 1, "progress": 1, "bar": 1, "bars": 1,
"sparkline": 1, "chart": 1, "heatmap": 1, "text": 1, "markdown": 1, "code": 1, "diff": 1, "logs": 1,
"waterfall": 1, "graph": 1, "timeline": 1, "board": 1, "terminal": 1, "canvas": 1, "calendar": 1,
}
Kind is a node's widget without its version: table@1 is table. Widgets are the widgets rig renders and the highest version of each; plugins learn them at initialize.
Functions ¶
func Apply ¶
func Apply(f *protocol.Frame, ops any, other func(protocol.Binding) (*protocol.Frame, error)) (*protocol.Frame, error)
Apply runs a node's transform: ops in order, each one of filter, sort, limit, select, rename, group or join. join fetches the other frame through other.
func Parse ¶
Parse reads a widget node: { widget: table, source: db, query: ..., ...props }, or a layout shorthand such as { grid: [[a, b], [c]] }, { tabs: { Name: node } } or { box: node, title: T }.
Types ¶
type Fetcher ¶
type Fetcher struct {
Query func(ctx context.Context, source string, args protocol.Args) (*protocol.Frame, error)
// TTL is how long a frame stays fresh when the binding gives no every:.
TTL time.Duration
// contains filtered or unexported fields
}
Fetcher shares fetches: one request per distinct source and args however many widgets bind to it, a TTL per binding, and backoff after errors. Renderers ask only for what is visible and cancel with the context when it hides.
func (*Fetcher) Forget ¶
func (f *Fetcher) Forget()
Forget drops cached frames so the next Get fetches again, as a manual refresh does.
type View ¶
type View struct {
Title string
// Slot is tab, command, subtab:<view>, service.section, detail:<scheme>, panel or home.
Slot string
// Command is the palette command that opens a view of slot command: slot: { command: usage }
Command string
Key string
// File holds the layout instead, relative to the file that declares the view.
File string
// Modes are the UI modes that show the view (software, product); none shows it in every mode.
Modes []string
Root protocol.Node
}
View is one entry under views: in rig.yaml or a plugin manifest.