Skip to content

Commit 1c1fb85

Browse files
author
Chad Juliano
committed
Convert tabs to spaces.
1 parent 3d112cd commit 1c1fb85

File tree

5 files changed

+425
-425
lines changed

5 files changed

+425
-425
lines changed

src/biw-bind.sh

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,79 +7,79 @@
77
##
88

99
function fn_biw_init()
10-
{
11-
fn_check_interactive
12-
fn_biw_set_env
10+
{
11+
fn_check_interactive
12+
fn_biw_set_env
1313

14-
# some keys you can bind
15-
local -r key_f1='OP'
16-
local -r key_f2='OQ'
17-
local -r key_f10='[21~'
18-
local -r key_f11='[23~'
19-
local -r key_f12='[24~'
20-
local -r key_up='[A'
21-
local -r key_down='[B'
22-
local -r key_left='[D'
23-
local -r key_right='[C'
14+
# some keys you can bind
15+
local -r key_f1='OP'
16+
local -r key_f2='OQ'
17+
local -r key_f10='[21~'
18+
local -r key_f11='[23~'
19+
local -r key_f12='[24~'
20+
local -r key_up='[A'
21+
local -r key_down='[B'
22+
local -r key_left='[D'
23+
local -r key_right='[C'
2424

25-
# set bind key here
26-
fn_choose_bind $key_down
25+
# set bind key here
26+
fn_choose_bind $key_down
2727
}
2828

2929
function fn_choose_bind()
3030
{
31-
local -r _bind_key=$1
31+
local -r _bind_key=$1
3232

33-
# We use 2 binds here because of an issue bash has with
34-
# multi-char escape sequences.
35-
local -r bind_int_char=$'"\201"'
36-
local -r bind_esc_char="\"\e${_bind_key}\""
33+
# We use 2 binds here because of an issue bash has with
34+
# multi-char escape sequences.
35+
local -r bind_int_char=$'"\201"'
36+
local -r bind_esc_char="\"\e${_bind_key}\""
3737

38-
bind -x ${bind_int_char}:fn_choose_show
39-
bind ${bind_esc_char}:${bind_int_char}
38+
bind -x ${bind_int_char}:fn_choose_show
39+
bind ${bind_esc_char}:${bind_int_char}
4040
}
4141

4242
function fn_choose_show()
4343
{
44-
if ! ${BIW_HOME}/biw-hist-chooser.sh
45-
then
46-
return 1
47-
fi
44+
if ! ${BIW_HOME}/biw-hist-chooser.sh
45+
then
46+
return 1
47+
fi
4848

49-
READLINE_LINE=$(cat $BIW_CH_RES_FILE)
50-
READLINE_POINT=${#READLINE_LINE}
49+
READLINE_LINE=$(cat $BIW_CH_RES_FILE)
50+
READLINE_POINT=${#READLINE_LINE}
5151

52-
rm $BIW_CH_RES_FILE
52+
rm $BIW_CH_RES_FILE
5353
}
5454

5555
function fn_check_interactive()
5656
{
57-
if [[ ! "$-" =~ "i" ]]
58-
then
59-
echo "ERROR: This script must be sourced and not executed."
60-
exit 1
61-
fi
57+
if [[ ! "$-" =~ "i" ]]
58+
then
59+
echo "ERROR: This script must be sourced and not executed."
60+
exit 1
61+
fi
6262
}
6363

6464
function fn_biw_set_env()
6565
{
66-
# file where history result will be saved
67-
export BIW_CH_RES_FILE=$HOME/.biw_selection
66+
# file where history result will be saved
67+
export BIW_CH_RES_FILE=$HOME/.biw_selection
6868

69-
# save the home dir
70-
local _script_name=${BASH_SOURCE[0]}
71-
local _script_dir=${_script_name%/*}
69+
# save the home dir
70+
local _script_name=${BASH_SOURCE[0]}
71+
local _script_dir=${_script_name%/*}
7272

73-
if [ "$_script_name" == "$_script_dir" ]
74-
then
75-
# _script name has no path
76-
_script_dir="."
77-
fi
73+
if [ "$_script_name" == "$_script_dir" ]
74+
then
75+
# _script name has no path
76+
_script_dir="."
77+
fi
7878

79-
# convert to absolute path
80-
_script_dir=$(cd $_script_dir; pwd -P)
81-
82-
export BIW_HOME=$_script_dir
79+
# convert to absolute path
80+
_script_dir=$(cd $_script_dir; pwd -P)
81+
82+
export BIW_HOME=$_script_dir
8383
}
8484

8585
# Activate bindings

src/biw-hmenu.sh

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -21,86 +21,86 @@ declare -i hmenu_data_size
2121

2222
function 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

3030
function 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

4848
function 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

6666
function 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

8080
function 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

Comments
 (0)