Merges 2.0.0 into master for final release #106

Manually merged
sloum merged 195 commits from develop into master 2019-12-01 17:10:03 +00:00
2 changed files with 19 additions and 16 deletions
Showing only changes of commit e32ba04a1a - Show all commits

View File

@ -56,26 +56,29 @@ func moveCursorToward(dir string, amount int) {
}
}
// Exit performs cleanup operations before exiting the application
func Exit() {
CleanupTerm()
os.Exit(0)
}
// InitTerm sets the terminal modes appropriate for Bombadillo
func InitTerm() {
SetCharMode()
Tput("rmam") // turn off line wrapping
Tput("smcup") // use alternate screen
}
// CleanupTerm reverts changs to terminal mode made by InitTerm
func CleanupTerm() {
moveCursorToward("down", 500)
moveCursorToward("right", 500)
SetLineMode()
fmt.Print("\n")
fmt.Print("\033[?25h")
Tput("smam") // turn on line wrap
Tput("rmcup") // stop using alternate screen
fmt.Print("\033[?25h") // reenables cursor blinking
Tput("smam") // turn on line wrap
Tput("rmcup") // stop using alternate screen
}
func Clear(dir string) {

26
main.go
View File

@ -149,20 +149,20 @@ func initClient() error {
// In the event of specific signals, ensure the display is shown correctly.
// Accepts a signal, blocking until it is received. Once not blocked, corrects
// terminal display settings. Loops indefinitely, does not return.
// terminal display settings as appropriate for that signal. Loops
// indefinitely, does not return.
func handleSignals(c <-chan os.Signal) {
switch <-c {
case syscall.SIGTSTP:
cui.CleanupTerm()
//TODO: getting stuck here
// SIGSTOP seems to be the right signal, but the process
// does not recover?
syscall.Kill(syscall.Getpid(), syscall.SIGSTOP)
case syscall.SIGCONT:
cui.InitTerm()
bombadillo.Draw()
case syscall.SIGINT:
cui.Exit()
for {
switch <-c {
case syscall.SIGTSTP:
cui.CleanupTerm()
syscall.Kill(syscall.Getpid(), syscall.SIGSTOP)
case syscall.SIGCONT:
cui.InitTerm()
bombadillo.Draw()
case syscall.SIGINT:
cui.Exit()
}
}
}