1
0
Fork 0
gilo/gilo.go

39 lines
494 B
Go
Raw Normal View History

2021-03-18 16:30:04 -04:00
package main
import (
2021-03-18 19:15:19 -04:00
"bufio"
"fmt"
2021-03-18 16:30:04 -04:00
"golang.org/x/term"
"os"
)
func goRaw() (*term.State, error) {
2021-03-18 19:15:19 -04:00
state, err := term.MakeRaw(int(os.Stdin.Fd()))
return state, err
2021-03-18 16:30:04 -04:00
}
func main() {
oldState, err := goRaw()
if err != nil {
panic(err)
}
defer term.Restore(int(os.Stdin.Fd()), oldState)
2021-03-18 19:15:19 -04:00
reader := bufio.NewReader(os.Stdin)
for {
char, _, err := reader.ReadRune()
if err != nil {
panic(err)
}
switch {
2021-03-19 08:45:33 -04:00
case char == 'q':
2021-03-18 19:15:19 -04:00
fmt.Println("bye!\r")
return
}
}
2021-03-18 16:30:04 -04:00
}