ui

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentWidth  = 72
	HeaderHeight  = 3
	FooterHeight  = 2
	MaxListItems  = 15
	ColumnGap     = 2
	ColumnPadding = 1
)

Layout constants

View Source
const AppName = "Lume"

Application info

Variables

View Source
var (
	PrimaryColor   = lipgloss.Color("#5fafff") // Bright blue
	SecondaryColor = lipgloss.Color("#5fd787") // Green
	AccentColor    = lipgloss.Color("#d787ff") // Purple accent
	DangerColor    = lipgloss.Color("#ff5f87") // Red
	WarningColor   = lipgloss.Color("#ffd75f") // Yellow
	SuccessColor   = lipgloss.Color("#5fd787") // Green
	GrayColor      = lipgloss.Color("#6b7280") // Mid gray
	LightGrayColor = lipgloss.Color("#9ca3af") // Light gray
	DimColor       = lipgloss.Color("#4e4e4e") // Very dim
	WhiteColor     = lipgloss.Color("#e4e4e4") // Off-white
	BlackColor     = lipgloss.Color("#000000")
	BgSelected     = lipgloss.Color("#1c3a5f") // Selection bg
)

Theme colors — cohesive modern palette

View Source
var (
	TitleStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(PrimaryColor)

	SubtitleStyle = lipgloss.NewStyle().
					Foreground(LightGrayColor)

	HelpStyle = lipgloss.NewStyle().
				Foreground(GrayColor)

	DimStyle = lipgloss.NewStyle().
				Foreground(DimColor)

	AccentStyle = lipgloss.NewStyle().
				Foreground(AccentColor).
				Bold(true)

	WarningStyle = lipgloss.NewStyle().
					Foreground(WarningColor).
					Bold(true)

	ErrorStyle = lipgloss.NewStyle().
				Foreground(DangerColor).
				Bold(true)

	SuccessStyle = lipgloss.NewStyle().
					Foreground(SecondaryColor).
					Bold(true)

	InfoBoxStyle = lipgloss.NewStyle().
					Border(lipgloss.Border{
			Top:         "-",
			Bottom:      "-",
			Left:        "|",
			Right:       "|",
			TopLeft:     "+",
			TopRight:    "+",
			BottomLeft:  "+",
			BottomRight: "+",
		}).
		BorderForeground(GrayColor).
		Padding(0, 1)
)

Base styles

View Source
var (
	ScanItemStyle = lipgloss.NewStyle().
					Padding(0, 0)

	SelectedScanItemStyle = lipgloss.NewStyle().
							Background(BgSelected).
							Foreground(WhiteColor).
							Padding(0, 0).
							Bold(true)
)

List styles

View Source
var (
	RiskLowStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("#5fd787"))

	RiskMediumStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("#ffd75f"))

	RiskHighStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("#ff5f87"))
)

Risk level styles

View Source
var AppVersion = "v1.0.0"

AppVersion is the application version. Override at build time: go build -ldflags "-X github.com/Tyooughtul/lume/pkg/ui.AppVersion=vX.Y.Z"

