tui

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	White = lipgloss.Color("#fff")
	Black = lipgloss.Color("#000")

	Blue      = lipgloss.Color("#0D6EFD")
	Blue100   = lipgloss.Color("#CFE2FF")
	Blue200   = lipgloss.Color("#9EC5FE")
	Blue300   = lipgloss.Color("#6EA8FE")
	Blue400   = lipgloss.Color("#3D8BFD")
	Blue500   = lipgloss.Color("#0D6EFD")
	Blue600   = lipgloss.Color("#0A58CA")
	Blue700   = lipgloss.Color("#084298")
	Blue800   = lipgloss.Color("#052C65")
	Blue900   = lipgloss.Color("#031633")
	Indigo    = lipgloss.Color("#6610F2")
	Indigo100 = lipgloss.Color("#E0CFFC")
	Indigo200 = lipgloss.Color("#C29FFA")
	Indigo300 = lipgloss.Color("#A370F7")
	Indigo400 = lipgloss.Color("#8540F5")
	Indigo500 = lipgloss.Color("#6610F2")
	Indigo600 = lipgloss.Color("#520DC2")
	Indigo700 = lipgloss.Color("#3D0A91")
	Indigo800 = lipgloss.Color("#290661")
	Indigo900 = lipgloss.Color("#140330")
	Purple    = lipgloss.Color("#6F42C1")
	Purple100 = lipgloss.Color("#E2D9F3")
	Purple200 = lipgloss.Color("#C5B3E6")
	Purple300 = lipgloss.Color("#A98EDA")
	Purple400 = lipgloss.Color("#8C68CD")
	Purple500 = lipgloss.Color("#6F42C1")
	Purple600 = lipgloss.Color("#59359A")
	Purple700 = lipgloss.Color("#432874")
	Purple800 = lipgloss.Color("#2C1A4D")
	Purple900 = lipgloss.Color("#160D27")
	Pink      = lipgloss.Color("#D63384")
	Pink100   = lipgloss.Color("#F7D6E6")
	Pink200   = lipgloss.Color("#EFADCE")
	Pink300   = lipgloss.Color("#E685B5")
	Pink400   = lipgloss.Color("#DE5C9D")
	Pink500   = lipgloss.Color("#D63384")
	Pink600   = lipgloss.Color("#AB296A")
	Pink700   = lipgloss.Color("#801F4F")
	Pink800   = lipgloss.Color("#561435")
	Pink900   = lipgloss.Color("#2B0A1A")
	Red       = lipgloss.Color("#DC3545")
	Red100    = lipgloss.Color("#F8D7DA")
	Red200    = lipgloss.Color("#F1AEB5")
	Red300    = lipgloss.Color("#EA868F")
	Red400    = lipgloss.Color("#E35D6A")
	Red500    = lipgloss.Color("#DC3545")
	Red600    = lipgloss.Color("#B02A37")
	Red700    = lipgloss.Color("#842029")
	Red800    = lipgloss.Color("#58151C")
	Red900    = lipgloss.Color("#2C0B0E")
	Orange    = lipgloss.Color("#FD7E14")
	Orange100 = lipgloss.Color("#FFE5D0")
	Orange200 = lipgloss.Color("#FECBA1")
	Orange300 = lipgloss.Color("#FEB272")
	Orange400 = lipgloss.Color("#FD9843")
	Orange500 = lipgloss.Color("#FD7E14")
	Orange600 = lipgloss.Color("#CA6510")
	Orange700 = lipgloss.Color("#984C0C")
	Orange800 = lipgloss.Color("#653208")
	Orange900 = lipgloss.Color("#331904")
	Yellow    = lipgloss.Color("#FFC107")
	Yellow100 = lipgloss.Color("#FFF3CD")
	Yellow200 = lipgloss.Color("#FFE69C")
	Yellow300 = lipgloss.Color("#FFDA6A")
	Yellow400 = lipgloss.Color("#FFCD39")
	Yellow500 = lipgloss.Color("#FFC107")
	Yellow600 = lipgloss.Color("#CC9A06")
	Yellow700 = lipgloss.Color("#997404")
	Yellow800 = lipgloss.Color("#664D03")
	Yellow900 = lipgloss.Color("#332701")
	Green     = lipgloss.Color("#198754")
	Green100  = lipgloss.Color("#D1E7DD")
	Green200  = lipgloss.Color("#A3CFBB")
	Green300  = lipgloss.Color("#75B798")
	Green400  = lipgloss.Color("#479F76")
	Green500  = lipgloss.Color("#198754")
	Green600  = lipgloss.Color("#146C43")
	Green700  = lipgloss.Color("#0F5132")
	Green800  = lipgloss.Color("#0A3622")
	Green900  = lipgloss.Color("#051B11")
	Teal      = lipgloss.Color("#20C997")
	Teal100   = lipgloss.Color("#D2F4EA")
	Teal200   = lipgloss.Color("#A6E9D5")
	Teal300   = lipgloss.Color("#79DFC1")
	Teal400   = lipgloss.Color("#4DD4AC")
	Teal500   = lipgloss.Color("#20C997")
	Teal600   = lipgloss.Color("#1AA179")
	Teal700   = lipgloss.Color("#13795B")
	Teal800   = lipgloss.Color("#0D503C")
	Teal900   = lipgloss.Color("#06281E")
	Cyan      = lipgloss.Color("#0DCAF0")
	Cyan100   = lipgloss.Color("#CFF4FC")
	Cyan200   = lipgloss.Color("#9EEAF9")
	Cyan300   = lipgloss.Color("#6EDFF6")
	Cyan400   = lipgloss.Color("#3DD5F3")
	Cyan500   = lipgloss.Color("#0DCAF0")
	Cyan600   = lipgloss.Color("#0AA2C0")
	Cyan700   = lipgloss.Color("#087990")
	Cyan800   = lipgloss.Color("#055160")
	Cyan900   = lipgloss.Color("#032830")
	Gray      = lipgloss.Color("#ADB5BD")
	Gray100   = lipgloss.Color("#EFF0F2")
	Gray200   = lipgloss.Color("#DEE1E5")
	Gray300   = lipgloss.Color("#CED3D7")
	Gray400   = lipgloss.Color("#BDC4CA")
	Gray500   = lipgloss.Color("#ADB5BD")
	Gray600   = lipgloss.Color("#8A9197")
	Gray700   = lipgloss.Color("#686D71")
	Gray800   = lipgloss.Color("#45484C")
	Gray900   = lipgloss.Color("#232426")
)

