tui

package
v0.6.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BrandGradient []lipgloss.Color
View Source
var SpinnerFrames = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}

Functions

func ASCIIBanner

func ASCIIBanner(frame int) string

func ActiveThemeIndex added in v0.6.0

func ActiveThemeIndex() int

func CategoryTag

func CategoryTag(emoji, label string) string

func CycleTheme

func CycleTheme() string

func DetailTabs

func DetailTabs(snap core.UsageSnapshot) []string

func LoadThemes added in v0.6.0

func LoadThemes(configDir string) error

LoadThemes reloads the theme catalog from the default theme, bundled themes, plus external theme files.

External files are loaded from:

  1. <configDir>/themes
  2. each path in OPENUSAGE_THEME_DIR (path-list separated)

Invalid theme files are skipped. The function returns an aggregated error when one or more files fail to load, while still keeping valid themes available.

func MetaTag

func MetaTag(icon, text string) string

func MetaTagHighlight

func MetaTagHighlight(icon, text string) string

func ModelColor

func ModelColor(idx int) lipgloss.Color

func ProviderColor

func ProviderColor(providerID string) lipgloss.Color

func PulseChar

func PulseChar(bright, dim string, frame int) string

func RenderBrailleChart

func RenderBrailleChart(title string, series []BrailleSeries, w, h int, yFmt func(float64) string) string

func RenderBudgetGauge

func RenderBudgetGauge(label string, used, limit float64, barW, labelW int, color lipgloss.Color, burnRate float64) string

func RenderDetailContent

func RenderDetailContent(snap core.UsageSnapshot, w int, warnThresh, critThresh float64, activeTab int) string

func RenderFixedGrid

func RenderFixedGrid(rows []PanelRow, totalW, totalH int) string

func RenderGauge

func RenderGauge(percent float64, width int, warnThresh, critThresh float64) string

func RenderGradientGauge

func RenderGradientGauge(percent float64, width int, colors []lipgloss.Color) string

func RenderGradientText

func RenderGradientText(text string, frame int) string

func RenderHBarChart

func RenderHBarChart(items []chartItem, maxBarW, labelW int) string

func RenderHeatmap added in v0.5.0

func RenderHeatmap(spec HeatmapSpec, w int) string

func RenderInlineGauge

func RenderInlineGauge(pct float64, w int) string

func RenderMiniGauge

func RenderMiniGauge(usedPercent float64, width int) string

func RenderShimmerGauge added in v0.5.5

func RenderShimmerGauge(width, frame int) string

RenderShimmerGauge draws an animated empty gauge track with a moving bright spot, used as a loading placeholder before real data arrives.

func RenderSparkline

func RenderSparkline(values []float64, w int, color lipgloss.Color) string

func RenderStackedUsageGauge added in v0.5.5

func RenderStackedUsageGauge(segments []GaugeSegment, totalPercent float64, width int) string

RenderStackedUsageGauge draws a multi-segment usage gauge bar. Each segment occupies a proportional share of the filled area. totalPercent is the overall usage percentage shown in the label.

func RenderSubTabBar

func RenderSubTabBar(labels []string, active int, w int) string

func RenderTimeChart added in v0.5.0

func RenderTimeChart(spec TimeChartSpec, w int) string

func RenderTokenBreakdown

func RenderTokenBreakdown(input, output float64, w int) string

func RenderUsageGauge

func RenderUsageGauge(usedPercent float64, width int, warnThresh, critThresh float64) string

func SetThemeByName

func SetThemeByName(name string) bool

func StatusBadge

func StatusBadge(s core.Status) string

func StatusBorderColor

func StatusBorderColor(s core.Status) lipgloss.Color

func StatusColor

func StatusColor(s core.Status) lipgloss.Color

func StatusIcon

func StatusIcon(s core.Status) string

func StatusPill

func StatusPill(s core.Status) string

func ThemeName

func ThemeName() string

Types

type AppUpdateMsg added in v0.5.7

type AppUpdateMsg struct {
	CurrentVersion string
	LatestVersion  string
	UpgradeHint    string
}

type BrailleSeries

type BrailleSeries struct {
	Label  string
	Color  lipgloss.Color
	Points []core.TimePoint
}

type DaemonStatus added in v0.5.0

type DaemonStatus string
const (
	DaemonConnecting   DaemonStatus = "connecting"
	DaemonNotInstalled DaemonStatus = "not_installed"
	DaemonStarting     DaemonStatus = "starting"
	DaemonRunning      DaemonStatus = "running"
	DaemonOutdated     DaemonStatus = "outdated"
	DaemonError        DaemonStatus = "error"
)

