xref: /freebsd/contrib/dialog/samples/form1-both (revision 4c8945a06b01a5c8122cdeb402af36bb46a06acc)
1*4c8945a0SNathan Whitehorn#! /bin/sh
2*4c8945a0SNathan Whitehorn# $Id: form1-both,v 1.5 2010/01/13 10:47:35 tom Exp $
3*4c8945a0SNathan Whitehorn
4*4c8945a0SNathan Whitehorn. ./setup-vars
5*4c8945a0SNathan Whitehorn
6*4c8945a0SNathan Whitehornbacktitle="An Example for the use of --form:"
7*4c8945a0SNathan Whitehorn
8*4c8945a0SNathan Whitehornids=`id|sed -e 's/([^)]*)//g'`
9*4c8945a0SNathan Whitehornuid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
10*4c8945a0SNathan Whitehorngid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`
11*4c8945a0SNathan Whitehorn
12*4c8945a0SNathan Whitehornuser="$USER"
13*4c8945a0SNathan Whitehornhome="$HOME"
14*4c8945a0SNathan Whitehorn
15*4c8945a0SNathan Whitehornreturncode=0
16*4c8945a0SNathan Whitehornwhile test $returncode != 1 && test $returncode != 250
17*4c8945a0SNathan Whitehorndo
18*4c8945a0SNathan Whitehornexec 3>&1
19*4c8945a0SNathan Whitehornvalue=`$DIALOG --ok-label "Submit" \
20*4c8945a0SNathan Whitehorn	  --extra-button --help-button \
21*4c8945a0SNathan Whitehorn	  --backtitle "$backtitle" "$@" \
22*4c8945a0SNathan Whitehorn	  --form "Here is a possible piece of a configuration program." \
23*4c8945a0SNathan Whitehorn20 50 0 \
24*4c8945a0SNathan Whitehorn	"Username:" 1 1	"$user" 1 10 10 0 \
25*4c8945a0SNathan Whitehorn	"UID:"      2 1	"$uid"  2 10  8 0 \
26*4c8945a0SNathan Whitehorn	"GID:"      3 1	"$gid"  3 10  8 0 \
27*4c8945a0SNathan Whitehorn	"HOME:"     4 1	"$home" 4 10 40 0 \
28*4c8945a0SNathan Whitehorn2>&1 1>&3`
29*4c8945a0SNathan Whitehornreturncode=$?
30*4c8945a0SNathan Whitehornexec 3>&-
31*4c8945a0SNathan Whitehorn
32*4c8945a0SNathan Whitehornshow=`echo "$value" |sed -e 's/^/	/'`
33*4c8945a0SNathan Whitehorn
34*4c8945a0SNathan Whitehorn	case $returncode in
35*4c8945a0SNathan Whitehorn	$DIALOG_CANCEL)
36*4c8945a0SNathan Whitehorn		"$DIALOG" \
37*4c8945a0SNathan Whitehorn		--clear \
38*4c8945a0SNathan Whitehorn		--backtitle "$backtitle" \
39*4c8945a0SNathan Whitehorn		--yesno "Really quit?" 10 30
40*4c8945a0SNathan Whitehorn		case $? in
41*4c8945a0SNathan Whitehorn		$DIALOG_OK)
42*4c8945a0SNathan Whitehorn			break
43*4c8945a0SNathan Whitehorn			;;
44*4c8945a0SNathan Whitehorn		$DIALOG_CANCEL)
45*4c8945a0SNathan Whitehorn			returncode=99
46*4c8945a0SNathan Whitehorn			;;
47*4c8945a0SNathan Whitehorn		esac
48*4c8945a0SNathan Whitehorn		;;
49*4c8945a0SNathan Whitehorn	$DIALOG_OK)
50*4c8945a0SNathan Whitehorn		"$DIALOG" \
51*4c8945a0SNathan Whitehorn		--clear \
52*4c8945a0SNathan Whitehorn		--backtitle "$backtitle" --no-collapse --cr-wrap \
53*4c8945a0SNathan Whitehorn		--msgbox "Resulting data:\n\
54*4c8945a0SNathan Whitehorn$show" 10 40
55*4c8945a0SNathan Whitehorn		;;
56*4c8945a0SNathan Whitehorn	$DIALOG_HELP)
57*4c8945a0SNathan Whitehorn		echo "Button 2 (Help) pressed."
58*4c8945a0SNathan Whitehorn		exit
59*4c8945a0SNathan Whitehorn		;;
60*4c8945a0SNathan Whitehorn	$DIALOG_EXTRA)
61*4c8945a0SNathan Whitehorn		echo "Button 3 (Extra) pressed."
62*4c8945a0SNathan Whitehorn		exit
63*4c8945a0SNathan Whitehorn		;;
64*4c8945a0SNathan Whitehorn	*)
65*4c8945a0SNathan Whitehorn		echo "Return code was $returncode"
66*4c8945a0SNathan Whitehorn		exit
67*4c8945a0SNathan Whitehorn		;;
68*4c8945a0SNathan Whitehorn	esac
69*4c8945a0SNathan Whitehorndone
70