Variables

View Source
var (
	BlueFamily = []ColorPair{
		{
			Name:  "Blue100",
			Value: Blue100,
		},
		{
			Name:  "Blue200",
			Value: Blue200,
		},
		{
			Name:  "Blue300",
			Value: Blue300,
		},
		{
			Name:  "Blue400",
			Value: Blue400,
		},
		{
			Name:  "Blue500",
			Value: Blue500,
		},
		{
			Name:  "Blue600",
			Value: Blue600,
		},
		{
			Name:  "Blue700",
			Value: Blue700,
		},
		{
			Name:  "Blue800",
			Value: Blue800,
		},
		{
			Name:  "Blue900",
			Value: Blue900,
		},
	}
	IndigoFamily = []ColorPair{
		{
			Name:  "Indigo100",
			Value: Indigo100,
		},
		{
			Name:  "Indigo200",
			Value: Indigo200,
		},
		{
			Name:  "Indigo300",
			Value: Indigo300,
		},
		{
			Name:  "Indigo400",
			Value: Indigo400,
		},
		{
			Name:  "Indigo500",
			Value: Indigo500,
		},
		{
			Name:  "Indigo600",
			Value: Indigo600,
		},
		{
			Name:  "Indigo700",
			Value: Indigo700,
		},
		{
			Name:  "Indigo800",
			Value: Indigo800,
		},
		{
			Name:  "Indigo900",
			Value: Indigo900,
		},
	}
	PurpleFamily = []ColorPair{
		{
			Name:  "Purple100",
			Value: Purple100,
		},
		{
			Name:  "Purple200",
			Value: Purple200,
		},
		{
			Name:  "Purple300",
			Value: Purple300,
		},
		{
			Name:  "Purple400",
			Value: Purple400,
		},
		{
			Name:  "Purple500",
			Value: Purple500,
		},
		{
			Name:  "Purple600",
			Value: Purple600,
		},
		{
			Name:  "Purple700",
			Value: Purple700,
		},
		{
			Name:  "Purple800",
			Value: Purple800,
		},
		{
			Name:  "Purple900",
			Value: Purple900,
		},
	}
	PinkFamily = []ColorPair{
		{
			Name:  "Pink100",
			Value: Pink100,
		},
		{
			Name:  "Pink200",
			Value: Pink200,
		},
		{
			Name:  "Pink300",
			Value: Pink300,
		},
		{
			Name:  "Pink400",
			Value: Pink400,
		},
		{
			Name:  "Pink500",
			Value: Pink500,
		},
		{
			Name:  "Pink600",
			Value: Pink600,
		},
		{
			Name:  "Pink700",
			Value: Pink700,
		},
		{
			Name:  "Pink800",
			Value: Pink800,
		},
		{
			Name:  "Pink900",
			Value: Pink900,
		},
	}
	RedFamily = []ColorPair{
		{
			Name:  "Red100",
			Value: Red100,
		},
		{
			Name:  "Red200",
			Value: Red200,
		},
		{
			Name:  "Red300",
			Value: Red300,
		},
		{
			Name:  "Red400",
			Value: Red400,
		},
		{
			Name:  "Red500",
			Value: Red500,
		},
		{
			Name:  "Red600",
			Value: Red600,
		},
		{
			Name:  "Red700",
			Value: Red700,
		},
		{
			Name:  "Red800",
			Value: Red800,
		},
		{
			Name:  "Red900",
			Value: Red900,
		},
	}
	OrangeFamily = []ColorPair{
		{
			Name:  "Orange100",
			Value: Orange100,
		},
		{
			Name:  "Orange200",
			Value: Orange200,
		},
		{
			Name:  "Orange300",
			Value: Orange300,
		},
		{
			Name:  "Orange400",
			Value: Orange400,
		},
		{
			Name:  "Orange500",
			Value: Orange500,
		},
		{
			Name:  "Orange600",
			Value: Orange600,
		},
		{
			Name:  "Orange700",
			Value: Orange700,
		},
		{
			Name:  "Orange800",
			Value: Orange800,
		},
		{
			Name:  "Orange900",
			Value: Orange900,
		},
	}
	YellowFamily = []ColorPair{
		{
			Name:  "Yellow100",
			Value: Yellow100,
		},
		{
			Name:  "Yellow200",
			Value: Yellow200,
		},
		{
			Name:  "Yellow300",
			Value: Yellow300,
		},
		{
			Name:  "Yellow400",
			Value: Yellow400,
		},
		{
			Name:  "Yellow500",
			Value: Yellow500,
		},
		{
			Name:  "Yellow600",
			Value: Yellow600,
		},
		{
			Name:  "Yellow700",
			Value: Yellow700,
		},
		{
			Name:  "Yellow800",
			Value: Yellow800,
		},
		{
			Name:  "Yellow900",
			Value: Yellow900,
		},
	}
	GreenFamily = []ColorPair{
		{
			Name:  "Green100",
			Value: Green100,
		},
		{
			Name:  "Green200",
			Value: Green200,
		},
		{
			Name:  "Green300",
			Value: Green300,
		},
		{
			Name:  "Green400",
			Value: Green400,
		},
		{
			Name:  "Green500",
			Value: Green500,
		},
		{
			Name:  "Green600",
			Value: Green600,
		},
		{
			Name:  "Green700",
			Value: Green700,
		},
		{
			Name:  "Green800",
			Value: Green800,
		},
		{
			Name:  "Green900",
			Value: Green900,
		},
	}
	TealFamily = []ColorPair{
		{
			Name:  "Teal100",
			Value: Teal100,
		},
		{
			Name:  "Teal200",
			Value: Teal200,
		},
		{
			Name:  "Teal300",
			Value: Teal300,
		},
		{
			Name:  "Teal400",
			Value: Teal400,
		},
		{
			Name:  "Teal500",
			Value: Teal500,
		},
		{
			Name:  "Teal600",
			Value: Teal600,
		},
		{
			Name:  "Teal700",
			Value: Teal700,
		},
		{
			Name:  "Teal800",
			Value: Teal800,
		},
		{
			Name:  "Teal900",
			Value: Teal900,
		},
	}
	CyanFamily = []ColorPair{
		{
			Name:  "Cyan100",
			Value: Cyan100,
		},
		{
			Name:  "Cyan200",
			Value: Cyan200,
		},
		{
			Name:  "Cyan300",
			Value: Cyan300,
		},
		{
			Name:  "Cyan400",
			Value: Cyan400,
		},
		{
			Name:  "Cyan500",
			Value: Cyan500,
		},
		{
			Name:  "Cyan600",
			Value: Cyan600,
		},
		{
			Name:  "Cyan700",
			Value: Cyan700,
		},
		{
			Name:  "Cyan800",
			Value: Cyan800,
		},
		{
			Name:  "Cyan900",
			Value: Cyan900,
		},
	}
	GrayFamily = []ColorPair{
		{
			Name:  "Gray100",
			Value: Gray100,
		},
		{
			Name:  "Gray200",
			Value: Gray200,
		},
		{
			Name:  "Gray300",
			Value: Gray300,
		},
		{
			Name:  "Gray400",
			Value: Gray400,
		},
		{
			Name:  "Gray500",
			Value: Gray500,
		},
		{
			Name:  "Gray600",
			Value: Gray600,
		},
		{
			Name:  "Gray700",
			Value: Gray700,
		},
		{
			Name:  "Gray800",
			Value: Gray800,
		},
		{
			Name:  "Gray900",
			Value: Gray900,
		},
	}

	ColorsFamilies = []string{
		"Blue",
		"Indigo",
		"Purple",
		"Pink",
		"Red",
		"Orange",
		"Yellow",
		"Green",
		"Teal",
		"Cyan",
		"Gray",
	}

	// All colors, grouped by their family
	ColorsByFamily = map[string][]ColorPair{
		"Blue":   BlueFamily,
		"Indigo": IndigoFamily,
		"Purple": PurpleFamily,
		"Pink":   PinkFamily,
		"Red":    RedFamily,
		"Orange": OrangeFamily,
		"Yellow": YellowFamily,
		"Green":  GreenFamily,
		"Teal":   TealFamily,
		"Cyan":   CyanFamily,
		"Gray":   GrayFamily,
	}

	// All known colors in a map to easily look up their name to value
	AllColors = map[string]lipgloss.Color{
		"Blue100":   Blue100,
		"Blue200":   Blue200,
		"Blue300":   Blue300,
		"Blue400":   Blue400,
		"Blue500":   Blue500,
		"Blue600":   Blue600,
		"Blue700":   Blue700,
		"Blue800":   Blue800,
		"Blue900":   Blue900,
		"Indigo100": Indigo100,
		"Indigo200": Indigo200,
		"Indigo300": Indigo300,
		"Indigo400": Indigo400,
		"Indigo500": Indigo500,
		"Indigo600": Indigo600,
		"Indigo700": Indigo700,
		"Indigo800": Indigo800,
		"Indigo900": Indigo900,
		"Purple100": Purple100,
		"Purple200": Purple200,
		"Purple300": Purple300,
		"Purple400": Purple400,
		"Purple500": Purple500,
		"Purple600": Purple600,
		"Purple700": Purple700,
		"Purple800": Purple800,
		"Purple900": Purple900,
		"Pink100":   Pink100,
		"Pink200":   Pink200,
		"Pink300":   Pink300,
		"Pink400":   Pink400,
		"Pink500":   Pink500,
		"Pink600":   Pink600,
		"Pink700":   Pink700,
		"Pink800":   Pink800,
		"Pink900":   Pink900,
		"Red100":    Red100,
		"Red200":    Red200,
		"Red300":    Red300,
		"Red400":    Red400,
		"Red500":    Red500,
		"Red600":    Red600,
		"Red700":    Red700,
		"Red800":    Red800,
		"Red900":    Red900,
		"Orange100": Orange100,
		"Orange200": Orange200,
		"Orange300": Orange300,
		"Orange400": Orange400,
		"Orange500": Orange500,
		"Orange600": Orange600,
		"Orange700": Orange700,
		"Orange800": Orange800,
		"Orange900": Orange900,
		"Yellow100": Yellow100,
		"Yellow200": Yellow200,
		"Yellow300": Yellow300,
		"Yellow400": Yellow400,
		"Yellow500": Yellow500,
		"Yellow600": Yellow600,
		"Yellow700": Yellow700,
		"Yellow800": Yellow800,
		"Yellow900": Yellow900,
		"Green100":  Green100,
		"Green200":  Green200,
		"Green300":  Green300,
		"Green400":  Green400,
		"Green500":  Green500,
		"Green600":  Green600,
		"Green700":  Green700,
		"Green800":  Green800,
		"Green900":  Green900,
		"Teal100":   Teal100,
		"Teal200":   Teal200,
		"Teal300":   Teal300,
		"Teal400":   Teal400,
		"Teal500":   Teal500,
		"Teal600":   Teal600,
		"Teal700":   Teal700,
		"Teal800":   Teal800,
		"Teal900":   Teal900,
		"Cyan100":   Cyan100,
		"Cyan200":   Cyan200,
		"Cyan300":   Cyan300,
		"Cyan400":   Cyan400,
		"Cyan500":   Cyan500,
		"Cyan600":   Cyan600,
		"Cyan700":   Cyan700,
		"Cyan800":   Cyan800,
		"Cyan900":   Cyan900,
		"Gray100":   Gray100,
		"Gray200":   Gray200,
		"Gray300":   Gray300,
		"Gray400":   Gray400,
		"Gray500":   Gray500,
		"Gray600":   Gray600,
		"Gray700":   Gray700,
		"Gray800":   Gray800,
		"Gray900":   Gray900,
	}
)
View Source
var AlphaMap = map[int]string{}/* 101 elements not displayed */
View Source
var Bold = func(s *lipgloss.Style) {
	s.Bold(true)
}