View Source
var PresetThemes = map[string]Theme{
	"modern": {
		Name:        "modern",
		Description: "Modern Cyber (default)",
		Primary:     "#00d4ff",
		Secondary:   "#00ff88",
		Accent:      "#ff00ff",
		Danger:      "#ff3366",
		Warning:     "#ffcc00",
		Success:     "#00ff88",
		Foreground:  "#ffffff",
		Gray:        "#6b7280",
		LightGray:   "#9ca3af",
		Dim:         "#4e4e4e",
		SelectedBg:  "#0a3d62",
		SelectedFg:  "#ffffff",
		Border:      "#00d4ff",
	},
	"retro": {
		Name:        "retro",
		Description: "Retro Terminal",
		Primary:     "#33ff33",
		Secondary:   "#00ff00",
		Accent:      "#ffff00",
		Danger:      "#ff3333",
		Warning:     "#ffaa00",
		Success:     "#33ff33",
		Foreground:  "#33ff33",
		Gray:        "#228822",
		LightGray:   "#44aa44",
		Dim:         "#115511",
		SelectedBg:  "#004400",
		SelectedFg:  "#33ff33",
		Border:      "#228822",
	},
	"amber": {
		Name:        "amber",
		Description: "Amber Monitor",
		Primary:     "#ffb000",
		Secondary:   "#ffcc00",
		Accent:      "#ffdd44",
		Danger:      "#ff6600",
		Warning:     "#ffaa00",
		Success:     "#cc9900",
		Foreground:  "#ffb000",
		Gray:        "#996600",
		LightGray:   "#cc8800",
		Dim:         "#553300",
		SelectedBg:  "#442200",
		SelectedFg:  "#ffb000",
		Border:      "#996600",
	},
	"ocean": {
		Name:        "ocean",
		Description: "Deep Ocean",
		Primary:     "#4fc3f7",
		Secondary:   "#80cbc4",
		Accent:      "#ff80ab",
		Danger:      "#ef5350",
		Warning:     "#ffca28",
		Success:     "#66bb6a",
		Foreground:  "#e3f2fd",
		Gray:        "#78909c",
		LightGray:   "#b0bec5",
		Dim:         "#37474f",
		SelectedBg:  "#1565c0",
		SelectedFg:  "#e3f2fd",
		Border:      "#4fc3f7",
	},
	"highcontrast": {
		Name:        "highcontrast",
		Description: "High Contrast (Accessibility)",
		Primary:     "#ffffff",
		Secondary:   "#00ff00",
		Accent:      "#ffff00",
		Danger:      "#ff0000",
		Warning:     "#ffff00",
		Success:     "#00ff00",
		Foreground:  "#ffffff",
		Gray:        "#888888",
		LightGray:   "#cccccc",
		Dim:         "#666666",
		SelectedBg:  "#ffffff",
		SelectedFg:  "#000000",
		Border:      "#ffffff",
	},
	"dracula": {
		Name:        "dracula",
		Description: "Dracula",
		Primary:     "#bd93f9",
		Secondary:   "#50fa7b",
		Accent:      "#ff79c6",
		Danger:      "#ff5555",
		Warning:     "#f1fa8c",
		Success:     "#50fa7b",
		Foreground:  "#f8f8f2",
		Gray:        "#6272a4",
		LightGray:   "#8be9fd",
		Dim:         "#44475a",
		SelectedBg:  "#44475a",
		SelectedFg:  "#f8f8f2",
		Border:      "#6272a4",
	},
	"solarized": {
		Name:        "solarized",
		Description: "Solarized Dark",
		Primary:     "#268bd2",
		Secondary:   "#2aa198",
		Accent:      "#d33682",
		Danger:      "#dc322f",
		Warning:     "#b58900",
		Success:     "#859900",
		Foreground:  "#839496",
		Gray:        "#586e75",
		LightGray:   "#93a1a1",
		Dim:         "#073642",
		SelectedBg:  "#073642",
		SelectedFg:  "#eee8d5",
		Border:      "#586e75",
	},
	"monokai": {
		Name:        "monokai",
		Description: "Monokai",
		Primary:     "#66d9ef",
		Secondary:   "#a6e22e",
		Accent:      "#f92672",
		Danger:      "#f92672",
		Warning:     "#e6db74",
		Success:     "#a6e22e",
		Foreground:  "#f8f8f2",
		Gray:        "#75715e",
		LightGray:   "#ae81ff",
		Dim:         "#49483e",
		SelectedBg:  "#49483e",
		SelectedFg:  "#f8f8f2",
		Border:      "#75715e",
	},
}

PresetThemes contains all built-in themes

Functions

func Center

func Center(width, height int, content string) string

Center centers content in the terminal

func Checkbox

func Checkbox(checked bool) string

Checkbox returns a styled checkbox

func CreateMenuItem

func CreateMenuItem(icon, name, desc string, selected bool, width int) string

CreateMenuItem creates a menu item line

func Divider

func Divider(width int) string

Divider creates a separator line

func FormatSize

func FormatSize(size int64) string

FormatSize formats file size with color coding

func GarbageTruckTick added in v1.0.3

func GarbageTruckTick() tea.Cmd

GarbageTruckTick 返回垃圾车动画 tick 命令

func GetQuickStats

func GetQuickStats() (string, error)

func GetRiskLabel added in v1.0.1

func GetRiskLabel(level scanner.RiskLevel) string

GetRiskLabel returns a styled, fixed-width risk label. Padding is applied to the plain text BEFORE coloring, so that runewidth sees only ASCII and every line has the same visual width.

func GetRiskStyle

func GetRiskStyle(level int) lipgloss.Style

GetRiskStyle returns style for a risk level

func Header(title, subtitle string) string

Header creates page header (legacy compat)

func HelpBar

func HelpBar(shortcuts []string) string

HelpBar creates a help bar (legacy compat)

func InitThemeManager added in v1.0.1

func InitThemeManager()

InitThemeManager initializes the global theme manager

func ListItem

