tui

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 79 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	PromptStashPreviewWidth = 60
	MaxStashItems           = 20

	ActionNoop       = "noop"
	ActionStashed    = "stashed"
	ActionRestored   = "restored"
	ActionOpenPanel  = "open_panel"
	ActionClosePanel = "close_panel"
)

Variables

View Source
var ClipboardImage func(dest string) bool

Saves the clipboard image of the host to a PNG file, false when the clipboard holds none

View Source
var ClipboardImageBlocker func() (missing string, noDesktop bool)

Program this host lacks to read clipboard images, or that no desktop clipboard is reachable

View Source
var PluginWidgets func(ctx context.Context) []Widget

Widgets the plugins of the profile registered, read each time the list is asked for, assigned where the plugin manager is wired

View Source
var ScanPluginWidgets func(ctx context.Context, force bool) ([]Widget, []WidgetLoadFailure)

Widgets the plugins of the profile register and the plugins that failed to load, after a scan of the plugins that is forced anew when asked or else runs only the first time, assigned where the plugin manager is wired

View Source
var SpeechOutput struct {
	Play          func(path string) bool
	Stop          func()
	StartThinking func(ctx context.Context, shouldPlay func() bool) bool
	StopThinking  func()
}

Speech output of this window, bound by the tier that carries voice and unset in a build without it

Functions

func BuildPreview

func BuildPreview(text string, width int) string

Collapses a multi line draft into one preview line ellipsized to width runes

func OpenWidget

func OpenWidget(ctx context.Context, id string, state any) bool

Opens the widget of an id in place of the modal one whose input function is running, with a state that needs no argument to parse, false outside such a call and for an id no widget has

func RegisterWidget

func RegisterWidget(w Widget) error

Adds a widget compiled into the binary, refusing one without an id or a render function

func Run

func Run(ctx context.Context, host Host) int

Runs the terminal UI, prints the session summary when it ends and returns the exit status

func TakeAfterExit

func TakeAfterExit() ([][]string, error)

TakeAfterExit returns the commands this window queued to run once the terminal UI has exited and empties its queue

Types

type Grant

type Grant struct {
	URL        string
	Protocols  []string
	ProfileID  string
	InstanceID string
	// Build of an idle gateway the attach replaced by one of this build, empty when none was
	Replaced string
}

Private WebSocket target of the home's gateway owner the terminal UI attaches with

type Host

type Host struct {
	Attach          func(ctx context.Context, start, recover bool) (Grant, error)
	RestoreSnapshot func(ctx context.Context, id, session string, handoff bool, release func()) SnapshotRestore
	SettleWorktrees func(ctx context.Context, trees []Worktree, active string)
	// Stops the home's background service of another build so the next attach starts one of this build, nil where the launcher cannot
	ReplaceOwner func(ctx context.Context) error
	// Settings of the window the launcher resolved for the home, the built-in defaults when nil
	Prefs *Prefs
}

Work the launcher does for the terminal UI on the home's gateway owner and its files, outside the wire

type Prefs

type Prefs struct {
	// Theme the profile sets at launch: auto, light or dark; light and dark pin the mode before the background service answers
	Theme string
	// Window animations turned off
	ReducedMotion bool
	// Rows one wheel step scrolls before it speeds up
	ScrollSpeed float64
	// Termux layout defaults apply when the window runs inside Termux
	TermuxLayout bool
	// Longest wait for the background service to answer a request
	RequestTimeout time.Duration
	// Longest wait for the background service to be ready
	StartupTimeout time.Duration
	// Destructive commands run without their confirmation
	NoConfirm bool
	// Copies always (true) or never (false) go through the terminal's clipboard sequence, nil deciding by the connection
	ClipboardSequence *bool
	// File the CPU profile goes to, empty for none
	CPUProfile string
	// Frame rate readout over the window
	FrameRate bool
	// Timing log of the slow frames
	FrameLog bool
	// Frames drawn faster than this stay out of the timing log
	FrameLogFloor time.Duration
	// File of the timing log, empty for perf.log in the icebath folder
	FrameLogFile string
	// Folder the memory dumps go to, empty for heapdumps in the icebath folder
	HeapDumpDir string
	// Memory watchdog writes whole heap profiles and not the facts alone
	AutoHeapProfile bool
	// Bytes the memory dump folder may hold
	HeapDumpMaxBytes int64
	// Shortest wait between two automatic memory dumps
	HeapDumpCooldown time.Duration
	// Memory dump written as soon as the window starts
	HeapDumpOnStart bool
}

Settings of the window itself, resolved by the launcher before the background service answers since the terminal UI reads no settings of its own

type PromptStash

type PromptStash struct {
	PanelOpen   bool
	PanelCursor int
	// contains filtered or unexported fields
}

Session scoped newest first stack of parked composer drafts

func NewPromptStashWith