Functions

func ColorToHex

func ColorToHex(in lipgloss.Color) string

func MixColors

func MixColors(a, b string, weight float64) lipgloss.Color

func Renderer

func Renderer(w io.Writer, opts ...termenv.OutputOption) *lipgloss.Renderer

func RendererWithTTY

func RendererWithTTY(w io.Writer, opts ...termenv.OutputOption) *lipgloss.Renderer

func ShadeColor

func ShadeColor(in string, percent float64) lipgloss.Color

func TintColor

func TintColor(in string, percent float64) lipgloss.Color

Types

type Box

type Box struct {
	Header lipgloss.Style
	Body   lipgloss.Style
}

func (Box) Copy

func (b Box) Copy() Box

type Color

type Color struct {
	Text         lipgloss.AdaptiveColor
	TextEmphasis lipgloss.AdaptiveColor
	Background   lipgloss.AdaptiveColor
	Border       lipgloss.AdaptiveColor
}

func NewColor

func NewColor(config ColorConfig) Color

func (Color) BoxStyles

func (c Color) BoxStyles(header, body lipgloss.Style) Box

func (Color) BuffPrinter added in v0.2.0

func (c Color) BuffPrinter(w io.Writer, options ...PrinterOption) Print

func (Color) Printer

func (c Color) Printer(renderer *lipgloss.Renderer, options ...PrinterOption) Print

