summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2015-10-29 20:48:49 (EDT)
committer P. J. McDermott <pj@pehjota.net>2015-10-29 20:48:49 (EDT)
commit869b1875f2febe169f5701e41de3e653e7a8343c (patch)
treea7f5e48649dc09a97c614f54d0e80dc5ad1adefe
parent1acca073f3fc1b9e346a398794e2acd520d0f94d (diff)
downloadfirman.sh-869b1875f2febe169f5701e41de3e653e7a8343c.zip
firman.sh-869b1875f2febe169f5701e41de3e653e7a8343c.tar.gz
firman.sh-869b1875f2febe169f5701e41de3e653e7a8343c.tar.bz2
message(): New function
-rw-r--r--src/ui.sh2
-rw-r--r--src/ui/cli.sh11
-rw-r--r--src/ui/tui.sh22
3 files changed, 32 insertions, 3 deletions
diff --git a/src/ui.sh b/src/ui.sh
index f3243c5..c127034 100644
--- a/src/ui.sh
+++ b/src/ui.sh
@@ -29,7 +29,7 @@ init_ui()
;;
esac
- for fn in exit_ui show_menu show_prompt; do
+ for fn in exit_ui message show_menu show_prompt; do
eval "${fn}() { ${ui}_${fn} \"\${@}\"; }"
done
for fn in dbg info warn err; do
diff --git a/src/ui/cli.sh b/src/ui/cli.sh
index b341c9e..369694c 100644
--- a/src/ui/cli.sh
+++ b/src/ui/cli.sh
@@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cli_tty=''
+cli_msg=''
cli_init_ui()
{
@@ -53,6 +54,16 @@ cli_err()
printf "Error: ${fmt}\n" "${@}" >"${cli_tty}"
}
+cli_message()
+{
+ local msg="${1}"
+ shift 1
+
+ printf '%s\n\n' "${msg}" >"${cli_tty}"
+
+ return 0
+}
+
cli_show_menu()
{
local title="${1}"
diff --git a/src/ui/tui.sh b/src/ui/tui.sh
index 4aec0d1..75ef4e6 100644
--- a/src/ui/tui.sh
+++ b/src/ui/tui.sh
@@ -15,6 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+_tui_msg=''
+
tui_init_ui()
{
term_init
@@ -33,6 +35,16 @@ tui_exit_ui()
term_cooked
}
+tui_message()
+{
+ local msg="${1}"
+ shift 1
+
+ _tui_msg="${msg}"
+
+ return 0
+}
+
_tui_box()
{
local w=${1}
@@ -43,10 +55,16 @@ _tui_box()
local i=
local line=''
- # Clear the screen and set the cursor position to center the box.
+ # Reset SGR and clear the screen.
term_attr_reset
term_clear
- y=$(expr \( $(term_lines) - ${h} \) / 2 + 1)
+
+ # Write the persistent message (if any).
+ term_cursor_position $(expr $(term_lines) - 1) 3
+ term_write "${_tui_msg}"
+
+ # Set the cursor position to center the box.
+ y=$(expr \( $(term_lines) - ${_tui_msg+3} - ${h} \) / 2 + 1)
x=$(expr \( $(term_columns) - ${w} \) / 2 + 1)
term_cursor_position ${y} ${x}