Documentation ¶
Overview ¶
Implements the ANSI VT100 control set. Please refer to http://www.termsys.demon.co.uk/vtansi.htm
Index ¶
- Constants
- Variables
- func Goto(r, c uint16) []byte
- func Scroll(start, end uint16) []byte
- func Set(attrs ...Attribute) []byte
- type Ansi
- func (a *Ansi) Close() error
- func (a *Ansi) CursorHide()
- func (a *Ansi) CursorShow()
- func (a *Ansi) DisableLineWrap()
- func (a *Ansi) EnableLineWrap()
- func (a *Ansi) EraseScreen()
- func (a *Ansi) Goto(r, c uint16)
- func (a *Ansi) QueryCursorPosition()
- func (a *Ansi) Read(dest []byte) (n int, err error)
- func (a *Ansi) Set(attrs ...Attribute)
- func (a *Ansi) Write(p []byte) (n int, err error)
- type Attribute
- type Report
- type ReportType
Constants ¶
View Source
const Esc = byte(27)
Variables ¶
View Source
var ( ResetBytes = Set(Reset) BrightBytes = Set(Bright) DimBytes = Set(Dim) ItalicBytes = Set(Italic) UnderscoreBytes = Set(Underscore) BlinkBytes = Set(Blink) ReverseBytes = Set(Reverse) HiddenBytes = Set(Hidden) //foreground colors BlackBytes = Set(Black) RedBytes = Set(Red) GreenBytes = Set(Green) YellowBytes = Set(Yellow) BlueBytes = Set(Blue) MagentaBytes = Set(Magenta) CyanBytes = Set(Cyan) WhiteBytes = Set(White) //background colors BlackBGBytes = Set(BlackBG) RedBGBytes = Set(RedBG) GreenBGBytes = Set(GreenBG) YellowBGBytes = Set(YellowBG) BlueBGBytes = Set(BlueBG) MagentaBGBytes = Set(MagentaBG) CyanBGBytes = Set(CyanBG) WhiteBGBytes = Set(WhiteBG) )
View Source
var ClearAllTabs = []byte{Esc, '[', '3', 'g'}
View Source
var ClearTab = []byte{Esc, '[', 'g'}
View Source
var CursorHide = []byte{Esc, '[', '?', '2', '5', 'l'}
View Source
var CursorShow = []byte{Esc, '[', '?', '2', '5', 'h'}
View Source
var DisableLineWrap = []byte{Esc, '[', '7', 'l'}
View Source
var EnableLineWrap = []byte{Esc, '[', '7', 'h'}
View Source
var EraseDown = []byte{Esc, '[', 'J'}
View Source
var EraseEndLine = []byte{Esc, '[', 'K'}
View Source
var EraseLine = []byte{Esc, '[', '2', 'K'}
View Source
var EraseScreen = []byte{Esc, '[', '2', 'J'}
View Source
var EraseStartLine = []byte{Esc, '[', '1', 'K'}
View Source
var EraseUp = []byte{Esc, '[', '1', 'J'}
View Source
var FontSetG0 = []byte{Esc, '('}
View Source
var FontSetG1 = []byte{Esc, ')'}
View Source
var PrintLine = []byte{Esc, '[', '1', 'i'}
View Source
var PrintScreen = []byte{Esc, '[', 'i'}
Printing
View Source
var QueryCode = []byte{Esc, '[', 'c'}
View Source
var QueryCursorPosition = []byte{Esc, '[', '6', 'n'}
View Source
var QueryDeviceStatus = []byte{Esc, '[', '5', 'n'}
View Source
var ResetDevice = []byte{Esc, 'c'}
View Source
var RestoreAttrCursor = []byte{Esc, '8'}
View Source
var SaveAttrCursor = []byte{Esc, '7'}
View Source
var SaveCursor = []byte{Esc, '[', 's'}
View Source
var ScrollDown = []byte{Esc, 'D'}
View Source
var ScrollScreen = []byte{Esc, '[', 'r'}
View Source
var ScrollUp = []byte{Esc, 'M'}
View Source
var SetTab = []byte{Esc, 'H'}
Tab Control
View Source
var StartPrintLog = []byte{Esc, '[', '5', 'i'}
View Source
var StopPrintLog = []byte{Esc, '[', '4', 'i'}
View Source
var UnsaveCursor = []byte{Esc, '[', 'u'}
Functions ¶
Types ¶
type Ansi ¶
type Ansi struct { Reports chan *Report // contains filtered or unexported fields }
Ansi represents a wrapped io.ReadWriter. It will read the stream, parse and remove ANSI report codes and place them on the Reports queue.
func Wrap ¶
func Wrap(rw io.ReadWriter) *Ansi
Wrap an io.ReadWriter (like a net.Conn) to easily read and write control codes
func (*Ansi) CursorHide ¶
func (a *Ansi) CursorHide()
func (*Ansi) CursorShow ¶
func (a *Ansi) CursorShow()
func (*Ansi) DisableLineWrap ¶
func (a *Ansi) DisableLineWrap()
func (*Ansi) EnableLineWrap ¶
func (a *Ansi) EnableLineWrap()
func (*Ansi) EraseScreen ¶
func (a *Ansi) EraseScreen()
func (*Ansi) QueryCursorPosition ¶
func (a *Ansi) QueryCursorPosition()
type Attribute ¶
type Attribute string
Sets multiple display attribute settings. The following lists standard attributes:
const ( //formatinn Reset Attribute = "0" Bright Attribute = "1" Dim Attribute = "2" Italic Attribute = "3" Underscore Attribute = "4" Blink Attribute = "5" Reverse Attribute = "7" Hidden Attribute = "8" //foreground colors Black Attribute = "30" Red Attribute = "31" Green Attribute = "32" Yellow Attribute = "33" Blue Attribute = "34" Magenta Attribute = "35" Cyan Attribute = "36" White Attribute = "37" //background colors BlackBG Attribute = "40" RedBG Attribute = "41" GreenBG Attribute = "42" YellowBG Attribute = "43" BlueBG Attribute = "44" MagentaBG Attribute = "45" CyanBG Attribute = "46" WhiteBG Attribute = "47" )
type Report ¶
type Report struct { Type ReportType Code int Pos struct { Row, Col int } }
Click to show internal directories.
Click to hide internal directories.