xref: /freebsd/contrib/dialog/samples/form4 (revision a96ef4501919d7ac08e94e98dc34b0bdd744802b)
14c8945a0SNathan Whitehorn#! /bin/sh
2*a96ef450SBaptiste Daroussin# $Id: form4,v 1.9 2020/11/26 00:32:31 tom Exp $
34c8945a0SNathan Whitehorn# form3 with --item-help
44c8945a0SNathan Whitehorn
54c8945a0SNathan Whitehorn. ./setup-vars
64c8945a0SNathan Whitehorn
74c8945a0SNathan Whitehornbacktitle="An Example for the use of --form:"
84c8945a0SNathan Whitehorn
94c8945a0SNathan Whitehornids=`id|sed -e 's/([^)]*)//g'`
104c8945a0SNathan Whitehornuid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
114c8945a0SNathan Whitehorngid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`
124c8945a0SNathan Whitehorn
134c8945a0SNathan Whitehornuser="$USER"
144c8945a0SNathan Whitehornhome="$HOME"
154c8945a0SNathan Whitehorn
164c8945a0SNathan Whitehornreturncode=0
174c8945a0SNathan Whitehornwhile test $returncode != 1 && test $returncode != 250
184c8945a0SNathan Whitehorndo
194c8945a0SNathan Whitehornexec 3>&1
20*a96ef450SBaptiste Daroussinreturntext=`$DIALOG --ok-label "Submit" \
214c8945a0SNathan Whitehorn	  --help-button \
224c8945a0SNathan Whitehorn	  --item-help \
234c8945a0SNathan Whitehorn	  --backtitle "$backtitle" "$@" \
244c8945a0SNathan Whitehorn	  --form "Here is a possible piece of a configuration program." \
254c8945a0SNathan Whitehorn20 50 0 \
264c8945a0SNathan Whitehorn	"Username:" 1 1	"$user" 1 10 10 0 "Login name" \
274c8945a0SNathan Whitehorn	"UID:"      2 1	"$uid"  2 10  8 0 "User ID" \
284c8945a0SNathan Whitehorn	"GID:"      3 1	"$gid"  3 10  8 0 "Group ID" \
294c8945a0SNathan Whitehorn	"HOME:"     4 1	"$home" 4 10 40 0 "User's home-directory" \
304c8945a0SNathan Whitehorn2>&1 1>&3`
314c8945a0SNathan Whitehornreturncode=$?
324c8945a0SNathan Whitehornexec 3>&-
334c8945a0SNathan Whitehorn
34*a96ef450SBaptiste Daroussinshow=`echo "$returntext" |sed -e 's/^/	/'`
354c8945a0SNathan Whitehorn
364c8945a0SNathan Whitehorn	case $returncode in
374c8945a0SNathan Whitehorn	$DIALOG_CANCEL)
384c8945a0SNathan Whitehorn		"$DIALOG" \
394c8945a0SNathan Whitehorn		--clear \
404c8945a0SNathan Whitehorn		--backtitle "$backtitle" \
414c8945a0SNathan Whitehorn		--yesno "Really quit?" 10 30
424c8945a0SNathan Whitehorn		case $? in
434c8945a0SNathan Whitehorn		$DIALOG_OK)
444c8945a0SNathan Whitehorn			break
454c8945a0SNathan Whitehorn			;;
464c8945a0SNathan Whitehorn		$DIALOG_CANCEL)
474c8945a0SNathan Whitehorn			returncode=99
484c8945a0SNathan Whitehorn			;;
494c8945a0SNathan Whitehorn		esac
504c8945a0SNathan Whitehorn		;;
514c8945a0SNathan Whitehorn	$DIALOG_OK)
524c8945a0SNathan Whitehorn		"$DIALOG" \
534c8945a0SNathan Whitehorn		--clear \
544c8945a0SNathan Whitehorn		--backtitle "$backtitle" --no-collapse --cr-wrap \
554c8945a0SNathan Whitehorn		--msgbox "Resulting data:\n\
564c8945a0SNathan Whitehorn$show" 10 40
574c8945a0SNathan Whitehorn		;;
584c8945a0SNathan Whitehorn	$DIALOG_HELP)
594c8945a0SNathan Whitehorn		"$DIALOG" \
604c8945a0SNathan Whitehorn		--clear \
614c8945a0SNathan Whitehorn		--backtitle "$backtitle" --no-collapse --cr-wrap \
624c8945a0SNathan Whitehorn		--msgbox "Help data:\n\
634c8945a0SNathan Whitehorn$show" 10 40
644c8945a0SNathan Whitehorn		;;
654c8945a0SNathan Whitehorn	*)
66*a96ef450SBaptiste Daroussin		. ./report-button
674c8945a0SNathan Whitehorn		exit
684c8945a0SNathan Whitehorn		;;
694c8945a0SNathan Whitehorn	esac
704c8945a0SNathan Whitehorndone
71