Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Styler ¶
type Styler interface { // Apply will parse and replace any valid style tags in the original rune array and return the result. // // Style tags are applied to a maximum depth of 5 nested tags. Apply(original []rune) (output []rune) // ApplyStr will call Apply while casting the arguments to/from strings. // There is a reasonable performance hit to this over Apply. ApplyStr(original string) (output string) // ApplyStrf will call Apply while casting the arguments to/from strings and using fmt.Sprintf. // Only the format string will be parsed for style tags. // // There is a reasonable performance hit to this over Apply. ApplyStrf(format string, args ...any) (output string) // Register will add a new named style which can be used in future calls of Apply. // The value expected is an ANSI escape code such as `31` for red. // To have a style map to multiple ANSI escape codes, separate them with a semicolon. // // Names have a maximum length of 16 characters. // // For example: // // s := instyle.NewStyler() // s.Register("error", "1;31") // _ = s.Apply([]rune("[~error]Something unexpected happened")) Register(name string, value string) (self Styler) // RegisterLipGlossStyle will extract the text styling from a [lipgloss.Style] and register it under the name provided. // Specifically, the following will be captured if set on the style: // // - Foreground color // - Background color // - Text styling of bold / faint / italic / underline / blink / strikethrough // // [lipgloss.Style]: https://github.com/charmbracelet/lipgloss RegisterLipGlossStyle(name string, value lipgloss.Style) (self Styler) }
Click to show internal directories.
Click to hide internal directories.