11# ##!/bin/bash
22# #
3- # BIW-TOOLS - Bash Inline Widget Tools
3+ # BASH-UI - Bash User Interface Tools
44# Copyright 2017 by Chad Juliano
55#
66# Licensed under GNU Lesser General Public License v3.0 only. Some rights
77# reserved. See LICENSE.
88#
9- # File: biw -main.sh
9+ # File: bui -main.sh
1010# Description: Top-level script for panel menus.
1111# #
1212
1313# generate errors if unset vars are used.
1414set -o nounset
1515
16- source ${BIW_HOME} /biw -util.sh
17- source ${BIW_HOME} /biw -theme-mgr.sh
18- source ${BIW_HOME} /biw -panel-hmenu.sh
19- source ${BIW_HOME} /biw -panel-vmenu.sh
20- source ${BIW_HOME} /biw -panel-browse.sh
21- source ${BIW_HOME} /biw -panel-credits.sh
22- source ${BIW_HOME} /biw -panel-slider.sh
16+ source ${BUI_HOME} /bui -util.sh
17+ source ${BUI_HOME} /bui -theme-mgr.sh
18+ source ${BUI_HOME} /bui -panel-hmenu.sh
19+ source ${BUI_HOME} /bui -panel-vmenu.sh
20+ source ${BUI_HOME} /bui -panel-browse.sh
21+ source ${BUI_HOME} /bui -panel-credits.sh
22+ source ${BUI_HOME} /bui -panel-slider.sh
2323
24- declare -r BIW_VERSION =0.9
24+ declare -r BUI_VERSION =0.9
2525
2626# a controller can set a result here when it is closed.
27- declare biw_selection_result
27+ declare bui_selection_result
2828
29- function fn_biw_main ()
29+ function fn_bui_main ()
3030{
3131 # remove any existing result file.
32- rm -f $BIW_RESULT_FILE
32+ rm -f $BUI_RESULT_FILE
3333
3434 fn_util_panel_open
3535 fn_theme_init
3636
3737 # show the panel
38- fn_biw_controller_hmenu_top
38+ fn_bui_controller_hmenu_top
3939
4040 fn_util_panel_close
4141
42- if [ -n " $biw_selection_result " ]
42+ if [ -n " $bui_selection_result " ]
4343 then
4444 # save to temporary file
45- echo " $biw_selection_result " > $BIW_RESULT_FILE
45+ echo " $bui_selection_result " > $BUI_RESULT_FILE
4646 fi
4747}
4848
4949# Entires in H-Menu
50- declare -r BIW_MENU_HISTORY =' History'
51- declare -r BIW_MENU_BROWSE =' File'
52- declare -r BIW_MENU_THEME =' Theme'
53- declare -r BIW_MENU_HOTKEY =' Hotkey'
54- declare -r BIW_MENU_CREDITS =' Credits'
55- declare -r BIW_MENU_DIMENSIONS =' Dims'
56- declare -r BIW_MENU_CONFIG =' Config'
57- # declare -r BIW_MENU_DEFAULT ='Default'
58-
59- # BIW_DISPATCH_MAP :
50+ declare -r BUI_MENU_HISTORY =' History'
51+ declare -r BUI_MENU_BROWSE =' File'
52+ declare -r BUI_MENU_THEME =' Theme'
53+ declare -r BUI_MENU_HOTKEY =' Hotkey'
54+ declare -r BUI_MENU_CREDITS =' Credits'
55+ declare -r BUI_MENU_DIMENSIONS =' Dims'
56+ declare -r BUI_MENU_CONFIG =' Config'
57+ # declare -r BUI_MENU_DEFAULT ='Default'
58+
59+ # BUI_DISPATCH_MAP :
6060# This determines what controller is invoked when an H-Menu entry is
6161# selected.
6262#
6363# A controller can also invoke a second-level H-Menu but regardless
6464# of the level, it uses this map to determine what its menu entries
6565# invoke.
66- declare -A BIW_DISPATCH_MAP =(
67- [$BIW_MENU_HISTORY ]=fn_biw_controller_history
68- [$BIW_MENU_BROWSE ]=fn_biw_controller_browse
69- [$BIW_MENU_CREDITS ]=fn_biw_controller_credits
70- [$BIW_MENU_CONFIG ]=fn_biw_controller_cfg_hmenu
71- [$BIW_MENU_THEME ]=fn_biw_controller_cfg_theme
72- [$BIW_MENU_HOTKEY ]=fn_biw_controller_cfg_hotkey
73- [$BIW_MENU_DIMENSIONS ]=fn_biw_controller_cfg_dims )
74-
75- function fn_biw_controller_hmenu_top ()
66+ declare -A BUI_DISPATCH_MAP =(
67+ [$BUI_MENU_HISTORY ]=fn_bui_controller_history
68+ [$BUI_MENU_BROWSE ]=fn_bui_controller_browse
69+ [$BUI_MENU_CREDITS ]=fn_bui_controller_credits
70+ [$BUI_MENU_CONFIG ]=fn_bui_controller_cfg_hmenu
71+ [$BUI_MENU_THEME ]=fn_bui_controller_cfg_theme
72+ [$BUI_MENU_HOTKEY ]=fn_bui_controller_cfg_hotkey
73+ [$BUI_MENU_DIMENSIONS ]=fn_bui_controller_cfg_dims )
74+
75+ function fn_bui_controller_hmenu_top ()
7676{
7777 local -a _top_menu=(
78- $BIW_MENU_HISTORY
79- $BIW_MENU_BROWSE
80- $BIW_MENU_CONFIG
81- $BIW_MENU_CREDITS )
78+ $BUI_MENU_HISTORY
79+ $BUI_MENU_BROWSE
80+ $BUI_MENU_CONFIG
81+ $BUI_MENU_CREDITS )
8282
8383 # setup the H-Menu
8484 fn_hmenu_init ' _top_menu[@]'
@@ -88,19 +88,19 @@ function fn_biw_controller_hmenu_top()
8888 fn_util_dispatcher
8989}
9090
91- function fn_biw_controller_cfg_hmenu ()
91+ function fn_bui_controller_cfg_hmenu ()
9292{
9393 # If we are at this point then it means:
9494 # 1. The user selected the "Config" entry in the H-Menu.
9595 # 2. The dispatcher looked up the associated controller
96- # in BIW_DISPATCH_MAP .
96+ # in BUI_DISPATCH_MAP .
9797 # 3. The dispatcher invoked this controller and is expecting
9898 # it to return when done.
9999
100100 local -a _config_menu=(
101- $BIW_MENU_THEME
102- $BIW_MENU_DIMENSIONS
103- $BIW_MENU_HOTKEY )
101+ $BUI_MENU_THEME
102+ $BUI_MENU_DIMENSIONS
103+ $BUI_MENU_HOTKEY )
104104
105105 # Call the dispatcher that will handle actions
106106 # for a second-level menu
@@ -121,7 +121,7 @@ function fn_biw_controller_cfg_hmenu()
121121# Controller: Hotkey configuration panel.
122122# #
123123
124- function fn_biw_controller_cfg_hotkey ()
124+ function fn_bui_controller_cfg_hotkey ()
125125{
126126 local -A _bind_selections=(
127127 [' Arrow-Up' ]=$CSI_KEY_UP
@@ -141,7 +141,7 @@ function fn_biw_controller_cfg_hotkey()
141141 mapfile -t _key_descr_list < <( echo " ${! _bind_selections[*]} " | sort)
142142
143143 fn_vmenu_init _key_descr_list[@]
144- fn_biw_cfg_hotkey_load
144+ fn_bui_cfg_hotkey_load
145145 vmenu_idx_selected=$?
146146
147147 fn_vmenu_set_message " Choose activation hotkey"
@@ -155,14 +155,14 @@ function fn_biw_controller_cfg_hotkey()
155155
156156 case " $_key " in
157157 $CSI_KEY_ENTER |$CSI_KEY_SPC )
158- fn_biw_cfg_hotkey_save
158+ fn_bui_cfg_hotkey_save
159159 fn_vmenu_redraw
160160 ;;
161161 esac
162162 done
163163}
164164
165- function fn_biw_cfg_hotkey_load ()
165+ function fn_bui_cfg_hotkey_load ()
166166{
167167 # create lookups
168168 local -A _bind_desc_lookup=()
@@ -177,22 +177,22 @@ function fn_biw_cfg_hotkey_load()
177177 _bind_desc_lookup+=( [" $_key_code " ]=$_bind_idx )
178178 done
179179
180- fn_settings_get_param $BIW_BIND_PARAM_NAME ' _selected_bind_key' $BIW_DEFAULT_BIND_KEY
180+ fn_settings_get_param $BUI_BIND_PARAM_NAME ' _selected_bind_key' $BUI_DEFAULT_BIND_KEY
181181
182182 local _selected_bind_key
183183 fn_settings_get_hotkey ' _selected_bind_key'
184184
185185 local -i _selected_bind_idx=${_bind_desc_lookup["$_selected_bind_key"]:- -1}
186186 if(( _selected_bind_idx < 0 ))
187187 then
188- local -i _default_bind_idx=${_bind_desc_lookup[$BIW_DEFAULT_BIND_KEY ]}
188+ local -i _default_bind_idx=${_bind_desc_lookup[$BUI_DEFAULT_BIND_KEY ]}
189189 return $_default_bind_idx
190190 fi
191191
192192 return $_selected_bind_idx
193193}
194194
195- function fn_biw_cfg_hotkey_save ()
195+ function fn_bui_cfg_hotkey_save ()
196196{
197197 local _selected_bind_desc
198198 fn_vmenu_get_current_val ' _selected_bind_desc'
@@ -208,7 +208,7 @@ function fn_biw_cfg_hotkey_save()
208208# Controller: Credits Animation panel
209209# #
210210
211- function fn_biw_controller_credits ()
211+ function fn_bui_controller_credits ()
212212{
213213 # change to matrix theme
214214 local -i _theme_idx=${theme_id_lookup[THEME_TYPE_MATRIX]}
@@ -227,15 +227,15 @@ function fn_biw_controller_credits()
227227# #
228228
229229# max values to load for history and file lists
230- declare -ri BIW_LIST_MAX =50
230+ declare -ri BUI_LIST_MAX =50
231231
232- function fn_biw_controller_history ()
232+ function fn_bui_controller_history ()
233233{
234- local _panel_command=" fc -lnr -$BIW_LIST_MAX "
234+ local _panel_command=" fc -lnr -$BUI_LIST_MAX "
235235 local -a _values
236236
237237 # read command into _values
238- mapfile -t -n $BIW_LIST_MAX _values < <( $_panel_command )
238+ mapfile -t -n $BUI_LIST_MAX _values < <( $_panel_command )
239239
240240 # remove first 2 leading blanks for history case
241241 _values=(" ${_values[@]# [[:blank:]][[:blank:]]} " )
@@ -252,7 +252,7 @@ function fn_biw_controller_history()
252252 case " $_key " in
253253 $CSI_KEY_ENTER )
254254 # we got the enter key so close the menu
255- fn_vmenu_get_current_val " biw_selection_result "
255+ fn_vmenu_get_current_val " bui_selection_result "
256256 util_exit_dispatcher=1
257257 break
258258 ;;
@@ -264,7 +264,7 @@ function fn_biw_controller_history()
264264# Controller: Theme configuration panel.
265265# #
266266
267- function fn_biw_controller_cfg_theme ()
267+ function fn_bui_controller_cfg_theme ()
268268{
269269 # load theme data into menu
270270 fn_vmenu_init " theme_desc_lookup[@]" $theme_active_idx
@@ -286,7 +286,7 @@ function fn_biw_controller_cfg_theme()
286286
287287 case " $_key " in
288288 $CSI_KEY_ENTER |$CSI_KEY_SPC )
289- fn_biw_cfg_theme_save
289+ fn_bui_cfg_theme_save
290290 fn_vmenu_redraw
291291 ;;
292292 esac
@@ -295,7 +295,7 @@ function fn_biw_controller_cfg_theme()
295295 fn_theme_load
296296}
297297
298- function fn_biw_cfg_theme_save ()
298+ function fn_bui_cfg_theme_save ()
299299{
300300 local _saved_theme=${THEME_LIST[$theme_active_idx]}
301301 fn_settings_set_param $THEME_PARAM_NAME $_saved_theme
@@ -308,24 +308,24 @@ function fn_biw_cfg_theme_save()
308308# Controller: Dimensions Configuration
309309# #
310310
311- declare -i biw_dims_save_pending
311+ declare -i bui_dims_save_pending
312312
313- function fn_biw_controller_cfg_dims ()
313+ function fn_bui_controller_cfg_dims ()
314314{
315- biw_dims_save_pending =0
315+ bui_dims_save_pending =0
316316
317317 declare -a slider_ctl_width=(
318318 [$SLIDER_CTL_ATTR_LABEL ]=' Width'
319319 [$SLIDER_CTL_ATTR_MIN ]=40
320320 [$SLIDER_CTL_ATTR_MAX ]=80
321- [$SLIDER_CTL_ATTR_VAL ]=$biw_panel_col_size
321+ [$SLIDER_CTL_ATTR_VAL ]=$bui_panel_col_size
322322 )
323323
324324 declare -a slider_ctl_height=(
325325 [$SLIDER_CTL_ATTR_LABEL ]=' Height'
326326 [$SLIDER_CTL_ATTR_MIN ]=8
327327 [$SLIDER_CTL_ATTR_MAX ]=40
328- [$SLIDER_CTL_ATTR_VAL ]=$biw_panel_row_size
328+ [$SLIDER_CTL_ATTR_VAL ]=$bui_panel_row_size
329329 )
330330
331331 local -a _slider_list=(
@@ -346,25 +346,25 @@ function fn_biw_controller_cfg_dims()
346346 if [ $? == $UTIL_ACT_CHANGED ]
347347 then
348348 # action handled so get next key
349- if(( ! biw_dims_save_pending ))
349+ if(( ! bui_dims_save_pending ))
350350 then
351351 fn_util_draw_footer ' Hit [Enter] or [Space] to save; [ESC] to cancel.'
352- biw_dims_save_pending =1
352+ bui_dims_save_pending =1
353353 fi
354354 continue
355355 fi
356356
357357 case " $_key " in
358358 $CSI_KEY_ENTER |$CSI_KEY_SPC )
359- fn_biw_cfg_dims_save
359+ fn_bui_cfg_dims_save
360360 ;;
361361 esac
362362 done
363363}
364364
365- function fn_biw_cfg_dims_save ()
365+ function fn_bui_cfg_dims_save ()
366366{
367- if(( ! biw_dims_save_pending ))
367+ if(( ! bui_dims_save_pending ))
368368 then
369369 return
370370 fi
@@ -377,8 +377,8 @@ function fn_biw_cfg_dims_save()
377377 fn_slider_redraw
378378 fn_util_draw_footer ' Changes saved to settings file.'
379379
380- biw_dims_save_pending =0
380+ bui_dims_save_pending =0
381381}
382382
383383# entry point
384- fn_biw_main
384+ fn_bui_main
0 commit comments