xref: /freebsd/contrib/bsddialog/examples_utility/timebox.sh (revision 7c20397b724a55001c2054fa133a768e9d06eb1c)
1#!/bin/sh
2#-
3# SPDX-License-Identifier: CC0-1.0
4#
5# Written in 2021 by Alfonso Sabato Siciliano.
6#
7# To the extent possible under law, the author has dedicated all copyright
8# and related and neighboring rights to this software to the public domain
9# worldwide. This software is distributed without any warranty, see:
10#	<http://creativecommons.org/publicdomain/zero/1.0/>.
11
12: ${BSDDIALOG_ERROR=255}
13: ${BSDDIALOG_OK=0}
14: ${BSDDIALOG_CANCEL=1}
15: ${BSDDIALOG_ESC=5}
16
17TIME=$(./bsddialog --title " timebox " \
18	--timebox "Tab / Left / Right to move\nUp / Down to select" 10 40 \
193>&1 1>&2 2>&3 3>&-)
20
21case $? in
22	$BSDDIALOG_ERROR )
23		exit 1
24	;;
25	$BSDDIALOG_ESC )
26		echo "[ESC]"
27	;;
28	$BSDDIALOG_CANCEL )
29		echo "[Cancel]"
30	;;
31	$BSDDIALOG_OK )
32		echo "[OK] $TIME"
33	;;
34esac
35