Skip to content

Commit 6b9641d

Browse files
author
Chad Juliano
committed
Re-factor chooser into separate file.
1 parent 31ef22f commit 6b9641d

File tree

5 files changed

+273
-258
lines changed

5 files changed

+273
-258
lines changed

src/biw-bind.sh

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
##
22
# BIW-BIND - Key binder for BIW Menus
3-
#
43
# Copyright 2017 by Chad Juliano
54
#
65
# Licensed under GNU Lesser General Public License v3.0 only. Some rights
76
# reserved. See LICENSE.
87
##
98

10-
function fn_choose_show()
11-
{
12-
if ! ${BIW_HOME}/biw-hist-chooser.sh
13-
then
14-
return 1
15-
fi
9+
function fn_biw_init()
10+
{
11+
# some keys you can bind
12+
local -r key_f1='OP'
13+
local -r key_f2='OQ'
14+
local -r key_f10='[21~'
15+
local -r key_f11='[23~'
16+
local -r key_f12='[24~'
17+
local -r key_up='[A'
18+
local -r key_down='[B'
19+
local -r key_left='[D'
20+
local -r key_right='[C'
1621

17-
READLINE_LINE=$(cat $BIW_CH_RES_FILE)
18-
READLINE_POINT=${#READLINE_LINE}
22+
# set bind key here
23+
fn_choose_bind $key_down
1924

20-
rm $BIW_CH_RES_FILE
25+
# set the BIW_HOME variable
26+
fn_biw_set_home
2127
}
2228

2329
function fn_choose_bind()
@@ -33,10 +39,23 @@ function fn_choose_bind()
3339
bind ${bind_esc_char}:${bind_int_char}
3440
}
3541

42+
function fn_choose_show()
43+
{
44+
if ! ${BIW_HOME}/biw-hist-chooser.sh
45+
then
46+
return 1
47+
fi
48+
49+
READLINE_LINE=$(cat $BIW_CH_RES_FILE)
50+
READLINE_POINT=${#READLINE_LINE}
51+
52+
rm $BIW_CH_RES_FILE
53+
}
54+
3655
function fn_biw_set_home()
3756
{
3857
# file where history result will be saved
39-
export BIW_CH_RES_FILE=$HOME/.chooser_history
58+
export BIW_CH_RES_FILE=$HOME/.biw_selection
4059

4160
# save the home dir
4261
local _script_name=${BASH_SOURCE[0]}
@@ -48,22 +67,5 @@ function fn_biw_set_home()
4867
export BIW_HOME=$_script_dir
4968
}
5069

51-
function fn_biw_init()
52-
{
53-
fn_biw_set_home
54-
55-
# some keys you can bind
56-
local -r key_f1='OP'
57-
local -r key_f2='OQ'
58-
local -r key_f10='[21~'
59-
local -r key_f11='[23~'
60-
local -r key_f12='[24~'
61-
local -r key_up='[A'
62-
local -r key_down='[B'
63-
local -r key_left='[D'
64-
local -r key_right='[C'
65-
66-
fn_choose_bind $key_down
67-
}
68-
70+
# Activate bindings
6971
fn_biw_init

0 commit comments

Comments
 (0)