func (Color) StderrPrinter

func (c Color) StderrPrinter(options ...PrinterOption) Print

func (Color) StdoutPrinter added in v0.6.0

func (c Color) StdoutPrinter(options ...PrinterOption) Print

func (Color) TextEmphasisStyle

func (c Color) TextEmphasisStyle(style lipgloss.Style) lipgloss.Style

func (Color) TextStyle

func (c Color) TextStyle(style lipgloss.Style) lipgloss.Style

type ColorConfig

type ColorConfig struct {
	Text         ComponentColor
	TextEmphasis ComponentColor
	Background   ComponentColor
	Border       ComponentColor
}

func NewColorComponentConfig

func NewColorComponentConfig(baseColor lipgloss.Color) ColorConfig

type ColorPair

type ColorPair struct {
	Name  string
	Value lipgloss.Color
}

type ComponentColor

type ComponentColor struct {
	Light ComponentColorConfig
	Dark  ComponentColorConfig
}

func (ComponentColor) AdaptiveColor

func (cc ComponentColor) AdaptiveColor() lipgloss.AdaptiveColor

type ComponentColorConfig

type ComponentColorConfig struct {
	Color    string
	MixColor string
	Filter   string
	Percent  float64
}

func (ComponentColorConfig) AsHex

func (ccc ComponentColorConfig) AsHex() string

