display

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const BannerLines = 3

BannerLines is the number of terminal rows FprintBanner occupies (leading \n + text + trailing \n\n). Used by watch to position the status line without hardcoding a row number.

Variables

This section is empty.

Functions

func ColorEnabled added in v1.0.5

func ColorEnabled() bool

ColorEnabled reports whether color output is allowed (TTY and NO_COLOR not set).

func ColorHeader added in v1.0.4

func ColorHeader(s string) string

ColorHeader wraps s in bold #FFE866 (gold) when color output is enabled.

func ColorPercent

func ColorPercent(pct float64) string

func CurrencySymbol

func CurrencySymbol(vs string) string

func FormatLargeNumber

func FormatLargeNumber(n float64, vs ...string) string

func FormatPercent

func FormatPercent(pct float64) string

func FormatPrice

func FormatPrice(price float64, vs ...string) string

func FormatRank

func FormatRank(rank int) string

FormatRank formats a market cap rank, returning "-" for zero/unranked.

func FormatSupply

func FormatSupply(n float64) string

func FormatSymbol

func FormatSymbol(s string) string

FormatSymbol sanitizes and uppercases a coin symbol from API data.

func FprintBanner added in v1.0.9

func FprintBanner(w io.Writer)

FprintBanner writes a compact one-line CoinGecko banner to w. Color is determined by the writer's fd (not the global ColorEnabled check), so writing to stdout vs stderr each gets the right color decision.

func PrintBanner

func PrintBanner()

PrintBanner prints a compact one-line CoinGecko banner to stderr. Writing to stderr keeps stdout clean for piped data.

func PrintLogo()

PrintLogo prints the full ASCII art CoinGecko logo in brand green to stderr.

func PrintTable

func PrintTable(headers []string, rows [][]string)

func PrintWelcomeBox

func PrintWelcomeBox()

PrintWelcomeBox prints a bordered quick-start box to stderr.

func SanitizeCell

func SanitizeCell(s string) string

SanitizeCell strips all ANSI escape sequences and non-printable control characters from untrusted API data. Call this on API-sourced strings (names, symbols) before passing to PrintTable. Internal color formatting (e.g. ColorPercent) operates on numeric values and should NOT be sanitized.

func StderrIsTerminal added in v1.0.5

func StderrIsTerminal() bool

StderrIsTerminal reports whether stderr is connected to an interactive terminal.

func StdoutColorEnabled added in v1.0.9

func StdoutColorEnabled() bool

StdoutColorEnabled reports whether color output is appropriate for stdout. Use this instead of ColorEnabled() when writing colored output to stdout (e.g. the watch table), so colors work even when stderr is redirected.

func StdoutIsTerminal added in v1.0.9

func StdoutIsTerminal() bool

StdoutIsTerminal reports whether stdout is connected to an interactive terminal.

func VisibleWidth

func VisibleWidth(s string) int

VisibleWidth returns the display width of a string after stripping ANSI escapes. Uses rune count rather than byte length so multi-byte Unicode (e.g. ▲, ▼, •) is measured as one cell per character.

Types

This section is empty.

Jump to

Keyboard shortcuts

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