package editor import ( "bufio" "timshome.page/gilo/internal/char" "timshome.page/gilo/internal/terminal" ) func readKey(reader *bufio.Reader) (rune, int) { ch, size, err := reader.ReadRune() if err != nil { panic(err) } return ch, size } func ProcessKeypress(reader *bufio.Reader) bool { ch, _ := readKey(reader) // Ugliest syntax structure ever? switch { case ch == char.Ctrl('q'): terminal.OutLn("bye!") return false case char.IsCtrl(ch): terminal.OutLn("%d", ch) default: terminal.OutLn("%d ('%c')", ch, ch) } return true }