tui

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 40 Imported by: ? modules, 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 (
	ReplyDone   = "done"
	ReplyFailed = "failed"
	WaitsOnYou  = "waiting"
)

What happened in a window that may deserve the person's attention: a reply ended, a reply failed, or the agent waits on the person for an approval or an answer

View Source
const (
	NotifyOff     = "off"
	NotifyWaiting = "waiting"
	NotifyAll     = "all"
)

Values of Notifications: none, only as the agent waits on the person, or as a reply ends too

View Source
const (
	LookLight = "light"
	LookDark  = "dark"
)

Modes of Looks that take one of the styles whatever the terminal

View Source
const (
	GroupSessions   = "Sessions"
	GroupModels     = "Models"
	GroupAbilities  = "What the agent can do"
	GroupAutomation = "Automation"
	GroupSafety     = "Safety"
	GroupMedia      = "Images and video"
	GroupVoice      = "Voice"
	GroupSecrets    = "Keys and passwords"
	GroupApp        = "This app"
	GroupMore       = "More"
)

Headings the command palette lists screens under, in the order they show: what a person reaches for first comes first

View Source
const JobContext = "job"

Keys of the page of a job

View Source
const LanguageSetting = "language"

Name the cards are told a change of the window's language by, as a setting of the kit

Variables

View Source
var ErrNoEditor = lang.Errorf("No editor was found. Set EDITOR to the editor you use.")

Why nothing was opened in an editor: none is set and none of the usual ones is on this machine

Functions

func After

func After(ctx context.Context, wait time.Duration, next func() tea.Cmd) tea.Cmd

Runs what to do next once the time passed, on the UI loop and with nothing drawn again for it, or never when the context ends first: the wait between two readings of something read again every little while

func Async

func Async(work func() func() tea.Cmd) tea.Cmd

Runs work off the UI loop, then what it hands back on the UI loop, after which every card draws again as what it shows may have changed. Work that found nothing to apply hands back nil: then nothing reaches the UI loop and no card is drawn again, so reading something again every little while costs the app nothing while what is read stays the same

func AsyncTo

func AsyncTo(card wm.Card, work func() func() tea.Cmd) tea.Cmd

Async for work whose outcome one card alone shows, such as what a view reads again every little while: what the work hands back runs on the UI loop, after which the card, or the hub or menu holding it, reads what it shows anew and draws again while every other card stays as it is drawn, however many windows are open. Work that found nothing to apply hands back nil, and then nothing reaches the UI loop. Work whose outcome other cards show too, such as a setting kept, goes through Async

func Behind

func Behind(work func() func() tea.Cmd) tea.Cmd

Async for work that changes nothing a card shows by itself, such as the wait between two readings: what the work hands back runs on the UI loop and nothing is drawn again for it, so it only looks at what the app holds and hands back what to do next. Whatever that does next that a card shows reaches the card as work of its own, through Async or AsyncTo

func Call

func Call[R any](hub *cards.Hub, call func() (R, error), then func(result R) tea.Cmd) tea.Cmd

func EditFile

func EditFile(ctx context.Context, path string, done func(err error) tea.Cmd) tea.Cmd

Opens the file in the person's editor with the terminal handed over to it, the editor found off the UI loop. done runs on the UI loop once the editor is back, with ErrNoEditor when there is none and why it did not start when it could not. An editor that ends with a status of its own still ran

func EditText

func EditText(ctx context.Context, name, text string, done func(edited string, err error) tea.Cmd) tea.Cmd

Opens the text in the person's editor, in a file of the name made off the UI loop in a folder of its own that only its owner can read. done runs on the UI loop once the editor is back, with what the file holds then, the folder gone, or why the text could not be edited

func Followed

func Followed(screens []Screen) []string

Keys of every setting the screens follow

func Held

func Held(value string) (string, bool)

Text a value held as YAML names, as a picker reads the value it words, empty with false for a value that is not text. What a value names is kept, as a row words the value it holds each time it is drawn and reads it once

func Language

func Language(l *base.Language) tea.Cmd

Has the window speak the language from now on

func PickOf

func PickOf(picks string) (kind, of string)

Kind of thing a setting's Picks names and what of that kind the picker lists, written kind:argument, such as model:openrouter for the models of OpenRouter alone. The argument is the picker's own to read; empty for every thing of the kind

func Reason

func Reason(err error) string

func Reread

