render

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Default color scheme with muted professional colors
	DefaultScheme = ColorScheme{
		Success: colorMutedGreen,
		Warning: colorMutedGold,
		Error:   colorMutedRed,
		Info:    colorMutedBlue,
		Dim:     colorMutedGray,
		Accent:  colorMutedPurple,
	}

	// No-color scheme for plain text
	NoColorScheme = ColorScheme{
		Error:   Color{ANSI: ""},
		Warning: Color{ANSI: ""},
		Success: Color{ANSI: ""},
		Info:    Color{ANSI: ""},
		Dim:     Color{ANSI: ""},
		Accent:  Color{ANSI: ""},
	}
)

Predefined colors using 256-color ANSI codes for consistent muted professional palette.

View Source
var (
	// ErrorStyle for error messages
	ErrorStyle = func(text string) string {
		return NewStyle(colorMutedRed).Bold().Apply(text)
	}

	// WarningStyle for warning messages
	WarningStyle = func(text string) string {
		return NewStyle(colorMutedGold).Apply(text)
	}

	// SuccessStyle for success messages
	SuccessStyle = func(text string) string {
		return NewStyle(colorMutedGreen).Apply(text)
	}

	// InfoStyle for informational messages
	InfoStyle = func(text string) string {
		return NewStyle(colorMutedBlue).Apply(text)
	}

	// EmphasisStyle for emphasized text
	EmphasisStyle = func(text string) string {
		return NewStyle(Color{}).Bold().Apply(text)
	}

	// DimStyle for secondary text
	DimStyle = func(text string) string {
		return NewStyle(colorMutedGray).Apply(text)
	}

	// CodeStyle for code/paths
	CodeStyle = func(text string) string {
		return text
	}

	// PathStyle for file paths
	PathStyle = func(text string) string {
		return NewStyle(colorMutedBlue).Apply(text)
	}

	// AccentStyle for accent text
	AccentStyle = func(text string) string {
		return NewStyle(colorMutedPurple).Apply(text)
	}
)

Predefined style functions for common use cases.

Functions

func ShouldUseColor

func ShouldUseColor() bool

ShouldUseColor determines if color output should be enabled.

func WithColor

func WithColor(colorEnabled bool, style StyleFunc, text string) string

WithColor returns styled text if color is enabled, plain text otherwise.

Types

type Color

type Color struct {
	ANSI string
}

Color represents a terminal color.

func (Color) Apply

func (c Color) Apply(text string) string

Apply applies the color to text.

type ColorScheme

type ColorScheme struct {
	Error   Color
	Warning Color
	Success Color
	Info    Color
	Dim     Color
	Accent  Color
}

ColorScheme defines a color palette.

func GetScheme

func GetScheme() ColorScheme

GetScheme returns the appropriate color scheme based on environment.

type Colorizer

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

Colorizer provides semantic color functions for consistent CLI output.

func NewColorizer

func NewColorizer(enabled bool) *Colorizer

NewColorizer creates a colorizer with the appropriate scheme.

func (*Colorizer) Accent

func (c *Colorizer) Accent(text string) string

Accent formats text with accent color (dark blue/purple).

func (*Colorizer) Bold

func (c *Colorizer) Bold(text string) string

Bold formats text with bold styling.

func (*Colorizer) Dim

func (c *Colorizer) Dim(text string) string

Dim formats text with dim color (muted gray).

func (*Colorizer) Error

func (c *Colorizer) Error(text string) string

Error formats text with error color (muted red).

func (*Colorizer) Info

func (c *Colorizer) Info(text string) string

Info formats text with info color (muted blue).

func (*Colorizer) Success

func (c *Colorizer) Success(text string) string

Success formats text with success color (muted green).

func (*Colorizer) Warning

func (c *Colorizer) Warning(text string) string

Warning formats text with warning color (muted gold).

type Layout

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

Layout provides text layout utilities.

func NewLayout

func NewLayout(width int) *Layout

NewLayout creates a layout with the given width.

func NewLayoutAuto

func NewLayoutAuto() *Layout

NewLayoutAuto creates a layout with automatic width detection.

func (*Layout) Box

func (l *Layout) Box(text string, title string) string

Box draws a box around text.

func (*Layout) Center

func (l *Layout) Center(text string) string

Center centers text within the layout width.

func (*Layout) Divider

func (l *Layout) Divider(char string) string

Divider returns a horizontal divider line.

func (*Layout) Indent

func (l *Layout) Indent(text string, level int) string

Indent adds indentation to text.

func (*Layout) List

func (l *Layout) List(items []string, bullet string) string

List formats items as a bulleted list.

func (*Layout) NumberedList

func (l *Layout) NumberedList(items []string) string

NumberedList formats items as a numbered list.

func (*Layout) Table

func (l *Layout) Table(headers []string, rows [][]string) string

Table formats data as a table.

func (*Layout) Width

func (l *Layout) Width() int

Width returns the layout width.

func (*Layout) Wrap

func (l *Layout) Wrap(text string, indent int) string

Wrap wraps text to terminal width.

type Style

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

Style defines terminal styling options.

func NewStyle

func NewStyle(c Color) Style

NewStyle creates a new style with the given color.

func (Style) Apply

func (s Style) Apply(text string) string

Apply applies the style to text.

func (Style) Bold

func (s Style) Bold() Style

Bold returns a style with bold enabled.

func (Style) Underline

func (s Style) Underline() Style

Underline returns a style with underline enabled.

type StyleFunc

type StyleFunc func(string) string

StyleFunc applies styling to text.

Jump to

Keyboard shortcuts

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