feat: add hilbish.cancel hook (closes #213)

cleanup
TorchedSammy 2022-11-25 19:21:36 -04:00
parent ef3e7d92bc
commit ff4609e432
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
3 changed files with 8 additions and 2 deletions

View File

@ -76,6 +76,7 @@ disables commands being added to history.
random errors introduced with the new Lua runtime (see [#197])
- `bait.release(name, catcher)` removes `handler` for the named `event`
- `exec`, `clear` and `cat` builtin commands
- `hilbish.cancel` hook
[#197]: https://github.com/Rosettea/Hilbish/issues/197

View File

@ -5,3 +5,5 @@
+ `hilbish.vimAction` -> actionName, args > Sent when the user does a "vim action," being something
like yanking or pasting text. See `doc vim-mode actions` for more info.
+ `hilbish.cancel` > Sent when the user cancels their input with Ctrl-C.

View File

@ -181,11 +181,14 @@ input:
break
}
if err != nil {
if err != readline.CtrlC {
if err == readline.CtrlC {
fmt.Println("^C")
hooks.Emit("hilbish.cancel")
} else {
// If we get a completely random error, print
fmt.Fprintln(os.Stderr, err)
}
fmt.Println("^C")
// TODO: Halt if any other error occurs
continue
}
var priv bool