Documentation
¶
Overview ¶
Package decl runs a golib QML program (tui/decl) as an AutoDoc card or dialog (ADR 1792254331 §4.7–4.10): the program runs inside the plugin on a backend of its own, and every frame it draws is sent to AutoDoc as host.frame. The host never sees QML; the wire is unchanged.
c := decl.New(decl.Options{
Program: []tuidecl.ProgramOption{
tuidecl.LayoutSource("card.qml", layout),
tuidecl.Singleton("hello", "1.0", "App"),
tuidecl.Sources(map[string]any{"App.status": "ready"}),
},
})
_ = plugin.Serve(ctx, c)
The layout binds its palette to Theme, which this package declares (module autodoc.plugin 1.0) and keeps to AutoDoc's theme:
import tui 1.0
import autodoc.plugin 1.0
Window { palette.window: Theme.app.window; palette.windowText: Theme.app.windowText … }
The program's state changes on its loop only: Options.Setup before the first frame, then Card.Post. Esc never reaches the program: AutoDoc keeps it to close or hide the card.
Index ¶
- type Card
- func (c *Card) Close()
- func (c *Card) Err() error
- func (c *Card) Focus(focused bool)
- func (c *Card) Hide()
- func (c *Card) Key(k plugin.Key)
- func (c *Card) Open(p *plugin.Peer, o plugin.Open)
- func (c *Card) Pointer(at plugin.Pointer)
- func (c *Card) Post(fn func()) bool
- func (c *Card) Program() *tuidecl.Program
- func (c *Card) Resize(w, h int)
- func (c *Card) Show()
- func (c *Card) Theme(t plugin.Theme)
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Card ¶
type Card struct {
// contains filtered or unexported fields
}
Card is a QML program as a plugin.Handler. It is also a Focuser, a PointerHandler and a Hider; a plugin wanting commands, the document feed or tables embeds *Card and adds them.
func (*Card) Close ¶
func (c *Card) Close()
Close is plugin.close, or the host gone: the program is stopped, and Close returns once Run has (cancelling is not finishing: only done says Run returned). A teardown that hangs is cut off at closeWait and logged, below the two seconds AutoDoc waits before it stops the process.
func (*Card) Focus ¶
Focus is plugin.focus: the card took AutoDoc's keys, or gave them back, as a terminal's focus.
func (*Card) Hide ¶
func (c *Card) Hide()
Hide and Show change nothing: the program runs on, unseen, as a hidden card does.
func (*Card) Open ¶
Open is plugin.open: the program is built at the size and in the theme AutoDoc gives, set up, and run on a goroutine of its own.
func (*Card) Pointer ¶
Pointer is plugin.pointer: a left press (a press and its release), or wheel steps.
func (*Card) Post ¶
Post queues fn for the program's loop and returns true while it runs; before Open, after a failed Open and once stopped it drops fn and returns false. A queued fn runs only if the Card is still live when the loop reaches it: one queued before Close is skipped after it.
type Options ¶
type Options struct {
Program []tuidecl.ProgramOption // the layout, singletons, sources, commands, handlers
// Setup runs once, on the Handler goroutine inside Open, after the program is built and before
// it runs: no loop exists yet, so it may Set sources and reach widgets directly. The first
// frame shows what it set. An error is a failed Open. nil: no setup.
Setup func(p *tuidecl.Program, host *plugin.Peer) error
Modal bool // a modal dialog: always focused, since AutoDoc sends it no plugin.focus
}
Options are a Card's program and its start.