Implement --exit-on flag for dnd kitten
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/b6835902-79c3-4d14-9761-8633073db808 Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
This commit is contained in:
parent
74787a60d7
commit
13898e73f2
3 changed files with 21 additions and 1 deletions
|
|
@ -227,7 +227,11 @@ func (dnd *dnd) on_drag_event(x, y, operation, Y int) (err error) {
|
|||
case 3:
|
||||
dnd.drag_status.dropped = true
|
||||
case 4:
|
||||
was_dropped := dnd.drag_status.dropped
|
||||
dnd.reset_drag()
|
||||
if was_dropped && dnd.has_exit_on("drag-finish") {
|
||||
dnd.lp.Quit(0)
|
||||
}
|
||||
case 5:
|
||||
if err = dnd.handle_data_request(y, Y == 1); err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -467,6 +467,9 @@ func (dnd *dnd) end_drop(success bool) {
|
|||
}
|
||||
}
|
||||
dnd.reset_drop()
|
||||
if success && dnd.has_exit_on("drop-finish") {
|
||||
dnd.lp.Quit(0)
|
||||
}
|
||||
}
|
||||
|
||||
func (dnd *dnd) all_drop_data_received() (err error) {
|
||||
|
|
|
|||
|
|
@ -103,6 +103,15 @@ func (dnd *dnd) send_test_response(payload string) {
|
|||
dnd.lp.DebugPrintln(payload)
|
||||
}
|
||||
|
||||
func (dnd *dnd) has_exit_on(event string) bool {
|
||||
for _, e := range strings.Split(dnd.opts.ExitOn, ",") {
|
||||
if strings.TrimSpace(e) == event {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (dnd *dnd) setup_base_dir(base_dir string) (err error) {
|
||||
if dnd.drop_output_dir != nil {
|
||||
dnd.drop_output_dir.Close()
|
||||
|
|
@ -281,7 +290,11 @@ func (dnd *dnd) run_loop() (err error) {
|
|||
return dnd.drop_confirm(true)
|
||||
}
|
||||
}
|
||||
if e.MatchesPressOrRepeat("ctrl+c") || e.MatchesPressOrRepeat("esc") {
|
||||
if e.MatchesPressOrRepeat("ctrl+c") {
|
||||
dnd.lp.Quit(0)
|
||||
return
|
||||
}
|
||||
if e.MatchesPressOrRepeat("esc") && dnd.has_exit_on("esc-key") {
|
||||
dnd.lp.Quit(0)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue