tui

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package tui provides terminal UI helpers.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ColorAccent is the brand mint used for titles, active items, and progress fills.
	ColorAccent = lipgloss.Color("#5FBE9E")
	// ColorPrimary is the default body-text color on dark terminals.
	ColorPrimary = lipgloss.Color("#C9D1D9")
	// ColorMuted is the dimmed gray used for help text and secondary info.
	// Kept readable on dark terminals (Ghostty, etc.) — clearly subordinate to
	// ColorPrimary but not so dim it disappears.
	ColorMuted = lipgloss.Color("#8a929b")
	// ColorDark is the near-black used as foreground when sitting on top of ColorAccent.
	ColorDark = lipgloss.Color("#0B1411")
	// ColorSurface is the dark gray used as a filler/background for unfilled regions.
	ColorSurface = lipgloss.Color("#30363D")
)

Shared color palette for ds4go TUI components. All hex colors used by the CLI live here so the theme stays consistent across pickers, prompts, and progress rendering.

View Source
var (
	TitleStyle   = lipgloss.NewStyle().Bold(true).Foreground(ColorAccent)
	ActiveStyle  = lipgloss.NewStyle().Bold(true).Foreground(ColorAccent)
	PrimaryStyle = lipgloss.NewStyle().Foreground(ColorPrimary)
	MutedStyle   = lipgloss.NewStyle().Foreground(ColorMuted)

	// SelectedStyle renders a filled "chip" — dark text on accent background —
	// so the focused option is immediately obvious even on low-contrast terminals.
	SelectedStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(ColorDark).
					Background(ColorAccent).
					Padding(0, 2)

	// UnselectedBox keeps the same width/padding as SelectedStyle so toggling
	// between options doesn't cause layout shift.
	UnselectedBox = lipgloss.NewStyle().
					Foreground(ColorPrimary).
					Padding(0, 2)

	// ProgressDone is the filled portion of a progress bar.
	ProgressDone = lipgloss.NewStyle().Bold(true).Foreground(ColorDark).Background(ColorAccent)
	// ProgressRest is the unfilled portion of a progress bar.
	ProgressRest = lipgloss.NewStyle().Foreground(ColorPrimary).Background(ColorSurface)
)

Shared styles. Define once here so pickers, confirms, progress bars, and any future components stay visually consistent.

Functions

func FormatModelBytes added in v0.4.0

func FormatModelBytes(n int64) string

FormatModelBytes formats a byte count into a human-readable string (e.g. "3.5 GiB").

func FormatPartialModel added in v0.4.0

func FormatPartialModel(partialBytes int64, sizeGiB float64) string

FormatPartialModel formats the download progress of a partially downloaded model.

func ModelFlags added in v0.4.0

func ModelFlags(model models.Model) string

ModelFlags returns a comma-separated string of flags/attributes for a model.

func PickModelAlias added in v0.4.0

func PickModelAlias(title string, list []models.Model, in io.Reader, out io.Writer) (string, error)

PickModelAlias launches a TUI picker to let the user select a model from the list.

Types

type ConfirmResult

type ConfirmResult int
const (
	ConfirmYes ConfirmResult = iota
	ConfirmNo
	ConfirmCancelled
)

func Confirm

func Confirm(prompt string, defaultYes bool, in io.Reader, out io.Writer) (ConfirmResult, error)

Confirm displays a Yes/No dialog and returns the user's selection. defaultYes sets which button is initially highlighted. If in or out are nil, the default tea program I/O (stdin/stdout) is used.

Jump to

Keyboard shortcuts

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