summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2015-10-30 16:56:41 (EDT)
committer P. J. McDermott <pj@pehjota.net>2015-10-30 16:56:41 (EDT)
commitf4ccc176b5c3143e218f9da1abd9716ba2befa6e (patch)
tree571db8bf69af7bf1f6e0ddf174022e9835f67169 /src
parent766225df49bac22581d121e7962c5613d2a0006c (diff)
downloadfirman.sh-f4ccc176b5c3143e218f9da1abd9716ba2befa6e.zip
firman.sh-f4ccc176b5c3143e218f9da1abd9716ba2befa6e.tar.gz
firman.sh-f4ccc176b5c3143e218f9da1abd9716ba2befa6e.tar.bz2
tui_show_prompt(): Add a Cancel button
Diffstat (limited to 'src')
-rw-r--r--src/ui/tui.sh19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/ui/tui.sh b/src/ui/tui.sh
index 0aca904..ffd3430 100644
--- a/src/ui/tui.sh
+++ b/src/ui/tui.sh
@@ -371,6 +371,9 @@ tui_show_prompt()
if [ $(expr ${len} + 7) -gt ${w} ]; then
w=$(expr ${len} + 7)
fi
+ if [ ${w} -lt 17 ]; then
+ w=17
+ fi
read -r y x <<-EOF
$(_tui_box ${w} 9)
EOF
@@ -393,7 +396,7 @@ tui_show_prompt()
# Event loop.
while :; do
# Draw a button.
- term_cursor_position $(($y + 7)) $(($x + $w - 6))
+ term_cursor_position $(($y + 7)) $(($x + $w - 15))
if [ ${focus} -eq 1 ]; then
term_attr_on reverse
term_write '[OK]'
@@ -401,6 +404,14 @@ tui_show_prompt()
else
term_write '[OK]'
fi
+ term_write ' '
+ if [ ${focus} -eq 2 ]; then
+ term_attr_on reverse
+ term_write '[Cancel]'
+ term_attr_off reverse
+ else
+ term_write '[Cancel]'
+ fi
# Draw a textbox.
term_cursor_position $(($y + 3)) $(($x + 2))
@@ -425,7 +436,7 @@ tui_show_prompt()
# Input.
key="$(term_getch)"
if [ "x${key}" = xKEY_TAB ]; then
- focus=$(expr \( ${focus} + 1 \) % 2)
+ focus=$(expr \( ${focus} + 1 \) % 3)
elif [ ${focus} -eq 0 ]; then
case "${key}" in
KEY_ENTER)
@@ -522,6 +533,10 @@ tui_show_prompt()
case "${key}" in
KEY_ENTER | KEY_SPACE) break;;
esac
+ elif [ ${focus} -eq 2 ]; then
+ case "${key}" in
+ KEY_ENTER | KEY_SPACE) return 1;;
+ esac
fi
done