tui

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package tui implements the Bubble Tea terminal user interface for doomsday.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ViewName

func ViewName(v View) string

ViewName returns the display name for a view.

Types

type AppKeyMap

type AppKeyMap struct {
	// Actions
	Help    key.Binding
	Quit    key.Binding
	Back    key.Binding
	Enter   key.Binding
	Refresh key.Binding
}

AppKeyMap defines the global keybindings for the application shell.

func DefaultAppKeyMap

func DefaultAppKeyMap() AppKeyMap

DefaultAppKeyMap returns the default application-level key bindings.

func (AppKeyMap) FullHelp

func (k AppKeyMap) FullHelp() [][]key.Binding

FullHelp returns key bindings grouped for the full help view.

func (AppKeyMap) ShortHelp

func (k AppKeyMap) ShortHelp() []key.Binding

ShortHelp returns key bindings for the short help view.

type AppModel

type AppModel struct {
	// contains filtered or unexported fields
}

AppModel is the root Bubble Tea model for the doomsday TUI.

func NewApp

func NewApp(opts ...AppOption) AppModel

NewApp creates a new root TUI application model.

func (AppModel) ActiveView

func (m AppModel) ActiveView() View

ActiveView returns the currently active view.

func (AppModel) Height

func (m AppModel) Height() int

Height returns the terminal height.

func (AppModel) Init

func (m AppModel) Init() tea.Cmd

Init implements tea.Model.

func (AppModel) Styles

func (m AppModel) Styles() Styles

Styles returns the current styles.

func (*AppModel) SwitchView

func (m *AppModel) SwitchView(v View)

SwitchView changes the active view programmatically.

func (AppModel) Theme

func (m AppModel) Theme() Theme

Theme returns the current theme.

func (AppModel) Update

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

Update implements tea.Model.

func (AppModel) View

func (m AppModel) View() string

View implements tea.Model.

func (AppModel) Width

func (m AppModel) Width() int

Width returns the terminal width.

type AppOption

type AppOption func(*AppModel)

AppOption is a functional option for configuring the App model.

func WithDissolveActiveFunc

func WithDissolveActiveFunc(fn func() bool) AppOption

WithDissolveActiveFunc sets a function that returns true during dissolve animation.

func WithModalActiveFunc

func WithModalActiveFunc(fn func() bool) AppOption

WithModalActiveFunc sets a function that returns true when a modal overlay is active. When active, global keybindings (quit, view switching) are suppressed.

func WithStatusMessageFunc

func WithStatusMessageFunc(fn func() string) AppOption

WithStatusMessageFunc sets a function that returns a transient status message to display in the status bar.

func WithTheme

func WithTheme(theme Theme) AppOption

WithTheme sets the theme for the app.

func WithThemeMode

func WithThemeMode(mode ThemeMode) AppOption

WithThemeMode sets the theme mode for the app.

func WithToolbarFunc

func WithToolbarFunc(fn func() string) AppOption

WithToolbarFunc sets the function that returns the context-sensitive toolbar.

func WithViewInitFunc

func WithViewInitFunc(fn func() tea.Cmd) AppOption

WithViewInitFunc sets the function called during Init to initialize views.

func WithViewRenderFunc

func WithViewRenderFunc(fn func(View, int, int) string) AppOption

WithViewRenderFunc sets the function used to render view content.

func WithViewUpdateFunc

func WithViewUpdateFunc(fn func(View, tea.Msg) tea.Cmd) AppOption

WithViewUpdateFunc sets the function used to dispatch updates to views.

type ColorPalette

type ColorPalette struct {
	// Primary brand colors
	Primary   lipgloss.Color
	Secondary lipgloss.Color
	Accent    lipgloss.Color

	// Status colors
	StatusOK      lipgloss.Color
	StatusWarning lipgloss.Color
	StatusError   lipgloss.Color

	// Text colors
	TextPrimary   lipgloss.Color
	TextSecondary lipgloss.Color
	TextMuted     lipgloss.Color
	TextInverse   lipgloss.Color

	// Surface colors
	Surface       lipgloss.Color
	SurfaceAlt    lipgloss.Color
	SurfaceBright lipgloss.Color
	Background    lipgloss.Color

	// Border colors
	Border       lipgloss.Color
	BorderActive lipgloss.Color
	BorderMuted  lipgloss.Color

	// Special purpose
	Highlight lipgloss.Color
	Selection lipgloss.Color

	// Progress bar gradient
	ProgressStart lipgloss.Color
	ProgressEnd   lipgloss.Color
}

ColorPalette holds all colors used throughout the TUI.

func DarkPalette

func DarkPalette() ColorPalette

DarkPalette returns the dark theme color palette. Apocalyptic aesthetic: deep reds, ambers, muted greens on dark surfaces.

func LightPalette

func LightPalette() ColorPalette

LightPalette returns the light theme color palette.

type DashboardKeyMap

type DashboardKeyMap struct {
	NavigationKeyMap
	RunBackup key.Binding
}

DashboardKeyMap defines keybindings for the dashboard/drill-down view.

func DefaultDashboardKeyMap

func DefaultDashboardKeyMap() DashboardKeyMap

DefaultDashboardKeyMap returns default dashboard view bindings.

func (DashboardKeyMap) FullHelp

func (k DashboardKeyMap) FullHelp() [][]key.Binding

FullHelp returns dashboard full help bindings.

func (DashboardKeyMap) ShortHelp

