# $Id$ OK_LABEL=$"Next" CANCEL_LABEL=$"Back" # common dialog boxes messagebox() { local header local text local height local width # very basic getops local OPTIND opt while getopts ":h:y:x:" opt do case ${opt} in h) header="${OPTARG}" ;; y) height="${OPTARG}" ;; x) width="${OPTARG}" ;; esac done shift $((OPTIND-1)) text="$@" #[[ -z ${header} ]] && die "no header given" [[ -z ${text} ]] && die "no text given" [[ -z ${height} ]] && height=8 [[ -z ${width} ]] && width=70 [[ -z ${OK_LABEL} ]] && OK_LABEL="Next" dialog \ --colors \ --title "${header}" \ --backtitle "${TITLE}" \ --ok-label "${OK_LABEL}" \ --msgbox "${text}" "${height}" "${width}" } infobox() { local header local text local height local width # very basic getops local OPTIND opt while getopts ":h:y:x:" opt do case ${opt} in h) header="${OPTARG}" ;; y) height="${OPTARG}" ;; x) width="${OPTARG}" ;; esac done shift $((OPTIND-1)) text="$@" #[[ -z ${header} ]] && die "no header given" [[ -z ${text} ]] && die "no text given" [[ -z ${height} ]] && height=3 [[ -z ${width} ]] && width=70 dialog \ --colors \ --title "${header}" \ --backtitle "${TITLE}" \ --infobox "${text}" "${height}" "${width}" } inputbox() { local header local text local height local width # very basic getops local OPTIND opt while getopts ":h:y:x:" opt do case ${opt} in h) header="${OPTARG}" ;; y) height="${OPTARG}" ;; x) width="${OPTARG}" ;; esac done shift $((OPTIND-1)) text="$@" #[[ -z ${header} ]] && die "no header given" [[ -z ${text} ]] && die "no text given" [[ -z ${height} ]] && height=0 [[ -z ${width} ]] && width=0 dialog \ --stdout \ --colors \ --title "${header}" \ --backtitle "${TITLE}" \ --inputbox "${text}" "${height}" "${width}" } passwordbox() { local header local text local height local width # very basic getops local OPTIND opt while getopts ":h:y:x:" opt do case ${opt} in h) header="${OPTARG}" ;; y) height="${OPTARG}" ;; x) width="${OPTARG}" ;; esac done shift $((OPTIND-1)) text="$@" #[[ -z ${header} ]] && die "no header given" [[ -z ${text} ]] && die "no text given" [[ -z ${height} ]] && height=0 [[ -z ${width} ]] && width=0 dialog \ --stdout \ --colors \ --title "${header}" \ --backtitle "${TITLE}" \ --insecure \ --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