mirror of https://github.com/Hilbis/Hilbish
fix: resize if terminal has been resized during running command and fix readline segfault
parent
6ac4aa50b3
commit
d270e8f66b
17
main.go
17
main.go
|
@ -34,6 +34,9 @@ var (
|
||||||
hooks bait.Bait
|
hooks bait.Bait
|
||||||
defaultConfPath string
|
defaultConfPath string
|
||||||
defaultHistPath string
|
defaultHistPath string
|
||||||
|
|
||||||
|
resized bool
|
||||||
|
started bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -167,6 +170,7 @@ func main() {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
started = true
|
||||||
input:
|
input:
|
||||||
for interactive {
|
for interactive {
|
||||||
running = false
|
running = false
|
||||||
|
@ -174,6 +178,11 @@ input:
|
||||||
lr.SetPrompt(fmtPrompt())
|
lr.SetPrompt(fmtPrompt())
|
||||||
input, err := lr.Read()
|
input, err := lr.Read()
|
||||||
|
|
||||||
|
if resized {
|
||||||
|
resized = false
|
||||||
|
lr.Resize()
|
||||||
|
}
|
||||||
|
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
// Exit if user presses ^D (ctrl + d)
|
// Exit if user presses ^D (ctrl + d)
|
||||||
break
|
break
|
||||||
|
@ -270,8 +279,12 @@ func HandleSignals() {
|
||||||
}
|
}
|
||||||
case syscall.SIGWINCH:
|
case syscall.SIGWINCH:
|
||||||
hooks.Em.Emit("signals.resize")
|
hooks.Em.Emit("signals.resize")
|
||||||
if !running && interactive {
|
if interactive {
|
||||||
lr.Resize()
|
if !running && started {
|
||||||
|
lr.Resize()
|
||||||
|
} else {
|
||||||
|
resized = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue