package editor import ( "timshome.page/gilo/internal/char" "timshome.page/gilo/internal/terminal" ) type Editor struct { rows int cols int } func drawRows() { _, rows := terminal.Size() for y :=0; y < rows; y += 1 { terminal.OutLn("~") } } func RefreshScreen() { terminal.ANSICode(terminal.ClearScreen) terminal.ANSICode(terminal.ResetCursor) drawRows() terminal.ANSICode(terminal.ResetCursor) } func ProcessKeypress() bool { ch, _ := terminal.ReadKey() // Clean up on exit if ch == char.Ctrl('q') { terminal.ANSICode(terminal.ClearScreen) terminal.ANSICode(terminal.ResetCursor) return false } // Ugliest syntax structure ever? switch { case char.IsCtrl(ch): terminal.OutLn("%d", ch) default: terminal.OutLn("%d ('%c')", ch, ch) } return true }