mirror of https://github.com/Hilbis/Hilbish
feat: add signal hooks for sigint and sigwinch (#80)
parent
94a8b4ad47
commit
af4c3885ae
7
lua.go
7
lua.go
|
@ -59,6 +59,13 @@ func LuaInit() {
|
||||||
hooks = bait.New()
|
hooks = bait.New()
|
||||||
l.PreloadModule("bait", hooks.Loader)
|
l.PreloadModule("bait", hooks.Loader)
|
||||||
|
|
||||||
|
// Add Ctrl-C handler
|
||||||
|
hooks.Em.On("signal.sigint", func() {
|
||||||
|
if !interactive {
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
l.SetGlobal("complete", l.NewFunction(hshcomplete))
|
l.SetGlobal("complete", l.NewFunction(hshcomplete))
|
||||||
|
|
||||||
// Add more paths that Lua can require from
|
// Add more paths that Lua can require from
|
||||||
|
|
5
main.go
5
main.go
|
@ -265,13 +265,12 @@ func HandleSignals() {
|
||||||
for s := range c {
|
for s := range c {
|
||||||
switch s {
|
switch s {
|
||||||
case os.Interrupt:
|
case os.Interrupt:
|
||||||
|
hooks.Em.Emit("signals.sigint")
|
||||||
if !running {
|
if !running {
|
||||||
if !interactive {
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
lr.ClearInput()
|
lr.ClearInput()
|
||||||
}
|
}
|
||||||
case syscall.SIGWINCH:
|
case syscall.SIGWINCH:
|
||||||
|
hooks.Em.Emit("signals.resize")
|
||||||
if !running {
|
if !running {
|
||||||
lr.Resize()
|
lr.Resize()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue