Skip to content

Commit b896eba

Browse files
committed
Adding standalone tester for browse.
1 parent 5601618 commit b896eba

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

src/bui-util.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ declare -ri UTIL_ACT_CHANGED=0
3232
# controllers will set this when the app should terminate
3333
declare -i util_exit_dispatcher=0
3434

35+
# determines if local echo should be enabled on termination
36+
declare -i util_exit_echo=0
37+
3538
# settings keys
3639
declare -r UTIL_PARAM_PANEL_ROWS='panel-rows'
3740
declare -r UTIL_PARAM_PANEL_COLS='panel-cols'
@@ -226,6 +229,12 @@ function fn_util_panel_close()
226229

227230
# restore terminal settings
228231
fn_csi_op $CSI_OP_CURSOR_SHOW
232+
233+
# if this is not a hotkey then echo should be enabled.
234+
if ((util_exit_echo))
235+
then
236+
stty echo
237+
fi
229238

230239
# remove signal handler
231240
trap - SIGHUP SIGINT SIGTERM
@@ -297,6 +306,12 @@ function fn_util_panic()
297306
# show and restore cursor
298307
fn_csi_op $CSI_OP_CURSOR_RESTORE
299308
fn_csi_op $CSI_OP_CURSOR_SHOW
309+
310+
# if this is not a hotkey then echo should be enabled.
311+
if ((util_exit_echo))
312+
then
313+
stty echo
314+
fi
300315

301316
# move cursor down so we don't overwrite error messages
302317
fn_csi_op $CSI_OP_ROW_DOWN 5

test/test-browse.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
##
2+
# BASH-UI - Bash User Interface Tools
3+
# Copyright 2017 by Chad Juliano
4+
#
5+
# Licensed under GNU Lesser General Public License v3.0 only. Some rights
6+
# reserved. See LICENSE.
7+
#
8+
# File: test-browse.sh
9+
# Description: Standalone tester for browse menu.
10+
##
11+
12+
# generate errors if unset vars are used.
13+
set -o nounset
14+
15+
if [ -o posix ]
16+
then
17+
echo "ERROR: Bash-UI should not be run in posix mode." 2>&1
18+
exit 1
19+
fi
20+
21+
_script_dir="$(cd "$(dirname $0)" && pwd -P)"
22+
BUI_HOME=${_script_dir}/../src
23+
24+
source ${BUI_HOME}/bui-term-draw.sh
25+
source ${BUI_HOME}/bui-settings.sh
26+
source ${BUI_HOME}/bui-util.sh
27+
source ${BUI_HOME}/bui-theme-mgr.sh
28+
source ${BUI_HOME}/bui-panel-hmenu.sh
29+
source ${BUI_HOME}/bui-panel-vmenu.sh
30+
source ${BUI_HOME}/bui-panel-browse.sh
31+
32+
function fn_test_browse()
33+
{
34+
# enable echo on exit
35+
util_exit_echo=1
36+
37+
fn_util_panel_open
38+
fn_theme_init
39+
40+
# set the location of where the hmenu would be
41+
hmenu_row_pos=-1
42+
43+
# show the panel
44+
fn_bui_controller_browse
45+
46+
fn_util_panel_close
47+
48+
echo "Browse result: ${bui_selection_result}"
49+
}
50+
51+
# entry point
52+
fn_test_browse

0 commit comments

Comments
 (0)