mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-10-20 20:22:10 +00:00
Dont allow abort while waiting for query response
This commit is contained in:
parent
22d69d24d0
commit
31df90a64e
1 changed files with 17 additions and 0 deletions
|
|
@ -131,6 +131,8 @@ func print_error(format string, args ...any) {
|
|||
fmt.Fprintf(os.Stderr, format, args...)
|
||||
fmt.Fprintln(os.Stderr)
|
||||
} else {
|
||||
lp.QueueWriteString("\r")
|
||||
lp.ClearToEndOfLine()
|
||||
lp.QueueWriteString(fmt.Sprintf(format, args...))
|
||||
lp.QueueWriteString("\r\n")
|
||||
}
|
||||
|
|
@ -308,6 +310,21 @@ func on_wakeup() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func on_key_event(event *loop.KeyEvent) error {
|
||||
if event.MatchesPressOrRepeat("ctrl+c") {
|
||||
event.Handled = true
|
||||
if query_in_flight {
|
||||
print_error("Waiting for response from terminal, aborting now could lead to corruption")
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Aborted by user")
|
||||
}
|
||||
if event.MatchesPressOrRepeat("ctrl+z") {
|
||||
event.Handled = true
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func main(cmd *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||
opts = o
|
||||
err = parse_place()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue