config

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToLipglossColor

func ConvertToLipglossColor(hex string) lipgloss.Color

ConvertToLipglossColor converts a hex color string to lipgloss.Color

func DetectTerminalDarkMode

func DetectTerminalDarkMode() bool

DetectTerminalDarkMode attempts to detect if terminal is in dark mode

func DetectTerminalDarkModeLive

func DetectTerminalDarkModeLive() bool

DetectTerminalDarkModeLive performs live terminal theme detection for dynamic theme switching while the app is running. The result is cached for liveModeTTL so rapid successive calls (and calls from concurrent goroutines) don't each spawn a subprocess.

An explicit SIMTOOL_THEME_MODE override bypasses the cache.

func FormatKeys

func FormatKeys(keys []string) string

FormatKeys formats multiple keys for display in the UI e.g. ["up", "k"] -> "↑/k"

func GetDetectedMode

func GetDetectedMode() string

GetDetectedMode returns the previously detected mode

func InitializeThemeDetection

func InitializeThemeDetection()

InitializeThemeDetection performs terminal theme detection before TUI starts

func IsColorDark

func IsColorDark(colorStr string) bool

IsColorDark determines if an RGB color string is dark

func QueryTerminalBackground

func QueryTerminalBackground() string

QueryTerminalBackground attempts to detect terminal background

func QueryTerminalBackgroundColor

func QueryTerminalBackgroundColor() (string, error)

QueryTerminalBackgroundColor queries the terminal's background color using OSC 11

func QueryTerminalBackgroundLive

func QueryTerminalBackgroundLive() string

QueryTerminalBackgroundLive attempts to detect terminal background for live updates This version is designed to work even when running inside a TUI

func ResetLiveModeCache added in v1.1.0

func ResetLiveModeCache()

ResetLiveModeCache clears the cached live theme mode. Intended for tests that need to force a fresh detection query.

func SaveExample

func SaveExample() error

SaveExample saves an example configuration file

Types

type Config

type Config struct {
	Theme   ThemeConfig   `toml:"theme"`
	Keys    KeysConfig    `toml:"keys"`
	Startup StartupConfig `toml:"startup"`
}

Config represents the application configuration

func Default

func Default() *Config

Default returns the default configuration

func Load

func Load() (*Config, error)

Load loads configuration from the standard config path. On any error a usable default config is returned alongside the error so callers can gracefully fall back.

func (*Config) GenerateStyles

func (c *Config) GenerateStyles() *Styles

GenerateStyles creates lipgloss styles from the configuration

func (*Config) GetActiveTheme

func (c *Config) GetActiveTheme() string

GetActiveTheme returns the active theme name based on config and terminal mode

func (*Config) Validate added in v1.1.0

func (c *Config) Validate() error

Validate checks that a Config's enum-valued fields hold only accepted values. Empty strings are accepted since they fall back to defaults via merge().

type KeyMap

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

KeyMap provides a fast lookup for key bindings

func NewKeyMap

func NewKeyMap(keys KeysConfig) *KeyMap

NewKeyMap creates a key mapping from the configuration

func (*KeyMap) GetAction

func (km *KeyMap) GetAction(key string) string

GetAction returns the action for a given key, or empty string if not bound

func (*KeyMap) IsKey

func (km *KeyMap) IsKey(key string, action string) bool

IsKey checks if a key is bound to a specific action

type KeysConfig

type KeysConfig struct {
	// Navigation
	Up    []string `toml:"up"`
	Down  []string `toml:"down"`
	Left  []string `toml:"left"`
	Right []string `toml:"right"`
	Home  []string `toml:"home"`
	End   []string `toml:"end"`

	// Actions
	Quit   []string `toml:"quit"`
	Boot   []string `toml:"boot"`   // Boot simulator
	Open   []string `toml:"open"`   // Open in Finder
	Filter []string `toml:"filter"` // Toggle filter
	Search []string `toml:"search"` // Start search
	Escape []string `toml:"escape"` // Exit search/cancel
	Enter  []string `toml:"enter"`  // Select/confirm

	// Search mode
	Backspace []string `toml:"backspace"` // Delete character in search
}

KeysConfig represents keyboard shortcut configuration

func DefaultKeys

func DefaultKeys() KeysConfig

DefaultKeys returns the default keyboard shortcuts

func (*KeysConfig) FormatKeyAction

func (kc *KeysConfig) FormatKeyAction(action string, label string) string

FormatKeyAction formats a key binding with its action label e.g. "up", "up" -> "↑/k: up"

type StartupConfig

type StartupConfig struct {
	// Initial view to show on startup: "simulator_list" (default) or "all_apps"
	InitialView string `toml:"initial_view"`
}

StartupConfig defines startup behavior

type Styles

type Styles struct {
	// Selection styles
	Selected lipgloss.Style
	Normal   lipgloss.Style

	// Status styles
	Booted   lipgloss.Style
	Shutdown lipgloss.Style
	Error    lipgloss.Style
	Success  lipgloss.Style

	// UI element styles
	Header lipgloss.Style
	Border lipgloss.Style
	Footer lipgloss.Style

	// Content styles
	Name   lipgloss.Style
	Detail lipgloss.Style
	Folder lipgloss.Style

	// Search and status styles
	Search  lipgloss.Style
	Status  lipgloss.Style
	Loading lipgloss.Style

	// List item style
	ListItem lipgloss.Style
}

Styles holds all the application styles generated from config

type ThemeColors

type ThemeColors struct {
	// Base colors
	Background string
	Foreground string

	// UI element colors
	Selection     string // For selected items
	SelectionText string // Text on selected items
	Border        string // For borders
	HeaderBg      string // Header background
	HeaderFg      string // Header foreground

	// Status colors
	Success string // Success/running status
	Error   string // Error messages
	Warning string // Warnings
	Info    string // Info messages

	// Content colors
	Primary   string // Primary content (names)
	Secondary string // Secondary content (details)
	Muted     string // Muted text (footer, etc)
	Accent    string // Accent color (folders, special items)
}

ThemeColors holds all colors derived from a chroma theme

func ExtractThemeColors

func ExtractThemeColors(themeName string) (*ThemeColors, error)

ExtractThemeColors extracts colors from a chroma theme

type ThemeConfig

type ThemeConfig struct {
	// Force dark or light mode ("dark", "light", or "auto")
	Mode string `toml:"mode"`

	// Themes for each mode
	DarkTheme  string `toml:"dark_theme"`  // Theme to use in dark mode
	LightTheme string `toml:"light_theme"` // Theme to use in light mode
}

ThemeConfig defines theme configuration

Jump to

Keyboard shortcuts

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