Inital try at handling SIGCONT

This commit is contained in:
asdf 2019-10-10 17:05:50 +11:00
parent 282bd9d246
commit 86485154c9
1 changed files with 25 additions and 7 deletions

22
main.go
View File

@ -1,4 +1,5 @@
package main
// Bombadillo is a gopher and gemini client for the terminal of unix or unix-like systems.
//
// Copyright (C) 2019 Brian Evans
@ -16,17 +17,18 @@ package main
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import (
"flag"
"fmt"
"io/ioutil"
"os"
"os/signal"
"strings"
"syscall"
_ "tildegit.org/sloum/bombadillo/gemini"
"tildegit.org/sloum/bombadillo/config"
"tildegit.org/sloum/bombadillo/cui"
_ "tildegit.org/sloum/bombadillo/gemini"
"tildegit.org/sloum/mailcap"
)
@ -144,6 +146,17 @@ func initClient() error {
return err
}
// On SIGCONT, ensure the terminal is still in the correct mode
// Accepts the signal, does the work, then starts another instance
// to handle any future occurences of SIGCONT
func handleSIGCONT(c <-chan os.Signal) {
<-c
cui.Tput("rmam") // turn off line wrapping
cui.Tput("smcup") // use alternate screen
cui.SetCharMode()
go handleSIGCONT(c)
}
func main() {
getVersion := flag.Bool("v", false, "See version number")
flag.Parse()
@ -153,6 +166,11 @@ func main() {
}
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
// So that we can open files from gemini
mc = mailcap.NewMailcap()