tui

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package tui implements the interactive terminal user interface.

Index

Constants

This section is empty.

Variables

View Source
var (
	ColorGreen  = lipgloss.Color("#00FF00")
	ColorYellow = lipgloss.Color("#FFFF00")
	ColorRed    = lipgloss.Color("#FF0000")
	ColorGray   = lipgloss.Color("#808080")
	ColorBlue   = lipgloss.Color("#0080FF")
	ColorWhite  = lipgloss.Color("#FFFFFF")
	ColorBlack  = lipgloss.Color("#000000")
	ColorDim    = lipgloss.Color("#666666")
)

Colors

View Source
var (
	// Title style for the header
	TitleStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(ColorWhite).
				Background(ColorBlue).
				Padding(0, 1)

	// Subtle title (no background)
	SubtitleStyle = lipgloss.NewStyle().
					Foreground(ColorDim)

	// Border style
	BorderStyle = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(ColorGray)

	// Status bar at the bottom
	StatusBarStyle = lipgloss.NewStyle().
					Background(lipgloss.Color("#333333")).
					Foreground(ColorWhite).
					Padding(0, 1)

	// Help text style
	HelpStyle = lipgloss.NewStyle().
				Foreground(ColorDim)

	// Selected row
	SelectedStyle = lipgloss.NewStyle().
					Background(ColorBlue).
					Foreground(ColorWhite)

	// Normal row
	NormalStyle = lipgloss.NewStyle()

	// Status colors
	StatusRunning  = lipgloss.NewStyle().Foreground(ColorGreen)
	StatusStarting = lipgloss.NewStyle().Foreground(ColorYellow)
	StatusStopped  = lipgloss.NewStyle().Foreground(ColorGray)
	StatusCrashed  = lipgloss.NewStyle().Foreground(ColorRed)

	// Log styles
	LogTimestamp = lipgloss.NewStyle().Foreground(ColorDim)
	LogStdout    = lipgloss.NewStyle().Foreground(ColorWhite)
	LogStderr    = lipgloss.NewStyle().Foreground(ColorRed)

	// Error message
	ErrorStyle = lipgloss.NewStyle().
				Foreground(ColorRed).
				Bold(true)
)

Styles

View Source
var Keys = KeyMap{
	Quit: key.NewBinding(
		key.WithKeys("q", "ctrl+c"),
		key.WithHelp("q", "quit"),
	),
	Help: key.NewBinding(
		key.WithKeys("?"),
		key.WithHelp("?", "help"),
	),
	Up: key.NewBinding(
		key.WithKeys("up", "k"),
		key.WithHelp("↑/k", "up"),
	),
	Down: key.NewBinding(
		key.WithKeys("down", "j"),
		key.WithHelp("↓/j", "down"),
	),
	Start: key.NewBinding(
		key.WithKeys("s"),
		key.WithHelp("s", "start"),
	),
	Stop: key.NewBinding(
		key.WithKeys("x"),
		key.WithHelp("x", "stop"),
	),
	Restart: key.NewBinding(
		key.WithKeys("r"),
		key.WithHelp("r", "restart"),
	),
	StartAll: key.NewBinding(
		key.WithKeys("S"),
		key.WithHelp("S", "start all"),
	),
	StopAll: key.NewBinding(
		key.WithKeys("X"),
		key.WithHelp("X", "stop all"),
	),
	Logs: key.NewBinding(
		key.WithKeys("l", "enter"),
		key.WithHelp("l", "logs"),
	),
	Back: key.NewBinding(
		key.WithKeys("esc", "backspace"),
		key.WithHelp("esc", "back"),
	),
	Kill: key.NewBinding(
		key.WithKeys("K"),
		key.WithHelp("K", "force kill"),
	),
}

Keys contains the default key bindings.

Functions

func GetStatusStyle

func GetStatusStyle(state string) lipgloss.Style

GetStatusStyle returns the appropriate style for a service state.

func Run

func Run(manager *process.Manager) error

Run starts the TUI application.

Types

type ErrorMsg

type ErrorMsg struct {
	Err error
}

ErrorMsg represents an error to display.

func (ErrorMsg) Error

func (e ErrorMsg) Error() string

type KeyMap

type KeyMap struct {
	Quit     key.Binding
	Help     key.Binding
	Up       key.Binding
	Down     key.Binding
	Start    key.Binding
	Stop     key.Binding
	Restart  key.Binding
	StartAll key.Binding
	StopAll  key.Binding
	Logs     key.Binding
	Back     key.Binding
	Kill     key.Binding
}

KeyMap defines all keyboard shortcuts.

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

FullHelp returns key bindings for the full help view.

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

ShortHelp returns key bindings for the short help view.

type Model

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

Model is the main TUI model.

func NewModel

func NewModel(manager *process.Manager) *Model

NewModel creates a new TUI model.

func (*Model) Init

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

Init initializes the model.

func (*Model) Update

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

Update handles messages.

func (*Model) View

func (m *Model) View() string

View renders the UI.

type ServiceEventMsg

type ServiceEventMsg struct {
	Event process.Event
}

ServiceEventMsg wraps a process event for the TUI.

type TickMsg

type TickMsg time.Time

TickMsg is sent periodically to refresh the UI.

type ViewMode

type ViewMode int

ViewMode represents the current view.

const (
	ViewDashboard ViewMode = iota
	ViewLogs
	ViewHelp
)

Jump to

Keyboard shortcuts

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