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