func Reread(card wm.Card, work func() func() bool) tea.Cmd

AsyncTo for a reading that mostly finds what its card shows already, such as what a card reads as it opens or reads again when something it follows changed: what the work hands back runs on the UI loop, where what the card holds now is known, and answers whether it changed anything the card shows. The card is drawn again only when it did; a reading that found what the card holds already, or that a later one overtook, draws nothing at all and wakes no frames. Looking on the UI loop rather than where the work ran means the answer is held against what the card holds as it arrives, not against what the card held as the reading began

func Run

func Run(ctx context.Context, screens []Screen, options Options) error

Makes the window of the screens and runs it on the terminal until the person quits or the context ends

func Theme

func Theme(name string) tea.Cmd

func Waiting

func Waiting(loaded bool, err error, none string) string

What a list says in place of its rows: why they could not be read, that they are being read, which the list shows beside a spinner until they come, else what it says of having none

Types

type Activity

type Activity struct {
	// A reply is under way, it waits on the person for an approval or an answer, a tool it called is at work, it thinks before it writes
	Busy, Waiting, Tool, Thinking bool
	// When its last reply ended well and whether it left every task of its list done, when one failed, when the person last sent it a
	// message from this window and what that said, and when anything last happened in it; zero for never
	Ended    time.Time
	Finished bool
	Failed   time.Time
	Said     time.Time
	Message  string
	Last     time.Time
	// Cell of the screen where what it does shows now, which what keeps the person company may look at: the approval or the question
	// that waits, else the composer while the person types, else the newest line while a reply is written; Spotted false for none
	Spot    image.Point
	Spotted bool
}

What a session does and what last happened in it

type Area

type Area struct {
	ID, Title, Group, About string
}

One area of the settings menu as the palette lists it: the key of its section, its name, the heading of its group and what is set there

type Ask

type Ask struct {
	Title string
	Intro []string
	// Key of the setting asked about, empty when a screen asks for itself
	Key string
	// Values held now, as YAML, by key: the setting's own and those of the settings beside it
	Values map[string]string
	// Choices listed before the things, such as what is in effect when nothing is picked
	First []Choice
	// Profile whose things are listed, the one in use when empty
	Profile string
	// What of the kind to list, as the setting's Picks says after the kind, such as the provider whose models alone are listed: the
	// picker's own to read; empty for every thing of the kind
	Of string
	// The setting at Key is a list and one item of it is asked for: Values holds that item alone under Key, nothing for a new one, and Done
	// is handed the one item picked under Key, the asker keeping the list
	Item bool
	// Word on the button that picks, the job's verb when the pick ends a job, such as Add; choose when empty
	Verb string
	// Handed the values to keep, as YAML, by key; a value of null puts a default back. The asker ends the job once they are kept
	Done func(values map[string]string) tea.Cmd
	// Empty stores the setting's empty value. It is nil for a setting that can't be left empty.
	Empty func() tea.Cmd
}

What a picker is asked

type Attention

type Attention struct {
	Kind    string
	Bell    bool
	Stopped bool
	Title   string
	Body    string
	Session string
	Folder  string
	Project string
	// How long the reply that ended ran, and the shortest whose end rings the bell, 0 for every one; a wait on the person rings whatever
	// they are
	Took, After time.Duration
	// The person is typing in the window it happened in: it is in front, the terminal has the focus, and its prompt changed a moment ago
	Typing bool
}

Something that happened, as the one rule of what deserves the person's attention weighs it: its kind, whether the bell of its kind is on, whether the person stopped the reply themselves, and what a notification of the desktop says of it: the title of the session with what looks like a secret masked, one line, and for Warp the session and the folder and project it works in

type Choice

type Choice struct {
	ID    string
	Title string
	// What the choice is, shown in the pane beside the list while it is in hand, never in the list
	Detail string
	// Heading the choice is listed under, the choices of one heading together in the order given; none for a list with no headings
	Group string
	// Word on the button while the choice is in hand, such as Add for a choice that ends a job where the others lead on; the list's own
	// verb when empty
	Verb string
}

type Doing

type Doing interface {
	// What the session shown does now and what last happened in it, read on the UI loop
	Doing() Activity
}

Card that shows a session at work, which says what the session is doing, so what keeps the person company in the app, such as a pet, reacts to it

type Flow

type Flow struct {
	// contains filtered or unexported fields
}

