xref: /freebsd/contrib/dialog/samples/form6 (revision a96ef4501919d7ac08e94e98dc34b0bdd744802b)
14c8945a0SNathan Whitehorn#! /bin/sh
2*a96ef450SBaptiste Daroussin# $Id: form6,v 1.8 2020/11/26 00:31:55 tom Exp $
34c8945a0SNathan Whitehorn# form4 with --help-status
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-status \
224c8945a0SNathan Whitehorn	  --help-button \
234c8945a0SNathan Whitehorn	  --item-help \
244c8945a0SNathan Whitehorn	  --backtitle "$backtitle" "$@" \
254c8945a0SNathan Whitehorn	  --form "Here is a possible piece of a configuration program." \
264c8945a0SNathan Whitehorn20 50 0 \
274c8945a0SNathan Whitehorn	"Username:" 1 1	"$user" 1 10 -9 9 "Login name" \
284c8945a0SNathan Whitehorn	"UID:"      2 1	"$uid"  2 10  8 0 "User ID" \
294c8945a0SNathan Whitehorn	"GID:"      3 1	"$gid"  3 10  8 0 "Group ID" \
304c8945a0SNathan Whitehorn	"HOME:"     4 1	"$home" 4 10 40 0 "User's home-directory" \
314c8945a0SNathan Whitehorn2>&1 1>&3`
324c8945a0SNathan Whitehornreturncode=$?
334c8945a0SNathan Whitehornexec 3>&-
344c8945a0SNathan Whitehorn
35*a96ef450SBaptiste Daroussinshow=`echo "$returntext" |sed -e 's/^/	/'`
364c8945a0SNathan Whitehorn
374c8945a0SNathan Whitehorn	case $returncode in
384c8945a0SNathan Whitehorn	$DIALOG_CANCEL)
394c8945a0SNathan Whitehorn		"$DIALOG" \
404c8945a0SNathan Whitehorn		--clear \
414c8945a0SNathan Whitehorn		--backtitle "$backtitle" \
424c8945a0SNathan Whitehorn		--yesno "Really quit?" 10 30
434c8945a0SNathan Whitehorn		case $? in
444c8945a0SNathan Whitehorn		$DIALOG_OK)
454c8945a0SNathan Whitehorn			break
464c8945a0SNathan Whitehorn			;;
474c8945a0SNathan Whitehorn		$DIALOG_CANCEL)
484c8945a0SNathan Whitehorn			returncode=99
494c8945a0SNathan Whitehorn			;;
504c8945a0SNathan Whitehorn		esac
514c8945a0SNathan Whitehorn		;;
524c8945a0SNathan Whitehorn	$DIALOG_OK)
534c8945a0SNathan Whitehorn		"$DIALOG" \
544c8945a0SNathan Whitehorn		--clear \
554c8945a0SNathan Whitehorn		--backtitle "$backtitle" --no-collapse --cr-wrap \
564c8945a0SNathan Whitehorn		--msgbox "Resulting data:\n\
574c8945a0SNathan Whitehorn$show" 10 40
584c8945a0SNathan Whitehorn		;;
594c8945a0SNathan Whitehorn	$DIALOG_HELP)
604c8945a0SNathan Whitehorn		"$DIALOG" \
614c8945a0SNathan Whitehorn		--clear \
624c8945a0SNathan Whitehorn		--backtitle "$backtitle" --no-collapse --cr-wrap \
634c8945a0SNathan Whitehorn		--msgbox "Help data:\n\
644c8945a0SNathan Whitehorn$show" 10 40
654c8945a0SNathan Whitehorn		;;
664c8945a0SNathan Whitehorn	*)
67*a96ef450SBaptiste Daroussin		. ./report-button
684c8945a0SNathan Whitehorn		exit
694c8945a0SNathan Whitehorn		;;
704c8945a0SNathan Whitehorn	esac
714c8945a0SNathan Whitehorndone
72