Merge branch 'copilot/implement-exit-on-flag' of https://github.com/kovidgoyal/kitty

This commit is contained in:
Kovid Goyal
2026-05-05 21:17:45 +05:30
3 changed files with 21 additions and 1 deletions

View File

@@ -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

View File

@@ -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) {

View File

@@ -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
}