Files
fuzic/src/sh/keys.sh

87 lines
4.2 KiB
Bash

# Key bindings
#
# Some key-bindings are used exclusively in the normal mode, others exclusively
# in the insert mode, others in both modes.
# Some key-bindings are universal in the sense that they do not depend on the
# state of the player (view, mode, arguments), others are not universal.
#
# For fast processing, we propose the following.
# The mode (normal or insert) is stored in the FZF_INPUT_STATE variable. All
# key-bindings that are independent of the `view` and of the `arguments` are
# directly processed using a `--bind` with inline transform element. Keys that
# depend on `view` or `arguments` are processed through `$0 --fzf-key`. In a
# future step, we may also store the `view` part of the state as hidden fields
# in the list (the list generator makes that). Then, it may be possible to
# completely get rid of the state files. Even beter, we may store the view part
# in FZF_HEADER_LABEL.
#
# Switching between the modes (normal <-> insert) is done using two fzf `--bind`
# arguments. We make sure that only one is active.
KEYS_I_NORMAL="${KEYS_I_NORMAL:-"esc"}"
KEYS_N_INSERT="${KEYS_N_INSERT:-"a,i,/"}"
KEYS_INPUT_SINGLE='0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,!,",#,$,%,&,\,(,),*,+,,,-,.,/,:,;,<,=,>,?,@,[,\,\,],^,_,`,{,|,},~'
KEYS_INPUT_SINGLE="$KEYS_INPUT_SINGLE,'"
KEYS_INPUT_SPECIAL="space,backspace,delete,left,right"
export KEYS_INPUT_SINGLE KEYS_INPUT_SPECIAL
# Normal and insert mode
KEYS_HALFPAGE_DOWN="${KEYS_HALFPAGE_DOWN:-"ctrl-d"}"
KEYS_HALFPAGE_UP="${KEYS_HALFPAGE_UP:-"ctrl-u"}"
KEYS_BROWSE="${KEYS_BROWSE:-"alt-b"}"
KEYS_OPEN="${KEYS_OPEN:-"alt-o"}"
KEYS_OUT="${KEYS_OUT:-"ctrl-h"}"
KEYS_IN="${KEYS_IN:-"ctrl-l"}"
KEYS_SELECT_ARTIST="${KEYS_SELECT_ARTIST:-"ctrl-a"}"
KEYS_FILTER_LOCAL="${KEYS_FILTER_LOCAL:-"alt-l"}"
KEYS_FILTER_1="${KEYS_FILTER_1:-"alt-1"}"
KEYS_FILTER_2="${KEYS_FILTER_2:-"alt-2"}"
KEYS_FILTER_3="${KEYS_FILTER_3:-"alt-3"}"
KEYS_FILTER_4="${KEYS_FILTER_4:-"alt-4"}"
KEYS_SWITCH_ARTIST_ALBUM="${KEYS_SWITCH_ARTIST_ALBUM:-"tab"}"
KEYS_SWITCH_LOCAL_REMOTE="${KEYS_SWITCH_LOCAL_REMOTE:-"ctrl-/"}"
KEYS_PLAY="${KEYS_PLAY:-"enter"}"
KEYS_QUEUE="${KEYS_QUEUE:-"ctrl-alt-m"}"
KEYS_SHOW_PLAYLIST="${KEYS_SHOW_PLAYLIST:-"ctrl-p"}"
KEYS_NI="$KEYS_HALFPAGE_DOWN,$KEYS_HALFPAGE_UP,$KEYS_BROWSE,$KEYS_OPEN,$KEYS_OUT,$KEYS_IN,$KEYS_SELECT_ARTIST,$KEYS_FILTER_LOCAL,$KEYS_FILTER_1,$KEYS_FILTER_2,$KEYS_FILTER_3,$KEYS_FILTER_4,$KEYS_SWITCH_ARTIST_ALBUM,$KEYS_SWITCH_LOCAL_REMOTE,$KEYS_PLAY,$KEYS_QUEUE,$KEYS_SHOW_PLAYLIST"
export KEYS_NI
# Keys in normal mode only
KEYS_N_DOWN="${KEYS_N_DOWN:-"j"}"
KEYS_N_UP="${KEYS_N_UP:-"k"}"
KEYS_N_OUT="${KEYS_N_OUT:-"h"}"
KEYS_N_IN="${KEYS_N_IN:-"l"}"
KEYS_N_TOP="${KEYS_N_TOP:-"1"}"
KEYS_N_BOT="${KEYS_N_BOT:-"G"}"
KEYS_N_QUIT="${KEYS_N_QUIT:-"q"}"
KEYS_N_INSERT="${KEYS_N_INSERT:-"a,i,/"}"
KEYS_N_TOGGLE_PLAY_PAUSE="${KEYS_N_TOGGLE_PLAY_PAUSE:-"space"}"
KEYS_N_PLAY_NEXT="${KEYS_N_PLAY_NEXT:-"right"}"
KEYS_N_PLAY_PREV="${KEYS_N_PLAY_PREV:-"left"}"
KEYS_N_SEEK_FORWARD="${KEYS_N_SEEK_FORWARD:-"shift-right"}"
KEYS_N_SEEK_BACKWARD="${KEYS_N_SEEK_BACKWARD:-"shift-left"}"
KEYS_N="$KEYS_N_DOWN,$KEYS_N_UP,$KEYS_N_OUT,$KEYS_N_IN,$KEYS_N_TOP,$KEYS_N_BOT,$KEYS_N_QUIT,$KEYS_N_INSERT,$KEYS_N_TOGGLE_PLAY_PAUSE,$KEYS_N_PLAY_NEXT,$KEYS_N_PLAY_PREV,$KEYS_N_SEEK_FORWARD,$KEYS_N_SEEK_BACKWARD"
export KEYS_N
# Keys in insert mode only
KEYS_I_NORMAL="${KEYS_I_NORMAL:-"esc"}"
KEYS_I="$KEYS_I_NORMAL"
export KEYS_I
# Special playlist keys
KEYS_PLAYLIST_RELOAD="${KEYS_PLAYLIST_RELOAD:-"r"}"
KEYS_PLAYLIST="$KEYS_PLAYLIST_RELOAD"
export KEYS_PLAYLIST
# Grouping
KEYS_ALL="$KEYS_NI,$KEYS_N,$KEYS_I,$KEYS_INPUT_SINGLE,$KEYS_INPUT_SPECIAL,$KEYS_PLAYLIST"
export KEYS_HALFPAGE_DOWN KEYS_HALFPAGE_UP KEYS_OPEN KEYS_BROWSE KEYS_OUT KEYS_IN \
KEYS_SELECT_ARTIST KEYS_FILTER_LOCAL KEYS_FILTER_1 KEYS_FILTER_2 KEYS_FILETER_3 KEYS_FILTER_4 \
KEYS_SWITCH_ARTIST_ALBUM KEYS_SWITCH_LOCAL_REMOTE KEYS_PLAY KEYS_QUEUE \
KEYS_N_DOWN KEYS_N_UP KEYS_N_OUT KEYS_N_IN KEYS_N_TOP KEYS_N_BOT KEYS_N_QUIT KEYS_N_INSERT \
KEYS_N_TOGGLE_PLAY_PAUSE KEYS_N_PLAY_NEXT KEYS_N_PLAY_PREV KEYS_N_SEEK_FORWARD \
KEYS_N_SEEK_BACKWARD KEYS_SHOW_PLAYLIST \
KEYS_I_NORMAL \
KEYS_GROUP_NI KEYS_GROUP_N KEYS_GROUP_I KEYS PLAYLIST KEYS_ALL