Steps of one job, each one question: a form of typed fields or a list to pick from, with one line above it saying what is asked. One view on the hub titled as the job through every step; esc goes back a step with the answers kept, and from the first leaves the job

func (*Flow) Ask

func (f *Flow) Ask(intro string, fields []cards.Field, verb string, next func(values map[string]string) tea.Cmd) tea.Cmd

Asks the next question in a form of typed fields under the intro, the verb on what enter does from the last field, Next when empty. Every step says what is asked: above its fields, or for a step of one field under that field, before the field's own help and never above it too. Fields asked at this place before come back as they were left

func (*Flow) End

func (f *Flow) End() tea.Cmd

Ends the job: the flow closes, and so does a menu the person came straight into for this job

func (*Flow) Hub

func (f *Flow) Hub() *cards.Hub

Hub the job runs over, which says what goes on along its bottom

func (*Flow) Pick

func (f *Flow) Pick(intro string, choices []Choice, current string, next func(choice Choice) tea.Cmd) tea.Cmd

Asks the next question as a list to pick from under the intro, the choice in use marked. A choice made at this place before is in hand again

func (*Flow) PickVerb

func (f *Flow) PickVerb(intro string, choices []Choice, current, verb string, next func(choice Choice) tea.Cmd) tea.Cmd

Pick whose button says verb, the job's verb when the choice ends the job, such as Add; choose for none

func (*Flow) Show

func (f *Flow) Show(view wm.Card) tea.Cmd

Shows the next step as a view of the caller's own, such as a page a sign-in goes on in, esc going back a step as from any other

type Heed

type Heed struct {
	Bell, Notify bool
}

What the one rule says of something that happened: whether the terminal's bell rings, and whether a notification of the desktop goes

func Weigh

func Weigh(a Attention, notify string, ignores, blurred, reported bool) Heed

The one rule of what deserves the person's attention: nothing for a reply the person stopped, nor while they type in the window it happened in; the bell where its setting for the kind says so, for a reply that ended or failed only once it ran at least as long as the bell asks; a notification where Notifications covers the kind, the terminal shows them, and the person is not looking at the terminal, as far as it reports its focus, a terminal that reports none told every time since it can't be known

type Kit

type Kit struct {
	Env     *cards.Env
	WM      *wm.Model
	History cards.History
	// contains filtered or unexported fields
}

func (*Kit) Add

func (k *Kit) Add(screens ...Screen) (tea.Cmd, error)

Adds screens while the app runs, such as the widgets of plugins, after those the app started with so a slash command of theirs wins; one with the ID of an added screen takes its place. Each is readied as a screen the app starts with is: its keys, the keys saved for them, its keymap contexts and actions, the settings it follows and what it learns before anyone opens it

func (*Kit) Apply

func (k *Kit) Apply(apply func() tea.Cmd)

func (*Kit) ApplyBehind

func (k *Kit) ApplyBehind(apply func() tea.Cmd)

Apply for a change no card shows by itself, such as what a list kept off the screen reads: it runs on the UI loop and nothing is drawn again for it, so what it changes that shows is drawn by what it does, such as Restatus or a Touch

func (*Kit) ApplyTo

func (k *Kit) ApplyTo(card wm.Card, apply func() tea.Cmd)

Apply for a change one card alone shows, which draws again while every other card stays as it is drawn

func (*Kit) Areas

func (k *Kit) Areas(areas []Area)

Tells the kit the areas of the settings menu, which the palette then lists in place of the screens that are their pages

func (*Kit) Ask

func (k *Kit) Ask(hub *cards.Hub, title string, field cards.Field, submit string, done func(text string) tea.Cmd) tea.Cmd

Asks one question over the hub in a form of the one field: typed into, its help under it, enter handing the trimmed answer to done and the button labeled submit. An empty answer is refused

func (*Kit) AskAny

func (k *Kit) AskAny(hub *cards.Hub, title string, field cards.Field, submit string, done func(text string) tea.Cmd) tea.Cmd

Ask that takes an empty answer too, for a value a person takes away by leaving its field empty

func (*Kit) AskOr

func (k *Kit) AskOr(hub *cards.Hub, title string, field cards.Field, submit string, done func(text string) tea.Cmd, left func() tea.Cmd) tea.Cmd

Ask whose form runs left when it closes with no answer given, by the way back or with its hub, for an asker that waits for the answer

func (*Kit) Attend

