mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-09-20 02:57:19 +03:00
Dont allow abort while waiting for query response
This commit is contained in:
parent
22d69d24d0
commit
31df90a64e
@ -131,6 +131,8 @@ func print_error(format string, args ...any) {
|
|||||||
fmt.Fprintf(os.Stderr, format, args...)
|
fmt.Fprintf(os.Stderr, format, args...)
|
||||||
fmt.Fprintln(os.Stderr)
|
fmt.Fprintln(os.Stderr)
|
||||||
} else {
|
} else {
|
||||||
|
lp.QueueWriteString("\r")
|
||||||
|
lp.ClearToEndOfLine()
|
||||||
lp.QueueWriteString(fmt.Sprintf(format, args...))
|
lp.QueueWriteString(fmt.Sprintf(format, args...))
|
||||||
lp.QueueWriteString("\r\n")
|
lp.QueueWriteString("\r\n")
|
||||||
}
|
}
|
||||||
@ -308,6 +310,21 @@ func on_wakeup() error {
|
|||||||
return nil
|
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) {
|
func main(cmd *cli.Command, o *Options, args []string) (rc int, err error) {
|
||||||
opts = o
|
opts = o
|
||||||
err = parse_place()
|
err = parse_place()
|
||||||
|
Loading…
Reference in New Issue
Block a user