1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
#!/bin/sh
# Whiptail functions for modconf
# (c) 2000 Software in the Public Interest
# Maintainer: Randolph Chung <tausq@debian.org> and debian-boot@lists.debian.org
# Derived from:
# Shell interface to "dialog"
# Bruce Perens, November 1995
# This is free software under the GNU General Public License.
export DIALOG_COMMAND=whiptail
#test -x /usr/bin/dialog && export DIALOG_COMMAND=dialog
# dialog breaks on zero-arguments
ttydev=${ttydev:-/dev/tty}
# Global options
# The variable $BACKTITLE specifies the back title.
# The variable $DIALOG_OPTIONS, initialized here to --clear, provides
# options you want on the command line of each dialog invocation.
# The variable $DIALOG_TEST can be set to "echo" to see the calls
# to dialog without executing them.
DIALOG_OPTIONS=""
BACKTITLE=""
# Make any dialogue box, with default settings and backtitle from
# $BACKTITLE in the environment.
#
# dialog [options] -- --type arg arg ...
#
dialogBox () {
local args
while true; do
if [ "$1" = "--" ]; then
shift
break
else
args="$args $1"
shift
fi
done
local type
type="$1"
shift
local title
title=""
local backtitle
backtitle=""
local result
local status
local text
text="$1"
shift
if [ $# -ge 1 ]; then
title="$1"
shift
fi
if [ -n "$BACKTITLE" ]; then
backtitle="$BACKTITLE"
fi
# do not confuse whiptail with different LC_* vars, we do not need
# LC_MESSAGES at this point anyways
unset LC_MESSAGES || true
$DIALOG_TEST $DIALOG_COMMAND $DIALOG_OPTIONS $args --title "$title" \
--backtitle "$backtitle" "$type" "$text " 0 0 "$@" 2>&1 1>$ttydev
return $?
}
# Display a file.
#
# fileBox filename [title]
#
fileBox () {
dialogBox -- --textbox "$1" "$2"
}
msgBox () {
dialogBox -- --msgbox "$1" "$2"
}
infoBox () {
dialogBox -- --infobox "$1" "$2"
}
yesNoBox () {
dialogBox -- --yesno "$1" "$2"
return $?
}
inputBox () {
dialogBox -- --inputbox "$1" "$2" "$3" "$4"
return $?
}
# menu text title defaultitem tag1 item1 ...
menu () {
local text
text="$1"
shift
local title
title="$1"
shift
local defaultitem
defaultitem="$1"
shift
if [ -z "$defaultitem" ]; then
dialogBox -- --menu "$text" "$title" 0 "$@"
else
dialogBox --default-item "$defaultitem" -- --menu "$text" "$title" 0 "$@"
fi
return $?
}
# menu text title tag1 item1 status1 ...
checklist () {
local text
text="$1"
shift
local title
title="$1"
shift
dialogBox -- --checklist "$text" "$title" 0 "$@"
return $?
}
# menu text title tag1 item1 status1 ...
radiolist () {
local text
text="$1"
shift
local title
title="$1"
shift
dialogBox -- --radiolist "$text" "$title" 0 "$@"
return $?
}
# Local Variables:
# mode: shell-script
# End:
|