func (k *Kit) Attend(a Attention) tea.Cmd

Tells the person of what happened as Weigh says, through the kit's writer to the terminal: the bell, then the notification in the form the terminal takes it, wrapped for tmux or screen where one stands between

func (*Kit) Changed

func (k *Kit) Changed(key, value string) tea.Cmd

Tells every screen that follows the setting its new value, as YAML, and every card that it changed. A value as the settings service shows it that is not the value in use, such as text that names a variable as ${NAME}, is read again for use first, off the UI loop, so what follows the setting acts on what it comes to and never on the reference; one that could not be read is said in the log and told to none

func (*Kit) Changes

func (k *Kit) Changes() uint64

Count of the changes to the screens and the areas so far, so what is worked out of the screens, such as which areas have a page or which settings a picker keeps together, is worked out again only once it moved

func (*Kit) Choose

func (k *Kit) Choose(hub *cards.Hub, picks string, ask Ask) (tea.Cmd, bool)

Opens the picker of a kind of thing over the hub, handed what of the kind to list when picks names it after the kind and the ask does not; false when no screen offers one

func (*Kit) CloneSession

func (k *Kit) CloneSession(profile, id string) tea.Cmd

Clones the session of the profile into a new session of this terminal, shown in a window of its own

func (*Kit) Dark

func (k *Kit) Dark() (dark, told bool)

Whether the terminal said the color of its background, and whether it is dark

func (*Kit) Drop

func (k *Kit) Drop(prefix string)

Drops the screens added under IDs that start with the prefix, with the keys that open them and the actions no other screen adds

func (*Kit) EditBeside

func (k *Kit) EditBeside(name, text string, done func(edited string, err error) tea.Cmd) tea.Cmd

Opens the text in the person's editor in a terminal window beside what they work in, which stays on the screen and goes on while they edit, such as the list of the actions while the keys of the keymap are edited: in a file of the name made off the UI loop in a folder of its own that only its owner can read. done runs on the UI loop once the editor ended or its window was closed, with what the file holds then, the folder gone, or why the text could not be edited

func (*Kit) Emptying

func (k *Kit) Emptying(hub *cards.Hub, list wm.Card, ask Ask, current string)

Emptying lets the empty key run the ask's Empty and close list, while list is on top of hub and current holds a choice. A picker that builds its own list calls it right after it pushes the list.

func (*Kit) Flow

func (k *Kit) Flow(hub *cards.Hub, title string) *Flow

Starts a job in steps over the hub, titled as the job; its first question shows it

func (*Kit) FlowAlone

func (k *Kit) FlowAlone(title string) *Flow

Starts a job in steps in a dialog of its own, titled as the job; its first question shows the dialog

func (*Kit) Focused

func (k *Kit) Focused() wm.Card

func (*Kit) HeldElsewhere

func (k *Kit) HeldElsewhere(id string) bool

Whether another terminal holds the session the server runs, false when no screen shows sessions

func (*Kit) Hub

func (k *Kit) Hub(key string, root wm.Card) *cards.Hub

Hub of a dialog of its own over its first view

func (*Kit) Indicate

func (k *Kit) Indicate(indicator string) tea.Cmd

Has every spinner of the app, those of the windows and of the bar alike, turn through the frames of the busy indicator, the wheel of the style worn for the unicode one; the style is worn again with them

func (*Kit) Indicator

func (k *Kit) Indicator() string

Busy indicator the spinners of the app turn as

func (*Kit) Job

func (k *Kit) Job(hub *cards.Hub, title string, run func(out Output) Outcome, ended func() tea.Cmd) tea.Cmd

Runs a job on a page pushed over the hub that shows what it says as it comes, carried on to its end when the page is closed. How it ended is the last line while the page shows, and the note of the hub once the page closed. ended runs on the UI loop once the job is over, such as to read a list again

func (*Kit) Look

func (k *Kit) Look(change func(looks *Looks)) tea.Cmd

Changes what the window wears from, and wears the style that comes to

func (*Kit) Mark

func (k *Kit) Mark(marked, on bool) string

Mark before a choice of a list where one choice is in use: filled on that one, hollow on the rest, nothing where no choice is marked

func (*Kit) Mount

func (k *Kit) Mount(area, argument string) (*cards.Hub, tea.Cmd, bool)

Opens the screen that names the area as the page of that area, handing it the argument: the hub its first view went into, with what its Open returned. False when no screen names the area; a nil hub when the screen showed nothing

