Help us shape the future of Go! Take the 2026 Go Developer Survey

view

package
v0.38.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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.

View Source
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 Key

func Key(b protocol.Binding) string

Key is what makes two bindings the same fetch.

func Kind

func Kind(n protocol.Node) string

func Parse

func Parse(n *yaml.Node) (protocol.Node, error)

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 }.

func Prop

func Prop(n protocol.Node, k string) string

Prop is a string prop, or "".

func Supported

func Supported(n protocol.Node) bool

Supported reports whether rig renders n's widget at the version it asks for (calendar@2).

func Walk

func Walk(n *protocol.Node, fn func(*protocol.Node))

Walk calls fn on n and every node under it, depth first.

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.

func (*Fetcher) Fresh

func (f *Fetcher) Fresh(b protocol.Binding) bool

Fresh says whether b's cached frame is still inside its TTL, so asking again would not fetch.

func (*Fetcher) Get

Get is b's frame from the cache while fresh, else fetched once for every caller waiting on it.

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.

func (*View) Load

func (v *View) Load(raw []byte) error

Load reads a view's file: a node, or a whole view whose layout replaces v's.

func (*View) UnmarshalYAML

func (v *View) UnmarshalYAML(n *yaml.Node) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL