@@ -21,86 +21,86 @@ declare -i hmenu_data_size
2121
2222function fn_hmenu_init()
2323{
24- hmenu_data_values=(" History" " Completions" )
25- hmenu_data_values=(" ${! 1} " )
26- hmenu_data_size=${# hmenu_data_values[*]}
27- hmenu_idx_end=$(( hmenu_data_size - 1 ))
24+ hmenu_data_values=(" History" " Completions" )
25+ hmenu_data_values=(" ${! 1} " )
26+ hmenu_data_size=${# hmenu_data_values[*]}
27+ hmenu_idx_end=$(( hmenu_data_size - 1 ))
2828}
2929
3030function fm_hmenu_left()
3131{
32- if(( hmenu_idx_active <= 0 ))
33- then
34- # can't move
35- return
36- fi
32+ if(( hmenu_idx_active <= 0 ))
33+ then
34+ # can't move
35+ return
36+ fi
3737
38- (( hmenu_idx_active -= 1 ))
38+ (( hmenu_idx_active -= 1 ))
3939
40- # move to correct row
41- fn_biw_cursor_home
40+ # move to correct row
41+ fn_biw_cursor_home
4242
43- # redraw affected items
44- fm_hmenu_draw_item $(( hmenu_idx_active + 1 ))
45- fm_hmenu_draw_item $(( hmenu_idx_active))
43+ # redraw affected items
44+ fm_hmenu_draw_item $(( hmenu_idx_active + 1 ))
45+ fm_hmenu_draw_item $(( hmenu_idx_active))
4646}
4747
4848function fm_hmenu_right()
4949{
50- if(( hmenu_idx_active >= hmenu_idx_end))
51- then
52- # can't move
53- return
54- fi
50+ if(( hmenu_idx_active >= hmenu_idx_end))
51+ then
52+ # can't move
53+ return
54+ fi
5555
56- (( hmenu_idx_active += 1 ))
56+ (( hmenu_idx_active += 1 ))
5757
58- # move to correct row
59- fn_biw_cursor_home
58+ # move to correct row
59+ fn_biw_cursor_home
6060
61- # redraw affected items
62- fm_hmenu_draw_item $(( hmenu_idx_active - 1 ))
63- fm_hmenu_draw_item $(( hmenu_idx_active))
61+ # redraw affected items
62+ fm_hmenu_draw_item $(( hmenu_idx_active - 1 ))
63+ fm_hmenu_draw_item $(( hmenu_idx_active))
6464}
6565
6666function fn_hmenu_redraw()
6767{
68- local _indexes=$( eval echo {0..$hmenu_idx_end })
69- local _item_idx
68+ local _indexes=$( eval echo {0..$hmenu_idx_end })
69+ local _item_idx
7070
71- # move to correct row
72- fn_biw_cursor_home
71+ # move to correct row
72+ fn_biw_cursor_home
7373
74- for _item_idx in ${_indexes}
75- do
76- fm_hmenu_draw_item $_item_idx
77- done
74+ for _item_idx in ${_indexes}
75+ do
76+ fm_hmenu_draw_item $_item_idx
77+ done
7878}
7979
8080function fm_hmenu_draw_item()
8181{
82- local -i _item_idx=$1
83- local _item_value=${hmenu_data_values[_item_idx]}
84-
85- local -i _adj_menu_width=$(( hmenu_item_width - 2 ))
86- printf -v _item_value " %-${_adj_menu_width} s" $_item_value
87-
88- local -i _item_color=$biw_color_inactive
89-
90- if (( _item_idx == hmenu_idx_active))
91- then
92- _item_value=" [${_item_value} ]"
93- _item_color=$biw_color_active
94- else
95- _item_value=" ${_item_value} "
96- fi
97-
98- fn_csi $csi_col_pos $(( biw_margin + _item_idx* hmenu_item_width))
99- fn_csi $csi_set_color $sgr_underline
100- fn_csi $csi_set_color $(( sgr_color_fg + biw_color_text))
101- fn_csi $csi_set_color $(( sgr_color_bg + _item_color))
102- echo -n " $_item_value "
103-
104- # reset colors
105- fn_csi $csi_set_color 0
82+ local -i _item_idx=$1
83+ local _item_value=${hmenu_data_values[_item_idx]}
84+
85+ local -i _adj_menu_width=$(( hmenu_item_width - 2 ))
86+ printf -v _item_value " %-${_adj_menu_width} s" $_item_value
87+
88+ local -i _item_color=$biw_color_inactive
89+
90+ if (( _item_idx == hmenu_idx_active))
91+ then
92+ _item_value=" [${_item_value} ]"
93+ _item_color=$biw_color_active
94+ else
95+ _item_value=" ${_item_value} "
96+ fi
97+
98+ fn_csi $csi_col_pos $(( biw_margin + _item_idx* hmenu_item_width))
99+ fn_csi $csi_set_color $sgr_underline
100+ fn_csi $csi_set_color $(( sgr_color_fg + biw_color_text))
101+ fn_csi $csi_set_color $(( sgr_color_bg + _item_color))
102+ echo -n " $_item_value "
103+
104+ # reset colors
105+ fn_csi $csi_set_color 0
106106}
0 commit comments