This repository has been archived on 2021-03-25. You can view files and clone it, but cannot push or open issues/pull-requests.
2021-03-24 11:21:06 +00:00
|
|
|
package tui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2021-03-25 10:21:12 +00:00
|
|
|
// Clear clears the terminal.
|
2021-03-24 11:21:06 +00:00
|
|
|
func Clear() {
|
2021-03-25 10:21:12 +00:00
|
|
|
_, h := TermSize()
|
2021-03-24 11:21:06 +00:00
|
|
|
buf := make([]byte, 2*h)
|
|
|
|
for i := range buf {
|
|
|
|
buf[i] = '\n'
|
|
|
|
}
|
|
|
|
mustWrite(buf)
|
|
|
|
}
|
|
|
|
|
2021-03-25 10:21:12 +00:00
|
|
|
// Write sends raw bytes to the terminal.
|
|
|
|
func Write(b []byte) {
|
|
|
|
mustWrite(b)
|
2021-03-24 11:21:06 +00:00
|
|
|
}
|
|
|
|
|
2021-03-25 10:21:12 +00:00
|
|
|
func Print(a ...interface{}) {
|
|
|
|
s := fmt.Sprint(a...)
|
|
|
|
mustWrite([]byte(s))
|
2021-03-24 11:21:06 +00:00
|
|
|
}
|
|
|
|
|
2021-03-25 10:21:12 +00:00
|
|
|
func Println(a ...interface{}) {
|
|
|
|
s := fmt.Sprintln(a...)
|
|
|
|
mustWrite([]byte(s))
|
2021-03-24 11:21:06 +00:00
|
|
|
}
|
|
|
|
|
2021-03-25 10:21:12 +00:00
|
|
|
func Printf(format string, a ...interface{}) {
|
|
|
|
s := fmt.Sprintf(format, a...)
|
|
|
|
mustWrite([]byte(s))
|
2021-03-24 11:21:06 +00:00
|
|
|
}
|