mirror of https://github.com/Hilbis/Hilbish
feat: add hilbish.cancel hook (closes #213)
parent
ef3e7d92bc
commit
ff4609e432
|
@ -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
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
7
main.go
7
main.go
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue