terminal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0, BSD-3-Clause, MIT Imports: 7 Imported by: 0

Documentation

Overview

Package terminal provides terminal utilities for all binaries Per AI.md PART 7: BINARY REQUIREMENTS - Common Go Modules

Index

Constants

This section is empty.

Variables

View Source
var ASCIISymbols = Symbols{
	Success: "[OK]",
	Error:   "[ERR]",
	Warning: "[WARN]",
	Info:    "[INFO]",
	Pending: "[...]",

	Spinner:    []string{"|", "/", "-", "\\"},
	ProgressFG: "#",
	ProgressBG: "-",

	BoxTopLeft:     "+",
	BoxTopRight:    "+",
	BoxBottomLeft:  "+",
	BoxBottomRight: "+",
	BoxHorizontal:  "-",
	BoxVertical:    "|",

	ArrowRight: "->",
	ArrowLeft:  "<-",
	ArrowUp:    "^",
	ArrowDown:  "v",

	Bullet:   "*",
	Check:    "[x]",
	Cross:    "[X]",
	Ellipsis: "...",
}

ASCII symbols (fallback for limited terminals)

View Source
var UnicodeSymbols = Symbols{
	Success: "✓",
	Error:   "✗",
	Warning: "⚠",
	Info:    "ℹ",
	Pending: "◌",

	Spinner:    []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"},
	ProgressFG: "█",
	ProgressBG: "░",

	BoxTopLeft:     "┌",
	BoxTopRight:    "┐",
	BoxBottomLeft:  "└",
	BoxBottomRight: "┘",
	BoxHorizontal:  "─",
	BoxVertical:    "│",

	ArrowRight: "→",
	ArrowLeft:  "←",
	ArrowUp:    "↑",
	ArrowDown:  "↓",

	Bullet:   "•",
	Check:    "✓",
	Cross:    "✗",
	Ellipsis: "…",
}

Unicode symbols (modern terminals)

Functions

func IsTerminal

func IsTerminal() bool

IsTerminal returns true if stdout is a terminal

Types

type ResizeHandler

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

ResizeHandler manages terminal resize events

func NewResizeHandler

func NewResizeHandler() *ResizeHandler

NewResizeHandler creates a new resize handler

func (*ResizeHandler) CurrentSize

func (h *ResizeHandler) CurrentSize() Size

CurrentSize returns the current terminal size

func (*ResizeHandler) OnResize

func (h *ResizeHandler) OnResize(callback func(Size))

OnResize registers a callback for resize events

func (*ResizeHandler) Refresh

func (h *ResizeHandler) Refresh()

Refresh manually refreshes the terminal size

func (*ResizeHandler) StartResizeListener

func (h *ResizeHandler) StartResizeListener(ctx context.Context) context.CancelFunc

StartResizeListener starts listening for SIGWINCH signals Returns a cancel function to stop listening

type Size

type Size struct {
	Cols int
	Rows int
	Mode SizeMode
}

Size represents terminal dimensions

func GetSize

func GetSize() Size

GetSize returns the current terminal size

type SizeMode

type SizeMode int

SizeMode represents terminal size breakpoints

const (
	// SizeModeMicro - <40 cols or <10 rows
	SizeModeMicro SizeMode = iota
	// SizeModeMinimal - 40-59 cols or 10-15 rows
	SizeModeMinimal
	// SizeModeCompact - 60-79 cols or 16-23 rows
	SizeModeCompact
	// SizeModeStandard - 80-119 cols and 24-39 rows
	SizeModeStandard
	// SizeModeWide - 120-199 cols and 40-59 rows
	SizeModeWide
	// SizeModeUltrawide - 200-399 cols and 60-79 rows
	SizeModeUltrawide
	// SizeModeMassive - 400+ cols and 80+ rows
	SizeModeMassive
)

func (SizeMode) ShowASCIIArt

func (s SizeMode) ShowASCIIArt() bool

ShowASCIIArt returns true if terminal is large enough for ASCII art

func (SizeMode) ShowBorders

func (s SizeMode) ShowBorders() bool

ShowBorders returns true if terminal supports bordered elements

func (SizeMode) ShowFullInfo

func (s SizeMode) ShowFullInfo() bool

ShowFullInfo returns true if terminal can show full information

func (SizeMode) ShowIcons

func (s SizeMode) ShowIcons() bool

ShowIcons returns true if terminal supports icons/symbols

func (SizeMode) ShowSidebar

func (s SizeMode) ShowSidebar() bool

ShowSidebar returns true if terminal is wide enough for sidebar

func (SizeMode) String

func (s SizeMode) String() string

String returns the string representation of the size mode

type Symbols

type Symbols struct {
	// Status indicators
	Success string
	Error   string
	Warning string
	Info    string
	Pending string

	// Progress
	Spinner    []string
	ProgressFG string
	ProgressBG string

	// Borders
	BoxTopLeft     string
	BoxTopRight    string
	BoxBottomLeft  string
	BoxBottomRight string
	BoxHorizontal  string
	BoxVertical    string

	// Arrows
	ArrowRight string
	ArrowLeft  string
	ArrowUp    string
	ArrowDown  string

	// Misc
	Bullet   string
	Check    string
	Cross    string
	Ellipsis string
}

Symbols provides terminal symbols with Unicode/ASCII fallback

func GetSymbols

func GetSymbols() Symbols

GetSymbols returns the appropriate symbol set based on terminal capabilities

Jump to

Keyboard shortcuts

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