]> git.tue.mpg.de Git - gsu.git/commitdiff
gui: Remember menu position.
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 22 Aug 2023 16:06:57 +0000 (18:06 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 29 Oct 2023 00:57:03 +0000 (02:57 +0200)
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

diff --git a/gui b/gui
index 72ddb28b2dd2b21655d834c0b3c193ad096d9d13..fbcbb01e49dce6d7c6e55045c5286e2652411549 100644 (file)
--- 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"