1
0
Fork 0

Raw mode swallowing characters

This commit is contained in:
Timothy Warren 2021-03-18 19:15:19 -04:00
parent 5f143cc5f0
commit 9de97f995b
1 changed files with 22 additions and 1 deletions

23
gilo.go
View File

@ -1,12 +1,16 @@
package main package main
import ( import (
"bufio"
"fmt"
"golang.org/x/term" "golang.org/x/term"
"os" "os"
) )
func goRaw() (*term.State, error) { func goRaw() (*term.State, error) {
return term.MakeRaw(int(os.Stdin.Fd())) state, err := term.MakeRaw(int(os.Stdin.Fd()))
return state, err
} }
func main() { func main() {
@ -16,4 +20,21 @@ func main() {
} }
defer term.Restore(int(os.Stdin.Fd()), oldState) defer term.Restore(int(os.Stdin.Fd()), oldState)
reader := bufio.NewReader(os.Stdin)
for {
char, _, err := reader.ReadRune()
if err != nil {
panic(err)
}
switch {
}
if char == 'q' {
fmt.Println("bye!\r")
return
}
}
} }