Des menus dans votre terminal - retour accueil
git clone git://bebou.netlib.re/zenu
Log | Files | Refs |
commit aa6044a4df77898ae5d556f3e1fa818b184b3c8e parent 7618449068bc1b07a81a71e84dfda2ebbe73457f Auterice: Marc Chantreux <mc@unistra.fr> Date: Fri, 30 Jun 2023 22:30:38 +0200 zenu.ends_with it's now possible for a widget to escape the loop Diffstat:
M | zenu.zsh | | | 17 | +++++++++++++---- |
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/zenu.zsh b/zenu.zsh @@ -31,18 +31,26 @@ zenu.update() { . $1.script } +# TODO: doc +# ZENU_HOOK_END: a code to execute while leaving the loop +# ZENU_AGAIN (bool) : run the loop again + +zenu.ends_with() { + ZENU_HOOK_END="$*" + ZENU_AGAIN=false +} + zenu.loop() { - local -a zenu_stack - zenu_stack=( main ) + local zenu_stack=( main ) + local ZENU_AGAIN=true local zenu_base= zenu_key= while (( $# )) { case "$1" in (from) zenu_stack=($2) ; shift 2 ;; (in) zenu_base=$2 ; shift 2 - ;; (*) >&2 echo "not a valid key $1"; return 1 esac } - while {true} { + while {eval $ZENU_AGAIN} { clear case $#zenu_stack in (0) return @@ -60,5 +68,6 @@ zenu.loop() { . $c.script esac } + eval "${ZENU_HOOK_END:-:}" }