Documentation
¶
Overview ¶
Package tui is the Oku dashboard: the Bubble Tea model behind `oku tui`, the palette it draws with, and the sections it draws. It is imported by internal/cli and imports nothing from it, so the CLI commands and the dashboard share a theme without sharing a package.
Index ¶
- func ActiveThemeName() string
- func ApplyThemeSetting(setting string) error
- func PinnedDark() (isDark bool, pinned bool)
- func ResolveThemeSetting(setting string) (string, error)
- func Run(ctx context.Context, a *app.App, density Density, version string) error
- func ThemeSettings() []string
- type Density
- type Model
- type NamedTheme
- type Theme
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActiveThemeName ¶
func ActiveThemeName() string
ActiveThemeName is the name of the palette in force, empty unless the `theme` config key named one. The help modal shows it, so a reader can tell which scheme they are looking at.
func ApplyThemeSetting ¶
ApplyThemeSetting honours the `theme` config key. "auto" (or empty) leaves the background to be detected — the dashboard asks the terminal for it and the CLI queries it once at startup; "dark" and "light" pin it, for terminals that do not answer the query or answer it wrongly. Any of the named palettes (see NamedThemes) pins the whole palette, and with it the background the palette was drawn for.
func PinnedDark ¶
PinnedDark reports the background the `theme` config key pinned, if it pinned one. The dashboard skips the terminal query when it did, and the CLI skips its own detection.
func ResolveThemeSetting ¶
ResolveThemeSetting checks a `theme` value and answers with its canonical spelling: one of "auto", "dark", "light" or a named palette. Empty resolves to "auto". Nothing is applied — the CLI resolves a name to write it or to describe it, and ApplyThemeSetting resolves it to pin it.
func Run ¶
Run starts the dashboard on a, with density as the row detail the CLI's --view flag asked for and version as the build it reports. It returns when the user quits.
func ThemeSettings ¶
func ThemeSettings() []string
ThemeSettings is every value the `theme` config key accepts, the three background settings first and the palettes after them in declaration order — this is the list an invalid value is reported against and the one `oku config theme` prints and previews.
Types ¶
type Density ¶
type Density int
Density is how much of a book a row shows. It is the CLI's `--view` setting and the dashboard's `z` key at once: both list the same books, so they read the same value.
func ParseDensity ¶
ParseDensity reads the `--view` flag. An empty value is the default, so a command that never sets the flag gets the middle density.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the root of the dashboard. It routes keys to the top modal or the active section, owns the data they share, and is the only place work starts: sections and modals answer keys with requests, updateCommon runs them with the in-flight guard and the spinner.
func New ¶
New builds the dashboard model. density is the CLI's --view setting, which the list rows and the detail pane read to decide how much to show, and version is the build the help modal names.
func (*Model) Update ¶
Update routes a key press: ctrl+c quits from anywhere; the top modal takes every other key; the root keys apply unless the section's input owns the keyboard; the focused detail pane scrolls on j/k; the section gets the rest. Everything else is common handling plus a broadcast.
type NamedTheme ¶
NamedTheme is one palette under the name the `theme` config key selects it with.
func NamedThemes ¶
func NamedThemes() []NamedTheme
NamedThemes is every named palette, in listing order.
type Theme ¶
type Theme struct {
Accent color.Color // focus, key hints, selection
Heading color.Color // titles
Text color.Color // body text
TextMuted color.Color // descriptions, secondary text
TextDim color.Color // hints, counts, subtle text
Border color.Color // unfocused borders, empty tracks
BorderFocused color.Color // focused borders
Background color.Color // dashboard background for explicit themes
Surface color.Color // status bar and modal background
Success color.Color // done, progress filled
Warning color.Color // wait, retry
Error color.Color // failures, destructive
Heat1 color.Color // activity ramp, lightest
Heat2 color.Color
Heat3 color.Color
Heat4 color.Color // activity ramp, busiest
}
Theme names the colours the dashboard and the CLI output are drawn with. Every colour is resolved for one background: lipgloss v2 has no adaptive colour, so NewTheme is handed the answer instead — the background the terminal reports (tea.BackgroundColorMsg for the dashboard, a query at startup for the CLI), or the `theme` config key when that pins it (see ApplyThemeSetting). The palette is warm on a dark terminal and the same hues darkened on a light one, so nothing washes out.
func ActiveTheme ¶
ActiveTheme is the palette to draw with: the named one the `theme` config key chose, or the built-in palette resolved for the background isDark. It is what the dashboard and the CLI build their styles from.
func DefaultTheme ¶
func DefaultTheme() Theme
DefaultTheme is the palette for a dark terminal, which is what the dashboard draws with until the terminal answers the background query and what the CLI falls back to when it is not writing to one.