cards

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: 28 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

Overview

Window manager cards sharing one environment of theme, keys and settings

Index

Constants

View Source
const (
	FormContext     = "form"
	FormTextContext = "form.text"
	FormPickContext = "form.pick"
)

Keymap contexts of a form: the keys of every row, of a row typed into and of a row picked from

View Source
const DefaultScrollback = 10000

Rows of scrollback a terminal window keeps when no setting names a count

View Source
const HubContext = "hub"

Keymap context of the row keys every screen of things to manage answers the same way

View Source
const HubViewContext = "hub.view"

Keymap context of the keys a hub answers on every view that takes no typing, help and reading again

Variables

This section is empty.

Functions

func DraftPath

func DraftPath(dir, sessionID string) string

File the draft of a session is kept in under dir

func Graphemes

func Graphemes(s string) []string

Grapheme clusters of a string, each one cell wide or wider

func OverlayPopup

func OverlayPopup(above []string, popup []string) []string

Paints the completion popup over the last rows of the lines above the composer, leaving the layout where it was

func RegisterHubKeys

func RegisterHubKeys(km *keys.Map)

Keys shared by every screen of things to manage, registered with the keymap of the app

func ShellWords

func ShellWords(line string) ([]string, error)

Words of a command line split the way a POSIX shell splits them, honoring quotes and backslashes

func WrapIndent

func WrapIndent(text string, w, indent int) []string

Lines of styled text wrapped to a width, every line after the first led by an indent of spaces

func WrapStyled

func WrapStyled(text string, w int, fg color.Color) []string

Text wrapped to a width in a color

Types

type Attachment

type Attachment struct {
	Path      string
	MediaType string
	Data      []byte
}

Image file attached to a message

type Box

type Box struct{ X, Y, W, H int }

Box of cells a section or row took on the last paint

func (Box) Contains

func (b Box) Contains(x, y int) bool

Reports whether a cell lies in the box

type Button

type Button struct {
	ID    string
	Label string
	On    bool
	// Buttons of a higher rank leave the bar first when it runs out of room
	Rank int
	// Gap drawn before the button
	Gap bool
}

Button of a toolbar, its action, its words and whether it stands pressed

type Chip

type Chip struct {
	Kind  string `json:"kind"`
	Label string `json:"label"`
	Text  string `json:"text,omitempty"`
	Path  string `json:"path,omitempty"`
	Mime  string `json:"mime,omitempty"`
}

Pasted text or an attached file a label in the prompt stands for, kept with the prompt in the history and the drafts

type Choice

type Choice struct {
	Value   string
	Label   string
	Meaning string
}

One choice of a field, the value sent and the words shown

type CommandMsg

type CommandMsg struct {
	Session string
	Name    string
	Args    string
}

Slash command a session composer parsed

type Composer

type Composer struct {
	SessionID string
	// Store of the prompts the history ring recalls, nil keeping nothing
	History History
	// Chips the labels of a prompt stand for, kept with it in the history and its draft
	Chips func(text string) []Chip
	// Called with an entry put into the prompt from the history or a kept draft, so the app takes its chips back
	OnRecall func(Entry)
	// Reports whether nothing typed may reach disk, the draft and history kept in memory alone
	Volatile func() bool
	// Hands every sent line to the app as typed, commands and shell lines included
	Literal bool
	// Text an empty prompt shows in place of the command and palette legend
	Hint string
	// Puts the highlighted offer in from its replace offset when the popup is accepted
	Apply func(text string, replace int) tea.Cmd
	// Called before the prompt is read for sending, for an app that rewrites its draft first
	Sending func()
	// Stops the running reply, what the send button does while a reply runs and nothing is typed
	OnStop func() tea.Cmd
	// Whether the session is out of reach, the send button showing it cannot send
	Offline bool
	// Frame count of the owner's animation clock, the send button pulsing with it while a reply runs
	Phase int
	// contains filtered or unexported fields
}

Multi line prompt with a history ring over the shared store, the app's completion candidates, attachments and a draft kept per session

func NewComposer

func NewComposer(t theme.Theme, km *keys.Map, dir string, base func() string) *Composer

Builds a composer on the keymap keeping the drafts of the sessions it binds under dir, none when empty, completing paths against base

func (*Composer) Action

func (c *Composer) Action(id string) tea.Cmd

Carries out a keymap action of the prompt or its completion popup

func (*Composer) Append

func (c *Composer) Append(text string) tea.Cmd

Inserts text at the end of the prompt, the cursor following it

func (*Composer) AtBottom

func (c *Composer) AtBottom() bool

Reports whether a down key leaves the prompt, it being empty or the cursor on its last screen row with nothing selected

func (*Composer) AtTop

func (c *Composer) AtTop() bool

Reports whether an up key leaves the prompt, it being empty or the cursor on its first screen row with nothing selected

func (*Composer) Attach

func (c *Composer) Attach(path string) tea.Cmd

Attaches the image at the path, as the attach command does

func (*Composer) Attachments

func (c *Composer) Attachments() []string

Files attached to the next message

func (*Composer) BackToDraft

func (c *Composer) BackToDraft()

Leaves a recalled history entry for the unsent draft, what was typed into the entry kept for when it comes back

