pretty

package module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NamedColors = map[string]Color{

	"black":   Basic(Black),
	"red":     Basic(Red),
	"green":   Basic(Green),
	"yellow":  Basic(Yellow),
	"blue":    Basic(Blue),
	"magenta": Basic(Magenta),
	"cyan":    Basic(Cyan),
	"white":   Basic(White),

	"bright_black":   Basic(BrightBlack),
	"bright_red":     Basic(BrightRed),
	"bright_green":   Basic(BrightGreen),
	"bright_yellow":  Basic(BrightYellow),
	"bright_blue":    Basic(BrightBlue),
	"bright_magenta": Basic(BrightMagenta),
	"bright_cyan":    Basic(BrightCyan),
	"bright_white":   Basic(BrightWhite),

	"orange": RGBColor(255, 165, 0),
	"pink":   RGBColor(255, 192, 203),
	"purple": RGBColor(128, 0, 128),
	"teal":   RGBColor(0, 128, 128),
	"lime":   RGBColor(0, 255, 0),
	"brown":  RGBColor(165, 42, 42),
	"gray":   RGBColor(128, 128, 128),
	"gold":   RGBColor(255, 215, 0),

	"bright_orange": RGBColor(255, 200, 0),
	"bright_pink":   RGBColor(255, 215, 230),
	"bright_purple": RGBColor(180, 0, 180),
	"bright_teal":   RGBColor(0, 200, 200),
	"bright_lime":   RGBColor(128, 255, 128),
	"bright_brown":  RGBColor(210, 105, 30),
	"bright_gray":   RGBColor(180, 180, 180),
	"bright_gold":   RGBColor(255, 235, 128),
}

Functions

This section is empty.

Types

type ANSI256

type ANSI256 uint8

type Align

type Align int
const (
	AlignLeft Align = iota
	AlignCenter
	AlignRight
)

type Basic

type Basic BasicColor

type BasicColor

type BasicColor int
const (
	Black BasicColor = iota
	Red
	Green
	Yellow
	Blue
	Magenta
	Cyan
	White
	BrightBlack
	BrightRed
	BrightGreen
	BrightYellow
	BrightBlue
	BrightMagenta
	BrightCyan
	BrightWhite
)

type Block

type Block struct {
	Segments []Segment
	Align    Align
	Style    Style
}

type Border

type Border struct {
	Chars BorderChars
	Style BorderStyle
}

type BorderChars

type BorderChars struct {
	Horizontal  rune
	Vertical    rune
	TopLeft     rune
	TopRight    rune
	BottomLeft  rune
	BottomRight rune
}

type BorderStyle

type BorderStyle struct {
	Color  Color
	Bold   bool
	Italic bool
}

func (BorderStyle) Base

func (s BorderStyle) Base() Style

type Box

type Box struct {
	Width    int
	SizeMode SizeMode
	MinWidth int

	PaddingX int
	PaddingY int
	MarginX  int
	MarginY  int

	Style  BoxStyle
	Border Border

	Blocks []Block
}

func NewAutoBox

func NewAutoBox() *Box

func NewBox

func NewBox(width int) *Box

func (*Box) AddBlock

func (box *Box) AddBlock(block Block)

func (*Box) Render

func (box *Box) Render() string

type BoxStyle

type BoxStyle struct {
	Background Color
}

func (BoxStyle) Base

func (s BoxStyle) Base() Style

type Color

type Color interface {
	// contains filtered or unexported methods
}

type Inline

type Inline interface {
	Width() int
	Render(base Style) string
}

type InlineSegment

type InlineSegment struct{ Items []Inline }

func (InlineSegment) Render

func (seg InlineSegment) Render(base Style, width int) []string

func (InlineSegment) Width

func (seg InlineSegment) Width() int

type RGB

type RGB struct {
	R, G, B uint8
}

func RGBColor

func RGBColor(r, g, b uint8) RGB

type Segment

type Segment interface {
	Width() int
	Render(base Style, width int) []string
}

type SizeMode

type SizeMode int
const (
	FixedWidth SizeMode = iota
	AutoWidth
)

type Span

type Span struct {
	Text  string
	Style Style
}

func (Span) Render

func (s Span) Render(base Style) string

func (Span) Width

func (s Span) Width() int

type Style

type Style struct {
	Foreground    Color
	Background    Color
	Bold          bool
	Italic        bool
	Underline     bool
	Strikethrough bool
}

func (Style) Combine

func (s1 Style) Combine(s2 Style) Style

type StyledTextBlockSegment added in v0.0.9

type StyledTextBlockSegment struct {
	Raw string
}

func (StyledTextBlockSegment) Render added in v0.0.9

func (s StyledTextBlockSegment) Render(base Style, width int) []string

func (StyledTextBlockSegment) Width added in v0.0.9

func (s StyledTextBlockSegment) Width() int

type TextBlockSegment

type TextBlockSegment struct {
	Text  string
	Style Style
}

func (TextBlockSegment) Render

func (s TextBlockSegment) Render(base Style, width int) []string

func (TextBlockSegment) Width

func (s TextBlockSegment) Width() int

Jump to

Keyboard shortcuts

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