Documentation ¶
Index ¶
- Variables
- func Cleanse(input string) (string, error)
- func HasEscapeCodes(input string) bool
- func Length(input string) (int, error)
- func String(input []*StyledText) string
- func Truncate(input string, maxChars int) (string, error)
- type Col
- type Hsl
- type Rgb
- type StyledText
- func (s *StyledText) Blinking() bool
- func (s *StyledText) Bold() bool
- func (s *StyledText) Faint() bool
- func (s *StyledText) Inversed() bool
- func (s *StyledText) Invisible() bool
- func (s *StyledText) Italic() bool
- func (s *StyledText) Strikethrough() bool
- func (s *StyledText) String() string
- func (s *StyledText) Underlined() bool
- type TextStyle
Constants ¶
This section is empty.
Variables ¶
var ColourMap = map[string]map[string]*Col{ "Regular": { "30": Cols[0], "31": Cols[1], "32": Cols[2], "33": Cols[3], "34": Cols[4], "35": Cols[5], "36": Cols[6], "37": Cols[7], }, "Bold": { "30": Cols[8], "31": Cols[9], "32": Cols[10], "33": Cols[11], "34": Cols[12], "35": Cols[13], "36": Cols[14], "37": Cols[15], }, "Faint": { "30": Cols[0], "31": Cols[1], "32": Cols[2], "33": Cols[3], "34": Cols[4], "35": Cols[5], "36": Cols[6], "37": Cols[7], }, }
ColourMap maps ansi identifiers to a colour
var Cols = []*Col{}/* 256 elements not displayed */
Cols represents the default colour definitions used by the library. This may be overridden.
Functions ¶
func HasEscapeCodes ¶
func String ¶
func String(input []*StyledText) string
Types ¶
type Col ¶
type Col struct { Id int `json:"id"` Hex string `json:"hex"` Rgb Rgb `json:"rgb"` Hsl Hsl `json:"hsl"` Name string `json:"name"` }
Col represents a colour value. The Id is the ANSI colour ID.
type StyledText ¶
StyledText represents a single formatted string
func Parse ¶
func Parse(input string) ([]*StyledText, error)
Parse will convert an ansi encoded string and return a slice of StyledText structs that represent the text. If parsing is unsuccessful, an error is returned.
func (*StyledText) Blinking ¶
func (s *StyledText) Blinking() bool
Blinking will return true if the text has a Blinking style
func (*StyledText) Bold ¶
func (s *StyledText) Bold() bool
Bold will return true if the text has a Bold style
func (*StyledText) Faint ¶
func (s *StyledText) Faint() bool
Faint will return true if the text has a Faint style
func (*StyledText) Inversed ¶
func (s *StyledText) Inversed() bool
Inversed will return true if the text has an Inversed style
func (*StyledText) Invisible ¶
func (s *StyledText) Invisible() bool
Invisible will return true if the text has an Invisible style
func (*StyledText) Italic ¶
func (s *StyledText) Italic() bool
Italic will return true if the text has an Italic style
func (*StyledText) Strikethrough ¶
func (s *StyledText) Strikethrough() bool
Strikethrough will return true if the text has a Strikethrough style
func (*StyledText) String ¶
func (s *StyledText) String() string
func (*StyledText) Underlined ¶
func (s *StyledText) Underlined() bool
Underlined will return true if the text has an Underlined style
type TextStyle ¶
type TextStyle int
TextStyle is a type representing the ansi text styles
const ( // Bold Style Bold TextStyle = 1 << 0 // Faint Style Faint TextStyle = 1 << 1 // Italic Style Italic TextStyle = 1 << 2 // Blinking Style Blinking TextStyle = 1 << 3 // Inversed Style Inversed TextStyle = 1 << 4 // Invisible Style Invisible TextStyle = 1 << 5 // Underlined Style Underlined TextStyle = 1 << 6 // Strikethrough Style Strikethrough TextStyle = 1 << 7 )