diff options
author | P. J. McDermott <pj@pehjota.net> | 2015-11-06 00:33:45 (EST) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2015-11-06 00:33:45 (EST) |
commit | 41f764da19048fc2e9ec583c37de73de915811d2 (patch) | |
tree | f9885d3dff0f08cd3c601baadad8c0f106d8ef3c | |
parent | 1bcbaaca746b4784a48eedc70cc3fbad00242eaa (diff) | |
download | firman.sh-41f764da19048fc2e9ec583c37de73de915811d2.zip firman.sh-41f764da19048fc2e9ec583c37de73de915811d2.tar.gz firman.sh-41f764da19048fc2e9ec583c37de73de915811d2.tar.bz2 |
notice(): New function
In the TUI, info() now creates a dialog box without an "OK" button, and
notice() creates a box with an "OK" button.
-rw-r--r-- | src/ui.sh | 2 | ||||
-rw-r--r-- | src/ui/cli.sh | 8 | ||||
-rw-r--r-- | src/ui/tui.sh | 21 |
3 files changed, 26 insertions, 5 deletions
@@ -32,7 +32,7 @@ init_ui() for fn in exit_ui message show_menu show_prompt; do eval "${fn}() { ${ui}_${fn} \"\${@}\"; }" done - for fn in dbg info warn err; do + for fn in dbg info notice warn err; do eval "${fn}() { ${ui}_${fn} \"\${@}\"; log_${fn} \"\${@}\"; }" done diff --git a/src/ui/cli.sh b/src/ui/cli.sh index ca78b04..5428319 100644 --- a/src/ui/cli.sh +++ b/src/ui/cli.sh @@ -41,6 +41,14 @@ cli_info() printf "${fmt}\n" "${@}" >"${cli_tty}" } +cli_notice() +{ + local fmt="${1}" + shift 1 + + printf "${fmt}\n" "${@}" >"${cli_tty}" +} + cli_warn() { local fmt="${1}" diff --git a/src/ui/tui.sh b/src/ui/tui.sh index ffd3430..3bc01ad 100644 --- a/src/ui/tui.sh +++ b/src/ui/tui.sh @@ -96,7 +96,8 @@ _tui_box() _tui_dialog() { local lvl="${1}" - local fmt="${2}" + local btn="${2}" + local fmt="${3}" shift 2 local msg='' @@ -131,6 +132,10 @@ _tui_dialog() term_cursor_forward 1 term_write "${msg}" + if ! ${btn}; then + return 0 + fi + # Draw a (selected) button. term_cursor_back 4 term_cursor_down 2 @@ -157,7 +162,15 @@ tui_info() local fmt="${1}" shift 1 - _tui_dialog info "${fmt}" "${@}" + _tui_dialog info false "${fmt}" "${@}" +} + +tui_notice() +{ + local fmt="${1}" + shift 1 + + _tui_dialog info true "${fmt}" "${@}" } tui_warn() @@ -165,7 +178,7 @@ tui_warn() local fmt="${1}" shift 1 - _tui_dialog warn "${fmt}" "${@}" + _tui_dialog warn true "${fmt}" "${@}" } tui_err() @@ -173,7 +186,7 @@ tui_err() local fmt="${1}" shift 1 - _tui_dialog err "${fmt}" "${@}" + _tui_dialog err true "${fmt}" "${@}" } tui_show_menu() |