func (*Kit) Move

func (k *Kit) Move(folder string) error

Moves the terminal into the folder its views and the sessions it starts work in, which every reader takes from Env.WorkDir; the process's own folder never changes. An error says why it could not, the terminal staying where it was. Whoever asks looks at the folder off the UI loop first, so the look here finds it in the disk cache

func (*Kit) Notifier

func (k *Kit) Notifier() tty.Notifier

The terminal this window runs in as its notifications go, read off the environment of the process once

func (*Kit) Notifying

func (k *Kit) Notifying(mode string)

Sets what sends a notification of the desktop, as Notifications says: off, waiting or all

func (*Kit) Open

func (k *Kit) Open(id, argument string) tea.Cmd

func (*Kit) OpenSession

func (k *Kit) OpenSession(profile, id string) tea.Cmd

Opens the session of the profile, the one in use for none, in a window of its own, or focuses the window that shows it

func (*Kit) OwnServer

func (k *Kit) OwnServer() bool

Whether the server the window runs on is this process's own

func (*Kit) Pages

func (k *Kit) Pages(profile string) map[string][]Page

Pages of the areas the screens are the pages of, by the key of each area, read from every screen that has some: off the UI thread, on a kit Still made on it

func (*Kit) Pick

func (k *Kit) Pick(hub *cards.Hub, title, verb string, choices []Choice, current string, pick func(choice Choice) tea.Cmd) tea.Cmd

Opens a list of choices by their titles over the hub, or in a hub of its own when hub is nil, the one in use marked on a list that has one, what the choice in hand is in the pane beside the list. Enter or the button labeled verb runs pick with the highlighted choice and closes the list

func (*Kit) PickAsked

func (k *Kit) PickAsked(hub *cards.Hub, ask Ask, title string, intro []string, verb string, choices []Choice, current string,
	pick func(choice Choice) tea.Cmd) tea.Cmd

PickAsked is PickFrom for a picker's ask. While the list is on top and a choice is held, the empty key runs the ask's Empty.

func (*Kit) PickFrom

func (k *Kit) PickFrom(hub *cards.Hub, title string, intro []string, verb string, choices []Choice, current string, pick func(choice Choice) tea.Cmd) tea.Cmd

Pick with lines above the choices that say what is being chosen, for a title that does not

func (*Kit) Picker

func (k *Kit) Picker(picks string) (Picker, bool)

Picker of the kind a setting's Picks names, the argument after the kind left to the picker; false when no screen offers one. Every row of a setting that names a kind asks, so the pickers are gathered by kind once and again only when the screens changed, the first screen that offers a kind winning as the screens are ordered

func (*Kit) Refuses

func (k *Kit) Refuses(profile, backend, then string) string

Why the window can't go to the profile with the server at backend, the profile's saved one when empty: one line naming the work under way on this terminal's own server that the move would leave, ending "then " and what to do then; empty when it can. Asks the server, so it is called off the UI loop

func (*Kit) Report

func (k *Kit) Report(report func(status *wm.Status))

Adds what a screen shows on the bar. The report runs only after Restatus, never on every frame

func (*Kit) Restatus

func (k *Kit) Restatus()

Has the bar ask every report again before it is next drawn, for a screen whose part of the bar changed

func (*Kit) RunBy

func (k *Kit) RunBy(id string, owner *Owner) string

One line that says who runs the session when this terminal may not write it, empty when it may or when no screen shows sessions

func (*Kit) Runner

func (k *Kit) Runner(id string, owner *Owner) string

Few words for who runs the session when this terminal may not write it, empty when it may or when no screen shows sessions

func (*Kit) Screens

func (k *Kit) Screens() []Screen

func (*Kit) Sessions

func (k *Kit) Sessions() []string

Sessions the windows of every space show, the focused one first

func (*Kit) SessionsVersion

func (k *Kit) SessionsVersion() uint64

Count that moves each time what the server runs or what the windows here show changes, which rows that say who runs a session follow

func (*Kit) Set

func (k *Kit) Set(name, value string) tea.Cmd

Sets a setting of the kit by the name its cards read it by, telling every card it changed

func (*Kit) SetRefusing

func (k *Kit) SetRefusing(refuses func(profile, backend, then string) string)

Sets what says why the window can't move to the server a profile uses

func (*Kit) SetSessionDesk

