ui

package
v0.71.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: Apache-2.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ui provides terminal UI helpers for the ToolHive CLI.

Package ui provides shared styling helpers for the ToolHive CLI.

Index

Constants

This section is empty.

Variables

View Source
var (
	ColorGreen  = lipgloss.Color("#9ece6a")
	ColorRed    = lipgloss.Color("#f7768e")
	ColorYellow = lipgloss.Color("#e0af68")
	ColorBlue   = lipgloss.Color("#7aa2f7")
	ColorPurple = lipgloss.Color("#bb9af7")
	ColorCyan   = lipgloss.Color("#7dcfff")
	ColorDim    = lipgloss.Color("#4a5070")
	ColorDim2   = lipgloss.Color("#6272a4")
	ColorText   = lipgloss.Color("#c0caf5")
	// ColorBg is the main TUI background — the same dark tone used by the statusbar.
	ColorBg = lipgloss.Color("#1e2030")
)

Tokyo Night palette

Functions

func PadToWidth added in v0.26.0

func PadToWidth(s string, w int) string

PadToWidth pads s (which may contain ANSI escapes) so its visible width equals w. If s is already wider, it is returned unchanged.

func RenderClientStatusTable

func RenderClientStatusTable(clientStatuses []client.ClientAppStatus) error

RenderClientStatusTable renders the client status table to stdout.

func RenderRegisteredClientsTable added in v0.2.8

func RenderRegisteredClientsTable(registeredClients []RegisteredClient, hasGroups bool) error

RenderRegisteredClientsTable renders the registered clients table to stdout.

func RenderStatusDot added in v0.26.0

func RenderStatusDot(status rt.WorkloadStatus) string

RenderStatusDot returns a colored bullet for the given WorkloadStatus.

func RunClientSetup

func RunClientSetup(
	clients []client.ClientAppStatus,
	availableGroups []*groups.Group,
) ([]client.ClientAppStatus, []string, bool, error)

RunClientSetup runs the interactive client setup and returns the selected clients, groups, and whether the user confirmed.

func VisibleLen added in v0.26.0

func VisibleLen(s string) int

VisibleLen returns the number of visible characters in s, stripping ANSI escape sequences and counting multi-byte UTF-8 codepoints as one character.

Types

type RegisteredClient added in v0.2.8

type RegisteredClient struct {
	Name   string
	Groups []string
}

RegisteredClient represents a registered client with its associated groups

type TUILogHandler added in v0.26.0

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

TUILogHandler is an end-of-pipeline slog.Handler that sends formatted WARN/ERROR records to a channel so the TUI can display them inside the dashboard instead of writing to stderr (which would corrupt the alt-screen rendering).

Because TUILogHandler is a terminal handler (it formats and dispatches records directly rather than delegating to an inner handler), it does not support WithAttrs/WithGroup chaining. Callers must not rely on slog.Logger.With to attach attributes through this handler; any attributes present on a record are inlined in Handle instead.

func NewTUILogHandler added in v0.26.0

func NewTUILogHandler(ch chan<- string, level slog.Level) *TUILogHandler

NewTUILogHandler creates a TUILogHandler that sends records to ch.

func (*TUILogHandler) Enabled added in v0.26.0

func (h *TUILogHandler) Enabled(_ context.Context, level slog.Level) bool

Enabled reports whether the handler handles records at the given level.

func (*TUILogHandler) Handle added in v0.26.0

func (h *TUILogHandler) Handle(_ context.Context, r slog.Record) error

Handle formats and sends a log record to the channel.

func (*TUILogHandler) WithAttrs added in v0.26.0

func (h *TUILogHandler) WithAttrs(_ []slog.Attr) slog.Handler

WithAttrs returns the receiver unchanged. TUILogHandler is an end-of-pipeline handler; pre-bound attributes from slog.Logger.With are silently dropped. See the type doc comment for details.

func (*TUILogHandler) WithGroup added in v0.26.0

func (h *TUILogHandler) WithGroup(_ string) slog.Handler

WithGroup returns the receiver unchanged. TUILogHandler is an end-of-pipeline handler; group scoping from slog.Logger.WithGroup is silently ignored. See the type doc comment for details.

Jump to

Keyboard shortcuts

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