type Print

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

func NewPrinter

func NewPrinter(color Color, renderer *lipgloss.Renderer, options ...PrinterOption) Print

func (Print) ApplyStyle

func (p Print) ApplyStyle(callback StyleChanger) Print

func (Print) Box

func (p Print) Box(header string, bodies ...string)

func (Print) Copy

func (p Print) Copy(options ...PrinterOption) Print

func (Print) Fprint

func (p Print) Fprint(w io.Writer, a ...any) (n int, err error)

func (Print) Fprintf

func (p Print) Fprintf(w io.Writer, format string, a ...any) (n int, err error)

func (Print) Fprintfln

func (p Print) Fprintfln(w io.Writer, format string, a ...any) (n int, err error)

func (Print) Fprintln

func (p Print) Fprintln(w io.Writer, a ...any) (n int, err error)

func (Print) GetWriter

func (p Print) GetWriter() io.Writer

func (Print) MaxWidth

func (p Print) MaxWidth() int

func (Print) Print

func (p Print) Print(a ...any) (n int, err error)

func (Print) Printf

func (p Print) Printf(format string, a ...any) (n int, err error)

func (Print) Printfln

func (p Print) Printfln(format string, a ...any) (n int, err error)

func (Print) Println

func (p Print) Println(a ...any) (n int, err error)

