Documentation
¶
Index ¶
- Constants
- Variables
- func Box(r Rect, chars [6]int, text string, style ...SGRType) string
- func CHA(n int) string
- func CNL(n int) string
- func CPL(n int) string
- func CUB(n int) string
- func CUD(n int) string
- func CUF(n int) string
- func CUP(m, n int) string
- func CUU(n int) string
- func CharAt(x, y, c int) string
- func ClearRect(r Rect) string
- func ED(n EraseType) string
- func EL(n EraseType) string
- func HLine(x1, x2, y, c int) string
- func HLineText(x1, x2, y, c int, text string, style ...SGRType) string
- func HVP(m, n int) string
- func ReadKey(reader *bufio.Reader) (r rune, size int, err error)
- func SD(n int) string
- func SGR(n ...SGRType) string
- func SU(n int) string
- func VLine(x, y1, y2, c int) string
- type Canvas
- func (c *Canvas) Bmp(x, y int, bmp [][]byte)
- func (c *Canvas) Clear()
- func (c *Canvas) Height() int
- func (c *Canvas) Init(w, h int)
- func (c *Canvas) Line(x0, y0, x1, y1 int)
- func (c *Canvas) Plot(x, y int)
- func (c *Canvas) PlotOr()
- func (c *Canvas) PlotUnwrap()
- func (c *Canvas) PlotWrap()
- func (c *Canvas) PlotXor()
- func (c *Canvas) Read(x, y int) bool
- func (c *Canvas) StringAspect() string
- func (c *Canvas) StringAspectBorder() string
- func (c *Canvas) StringDense() string
- func (c *Canvas) StringDenseBorder() string
- func (c *Canvas) Width() int
- type EraseType
- type KeyCallback
- type LineCallback
- type LocType
- type Point
- type Rect
- type SGRType
- type Tile
- func (t *Tile) Clear() string
- func (t *Tile) Cursor() string
- func (t *Tile) Height() int
- func (t *Tile) Line() string
- func (tile *Tile) Print(s ...any)
- func (tile *Tile) Printf(format string, s ...any)
- func (tile *Tile) Println(s ...any)
- func (t *Tile) ResetBuffer()
- func (t *Tile) SetKeyCallback(c KeyCallback) error
- func (t *Tile) SetLineCallback(c LineCallback) error
- func (t *Tile) Width() int
- func (tile *Tile) Write(buf []byte) (n int, err error)
- type TileHandler
- type TileTerm
- func (tTerm *TileTerm) AddTile(name string, cursor string, outline [6]int, fraction float32, location LocType, ...) (*Tile, error)
- func (tTerm *TileTerm) DeleteTile(tile *Tile)
- func (tTerm *TileTerm) Render()
- func (tTerm *TileTerm) Start() error
- func (tTerm *TileTerm) String() string
- func (tTerm *TileTerm) TileByIndex(index int) (tile *Tile)
- type TileType
Constants ¶
const ( SBox_Horiz = 0x2501 //single line SBox_Vert = 0x2503 SBox_UL = 0x250F SBox_UR = 0x2513 SBox_LL = 0x2517 SBox_LR = 0x251B DBox_Horiz = 0x2550 //double line DBox_Vert = 0x2551 DBox_UL = 0x2554 DBox_UR = 0x2557 DBox_LL = 0x255A DBox_LR = 0x255D BBox_Horiz = 0x2509 //broken line BBox_Vert = 0x250B BBox_UL = 0x250F BBox_UR = 0x2513 BBox_LL = 0x2517 BBox_LR = 0x251B HBox_Horiz = 0x2501 //horiz only HBox_Vert = 0x20 HBox_UL = 0x20 HBox_UR = 0x20 HBox_LL = 0x20 HBox_LR = 0x20 )
const ( CtrlA = 0x01 + iota CtrlB CtrlC CtrlD CtrlE CtrlF CtrlG CtrlH CtrlI CtrlJ CtrlK CtrlL CtrlM CtrlN CtrlO CtrlP CtrlQ CtrlR CtrlS CtrlT CtrlU CtrlV CtrlW CtrlX CtrlY CtrlZ )
const ( KeyTab = 9 KeyEnter = 13 KeyEscape = 27 KeySpace = 32 KeyLBracket = 91 KeyBackspace = 127 )
const ( KeyUnknown = 0xd800 + iota KeyUp KeyDown KeyLeft KeyRight KeyBackTab KeyDel )
const ( Box_Horiz = iota Box_Vert Box_UL Box_UR Box_LL Box_LR )
box part indices within a char set
const CSI = "\x1b\x5b"
Variables ¶
var BlocksAspect = [16][2]int{
{0x20, 0x20},
{0x2580, 0x20},
{0x20, 0x2580},
{0x2580, 0x2580},
{0x2584, 0x20},
{0x2588, 0x20},
{0x2584, 0x2580},
{0x2588, 0x2580},
{0x20, 0x2584},
{0x2580, 0x2584},
{0x20, 0x2588},
{0x2580, 0x2588},
{0x2584, 0x2584},
{0x2588, 0x2584},
{0x2584, 0x2588},
{0x2588, 0x2588},
}
var BlocksDense = [16]int{
0x20,
0x2598,
0x259d,
0x2580,
0x2596,
0x258c,
0x259e,
0x259b,
0x2597,
0x259a,
0x2590,
0x259c,
0x2584,
0x2599,
0x259f,
0x2588,
}
1 2 4 8
var BrokenBox = [6]int{BBox_Horiz, BBox_Vert, BBox_UL, BBox_UR, BBox_LL, BBox_LR}
var DoubleBox = [6]int{DBox_Horiz, DBox_Vert, DBox_UL, DBox_UR, DBox_LL, DBox_LR}
var HorizBox = [6]int{HBox_Horiz, HBox_Vert, HBox_UL, HBox_UR, HBox_LL, HBox_LR}
var SingleBox = [6]int{SBox_Horiz, SBox_Vert, SBox_UL, SBox_UR, SBox_LL, SBox_LR}
box char sets
Functions ¶
func ED ¶
ED - Erase in Display If n is 0, clear from cursor to end of screen. If n is 1, clear from cursor to beginning of the screen. If n is 2, clear entire screen (and moves cursor to upper left on DOS ANSI.SYS).
func EL ¶
EL - Erase in Line If n is 0 (or missing), clear from cursor to the end of the line. If n is 1, clear from cursor to beginning of the line. If n is 2, clear entire line. Cursor position does not change.
func HLineText ¶
HLineText is a helper to make a horizontal line with text in the center SGRType is applied to the text
Types ¶
type Canvas ¶
type Canvas struct {
// contains filtered or unexported fields
}
Canvas holds a bit buffer for plotting Canvas assumes a virtual canvas of bits arranged as width 0 -> height 0 | v Upper left is 0,0 bits are arranged within a byte as:
x x
y 1 2 y 4 8 (y, x) (00)(01) (10)(11) if xor is true the new plot is xor'd on the existing canvas, otherwise it is just set if wrap is true the x, y coordinates are moded to wrap to the boundary
func (*Canvas) Init ¶
Init an existing Canvas, w and h are in pixels So Init(80,80) renders an array of 40x40 characters as StringDense and an array of 80x40 characters as StringAspect
func (*Canvas) PlotOr ¶
func (c *Canvas) PlotOr()
PlotOr sets the plot mode to or the new pixel on the existing pixel (default)
func (*Canvas) PlotUnwrap ¶
func (c *Canvas) PlotUnwrap()
Plotwrap sets the plot mode to not wrap cordinates on the borders (default)
func (*Canvas) PlotWrap ¶
func (c *Canvas) PlotWrap()
Plotwrap sets the plot mode to wrap cordinates on the borders
func (*Canvas) PlotXor ¶
func (c *Canvas) PlotXor()
PlotXor sets the plot mode to xor the new pixel on the existing pixel
func (*Canvas) StringAspect ¶
Render the Canvas to a string as "square" (1x2) pixels
func (*Canvas) StringAspectBorder ¶
Render the Canvas to a string as "square" (1x2) pixels, with a border
func (*Canvas) StringDense ¶
Render the Canvas to a string as dense (2x2) rectangle pixels
func (*Canvas) StringDenseBorder ¶
Render the Canvas to a string as dense (2x2) rectangle pixels, with a border
type KeyCallback ¶
returning true from any KeyCallback will exit TileTerm
type LineCallback ¶
returning true from any LineCallback will exit TileTerm
type Rect ¶
type Rect struct {
Min, Max Point
}
type SGRType ¶
type SGRType int
const ( SGR_Off SGRType = 0 // All attributes off SGR_Bold SGRType = 1 // Bold SGR_Underline SGRType = 4 // Underline SGR_Blinking SGRType = 5 // Blinking SGR_Negative SGRType = 7 // Negative image SGR_Invisible SGRType = 8 // Invisible image SGR_BoldOff SGRType = 22 // Bold off SGR_UnderlineOff SGRType = 24 // Underline off SGR_BlinkingOff SGRType = 25 // Blinking off SGR_NegativeOff SGRType = 27 // Negative image off SGR_InvisibleOff SGRType = 28 // Invisible image off )
type Tile ¶
type Tile struct {
// contains filtered or unexported fields
}
Tile contains the state for a Tile
func (*Tile) SetKeyCallback ¶
func (t *Tile) SetKeyCallback(c KeyCallback) error
SetKeyCallback sets the Key Callback function for TileType_ScrollDownClipRaw
func (*Tile) SetLineCallback ¶
func (t *Tile) SetLineCallback(c LineCallback) error
SetLineCallback sets the Line Callback function for TileType_ScrollUp
type TileHandler ¶
type TileTerm ¶
type TileTerm struct {
// contains filtered or unexported fields
}
TileTerm contains the state for a TileTerm session
func NewTileTerm ¶
NewTileTerm returns a new TileTerm session, typically pass in stdin and stdout
func (*TileTerm) AddTile ¶
func (tTerm *TileTerm) AddTile(name string, cursor string, outline [6]int, fraction float32, location LocType, parent *Tile, handler TileType) (*Tile, error)
AddTile adds a new tile to the TileTerm session name: Title name of the tile, or "" cursor: Cursor suffix for the tile, or "" outline: Box character set to use for tile border fraction: % of parent tile to take for this child location: location within parent tile to use for this child parent: which existing tile to use as parent for this child (root is nil) handler: which tile handler set to use
func (*TileTerm) DeleteTile ¶
DeleteTile deletes a tile and all of its children
func (*TileTerm) Render ¶
func (tTerm *TileTerm) Render()
Render renders the TileTerm session to Out It is a convenience function for String()
func (*TileTerm) TileByIndex ¶
TileByIndex returns a tile by its index