tui

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 27 Imported by: 0

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

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

func ApplyThemeSetting(setting string) error

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

func PinnedDark() (isDark bool, pinned bool)

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

func ResolveThemeSetting(setting string) (string, error)

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

func Run(ctx context.Context, a *app.App, density Density, version string) error

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.

const (
	DensityCompact Density = iota
	DensityDefault
	DensityVerbose
)

func ParseDensity

func ParseDensity(raw string) (Density, error)

ParseDensity reads the `--view` flag. An empty value is the default, so a command that never sets the flag gets the middle density.

func (Density) Label

func (d Density) Label() string

Label names the density for a toast or a flag error.

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

func New(ctx context.Context, a *app.App, density Density, version string) *Model

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

func (m *Model) Init() tea.Cmd

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

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.

func (*Model) View

func (m *Model) View() tea.View

View is the frame plus the terminal's own cursor. The alt screen is a field of the view in v2 rather than a program option, so it is set here on every frame.

type NamedTheme

type NamedTheme struct {
	Name   string
	IsDark bool
	Theme  Theme
}

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

func ActiveTheme(isDark bool) Theme

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.

func NewTheme

func NewTheme(isDark bool) Theme

NewTheme is the built-in palette in 256-colour indices, resolved for a dark or a light terminal. The dark side is the gold-and-olive look the dashboard has always had; the light side keeps the hues but drops their luminance so they read on white.

Jump to

Keyboard shortcuts

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