fixes screen display properly, better start location

This commit is contained in:
asdf 2019-10-11 12:04:19 +11:00
parent 86485154c9
commit 6faf4e5205
1 changed files with 15 additions and 13 deletions

28
main.go
View File

@ -146,15 +146,17 @@ func initClient() error {
return err return err
} }
// On SIGCONT, ensure the terminal is still in the correct mode // In the event of SIGCONT, ensure the display is shown correctly. Accepts a
// Accepts the signal, does the work, then starts another instance // signal, blocking until it is received. Once not blocked, corrects terminal
// to handle any future occurences of SIGCONT // display settings. Loops indefinitely, does not return.
func handleSIGCONT(c <-chan os.Signal) { func handleSIGCONT(c <-chan os.Signal) {
<-c for {
cui.Tput("rmam") // turn off line wrapping <-c
cui.Tput("smcup") // use alternate screen cui.Tput("rmam") // turn off line wrapping
cui.SetCharMode() cui.Tput("smcup") // use alternate screen
go handleSIGCONT(c) cui.SetCharMode()
bombadillo.Draw()
}
} }
func main() { func main() {
@ -166,11 +168,6 @@ func main() {
} }
args := flag.Args() args := flag.Args()
// buffered channel to capture SIGCONT for handling
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGCONT)
go handleSIGCONT(c)
// Build the mailcap db // Build the mailcap db
// So that we can open files from gemini // So that we can open files from gemini
mc = mailcap.NewMailcap() mc = mailcap.NewMailcap()
@ -184,6 +181,11 @@ func main() {
panic(err) panic(err)
} }
// watch for SIGCONT, send it to be handled
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGCONT)
go handleSIGCONT(c)
// Start polling for terminal size changes // Start polling for terminal size changes
go bombadillo.GetSize() go bombadillo.GetSize()