Documentation ¶
Index ¶
Constants ¶
const ( // Normal intensity Normal Intensity = 0 // Bright intensity Bright = 1 // Dim intensity Dim = 2 )
Variables ¶
var ( // DefaultColor technically RGBAs are supposed to be premultiplied. But CSS doesn't expect them // that way, so we won't do it in this file. DefaultColor = color.RGBA{0, 0, 0, 0} // Black has 255 alpha, so it will compare negatively with DefaultColor. Black = color.RGBA{0, 0, 0, 255} // Red color Red = color.RGBA{255, 0, 0, 255} // Green color Green = color.RGBA{0, 255, 0, 255} // Yellow color Yellow = color.RGBA{255, 255, 0, 255} // Blue color Blue = color.RGBA{0, 0, 255, 255} // Magenta color Magenta = color.RGBA{255, 0, 255, 255} // Cyan color Cyan = color.RGBA{0, 255, 255, 255} // White color White = color.RGBA{255, 255, 255, 255} )
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command interface {
// contains filtered or unexported methods
}
Command is a type of object that the terminal can process to perform an update.
func Decode ¶
func Decode(s io.RuneScanner) (Command, error)
Decode decodes one ANSI terminal command from s.
s should be connected to a client program that expects an ANSI terminal on the other end. It will push bytes to us that we are meant to intepret as terminal control codes, or text to place onto the terminal.
This Command alone does not actually update the terminal. You need to pass it to VT100.Process().
You should not share s with any other reader, because it could leave the stream in an invalid state.
type Cursor ¶
type Cursor struct {
// Y and X are the coordinates.
Y, X int
// F is the format that will be displayed.
F Format
}
Cursor represents both the position and text type of the cursor.
type Format ¶
type Format struct { // Fg is the foreground color. Fg color.RGBA // Bg is the background color. Bg color.RGBA // Intensity is the text intensity (bright, normal, dim). Intensity Intensity // Various text properties. Underscore, Conceal, Negative, Blink, Inverse bool }
Format represents the display format of text on a terminal.
type UnsupportedError ¶
type UnsupportedError struct {
// contains filtered or unexported fields
}
UnsupportedError indicates that we parsed an operation that this terminal does not implement. Such errors indicate that the client program asked us to perform an action that we don't know how to. It MAY be safe to continue trying to do additional operations. This is a distinct category of errors from things we do know how to do, but are badly encoded, or errors from the underlying io.RuneScanner that we're reading commands from.
type VT100 ¶
type VT100 struct {
// Height and Width are the dimensions of the terminal.
Height, Width int
// Content is the text in the terminal.
Content [][]rune
// Format is the display properties of each cell.
Format [][]Format
// Cursor is the current state of the cursor.
Cursor Cursor
// contains filtered or unexported fields
}
VT100 represents a simplified, raw VT100 terminal.
func NewVT100 ¶
NewVT100 creates a new VT100 object with the specified dimensions. y and x must both be greater than zero.
Each cell is set to contain a ' ' rune, and all formats are left as the default.
func (*VT100) Process ¶
Process handles a single ANSI terminal command, updating the terminal appropriately.
One special kind of error that this can return is an UnsupportedError. It's probably best to check for these and skip, because they are likely recoverable. Support errors are exported as expvars, so it is possibly not necessary to log them. If you want to check what's failed, start a debug http server and examine the vt100-unsupported-commands field in /debug/vars.