fix: only resize term if not running command

dev
TorchedSammy 2021-11-22 10:41:27 -05:00
parent 5a258ce68e
commit 77cc7fe24a
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
3 changed files with 25 additions and 9 deletions

26
main.go
View File

@ -5,18 +5,19 @@ import (
"fmt" "fmt"
"io" "io"
"os" "os"
"runtime"
"strings"
"os/signal" "os/signal"
"os/user" "os/user"
"path/filepath" "path/filepath"
"runtime"
"strings"
"syscall"
"hilbish/golibs/bait" "hilbish/golibs/bait"
"github.com/pborman/getopt" "github.com/pborman/getopt"
"github.com/yuin/gopher-lua" "github.com/yuin/gopher-lua"
"layeh.com/gopher-luar"
"golang.org/x/term" "golang.org/x/term"
"layeh.com/gopher-luar"
) )
var ( var (
@ -258,14 +259,21 @@ func fmtPrompt() string {
// do i even have to say // do i even have to say
func HandleSignals() { func HandleSignals() {
c := make(chan os.Signal) c := make(chan os.Signal)
signal.Notify(c, os.Interrupt) signal.Notify(c, os.Interrupt, syscall.SIGWINCH)
for range c { for s := range c {
if !running { switch s {
if !interactive { case os.Interrupt:
os.Exit(0) if !running {
if !interactive {
os.Exit(0)
}
lr.ClearInput()
}
case syscall.SIGWINCH:
if !running {
lr.Resize()
} }
lr.ClearInput()
} }
} }
} }

4
rl.go
View File

@ -1,3 +1,4 @@
//go:build !hilbiline
// +build !hilbiline // +build !hilbiline
package main package main
@ -41,3 +42,6 @@ func (lr *LineReader) ClearInput() {
readline.RefreshLine() readline.RefreshLine()
} }
func (lr *LineReader) Resize() {
readline.Resize()
}

View File

@ -37,3 +37,7 @@ func (lr *LineReader) ClearInput() {
return return
} }
func (lr *LineReader) Resize() {
return
}