func (k *Kit) SetSessionDesk(desk SessionDesk)

Sets what opens, clones and tells the owner of sessions for every screen

func (*Kit) Show

func (k *Kit) Show(key string, root wm.Card) (*cards.Hub, tea.Cmd)

Shows the first view of a screen: as the page of its area when the settings menu is opening it, else in a dialog of its own. Called by Open before it returns

func (*Kit) Shown

func (k *Kit) Shown() []Shown

Sessions the windows of every space show with their profiles, each once, the focused one first

func (*Kit) Slash

func (k *Kit) Slash(line string) (tea.Cmd, bool)

func (*Kit) Still

func (k *Kit) Still() *Kit

The kit as it stands on the UI loop now, for work off it such as reading Pages: the folder of the session in view, the settings and the screens as they are now, so what the UI loop changes meanwhile, such as a session moving into a worktree, is never read from another thread

func (*Kit) Terminal

func (k *Kit) Terminal() *cards.Terminal

func (*Kit) TerminalCommand

func (k *Kit) TerminalCommand(line string) *cards.Terminal

Terminal window that runs one command line through the shell in the folder the window works in, closing once it ends

func (*Kit) TerminalProgram

func (k *Kit) TerminalProgram(argv []string, done func(cards.TerminalEnd) tea.Cmd) *cards.Terminal

Terminal window that runs a program with its arguments in the folder the window works in, with no shell between, such as the person's editor on a file: it closes once the program ends well and stays open with what the program printed when it fails. done is told once how the program ended and what it left on the screen, or that it did not start or its window was closed while it ran

func (*Kit) WatchSessions

func (k *Kit) WatchSessions(tell func() tea.Cmd) func()

Calls tell on the UI loop each time what the server runs changes, until the function handed back is called

func (*Kit) Wear

func (k *Kit) Wear(saved string) tea.Cmd

Wears the saved style again once a source handed the app's styles anew, as one of a source has it now; while they lack it the one worn stays as long as they still have that, else the default one is worn. A style of the kit is left to whatever follows the saved one. The light style stands in for the saved one where the look says the window wears it

func (*Kit) While

func (k *Kit) While(hub *cards.Hub) func() context.Context

Context for what a view reads to show itself, by the hub it shows on: it ends once the hub leaves the screen, so a reading still under way for a page a person left stops rather than running on behind, and it is made anew the next time it is asked for after that. Asked for on the UI loop as a reading starts. Whoever takes the reading in drops what it found once the context ended and reads again when the page is back, as what a stopped reading answers is no answer

func (*Kit) Worn

func (k *Kit) Worn() string

Name of the style the window wears now, empty before the style it is set to is known

type LanguageMsg

type LanguageMsg struct {
	Language *base.Language
}

The window speaks another language

type Looks

type Looks struct {
	Style, Light string
	// LookLight or LookDark to take one of the two always, anything else to go by the background of the terminal
	Mode string
}

Which style the window wears: the style it is set to, the one for a light background, and which of the two it takes

type Next

type Next struct {
	Label    string
	Question *cards.Question
	Run      func() tea.Cmd
}

What the page of a job offers once the job ended, such as installing what it read: the word on its key, a question asked along the bottom of the page first when there is one, and what it runs on the UI loop, once

type Options

type Options struct {
	Style string
	Keys  map[string][]string
	// Frame rate readout in the corner, and the log of the frames slower than the floor to the file
	FrameRate, FrameLog bool
	FrameLogFloor       time.Duration
	FrameLogFile        string
	// Mouse tracking asked of the terminal, as the setting of the mouse names it: wm.MouseAll, wm.MouseClicks or wm.MouseOff, every move
	// when empty
	Mouse string
	// Value as YAML of every setting a screen follows, by key, as it is read for use
	Settings map[string]string
	// Reads the value as YAML of a setting as it is read for use: of one that a screen added while the app runs follows, when the app did
	// not read it as it started, and of one whose change was told as Shown says the settings service shows it
	Read func(key string) (string, error)
	// Whether a value as YAML that the settings service shows of a setting is not the value in use, such as text that names a variable as
	// ${NAME} or a secret masked: a change told with such a value is read again with Read before the screens that follow the setting hear
	// it
	Shown func(value string) bool
	// Variables the shells of terminal windows run with over this process's own, as KEY=value, read as each shell starts
	ShellEnv func() []string
	// Styles beside those of the kit by where they come from, such as the styles folder of the profile
	Styles map[string][]theme.Theme
	// What the terminal's background was the run before, LookLight, LookDark or empty, which the first frame is worn for until the terminal
	// answers; and how what the window learns of it is kept for the next run, called off the UI loop, nil for not at all
	Background string
	Remember   func(dark bool)
	// Told what the terminal was found to draw and the way pictures are drawn in it each time that changed, off the UI loop, so the doctor
	// and the report of the installation can say it; nil for no one
	Graphics func(report gfx.Report)
	// The server the window runs on is this process's own, so the replies it runs wait while the window is suspended to the shell
	Own bool
	// Windows the last run kept, opened again as the terminal starts, nil for none; and what keeps the windows for the next run, called off
	// the UI loop a moment after they change and once the program ended, nil for nothing
	Layout *wm.Layout
	Keep   func(layout wm.Layout)
}

