From ee15449b2eef26c7a0a36463a6942428cf6002e8 Mon Sep 17 00:00:00 2001 From: Simon Oehrl <oehrl@vr.rwth-aachen.de> Date: Sun, 26 Jan 2020 18:58:36 +0100 Subject: [PATCH] Use arrows for selecting branches --- setup.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/setup.sh b/setup.sh index 7a4957f1..9b273bfb 100755 --- a/setup.sh +++ b/setup.sh @@ -112,7 +112,7 @@ function manage_plugins() { fi done - function toggle_branch() { + function next_branch() { case ${plugin_branches[$1]} in "") plugin_branches[$1]="master" ;; "master") plugin_branches[$1]="develop" ;; @@ -121,6 +121,15 @@ function manage_plugins() { esac } + function previous_branch() { + case ${plugin_branches[$1]} in + "master") plugin_branches[$1]="" ;; + "develop") plugin_branches[$1]="master" ;; + "") plugin_branches[$1]="develop" ;; + *) >&2; plugin_branches[$1]="" ;; + esac + } + selection=0 exit=false cancel=false @@ -156,10 +165,10 @@ function manage_plugins() { echo "" - echo "[Arrow Up/Down] Select Plugin" - echo "[Space] Toggle branch" - echo "[Enter] Continue" - echo "[Esc] Cancel" + echo "[Arrow Up/Down] Select Plugin" + echo "[Arrow Left/Right] Select branch" + echo "[Enter] Continue" + echo "[Esc] Cancel" SAVEIFS=$IFS IFS='' @@ -173,7 +182,8 @@ function manage_plugins() { IFS=$SAVEIFS case $mode in "") if [ "$escape" == true ]; then cancel=true; fi; exit=true ;; - " ") toggle_branch $selection ;; + "[D") previous_branch $selection ;; + "[C") next_branch $selection ;; "[A") if [ "$selection" -gt "0" ]; then let selection-=1; fi ;; "[B") if [ "$selection" -lt "$num_plugins_minus_one" ]; then let selection+=1; fi ;; *) >&2 ;; -- GitLab