func (k DashboardKeyMap) ShortHelp() []key.Binding

ShortHelp returns dashboard short help bindings.

type NavigationKeyMap struct {
	Up       key.Binding
	Down     key.Binding
	PageUp   key.Binding
	PageDown key.Binding
	Top      key.Binding
	Bottom   key.Binding
}

NavigationKeyMap provides vim-style up/down navigation.

func DefaultNavigationKeyMap

func DefaultNavigationKeyMap() NavigationKeyMap

DefaultNavigationKeyMap returns standard vim-style navigation bindings.

func (k NavigationKeyMap) FullHelp() [][]key.Binding

FullHelp returns bindings for full help.

func (k NavigationKeyMap) ShortHelp() []key.Binding

ShortHelp returns bindings for short help.

type SnapshotKeyMap

type SnapshotKeyMap struct {
	NavigationKeyMap
	Browse  key.Binding
	Restore key.Binding
	Diff    key.Binding
	Filter  key.Binding
}

SnapshotKeyMap defines keybindings for the snapshot browser view.

func DefaultSnapshotKeyMap

func DefaultSnapshotKeyMap() SnapshotKeyMap

DefaultSnapshotKeyMap returns default snapshot view bindings.

func (SnapshotKeyMap) FullHelp

func (k SnapshotKeyMap) FullHelp() [][]key.Binding

FullHelp returns snapshot full help bindings.

func (SnapshotKeyMap) ShortHelp

func (k SnapshotKeyMap) ShortHelp() []key.Binding

ShortHelp returns snapshot short help bindings.

type Styles

type Styles struct {
	// Layout
	App       lipgloss.Style
	TabBar    lipgloss.Style
	TabActive lipgloss.Style
	TabItem   lipgloss.Style
	Content   lipgloss.Style
	StatusBar lipgloss.Style

	// Typography
	Title    lipgloss.Style
	Subtitle lipgloss.Style
	Heading  lipgloss.Style
	Body     lipgloss.Style
	Muted    lipgloss.Style
	Bold     lipgloss.Style
	Code     lipgloss.Style
	Whimsy   lipgloss.Style

	// Status indicators
	StatusOK      lipgloss.Style
	StatusWarning lipgloss.Style
	StatusError   lipgloss.Style
	StatusBadge   lipgloss.Style

	// Cards and containers
	Card        lipgloss.Style
	CardActive  lipgloss.Style
	CardHeader  lipgloss.Style
	Panel       lipgloss.Style
	PanelBorder lipgloss.Style

	// Data display
	Key       lipgloss.Style
	Value     lipgloss.Style
	Label     lipgloss.Style
	Number    lipgloss.Style
	Timestamp lipgloss.Style
	Path      lipgloss.Style
	BlobID    lipgloss.Style

	// Interactive
	Selected  lipgloss.Style
	Cursor    lipgloss.Style
	Highlight lipgloss.Style

	// Table
	TableHeader   lipgloss.Style
	TableCell     lipgloss.Style
	TableSelected lipgloss.Style

	// Backup config items
	ConfigName    lipgloss.Style
	ConfigOK      lipgloss.Style
	ConfigWarning lipgloss.Style
	ConfigError   lipgloss.Style

	// Progress
	ProgressLabel lipgloss.Style
	ProgressValue lipgloss.Style
	ProgressSpeed lipgloss.Style
	ProgressETA   lipgloss.Style

	// Dividers
	Divider lipgloss.Style

	// Logo / brand
	LogoAccent lipgloss.Style

	// Help
	HelpKey  lipgloss.Style
	HelpDesc lipgloss.Style
	HelpSep  lipgloss.Style
}

Styles holds all lipgloss styles used throughout the TUI. Built from a Theme so they adapt to dark/light mode.

func NewStyles

func NewStyles(theme Theme) Styles

NewStyles creates a complete style set from a theme.

func (Styles) RenderDivider

func (s Styles) RenderDivider(width int) string

Divider returns a horizontal divider string of the given width.

func (Styles) StatusDot

func (s Styles) StatusDot(status string) string

StatusDot returns a colored dot for the given status.

func (Styles) StatusText

func (s Styles) StatusText(status, text string) string

StatusText returns styled text with status coloring.

type Theme

type Theme struct {
	Mode   ThemeMode
	Colors ColorPalette
	IsDark bool
	Name   string
}

Theme holds the active color palette and metadata.

func DefaultTheme

func DefaultTheme() Theme

DefaultTheme returns the default auto-detect theme.

func NewTheme

func NewTheme(mode ThemeMode) Theme

NewTheme creates a theme based on the given mode.

type ThemeMode

type ThemeMode int

ThemeMode represents the terminal color scheme.

const (
	// ThemeAuto detects the terminal background color.
	ThemeAuto ThemeMode = iota
	// ThemeDark uses the dark color palette.
	ThemeDark
	// ThemeLight uses the light color palette.
	ThemeLight
)

func ParseThemeMode

func ParseThemeMode(s string) ThemeMode

ParseThemeMode converts a config string to a ThemeMode.

type View

type View int

View identifies the currently active TUI view.

const (
	ViewDashboard View = iota
	ViewHelp
)

type ViewModel

type ViewModel interface {
	Init() tea.Cmd
	Update(tea.Msg) (ViewModel, tea.Cmd)
	View() string
}

ViewModel is the interface that all view sub-models must implement to participate in the app's view switching mechanism.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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