1
0
Fork 0

Try out recover for panic calls

This commit is contained in:
Timothy Warren 2021-03-25 13:55:17 -04:00
parent 0d5f2d0fcc
commit c02206233c
1 changed files with 12 additions and 1 deletions

13
gilo.go
View File

@ -1,14 +1,25 @@
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 terminal.RawOff(oldState)
defer cleanup(oldState)
e := editor.New()