tui

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Colors
	ColorPrimary   = lipgloss.Color("#6366F1") // Indigo
	ColorSecondary = lipgloss.Color("#3B82F6") // Blue
	ColorSuccess   = lipgloss.Color("#10B981") // Emerald
	ColorWarning   = lipgloss.Color("#F59E0B") // Amber
	ColorDanger    = lipgloss.Color("#EF4444") // Red
	ColorInfo      = lipgloss.Color("#06B6D4") // Cyan
	ColorDarkBg    = lipgloss.Color("#0F172A") // Slate 900
	ColorCardBg    = lipgloss.Color("#1E293B") // Slate 800
	ColorBorder    = lipgloss.Color("#334155") // Slate 700
	ColorText      = lipgloss.Color("#F8FAFC") // Slate 50
	ColorMuted     = lipgloss.Color("#94A3B8") // Slate 400
	ColorHighlight = lipgloss.Color("#8B5CF6") // Purple

	// Text Styles
	TitleStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(ColorText).
				Background(ColorPrimary).
				Padding(0, 1)

	SubTitleStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(ColorInfo)

	MutedStyle = lipgloss.NewStyle().
				Foreground(ColorMuted)

	BoldStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(ColorText)

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

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

	DangerStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(ColorDanger)

	InfoStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(ColorInfo)

	// Card & Container Styles
	CardStyle = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(ColorBorder).
				Background(ColorCardBg).
				Padding(0, 1)

	CardActiveStyle = lipgloss.NewStyle().
					Border(lipgloss.RoundedBorder()).
					BorderForeground(ColorPrimary).
					Background(ColorCardBg).
					Padding(0, 1)

	// Tabs
	TabStyle = lipgloss.NewStyle().
				Foreground(ColorMuted).
				Padding(0, 2)

	ActiveTabStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(ColorText).
					Background(ColorPrimary).
					Padding(0, 2)

	TabGapStyle = lipgloss.NewStyle().
				Foreground(ColorBorder)

	// Badges & Pills
	PassBadge = lipgloss.NewStyle().
				Bold(true).
				Foreground(lipgloss.Color("#064E3B")).
				Background(ColorSuccess).
				Padding(0, 1)

	WarnBadge = lipgloss.NewStyle().
				Bold(true).
				Foreground(lipgloss.Color("#78350F")).
				Background(ColorWarning).
				Padding(0, 1)

	CritBadge = lipgloss.NewStyle().
				Bold(true).
				Foreground(lipgloss.Color("#7F1D1D")).
				Background(ColorDanger).
				Padding(0, 1)

	// Header & Footer
	HeaderStyle = lipgloss.NewStyle().
				Border(lipgloss.NormalBorder(), false, false, true, false).
				BorderForeground(ColorBorder).
				Padding(0, 1).
				MarginBottom(1)

	FooterStyle = lipgloss.NewStyle().
				Border(lipgloss.NormalBorder(), true, false, false, false).
				BorderForeground(ColorBorder).
				Foreground(ColorMuted).
				Padding(0, 1).
				MarginTop(1)

	// Search & Input
	SearchBoxStyle = lipgloss.NewStyle().
					Border(lipgloss.RoundedBorder()).
					BorderForeground(ColorPrimary).
					Padding(0, 1)

	// Table Styles
	TableHeaderStyle = lipgloss.NewStyle().
						Bold(true).
						Foreground(ColorText).
						Border(lipgloss.NormalBorder(), false, false, true, false).
						BorderForeground(ColorBorder)

	TableRowSelectedStyle = lipgloss.NewStyle().
							Bold(true).
							Foreground(ColorText).
							Background(lipgloss.Color("#312E81")) // Indigo 900
)

UI Theme & Palette definitions

View Source
var TabNames = []string{
	"1: Dashboard",
	"2: Processes",
	"3: Diagnostics",
	"4: Alerts",
	"5: Network & Ports",
	"6: Containers",
}

Functions

func FormatBytes

func FormatBytes(b uint64) string

FormatBytes formats byte counts into human-readable strings.

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats duration into readable string.

func FormatRate

func FormatRate(r float64) string

FormatRate formats bytes/sec into readable rate strings.

func RenderProgressBar

func RenderProgressBar(pct float64, width int) string

RenderProgressBar renders an ASCII/Unicode progress bar with custom colors.

func RenderSparkline

func RenderSparkline(values []float64, maxVal float64) string

RenderSparkline creates a mini unicode sparkline string from a slice of floats.

func Run

func Run(
	cfg *config.Config,
	col *collector.Manager,
	store storage.Storage,
	diagEng *diagnostics.Engine,
	alertEng *alerts.Engine,
	anomDet *anomaly.Detector,
) error

Run initializes and executes the interactive Bubbletea TUI application.

func SeverityBadge

func SeverityBadge(sev model.Severity) string

SeverityBadge returns a formatted severity pill.

func StatusBadge

func StatusBadge(status model.DiagnosticStatus) string

StatusBadge returns a formatted status pill.

func TruncateString

func TruncateString(s string, maxLen int) string

TruncateString truncates strings exceeding maxLen.

Types

type DiagResultMsg

type DiagResultMsg *model.DiagnosticReport

type KillResultMsg

type KillResultMsg struct {
	PID int
	Err error
}

type Model

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

func NewModel

func NewModel(
	cfg *config.Config,
	col *collector.Manager,
	store storage.Storage,
	diagEng *diagnostics.Engine,
	alertEng *alerts.Engine,
	anomDet *anomaly.Detector,
) Model

func (Model) Init

func (m Model) Init() tea.Cmd

func (*Model) SetStatus

func (m *Model) SetStatus(msg string, duration time.Duration)

func (Model) Update

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

func (Model) View

func (m Model) View() string

type ProcessSortField

type ProcessSortField int
const (
	SortCPU ProcessSortField = iota
	SortMemory
	SortPID
	SortName
)

type Tab

type Tab int
const (
	TabDashboard Tab = iota
	TabProcesses
	TabDiagnostics
	TabAlerts
	TabNetwork
	TabContainers
)

type TickMsg

type TickMsg time.Time

Jump to

Keyboard shortcuts

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