Documentation ¶
Index ¶
- func Escape(message string) string
- func EscapeTrailingBackslash(message string) string
- type OutputFormatter
- func (o *OutputFormatter) FindTagsInString(text string) []TagPos
- func (o *OutputFormatter) Format(message string) string
- func (o *OutputFormatter) GetStyle(name string) *OutputFormatterStyle
- func (o *OutputFormatter) GetStyleStack() *OutputFormatterStyleStack
- func (o *OutputFormatter) HasStyle(name string) bool
- func (o *OutputFormatter) IsDecorated() bool
- func (o *OutputFormatter) SetDecorated(decorated bool)
- func (o *OutputFormatter) SetStyle(name string, style OutputFormatterStyle)
- type OutputFormatterInterface
- type OutputFormatterStyle
- func (style *OutputFormatterStyle) Apply(text string) string
- func (style *OutputFormatterStyle) SetBackground(name string)
- func (style *OutputFormatterStyle) SetForeground(name string)
- func (style *OutputFormatterStyle) SetOption(name string)
- func (style *OutputFormatterStyle) SetOptions(options []string)
- func (style *OutputFormatterStyle) UnsetOption(name string)
- type OutputFormatterStyleStack
- func (stack *OutputFormatterStyleStack) GetCurrent() *OutputFormatterStyle
- func (stack *OutputFormatterStyleStack) GetDefaultStyle() *OutputFormatterStyle
- func (stack *OutputFormatterStyleStack) Pop(style *OutputFormatterStyle) *OutputFormatterStyle
- func (stack *OutputFormatterStyleStack) Push(style *OutputFormatterStyle)
- func (stack *OutputFormatterStyleStack) Reset()
- func (stack *OutputFormatterStyleStack) SetDefaultStyle(style OutputFormatterStyle)
- type TagPos
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscapeTrailingBackslash ¶
Escapes trailing "\" in given text.
Types ¶
type OutputFormatter ¶
type OutputFormatter struct {
// contains filtered or unexported fields
}
Formatter class for console output.
func (*OutputFormatter) FindTagsInString ¶
func (o *OutputFormatter) FindTagsInString(text string) []TagPos
Make a tagMap from a message
func (*OutputFormatter) Format ¶
func (o *OutputFormatter) Format(message string) string
Formats a message according to the given styles.
func (*OutputFormatter) GetStyle ¶
func (o *OutputFormatter) GetStyle(name string) *OutputFormatterStyle
Gets style from cache with specified name.
func (*OutputFormatter) GetStyleStack ¶
func (o *OutputFormatter) GetStyleStack() *OutputFormatterStyleStack
Gets style stack
func (*OutputFormatter) HasStyle ¶
func (o *OutputFormatter) HasStyle(name string) bool
Checks if output formatter has style in cache with specified name.
func (*OutputFormatter) IsDecorated ¶
func (o *OutputFormatter) IsDecorated() bool
Gets the decorated flag.
func (*OutputFormatter) SetDecorated ¶
func (o *OutputFormatter) SetDecorated(decorated bool)
Sets the decorated flag.
func (*OutputFormatter) SetStyle ¶
func (o *OutputFormatter) SetStyle(name string, style OutputFormatterStyle)
Sets a new style to cache.
type OutputFormatterInterface ¶
type OutputFormatterInterface interface { // Sets the decorated flag. SetDecorated(decorated bool) // Gets the decorated flag. IsDecorated() bool // Sets a new style to cache. SetStyle(name string, style OutputFormatterStyle) // Gets style from cache with specified name. GetStyle(name string) *OutputFormatterStyle // Gets style stack GetStyleStack() *OutputFormatterStyleStack // Checks if output formatter has style in cache with specified name. HasStyle(name string) bool // Formats a message according to the given styles. Format(message string) string // Return a list of tags found in the given text. FindTagsInString(text string) []TagPos }
Formatter interface for console output
type OutputFormatterStyle ¶
type OutputFormatterStyle struct {
// contains filtered or unexported fields
}
Formatter style class for defining styles
func NewOutputFormatterStyle ¶
func NewOutputFormatterStyle( foreground string, background string, options []string, ) *OutputFormatterStyle
Formatter style constructor
func (*OutputFormatterStyle) Apply ¶
func (style *OutputFormatterStyle) Apply(text string) string
Applies the style to a given text.
func (*OutputFormatterStyle) SetBackground ¶
func (style *OutputFormatterStyle) SetBackground(name string)
Sets style background color.
func (*OutputFormatterStyle) SetForeground ¶
func (style *OutputFormatterStyle) SetForeground(name string)
Sets style foreground color.
func (*OutputFormatterStyle) SetOption ¶
func (style *OutputFormatterStyle) SetOption(name string)
Sets some specific style option.
func (*OutputFormatterStyle) SetOptions ¶
func (style *OutputFormatterStyle) SetOptions(options []string)
Sets multiple style options at once.
func (*OutputFormatterStyle) UnsetOption ¶
func (style *OutputFormatterStyle) UnsetOption(name string)
Unsets some specific style option.
type OutputFormatterStyleStack ¶
type OutputFormatterStyleStack struct {
// contains filtered or unexported fields
}
Formatter style stack class for defining styles
func NewOutputFormatterStyleStack ¶
func NewOutputFormatterStyleStack(style *OutputFormatterStyle) *OutputFormatterStyleStack
output formatter style constructor
func (*OutputFormatterStyleStack) GetCurrent ¶
func (stack *OutputFormatterStyleStack) GetCurrent() *OutputFormatterStyle
Computes current style with stacks top codes
func (*OutputFormatterStyleStack) GetDefaultStyle ¶
func (stack *OutputFormatterStyleStack) GetDefaultStyle() *OutputFormatterStyle
get default style
func (*OutputFormatterStyleStack) Pop ¶
func (stack *OutputFormatterStyleStack) Pop(style *OutputFormatterStyle) *OutputFormatterStyle
Pops a style from the stack, pop the first if style equal nil.
func (*OutputFormatterStyleStack) Push ¶
func (stack *OutputFormatterStyleStack) Push(style *OutputFormatterStyle)
Pushes a style in the stack.
func (*OutputFormatterStyleStack) Reset ¶
func (stack *OutputFormatterStyleStack) Reset()
Resets stack (ie. empty internal arrays).
func (*OutputFormatterStyleStack) SetDefaultStyle ¶
func (stack *OutputFormatterStyleStack) SetDefaultStyle(style OutputFormatterStyle)
set default style