func (*Composer) Bind

func (c *Composer) Bind(sessionID string) tea.Cmd

Binds the prompt to a session: text typed before any session was bound moves to it, a prompt bound to another session keeps its draft there and takes the draft of the new one

func (*Composer) ClearSelection

func (c *Composer) ClearSelection()

Drops the selection, the text left as it is

func (*Composer) Click

func (c *Composer) Click(x, y int) (tea.Cmd, bool)

Sends when the click lands on the send button, or stops the running reply when nothing is typed, reporting whether it took the click

func (*Composer) Completing

func (c *Composer) Completing() bool

Reports whether the completion popup takes keys for the text typed now, a popup that only informs taking none

func (*Composer) Completions

func (c *Composer) Completions() []string

Candidates shown in the popup, nil when it is closed

func (*Composer) Cursor

func (c *Composer) Cursor() *tea.Cursor

Cursor inside the input area, on the search line while a search runs

func (*Composer) Cut

func (c *Composer) Cut(span Selection) tea.Cmd

Removes the span when it is still the one selected, as a cut does once the clipboard holds its text

func (*Composer) Drag

func (c *Composer) Drag(x, y int)

Extends the selection a press started to a cell of the composer

func (*Composer) Empty

func (c *Composer) Empty() bool

Reports whether the input is empty with nothing attached

func (*Composer) Fit

func (c *Composer) Fit(w int) int

Fits the input beside the send button at width w, wrapping the text there so the height reads true

func (*Composer) Height

func (c *Composer) Height() int

Rows the composer wants, two at least unless set lower, growing with the wrapped text only. The completion popup floats over the rows above the composer (see Popup) so opening, narrowing or closing it never moves the layout

func (*Composer) Holds

func (c *Composer) Holds(x, y int) bool

Reports whether a cell of the composer shows the text of the input, where a press places the cursor and a drag selects

func (*Composer) Insert

func (c *Composer) Insert(text string) tea.Cmd

Inserts text at the cursor as if typed

func (*Composer) Kept

func (c *Composer) Kept() []string

Texts the prompt keeps out of view while it shows another slot, the draft and the edited history entries, whose chips must stay

func (*Composer) Offer

func (c *Composer) Offer(value string, offers []Offer, replace int)

Shows the candidates the app found for a prompt text, the first one highlighted, none closing the popup. An answer for a text no longer typed is dropped; the list on screen follows the typing on its own until the answer for the current text replaces it

func (*Composer) Offset

func (c *Composer) Offset() int

Place of the cursor in the prompt, counted in runes from its start

func (*Composer) Popup

func (c *Composer) Popup(w int) []string

Completion rows the owner paints over the rows right above the composer, only those for the text typed now, nil when closed or unfocused

func (*Composer) Press

func (c *Composer) Press(x, y int)

Starts a selection at a cell of the composer, the cursor going to the grapheme drawn there

func (*Composer) Rebind

func (c *Composer) Rebind()

Rebuilds the editing bindings of the input from the keymap, every other key only typing text

func (*Composer) Recalling

func (c *Composer) Recalling() (int, bool)

Position in the history while recalling, false at the unsent draft

func (*Composer) Release

func (c *Composer) Release()

Ends the selection a press started, a press and release on one place leaving the cursor there with nothing selected

func (*Composer) Revision

func (c *Composer) Revision() int

Number that changes whenever the draft is replaced as a whole, by a send, a recall, a search, a session switch or the app setting it, so work started for an older draft can tell it is stale

func (*Composer) SearchKey

func (c *Composer) SearchKey(id string) (tea.Cmd, bool)

Takes an action while a search runs: the search key steps older, the completion key narrows it to the bound session or widens it again, editing keys change the query, escape puts the prompt back, enter and any other key keep the match for editing; reports whether the action was used up and the command it needs

func (*Composer) Searching

func (c *Composer) Searching() bool

Whether a reverse search runs

func (*Composer) SelectAll

func (c *Composer) SelectAll()

Selects the whole prompt

func (*Composer) Selection

func (c *Composer) Selection() (Selection, bool)

Selected span of the prompt, false when nothing is selected

func (*Composer) Send

func (c *Composer) Send() tea.Cmd

Sends the prompt as it is typed, whatever the completion popup offers; a line ending in a backslash breaks there instead

func (*Composer) SetBusy

func (c *Composer) SetBusy(on bool)

Tells the send button whether a run is going, so it offers to steer it

func (*Composer) SetDraftDir

func (c *Composer) SetDraftDir(dir string)

Directory the drafts of the bound sessions are kept under, empty keeping them in memory

func (*Composer) SetFocus

func (c *Composer) SetFocus(on bool) tea.Cmd

Moves the input focus with the card focus

func (*Composer) SetMinRows

func (c *Composer) SetMinRows(n int)

Sets the rows the prompt keeps while it holds less, one on a small terminal where every row counts

func (*Composer) SetTheme

func (c *Composer) SetTheme(t theme.Theme)

Paints the input with the theme, the prompt mark on the first row only so a long prompt never reads as several

func (*Composer) SetValue

func (c *Composer) SetValue(text string) tea.Cmd

Replaces the text with the cursor at its end, the completion popup closed until the app offers again and a recalled entry left for the draft slot

