Documentation ¶
Index ¶
- Constants
- Variables
- func DisableEcho()
- func Draw()
- func EnableEcho()
- func HideCursor()
- func InitColors(num int) bool
- func ShowCursor()
- type Canvas
- func (c *Canvas) Clear()
- func (c *Canvas) ClearSafe()
- func (c *Canvas) Flush()
- func (c *Canvas) FlushSafe()
- func (c *Canvas) Move(x, y int) error
- func (c *Canvas) MoveSafe(x, y int) error
- func (c *Canvas) Set(x, y int, char rune)
- func (c *Canvas) SetBackground(clr Color)
- func (c *Canvas) SetBackgroundSafe(clr Color)
- func (c *Canvas) SetForeground(clr Color)
- func (c *Canvas) SetForegroundSafe(clr Color)
- func (c *Canvas) SetSafe(x, y int, char rune)
- func (c *Canvas) SetStyle(style int)
- func (c *Canvas) SetStyleSafe(style int)
- func (c *Canvas) Write(text string)
- func (c *Canvas) WriteAt(x, y int, foreground, background Color, style int, text string)
- func (c *Canvas) WriteAtSafe(x, y int, foreground, background Color, style int, text string)
- func (c *Canvas) WriteSafe(text string)
- type Color
Constants ¶
const ( StyleNoChange = 1 << iota StyleNormal StyleBold StyleDim StyleUnderlined StyleBlink StyleInverted StyleHidden )
Variables ¶
var ( ErrorOutOfBounds = errors.New("out of bounds") ErrorTruncated = errors.New("string truncated") )
var ( ColorDefault = Color{/* contains filtered or unexported fields */} ColorBlack = Color{Term256: 0} ColorRed = Color{Term256: 1} ColorGreen = Color{Term256: 2} ColorYellow = Color{Term256: 3} ColorBlue = Color{Term256: 4} ColorMagenta = Color{Term256: 5} ColorCyan = Color{Term256: 6} ColorLightGray = Color{Term256: 7} ColorDarkGray = Color{Term256: 8} ColorLightRed = Color{Term256: 9} ColorLightGreen = Color{Term256: 10} ColorLightYellow = Color{Term256: 11} ColorLightBlue = Color{Term256: 12} ColorLightMagenta = Color{Term256: 13} ColorLightCyan = Color{Term256: 14} ColorWhite = Color{Term256: 15} )
colors is a palette where the index corresponds to a 8 bit terminal color palette (i.e. 256 colors)
Functions ¶
func DisableEcho ¶
func DisableEcho()
func EnableEcho ¶
func EnableEcho()
func HideCursor ¶
func HideCursor()
func InitColors ¶
InitColors initializes 'Colors' (the terminal emulator color palette) with 'num' colors. Accepted num values are 8, 16, 256. Returns a boolean indicating success or failure. If 'num' is not one of the accepted values, 256 colors are initialized and false is returned.
func ShowCursor ¶
func ShowCursor()
Types ¶
type Canvas ¶
type Canvas struct { // Width is the width of the canvas Width int // Height is the height of the canvas Height int // Logger can be used for debugging purposes. Logger *log.Logger Background Color // CursorOnEnd will move the cursor to (x-Max, y-Max) when Flush() // is invoked. This comes in handy if you want the user prompt to // show up right after the canvas (as opposed to somewhere in // between), when there is an abrupt termination. CursorOnEnd bool // contains filtered or unexported fields }
Canvas is a representation of a painting canvas on a terminal that supports 256 colors. The canvas is rendered in-line.
It provides functions to manipulate the canvas and thread-safe implementations of the same functions as well. If you don't intend to use this in a multi-threaded fashion, then use the non thread-safe functions as they offer better performance which is critical in animation and gaming applications.
func (*Canvas) SetBackground ¶
func (*Canvas) SetBackgroundSafe ¶
func (*Canvas) SetForeground ¶
func (*Canvas) SetForegroundSafe ¶
func (*Canvas) SetStyleSafe ¶
func (*Canvas) WriteAtSafe ¶
type Color ¶
type Color struct { // RGBA defines a standard color value defined as R,G,B,A. The // system will pick the closest color on a terminal that supports // 256 colors. RGBA color.Color // Term256 can be used to specify one of the 256 terminal colors // on a terminal that supports 256 colors. This value will be used // only if RGBA is nil. Term256 uint8 // contains filtered or unexported fields }
Color defines a color either expressed as an RGBA value or as one of the 256 colors on a terminal that supports 256 colors.
func ColorRandom ¶
func ColorRandom() Color