From d1037072b04cce9aa173308937c944fc4cdeba08 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 20 Nov 2023 20:38:34 +0100 Subject: [PATCH] rc tools menu: add -on-abort switch Along -select-cmds this is useful to implement preview functionality. --- rc/tools/menu.kak | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rc/tools/menu.kak b/rc/tools/menu.kak index 8615afe0..4fd7dde4 100644 --- a/rc/tools/menu.kak +++ b/rc/tools/menu.kak @@ -11,11 +11,13 @@ define-command menu -params 1.. -docstring %{ auto_single=false select_cmds=false stride=2 + on_abort= while true do case "$1" in (-auto-single) auto_single=true ;; (-select-cmds) select_cmds=true; stride=3 ;; + (-on-abort) on_abort="$2"; shift ;; (-markup) ;; # no longer supported (*) break ;; esac @@ -73,6 +75,9 @@ define-command menu -params 1.. -docstring %{ ¶ §" "$select_cases" fi + if [ -n "$on_abort" ]; then + printf " -on-abort '%s'" "$(printf %s "$on_abort" | sed "s/'/''/g")" + fi printf ' -menu -shell-script-candidates %%§ printf %%s %s §\n' "$(shellquote "$completion")"