func (*Composer) SetValueAt

func (c *Composer) SetValueAt(text string, offset int) tea.Cmd

Replaces the text with the cursor at a rune offset of it, otherwise as SetValue does

func (*Composer) Status

func (c *Composer) Status() string

Short trailer naming the attachments with their size and the history position

func (*Composer) Update

func (c *Composer) Update(msg tea.Msg) tea.Cmd

Takes pasted text and typed keys the keymap left unbound, which only ever insert their text

func (*Composer) Value

func (c *Composer) Value() string

Text typed so far

func (*Composer) View

func (c *Composer) View(w, h int) string

type Entry

type Entry struct {
	Text    string `json:"text"`
	Chips   []Chip `json:"chips,omitempty"`
	Session string `json:"sid,omitempty"`
	Cwd     string `json:"cwd,omitempty"`
	At      int64  `json:"ts,omitempty"`
}

Prompt as it was sent or left as a draft, with the chips of its labels, the session it was typed in, the folder and when

type Env

type Env struct {
	Theme theme.Theme
	Keys  *keys.Map
	// Lifetime of the app
	Ctx context.Context
	// Setting values as the app holds them keyed by name, empty while unset
	Settings func() map[string]string
	// Directory the active session works in, Root while unset
	WorkDir func() string
	// Directory exports and the shell fallback use
	ProjectDir string
	// Project root the sessions of this instance belong to
	Root string
	// Version of the program, handed to the shells of terminal windows
	Version string
	// Terminal graphics as probed, what the terminal draws and how big its cells are
	Graphics *gfx.Terminal
	// Hands a message to the program from outside its update loop
	Send func(tea.Msg)
}

Live state every card may read, nil members standing for parts the app did not build

type Field added in v1.0.11

type Field struct {
	ID    string
	Label string
	// One line shown under the field while it has the cursor
	Help string
	Kind FieldKind
	// Text of the field, the value of a choice, true or false for a switch
	Value       string
	Choices     []Choice
	Required    bool
	Placeholder string
	// Kept behind the more options row until it is opened
	More bool
	// Says what is wrong with a value, empty when it is fine
	Check func(value string) string
}

One field of a form

type FieldKind added in v1.0.11

type FieldKind int

Kind of value a form field holds

const (
	// One line of text
	FieldText FieldKind = iota
	// Text shown as dots
	FieldSecret
	// Whole or decimal number typed as text
	FieldNumber
	// Yes or no
	FieldBool
	// One of a set of choices
	FieldChoice
	// Line of text that takes no answer
	FieldNote
	// Button that runs something of the caller's when pressed
	FieldButton
)

type Form

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

Card of fields typed into or picked from, checked and sent with one key

func NewForm

func NewForm(env *Env, spec FormSpec) *Form

Builds a form from the spec, the cursor on its first field

func (*Form) Commit

func (f *Form) Commit(id, value string) tea.Cmd

Sets a field's value and hands it to Changed, as a choice made in a picker of the caller's

func (*Form) Contexts

func (f *Form) Contexts() []string

func (*Form) Cursor

func (f *Form) Cursor() *tea.Cursor

func (*Form) Hints

func (f *Form) Hints() []wm.Hint

func (*Form) Init

func (f *Form) Init() tea.Cmd

func (*Form) SetBusy

func (f *Form) SetBusy(on bool)

Ignores sending while the caller waits on the last one

func (*Form) SetError

func (f *Form) SetError(id, text string)

Shows what is wrong with a field under it, such as a refusal of the value, and puts the cursor on it

func (*Form) SetFields

func (f *Form) SetFields(fields []Field)

Replaces the fields, such as when an answer shows or hides others, the cursor staying on the field it was on

func (*Form) SetValue

func (f *Form) SetValue(id, value string)

Sets the value of a field by id

func (*Form) Title

func (f *Form) Title() string

func (*Form) Update

func (f *Form) Update(msg tea.Msg) (wm.Card, tea.Cmd)

func (*Form) Value

func (f *Form) Value(id string) string

Value of a field by id, empty for an unknown one

func (*Form) Values

func (f *Form) Values() map[string]string

Values of every field by id

func (*Form) View

func (f *Form) View(w, h int) string

type FormSpec

type FormSpec struct {
	Title string
	// Lines above the fields, such as the usage line of a command
	Intro  []string
	Fields []Field
	// Word on the button that sends the form
	Submit string
	// Handed the values by field id once every field checks out
	Done func(f *Form, values map[string]string) tea.Cmd
	// Runs on the cancel key, nil closing nothing on its own
	Cancel func(f *Form) tea.Cmd
	// Opens a long list of choices in a picker of the caller's, nil cycling through them in place
	Pick func(f *Form, field Field) tea.Cmd
	// Runs once a field's answer is given: a switch flipped, a choice made, or text kept as the cursor leaves the field
	Changed func(f *Form, field Field) tea.Cmd
	// Runs a button field when it is pressed
	Press func(f *Form, field Field) tea.Cmd
	// Keymap context of the form's own actions and those actions by id
	Context string
	Actions map[string]func(f *Form) tea.Cmd
	// Legend of the form's own actions, ahead of the form keys
	Hints []wm.Hint
}