func (Print) Sprint

func (p Print) Sprint(a ...any) string

func (Print) Sprintf

func (p Print) Sprintf(format string, a ...any) string

func (Print) Sprintfln

func (p Print) Sprintfln(format string, a ...any) string

func (Print) Sprintln

func (p Print) Sprintln(a ...any) string

func (Print) Style

func (p Print) Style() lipgloss.Style

func (Print) WrapMode

func (p Print) WrapMode() promptkit.WrapMode

func (Print) Write added in v0.6.0

func (p Print) Write(b []byte) (n int, err error)

func (Print) Writer

func (p Print) Writer() io.Writer

type Printer

type Printer interface {

	// Fprint mirrors [fmt.Fprint] signature and behavior, with the configured style
	// and (optional) word wrapping applied
	Fprint(w io.Writer, a ...any) (n int, err error)

	// Fprintf mirrors [fmt.Fprintf] signature and behavior, with the configured style
	// and (optional) word wrapping applied
	Fprintf(w io.Writer, format string, a ...any) (n int, err error)

	// Fprintfln mirrors [fmt.Fprintfln] signature and behavior, with the configured style
	// and (optional) word wrapping applied
	Fprintfln(w io.Writer, format string, a ...any) (n int, err error)

	// Fprintln mirrors [fmt.Fprintln] signature and behavior, with the configured style
	// and (optional) word wrapping applied
	Fprintln(w io.Writer, a ...any) (n int, err error)

	// Print mirrors [fmt.Print] signature and behavior, with the configured style
	// and (optional) word wrapping applied.
	//
	// Instead of writing to [os.Stdout] it will write to the configured [io.Writer].
	Print(a ...any) (n int, err error)

	// Printf mirrors [fmt.Printf] signature and behavior, with the configured style
	// and (optional) word wrapping applied.
	//
	// Instead of writing to [os.Stdout] it will write to the configured [io.Writer].
	Printf(format string, a ...any) (n int, err error)

	// Printfln behaves like [fmt.Printf] but supports the [formatter] signature.
	//
	// This does *not* map to a Go native printer, but a mix for formatting + newline
	Printfln(format string, a ...any) (n int, err error)

	// Println mirrors [fmt.Println] signature and behavior, with the configured style
	// and (optional) word wrapping applied.
	//
	// Instead of writing to [os.Stdout] it will write to the configured [io.Writer].
	Println(a ...any) (n int, err error)

	// Sprint mirrors [fmt.Sprint] signature and behavior, with the configured style
	// and (optional) word wrapping applied.
	Sprint(a ...any) string

	// Sprintf mirrors [fmt.Sprintf] signature and behavior, with the configured style
	// and (optional) word wrapping applied.
	Sprintf(format string, a ...any) string

	// Sprintfln behaves like [fmt.Sprintln] but supports the [formatter] signature.
	//
	// This does *not* map to a Go native printer, but a mix for formatting + newline
	Sprintfln(format string, a ...any) string

	// Sprintln mirrors [fmt.Sprintln] signature and behavior, with the configured style
	// and (optional) word wrapping applied.
	Sprintln(a ...any) string

	Copy(options ...PrinterOption) Print

	// GetMaxWidth returns the configured [MaxWidth] for word wrapping
	MaxWidth() int

	// TextStyle returns a *copy* of the current [lipgloss.Style]
	Style() lipgloss.Style

	// ApplyTextStyle returns a new copy of [StylePrint] instance with the [Style] based on the callback changes
	ApplyStyle(changer StyleChanger) Print

	// WrapMode returns the configured [WrapMode]
	WrapMode() promptkit.WrapMode

	// Writer returns the configured [io.Writer]
	Writer() io.Writer

	// Create a visual box with the printer style
	Box(header string, body ...string)
}

