tui

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 32 Imported by: 0 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

Overview

Package tui is sitrep's full-screen dashboard: tabs for a Cards view and a Table view, a detail pane, jumping to a session's terminal, and the queue and prune screens. It reads a snapshot from an Engine and changes state only by running the same fixed sitrep commands, after a confirm, through that Engine; --read-only turns every one of them off.

Index

Constants

This section is empty.

Variables

View Source
var ThemeNames = []string{"default", "pastel", "rainbow", "high-contrast", "ocean", "forest", "homebrew", "red-sands", "novel", "nord", "solarized", "winter", "spring", "summer", "fall", "eighties", "blues", "reggae", "opera", "metal", "bossa-nova", "hip-hop", "disco", "punk", "vaporwave", "desert-night", "tokyo", "arctic", "volcano", "tropical", "sunset", "candy", "coffee", "terminal-amber", "paper", "gameboy", "cvd-safe", "mono"}

ThemeNames are the themes SITREP_THEME may name. "mono" uses no colors, only bold, faint and reverse.

Functions

func Frame

func Frame(ctx context.Context, eng Engine, tab string, width int, showEnded bool) (string, error)

Frame is one frame of a tab as plain text, for `sitrep status`.

func Run

func Run(opts Options, eng Engine) error

Run shows the dashboard until the user quits.

func RunColors added in v1.0.0

func RunColors(opts ColorsOptions) error

RunColors shows the color tool until the user quits.

func ShotFrame added in v1.0.0

func ShotFrame(s snapshot.Snapshot, tab string, width, height int, theme string, dark bool, sel string, demo bool) (string, error)

ShotFrame draws one frame of a tab with colors, as the dashboard would show it on a dark or a light terminal, for the pictures of the README (see docs/theme-shots). sel is the id of the selected session, or "".

Types

type Backup added in v1.0.7

type Backup struct {
	At    int64 `json:"at"`
	Age   int64 `json:"age"`
	Stale bool  `json:"stale"`
}

Backup is when the last backup was made, and whether that is longer ago than the limit.

type ColorsFile added in v1.0.0

type ColorsFile interface {
	Path() string                     // the file a write goes to, with a link followed
	Values() (theme, colors string)   // what the file holds, whatever the environment says
	Read() (string, error)            // the whole file
	Write(out, original string) error // replace it, when it still holds original
	Backup(body string) (string, error)
}

ColorsFile is the file the color tool reads and writes, which is sitrep.conf.

type ColorsOptions added in v1.0.0

type ColorsOptions struct {
	Sessions snapshot.Snapshot // what the preview shows
	File     ColorsFile
	ReadOnly bool
	Dark     *bool    // the kind of terminal to preview, until the terminal says which it is
	Notes    []string // what to say at the start: an environment setting that beats the file, NO_COLOR
}

ColorsOptions are the color tool's inputs.

type Context added in v0.8.0

type Context struct {
	UsedPercent float64 `json:"used_percent"`
	Window      int64   `json:"window"`
	Tokens      int64   `json:"tokens"`
	At          int64   `json:"at"`
	Age         int64   `json:"-"` // how long before the listing the status line last showed these numbers, worked out from the document's own time
}

Context is how full the context window of a session was at its last status line.

func (Context) Left added in v0.8.0

func (c Context) Left() int

Left is the share of the window left, in whole per cent, rounded down.

type Engine

type Engine struct {
	// Snapshot reads everything: all sessions, every queue item.
	Snapshot func(ctx context.Context) (snapshot.Snapshot, error)
	// Command runs one fixed sitrep command line (without the program name) and returns what it printed. An error carries its message.
	Command func(ctx context.Context, args ...string) (string, error)
	// Demo says the sessions are made up, which the status bar then says too.
	Demo bool
}

Engine is what the dashboard gets its data from and acts through.

type Hidden

type Hidden struct {
	Ended         int `json:"ended"`
	StrandedItems int `json:"stranded_items"`
}

type Options

type Options struct {
	Tab        string // cards, table or wall
	Interval   time.Duration
	ReadOnly   bool
	NoBell     bool
	NoHints    bool // the bottom row is empty until something happens
	Mouse      bool // a click selects a row and a double click jumps
	QuitOnJump bool
	Colors     *ColorsOptions // what the C key opens; nil when the color tool is not on offer here
}