type Outcome

type Outcome struct {
	// A failure the job did not say as a line
	Err error
	// Ended with problems it said as lines
	Problems bool
	// Something the job made that the person may copy, such as a path, said on the last line
	Made, MadeWhat string
	// What the job says of how it ended, in place of the usual words: the last line, and the note of the hub once the page closed
	Note string
	// The note tells how to go on rather than that the job went well, such as what to do by hand that the job could not
	Info bool
	// Builds, on the UI loop, what takes the place of the page once the job ended while the page shows, such as a list of what the job
	// came to; nil keeps the page
	Result func() wm.Card
	// What the page offers once the job ended, nil for nothing
	Next *Next
}

How a job ended

func Stream

func Stream[T any](receive func() (T, error), take func(event T, outcome *Outcome)) Outcome

Reads the stream of a job to its end, each event handed to take with the outcome to fill in. A service ends a stream once it said everything, so its end is the job done as take found it, and a failure to read is the job's failure

type Output

type Output interface {
	// A line of what happened, in its tone
	Line(text string, tone Tone)
	// What goes on now, shown under the lines with a spinner until the next
	Status(text string)
	// Rows under the titles of their columns, drawn as a table at the width of the page
	Table(columns []render.Column, rows [][]string)
	// Text written in markdown, such as a file the job read, drawn formatted at the width of the page
	Markdown(text string)
}

Where a job tells the person what it does

type Owner

type Owner struct {
	Process, Purpose, Host string
	Pid                    int32
	Here                   bool
}

Process that runs a session, as the session store names it: its key, empty while none runs it, its pid, its purpose (window, server or command), its computer, and whether it is the process that answers this terminal

type Page

type Page struct {
	// What the page is called, and the titles of the pages above it inside the area, outermost first
	Title string
	Trail []string
	// One line saying what is there
	About string
	// More words a search reads, such as the names of what the page shows
	Words string
	// Argument the screen opens the area with to show the page, as its Open takes it after the profile; empty for the area's own page
	Argument string
	// Keys of the settings the page shows rows or controls of, so a setting found by a search opens the page with its control over it; a
	// key ending in a dot stands for every key under it
	Keys []string
}

A page inside an area that a search of Settings finds and opens: the area on that page, the keys on it

func Remembered

func Remembered(key string, read func() []Page) []Page

Pages as last read under the key, read again behind so the next answer is fresh: how Pages answers at once for a screen whose things take time to find, such as places found by probing this computer. The first call for a key waits for its reading; a reading that fails, nil, keeps what was read before

func (Page) Shows

func (p Page) Shows(key string) bool

Whether the page shows the setting at the key

type Picker

type Picker struct {
	// Opens the list to pick from over the hub
	Open func(kit *Kit, hub *cards.Hub, ask Ask) tea.Cmd
	// Keys of the settings kept as one choice with the setting at key: one row shows them all and their own rows are left out. Nil for
	// a kind whose choice is one value
	Beside func(key string) []string
	// What the row shows for the values held; the value in the settings service's own words when nil or when it answers nothing
	Shown func(ask Ask) string
}

What a screen offers for every setting whose value names its kind of thing, registered under the name those settings give in Picks

type Screen

