Documentation
¶
Index ¶
- Constants
- func BindingHints(r *Runtime, focus string) string
- func Call(ctx context.Context, path string, q Request) (any, error)
- func ComposeModal(background, title, body, footer string, width, height int, styles Styles) string
- func InputView(in *Input, width, height int) string
- func IntArg(a Arguments, name string, fallback int) int
- func JSONPointer(value any, path string) (any, error)
- func JobsTicker(jobs []JobInfo, width int) []string
- func ModalSize(width, height int) (contentWidth, contentHeight int)
- func PanelContentSize(width, height int) (int, int)
- func RegisterInputOperations(r *Runtime)
- func StringArg(a Arguments, name, fallback string) string
- type Align
- type AppHandler
- type Appearance
- type Arguments
- type Binding
- func (b Binding) Captured() Binding
- func (b Binding) FromKey(arg string) Binding
- func (b Binding) FromPayload(arg, source string) Binding
- func (b Binding) Guard(name string) Binding
- func (b Binding) Hide() Binding
- func (b Binding) Hinted(text string) Binding
- func (b Binding) Join(arg string, sources ...string) Binding
- type BindingTimeoutMsg
- type Block
- type CallMsg
- type Choice
- type Column
- type Completion
- type Component
- type Context
- type Ctx
- type EditNode
- type FocusTargeter
- type Footer
- type Guard
- type Handler
- type Header
- type HelpRow
- type HistoryContext
- type HistoryEntry
- type HistoryResult
- type Input
- type Instance
- type InstanceOption
- type JobInfo
- type JobLingerMsg
- type KeyEvent
- type Layout
- func (l Layout) BodySize() (width, height int)
- func (l Layout) BodySizeWith(f Footer) (width, height int)
- func (l Layout) Page(title, subtitle, body, footer string) string
- func (l Layout) PageBlock(title, subtitle string, body Block, footer string) Block
- func (l Layout) Panel(title, body string, width, height int, focused bool) string
- func (l Layout) PanelBlock(title string, body Block, width, height int, focused bool) Block
- func (l Layout) Shell(h Header, body Block, f Footer) Block
- func (l Layout) Sidebar(title string, items []string, selected int, mainTitle, mainBody string) string
- func (l Layout) SidebarBlock(title string, items []string, selected int, mainTitle string, mainBody Block) Block
- func (l Layout) Split(leftTitle, leftBody, rightTitle, rightBody string) string
- func (l Layout) SplitBlock(leftTitle string, leftBody Block, rightTitle string, rightBody Block) Block
- type Lines
- type List
- func (l *List) Columns() []Column
- func (l *List) Focus() error
- func (l *List) FocusTarget() string
- func (l *List) Focused() bool
- func (l *List) Items() []ListItem
- func (l *List) Len() int
- func (l *List) Marked() []ListItem
- func (l *List) Move(delta int)
- func (l *List) Select(id string) error
- func (l *List) Selected() (ListItem, bool)
- func (l *List) SetColumns(cols ...Column)
- func (l *List) SetItems(items []ListItem) error
- func (l *List) Snapshot() map[string]any
- func (l *List) ToggleMark(id string) error
- func (l *List) View(width, height int) string
- type ListItem
- type MacroKey
- type MacroState
- type ModalOption
- type ModalView
- type ModeBuilder
- func (m *ModeBuilder) Bind(keys string, row Binding) *ModeBuilder
- func (m *ModeBuilder) Extends(parent string) *ModeBuilder
- func (m *ModeBuilder) Pattern(pattern string, row Binding) *ModeBuilder
- func (m *ModeBuilder) Unbind(keysOrPattern string) *ModeBuilder
- func (m *ModeBuilder) When(guard string) *ModeBuilder
- type ModeObserver
- type ModeState
- type Model
- type Noun
- type NounBuilder
- func (b *NounBuilder) Action(key string, h Handler) *NounBuilder
- func (b *NounBuilder) Columns(cols ...Column) *NounBuilder
- func (b *NounBuilder) Confirm(prompt string) *NounBuilder
- func (b *NounBuilder) Focusable() *NounBuilder
- func (b *NounBuilder) Mode(mode string) *ModeBuilder
- func (b *NounBuilder) Motion() *NounBuilder
- func (b *NounBuilder) Noun() *Noun
- func (b *NounBuilder) Pin(mode string) *NounBuilder
- func (b *NounBuilder) Positional(names ...string) *NounBuilder
- func (b *NounBuilder) Quiet() *NounBuilder
- func (b *NounBuilder) Region() *NounBuilder
- func (b *NounBuilder) Rows(noun string) *NounBuilder
- func (b *NounBuilder) State() *NounBuilder
- func (b *NounBuilder) Verb(verb string, h any, description ...string) *NounBuilder
- func (b *NounBuilder) Verbs(verbs ...string) *NounBuilder
- func (b *NounBuilder) When(guard string) *NounBuilder
- type Operation
- type Page
- type Palette
- func (p *Palette) Close()
- func (p *Palette) HandleKey(key string) (bool, error)
- func (p *Palette) IsActive() bool
- func (p *Palette) IsOpen() bool
- func (p *Palette) Open() error
- func (p *Palette) RegisterNoun(noun string, config PaletteNoun) error
- func (p *Palette) Text() string
- func (p *Palette) View() string
- func (p *Palette) ViewSized(width, height int) string
- type PaletteEntry
- type PaletteInstance
- type PaletteNoun
- type PaletteSource
- type PaletteWord
- type Parameter
- type Payload
- type Picker
- type PickerEntry
- type Placement
- type Pos
- type Predicate
- func AllOf(of ...Predicate) Predicate
- func AnyOf(of ...Predicate) Predicate
- func ByID(id string) Predicate
- func ByKind(kind string) Predicate
- func ByNoun(noun string) Predicate
- func ChildOf(id string) Predicate
- func InState(mode string) Predicate
- func IsFocusable() Predicate
- func IsRegion() Predicate
- func Not(of ...Predicate) Predicate
- func ParsePredicates(v any) ([]Predicate, error)
- func Where(name, arg string) Predicate
- func Within(id string) Predicate
- type PredicateFunc
- type QueryMatch
- type Register
- type Registers
- type Request
- type Response
- type Result
- type Runtime
- func (r *Runtime) Accepts(t Ticket) bool
- func (r *Runtime) ActionFor(focus, key string) Handler
- func (r *Runtime) AddInput(in *Input, opts ...InstanceOption) error
- func (r *Runtime) AddList(id string, items []ListItem, opts ...InstanceOption) (*List, error)
- func (r *Runtime) AddPage(id, title string, render func(*Runtime, int, int) Block, ...) (*Page, error)
- func (r *Runtime) AddTerminal(id string, stream TerminalStream, opts ...InstanceOption) (*Terminal, error)
- func (r *Runtime) AddTree(id string, nodes []TreeNode, opts ...InstanceOption) (*Tree, error)
- func (r *Runtime) Ancestry(id string) []string
- func (r *Runtime) BaseFocus() string
- func (r *Runtime) BaseMode() string
- func (r *Runtime) Bind(rows ...Binding) error
- func (r *Runtime) BindingTimeoutCommand() tea.Cmd
- func (r *Runtime) CancelPendingBinding()
- func (r *Runtime) Catalog() []Operation
- func (r *Runtime) Children(id string) []*Instance
- func (r *Runtime) Choices(c Context, p Parameter) ([]Choice, error)
- func (r *Runtime) Context() Context
- func (r *Runtime) Define(name string) *NounBuilder
- func (r *Runtime) DefineGuard(name string, fn Guard)
- func (r *Runtime) DefineMode(name string, pending bool) error
- func (r *Runtime) DefinePassthrough(name string) error
- func (r *Runtime) Deliver(msg tea.Msg) (bool, error)
- func (r *Runtime) Dispatch(key MacroKey) (bool, error)
- func (r *Runtime) Execute(q Request) (any, error)
- func (r *Runtime) ExecuteAt(c Context, q Request) (any, error)
- func (r *Runtime) HandleBinding(key string) (bool, error)
- func (r *Runtime) HandleBindingTimeout(msg BindingTimeoutMsg) (bool, error)
- func (r *Runtime) HandleCall(msg CallMsg)
- func (r *Runtime) History(n int) []HistoryEntry
- func (r *Runtime) Input(id string) *Input
- func (r *Runtime) Inputs() []*Input
- func (r *Runtime) Instance(id string, opts ...InstanceOption) *Instance
- func (r *Runtime) InstancePath(id string) []string
- func (r *Runtime) Issue(owner, verb, slot string, c Ctx) (Ticket, context.Context, error)
- func (r *Runtime) IssueAt(owner, scope, verb, slot string, c Ctx) (Ticket, context.Context, error)
- func (r *Runtime) Jobs() []JobInfo
- func (r *Runtime) JumpFocus(steps int, scope string) error
- func (r *Runtime) Launch(owner, verb string, res Result, c Ctx) (Ticket, error)
- func (r *Runtime) List(id string) *List
- func (r *Runtime) ListBindings(focus string) []Binding
- func (r *Runtime) Lists() []*List
- func (r *Runtime) LoadBindingSpec(noun string, data []byte) error
- func (r *Runtime) LoadBindings(data []byte) ([]Binding, error)
- func (r *Runtime) ModalFocus(id string) string
- func (r *Runtime) Modals() []*Instance
- func (r *Runtime) Noun(name string) *Noun
- func (r *Runtime) OpenModal(kind string, payload Payload, opts ...ModalOption) (*Instance, error)
- func (r *Runtime) OpenPage(id string) error
- func (r *Runtime) PageFocus(id string) string
- func (r *Runtime) PageList() []*Page
- func (r *Runtime) PageOf(id string) *Page
- func (r *Runtime) PendingCommands() tea.Cmd
- func (r *Runtime) Placed(id string)
- func (r *Runtime) PlacedAt(id, text string, focus, height int) string
- func (r *Runtime) Pop() error
- func (r *Runtime) Push(id, focus string) error
- func (r *Runtime) Query(preds ...Predicate) []*Instance
- func (r *Runtime) ReadYank(register string) (Yank, error)
- func (r *Runtime) Register(o Operation)
- func (r *Runtime) RegisterPage(page *Page, opts ...InstanceOption) error
- func (r *Runtime) RegisterPredicate(name string, fn PredicateFunc)
- func (r *Runtime) Registers() *Registers
- func (r *Runtime) RemoveInstance(id string) error
- func (r *Runtime) RetargetFocus(match func(id string) bool, to string)
- func (r *Runtime) SetConfirm(key, prompt string) error
- func (r *Runtime) SetFocus(id string) error
- func (r *Runtime) SetMode(mode string) error
- func (r *Runtime) Settle(t Ticket, err error) bool
- func (r *Runtime) Snapshot() map[string]any
- func (r *Runtime) Sourced(source string) (restore func())
- func (r *Runtime) Start(owner string, work func(context.Context) (any, error), ...) (Ticket, error)
- func (r *Runtime) StoreYank(y Yank, register string, deletion bool) error
- func (r *Runtime) Terminal(id string) *Terminal
- func (r *Runtime) TopModal() string
- func (r *Runtime) Tree(id string) *Tree
- func (r *Runtime) ValidateBindings() ([]string, error)
- func (r *Runtime) VerbGuard(key string) string
- func (r *Runtime) VerbShown(key, focus string, mode ModeState) bool
- type Server
- type Styles
- type Terminal
- func (t *Terminal) Close()
- func (t *Terminal) Err() string
- func (t *Terminal) Focused() bool
- func (t *Terminal) Frame() TerminalFrame
- func (t *Terminal) HandleMessage(msg tea.Msg) bool
- func (t *Terminal) ID() string
- func (t *Terminal) PendingCommand() tea.Cmd
- func (t *Terminal) Size() (cols, rows int)
- func (t *Terminal) View(width, height int) string
- func (t *Terminal) ViewBlock(width, height int) Block
- type TerminalFrame
- type TerminalReleaser
- type TerminalStream
- type Ticket
- type Tree
- func (t *Tree) Block(width, height int) Block
- func (t *Tree) Close()
- func (t *Tree) CollapseAll() error
- func (t *Tree) Collapsed(id string) bool
- func (t *Tree) DebounceCurrent(tick TreeDebounceMsg) bool
- func (t *Tree) Editable() bool
- func (t *Tree) Editing() string
- func (t *Tree) Failure() error
- func (t *Tree) Flush() error
- func (t *Tree) Focus() error
- func (t *Tree) FocusTarget() string
- func (t *Tree) HandleMessage(msg tea.Msg) bool
- func (t *Tree) ID() string
- func (t *Tree) List() *List
- func (t *Tree) Nodes() []TreeNode
- func (t *Tree) PendingCommand() tea.Cmd
- func (t *Tree) Select(id string) error
- func (t *Tree) Selected() (TreeNode, bool)
- func (t *Tree) SetCollapsed(id string, collapsed bool) error
- func (t *Tree) SetNodes(nodes []TreeNode) error
- func (t *Tree) View(width, height int) string
- type TreeChange
- type TreeDebounceMsg
- type TreeNode
- type Yank
Examples ¶
Constants ¶
const ( JobRunning = "running" JobDone = "done" JobFailed = "failed" JobCancelled = "cancelled" )
Job states as jobs.list and the snapshot report them.
const ( KindInteraction = "interaction" // runs synchronously on the loop (default) KindApplication = "application" // an AppHandler; pending work runs off the loop )
Operation kinds.
const ( SourceKey = "key" SourceDigit = "digit" SourceText = "text" SourceCount = "count" SourceLine = "line" SourceSteps = "steps" SourceOp = "op" SourceOpCount = "opcount" SourcePrefix = "prefix" )
Sources a From entry may name: "key" (the key name), "digit" (the key as an integer), "text" (pasted or typed text), "count" (payload count, at least 1), "line" (payload count, 0 when absent, else the operator count), "steps" (count times operator count), "op" (payload operator), "opcount", "prefix" (the key sequence the pending mode holds). A From value may name several sources separated by spaces ("prefix key"): their texts are joined with a space, the way terminal.send reads a key list.
const ( Digit = "digit" Alpha = "alpha" Printable = "printable" Paste = "paste" Any = "any" )
Pattern names.
const ( TreeAdd = "add" TreeRename = "rename" TreeMove = "move" TreeDelete = "delete" )
Tree change operations.
const CancelKey = "esc"
CancelKey is the key every key-sequence prefix answers with mode.leave: a default row "<prefix> esc" is kept in each table that binds a sequence, so Escape cancels a pending prefix without running anything and the resolver never names a key.
const DefaultBindingTimeout = 1000 * time.Millisecond
DefaultBindingTimeout is how long a pending multi-key binding waits for its next key.
const DefaultTreeDebounce = 400 * time.Millisecond
DefaultTreeDebounce is how long typing in an outline line pauses before the line is written.
const HistoryLimit = 500
HistoryLimit bounds the action history ring.
const JobLinger = 4 * time.Second
JobLinger is how long a finished job stays on the ticker after the frame that first saw it finished. The Model schedules one JobLingerMsg for the earliest remembered finish (Model.lingerCommand), so the row goes on an idle screen; any earlier frame past the deadline drops it too, and a newer job can push it off sooner.
const JobTickerRows = 2
JobTickerRows is the most rows the jobs ticker takes above the footer.
const MovementSection = "movement"
MovementSection is the help section that holds every motion, after the app's rows.
const TreeRowNoun = "outline-row"
TreeRowNoun is the noun of a node that names none: enter toggles it.
Variables ¶
This section is empty.
Functions ¶
func BindingHints ¶
BindingHints renders the rows a focus answers to in its current mode as a hint line, from the innermost level outward (the focused instance's rows, its noun's, then its parents' up to the page and app): "enter demo.open · : palette.open · ? bindings.help". Motions (Operation.Motion) and hidden rows (counts, registers, macros, ctrl+c) are left to ? help, and of rows that run the same request only the first (innermost) key is shown. It is the data bindings.list prints, so a hint never names a key that is not bound; the descriptions are in BindingHelp (the ? modal).
func ComposeModal ¶
ComposeModal centers a content-sized panel over the existing page, not a blank screen. Body and backdrop may contain trusted ANSI; title and footer are raw labels.
func InputView ¶
InputView renders an input's visible text without a cursor, for inputs that are not focused. See InputBlock.
func JobsTicker ¶
JobsTicker renders ticker rows: one message per row, "noun.verb state", with ": error" on a failure, truncated to width.
func ModalSize ¶
ModalSize returns safe body bounds, reserving the same chrome as ComposeModal. Modal chrome uses one horizontal padding cell regardless of page density.
func PanelContentSize ¶
PanelContentSize returns the body cells available inside a Panel, excluding its border and horizontal padding. Tiny panels omit their chrome.
func RegisterInputOperations ¶
func RegisterInputOperations(r *Runtime)
Types ¶
type Align ¶
type Align string
Align is a column's alignment: AlignLeft (the zero value) or AlignRight.
type AppHandler ¶
AppHandler is the signature of an application verb: it reads the Ctx and returns Done, Failed or Pending work. Pending work runs off the loop; its completion is delivered to the owning instance through the contract, so a handler never blocks key handling.
type Appearance ¶
type Appearance struct {
Theme string `json:"theme"`
Density string `json:"density"`
Dark bool `json:"dark"`
}
Appearance is event-loop-owned configuration. Operation results are value snapshots. Dark is the terminal background reported by tea.BackgroundColorMsg; the adaptive theme assumes a dark background until that message arrives.
func NewAppearance ¶
func NewAppearance(r *Runtime) *Appearance
NewAppearance registers appearance operations once per runtime.
type Arguments ¶
Arguments are a request's named arguments, keyed by parameter name.
func ParseArguments ¶
ParseArguments parses the same JSON object used by the wire API.
type Binding ¶
type Binding struct {
Noun string `json:"noun,omitempty"`
Instance string `json:"instance,omitempty"`
Mode string `json:"mode,omitempty"`
Keys string `json:"keys,omitempty"`
Pattern string `json:"pattern,omitempty"`
Request Request `json:"request"`
From map[string]string `json:"from,omitempty"`
When string `json:"when,omitempty"`
Unbind bool `json:"unbind,omitempty"`
Replay bool `json:"replay,omitempty"`
Capture bool `json:"capture,omitempty"`
// Hint replaces "noun.verb: description" in the footer and the help
// for a row whose operation says nothing useful on its own (the
// terminal leader's mode.enter); bindings list carries it too.
Hint string `json:"hint,omitempty"`
// Hidden keeps the row off the footer's hint line (counts, registers,
// macros, ctrl+c); ? help and bindings list still show it.
Hidden bool `json:"hidden,omitempty"`
}
Binding is one row of a mode table, identical in code and config: {noun | instance, mode, keys | pattern, request | null, from, when}. Keys is an exact key or a space-separated sequence ("g g"); Pattern is a key class: digit, alpha, printable, paste, any, a class minus keys ("alpha-q"), or a set ("one-of:h j k l"). From fills request arguments from the key or the mode payload (see Sources). When names a registered guard. Unbind removes the default row with the same mode and keys or pattern. Replay dispatches the key again, fresh, after the row ran (a pending mode that hands an unknown key back to the stack). Capture rows are consulted outer-first (app first) before the inner-first walk (see resolve.go).
A row is atomic: a Request (one registered operation, its arguments from the row, the key or the payload), a mode transition (Enter, Leave) or an unbind. There is no row that runs Go code with the key. Composite behaviour is an operation whose handler calls other operations through Execute (macro.record, terminal.paste under the leader); a condition is a named guard. TestBindingRowsAreAtomic pins this for every table.
func Enter ¶
Enter builds a row that enters a pending mode with a typed payload: the operator fields (Op, Count, OpCount) and, for a leader, Prefix (the key sequence the mode holds, which arms the sequence timer) and Request (what the timer runs when no second key arrives).
func Leave ¶
func Leave() Binding
Leave builds a row that returns from a pending mode to the mode it shadowed.
func (Binding) Captured ¶
Captured marks a row as a capture row: consulted outer-first before the inner-first walk (config field "capture").
func (Binding) FromPayload ¶
FromPayload fills an argument from the mode payload (a Source name).
func (Binding) Hide ¶
Hide keeps the row off the footer (config field "hidden"); ? help and bindings list still show it.
type BindingTimeoutMsg ¶
type BindingTimeoutMsg struct {
// contains filtered or unexported fields
}
BindingTimeoutMsg resolves a pending key sequence on the owning event loop. Messages from an older sequence or another runtime are ignored.
type Block ¶
Block is the result of rendering. Text is trusted ANSI. Cursor is where the focused input's cursor sits inside Text, or nil when the block holds no focused input. Only the innermost focused component supplies a cursor; composers move it by where they placed the child and never invent one.
func ComposeModalBlock ¶
func ComposeModalBlock(background, title string, body Block, footer string, width, height int, styles Styles) Block
ComposeModalBlock is ComposeModal for a body that may carry a cursor. The result's cursor is the body's, moved to where the panel placed it; the backdrop never contributes one because a modal covers whatever it held.
func InputBlock ¶
InputBlock renders width x height cells of an input around its cursor and reports where the cursor sits, without changing text or editing state. Visual selections are painted in reverse video; the cursor itself is left to the terminal, so compose this block only for the focused input.
func (Block) Clip ¶
Clip drops a cursor that fell outside a width x height cell area whose top-left corner is the block's origin, as when a composer clipped the child.
type Choice ¶
Choice is one value a parameter accepts: ID is the argument value, Label what a pick list shows.
func ParseChoices ¶
ParseChoices reads a source operation's result: []string, []Choice, []PaletteInstance, []map with "id" and optional "label", or []any of strings or such maps (the JSON-decoded form).
type Column ¶
type Column struct {
Title string `json:"title"`
Width int `json:"width,omitempty"`
Min int `json:"min,omitempty"`
Align Align `json:"align,omitempty"`
Priority int `json:"priority,omitempty"`
}
Column is one column of a table. Width fixes the column's cells (0: a flexible column, as wide as its widest cell or title when there is room); Min is a flexible column's least width before columns drop (default: 10 cells or its title's width when wider, at most its widest cell or title). Priority orders dropping when the width is short: the column with the largest Priority drops first, ties the rightmost first; 0, the default, is the most important, and the last column left never drops (it is cut instead).
type Completion ¶
Completion is the message off-loop work sends back. It is delivered to the owning instance only while its ticket is current.
type Component ¶
Component is the delivery contract every instance that works off the loop implements through Instance.Component. HandleMessage applies a result on the loop and reports whether the message was for this component; PendingCommand hands the Bubble Tea adapter the work scheduled since the last drain; Close cancels outstanding work and releases anything held. The picker and the registers component are the framework's own; an application adds its own by setting Instance.Component.
type Context ¶
Context is the derived view of a focus: the instance ids from app down to the focused instance (Path), and the focused input when there is one.
type Ctx ¶
Ctx is what an application handler receives: the runtime, the context the request runs in, its arguments and the instance it addresses (id, noun, payload).
type EditNode ¶
type EditNode struct {
Text string `json:"text"`
Cursor int `json:"cursor"`
Parent int `json:"parent"`
Children []int `json:"children"`
}
EditNode is one state in an input's undo tree: its text, cursor, parent and children.
type FocusTargeter ¶
type FocusTargeter interface {
FocusTarget() string
}
FocusTargeter is a component that knows where focus lands inside it: a list on its selected row, a grid on its cursor cell.
type Footer ¶
type Footer struct {
}
Footer is the bottom row of the page chrome: a raw label, styled as an error when Error is set. Jobs are the jobs ticker's rows (Model.JobsTicker), drawn above the rule over the footer; the body gives up one row per job row, so no jobs means no rows.
type Guard ¶
Guard is a named condition a row requires. The built-in guards are "input" and "no-input" (the focus is or is not an input), "multiline", "count" and "no-count" (the pending count is present or absent), "self" (the focus is the instance whose level the row sits on, not a descendant), "shadow-idle" (the mode a shadow mode such as macro_recording re-dispatches in is normal with an empty payload) and "op:<key>" (the pending operator). Applications add their own with DefineGuard.
type Header ¶
Header is the top of the page chrome: the title row with an optional right-aligned badge (the shell shows the mode there) and the subtitle row, which is a label or, when Tabs is set, the page tabs with Active marked. Every field is a raw label.
type HelpRow ¶
type HelpRow struct {
Key string `json:"key"`
Operation string `json:"operation"`
Description string `json:"description,omitempty"`
Noun string `json:"noun"`
Section string `json:"section,omitempty"`
}
HelpRow is one binding as the help shows it: the key, the operation it runs (noun.verb, or the row's Hint when it has one), the operation's description, the noun of the level that answers with it, and the help's section: that noun, or "movement" for a motion (Operation.Motion).
func BindingHelp ¶
BindingHelp lists the rows a focus answers to in its current mode with their descriptions, grouped by the noun of the level that answers, from the innermost instance outward (the focused instance's rows, its noun's, its parents' up to the page, then app; a capture row sits with its own level, so app's ctrl+c comes after the focused row's verbs), and the motions of every level last, under "movement".
type HistoryContext ¶
type HistoryContext struct {
Focus string `json:"focus"`
Page string `json:"page,omitempty"`
Mode string `json:"mode"`
Source string `json:"source"`
}
HistoryContext is the interaction state a request ran in. Source is "key:<keys>", "macro:<register>", "palette", "cli" or "api".
type HistoryEntry ¶
type HistoryEntry struct {
Seq uint64 `json:"seq"`
At time.Time `json:"at"`
Request Request `json:"request"`
Context HistoryContext `json:"context"`
Result HistoryResult `json:"result"`
Job uint64 `json:"job,omitempty"`
// Depth is how many requests enclose this one: a request an operation
// runs while it runs (a choices source, a macro's keys) is one deeper.
Depth int `json:"depth,omitempty"`
}
HistoryEntry is one executed request: what ran, where, from which source and how it ended. Value is the result as JSON at the time it ran; Job is the job id an application verb launched.
type HistoryResult ¶
type HistoryResult struct {
OK bool `json:"ok"`
Value json.RawMessage `json:"value,omitempty"`
Error string `json:"error,omitempty"`
}
HistoryResult is the outcome: ok with the value, or the error.
type Input ¶
type Input struct {
ID string
Text []rune
Cursor int
Mode string // the editing mode: normal, insert or a visual mode; pending modes live on the instance
Multiline bool
Kind string
PathFilter string
Anchor int
History []EditNode
Head int
// contains filtered or unexported fields
}
Input is a single- or multi-line modal text field with an undo tree.
func (*Input) Count ¶
Count is the pending Vim count, read from the global mode payload while the input is focused.
func (*Input) Pending ¶
Pending describes the pending editor mode the way the old grammar did: "d" for an operator, "g" for a g prefix, "dg" for both, "register" while a register name is awaited, "" otherwise.
type Instance ¶
type Instance struct {
ID string `json:"id"`
Noun string `json:"noun"`
Parent string `json:"parent,omitempty"`
Payload Payload `json:"payload"`
Bindings []Binding `json:"bindings,omitempty"`
Unfocusable bool `json:"unfocusable,omitempty"`
Label string `json:"label,omitempty"` // a display name (a list row's label, a header name); {{label}} in a confirm prompt
Data any `json:"data,omitempty"` // an opaque application value (a list row's ListItem.Data)
Component any `json:"-"`
// contains filtered or unexported fields
}
Instance is one addressable thing on screen: a page, a list, a list row, a modal body, or an input. Parent links form the focus stack; walking them from the focused instance outward is the path Context.Path spells out. An instance holds no mode: the mode is global (Runtime.Mode). Payload is the data a modal body carries (a confirm's prompt and request). Bindings are this instance's own rows, resolved above its noun's table at the same stack level. Component holds the typed component the instance fronts. Unfocusable opts the instance out of being a focus stop although its noun is Focusable (a disabled panel). Label is an optional display name a confirm prompt reads as {{label}}. Data is an opaque application value (a list row's ListItem.Data); the framework never reads it.
type InstanceOption ¶
type InstanceOption func(*instanceSpec)
InstanceOption configures the instance constructors: Instance, AddPage, AddList, AddInput, AddTerminal and RegisterPage.
func CloseOnDetach ¶
func CloseOnDetach() InstanceOption
CloseOnDetach makes terminal.detach remove the terminal instance after returning focus, so the stream is released (see TerminalReleaser) instead of kept for a later attach. Only AddTerminal reads it.
func Columns ¶
func Columns(cols ...Column) InstanceOption
Columns makes AddList's list a table with these columns (List.SetColumns changes them later). A list without columns draws its labels.
func Focus ¶
func Focus(id string) InstanceOption
Focus names the instance a page starts focused on (default: the page itself). Other constructors ignore it.
func FocusOnClose ¶
func FocusOnClose(id string) InstanceOption
FocusOnClose names the instance the focus moves to when this instance is removed while the focus is on it or inside it: a CloseOnDetach detach, Pop of a modal body, a list row dropped by SetItems, RemoveInstance. A target that is gone (or removed with it) falls back to the default (the parent, or the return Pop restores). Every constructor reads it.
func Kind ¶
func Kind(noun string) InstanceOption
Kind names the noun the instance answers to (default: the instance id for plain instances, "editor" for inputs, "list" for lists, "page" for pages, "terminal" for terminals).
func NoSpill ¶
func NoSpill() InstanceOption
NoSpill makes a list trap its motions: list.move past its last (first) row stays on that row instead of moving the focus to the next (previous) stop on the page. For a list that must keep the focus, such as a picker.
func Parent ¶
func Parent(id string) InstanceOption
Parent places the instance under another instance (default app).
type JobInfo ¶
type JobInfo struct {
Job uint64 `json:"job"`
Owner string `json:"owner"`
Verb string `json:"verb"`
Slot string `json:"slot,omitempty"`
Scope string `json:"scope,omitempty"`
Started time.Time `json:"started"`
State string `json:"state"`
Error string `json:"error,omitempty"`
}
JobInfo is one row of the jobs list: what jobs.list returns and what the snapshot's /jobs holds for running jobs.
type JobLingerMsg ¶
JobLingerMsg is the ticker's one-shot timer: it fires when the oldest remembered finished job passes JobLinger, so the frame it causes drops the row with no key pressed. At is the deadline it was scheduled for; only the message for the timer in flight clears it.
type KeyEvent ¶
type KeyEvent struct {
Key MacroKey
Mode ModeState
Focus string
Level string // the instance whose level is answering, "" for a noun-only level
}
KeyEvent is what a row receives: the key, the mode it was resolved in and the focused instance.
type Layout ¶
Layout renders page chrome, bounded panels and panel pairs for a viewport. It is a plain value: every method only renders and keeps no state.
Example ¶
layout := Layout{
Width: 80, Height: 24,
Styles: NewStyles(Appearance{Theme: "adaptive"}),
}
body := layout.Split("Files", "main.go\nlayout.go", "Preview", "Selected file contents")
page := layout.Page("Workspace", "Browse files", body, "Enter open · Esc back")
fmt.Print(page)
func (Layout) BodySize ¶
BodySize returns the exact cells available to Page's body. Viewports that cannot hold any body report 0, 0. Small viewports drop the header and keep only a footer row.
func (Layout) BodySizeWith ¶
BodySizeWith is BodySize less the rows the footer's jobs ticker takes (only with the complete chrome; a small viewport draws no ticker).
func (Layout) Page ¶
Page renders title, subtitle, body and footer into exactly Width x Height cells. Body is trusted ANSI; title, subtitle and footer are raw labels. Overlong bodies are clipped; use Panel for a visible overflow marker.
func (Layout) PageBlock ¶
PageBlock is Page for a body that may carry a cursor; the cursor is moved by the page chrome around the body.
func (Layout) Panel ¶
Panel renders a rounded, titled box of exactly width x height outer cells. Focused panels use the heavy accent border. Body is trusted ANSI; title is a raw label. Content that does not fit is clipped and marked with "…" (columns) or a "… N more" last row (lines). Below 3x3 cells the border is dropped.
func (Layout) PanelBlock ¶
PanelBlock is Panel for a body that may carry a cursor; the cursor is moved inside the border and padding.
func (Layout) Shell ¶
Shell is the one page chrome: title row, subtitle row, a rule, the body, a rule, the footer and a bottom margin, inside a gutter, into exactly Width x Height cells. Viewports too small for the chrome keep the body and, from three rows up, the footer. The shell and PageBlock both render through it, so a page and the application around it reserve the same rows. The body's cursor is moved by the chrome around it.
func (Layout) Sidebar ¶
func (l Layout) Sidebar(title string, items []string, selected int, mainTitle, mainBody string) string
Sidebar renders a 28-cell navigation rail beside the main panel. Below 72 columns it stacks above the main panel. Items are raw labels; mainBody is trusted ANSI. Selection is zero-based and clamped for rendering. The caller owns selection and key handling; this method keeps the selected item visible.
Example ¶
layout := Layout{Width: 80, Height: 24, Styles: NewStyles(Appearance{Theme: "adaptive"})}
body := layout.Sidebar("Workspace", []string{"Files", "Search", "Settings"}, 1, "Search", "Search results")
fmt.Print(layout.Page("Project", "Workspace navigation", body, "↑↓ select · Enter open"))
func (Layout) SidebarBlock ¶
func (l Layout) SidebarBlock(title string, items []string, selected int, mainTitle string, mainBody Block) Block
SidebarBlock is Sidebar for a main body that may carry a cursor.
type Lines ¶
type Lines []any
Lines is a result printed as JSON Lines (one compact value per line, no outer array) by a CLI, so a reader can decode it as it arrives; over JSON it is an array. HandleCall keeps the type through its copy.
type List ¶
type List struct {
// contains filtered or unexported fields
}
List owns flat selection, marks and scrolling on the runtime's event loop. Focus sits on the selected row when there is one, else on the list.
func (*List) FocusTarget ¶
FocusTarget is where a focus jump to the list lands: its selected row.
func (*List) Focused ¶
Focused derives focus from the active frame instead of retaining a stale flag.
func (*List) SetColumns ¶
SetColumns replaces the list's columns; none makes it a plain list again.
func (*List) SetItems ¶
SetItems copies rows, preserves selection by ID, and falls back to the nearest remaining index if that ID disappears. Invalid updates leave the list unchanged. It creates one instance per new row under the list and removes the instances of rows that disappear; a retained row keeps its instance and any bindings the application put on it.
func (*List) ToggleMark ¶
ToggleMark marks or unmarks a row for fan-out verbs.
func (*List) View ¶
View fits the viewport and updates its scroll offset to keep selection visible; a list with columns draws as a table (tableView). Calling it places the list in its page's drawing order (Placed), even at zero height, and reports its selected row's line (PlacedAt) so the page scrolls to keep that row on screen.
type ListItem ¶
type ListItem struct {
ID string `json:"id"`
Label string `json:"label"`
Noun string `json:"noun"`
Data any `json:"data,omitempty"`
Cells []string `json:"cells,omitempty"`
}
ListItem is application-owned identity, display text, and the registered noun the row answers to. Each row is an Instance whose ID is the item ID and whose Parent is the list; its bindings and actions come from its noun. Data is an opaque value the application keeps on the row (a host's record of the row, an extension's own id); SetItems copies it to the row instance's Data, where a verb reads it as Ctx.Instance.Data. The framework never reads it. Cells are the row's text per column when the list has columns (a table, Columns); Label stays the row's name for the palette, search and {{label}}, and is the first cell of a row without cells.
type MacroState ¶
type MacroState struct {
Recording string `json:"recording,omitempty"`
Last string `json:"last,omitempty"`
Keys []MacroKey `json:"keys,omitempty"`
Depth int `json:"depth"`
Steps int `json:"steps"`
}
MacroState is the application-wide recording and replay state. Awaiting a register name is the macro_pending or replay_pending mode of the focused instance, not a field here.
type ModalOption ¶
type ModalOption func(*modalSpec)
ModalOption configures OpenModal.
func WithInput ¶
func WithInput(in *Input, opts ...InstanceOption) ModalOption
WithInput places an input inside the modal body and focuses it, so a one-field prompt is one call. The input is registered under the body (a Kind option names its noun; Parent is ignored) and is removed with the body on Pop; the *Input keeps its text and undo history and may be passed again to the next OpenModal.
type ModalView ¶
ModalView renders one modal without replacing or inspecting its parent page. Render receives the modal instance (its Payload carries what OpenModal gave it) and returns the body as a Block; its cursor, when the modal holds the focused input, is relative to the body's top-left cell.
type ModeBuilder ¶
type ModeBuilder struct {
*NounBuilder
// contains filtered or unexported fields
}
ModeBuilder binds rows into one mode table of a noun.
func (*ModeBuilder) Bind ¶
func (m *ModeBuilder) Bind(keys string, row Binding) *ModeBuilder
Bind adds an exact-key (or key-sequence) row, replacing an unguarded row with the same keys.
func (*ModeBuilder) Extends ¶
func (m *ModeBuilder) Extends(parent string) *ModeBuilder
Extends makes the selected mode's table read parent's rows after its own, as the editor spec's "extends" does: three motion tables become one table and two that extend it. A mode extends one parent; Extends("") removes the link.
func (*ModeBuilder) Pattern ¶
func (m *ModeBuilder) Pattern(pattern string, row Binding) *ModeBuilder
Pattern adds a key-class row.
func (*ModeBuilder) Unbind ¶
func (m *ModeBuilder) Unbind(keysOrPattern string) *ModeBuilder
Unbind removes the rows with these keys or this pattern.
func (*ModeBuilder) When ¶
func (m *ModeBuilder) When(guard string) *ModeBuilder
When guards the last bound row with a registered guard name.
type ModeObserver ¶
type ModeObserver interface {
ModeChanged(from, to string)
}
ModeObserver is implemented by a component that follows the base mode while the focus sits on it or beneath it: the grid starts and ends its selection when a visual shape is entered or left.
type Model ¶
type Model struct {
Runtime *Runtime
Palette *Palette
Appearance *Appearance
ModalViews map[string]ModalView
Title string
Width int
Height int
Status string
// Notices are persistent lines (a host's mount warnings): drawn in the
// footer before the hints, kept across keys and errors until notice.clear
// (or the application) clears them. Status is the last key's error and
// goes with the next key; a notice does not.
Notices []string
// Sidebar replaces page tabs with a navigation rail. Existing page operations
// remain the only navigation state; input focus and modal routing are unchanged.
Sidebar bool
// Now is the Model's clock: the ticker's memory of finished jobs and
// the linger timer read it (time.Now by default, time.Now when nil). A
// headless host fakes it, advances it to JobLingerTick's deadline and
// delivers that message instead of waiting JobLinger.
Now func() time.Time
// contains filtered or unexported fields
}
Model is the Bubble Tea adapter. Pages and modal instances retain their state in Runtime; components (picker, registers, application components) are instances the runtime drives through the delivery contract, so the adapter holds no component list of its own.
func (*Model) JobLingerTick ¶
func (m *Model) JobLingerTick() (JobLingerMsg, bool)
JobLingerTick is the linger timer in flight, the message its tea.Tick will deliver at its deadline (At), and false when none is scheduled. A host with a fake Now advances the clock to At and delivers the message itself rather than waiting JobLinger.
func (*Model) JobsTicker ¶
JobsTicker is the ticker the shell draws above the footer for the current frame, as plain lines at most width cells: zero rows when no job shows.
func (*Model) Notify ¶
Notify adds a persistent notice to the footer (Notices); notice.clear removes them.
func (*Model) View ¶
View renders the shell as a full-screen tea.View; View().Content is the string. The terminal cursor follows the focused input through the page or modal that holds it: a bar in insert mode, a block in normal mode and an underline in visual modes. It is hidden when no input is focused.
type Noun ¶
type Noun struct {
Name string `json:"name"`
Verbs []string `json:"verbs,omitempty"`
Pin string `json:"pin,omitempty"`
Focusable bool `json:"focusable,omitempty"`
Region bool `json:"region,omitempty"`
Bindings map[string][]Binding `json:"bindings"`
Extends map[string]string `json:"extends,omitempty"`
Guards map[string]string `json:"guards,omitempty"`
Actions map[string]Handler `json:"-"`
// Columns are the table columns a list of the noun's rows draws
// (NounBuilder.Columns, the catalog's columns): declared data a host
// passes to Columns when it builds the list, never applied on its own.
Columns []Column `json:"columns,omitempty"`
}
Noun is the behaviour shared by every instance of one kind: the verbs it answers to, its key bindings per mode, the action handlers that override an operation's default while the noun is on the focus stack, and an optional pinned mode (the prompt noun pins insert). Focusable marks every instance of the noun as a focus stop (focus.next and the mode rule read it); Region marks a grouping that focus.next {scope: "region"} jumps between.
Bindings is keyed by mode name. "" holds rows that apply in every base mode; a pending mode (operator_pending, a key-sequence prefix, ...) is exclusive and reads only its own table.
type NounBuilder ¶
type NounBuilder struct {
// contains filtered or unexported fields
}
NounBuilder is the declaration surface of one noun.
func (*NounBuilder) Action ¶
func (b *NounBuilder) Action(key string, h Handler) *NounBuilder
Action overrides any operation ("noun.verb") while this noun is on the stack.
func (*NounBuilder) Columns ¶
func (b *NounBuilder) Columns(cols ...Column) *NounBuilder
Columns declares the table columns a list of the noun's rows draws, in order, each row's ListItem.Cells the same order (Noun.Columns). The catalog carries them, so a host mounting the noun's rows draws a table; an application passes r.Noun(noun).Columns to the Columns list option.
func (*NounBuilder) Confirm ¶
func (b *NounBuilder) Confirm(prompt string) *NounBuilder
Confirm asks before the last declared verb runs: the prompt template ({{id}}, {{noun}}, {{<arg>}}) opens a confirm modal whose y runs the stored request and n or esc pops it. An empty prompt removes the confirm.
func (*NounBuilder) Focusable ¶
func (b *NounBuilder) Focusable() *NounBuilder
Focusable makes every instance of the noun a focus stop.
func (*NounBuilder) Mode ¶
func (b *NounBuilder) Mode(mode string) *ModeBuilder
Mode selects the table rows are bound into; "" is the any-mode table.
func (*NounBuilder) Motion ¶
func (b *NounBuilder) Motion() *NounBuilder
Motion marks the last declared verb as a motion (Operation.Motion): the footer leaves its rows to ? help, as it does for list.move.
func (*NounBuilder) Noun ¶
func (b *NounBuilder) Noun() *Noun
func (*NounBuilder) Pin ¶
func (b *NounBuilder) Pin(mode string) *NounBuilder
Pin keeps every instance of the noun in one base mode.
func (*NounBuilder) Positional ¶
func (b *NounBuilder) Positional(names ...string) *NounBuilder
Positional names the parameters of the last declared verb that bare words fill first, in order (Operation.Positional): Positional("name") makes BIN project link foo set name even though the boolean all sorts first. The CLI gives a boolean a bare word only when it is named here.
func (*NounBuilder) Quiet ¶
func (b *NounBuilder) Quiet() *NounBuilder
Quiet marks the last declared verb as bookkeeping (Operation.Quiet): its jobs stay off the jobs ticker. The framework names no quiet verb.
func (*NounBuilder) Region ¶
func (b *NounBuilder) Region() *NounBuilder
Region makes every instance of the noun a focus region: a grouping (a panel) that focus.next {scope: "region"} jumps between, never a stop.
func (*NounBuilder) Rows ¶
func (b *NounBuilder) Rows(noun string) *NounBuilder
Rows declares that the last declared verb's result lists rows of noun (Operation.Rows): a host reading the catalog knows which noun a list verb's rows answer to. An empty noun removes the declaration.
func (*NounBuilder) State ¶
func (b *NounBuilder) State() *NounBuilder
State marks the last declared verb as the runtime's state source (Operation.State): one call answers every list's rows as JSON Lines, each line tagged with the list noun (see cli.CatalogDoc). A host reading the catalog's state runs it once instead of one row source per list. The framework names no state verb.
func (*NounBuilder) Verb ¶
func (b *NounBuilder) Verb(verb string, h any, description ...string) *NounBuilder
Verb registers noun.verb as an operation when it is new, else installs the handler as this noun's override of the existing operation. The handler is a Handler (an interaction verb, run on the loop) or an AppHandler (func(Ctx) Result: an application verb whose pending work runs off the loop). An override of an existing operation must be a Handler.
func (*NounBuilder) Verbs ¶
func (b *NounBuilder) Verbs(verbs ...string) *NounBuilder
Verbs records the verbs the noun answers to, for help and the palette.
func (*NounBuilder) When ¶
func (b *NounBuilder) When(guard string) *NounBuilder
When guards the last declared verb with a registered guard name: while the guard is false at the focus and mode the verb would run in, the palette does not offer it. The guard reads a KeyEvent whose Focus and Level are that focus and whose Mode is that mode. A palette noun's default verb is never guarded (RegisterNoun refuses one). An empty name removes the guard.
type Operation ¶
type Operation struct {
Verb string `json:"verb"`
Noun string `json:"noun"`
Description string `json:"description"`
Parameters map[string]Parameter `json:"parameters"`
Result string `json:"result"`
Kind string `json:"kind"`
Confirm string `json:"confirm,omitempty"`
Repeatable bool `json:"repeatable,omitempty"`
// Rows names the noun whose rows the verb's result lists (a list
// verb's JSON array of rows of that noun); "" when the result is not
// rows. It is data for hosts (the catalog's rows); the runtime does
// not read it.
Rows string `json:"rows,omitempty"`
// State marks the verb whose answer is the rows of every one of a
// host's lists in one call (NounBuilder.State), as JSON Lines of
// cli.Row tagged by list noun ({"noun":"agent","id":..,"label":..}).
// Data for hosts (the catalog's state); the runtime does not read it.
State bool `json:"state,omitempty"`
// Quiet marks bookkeeping (a list reload) the jobs ticker does not
// show; set by NounBuilder.Quiet. The catalog's quiet.
Quiet bool `json:"quiet,omitempty"`
// Motion marks movement (list.move, focus.next, surface.scroll,
// page.next): the footer's hint line leaves its rows out, since motions
// are standard and the footer is for the verbs the focus offers; ?
// help and bindings list keep them. Set by NounBuilder.Motion; the
// framework's own motions are marked as they register (motionOps).
Motion bool `json:"motion,omitempty"`
// Positional names the parameters bare words fill first, in this
// order (NounBuilder.Positional), ahead of ParameterOrder's
// required-then-by-name rest. The CLI gives a boolean a bare word only
// when it is named here. The catalog's positional.
Positional []string `json:"positional,omitempty"`
Run Handler `json:"-"`
App AppHandler `json:"-"`
}
Operation is one registered noun.verb. Kind is "interaction" (the default: Run executes synchronously on the loop) or "application" (App is an AppHandler whose pending work runs off the loop and reports through the delivery contract). Confirm, when set, is a prompt template ({{id}}, {{noun}}, {{label}}, {{<arg>}}) shown in a confirm modal before the operation runs. Repeatable marks a change (not a motion or navigation) that dot-repeat (history.repeat, bound to . on app in normal mode) may run again; set it on the Operation passed to Register.
func (Operation) ParameterOrder ¶
ParameterOrder lists the operation's parameters in positional order: the Positional names first, in their order, then the rest required first, then by name. Parameters is a map, so this is the declared order the palette's words and the CLI's bare arguments fill.
type Page ¶
type Page struct {
ID string `json:"id"`
Title string `json:"title"`
Focus string `json:"focus"`
Remembered string `json:"remembered"`
Render func(*Runtime, int, int) Block `json:"-"`
// Scrolloff is how many lines the page keeps visible above and below
// the focused element when it scrolls to follow the focus: 0 means the
// default, 2; a negative value keeps no margin.
Scrolloff int `json:"scrolloff,omitempty"`
// contains filtered or unexported fields
}
Page is the component a page instance fronts: a title, the instance it starts focused on (Focus), the focus it remembers while another page is open (Remembered, restored with its mode by OpenPage), and a renderer. Render returns the page body for the given cell bounds as a Block; its cursor, when the page holds the focused input, is relative to the body's top-left cell. Pages without inputs return Text(body).
type Palette ¶
type Palette struct {
// contains filtered or unexported fields
}
Palette is the ex-mode command line: one prompt input whose text is the source of truth, parsed by the grammar in palette_parse.go, with a completion list for the next word beneath it. It never edits the originating input. Create one palette per runtime: operation keys are globally unique.
func NewPalette ¶
NewPalette returns the command palette for r.
func (*Palette) RegisterNoun ¶
func (p *Palette) RegisterNoun(noun string, config PaletteNoun) error
RegisterNoun adds or replaces a live instance source without changing operation forms.
type PaletteEntry ¶
type PaletteEntry struct {
Value string `json:"value"`
Kind string `json:"kind"`
Label string `json:"label"`
ID string `json:"id,omitempty"`
Verb string `json:"verb,omitempty"`
}
PaletteEntry is one completion: Value is the word it appends, Kind is verb, noun or choice, Label what the list shows.
type PaletteInstance ¶
PaletteInstance is a labeled object whose ID becomes the default action argument.
func PagesPaletteSource ¶
func PagesPaletteSource(r *Runtime, _ Context) []PaletteInstance
PagesPaletteSource reads the runtime registry on every listing, not at startup.
type PaletteNoun ¶
type PaletteNoun struct {
Source PaletteSource
DefaultVerb string
Argument string
}
PaletteNoun explicitly chooses the action and string argument used for an instance.
type PaletteSource ¶
type PaletteSource func(*Runtime, Context) []PaletteInstance
PaletteSource reads current instances in the context captured when the palette opened.
type PaletteWord ¶
type PaletteWord struct {
Text string `json:"text"`
Kind string `json:"kind,omitempty"`
Value string `json:"value,omitempty"`
Param string `json:"param,omitempty"`
Candidates []string `json:"candidates,omitempty"`
}
PaletteWord is one word of the line and what it resolved to: Kind is verb, noun, instance or argument; Value is the full word ("" while it is unresolved); Candidates are the words an ambiguous prefix could be.
type Parameter ¶
type Parameter struct {
Type string `json:"type"`
Required bool `json:"required,omitempty"`
Description string `json:"description,omitempty"`
// Enum lists the static choices of a string parameter; Source names an
// operation (noun.verb) whose result lists more. Free also accepts a
// value outside them.
Enum []string `json:"enum,omitempty"`
Source string `json:"source,omitempty"`
Free bool `json:"free,omitempty"`
}
Parameter describes one argument of an operation: its type, whether it is required, and its choices.
type Payload ¶
type Payload struct {
Return string `json:"return,omitempty"`
Count int `json:"count,omitempty"`
OpCount int `json:"opCount,omitempty"`
Op string `json:"op,omitempty"`
Prefix string `json:"prefix,omitempty"`
Prompt string `json:"prompt,omitempty"`
Request *Request `json:"request,omitempty"`
Shadow *ModeState `json:"shadow,omitempty"`
}
Payload is the small typed state a mode carries (Runtime.Mode.Payload). For a pending mode Return is the mode it returns to on leave. Count and OpCount are the Vim counts before and after an operator; Op is the pending operator; Prefix is the key sequence typed so far; Request is a stored request (the completed match a sequence prefix falls back to, or a confirm's deferred action); Prompt is the text a confirm modal shows; Shadow is the mode the macro_recording shadow mode re-dispatches in.
type Picker ¶
type Picker struct {
Runtime *Runtime
Origin Context
Directory string
Filter string
Entries []PickerEntry
Selected int
Error string
Loading bool
// contains filtered or unexported fields
}
Picker owns one modal and one ordinary editor. Background commands only read immutable snapshots; HandleMessage is the sole result-application boundary. Its work runs as three replacing jobs on the picker instance (the "index", "search" and "preview" slots), so the runtime's jobs list decides which result is current: a newer job in a slot drops the older, and Close cancels them all.
func (*Picker) Close ¶
func (p *Picker) Close()
Close cancels indexing, searching and previews; the picker instance stays registered for the next open.
func (*Picker) HandleMessage ¶
HandleMessage applies only the current job of each slot (index, search, preview) on the UI loop; the runtime's jobs list says which that is.
func (*Picker) PendingCommand ¶
PendingCommand is drained by Runtime.PendingCommands after every event, including CallMsg. It schedules work, never waits on filesystem or search.
type PickerEntry ¶
PickerEntry is relative to the indexed root. Symlinks are selectable files, never traversal edges.
type Placement ¶
type Placement struct {
ID string `json:"id"`
// Line is the body line the view's first line landed on, -1 when the
// view reported no text or the page did not draw it; Height is its line
// count.
Line int `json:"line"`
Height int `json:"height"`
// Focus and FocusHeight are the focused lines, relative to Line.
Focus int `json:"focus"`
FocusHeight int `json:"focusHeight"`
}
Placement is one Placed call of a frame: the instance drawn and, when its view reported them (PlacedAt), the lines it covers in the page body and the lines inside it that hold the focus (a list's selected row, a grid's cursor row, an input's whole box, a terminal's top line).
type Pos ¶
type Pos struct {
X, Y int
}
Pos is a cell position inside a rendered block: zero-based, counted from the block's top-left corner.
type Predicate ¶
type Predicate struct {
Name string `json:"name"`
Arg string `json:"arg,omitempty"`
Of []Predicate `json:"of,omitempty"`
}
Predicate is one named test over an instance: a value, never a string selector. A query is a list of predicates, ANDed. Name is a registered predicate (noun, id, kind, within, child-of, focusable, region, state or one an application adds) and Arg its argument; the combinators any, all and not take nested predicate lists in Of instead. The wire form is a JSON array: ["noun","row"], ["any",[["noun","a"],["noun","b"]]].
func IsFocusable ¶
func IsFocusable() Predicate
func ParsePredicates ¶
ParsePredicates reads the wire form: a list of [name, arg] pairs, or [combinator, [nested pairs]] for any, all and not. A []Predicate from Go passes through.
type PredicateFunc ¶
PredicateFunc tests one instance; arg is the predicate's argument.
type QueryMatch ¶
type QueryMatch struct {
ID string `json:"id"`
Noun string `json:"noun"`
Parent string `json:"parent,omitempty"`
}
QueryMatch is one instances.query result row.
type Registers ¶
type Registers struct {
Named map[string]Register
History []Yank
Active string
Macro MacroState
// contains filtered or unexported fields
}
Registers is the component that owns the shared yanks, named registers, yank history, the register selected for the next operation and the macro state. It is one instance under app, reached through the register, macro and yank-history operations and Runtime.Registers(), never through Runtime fields. Its key rows (q, @, " and the pending modes they enter) sit on the app noun so a page or list focus can record and replay too.
func (*Registers) Close ¶
func (g *Registers) Close()
Close abandons a recording in progress; the registers themselves stay.
func (*Registers) HandleMessage ¶
HandleMessage: the registers do no off-loop work.
func (*Registers) PendingCommand ¶
PendingCommand: nothing is ever scheduled.
type Request ¶
type Request struct {
Verb string `json:"verb"`
Noun string `json:"noun"`
Target string `json:"target,omitempty"`
Args Arguments `json:"args,omitempty"`
Confirmed bool `json:"confirmed,omitempty"`
}
Request names an operation and, optionally, the instance it addresses. Confirmed skips the operation's Confirm prompt: the confirm modal's y sets it on the stored request, and a script may set it to run unattended.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result is what an application handler returns.
func Pending ¶
Pending schedules work off the loop as a job that accumulates: it runs beside the owner's other jobs and its completion is delivered whenever it finishes. The context is cancelled when the owning instance closes.
func (Result) Replacing ¶
Replacing puts the pending work in a slot on its owner: starting it cancels the owner's running job in the same slot, and a newer job in the slot cancels this one. Use it for replaceable work such as a preview or a search, never for independent work.
func (Result) ReplacingAt ¶
ReplacingAt is Replacing with the slot scoped to scope, the owner or one of its ancestors: the newest job in (scope, slot) cancels the older one whichever descendant of scope asked, so previews launched from the rows of one list replace each other while another list keeps its own. The job still belongs to the row that asked (its completion and Then land there and closing it cancels the job); Replacing(slot) is ReplacingAt(owner, slot). A scope off the owner's ancestry fails the launch.
type Runtime ¶
type Runtime struct {
Nouns map[string]*Noun
Instances map[string]*Instance
Focus string // the focused instance; Context() is derived from it
Mode ModeState // the one interaction mode; mode.set writes it, a focus change to another stop resets it
Page string // the current page instance; always an ancestor of BaseFocus()
Modes map[string]bool
Operations map[string]Operation
Quit bool
Pending string
BindingTimeout time.Duration
// contains filtered or unexported fields
}
Runtime is owned by one event loop. Transport callers submit messages to that loop. It holds the operation registry (Operations, Modes and their guards), the instance registry (Nouns, Instances and their parent links, including list rows), the three plain interaction fields Focus, Mode and Page with the chain of open modals, the pending key-sequence state (Pending, prefix, BindingTimeout) and the hook that hands off-loop work to the adapter (commands). Components such as inputs, lists, the picker and the registers are instances, never fields; TestRuntimeHoldsNoComponentFields pins this list.
func NewRuntime ¶
func NewRuntime() *Runtime
NewRuntime returns a runtime with the framework nouns registered and focus on the app instance.
func (*Runtime) ActionFor ¶
ActionFor returns the innermost noun handler for an operation key on the focus stack, or nil when the operation's own Run applies.
func (*Runtime) AddInput ¶
func (r *Runtime) AddInput(in *Input, opts ...InstanceOption) error
AddInput registers an editor instance. Options: Parent(id) (default app) and Kind(noun) (default "editor"; "prompt" pins insert mode).
func (*Runtime) AddList ¶
AddList registers a list instance of the list noun with its rows. Options: Parent(id) (default app), Kind(noun) for a list that answers to its own noun as well, NoSpill() for a list whose motions stay inside it, and Columns(...) for a table.
func (*Runtime) AddPage ¶
func (r *Runtime) AddPage(id, title string, render func(*Runtime, int, int) Block, opts ...InstanceOption) (*Page, error)
AddPage registers a page instance of kind page under app with a title and a renderer. Options: Focus(id) names where the page starts (the page itself or an instance beneath it, registered first) and Kind(noun) a noun of the application's own. Registration does not activate the page; see OpenPage. It is RegisterPage for callers that do not hold a *Page.
func (*Runtime) AddTerminal ¶
func (r *Runtime) AddTerminal(id string, stream TerminalStream, opts ...InstanceOption) (*Terminal, error)
AddTerminal registers a terminal instance of the terminal noun fed by stream, in terminal mode: every key forwards to the pane except the leader. Options: Parent(id) (default app), Kind(noun) for a noun that supplies its own tables and CloseOnDetach to remove the instance (and release the stream) on detach. The first frame read is scheduled at once.
func (*Runtime) AddTree ¶
AddTree registers a tree under Parent (default app) with its nodes. Columns(...) makes its rows a table; NoSpill keeps motions inside it.
func (*Runtime) Ancestry ¶
Ancestry walks the parent links from id outward: id first, app last. An unknown id yields nil.
func (*Runtime) BaseFocus ¶
BaseFocus is the focus beneath every open modal: the return of the outermost modal, else Focus. Runtime.Page is always an ancestor of it.
func (*Runtime) BaseMode ¶
BaseMode is the mode Runtime.Mode stands in: its name, or for a pending mode or a key-sequence prefix the base mode it returns to.
func (*Runtime) Bind ¶
Bind installs rows from config or code onto their noun or instance tables: the same mode and keys or pattern replaces, a new one adds, Unbind removes.
func (*Runtime) BindingTimeoutCommand ¶
BindingTimeoutCommand schedules the latest deadline once. Custom Tea models call it after dispatch and send BindingTimeoutMsg to HandleBindingTimeout.
func (*Runtime) CancelPendingBinding ¶
func (r *Runtime) CancelPendingBinding()
CancelPendingBinding leaves a key-sequence prefix mode without running its completed match and invalidates its timer.
func (*Runtime) Choices ¶
Choices lists a parameter's accepted values in context c: its Enum, then the result of its Source operation. A source that asks for confirmation is refused; it must be a read.
func (*Runtime) Define ¶
func (r *Runtime) Define(name string) *NounBuilder
Define declares a noun, or returns the builder of an existing one.
func (*Runtime) DefineGuard ¶
DefineGuard registers a named row guard.
func (*Runtime) DefineMode ¶
DefineMode registers a mode name. A pending mode is exclusive: only rows in its own table answer, and a row that leaves the mode unchanged returns the instance to the mode it shadowed.
func (*Runtime) DefinePassthrough ¶
DefinePassthrough marks a defined mode as a passthrough mode: while it is the base mode (a pending mode over it included) capture rows stand aside, so the focused level's rows answer every key. The terminal mode is one: ctrl+c reaches the pane instead of the app's captured quit.
func (*Runtime) Deliver ¶
Deliver routes a message on the loop: a Completion goes to its owner when its job is running and is dropped otherwise; any other message is offered to every component until one claims it. A Then callback that removes its own owner is safe: the job is already settled and the completion is not offered to the gone component. It reports whether a component consumed the message and the delivered completion's error, if any.
func (*Runtime) Dispatch ¶
Dispatch resolves one key through the stack walk and runs the first row that answers. It reports whether any row claimed the key. Live keys and macro playback both arrive here.
func (*Runtime) ExecuteAt ¶
ExecuteAt runs an operation for a context. The innermost noun on the focus stack that overrides the operation handles it; otherwise its Run does. Every request but history.list and state.get is appended to the action history with the context it ran in and its result.
func (*Runtime) HandleBinding ¶
HandleBinding dispatches a named key; kept for callers that only know keys.
func (*Runtime) HandleBindingTimeout ¶
func (r *Runtime) HandleBindingTimeout(msg BindingTimeoutMsg) (bool, error)
HandleBindingTimeout executes the longest completed match, or clears an incomplete prefix. Its result is false for a stale or cancelled timer.
func (*Runtime) HandleCall ¶
func (*Runtime) History ¶
func (r *Runtime) History(n int) []HistoryEntry
History returns the last n entries, oldest first (all of them for n <= 0).
func (*Runtime) Instance ¶
func (r *Runtime) Instance(id string, opts ...InstanceOption) *Instance
Instance registers a plain instance: a page body, a panel, a modal body. Its noun is defined when it does not exist yet. Registering an existing id returns it unchanged.
func (*Runtime) InstancePath ¶
InstancePath is Ancestry reversed: app first, id last.
func (*Runtime) Issue ¶
Issue admits a job for owner and returns its ticket and the context its work runs under; the caller runs the work and reports back with a message carrying the ticket, checked with Accepts and closed with Settle. A slot name cancels the owner's running job in that slot; "" accumulates. Launch and Start build on it for work the runtime runs as a tea.Cmd.
func (*Runtime) IssueAt ¶
IssueAt is Issue with the slot scoped to scope, owner or one of its ancestors: the running job in (scope, slot) is cancelled whichever instance owns it. See Result.ReplacingAt.
func (*Runtime) Jobs ¶
Jobs lists every job the runtime knows in start order: the running ones and the finished ones retained since the last jobs.list read.
func (*Runtime) JumpFocus ¶
JumpFocus moves the focus steps stops (scope "stop") or regions (scope "region") forward, or backward for negative steps, through the focus root in drawing order (units), wrapping. The current unit is the nearest stop (or region) on the focus path; the next one is the first after that unit's whole subtree. A stop is never descended into (a grid is one stop, its cells are not); the focus lands on the unit's remembered child.
func (*Runtime) Launch ¶
Launch starts a pending result as a job of owner under verb and queues its work for the adapter. The completion reaches the owner's Component.HandleMessage and the result's Then callback when the job is still current.
func (*Runtime) ListBindings ¶
ListBindings prints the rows the focus answers to in its current mode, one per key or pattern, sorted by key with pattern rows last.
func (*Runtime) LoadBindingSpec ¶
LoadBindingSpec installs a spec onto one noun: modes, then rows.
func (*Runtime) LoadBindings ¶
LoadBindings installs rows from a JSON array in the binding row shape and returns the installed rows.
func (*Runtime) ModalFocus ¶
ModalFocus is the instance an open modal points at: Focus for the top modal, else the return focus stored in the modal opened over it.
func (*Runtime) OpenModal ¶
OpenModal opens a modal whose body is a new instance of noun kind (its id is the kind), parented at the current focus and carrying payload, and focuses it (or the input WithInput places in it). The instance lives until Pop closes the modal. The kind's rows answer first, then the focus it opened over, then the modal noun.
func (*Runtime) OpenPage ¶
OpenPage makes a page current and restores the focus and mode it was left in; an open modal blocks navigation. Runtime.Page is always an ancestor of the focus.
func (*Runtime) PageFocus ¶
PageFocus is the focus a page shows: the live base focus while it is the current page, else the focus it remembers.
func (*Runtime) PendingCommands ¶
PendingCommands drains the work scheduled since the last call: the runtime's own queue and every component's PendingCommand.
func (*Runtime) Placed ¶
Placed records that the instance id is being drawn now, during its page's render: the order of these calls in a frame is the page's drawing order, which focus jumps (focus.next, focus.previous) and list spills walk, so motions follow the screen as drawn and cannot drift from it. List, Input (InputBlock), Terminal and grid views call it; a component of the application's own calls it from its view. Outside a page render it does nothing. There is no other way to order stops: an instance no frame drew follows the drawn ones in tree order.
func (*Runtime) PlacedAt ¶
PlacedAt records where the view text of instance id holds the focus (lines focus to focus+height of text; a list's selected row, an input's whole box) and returns text marked so its page finds the body line it lands on, which is how the page scrolls to keep the focus visible. Call it with the view's final text after Placed; it amends that placement (or places id, if Placed was not called). Outside a page render it returns text unchanged. List, Input, Terminal and grid views call it.
func (*Runtime) Pop ¶
Pop closes the active modal and restores the focus and mode it opened over. A body the modal created is closed through the delivery contract and removed with what it holds.
func (*Runtime) Push ¶
Push opens a modal with id focused on focus (app when empty). An id that is not already an instance becomes one of the modal noun for as long as it is open. The modal remembers the focus and mode it opened over.
func (*Runtime) Query ¶
Query returns the instances matching every predicate, in tree order: app first, then depth-first with siblings in the order they were added. An unknown predicate matches nothing; instances.query reports it instead.
func (*Runtime) ReadYank ¶
ReadYank reads a register ("" is the active register, else the unnamed one).
func (*Runtime) Register ¶
Register adds an operation. An operation with App set is of kind application and its Run is the framework's dispatcher for it.
func (*Runtime) RegisterPage ¶
func (r *Runtime) RegisterPage(page *Page, opts ...InstanceOption) error
RegisterPage registers a page as an instance of kind page under app (the instance may already exist, registered through Instance with the inputs and lists it holds). Focus names where the page starts: the page itself or an instance beneath it. Registration does not activate the page.
func (*Runtime) RegisterPredicate ¶
func (r *Runtime) RegisterPredicate(name string, fn PredicateFunc)
RegisterPredicate adds a named predicate an application's queries (and the CLI's instances.query) can use, such as marked.
func (*Runtime) RemoveInstance ¶
RemoveInstance closes an instance and its descendants (components closed, jobs cancelled) and drops them. Every focus reference into the removed subtree (Focus, a page's remembered focus, an open modal's return) moves to the nearest surviving ancestor (the Focus itself to a removed instance's FocusOnClose target when that survives); an open modal inside the subtree is kept and reparented there. app cannot be removed.
func (*Runtime) RetargetFocus ¶
RetargetFocus points every focus reference that match accepts (the focus, a page's remembered focus, an open modal's return) at to. A component that recreates its focused child (the grid's cell, the list's row) calls it after the move; staying inside one focus stop, it keeps the mode.
func (*Runtime) SetConfirm ¶
SetConfirm sets or clears (empty prompt) the confirm prompt of noun.verb.
func (*Runtime) SetFocus ¶
SetFocus points the focus at one instance: an input, a list, a row, a page or a modal body. Without a modal, the focus must sit inside the current page; a hidden page's instances are addressed with an explicit target.
func (*Runtime) SetMode ¶
SetMode sets the global mode by name and clears its payload, as mode.set does: a focused input runs its own transition (insert sessions, visual anchor), and a pinned input stays in its pinned mode.
func (*Runtime) Settle ¶
Settle records the outcome of a running job and reports whether the ticket was current; a stale ticket leaves the list unchanged. Deliver settles the completions it routes; a component that runs its own commands settles the tickets it issued.
func (*Runtime) Sourced ¶
Sourced sets the source the requests executed until restore is called are recorded with, unless an outer caller already set one (a row run by a key inside a macro replay keeps "macro:q"). Callers: the resolver ("key:<keys>"), the transport ("cli"), the palette ("palette").
func (*Runtime) Start ¶
func (r *Runtime) Start(owner string, work func(context.Context) (any, error), then func(Ctx, any, error), c Ctx) (Ticket, error)
Start schedules accumulating work owned by an instance and returns its ticket; it is Launch with Pending(work).Then(then) under the verb "work".
func (*Runtime) StoreYank ¶
StoreYank puts a yank into the shared registers with the bookkeeping the editor's yank operations use: the named or active register, the unnamed register, "0" for a yank or "1".."9" and "-" for a deletion, and the yank history. A component outside the package (a grid) yanks shapes the editor does not know ("column"), which register.set refuses, so it stores through this call and the editor still sees the text.
func (*Runtime) ValidateBindings ¶
ValidateBindings checks every row of every noun and instance table the way Bind checks a row it installs: keys or a pattern, a registered mode and guard, and a Request to a registered operation with known arguments and sources, or an unbind. Every row is therefore atomic. It is the check behind TestBindingRowsAreAtomic and is for an application to run after it loads its own rows.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server serves runtime requests over a Unix socket; see Listen.
type Styles ¶
type Styles struct {
Title lipgloss.Style
Subtitle lipgloss.Style
Muted lipgloss.Style
Accent lipgloss.Style
Error lipgloss.Style
Panel lipgloss.Style
FocusedPanel lipgloss.Style
Tab lipgloss.Style
ActiveTab lipgloss.Style
Badge lipgloss.Style
Padding int
}
Styles is a render-time value; it does not retain mutable appearance state.
func NewStyles ¶
func NewStyles(a Appearance) Styles
NewStyles keeps layout and focus cues usable without terminal color support.
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
Terminal is the component of a terminal instance: it holds the last frame the stream delivered, renders it into the area a page gives it and reports the pane's cursor. Frames arrive through the delivery contract as Completions owned by the instance in the "read" slot, one read at a time, so a frame that arrives after Close, or after a newer read started, is stale and dropped before it reaches the component.
func (*Terminal) Close ¶
func (t *Terminal) Close()
Close stops reading and releases a TerminalReleaser stream, once; the runtime has already cancelled the read in flight.
func (*Terminal) Frame ¶
func (t *Terminal) Frame() TerminalFrame
Frame is the last frame the stream delivered.
func (*Terminal) HandleMessage ¶
HandleMessage stores a frame delivered to this terminal and schedules the next read. A stream error ends reading; a cancelled read is silent.
func (*Terminal) PendingCommand ¶
PendingCommand is nil: reads are scheduled through Runtime.Start.
func (*Terminal) ViewBlock ¶
ViewBlock renders the pane's cells into exactly width x height cells and reports the pane's cursor; compose the cursor only while the terminal is focused. The stream is told the area the first time it is seen and whenever it changes, so the pane is sized to the detail area it fills.
type TerminalFrame ¶
type TerminalFrame struct {
Lines []string `json:"lines"`
Cursor Pos `json:"cursor"`
Shape string `json:"shape,omitempty"`
Hidden bool `json:"hidden,omitempty"`
}
TerminalFrame is one rendering of a pane: its rows of trusted ANSI, the cursor cell, the cursor shape the pane reports ("block", "bar", "underline"; "" for the default block) and whether the cursor is hidden.
type TerminalReleaser ¶
type TerminalReleaser interface {
Release() error
}
TerminalReleaser is a TerminalStream that holds something to give back when its terminal closes: a daemon size lease, a connection. Terminal.Close calls Release once, so Pop, SetItems, RemoveInstance and a CloseOnDetach detach all release the stream; its error is kept as the terminal's Err.
type TerminalStream ¶
type TerminalStream interface {
Next(ctx context.Context) (TerminalFrame, error)
Send(keys ...string) error
Paste(text string) error
Resize(cols, rows int) error
}
TerminalStream is the application's connection to one pane: a daemon client, never a PTY the framework owns. The framework reads frames from it, forwards keys and pasted text to it and tells it the pane's size. Next blocks until the pane changes and returns its next frame; it returns ctx's error when the terminal instance closes or newer work supersedes the read. Keys are named as bindings spell them ("ctrl+a", "d", "esc").
type Ticket ¶
type Ticket struct {
Owner string `json:"owner"`
Job uint64 `json:"job"`
Slot string `json:"slot,omitempty"`
}
Ticket names one job: the instance that owns it, its runtime-wide id and the slot it was started in. Slot is "" for a job that accumulates (every completion is delivered, in finish order) and a name for a job that replaces: a newer job in the same slot on the same owner (or, with ReplacingAt, on the same scope) drops the older. A completion is stale, and dropped, only when its job was cancelled by a newer job in its slot or by its owner closing.
type Tree ¶
type Tree struct {
// OnChange makes the tree editable and receives each change as it is
// made; an error keeps the change on screen, marks the row and retries
// it before the next change.
OnChange func(TreeChange) error
// NewID names a new node (default "<tree>-n<seq>").
NewID func() string
// RowNoun is the noun of nodes the tree adds (default TreeRowNoun).
RowNoun string
// Debounce is the pause in typing before a line is written.
Debounce time.Duration
// contains filtered or unexported fields
}
Tree is a list whose rows are nested nodes: expand and collapse, the same motions as a list (it is one: rows spill to the neighbouring stops in drawing order), the one highlighted row, columns like a table. Given OnChange it is an outline editor: every structural edit is written at once, typing within a line is written after a pause (Debounce) and when the line is left, undo and redo are changes too, and esc never discards.
The tree is an instance of the outline noun with a list child (id+"/list") holding the visible rows; editing adds an input (id+"/line", noun outline-line) under the tree while a line is edited. (The nouns are "outline", not "tree", so palette prefixes such as "tr" stay unique in apps.)
func (*Tree) Block ¶
Block renders the rows as the list does; while a line is open its row is the input, with the terminal cursor in it.
func (*Tree) CollapseAll ¶
CollapseAll collapses every node that has children.
func (*Tree) DebounceCurrent ¶
func (t *Tree) DebounceCurrent(tick TreeDebounceMsg) bool
DebounceCurrent reports whether a pause timer is for the line's latest change (an older timer writes nothing).
func (*Tree) Failure ¶
Failure is the last background failure, cleared when read: Deliver returns it for the message the tree handled, so it reaches the status.
func (*Tree) FocusTarget ¶
FocusTarget is where a jump to the tree lands: its selected row.
func (*Tree) HandleMessage ¶
HandleMessage writes the open line when its pause timer is the latest.
func (*Tree) PendingCommand ¶
PendingCommand notices typing in the open line and sets the pause timer; a line whose input lost the focus is closed (and written).
func (*Tree) SetCollapsed ¶
SetCollapsed collapses or expands one node.
type TreeChange ¶
type TreeChange struct {
Op string `json:"op"`
ID string `json:"id"`
Parent string `json:"parent,omitempty"`
Index int `json:"index"`
Text string `json:"text,omitempty"`
}
TreeChange is one committed edit of an outline: add, rename, move or delete. Index is the node's position among its parent's children after the change. The application writes each one to its store as it comes (Tree.OnChange); undo is a further change, never a discard.
func (TreeChange) String ¶
func (c TreeChange) String() string
String reads a change in one line: "add n1 under root at 1: text", "rename n1: text", "move n1 under a at 0", "delete n1".
type TreeDebounceMsg ¶
TreeDebounceMsg is the timer a pause in typing sets off: when Seq is still the line's latest change, the line is written.
type TreeNode ¶
type TreeNode struct {
ID string `json:"id"`
Parent string `json:"parent,omitempty"`
Label string `json:"label"`
Noun string `json:"noun,omitempty"`
Data any `json:"data,omitempty"`
Cells []string `json:"cells,omitempty"`
}
TreeNode is one node of a tree. Nodes are flat and in display order: a node's children follow it, and Parent "" is a root. Noun is the row's noun (default TreeRowNoun); Data and Cells are as on ListItem.
Source Files
¶
- bindings.go
- block.go
- cli.go
- configuration.go
- confirm.go
- delivery.go
- editing.go
- editor.go
- editor_block.go
- editor_keys.go
- focus.go
- help.go
- history.go
- input.go
- instance.go
- layout.go
- list.go
- macros.go
- model.go
- noun.go
- pages.go
- palette.go
- palette_choices.go
- palette_editing.go
- palette_nouns.go
- palette_parse.go
- params.go
- picker.go
- picker_preview.go
- picker_search.go
- picker_view.go
- query.go
- registers.go
- resolve.go
- runtime.go
- surface.go
- table.go
- terminal.go
- theme.go
- ticker.go
- transport.go
- tree.go
- yank_api.go
- yank_history.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cli is the generic command line of an ochazuke application: the NOUN VERB shell over a runtime (Shell), the oden mount that makes every noun a command of the bin (Mount) and the catalog answer that describes the runtime as JSON (Catalog).
|
Package cli is the generic command line of an ochazuke application: the NOUN VERB shell over a runtime (Shell), the oden mount that makes every noun a command of the bin (Mount) and the catalog answer that describes the runtime as JSON (Catalog). |
|
cmd
|
|
|
charmrefs
command
Command charmrefs writes docs/CHARM-INVENTORY.md: for every project listed in docs/charm-refs.txt, the Charm (charm.land, charmbracelet) modules it depends on, how many files import each package, its entry points, and its agent docs.
|
Command charmrefs writes docs/CHARM-INVENTORY.md: for every project listed in docs/charm-refs.txt, the Charm (charm.land, charmbracelet) modules it depends on, how many files import each package, its entry points, and its agent docs. |
|
codemap
command
Command codemap writes docs/CODEMAP.md: one entry per Go file in the root package and in each importable subpackage (cli/, grid/), listing what each file declares and which sibling files it leans on.
|
Command codemap writes docs/CODEMAP.md: one entry per Go file in the root package and in each importable subpackage (cli/, grid/), listing what each file declares and which sibling files it leans on. |
|
docgen
command
Command docgen generates the offline reference linked from the architecture guide.
|
Command docgen generates the offline reference linked from the architecture guide. |
|
o-story
command
Command o-story is a storybook-style sandbox for ochazuke: a story is a JSON file describing a synthetic page, a script of events and what must hold afterwards.
|
Command o-story is a storybook-style sandbox for ochazuke: a story is a JSON file describing a synthetic page, a script of events and what must hold afterwards. |
|
ochazuke
command
|
|
|
renamekeys
command
Command renamekeys rewrites operation keys from one spelling to the other across the repository's .go, .json, .md and .html files.
|
Command renamekeys rewrites operation keys from one spelling to the other across the repository's .go, .json, .md and .html files. |
|
examples
|
|
|
core
command
|
|
|
csv
command
Package main is the CSV reader and editor from docs/CSV-APP-SKETCH.md: the framework's lightweight second consumer.
|
Package main is the CSV reader and editor from docs/CSV-APP-SKETCH.md: the framework's lightweight second consumer. |
|
demo
Package demo is the runnable example behind `ochazuke run`: four pages, nested draft modals, the picker and the keyboard guide, built only from the public API.
|
Package demo is the runnable example behind `ochazuke run`: four pages, nested draft modals, the picker and the keyboard guide, built only from the public API. |
|
full-project
command
|
|
|
Package grid is a two-dimensional cursor component for ochazuke: a header and rows the application owns, a cursor and viewport in two axes, a visual selection in three shapes plus marks, and one instance per focused cell, parented to a row instance, parented to a column instance, parented to the grid, so the cell, row and column nouns all sit on the focus stack.
|
Package grid is a two-dimensional cursor component for ochazuke: a header and rows the application owns, a cursor and viewport in two axes, a visual selection in three shapes plus marks, and one instance per focused cell, parented to a row instance, parented to a column instance, parented to the grid, so the cell, row and column nouns all sit on the focus stack. |
|
internal
|
|
|
keytest
Package keytest drives Bubble Tea models from tests using the key names that bindings use ("ctrl+c", "esc", "enter", "shift+tab", "alt+b", "space", "x").
|
Package keytest drives Bubble Tea models from tests using the key names that bindings use ("ctrl+c", "esc", "enter", "shift+tab", "alt+b", "space", "x"). |
|
Package story is o-story's engine: a story is data (a synthetic page, a script of events, an expectation), Build turns it into a live runtime and model, a Driver plays events against it headless, and a Recorder turns the messages of a live session into the same events.
|
Package story is o-story's engine: a story is data (a synthetic page, a script of events, an expectation), Build turns it into a live runtime and model, a Driver plays events against it headless, and a Recorder turns the messages of a live session into the same events. |