cards

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 26 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 DefaultScrollback = 10000

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

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 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 CommandMsg

type CommandMsg struct {
	Session string
	Name    string
	Args    string
}

Slash command a session composer parsed

type Composer

type Composer struct {
	SessionID string
	// 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
	// Called with each line the history takes, for an app keeping its own history file
	OnRemember func(text 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()
	// contains filtered or unexported fields
}

Multi line prompt with history, 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 history and bound drafts under dir, 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, a history line being recalled or the cursor on its last line 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 line 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) Bind

func (c *Composer) Bind(sessionID string)

Binds the prompt to a session, text already typed moving to it and otherwise its kept draft coming back

func (*Composer) Click

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

Sends when the click lands on the send button, reporting whether it did

func (*Composer) Completing

func (c *Composer) Completing() bool

Reports whether the completion popup is open for the text typed now

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, below any completion popup

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, growing with the wrapped text and the completion popup

func (*Composer) History

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

Lines the composer remembers, oldest first

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) 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 or a text no longer typed closing the popup

func (*Composer) Offset

func (c *Composer) Offset() int

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

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 remembered lines 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) Remember

func (c *Composer) Remember(text string)

Adds a draft the person discarded to the history, so recalling brings it back

func (*Composer) Seed

func (c *Composer) Seed(lines []string)

Replaces the remembered lines, oldest first, for an app that keeps the history file itself

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

func (c *Composer) SetBusy(on bool)

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

func (*Composer) SetFocus

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

Moves the input focus with the card focus

func (*Composer) SetTheme

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

Paints the input with the theme

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 history line left behind

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 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 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) 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) Hints added in v1.0.11

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

Actions the table answers now, those of its tab first and then the filter and cursor

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

func (List) View added in v1.0.11

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

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
}

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

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

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 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 {
	// 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 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 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) 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 alt, super, hyper, meta and Option typed keys reach the window manager unless 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 no search bar is open

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