type Screen struct {
	ID string
	// ID of the command that opens the screen from the palette, the keys and the bar, open.<ID> when empty
	Command string
	Title   string
	Short   string
	// Heading the command palette lists the screen under, one of the Group names, and its place among the screens of that heading,
	// lower first. A screen that names no heading is listed under More
	Group string
	Order int
	Slash []string
	// More names the screen answers as a slash command, which the slash list, /help and the palette leave out
	Aliases []string
	Usage   string
	Keys    []string
	Actions []keys.Action
	Where   map[string]string
	// Opened once when the app starts
	Startup bool
	// Listed with its key on an empty screen
	Suggest bool
	Ready   func(kit *Kit) bool
	Open    func(kit *Kit, argument string) tea.Cmd
	// Settings the screen follows by key, each run with the value as YAML once the app starts and again whenever it changes
	Follows map[string]func(kit *Kit, value string) tea.Cmd
	// Key of the settings section the screen is the page of. The screen is then one area of the settings menu: the palette, its slash
	// commands, Kit.Open and the menu itself all show it there
	Area string
	// Opens the settings menu on the area with the section key and hands the argument to the page of that area. Only the screen of the
	// menu itself has one
	Menu func(kit *Kit, area, argument string) tea.Cmd
	// Pickers the screen offers every other screen, by the kind of thing each picks
	Pickers map[string]Picker
	// Pages inside the area the screen is the page of, as a search of Settings finds them: read each time a search starts, off the UI
	// thread on a kit Still made as it started, so it may ask a service; the profile is the one whose settings are shown
	Pages func(kit *Kit, profile string) []Page
	// Runs once as the app starts, for what a screen learns before anyone opens it
	Start func(kit *Kit) tea.Cmd
	// Values a hole of its usage takes as a person completes its slash line, such as the styles for [name]: called off the UI loop on a kit
	// Still made on it, with the hole as the usage names it and the words typed before it; nil for a screen whose holes take anything
	Values func(kit *Kit, hole string, words []string) []cards.Offer
	// Card of the screen made again for one it made the run before under the key, as the window opens the windows the last run kept: a new
	// card, which is handed the state the old one kept (wm.Stateful) before it starts, so the key it has now may differ; nil for a key that
	// is not the screen's or a card it makes no more of, such as a window that showed no session. The state is what the old card kept, nil
	// for none
	Reopen func(kit *Kit, key string, state json.RawMessage) wm.Card
}

type SessionDesk

type SessionDesk interface {
	// Opens the session of the profile, the one in use for none, in a window of its own, or focuses the window that shows it
	Open(profile, id string) tea.Cmd
	// Clones the session of the profile into a new session of this terminal, shown in a window of its own
	Clone(profile, id string) tea.Cmd
	// One line that says who runs the session when this terminal may not write it, empty when it may; nil owner when the screen read none
	RunBy(id string, owner *Owner) string
	// The same in a few words, as a list's column says it
	Runner(id string, owner *Owner) string
	// Whether another terminal holds the session the server runs, so what it asks is that terminal's to answer
	HeldElsewhere(id string) bool
	// Calls tell on the UI loop each time what the server runs changes, until the function handed back is called
	Watch(tell func() tea.Cmd) func()
	// Count that moves each time what the server runs or what the windows here show changes
	Version() uint64
}

What the windows of sessions do for every screen that lists or opens sessions

type Sessioned

type Sessioned interface {
	// Id of the session shown, empty before it has one
	Session() string
	// Profile the session shown runs on, which requests about it name
	Profile() string
}

Card that shows one session of the agent, such as a session window

type Shown

type Shown struct{ ID, Profile string }

A session a window shows and the profile it runs on

type ThemeMsg

type ThemeMsg struct {
	Name string
}

type Tone

type Tone int

How a line of a job's output reads, which the page colors it by

const (
	TonePlain Tone = iota
	// The heading of a step, set apart from the lines before it
	ToneStep
	ToneGood
	ToneWarn
	ToneBad
	// Said by the way, such as where a file is
	ToneDim
	// Set apart for the person to read, such as what the job leads with
	ToneNote
)

type Window

type Window struct {
	// contains filtered or unexported fields
}

The window of the screens, made and not yet run on a terminal

func New

func New(ctx context.Context, screens []Screen, options Options) (*Window, error)

Makes the window of the screens: its keymap with the action that opens each screen, the places a screen names and the actions it adds, the saved keys over them, and what each screen makes of the first values of the settings it follows. What the keymap refuses of a screen is the error, and no window is made

func (*Window) Run

func (w *Window) Run() error

Runs the window on the terminal until the person quits or the context it was made with ends

Jump to

Keyboard shortcuts

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