Form a caller describes: its fields, what sending it does and any keys of its own

type Helper

type Helper interface {
	HelpLines() []string
}

View of a hub that adds help lines of its own to the help page, such as what the highlighted row does

type History

type History interface {
	// Entries oldest first
	Entries() []Entry
	// Records a sent prompt, an older entry with the same text giving way to it
	Add(Entry)
}

Prompts every composer recalls, one store shared by all of them and read at each recall

type Hub

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

Screen of things to manage: views stacked over one root list, the same keys on each, with a note line along the bottom for progress and errors

func NewHub

func NewHub(env *Env, key string, root wm.Card, screen func() (int, int)) *Hub

Builds a hub over its root view, sized from the screen it floats over

func (*Hub) Back

func (h *Hub) Back() bool

Esc on the hub while its view takes typing and has no step back of its own: a stacked view closes, the root lets the hub close

func (*Hub) Busy

func (h *Hub) Busy(text string)

Shows work in flight under the view

func (*Hub) Close

func (h *Hub) Close(c wm.Card) tea.Cmd

Closes c wherever it is stacked, the root staying

func (*Hub) Contexts

func (h *Hub) Contexts() []string

Keymap contexts of the view on top, with help and reading again while it takes no typing

func (*Hub) Cursor

func (h *Hub) Cursor() *tea.Cursor

func (*Hub) Depth

func (h *Hub) Depth() int

Number of views stacked over the root

func (*Hub) Done

func (h *Hub) Done(text string) tea.Cmd

Shows that something finished under the view

func (*Hub) Fail

func (h *Hub) Fail(text string) tea.Cmd

Shows why something failed under the view

func (*Hub) Glyph

func (h *Hub) Glyph() string

func (*Hub) Grabs

func (h *Hub) Grabs(x, y int) bool

func (*Hub) Hints

func (h *Hub) Hints() []wm.Hint

Legend of the view on top, then help and back

func (*Hub) Holds

func (h *Hub) Holds(c wm.Card) bool

Reports whether the view is stacked on the hub

func (*Hub) Init

func (h *Hub) Init() tea.Cmd

func (*Hub) Key

func (h *Hub) Key() string

func (*Hub) MinSize

func (h *Hub) MinSize() (int, int)

Opens near the whole screen on a small terminal and at a readable width on a large one

func (*Hub) OnClose

func (h *Hub) OnClose(fn func() tea.Cmd)

Runs fn once the hub leaves the screen, after the ones added before

func (*Hub) Pop

func (h *Hub) Pop() tea.Cmd

Closes the view on top and gives the keys back to the one under it, the root staying

func (*Hub) PopTo

func (h *Hub) PopTo(c wm.Card) tea.Cmd

Closes every view down to c, c staying on top, nothing when c is not stacked

func (*Hub) Push

func (h *Hub) Push(c wm.Card) tea.Cmd

Puts a view on top, the one under it waiting until it closes

func (*Hub) Quiet

func (h *Hub) Quiet()

Clears the note under the view

func (*Hub) Raw

func (h *Hub) Raw() bool

Every key as typed while the view on top asks for it

func (*Hub) Root

func (h *Hub) Root() wm.Card

Root view of the hub

func (*Hub) Say

func (h *Hub) Say(text string, level NoteLevel) tea.Cmd

Shows a note under the view, a report clearing itself after a while

func (*Hub) Selectable

func (h *Hub) Selectable() bool

func (*Hub) Shown

func (h *Hub) Shown() bool

Reports whether the hub is on screen

func (*Hub) Status

func (h *Hub) Status() string

func (*Hub) Stick

func (h *Hub) Stick()

Keeps the hub as a question: another overlay holds it beneath instead of dropping it, and only an answer or esc closes it

func (*Hub) Sticky

func (h *Hub) Sticky() bool

Whether the hub waits beneath other overlays

func (*Hub) Swap

func (h *Hub) Swap(c wm.Card) tea.Cmd

Puts c in the place of the view on top, such as another tab of the root, the views keeping their order

func (*Hub) Title

func (h *Hub) Title() string

func (*Hub) Top

func (h *Hub) Top() wm.Card

View on top, the one taking the keys

func (*Hub) Update

func (h *Hub) Update(msg tea.Msg) (wm.Card, tea.Cmd)

func (*Hub) View

func (h *Hub) View(w, ht int) string

func (*Hub) Waiting

func (h *Hub) Waiting() bool

Reports whether work the hub started is still in flight

type List added in v1.0.11

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

Table card with a filter bar, detail pane and keymap actions an extension drives through its spec

func NewList added in v1.0.11

func NewList(env *Env, spec ListSpec) *List

Builds the table from the spec, each action handed the list and the row under the cursor

func (*List) Confirm

func (l *List) Confirm(text string, yes func() tea.Cmd)

Asks a yes or no question along the bottom of the list, yes running the action

func (List) Contexts added in v1.0.11

func (l List) Contexts() []string

Keymap contexts in force, a capture, a question, an edit or the filter bar ahead of the table

func (List) Cursor added in v1.0.11

func (l List) Cursor() *tea.Cursor

Cursor in the filter bar while it takes typing, else at the end of the cell being typed into, the start of the row input while it is empty

