From: Andre Noll Date: Tue, 22 Aug 2023 16:06:57 +0000 (+0200) Subject: gui: Remember menu position. X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=b94faafa111dbec1b5cc45fb588f9258b4ca5abc;p=gsu.git 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(). --- 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"