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"
"io"
"os"
"runtime"
"strings"
"os/signal"
"os/user"
"path/filepath"
"runtime"
"strings"
"syscall"
"hilbish/golibs/bait"
"github.com/pborman/getopt"
"github.com/yuin/gopher-lua"
"layeh.com/gopher-luar"
"golang.org/x/term"
"layeh.com/gopher-luar"
)
var (
@ -258,14 +259,21 @@ func fmtPrompt() string {
// do i even have to say
func HandleSignals() {
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt)
signal.Notify(c, os.Interrupt, syscall.SIGWINCH)
for range c {
if !running {
if !interactive {
os.Exit(0)
for s := range c {
switch s {
case os.Interrupt:
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
package main
@ -41,3 +42,6 @@ func (lr *LineReader) ClearInput() {
readline.RefreshLine()
}
func (lr *LineReader) Resize() {
readline.Resize()
}

View File

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