Help us shape the future of Go! Take the 2026 Go Developer Survey

ui

package
v0.0.0-...-caf1669 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package ui draws a snapshot. Render is pure: same snapshot, same text. Every line fits Options.Width, truncated with "…", never wrapped. A line is a list of coloured spans; width is counted on the plain text, so escape codes never push a line past the terminal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatAge

func FormatAge(d time.Duration) string

FormatAge: 8s · 12m · 2h06m · 1d17h.

func FormatBytes

func FormatBytes(b int64) string

FormatBytes takes bytes.

func FormatMemory

func FormatMemory(kb int64) string

FormatMemory takes kilobytes: "512 MB", "2.5 GB".

func Render

func Render(s agent.Snapshot, o Options) string

Render draws one screenful.

func Spread

func Spread(left, right string, w int) string

Spread puts right flush to the edge; left gives way first.

func Truncate

func Truncate(s string, w int) string

Truncate cuts s to w runes, ending in "…".

Types

type App

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

App is the live screen: collect on a tick, render, scroll.

func NewApp

func NewApp(collect func() agent.Snapshot, interval time.Duration, color bool, home string) App

func (App) Init

func (a App) Init() tea.Cmd

Init dispatches refresh() without setting collecting (Init can't change the model). The worst case is one overlapping collect at start-up, which is harmless.

func (App) Update

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

func (App) View

func (a App) View() string

type Options

type Options struct {
	Width  int
	Now    time.Time
	Color  bool
	Footer bool
	Home   string // shown as ~
}

Options controls one render.

Jump to

Keyboard shortcuts

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