toolbox/tui/output.go

36 lines
530 B
Go

package tui
import (
"fmt"
)
// Clear clears the terminal.
func Clear() {
_, h := TermSize()
buf := make([]byte, 2*h)
for i := range buf {
buf[i] = '\n'
}
mustWrite(buf)
}
// Write sends raw bytes to the terminal.
func Write(b []byte) {
mustWrite(b)
}
func Print(a ...interface{}) {
s := fmt.Sprint(a...)
mustWrite([]byte(s))
}
func Println(a ...interface{}) {
s := fmt.Sprintln(a...)
mustWrite([]byte(s))
}
func Printf(format string, a ...interface{}) {
s := fmt.Sprintf(format, a...)
mustWrite([]byte(s))
}