func NewPromptStashWith(maxItems int, clock func() float64) *PromptStash

Stash capped at maxItems, at least one, stamping entries with clock

func (*PromptStash) Clear

func (s *PromptStash) Clear()

func (*PromptStash) ClosePanel

func (s *PromptStash) ClosePanel()

func (*PromptStash) ComposerHint

func (s *PromptStash) ComposerHint() string

Composer hint advertising the stashed drafts

func (*PromptStash) DeleteAtCursor

func (s *PromptStash) DeleteAtCursor() bool

Deletes the highlighted entry, closing the panel once empty, false when nothing was stashed

func (*PromptStash) Indicator

func (s *PromptStash) Indicator() string

Status bar pin with the count, an up arrow while browsing, empty when nothing is stashed

func (*PromptStash) Items

func (s *PromptStash) Items() []StashEntry

Newest first copy of the entries

func (*PromptStash) Len

func (s *PromptStash) Len() int

func (*PromptStash) MoveCursor

func (s *PromptStash) MoveCursor(delta int) int

Moves the panel cursor by delta clamped to the list bounds

func (*PromptStash) OpenPanel

func (s *PromptStash) OpenPanel() bool

Opens the browse panel at the top, false when nothing is stashed

func (*PromptStash) PanelRows

func (s *PromptStash) PanelRows() []map[string]any

func (*PromptStash) Peek

func (s *PromptStash) Peek(index int) (StashEntry, bool)

func (*PromptStash) Pop

func (s *PromptStash) Pop(index int) (string, []any, bool)

Removes and returns the text and images at index, ok false when out of range

func (*PromptStash) RestoreAtCursor

func (s *PromptStash) RestoreAtCursor() (string, []any, bool)

Pops the highlighted entry and closes the panel

func (*PromptStash) Stash

func (s *PromptStash) Stash(text string, images []any) bool

Pushes a draft, false for a blank buffer with no images, the oldest dropped past the cap

type SnapshotRestore

type SnapshotRestore struct {
	Lines       []string
	Released    bool
	SessionKept bool
}

Outcome of a quick snapshot restore, the lines to show and whether the socket was released for it

type StashEntry

type StashEntry struct {
	Text      string
	Images    []any
	StashedAt float64
	Preview   string
}

One parked draft with its exact text and attached images

func (StashEntry) AsDict

func (e StashEntry) AsDict() map[string]any

Row the stash panel renderer consumes, images copied

type StashPayload

type StashPayload struct {
	Text   string
	Images []any
}

Restored draft of a ctrl s press

func ResolveCtrlS

func ResolveCtrlS(s *PromptStash, bufferText string, images []any) (string, *StashPayload)

Action one ctrl s press takes, with the restored draft for a restore

type Widget

type Widget struct {
	ID    string
	Help  string
	Usage string
	// Modal takes the keys in a window over the session, ambient sits in a zone beside the transcript
	Mode string
	// One of top-left, top-right, bottom-left, bottom-right, dock-top, dock-bottom
	Zone  string
	Width int
	// Interval at which Tick advances the state of an animated widget, zero for a still one
	Every time.Duration
	// Rows the window of a modal widget asks for at a width, six tenths of the screen when the widget has no say
	Rows func(state any, cols int) int
	// Step a modal widget takes back at the close key before its window closes, false once it has none left
	Back   func(ctx context.Context, state any) (next any, stepped bool, err error)
	Open   func(ctx context.Context, arg string) (state any, ok bool, err error)
	Input  func(ctx context.Context, state any, in WidgetInput) (next any, open bool, err error)
	Tick   func(ctx context.Context, state any) (next any, err error)
	Render func(ctx context.Context, frame WidgetFrame) (WidgetView, error)
}

Widget the terminal UI shows from its slash command, built in or provided by a plugin

type WidgetFrame

type WidgetFrame struct {
	Cols  int
	Rows  int
	State any
}

Size and state a widget renders for

type WidgetInput

type WidgetInput struct {
	Text  string
	Key   string
	Ctrl  bool
	Alt   bool
	Shift bool
}

One key press or text input delivered to a modal widget

type WidgetLine

type WidgetLine struct{ Spans []WidgetSpan }

One rendered line

type WidgetLoadFailure

type WidgetLoadFailure struct {
	Plugin  string
	Message string
}

Plugin that failed to load at a scan, with the reason

type WidgetSpan

type WidgetSpan struct {
	Text      string
	Role      string
	Bold      bool
	Dim       bool
	Italic    bool
	Underline bool
	Inverse   bool
}

Run of text in one theme role and style

type WidgetView

type WidgetView struct{ Lines []WidgetLine }

Rendered lines of a widget

type Worktree

type Worktree struct {
	Path     string
	Branch   string
	RepoRoot string
}

Tree a /worktree new created, as the gateway described it

Source Files

Jump to

Keyboard shortcuts

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