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 ¶
- Variables
- func Frame(ctx context.Context, eng Engine, tab string, width int, showEnded bool) (string, error)
- func Run(opts Options, eng Engine) error
- func RunColors(opts ColorsOptions) error
- func ShotFrame(s snapshot.Snapshot, tab string, width, height int, theme string, dark bool, ...) (string, error)
- type Backup
- type ColorsFile
- type ColorsOptions
- type Context
- type Engine
- type Hidden
- type Options
- type Queue
- type Session
- type Settings
- type Snapshot
- type Theme
Constants ¶
This section is empty.
Variables ¶
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 colours, only bold, faint and reverse.
Functions ¶
func RunColors ¶ added in v1.0.0
func RunColors(opts ColorsOptions) error
RunColors shows the colour 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 colours, 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
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 colour 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 colour 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.
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 Options ¶
type Options struct {
Tab string // cards, table or wall
Interval time.Duration
ReadOnly bool
NoBell bool
Mouse bool // a click selects a row and a double click jumps
QuitOnJump bool
Colors *ColorsOptions // what the C key opens; nil when the colour tool is not on offer here
}
Options are the dashboard's settings.
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"`
AttnFaded bool `json:"attn_faded"` // needs the user, but for so long that the row is no longer coloured
Objective string `json:"objective"`
Progress string `json:"progress"`
Now string `json:"now"`
Queue Queue `json:"queue"`
Context *Context `json:"context"`
}
func (Session) RowLabel ¶ added in v1.0.1
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 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 ¶
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 colour 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 colour of its bar, readable as text
Quiet lipgloss.Style // the bracket of a card that is none of those: a grey that shows where the card is and no more
Dull lipgloss.Style // a session that has needed the user for long: the needs-you colour, weakened
HasDull bool
Plain bool
Mono bool // the mono theme: no colours, so marks carry the meaning
}
Theme holds every style the views use. The plain theme has none, so tests compare text.