--- trunk/installer-simple/functions/common-dialogs.sh 2014/01/07 12:59:51 2395 +++ trunk/installer-simple/functions/common-dialogs.sh 2014/01/07 13:01:02 2396 @@ -138,6 +138,53 @@ --passwordbox "${text}" "${height}" "${width}" } +menubox() +{ + local header + local text + local height + local width + local items + local index + local dialog_opts + + # very basic getops + local OPTIND opt + while getopts ":h:y:x:i:n" opt + do + case ${opt} in + n) dialog_opts+=" --no-cancel" ;; + h) header="${OPTARG}" ;; + y) height="${OPTARG}" ;; + x) width="${OPTARG}" ;; + esac + done + shift $((OPTIND-1)) + text="$1" + shift + items=( "$@" ) + index="${#items[*]}" + + #[[ -z ${header} ]] && header="empty header: add -h yourheader" + [[ -z ${text} ]] && die "no text given" + [[ -z ${height} ]] && height=0 + [[ -z ${width} ]] && width=70 + + [[ -z ${OK_LABEL} ]] && OK_LABEL="Next" + [[ -z ${CANCEL_LABEL} ]] && CANCEL_LABEL="Back" + + eval dialog \ + --stdout \ + --colors \ + --title "'${header}'" \ + --backtitle "'${TITLE}'" \ + --ok-label "'${OK_LABEL}'" \ + --cancel-label "'${CANCEL_LABEL}'" \ + "${dialog_opts}" \ + --menu "'${text}'" "${height}" "${width}" "${index}" \ + $(for ((i=0;i