cli/cmd/termsize/main.go

41 lines
740 B
Go

package main
import "surdeus.su/core/cli/tx"
import "log"
import "os"
import "io"
import "surdeus.su/core/cli/aes"
//import "fmt"
func main() {
term, err := tx.NewTerminal(os.Stdin)
if err != nil {
// Some not terminal handling.
log.Fatal("tx.NewTerminal(...): %s\n", err)
}
term.MakeRaw()
defer term.Restore()
w, h, err := term.GetSize()
if err != nil {
log.Fatalf("term.GetSize(...): %s\n", err)
}
term.Printf("TermSize: %dx%d\r\n", w, h)
for {
key, _, err := term.ReadKey()
if err != nil {
if err == io.EOF {
break
}
log.Fatalf("term.ReadLine(...): %s\n", err)
}
if key == tx.KeyControlC {
break
}
term.Print(
"shit:", aes.ETF("%q", key).Bold().With(aes.EffectRedFG), "\r\n",
)
}
}