Documentation
¶
Overview ¶
Package tty provides primitives to communicate with the terminal
tty.Open()
defer tty.Close()
rows, cols, err := tty.Dimensions()
tty.MoveTo(2, 1)
tty.SetDefaultColor()
tty.SetBgColor(20, 133, 204)
tty.SetFgColor(178, 18, 18)
tty.SetBold()
tty.SetUnderscore()
tty.SetReverse()
tty.SetBlink()
tty.Write([]byte("Bold"))
Index ¶
- func Clean()
- func Close() error
- func Dimensions() (height, width int, err error)
- func EraseLine()
- func Flush() (n int, e error)
- func MoveTo(line, pos int)
- func Open() (err error)
- func Read(data []byte) (n int, e error)
- func SetBgColor(r, g, b int)
- func SetBlink()
- func SetBold()
- func SetDefaultBgColor()
- func SetDefaultColor()
- func SetDefaultFgColor()
- func SetFgColor(r, g, b int)
- func SetNoBlink()
- func SetNormal()
- func SetReverse()
- func SetUnderscore()
- func Write(data []byte) (n int, e error)
- type Tty
- func (t *Tty) Clean()
- func (t *Tty) Close() error
- func (t *Tty) Dimensions() (height, width int, err error)
- func (t *Tty) EraseLine()
- func (t *Tty) Flush() (n int, e error)
- func (t *Tty) MoveTo(line, pos int)
- func (t *Tty) Open() (err error)
- func (t *Tty) Read(data []byte) (n int, e error)
- func (t *Tty) SetBgColor(r, g, b int)
- func (t *Tty) SetBlink()
- func (t *Tty) SetBold()
- func (t *Tty) SetDefaultBgColor()
- func (t *Tty) SetDefaultColor()
- func (t *Tty) SetDefaultFgColor()
- func (t *Tty) SetFgColor(r, g, b int)
- func (t *Tty) SetNoBlink()
- func (t *Tty) SetNormal()
- func (t *Tty) SetReverse()
- func (t *Tty) SetUnderscore()
- func (t *Tty) Write(data []byte) (n int, e error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dimensions ¶
Dimensions returns terminal dimensions
func MoveTo ¶
func MoveTo(line, pos int)
MoveTo makes the next text to be writen in a specific position
func Read ¶
Read reads data from for Stdout If InputDelay is different than 0, a buffer will be use and a call to Read will not imply a call to Stdin.Read
func SetBgColor ¶
func SetBgColor(r, g, b int)
SetBgColor set the background color for the next text to be writen
func SetDefaultBgColor ¶
func SetDefaultBgColor()
SetDefaultBgColor makes the next text to be writen to use the default Background color
func SetDefaultColor ¶
func SetDefaultColor()
SetDefaultColor is the same as calling SetDefaultFgColor and SetDefaultBgColor
func SetDefaultFgColor ¶
func SetDefaultFgColor()
SetDefaultFgColor makes the next text to be writen to use the default Foreground color
func SetFgColor ¶
func SetFgColor(r, g, b int)
SetFgColor set the foreground color for the next text to be writen
func SetNormal ¶
func SetNormal()
SetNormal disables Bold Underlink Reverse and Blink for the next text to be writen
func SetReverse ¶
func SetReverse()
SetReverse makes the next text to be writen to be with reversed colors
func SetUnderscore ¶
func SetUnderscore()
SetUnderscore makes the next text to be writen to have underscore
Types ¶
type Tty ¶
type Tty struct {
// InputDelay is the amount of time that Read should wait to complete the read.
// While sending escape sequences is not the same \027 that is the Esc key than
// \027 ... that is ...
// If InputDelay is 0, it will return immediately
InputDelay time.Duration
// Stdin is the file where the Read function will read from.
// It defaults to os.Stdin
Stdin *os.File
// Stdout is the file where the Write function will write to.
// It defaults to os.Stdout
Stdout *os.File
// Fps is the maximum number of times that the write function will be called in
// Stdout during a second
// If Fps is 0 Writes are sync
Fps int
// ManualFlush prevents Write to behave synchronously
// If ManualFlush is set to true you should call Flush for your writes to be dump
ManualFlush bool
// contains filtered or unexported fields
}
Tty represent a terminal
var DefaultTty *Tty
DefaultTty is automatically associated with the current Stdin and Stdout
func (*Tty) Dimensions ¶
Dimensions returns terminal dimensions
func (*Tty) Read ¶
Read reads data from for Stdout If InputDelay is different than 0, a buffer will be use and a call to Read will not imply a call to Stdin.Read
func (*Tty) SetBgColor ¶
SetBgColor set the background color for the next text to be writen
func (*Tty) SetDefaultBgColor ¶
func (t *Tty) SetDefaultBgColor()
SetDefaultBgColor makes the next text to be writen to use the default Background color
func (*Tty) SetDefaultColor ¶
func (t *Tty) SetDefaultColor()
SetDefaultColor is the same as calling SetDefaultFgColor and SetDefaultBgColor
func (*Tty) SetDefaultFgColor ¶
func (t *Tty) SetDefaultFgColor()
SetDefaultFgColor makes the next text to be writen to use the default Foreground color
func (*Tty) SetFgColor ¶
SetFgColor set the foreground color for the next text to be writen
func (*Tty) SetNoBlink ¶
func (t *Tty) SetNoBlink()
SetNoBlink makes next text to be writen not to blink
func (*Tty) SetNormal ¶
func (t *Tty) SetNormal()
SetNormal disables Bold Underlink Reverse and Blink for the next text to be writen
func (*Tty) SetReverse ¶
func (t *Tty) SetReverse()
SetReverse makes the next text to be writen to be with reversed colors
func (*Tty) SetUnderscore ¶
func (t *Tty) SetUnderscore()
SetUnderscore makes the next text to be writen to have underscore