func (*List) DetailShown

func (l *List) DetailShown() bool

Reports whether the detail pane of the selected row is open

func (*List) EditCell

func (l *List) EditCell(col int, initial string, done func(l *List, text string) tea.Cmd)

Opens a cell of the selected row for typing from initial, enter handing the trimmed text to done

func (List) Editing added in v1.0.11

func (l List) Editing() bool

Reports whether a cell is being typed into

func (*List) Filter

func (l *List) Filter(text string)

Opens the filter bar holding the text, the rows narrowed to those holding it

func (*List) Filtered

func (l *List) Filtered() bool

Reports whether the filter narrows the rows

func (List) Glyph added in v1.0.11

func (l List) Glyph() string

func (List) Grabs added in v1.0.11

func (l List) Grabs(x, y int) bool

Reports whether a press at the cell takes hold of the scrollbar of the detail pane

func (*List) HelpLines

func (l *List) HelpLines() []string

Lines the help of a hub shows for the row under the cursor

func (*List) Hints added in v1.0.11

func (l *List) Hints() []wm.Hint

Legend of the table, a pick list naming its filter bar keys for what they do there: enter picks and esc goes back

func (*List) Index added in v1.0.11

func (l *List) Index() int

Row under the cursor as an index into the rows, -1 when there is none

func (List) Init added in v1.0.11

func (l List) Init() tea.Cmd

func (List) Key added in v1.0.11

func (l List) Key() string

func (*List) Move

func (l *List) Move(d int)

Moves the cursor by d rows within the rows the filter shows

func (*List) Picks

func (l *List) Picks() bool

Reports whether the list is one to pick from

func (List) Raw added in v1.0.11

func (l List) Raw() bool

Takes every key as typed while it waits for a key to bind

func (*List) Refresh added in v1.0.11

func (l *List) Refresh()

Recomputes the rows now

func (*List) Select

func (l *List) Select(i int) bool

Moves the cursor to row i of the rows, reporting whether the filter shows it

func (List) Selectable added in v1.0.11

func (l List) Selectable() bool

func (*List) SetTyped

func (l *List) SetTyped(text string)

Replaces the text of the input row

func (List) Status added in v1.0.11

func (l List) Status() string

Trailer on the frame, what the tab says about its rows and then how many of them a scrolled table hides above and below

func (List) Title added in v1.0.11

func (l List) Title() string

func (*List) ToggleDetail added in v1.0.11

func (l *List) ToggleDetail() tea.Cmd

Opens the detail pane of the selected row when closed and closes it when open

func (*List) Typed

func (l *List) Typed() string

Text typed into the input row so far

func (*List) Update added in v1.0.11

func (l *List) Update(msg tea.Msg) (wm.Card, tea.Cmd)

Hands the message to the table and keeps the list as the card the window manager holds, a pick list picking from its filter bar and moving the cursor to the row whose first cell best matches what was typed

func (*List) View added in v1.0.11

func (l *List) View(w, h int) string

Paints the columns that fit the width, those that yield giving way first to last

type ListInput

type ListInput struct {
	// Reports whether row i is the one typed into
	Row func(i int) bool
	// Column the text shows in
	Col int
	// Keymap contexts in force on the row ahead of the cell keys, their actions run from the Actions of the spec
	Contexts []string
	// Handed the trimmed text on the apply key
	Done func(l *List, text string) tea.Cmd
	// Runs on the cancel key, which clears the text when nil
	Cancel func(l *List) tea.Cmd
}

Row of a list that takes typing in place of the table keys while the cursor sits on it

type ListSpec added in v1.0.11

type ListSpec struct {
	Title, Glyph, Key string
	// Keymap context of its own actions
	Context string
	// Keymap contexts in force on every row besides Context, the input row included
	Shared []string
	// Action a click on the selected row runs
	Primary string
	Columns []render.Column
	Rows    func() [][]string
	Detail  func(i int) []string
	Actions map[string]func(l *List, i int) tea.Cmd
	// Actions that apply with no row under the cursor
	Free map[string]bool
	// Legend of the row under the cursor in place of every action of the context, -1 for none
	Hints   func(l *List, i int) []wm.Hint
	Empty   func() string
	OnFocus func(l *List) tea.Cmd
	// Keeps the cursor on the newest row while it sits there
	Follow bool
	// Trailer on the frame, ahead of the count of rows a scrolled table hides
	Status func() string
	// Line above the table while it returns text, such as a part of the rows that failed to load
	Banner func() string
	// Takes text typed or pasted while the table holds the keys, an unbound printable key or a paste
	Typed func(l *List, text string, pasted bool) tea.Cmd
	// Runs on a digit picking one of the first ten rows in view, which show their digit
	Quick func(l *List, i int) tea.Cmd
	// Row typed into in place while the cursor sits on it, nil for a table without one
	Input *ListInput
	// Columns that give way, first to last, when the width cannot hold every column at a readable width
	Yield []int
	// Lines the help of a hub shows for row i, the detail of the row when nil
	Help func(i int) []string
	// A list to pick from: the filter bar takes typing from the start and enter on it runs Primary on the highlighted row
	Pick bool
}

Table panel an extension builds, rows and details computed on every view

type NoteLevel