type DaemonStatusMsg added in v0.5.0

type DaemonStatusMsg struct {
	Status      DaemonStatus
	Message     string
	InstallHint string
}

type DetailTab

type DetailTab int
const (
	TabAll  DetailTab = 0 // show everything
	TabDyn1 DetailTab = 1 // first dynamic group
)

type GaugeSegment added in v0.5.5

type GaugeSegment struct {
	Percent float64
	Color   lipgloss.Color
}

GaugeSegment represents one colored segment of a stacked gauge bar.

type HeatmapSpec added in v0.5.0

type HeatmapSpec struct {
	Title     string
	Rows      []string
	Cols      []string
	Values    [][]float64 // [row][col]
	MaxCols   int
	RowColors []lipgloss.Color
	RowScale  bool
}

type Model

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

func NewModel

func NewModel(
	warnThresh, critThresh float64,
	experimentalAnalytics bool,
	dashboardCfg config.DashboardConfig,
	accounts []core.AccountConfig,
	timeWindow core.TimeWindow,
) Model

func (Model) Init

func (m Model) Init() tea.Cmd

func (*Model) SetOnAddAccount added in v0.2.0

func (m *Model) SetOnAddAccount(fn func(core.AccountConfig))

SetOnAddAccount sets a callback invoked when a new provider account is added via the API Keys tab.

func (*Model) SetOnInstallDaemon added in v0.5.0

func (m *Model) SetOnInstallDaemon(fn func() error)

func (*Model) SetOnRefresh added in v0.4.0

func (m *Model) SetOnRefresh(fn func())

SetOnRefresh sets a callback invoked when the user requests a manual refresh.

func (*Model) SetOnTimeWindowChange added in v0.5.2

func (m *Model) SetOnTimeWindowChange(fn func(string))

SetOnTimeWindowChange sets a callback invoked when the user changes the time window.

func (Model) Update

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

func (Model) View

func (m Model) View() string

type Panel

type Panel struct {
	Title   string         // displayed in the top border
	Icon    string         // emoji icon before title
	Content string         // pre-rendered body text
	Span    int            // how many grid columns this panel occupies (1 or 2)
	Color   lipgloss.Color // accent color for the border
}

type PanelRow

type PanelRow struct {
	Panels []Panel
	Weight int // relative height weight (0 → 1)
}

type SnapshotsMsg

type SnapshotsMsg map[string]core.UsageSnapshot

type Theme

type Theme struct {
	Name string `json:"name"`
	Icon string `json:"icon"`

	Base     lipgloss.Color `json:"base"`
	Mantle   lipgloss.Color `json:"mantle"`
	Surface0 lipgloss.Color `json:"surface0"`
	Surface1 lipgloss.Color `json:"surface1"`
	Surface2 lipgloss.Color `json:"surface2"`
	Overlay  lipgloss.Color `json:"overlay"`

	Text    lipgloss.Color `json:"text"`
	Subtext lipgloss.Color `json:"subtext"`
	Dim     lipgloss.Color `json:"dim"`

	Accent    lipgloss.Color `json:"accent"`
	Blue      lipgloss.Color `json:"blue"`
	Sapphire  lipgloss.Color `json:"sapphire"`
	Green     lipgloss.Color `json:"green"`
	Yellow    lipgloss.Color `json:"yellow"`
	Red       lipgloss.Color `json:"red"`
	Peach     lipgloss.Color `json:"peach"`
	Teal      lipgloss.Color `json:"teal"`
	Flamingo  lipgloss.Color `json:"flamingo"`
	Rosewater lipgloss.Color `json:"rosewater"`
	Lavender  lipgloss.Color `json:"lavender"`
	Sky       lipgloss.Color `json:"sky"`
	Maroon    lipgloss.Color `json:"maroon"`
}

Theme represents the full visual token set used by the TUI.

External themes can be defined as JSON files with matching snake_case fields, for example: {"name":"My Theme","base":"#111111",...}.

func ActiveTheme added in v0.6.0

func ActiveTheme() Theme

func AvailableThemes added in v0.6.0

func AvailableThemes() []Theme

type TimeChartMode added in v0.5.0

type TimeChartMode int
const (
	TimeChartLine TimeChartMode = iota
	TimeChartStacked
	TimeChartBars
)

type TimeChartSpec added in v0.5.0

type TimeChartSpec struct {
	Title      string
	Mode       TimeChartMode
	Series     []BrailleSeries
	Height     int
	MaxSeries  int
	WindowDays int
	YFmt       func(float64) string
}

Jump to

Keyboard shortcuts

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