Options are the dashboard's settings.

type Queue

type Queue struct {
	Count int      `json:"count"`
	Items []string `json:"items"`
}

type Session

type Session struct {
	ID           string   `json:"id"`
	Short        string   `json:"short"`
	Alias        string   `json:"alias"`
	Dir          string   `json:"dir"`
	Cwd          string   `json:"cwd"`
	Running      bool     `json:"running"`
	State        string   `json:"state"`
	StateLabel   string   `json:"state_label"`
	Age          int64    `json:"age"`
	StateChanged int64    `json:"state_changed"`
	Idle         bool     `json:"idle"`
	NeedsInput   bool     `json:"needs_input"`
	Blocked      string   `json:"blocked"`
	Snoozed      bool     `json:"snoozed"`
	QuietSecs    *int64   `json:"quiet_secs"`
	PID          *int64   `json:"pid"`
	Pinned       bool     `json:"pinned"`
	Highlight    bool     `json:"highlight"`
	Background   bool     `json:"background"` // runs under the daemon, with no terminal of its own
	Clients      []int    `json:"clients"`    // the terminal processes that show a background session
	AttnFaded    bool     `json:"attn_faded"` // needs the user, but for so long that the row is no longer colored
	Objective    string   `json:"objective"`
	Progress     string   `json:"progress"`
	Now          string   `json:"now"`
	Queue        Queue    `json:"queue"`
	Context      *Context `json:"context"`
}

func (Session) Label added in v0.6.0

func (x Session) Label() string

func (Session) RowLabel added in v1.0.1

func (x Session) RowLabel() string

Label is the name a person is shown for a session: its alias, or the Short. Whatever is passed to a command is the ID, never this. RowLabel is what the first column of a row holds: the short id, or, for a session with a name, the name (cut with an ellipsis) and the short id in brackets, as `sitrep ls` shows it, so that the id to type for a command is never hidden by the name.

type Settings

type Settings struct {
	QueueItems       int    `json:"queue_items"`
	HighlightSeconds int    `json:"highlight_seconds"`
	HighlightSGR     string `json:"highlight_sgr"`
	Theme            string `json:"theme"`
	Colors           string `json:"colors"`
}

type Snapshot

type Snapshot struct {
	Version   int       `json:"version"`
	Generated int64     `json:"generated"`
	Registry  string    `json:"registry"`
	Settings  Settings  `json:"settings"`
	Backup    *Backup   `json:"backup"` // the last backup, or nil when none has been made
	Inbox     Queue     `json:"inbox"`
	Hidden    Hidden    `json:"hidden"`
	Sessions  []Session `json:"sessions"`
}

Snapshot is the document `sitrep ls --json -a` prints.

func FromSnapshot

func FromSnapshot(s snapshot.Snapshot) Snapshot

FromSnapshot makes the dashboard's own copy of a snapshot, cleaned again as everything it shows is.

type Theme

type Theme struct {
	Tab, TabActive, Rule, Label, Dim, Err, Status, StatusKey, Hot, Attn, Warn, Snooze lipgloss.Style
	Head                                                                              lipgloss.Style // the labels of a card and the numbers of a queue: they stand out from the text they head
	// the mark down the left edge of a card and the state word of one that needs you: the color of what needs the user, of what needed them
	// long ago, and of recent activity, each made to read on the terminal's own background
	Need, Fade, Recent, RecentWord lipgloss.Style // RecentWord is the state of a recent card: the color of its bar, readable as text
	Quiet                          lipgloss.Style // the bracket of a card that is none of those: a gray that shows where the card is and no more
	Dull                           lipgloss.Style // a session that has needed the user for long: the needs-you color, weakened
	HasDull                        bool
	Plain                          bool
	Stock                          bool // the default theme with no color changed: the help may name its colors (pink-red), as they are true
	Mono                           bool // the mono theme: no colors, so marks carry the meaning
}

Theme holds every style the views use. The plain theme has none, so tests compare text.

Jump to

Keyboard shortcuts

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