type NoteLevel int

Weight of the line a hub shows under its view

const (
	// What the screen says about itself, cleared after a while
	NoteInfo NoteLevel = iota
	// Work in flight, kept until the next note
	NoteBusy
	// Work that finished, cleared after a while
	NoteDone
	// Work that failed, kept until the next note or action
	NoteFailed
)

type Offer

type Offer struct {
	Text    string
	Display string
	Meta    string
}

Candidate an app completion source offers, its text put in from the replace offset; one without text only informs

type Page

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

Card of text lines scrolled with the list keys, such as help, a sign in in progress or the output of a command

func NewPage

func NewPage(env *Env, spec PageSpec) *Page

Builds a page from the spec, at its end when it follows its last line

func (*Page) Contexts

func (p *Page) Contexts() []string

func (*Page) End

func (p *Page) End()

Moves the view to its end

func (*Page) Hints

func (p *Page) Hints() []wm.Hint

func (*Page) Init

func (p *Page) Init() tea.Cmd

func (*Page) Key

func (p *Page) Key() string

func (*Page) Selectable

func (p *Page) Selectable() bool

func (*Page) Status

func (p *Page) Status() string

Count of lines out of view above and below

func (*Page) Title

func (p *Page) Title() string

func (*Page) Update

func (p *Page) Update(msg tea.Msg) (wm.Card, tea.Cmd)

func (*Page) View

func (p *Page) View(w, h int) string

type PageSpec

type PageSpec struct {
	Title, Key string
	// Lines at the width given, styled by the caller
	Lines func(w int) []string
	// Keymap context of the page's own actions and those actions by id
	Context string
	Actions map[string]func(p *Page) tea.Cmd
	// Legend of the page's own actions, ahead of the scroll keys
	Hints func(p *Page) []wm.Hint
	// Keeps the last line in view while the page sits at its end, for output that grows
	Follow bool
	// Runs when the page first shows
	Init func(p *Page) tea.Cmd
}

Page a caller describes: lines read on every view, keys of its own and whether it follows its last line

type Painter

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

Writes text, boxes and panels into the cells of a painted card in the theme

func NewPainter

func NewPainter(buf *uv.Buffer, t theme.Theme) *Painter

func (*Painter) Cells

func (p *Painter) Cells() *uv.Buffer

Cells the painter writes into

func (*Painter) Fill

func (p *Painter) Fill(x, y, w, h int, bg color.Color)

Fills a box with one color, dropping what was there

func (*Painter) Handle

func (p *Painter) Handle(x, y, h int, hot bool)

Column of grip marks along an edge that drags, lit while the pointer holds it

func (*Painter) Label

func (p *Painter) Label(x, y int, s string, fg, bg color.Color, bold bool) int

Writes text with its own background, cut at the right edge

func (*Painter) Lines

func (p *Painter) Lines(x, y, w, h int, lines []string)

Writes lines down a box, each cut to its width, the rest of the box left as it is

func (*Painter) Panel

func (p *Painter) Panel(x, y, w, h int, title string, share float64)

Draws a bordered panel with a title over the cells, tinted by a share, its body left for the caller

func (*Painter) Size

func (p *Painter) Size() (w, h int)

Width and height of the cells

func (*Painter) Styled

func (p *Painter) Styled(x, y, w, h int, s string)

Draws a styled string, as lipgloss renders it, into a box

func (*Painter) Text

func (p *Painter) Text(x, y int, s string, fg color.Color, bold bool) int

Writes plain text at a cell in a color over whatever background is there, cut at the right edge

func (*Painter) Theme

func (p *Painter) Theme() theme.Theme

Theme the painter draws in

func (*Painter) Tint

func (p *Painter) Tint(x, y, w, h int, bg color.Color, share float64)

Tints a box toward a color by a share, text under it kept, for a panel laid over a drawing

func (*Painter) TintBg

func (p *Painter) TintBg(x, y, w, h int, bg color.Color)

Blends the background of a box toward a color, the text and its colors kept

type Readable

type Readable interface {
	// Rows of the text
	ReadRows() int
	// Plain text of a row
	ReadRow(i int) string
	// First row in view and how many rows show
	ReadWindow() (top, height int)
	// Scrolls so that the row is the first in view
	ReadScroll(top int)
	// Row of the prompt nearest before the row for a negative step or after it for a positive one, false when there is none that way
	ReadPrompt(from, d int) (int, bool)
	// Rows from and up to of the message or command output that holds the row
	ReadBlock(row int) (int, int)
}

Text a reader moves through: its rows as plain text, the window of rows on screen and where its prompts and blocks lie

type Reader

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

Reading mode over a text: a cursor row moved with the reading keys, prompts to jump between, a search with its matches, a selection of rows and copying; the same for a transcript, a terminal's scrollback and a long text

func NewReader

func NewReader(src Readable, km *keys.Map) *Reader

Reader over a text, not reading yet

func (*Reader) Action

func (r *Reader) Action(id string) (tea.Cmd, bool)

Carries out a reading key, reporting whether the reader took it; the open key is left to the text's owner

func (*Reader) Active

func (r *Reader) Active() bool

Whether the reader holds the keys

func (*Reader) Contexts

func (r *Reader) Contexts() []string

