Timothy J. Warren
bd9a07feed
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good
43 lines
742 B
Go
43 lines
742 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"golang.org/x/term"
|
|
"os"
|
|
"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()
|
|
|
|
// If there is an argument passed, open it as a file to edit
|
|
if len(os.Args) >= 2 && os.Args[1] != "" {
|
|
e.Open(os.Args[1])
|
|
}
|
|
|
|
e.SetStatusMessage("HELP: Ctrl-Q = quit");
|
|
|
|
// The input loop
|
|
for {
|
|
e.RefreshScreen()
|
|
|
|
if e.ProcessKeypress() == false {
|
|
break
|
|
}
|
|
}
|
|
}
|