Raw mode swallowing characters
This commit is contained in:
parent
5f143cc5f0
commit
9de97f995b
23
gilo.go
23
gilo.go
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user