66# reserved. See LICENSE.
77# #
88
9+ # Layout
10+ declare -ri HMENU_HEIGHT=1
11+ declare -ri HMENU_ITEM_WIDTH=12
12+
913# Indexes
1014declare -i hmenu_idx_active=0
1115declare -i hmenu_idx_end
1216
13- # Layout
14- declare -ri hmenu_height=1
15- declare -i hmenu_item_width=12
16-
1717# Data
1818declare -a hmenu_data_values
1919declare -i hmenu_data_size
@@ -33,15 +33,17 @@ fn_hmenu_actions()
3333{
3434 local _key=$1
3535 case " $_key " in
36- $csi_key_left )
37- fn_hmenu_action_left || return $biw_act_terminate
36+ $CSI_KEY_LEFT )
37+ fn_hmenu_action_left
38+ return $?
3839 ;;
39- $csi_key_right )
40- fn_hmenu_action_right || return $biw_act_terminate
40+ $CSI_KEY_RIGHT )
41+ fn_hmenu_action_right
42+ return $?
4143 ;;
4244 esac
4345
44- return $biw_act_continue
46+ return $BIW_ACT_IGNORED
4547}
4648
4749function fn_hmenu_get_current_val()
@@ -54,7 +56,7 @@ function fn_hmenu_action_left()
5456 if(( hmenu_idx_active <= 0 ))
5557 then
5658 # can't move
57- return $biw_act_terminate
59+ return $BIW_ACT_IGNORED
5860 fi
5961
6062 (( hmenu_idx_active -= 1 ))
@@ -66,15 +68,15 @@ function fn_hmenu_action_left()
6668 fn_hmenu_draw_item $(( hmenu_idx_active + 1 ))
6769 fn_hmenu_draw_item $(( hmenu_idx_active))
6870
69- return $biw_act_continue
71+ return $BIW_ACT_HANDLED
7072}
7173
7274function fn_hmenu_action_right()
7375{
7476 if(( hmenu_idx_active >= hmenu_idx_end))
7577 then
7678 # can't move
77- return $biw_act_terminate
79+ return $BIW_ACT_IGNORED
7880 fi
7981
8082 (( hmenu_idx_active += 1 ))
@@ -86,7 +88,7 @@ function fn_hmenu_action_right()
8688 fn_hmenu_draw_item $(( hmenu_idx_active - 1 ))
8789 fn_hmenu_draw_item $(( hmenu_idx_active))
8890
89- return $biw_act_continue
91+ return $BIW_ACT_HANDLED
9092}
9193
9294function fn_hmenu_redraw()
@@ -110,22 +112,22 @@ function fn_hmenu_draw_item()
110112 local -i _item_idx=$1
111113 local _item_value=${hmenu_data_values[_item_idx]}
112114
113- local -i _adj_menu_width=$(( hmenu_item_width - 2 ))
115+ local -i _adj_menu_width=$(( HMENU_ITEM_WIDTH - 2 ))
114116 printf -v _item_value " %-${_adj_menu_width} s" $_item_value
115117
116118 if (( _item_idx == hmenu_idx_active))
117119 then
118120 _item_value=" [${_item_value} ]"
119- fn_theme_set_bg_attr $theme_attr_active
121+ fn_theme_set_bg_attr $TATTR_ACTIVE
120122 else
121123 _item_value=" ${_item_value} "
122- fn_theme_set_bg_attr $theme_attr_background
124+ fn_theme_set_bg_attr $TATTR_BACKGROUND
123125 fi
124126
125- fn_csi_op $csi_op_col_pos $(( biw_margin + _item_idx* hmenu_item_width ))
126- fn_sgr_set $sgr_attr_underline
127+ fn_csi_op $CSI_OP_COL_POS $(( BIW_MARGIN + _item_idx* HMENU_ITEM_WIDTH ))
128+ fn_sgr_set $SGR_ATTR_UNDERLINE
127129 echo -n " $_item_value "
128130
129131 # reset colors
130- fn_sgr_set $sgr_attr_default
132+ fn_sgr_set $SGR_ATTR_DEFAULT
131133}
0 commit comments