From b94faafa111dbec1b5cc45fb588f9258b4ca5abc Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 22 Aug 2023 18:06:57 +0200 Subject: [PATCH] gui: Remember menu position. That's generally the expected behaviour, and it's not too hard to implement. We let _gsu_menu() take an additional argument for the default item and maintain its value in _browse(). --- gui | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/gui b/gui index 72ddb28..fbcbb01 100644 --- a/gui +++ b/gui @@ -95,14 +95,14 @@ gsu_msgbox() _gsu_menu() { - local header="${1:-root}" - local items="$2" + local header=${1:-root} dflt_item=$2 items=$3 local geom _get_geometry geom=$result - result="$(dialog --no-lines --no-items --menu \ - "$gsu_banner_txt ($header)" \ + result="$(dialog --no-lines --no-items \ + --default-item "$dflt_item" \ + --menu "$gsu_banner_txt ($header)" \ $geom 16 $items 3>&1 1>&2 2>&3 3>&-)" _set_dialog_ret $? } @@ -154,12 +154,14 @@ _get_root_nodes() _browse() { - local header="$1" old_header - local tree="$2" subtree="$3" + local header=$1 tree=$2 + local -a subtree=($3) + local old_header dflt_item=${subtree[0]} while :; do - _gsu_menu "$header" "$subtree" + _gsu_menu "$header" "$dflt_item" "${subtree[*]}" ((ret < 0)) && return + dflt_item=$result [[ -z "$result" ]] && return # menu was cancelled if [[ "${result%/}" != "$result" ]]; then old_header="$header" -- 2.39.5