Documentation
¶
Overview ¶
Package tui provides shared TUI components for Lango CLI commands.
Index ¶
- Constants
- Variables
- func BadgeStyle(color lipgloss.Color) lipgloss.Style
- func Banner() string
- func BannerBox() string
- func Breadcrumb(segments ...string) string
- func Divider(width int) string
- func FormatDuration(d time.Duration) string
- func FormatFail(msg string) string
- func FormatMuted(msg string) string
- func FormatNumber(n int64) string
- func FormatPass(msg string) string
- func FormatTokens(n int) string
- func FormatWarn(msg string) string
- func GetVersion() string
- func HelpBar(entries ...string) string
- func HelpEntry(key, label string) string
- func KeyBadge(key string) string
- func RelativeTime(now, t time.Time) string
- func RelativeTimeHuman(now, t time.Time) string
- func ServeBanner() string
- func SetProfile(name string)
- func SetVersionInfo(version, buildTime string)
- func StartupSummary(features []FeatureLine) string
- func Truncate(s string, maxLen int) string
- func WordWrap(text string, width int) string
- type FeatureLine
Constants ¶
const ( CheckPass = "✓" CheckWarn = "⚠" CheckFail = "✗" Spinner = "◌" )
Check result indicators
Variables ¶
var ( Primary = lipgloss.Color("#7C3AED") // Purple Success = lipgloss.Color("#10B981") // Green Warning = lipgloss.Color("#F59E0B") // Amber Error = lipgloss.Color("#EF4444") // Red Muted = lipgloss.Color("#6B7280") // Gray Foreground = lipgloss.Color("#F9FAFB") // White Background = lipgloss.Color("#1F2937") // Dark gray Highlight = lipgloss.Color("#3B82F6") // Blue Accent = lipgloss.Color("#04B575") // Green (selection/focus) Dim = lipgloss.Color("#626262") // Dim gray (descriptions) Separator = lipgloss.Color("#374151") // Dark gray (dividers) )
Color palette for consistent theming
var ( // TitleStyle for main headers TitleStyle = lipgloss.NewStyle(). Bold(true). Foreground(Primary). MarginBottom(1) // SubtitleStyle for secondary headers SubtitleStyle = lipgloss.NewStyle(). Foreground(Muted). MarginBottom(1) // SuccessStyle for success messages SuccessStyle = lipgloss.NewStyle(). Foreground(Success) // WarningStyle for warning messages WarningStyle = lipgloss.NewStyle(). Foreground(Warning) // ErrorStyle for error messages ErrorStyle = lipgloss.NewStyle(). Foreground(Error) // MutedStyle for less important text MutedStyle = lipgloss.NewStyle(). Foreground(Muted) // HighlightStyle for emphasized text HighlightStyle = lipgloss.NewStyle(). Foreground(Highlight). Bold(true) // BoxStyle for bordered containers BoxStyle = lipgloss.NewStyle(). Border(lipgloss.RoundedBorder()). BorderForeground(Muted). Padding(1, 2) // ListItemStyle for list items ListItemStyle = lipgloss.NewStyle(). PaddingLeft(2) // SelectedItemStyle for selected list items SelectedItemStyle = lipgloss.NewStyle(). PaddingLeft(2). Foreground(Primary). Bold(true) // SectionHeaderStyle for menu section titles SectionHeaderStyle = lipgloss.NewStyle(). Foreground(Highlight). Bold(true). PaddingLeft(2) // SeparatorLineStyle for section dividers SeparatorLineStyle = lipgloss.NewStyle(). Foreground(Separator) // CursorStyle for the selection arrow CursorStyle = lipgloss.NewStyle(). Foreground(Accent) // ActiveItemStyle for highlighted/selected items ActiveItemStyle = lipgloss.NewStyle(). Foreground(Accent). Bold(true) // SearchBarStyle for the search input container SearchBarStyle = lipgloss.NewStyle(). Border(lipgloss.RoundedBorder()). BorderForeground(Primary). Padding(0, 1) // FormTitleBarStyle for form titles FormTitleBarStyle = lipgloss.NewStyle(). Bold(true). Foreground(Primary). Border(lipgloss.NormalBorder(), false, false, true, false). BorderForeground(Primary). MarginBottom(1) // FieldDescStyle for field description/help text FieldDescStyle = lipgloss.NewStyle(). Foreground(Dim). Italic(true). PaddingLeft(2) // BadgeAdvancedStyle for the ADV badge on advanced categories BadgeAdvancedStyle = lipgloss.NewStyle(). Foreground(Foreground). Background(Muted). Bold(true). Padding(0, 1) // BadgeDependencyStyle for the dependency warning badge on categories BadgeDependencyStyle = lipgloss.NewStyle(). Foreground(Foreground). Background(Warning). Bold(true). Padding(0, 1) // BadgeExperimentalStyle for the EXP badge on experimental categories BadgeExperimentalStyle = lipgloss.NewStyle(). Foreground(Warning). Bold(true). Padding(0, 1) )
Base styles for TUI components
var ( Danger = Error // destructive/high-risk operations Info = Highlight // informational highlights Selection = Accent // user selection/focus indicator )
Semantic color aliases for state-driven rendering.
var ( // BadgeBaseStyle renders a compact pill-shaped label with padding and no border. BadgeBaseStyle = lipgloss.NewStyle(). Padding(0, 1). Bold(true) // DividerStyle renders a subtle horizontal separator using dim foreground. DividerStyle = lipgloss.NewStyle(). Foreground(Separator) // PillStyle renders a rounded-corner pill for status labels. PillStyle = lipgloss.NewStyle(). Padding(0, 1) // SpacedBlockStyle provides consistent vertical spacing without borders. SpacedBlockStyle = lipgloss.NewStyle(). PaddingLeft(2). MarginBottom(1) )
Spacing-based styles (prefer over borders for visual hierarchy).
Functions ¶
func BadgeStyle ¶ added in v0.7.0
BadgeStyle returns a pill-shaped badge in the given color.
func BannerBox ¶
func BannerBox() string
BannerBox wraps the Banner in a rounded border box (for settings welcome).
func Breadcrumb ¶
Breadcrumb renders a navigation path like "Settings > Agent Configuration".
func FormatDuration ¶ added in v0.7.0
FormatDuration renders a duration as a human-friendly string (e.g., "2h 15m", "3m 42s", "150ms").
func FormatNumber ¶ added in v0.7.0
FormatNumber renders an integer with comma-separated thousands (e.g., 12345 -> "12,345").
func FormatTokens ¶ added in v0.7.0
FormatTokens returns a human-readable token count with comma separators.
func GetVersion ¶ added in v0.6.0
func GetVersion() string
GetVersion returns the current version string.
func RelativeTime ¶ added in v0.7.0
RelativeTime formats a timestamp as a human-readable relative duration. It returns precise values for sub-minute durations (e.g., "5s ago").
func RelativeTimeHuman ¶ added in v0.7.0
RelativeTimeHuman formats a timestamp as a friendly relative duration. For sub-minute durations it returns "just now" instead of precise seconds.
func ServeBanner ¶
func ServeBanner() string
ServeBanner returns a banner for the serve command with a separator line.
func SetVersionInfo ¶
func SetVersionInfo(version, buildTime string)
SetVersionInfo injects version and build time from main.go.
func StartupSummary ¶ added in v0.6.0
func StartupSummary(features []FeatureLine) string
StartupSummary renders activated features based on config flags. Each entry is a key string mapped to an enabled bool and optional detail.
Types ¶
type FeatureLine ¶ added in v0.6.0
FeatureLine describes a single feature for startup summary.