Keymap contexts while reading: the search bar and the field keys while a query is typed, else the reading keys

func (*Reader) Cursor

func (r *Reader) Cursor() int

Row the cursor is on

func (*Reader) Hints

func (r *Reader) Hints() []wm.Hint

Keys worth a reminder while reading

func (*Reader) Line

func (r *Reader) Line(w int, t theme.Theme) (string, int)

Line naming the mode with the place of the cursor, the search and the keys that matter, the query with its caret while one is typed

func (*Reader) Mark

func (r *Reader) Mark(row int, line string, t theme.Theme) string

One rendered row of the window with the reading marks over it: the cursor and selection in its first cell and the matches lit, its colors kept

func (*Reader) MarkBuffer

func (r *Reader) MarkBuffer(buf *uv.Buffer, top int, t theme.Theme)

Puts the reading marks onto the cells of a painted window whose first row is the text row top: the matches lit and the cursor and selection rows tinted

func (*Reader) Start

func (r *Reader) Start(find bool)

Starts reading at the last row in view, with a search being typed when asked

func (*Reader) Stop

func (r *Reader) Stop()

Stops reading, the search and selection dropped

func (*Reader) Take

func (r *Reader) Take(msg tea.Msg) bool

Takes typed or pasted text into the query being typed, reporting whether the reader used it

func (*Reader) Typing

func (r *Reader) Typing() bool

Whether a search query is being typed

type Row

type Row struct {
	ID       string
	First, N int
}

Clickable row of a section, the lines it spans and what it stands for

type RunMsg added in v1.0.10

type RunMsg struct {
	Session string
	Line    string
}

Shell line typed with a leading bang, to run in the terminal window beside the session

type Section

type Section struct {
	ID    string
	Title string
	// Count shown at the right of the title while nothing is scrolled
	Count string
	Lines []string
	Rows  []Row
	// Whether the section shares the height left after the fixed ones instead of taking its own
	Flex bool
	// Whether the section follows its end as lines arrive, until scrolled up
	Tail bool
}

Section of a dock, its lines, the clickable rows among them and how it takes height

type Sections

type Sections struct {
	// Whether each section is open, every section open until folded
	Open map[string]bool
	// Share of the flex height the first flex section takes
	Share float64
	// Action under the pointer, its title drawn raised
	Hover string
	// contains filtered or unexported fields
}

Stack of sections that fold, scroll and share the height of a dock, the flex ones split by a draggable rule

func NewSections

func NewSections(share float64) Sections

Sections with the first flex one taking the share of the flex height

func (*Sections) At

func (d *Sections) At(x, y int) (string, bool)

Id of the section holding a cell of the last paint, false between them

func (*Sections) Follows

func (d *Sections) Follows(id string) bool

Reports whether a tailing section still follows its end

func (*Sections) IsOpen

func (d *Sections) IsOpen(id string) bool

Reports whether the section is open, which it is until folded

func (*Sections) Paint

func (d *Sections) Paint(p *Painter, x, y, w, h int, secs []Section, hit func(id string, x, y, w, h int), rowBg func(id string) color.Color)

Draws the sections down a box, each under a title row that folds it, reporting the box of every title and row through the callback and tinting rows by the color the callback gives

func (*Sections) Rect

func (d *Sections) Rect(id string) (Box, bool)

Box a section took on the last paint, its title row included, false when it was not painted

func (*Sections) Scroll

func (d *Sections) Scroll(id string, rows int, tail bool)

Scrolls a section by a count of rows, a tailing one leaving its end once scrolled up and following it again once scrolled back down

func (*Sections) Show

func (d *Sections) Show(id string)

Opens the section

func (*Sections) Split

func (d *Sections) Split() int

Row of the rule between the first two flex sections on the last paint, negative while there is none

func (*Sections) Toggle

func (d *Sections) Toggle(id string)

Folds the section or opens it again at its top, a tailing one back on its end

func (*Sections) Top

func (d *Sections) Top(id string)

Scrolls the section back to its top

type Selection

type Selection struct {
	Text string
	// contains filtered or unexported fields
}

Span of prompt text a person selected

type SettingChangedMsg added in v1.0.10

type SettingChangedMsg struct {
	Key   string
	Value string
}

Setting the app applied, sent to every card so those showing it follow

type SubmitMsg

type SubmitMsg struct {
	Session     string
	Text        string
	Attachments []Attachment
}

Input a session composer sends to its agent

type Terminal added in v1.0.10

type Terminal struct {

	// Called once when the program ends, the window closes first or the program fails to start, with what the program left on screen
	OnEnd func(TerminalEnd) tea.Cmd
	// contains filtered or unexported fields
}

Window running a shell on a pseudo terminal, every key going to it while the window keys still reach the manager

func NewTerminal added in v1.0.10

func NewTerminal(env *Env, id int, dir string) *Terminal

Builds terminal number id starting its shell in dir, the agent shell directory when empty

func NewTerminalArgv

func NewTerminalArgv(env *Env, id int, dir string, argv []string) *Terminal

Builds terminal number id running a program with its arguments in dir without a shell, the window closing when it ends well and staying open with its output when it fails

func NewTerminalCommand

func NewTerminalCommand(env *Env, id int, dir, line string) *Terminal

