xref: /freebsd/contrib/dialog/samples/form5 (revision 641a6cfb86023499caafe26a4d821a0b885cf00b)
1#! /bin/sh
2# $Id: form5,v 1.6 2010/01/13 10:49:52 tom Exp $
3# form4 with --help-status
4
5. ./setup-vars
6
7backtitle="An Example for the use of --form:"
8
9ids=`id|sed -e 's/([^)]*)//g'`
10uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
11gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`
12
13user="$USER"
14home="$HOME"
15
16returncode=0
17while test $returncode != 1 && test $returncode != 250
18do
19exec 3>&1
20value=`$DIALOG --ok-label "Submit" \
21	  --help-status \
22	  --help-button \
23	  --item-help \
24	  --backtitle "$backtitle" "$@" \
25	  --form "Here is a possible piece of a configuration program." \
2620 50 0 \
27	"Username:" 1 1	"$user" 1 10 10 0 "Login name" \
28	"UID:"      2 1	"$uid"  2 10  8 0 "User ID" \
29	"GID:"      3 1	"$gid"  3 10  8 0 "Group ID" \
30	"HOME:"     4 1	"$home" 4 10 40 0 "User's home-directory" \
312>&1 1>&3`
32returncode=$?
33exec 3>&-
34
35show=`echo "$value" |sed -e 's/^/	/'`
36
37	case $returncode in
38	$DIALOG_CANCEL)
39		"$DIALOG" \
40		--clear \
41		--backtitle "$backtitle" \
42		--yesno "Really quit?" 10 30
43		case $? in
44		$DIALOG_OK)
45			break
46			;;
47		$DIALOG_CANCEL)
48			returncode=99
49			;;
50		esac
51		;;
52	$DIALOG_OK)
53		"$DIALOG" \
54		--clear \
55		--backtitle "$backtitle" --no-collapse --cr-wrap \
56		--msgbox "Resulting data:\n\
57$show" 10 40
58		;;
59	$DIALOG_HELP)
60		"$DIALOG" \
61		--clear \
62		--backtitle "$backtitle" --no-collapse --cr-wrap \
63		--msgbox "Help data:\n\
64$show" 10 40
65		;;
66	*)
67		echo "Return code was $returncode"
68		exit
69		;;
70	esac
71done
72