Raw mode swallowing characters

This commit is contained in:
Timothy Warren 2021-03-18 19:15:19 -04:00
parent 5f143cc5f0
commit 9de97f995b

23
gilo.go
View File

@ -1,12 +1,16 @@
package main
import (
"bufio"
"fmt"
"golang.org/x/term"
"os"
)
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() {
@ -16,4 +20,21 @@ func main() {
}
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
}
}
}