Printer mirrors the fmt package print/sprint functions, wraps them in a lipgloss.Style and an optional [WordWrap] configuration with a configured [MaxWidth].

Additionally, [Print*] methods writes to the configured [Writer] instead of os.Stdout

type PrinterOption

type PrinterOption func(p *Print)

func WithBoxStyle

func WithBoxStyle(style Box) PrinterOption

func WithColor

func WithColor(color Color) PrinterOption

func WithEmphasis

func WithEmphasis(b bool) PrinterOption

func WithMaxWidth

func WithMaxWidth(i int) PrinterOption

func WithRenderer

func WithRenderer(renderer *lipgloss.Renderer) PrinterOption

func WithTextStyle

func WithTextStyle(style lipgloss.Style) PrinterOption

func WithTheme

func WithTheme(theme ThemeConfig) PrinterOption

func WithWrapMode

func WithWrapMode(mode promptkit.WrapMode) PrinterOption

func WithWriter

func WithWriter(w io.Writer) PrinterOption

type StyleChanger

type StyleChanger func(*lipgloss.Style)

type ThemeConfig

type ThemeConfig struct {
	DefaultWidth int

	// Line wrapping handling
	WrapMode promptkit.WrapMode

	Danger    Color
	Dark      Color
	Info      Color
	Light     Color
	Primary   Color
	Secondary Color
	Success   Color
	Warning   Color
}
var Theme ThemeConfig

Jump to

Keyboard shortcuts

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