icons

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package icons is hawk's centralized icon registry.

Hawk never emits emoji or one-off Unicode glyphs in its CLI/TUI output. Every glyph hawk renders goes through this package. Each glyph has two forms:

  • A Nerd Font PUA (Private Use Area) codepoint (U+E000–U+F8FF). These render as designed icons when the user has any Nerd Font patched font installed (https://www.nerdfonts.com).
  • An ASCII fallback. The default. Used on any terminal that does not have a patched font, when stdout is not a TTY (e.g. CI logs, captured output), or when the user sets HAWK_ICONS=ascii.

No emoji block codepoints (U+1F300–U+1FAFF) and no symbol/dingbat block codepoints (U+2600–U+27BF) are used anywhere. The codepoints defined in this file are verified to be in the Unicode PUA by the audit test in internal/testaudit.

Codepoints are derived from:

Why this and not Lucide SVG?

Lucide (https://lucide.dev) is the project's visual identity for docs
and web surfaces (see docs/architecture.md). It is an SVG-only icon
set — there is no standard PUA mapping for Lucide in Nerd Fonts, so
the icon shapes cannot be rendered in a plain terminal. The two
realistic options are (a) build and ship a custom Nerd Font that
embeds a Lucide subset (large infrastructure dependency, no
toolchain in CI), or (b) render Lucide SVGs as Unicode block art at
print time (slow, error-prone, breaks captured output). The Go-CLI
ecosystem (charmbracelet, spf13/cobra, github/cli, k9s) uses the
PUA-or-ASCII approach we have here; the surveys of those projects
are recorded in scripts/ICONICONSURVEY.md. The 0-emoji audit in
internal/testaudit enforces that policy going forward.

Index

Constants

View Source
const (
	ASCIIPrompt        = ">"
	ASCIIRobot         = "*"
	ASCIICircleFilled  = "*"
	ASCIICircleOutline = "."
	ASCIIAlert         = "!"
	ASCIICheck         = "+"
	ASCIICross         = "x"
	ASCIIBallotX       = "x"
	ASCIIBlock         = "#"
	ASCIIReturn        = "<-"
	ASCIIArrowRight    = "->"
	ASCIIArrowLeft     = "<-"
	ASCIIArrowUp       = "^"
	ASCIIArrowDown     = "v"
	ASCIISwap          = "<->"
	ASCIITimer         = "[t]"
	ASCIIReload        = "[r]"
	ASCIIStop          = "[x]"
	ASCIIBell          = "[!]"
	ASCIICheckDecagram = "[ok]"
	ASCIIAlertOctagram = "[!!]"
	ASCIICancel        = "[x]"
	ASCIIFile          = "[f]"
	ASCIIQuestion      = "?"
	ASCIIMail          = "[m]"
	ASCIIRefresh       = "[r]"
	ASCIIHourglass     = "[..]"
	ASCIICheckCircle   = "[ok]"
	ASCIICloseCircle   = "[x]"
	ASCIIImage         = "[img]"
	ASCIIFileDocument  = "[doc]"
	ASCIIKey           = "[key]"
	ASCIICog           = "[*]"
	ASCIIMagnify       = "/"
	ASCIIBolt          = "!"
	ASCIIBrain         = "[think]"
	ASCIIEmail         = "[m]"
	ASCIIHelpCircle    = "?"
	ASCIIBranch        = "(|)"
	ASCIIClockOutline  = "[t]"
	ASCIIPause         = "[||]"
	ASCIIExpandAll     = "[+]"
	ASCIICaretRight    = ">"
	ASCIICaretDown     = "v"
	ASCIITriangleSmall = ">"
	ASCIICircleHalf    = "o"
	ASCIICircleQuarter = "."
	ASCIICircleSlice5  = "."
	ASCIICircleSlice6  = "."
	ASCIIRotateVariant = "[r]"
	ASCIILlama         = "[ollama]"
)

ASCII fallback strings. Every glyph in the registry has one. Defaults are single ASCII runes or short bracketed tokens ("[ok]", "[!!]") for state indicators that need more visibility than a single character.

Variables

This section is empty.

Functions

func ASCII

func ASCII(name string) string

ASCII returns the ASCII fallback for the given name regardless of the active mode. Use this in:

  • golden-file tests (stable byte-for-byte expected output)
  • log lines that may be shipped to a non-tty destination later
  • the TUI when it detects it is being rendered to a captured file

func Alert

func Alert() string

func AlertOctagram

func AlertOctagram() string

func ArrowDown

func ArrowDown() string

func ArrowLeft

func ArrowLeft() string

func ArrowRight

func ArrowRight() string

func ArrowUp

func ArrowUp() string

func BallotX

func BallotX() string

func Bell

func Bell() string

func Block

func Block() string

func Bolt

func Bolt() string

func Brain

func Brain() string

func Branch

func Branch() string

func Cancel

func Cancel() string

func CaretDown

func CaretDown() string

func CaretRight

func CaretRight() string

func Check

func Check() string

func CheckBold

func CheckBold() string

func CheckCircle

func CheckCircle() string

func CheckDecagram

func CheckDecagram() string

func ChevronRight

func ChevronRight() string

func CircleFilled

func CircleFilled() string

func CircleHalf

func CircleHalf() string

func CircleOutline

func CircleOutline() string

func CircleQuarter

func CircleQuarter() string

func CircleSlice5

func CircleSlice5() string

func CircleSlice6

func CircleSlice6() string

func ClockOutline

func ClockOutline() string

func Close

func Close() string

func CloseCircle

func CloseCircle() string

func CloseThick

func CloseThick() string

func Cog

func Cog() string

func Email

func Email() string

func ExpandAll

func ExpandAll() string

func File

func File() string

func FileDocument

func FileDocument() string

func Glyph

func Glyph(name string) string

Glyph returns the active-mode glyph for the given name. Panics on unknown names — that is a programmer error, not a runtime condition.

func HelpCircle

func HelpCircle() string

func Hourglass

func Hourglass() string

func Image

func Image() string

func Key

func Key() string

func Llama

func Llama() string

func Magnify

func Magnify() string

func Mail

func Mail() string

func Names

func Names() []string

Names returns all registered glyph names in display order.

func Nerd

func Nerd(name string) string

Nerd returns the Nerd Font PUA form for the given name regardless of the active mode. Used by the harness command's "icons" section.

func Pause

func Pause() string

func Pin

func Pin() string

func Question

func Question() string

func Refresh

func Refresh() string

func Reload

func Reload() string

func Return

func Return() string

func Robot

func Robot() string

func RotateVariant

func RotateVariant() string

func SetMode

func SetMode(m IconMode)

SetMode overrides detection. Pass ModeAuto to re-enable detection on the next Mode() call. Tests use this to pin behaviour.

func Stop

func Stop() string

func Swap

func Swap() string

func Timer

func Timer() string

func TriangleSmall

func TriangleSmall() string

Types

type IconMode

type IconMode int32

Mode selects which glyph set the icons package returns.

const (
	// ModeAuto is resolved lazily by Mode() on first call.
	ModeAuto IconMode = iota
	// ModeASCII forces every glyph to its ASCII fallback.
	ModeASCII
	// ModeNerd forces every glyph to its Nerd Font PUA codepoint.
	ModeNerd
)

func Mode

func Mode() IconMode

Mode returns the active rendering mode. On first call, resolves ModeAuto from env vars. Subsequent calls return the cached value unless SetMode is used.

Resolution is conservative: ASCII is the default; Nerd Font is enabled only when env markers explicitly indicate a patched terminal is in use AND stdout is a TTY.

Precedence:

  1. HAWK_ICONS=nerd|ascii → ModeNerd / ModeASCII
  2. NO_COLOR set → ModeASCII
  3. !stdoutIsTTY() → ModeASCII (piped output stays clean)
  4. TERM / TERM_PROGRAM / LC_TERMINAL matches a known Nerd-Font-friendly terminal → ModeNerd
  5. LANG / LC_ALL / LC_CTYPE contains "UTF-8" → ModeNerd
  6. otherwise → ModeASCII

func (IconMode) String

func (m IconMode) String() string

Jump to

Keyboard shortcuts

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