func ListItem(checkbox, name, size, extra string, selected bool, widths map[string]int) string

ListItem creates a list item

func Logo() string

Logo renders the application banner

func PageHeader(icon, title string, width int) string

PageHeader renders a consistent page header with title and navigation hint

func ProgressBar

func ProgressBar(percent float64, width int, usedColor, freeColor lipgloss.Color) string

ProgressBar renders a colored progress bar

func RecordSnapshot

func RecordSnapshot(total, used uint64, cleanedSize int64, trigger, details string) tea.Cmd

func ScrollIndicator

func ScrollIndicator(offset, total, visible int) (above, below string)

ScrollIndicator returns scroll direction hints

func StatsBar

func StatsBar(stats []string) string

StatsBar creates a statistics bar with border

func StatsLine

func StatsLine(stats []string) string

StatsLine renders inline statistics separated by dim pipes

func StyledHelpBar

func StyledHelpBar(shortcuts []KeyHelp) string

StyledHelpBar renders a help bar with highlighted keys

func TableHeader

func TableHeader(columns []string, widths []int) string

TableHeader creates a table header

Types

type App

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

App is the main application model

func NewApp

func NewApp() *App

NewApp creates the main application

func (App) Init

func (a App) Init() tea.Cmd

Init initializes the application

func (*App) Update

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

Update handles state updates

func (App) View

func (a App) View() string

View renders the current view

type AppUninstallerView

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

func NewAppUninstallerView

func NewAppUninstallerView() *AppUninstallerView

func (*AppUninstallerView) Init

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

func (*AppUninstallerView) Update

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

func (AppUninstallerView) View

func (m AppUninstallerView) View() string

type BackToMenuMsg

type BackToMenuMsg struct{}

type Box

type Box struct {
	Title   string
	Content string
	Footer  string
	Width   int
}

Box is a generic content box

func (Box) Render

func (b Box) Render() string

Render renders a Box

type BrowserDataView

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

func NewBrowserDataView

func NewBrowserDataView() *BrowserDataView

func (*BrowserDataView) Init

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

func (*BrowserDataView) Update

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

func (BrowserDataView) View

func (m BrowserDataView) View() string

type DiskTrend

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

func NewDiskTrend

func NewDiskTrend() *DiskTrend

func (*DiskTrend) Init

func (d *DiskTrend) Init() tea.Cmd

func (*DiskTrend) Update

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

func (*DiskTrend) View

func (d *DiskTrend) View() string

type DuplicatesView

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

func NewDuplicatesView

func NewDuplicatesView() *DuplicatesView

func (*DuplicatesView) Init

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

func (*DuplicatesView) Update

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

func (DuplicatesView) View

func (m DuplicatesView) View() string

type GarbageTruckAnimation added in v1.0.3

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

GarbageTruckAnimation garbage truck idle animation

func NewGarbageTruckAnimation added in v1.0.3

func NewGarbageTruckAnimation() *GarbageTruckAnimation

func (*GarbageTruckAnimation) Draw added in v1.0.3

func (g *GarbageTruckAnimation) Draw(width int) string

func (*GarbageTruckAnimation) Update added in v1.0.3

func (g *GarbageTruckAnimation) Update()

type GarbageTruckTickMsg added in v1.0.3

type GarbageTruckTickMsg struct{}

GarbageTruckTickMsg 垃圾车动画 tick

type KeyHelp

type KeyHelp struct {
	Key  string
	Desc string
}

KeyHelp represents a keyboard shortcut

type LargeFilesView

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

func NewLargeFilesView

func NewLargeFilesView() *LargeFilesView

func (*LargeFilesView) Init

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

func (*LargeFilesView) Update

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

func (LargeFilesView) View

func (m LargeFilesView) View() string
type MainMenu struct {
	ThemeNotif string // transient theme-switch notification
	// contains filtered or unexported fields
}

func NewMainMenu

func NewMainMenu() *MainMenu
func (m MainMenu) Init() tea.Cmd
func (m *MainMenu) Update(msg tea.Msg) (tea.Model, tea.Cmd)
func (m MainMenu) View() string
type MenuItem struct {
	Name        string
	Description string
	Icon        string
	View        ViewType
}
type MenuSelectedMsg struct {
	View ViewType
}

type RecordSnapshotMsg

type RecordSnapshotMsg struct {
	Total       uint64
	Used        uint64
	CleanedSize int64
	Trigger     string
	Details     string
}

type SystemJunkViewEnhanced

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

func NewSystemJunkViewEnhanced

func NewSystemJunkViewEnhanced() *SystemJunkViewEnhanced