Builds terminal number id running one command line through the shell in dir, the window closing when it ends

func (*Terminal) Close added in v1.0.10

func (t *Terminal) Close()

Ends the shell and waits for it, for a program shutting down

func (*Terminal) Contexts added in v1.0.10

func (t *Terminal) Contexts() []string

Keymap contexts, the search bar ahead of the terminal keys and the field keys after them while it is open

func (*Terminal) Cursor added in v1.0.10

func (t *Terminal) Cursor() *tea.Cursor

Cursor of the shell, or of the search bar while it is open, none while scrolled back or ended

func (*Terminal) Cwd added in v1.0.10

func (t *Terminal) Cwd() string

Working directory of the shell, what it announced, else what the kernel reports, else where it started

func (*Terminal) Glyph added in v1.0.10

func (t *Terminal) Glyph() string

func (*Terminal) Hints added in v1.0.10

func (t *Terminal) Hints() []wm.Hint

Actions worth a reminder

func (*Terminal) ID added in v1.0.10

func (t *Terminal) ID() int

func (*Terminal) Init added in v1.0.10

func (t *Terminal) Init() tea.Cmd

Starts the shell

func (*Terminal) Key added in v1.0.10

func (t *Terminal) Key() string

func (*Terminal) MinSize added in v1.0.10

func (t *Terminal) MinSize() (int, int)

func (*Terminal) Output

func (t *Terminal) Output() string

Text the program left in the scrollback and on the screen, soft wrapped rows joined and blank rows at the end dropped

func (*Terminal) Paint added in v1.0.10

func (t *Terminal) Paint(buf *uv.Buffer)

Paints the screen with the search, selection, scrollbar and exit banner over it

func (*Terminal) Passes added in v1.0.10

func (t *Terminal) Passes(k tea.KeyPressMsg) bool

Lets the window manager have an alt or command key only while a global window key holds it, every other key going to the program, so readline's meta keys reach the shell; nothing passes while the keys are locked

func (*Terminal) Raw added in v1.0.10

func (t *Terminal) Raw() bool

Takes every key as typed while the shell runs and neither the search bar nor reading mode is open

func (*Terminal) ReadBlock

func (t *Terminal) ReadBlock(row int) (int, int)

Rows of the command output holding a row, from the prompt at or before it up to the next prompt, the row alone where shells mark no prompts

func (*Terminal) ReadPrompt

func (t *Terminal) ReadPrompt(from, d int) (int, bool)

Row of the shell prompt before or after a row, for shells that mark their prompts

func (*Terminal) ReadRow

func (t *Terminal) ReadRow(i int) string

Plain text of a row counted from the oldest one kept

func (*Terminal) ReadRows

func (t *Terminal) ReadRows() int

Rows the scrollback and the screen hold

func (*Terminal) ReadScroll

func (t *Terminal) ReadScroll(top int)

Scrolls so that the row is the first in view, as far as the scrollback goes

func (*Terminal) ReadWindow

func (t *Terminal) ReadWindow() (int, int)

First row in view counted from the oldest one kept, and the rows of the window

func (*Terminal) Run added in v1.0.10

func (t *Terminal) Run(line string) tea.Cmd

Types a line into the shell, starting it again first when it has ended

func (*Terminal) Selectable added in v1.0.10

func (t *Terminal) Selectable() bool

func (*Terminal) SetState added in v1.0.10

func (t *Terminal) SetState(raw json.RawMessage) error

Starts the next shell in the saved directory when it still exists

func (*Terminal) State added in v1.0.10

func (t *Terminal) State() any

Directory of the shell for the next run

func (*Terminal) Status added in v1.0.10

func (t *Terminal) Status() string

Directory, scroll position, lock and how the shell ended

func (*Terminal) Title added in v1.0.10

func (t *Terminal) Title() string

func (*Terminal) Tracks added in v1.0.10

func (t *Terminal) Tracks() bool

func (*Terminal) Update added in v1.0.10

func (t *Terminal) Update(msg tea.Msg) (wm.Card, tea.Cmd)

func (*Terminal) View added in v1.0.10

func (t *Terminal) View(w, h int) string

Screen as a string, for frames composed from text

type TerminalEnd

type TerminalEnd struct {
	Output string
	Exit   *term.Exit
	// Error that kept the program from starting
	Err error
	// Whether the window was closed while the program still ran
	Closed bool
}

How the program of a window ended, the text it left on screen and in the scrollback and its exit, nil when it never got to exit

type Toolbar

type Toolbar struct {
	Keys *keys.Map
	// Action under the pointer, drawn raised
	Hover string
}

Row of buttons across a painted card, each labeled with its key while they fit, the least needed dropped first

func (Toolbar) Paint

func (tb Toolbar) Paint(p *Painter, x, y, w int, btns []Button, hit func(id string, x, y, w, h int))

Draws the buttons that fit across a row, reporting the box of each through the callback

type UnterminatedQuoteError

type UnterminatedQuoteError struct {
	Quote rune
}

Error of ShellWords when a quote or a trailing backslash is left open

func (*UnterminatedQuoteError) Error

func (e *UnterminatedQuoteError) Error() string

Jump to

Keyboard shortcuts

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