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

decl

package
v0.3.3 Latest Latest
Warning

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

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

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

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 New

func New(o Options) *Card

New is a Card that runs the program o describes when AutoDoc opens it.

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) Err

func (c *Card) Err() error

Err is what Run returned; nil while it runs.

func (*Card) Focus

func (c *Card) Focus(focused bool)

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) Key

func (c *Card) Key(k plugin.Key)

Key is plugin.key, as the terminal would have sent it.

func (*Card) Open

func (c *Card) Open(p *plugin.Peer, o plugin.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

func (c *Card) Pointer(at plugin.Pointer)

Pointer is plugin.pointer: a left press (a press and its release), or wheel steps.

func (*Card) Post

func (c *Card) Post(fn func()) bool

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.

func (*Card) Program

func (c *Card) Program() *tuidecl.Program

Program is the running program; nil before Open and after a failed one.

func (*Card) Resize

func (c *Card) Resize(w, h int)

Resize is plugin.resize: the size Size answers moves, and the App takes it on its loop; the grid follows in FlushSized (§4.8).

func (*Card) Show

func (c *Card) Show()

func (*Card) Theme

func (c *Card) Theme(t plugin.Theme)

Theme is plugin.theme: the Theme.* sources move, and every palette bound to them follows.

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.

Jump to

Keyboard shortcuts

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