func (*SystemJunkViewEnhanced) Init

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

func (*SystemJunkViewEnhanced) Update

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

func (SystemJunkViewEnhanced) View

func (m SystemJunkViewEnhanced) View() string

type Theme added in v1.0.1

type Theme struct {
	Name        string `json:"name"`
	Description string `json:"description"`

	// Core colors
	Primary   string `json:"primary"`   // primary (titles, selected items)
	Secondary string `json:"secondary"` // secondary (success, idle state)
	Accent    string `json:"accent"`    // accent (special highlights)
	Danger    string `json:"danger"`    // danger / alert
	Warning   string `json:"warning"`   // warning / attention
	Success   string `json:"success"`   // success / complete

	// Neutral colors
	Background string `json:"background"` // background
	Foreground string `json:"foreground"` // foreground / text
	Gray       string `json:"gray"`       // medium gray
	LightGray  string `json:"light_gray"` // light gray (secondary text)
	Dim        string `json:"dim"`        // dim gray (dividers)

	// Interactive states
	SelectedBg string `json:"selected_bg"` // selected background
	SelectedFg string `json:"selected_fg"` // selected foreground
	Border     string `json:"border"`      // border color
}

Theme defines a complete color theme

func (*Theme) AccentColor added in v1.0.1

func (t *Theme) AccentColor() lipgloss.Color

func (*Theme) BorderColor added in v1.0.1

func (t *Theme) BorderColor() lipgloss.Color

func (*Theme) DangerColor added in v1.0.1

func (t *Theme) DangerColor() lipgloss.Color

func (*Theme) DimColor added in v1.0.1

func (t *Theme) DimColor() lipgloss.Color

func (*Theme) ForegroundColor added in v1.0.1

func (t *Theme) ForegroundColor() lipgloss.Color

func (*Theme) GrayColor added in v1.0.1

func (t *Theme) GrayColor() lipgloss.Color

func (*Theme) LightGrayColor added in v1.0.1

func (t *Theme) LightGrayColor() lipgloss.Color

func (*Theme) PrimaryColor added in v1.0.1

func (t *Theme) PrimaryColor() lipgloss.Color

Lipgloss colors

func (*Theme) SecondaryColor added in v1.0.1

func (t *Theme) SecondaryColor() lipgloss.Color

func (*Theme) SelectedBgColor added in v1.0.1

func (t *Theme) SelectedBgColor() lipgloss.Color

func (*Theme) SelectedFgColor added in v1.0.1

func (t *Theme) SelectedFgColor() lipgloss.Color

func (*Theme) SuccessColor added in v1.0.1

func (t *Theme) SuccessColor() lipgloss.Color

func (*Theme) WarningColor added in v1.0.1

func (t *Theme) WarningColor() lipgloss.Color

type ThemeChangedMsg added in v1.0.1

type ThemeChangedMsg struct{}

ThemeChangedMsg is sent when the theme changes

type ThemeManager added in v1.0.1

type ThemeManager struct {
	CurrentTheme Theme
	AllThemes    map[string]Theme
	ConfigPath   string
}

ThemeManager manages theme configuration

var GlobalThemeManager *ThemeManager

Global theme manager instance

func NewThemeManager added in v1.0.1

func NewThemeManager() *ThemeManager

NewThemeManager creates a theme manager

func (*ThemeManager) GetThemeNames added in v1.0.1

func (tm *ThemeManager) GetThemeNames() []string

GetThemeNames returns all available theme names (sorted for stable switch order)

func (*ThemeManager) NextTheme added in v1.0.1

func (tm *ThemeManager) NextTheme() string

NextTheme cycles to the next theme

func (*ThemeManager) SetTheme added in v1.0.1

func (tm *ThemeManager) SetTheme(name string) error

SetTheme switches to the specified theme

type ViewType

type ViewType int
const (
	ViewMainMenu ViewType = iota
	ViewSystemJunk
	ViewLargeFiles
	ViewAppUninstaller
	ViewDuplicates
	ViewBrowserData
	ViewDiskTrend
	ViewZombieHunter
)

type ZombieHunterView added in v1.0.2

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

ZombieHunterView shows file access heatmap

func NewZombieHunterView added in v1.0.2

func NewZombieHunterView() *ZombieHunterView

func (*ZombieHunterView) Init added in v1.0.2

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

func (*ZombieHunterView) Update added in v1.0.2

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

func (*ZombieHunterView) View added in v1.0.2

func (m *ZombieHunterView) View() string

Jump to

Keyboard shortcuts

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