package main import ( "fmt" "golang.org/x/term" "timshome.page/gilo/editor" "timshome.page/gilo/terminal" ) func cleanup(oldState *term.State) { defer terminal.RawOff(oldState) // Recover from panic to allow restoring terminal state if a := recover(); a != nil { fmt.Println("RECOVER", a) } } func main() { // Go to proper raw mode, but restore canonical mode at exit oldState := terminal.RawOn() defer cleanup(oldState) e := editor.New() e.Open() // The input loop for { e.RefreshScreen() if e.ProcessKeypress() == false { break } } }