Documentation ¶
Overview ¶
Example ¶
var lines ansi.Lines writer := ansi.NewWriter(&lines) writer.Write([]byte("\x1b[1mbold\x1b[m text")) writer.Write([]byte("\nline 2")) linesJSON, _ := json.Marshal(lines) fmt.Println(string(linesJSON))
Output: [[{"data":"bold","style":{"bold":true}},{"data":" text","style":{}}],[{"data":"line 2","style":{}}]]
Index ¶
- type Action
- type CarriageReturn
- type Chunk
- type Color
- type CursorBack
- type CursorColumn
- type CursorDown
- type CursorForward
- type CursorPosition
- type CursorUp
- type EraseDisplay
- type EraseLine
- type EraseMode
- type Line
- type LineDiscipline
- type Linebreak
- type Lines
- type Output
- type Parser
- type Pos
- type Print
- type Reset
- type RestoreCursorPosition
- type SaveCursorPosition
- type SetBackground
- type SetBlink
- type SetBold
- type SetFaint
- type SetForeground
- type SetFraktur
- type SetFramed
- type SetInverted
- type SetItalic
- type SetUnderline
- type State
- type Style
- type StyleModifier
- type Text
- type Writer
- type WriterOption
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CarriageReturn ¶
type CarriageReturn struct{}
func (CarriageReturn) ActionString ¶
func (a CarriageReturn) ActionString() string
func (CarriageReturn) String ¶
func (a CarriageReturn) String() string
type CursorBack ¶
type CursorBack int
func (CursorBack) ActionString ¶
func (a CursorBack) ActionString() string
func (CursorBack) String ¶
func (a CursorBack) String() string
type CursorColumn ¶
type CursorColumn int
func (CursorColumn) ActionString ¶
func (a CursorColumn) ActionString() string
func (CursorColumn) String ¶
func (a CursorColumn) String() string
type CursorDown ¶
type CursorDown int
func (CursorDown) ActionString ¶
func (a CursorDown) ActionString() string
func (CursorDown) String ¶
func (a CursorDown) String() string
type CursorForward ¶
type CursorForward int
func (CursorForward) ActionString ¶
func (a CursorForward) ActionString() string
func (CursorForward) String ¶
func (a CursorForward) String() string
type CursorPosition ¶
type CursorPosition Pos
func (CursorPosition) ActionString ¶
func (a CursorPosition) ActionString() string
func (CursorPosition) String ¶
func (a CursorPosition) String() string
type EraseDisplay ¶
type EraseDisplay EraseMode
func (EraseDisplay) ActionString ¶
func (a EraseDisplay) ActionString() string
func (EraseDisplay) String ¶
func (a EraseDisplay) String() string
type RestoreCursorPosition ¶
type RestoreCursorPosition struct{}
func (RestoreCursorPosition) ActionString ¶
func (a RestoreCursorPosition) ActionString() string
func (RestoreCursorPosition) String ¶
func (a RestoreCursorPosition) String() string
type SaveCursorPosition ¶
type SaveCursorPosition struct{}
func (SaveCursorPosition) ActionString ¶
func (a SaveCursorPosition) ActionString() string
func (SaveCursorPosition) String ¶
func (a SaveCursorPosition) String() string
type SetBackground ¶
type SetBackground Color
func (SetBackground) ActionString ¶
func (a SetBackground) ActionString() string
func (SetBackground) String ¶
func (a SetBackground) String() string
type SetForeground ¶
type SetForeground Color
func (SetForeground) ActionString ¶
func (a SetForeground) ActionString() string
func (SetForeground) String ¶
func (a SetForeground) String() string
type SetFraktur ¶
type SetFraktur bool
func (SetFraktur) ActionString ¶
func (a SetFraktur) ActionString() string
func (SetFraktur) String ¶
func (a SetFraktur) String() string
type SetInverted ¶
type SetInverted bool
func (SetInverted) ActionString ¶
func (a SetInverted) ActionString() string
func (SetInverted) String ¶
func (a SetInverted) String() string
type SetUnderline ¶
type SetUnderline bool
func (SetUnderline) ActionString ¶
func (a SetUnderline) ActionString() string
func (SetUnderline) String ¶
func (a SetUnderline) String() string
type Style ¶
type Style struct { Foreground Color Background Color Modifier StyleModifier }
func (Style) MarshalJSON ¶
func (*Style) UnmarshalJSON ¶
type StyleModifier ¶
type StyleModifier uint8
const ( Bold StyleModifier = 1 << iota Faint Italic Underline Blink Inverted Fraktur Framed )
type WriterOption ¶
type WriterOption func(*Writer)
func WithInitialScreenSize ¶
func WithInitialScreenSize(lines, cols int) WriterOption
func WithLineDiscipline ¶
func WithLineDiscipline(d LineDiscipline) WriterOption
Click to show internal directories.
Click to hide internal directories.