ui

package
v7.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package ui provides shared terminal rendering utilities for the CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearScreen

func ClearScreen(w io.Writer)

ClearScreen clears the terminal and positions the cursor at the top-left corner.

func Dimensions

func Dimensions(w io.Writer, fallbackWidth, fallbackHeight int) (width, height int)

Dimensions attempts to determine the terminal size for the provided writer. If the writer is not backed by an *os.File or the lookup fails, it returns a safe default.

func DisableWrap

func DisableWrap(w io.Writer)

DisableWrap turns off automatic line wrapping.

func Ellipsis

func Ellipsis(s string, maxLen int) string

Ellipsis truncates the provided string to maxLen characters, appending an ellipsis when truncation occurs. For zero or negative lengths it returns an empty string. The function is intentionally ASCII-focused to match existing interactive behavior.

func EnableWrap

func EnableWrap(w io.Writer)

EnableWrap reenables automatic line wrapping.

func HideCursor

func HideCursor(w io.Writer)

HideCursor hides the terminal cursor until ShowCursor is called.

func ShowCursor

func ShowCursor(w io.Writer)

ShowCursor makes the terminal cursor visible.

Types

type ANSIColors

type ANSIColors struct {
	Black   string
	Red     string
	Green   string
	Yellow  string
	Blue    string
	Magenta string
	Cyan    string
	White   string

	BrightBlack   string
	BrightRed     string
	BrightGreen   string
	BrightYellow  string
	BrightBlue    string
	BrightMagenta string
	BrightCyan    string
	BrightWhite   string

	Bold      string
	Underline string
	Reverse   string
	Reset     string
}

ANSIColors defines terminal color escape sequences for both base and bright palettes, plus common text attributes. All fields contain raw ANSI escape codes suitable for writing directly to an io.Writer.

func NewANSIColors

func NewANSIColors() *ANSIColors

NewANSIColors returns a palette initialized with the standard ANSI escape codes.

Jump to

Keyboard shortcuts

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