Switch keys

This commit is contained in:
2025-09-05 09:35:25 +02:00
parent 45d75fe9cc
commit dac9e5c332
2 changed files with 62 additions and 37 deletions

View File

@@ -356,6 +356,13 @@ mpv_start
# The argument is stored in $FZF_LIST_LABEL. To set the argument, call
# `change-list-label($arg)`.
IN_NORMAL_MODE="[ \"\$FZF_INPUT_STATE\" = \"hidden\" ]"
IN_VIEW_PATTERN="[ \"\$FZF_BORDER_LABEL\" = \"%s\" ]"
IN_LIST_ARTISTS_VIEW="$(printf "$IN_VIEW_PATTERN" "$VIEW_LIST_ARTISTS")"
IN_LIST_ALBUMS_VIEW="$(printf "$IN_VIEW_PATTERN" "$VIEW_LIST_ALBUMS")"
IN_SEARCH_ARTIST_VIEW="$(printf "$IN_VIEW_PATTERN" "$VIEW_SEARCH_ARTIST")"
IN_SEARCH_ALBUM_VIEW="$(printf "$IN_VIEW_PATTERN" "$VIEW_SEARCH_ALBUM")"
FZF_CURRENT_MODE="\$FZF_INPUT_STATE"
FZF_CURRENT_VIEW="\$FZF_BORDER_LABEL"
PUT_FZF_KEY_LOGIC="case \"\$FZF_KEY\" in \"space\") echo \"put( )\";; \"backspace\"|\"bspace\"|\"bs\") echo \"backward-delete-char\";; \"delete\"|\"del\") echo \"delete-char\";; *) echo \"put(\$FZF_KEY)\";; esac"
while true; do
case "$VIEW" in
@@ -432,15 +439,27 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
--bind="$KEYS_N_UP:transform:$IN_NORMAL_MODE && echo \"up\" || $PUT_FZF_KEY_LOGIC" \
--bind="$KEYS_N_BOT:transform:$IN_NORMAL_MODE && echo \"last\" || $PUT_FZF_KEY_LOGIC" \
--bind="$KEYS_N_TOP:transform:$IN_NORMAL_MODE && echo \"first\" || $PUT_FZF_KEY_LOGIC" \
--bind="$KEYS_IN:transform:[ {3} ] && $0 --draw \$FZF_INPUT_STATE \$FZF_BORDER_LABEL {3} \"+1\"" \
--bind="$KEYS_OUT:transform:[ {2} ] && $0 --draw \$FZF_INPUT_STATE \$FZF_BORDER_LABEL {2} \"-1\"" \
--bind="$KEYS_N_IN:transform:$IN_NORMAL_MODE && ([ {3} ] && $0 --draw \$FZF_INPUT_STATE \$FZF_BORDER_LABEL {3} \"+1\") || $PUT_FZF_KEY_LOGIC" \
--bind="$KEYS_N_OUT:transform:$IN_NORMAL_MODE && ([ {2} ] && $0 --draw \$FZF_INPUT_STATE \$FZF_BORDER_LABEL {2} \"-1\") || $PUT_FZF_KEY_LOGIC" \
--bind="$KEYS_JUMPTO_ARTIST:transform:$0 --jumpto-artist \$FZF_INPUT_STATE \$FZF_BORDER_LABEL {2} {3}" \
--bind="$KEYS_JUMPTO_LIST_ARTISTS:transform:$0 --draw \$FZF_INPUT_STATE $VIEW_LIST_ARTISTS" \
--bind="$KEYS_JUMPTO_LIST_ALBUMS:transform:$0 --draw \$FZF_INPUT_STATE $VIEW_LIST_ALBUMS" \
--bind="$KEYS_JUMPTO_SEARCH_ARTIST:transform:$0 --draw $MODE_INSERT $VIEW_SEARCH_ARTIST" \
--bind="$KEYS_JUMPTO_SEARCH_ALBUM:transform:$0 --draw $MODE_INSERT $VIEW_SEARCH_ALBUM" \
--bind="$KEYS_IN:transform:[ {3} ] && $0 --draw $FZF_CURRENT_MODE $FZF_CURRENT_VIEW {3} \"+1\"" \
--bind="$KEYS_OUT:transform:[ {2} ] && $0 --draw $FZF_CURRENT_MODE $FZF_CURRENT_VIEW {2} \"-1\"" \
--bind="$KEYS_N_IN:transform:$IN_NORMAL_MODE && ([ {3} ] && $0 --draw $FZF_CURRENT_MODE $FZF_CURRENT_VIEW {3} \"+1\") || $PUT_FZF_KEY_LOGIC" \
--bind="$KEYS_N_OUT:transform:$IN_NORMAL_MODE && ([ {2} ] && $0 --draw $FZF_CURRENT_MODE $FZF_CURRENT_VIEW {2} \"-1\") || $PUT_FZF_KEY_LOGIC" \
--bind="$KEYS_SELECT_ARTIST:transform:$0 --jumpto-artist $FZF_CURRENT_MODE $FZF_CURRENT_VIEW {2} {3}" \
--bind="$KEYS_LIST_ARTISTS:transform:$0 --draw \$FZF_INPUT_STATE $VIEW_LIST_ARTISTS" \
--bind="$KEYS_LIST_ALBUMS:transform:$0 --draw \$FZF_INPUT_STATE $VIEW_LIST_ALBUMS" \
--bind="$KEYS_SEARCH_ARTIST:transform:$0 --draw $MODE_INSERT $VIEW_SEARCH_ARTIST" \
--bind="$KEYS_SEARCH_ALBUM:transform:$0 --draw $MODE_INSERT $VIEW_SEARCH_ALBUM" \
--bind="$KEYS_SWITCH_ARTIST_ALBUM:transform:case \"$FZF_CURRENT_VIEW\" in
\"$VIEW_LIST_ARTISTS\") $0 --draw $FZF_CURRENT_MODE $VIEW_LIST_ALBUMS ;;
\"$VIEW_LIST_ALBUMS\") $0 --draw $FZF_CURRENT_MODE $VIEW_LIST_ARTISTS ;;
\"$VIEW_SEARCH_ARTIST\") $0 --draw $MODE_INSERT $VIEW_SEARCH_ALBUM ;;
\"$VIEW_SEARCH_ALBUM\") $0 --draw $MODE_INSERT $VIEW_SEARCH_ARTIST ;;
esac" \
--bind="$KEYS_SWITCH_LOCAL_REMOTE:transform:case \"$FZF_CURRENT_VIEW\" in
\"$VIEW_LIST_ARTISTS\") $0 --draw $MODE_INSERT $VIEW_SEARCH_ARTIST ;;
\"$VIEW_LIST_ALBUMS\") $0 --draw $MODE_INSERT $VIEW_SEARCH_ALBUM ;;
\"$VIEW_SEARCH_ARTIST\") $0 --draw $MODE_NORMAL $VIEW_LIST_ARTISTS ;;
\"$VIEW_SEARCH_ALBUM\") $0 --draw $MODE_NORMAL $VIEW_LIST_ALBUMS ;;
esac" \
--bind="$KEYS_BROWSE:execute-silent:
[ {3} ] || exit 0
case \"\$FZF_BORDER_LABEL\" in

View File

@@ -1,30 +1,36 @@
# List of keys, organized in groups
#
# Mode selection:
# - $KEYS_I_NORMAL: Switch to normal mode (insert mode)
# - $KEYS_N_INSERT: Switch to insert mode (normal mode)
# - KEYS_I_NORMAL: Switch to normal mode (insert mode)
# - KEYS_N_INSERT: Switch to insert mode (normal mode)
#
# Vertical navigation:
# - $KEYS_DOWN: Move cursor to the next line
# - $KEYS_UP: Move cursor to the previous line
# - $KEYS_HALFPAGE_UP: Move cursor half a page up
# - $KEYS_HALFPAGE_DOWN: Move cursor half a page up
# - $KEYS_N_DOWN: Move cursor to the next line (normal mode)
# - $KEYS_N_UP: Move cursor to the previous line (normal mode)
# - $KEYS_N_BOT: Move cursor to the last line (normal mode)
# - $KEYS_N_TOP: Move cursor to the first line (normal mode)
# - KEYS_DOWN: Move cursor to the next line
# - KEYS_UP: Move cursor to the previous line
# - KEYS_HALFPAGE_UP: Move cursor half a page up
# - KEYS_HALFPAGE_DOWN: Move cursor half a page up
# - KEYS_N_DOWN: Move cursor to the next line (normal mode)
# - KEYS_N_UP: Move cursor to the previous line (normal mode)
# - KEYS_N_BOT: Move cursor to the last line (normal mode)
# - KEYS_N_TOP: Move cursor to the first line (normal mode)
#
# Horizontal navigation:
# - $KEYS_IN: Enter into selected item, down the hierarchy
# - $KEYS_OUT: Leave current item, up the hierarchy
# - $KEYS_N_IN: Enter into selected item, down the hierarchy (normal mode)
# - $KEYS_N_OUT: Leave current item, up the hierarchy (normal mode)
# - $KEYS_JUMPTO_ARTIST: Go to artist of selected entry (in case of multiple
# artists, provide a choice)
# - $KEYS_JUMPTO_LIST_ARTISTS: Go to VIEW_LIST_ARTISTS
# - $KEYS_JUMPTO_LIST_ALBUMS: Go to VIEW_LIST_ALBUMS
# - $KEYS_JUMPTO_SEARCH_ARTIST: Go to VIEW_SEARCH_ARTIST
# - $KEYS_JUMPTO_SEARCH_ALBUM: Go to VIEW_SEARCH_ALBUM
# - KEYS_IN: Enter into selected item, down the hierarchy
# - KEYS_OUT: Leave current item, up the hierarchy
# - KEYS_N_IN: Enter into selected item, down the hierarchy (normal mode)
# - KEYS_N_OUT: Leave current item, up the hierarchy (normal mode)
# - KEYS_SELECT_ARTIST: Go to artist of selected entry (in case of multiple
# artists, provide a choice)
# - KEYS_LIST_ARTISTS: Go to VIEW_LIST_ARTISTS
# - KEYS_LIST_ALBUMS: Go to VIEW_LIST_ALBUMS
# - KEYS_SEARCH_ARTIST: Go to VIEW_SEARCH_ARTIST
# - KEYS_SEARCH_ALBUM: Go to VIEW_SEARCH_ALBUM
# - KEYS_SWITCH_ARTIST_ALBUM: Switch artist and album views, i.e.,
# VIEW_LIST_ARTISTS <-> VIEW_LIST_ALBUMS, and VIEW_SEARCH_ARTIST <->
# VIEW_SEARCH_ALBUM.
# - KEYS_SWITCH_LOCAL_REMOTE: Switch between locally available music and remote
# search views, i.e., VIEW_LIST_ARTISTS <-> VIEW_SEARCH_ARTIST, and
# VIEW_LIST_ALBUMS <-> VIEW_SEARCH_ALBUM.
#
# Filtering:
#
@@ -37,7 +43,7 @@
# Mode selection:
KEYS_I_NORMAL="${KEYS_I_NORMAL:-"esc"}"
KEYS_N_INSERT="${KEYS_N_INSERT:-"a,i,/"}"
KEYS_N_INSERT="${KEYS_N_INSERT:-"a,i,/,?"}"
# Vertical navigation:
KEYS_DOWN="${KEYS_DOWN:-"ctrl-j,down"}"
@@ -54,11 +60,13 @@ KEYS_IN="${KEYS_IN:-"ctrl-l"}"
KEYS_OUT="${KEYS_OUT:-"ctrl-h"}"
KEYS_N_IN="${KEYS_N_IN:-"l"}"
KEYS_N_OUT="${KEYS_N_OUT:-"h"}"
KEYS_JUMPTO_ARTIST="${KEYS_JUMPTO_ARTIST:-"ctrl-a"}"
KEYS_JUMPTO_LIST_ARTISTS="${KEYS_JUMPTO_LIST_ARTISTS:-"alt-a"}"
KEYS_JUMPTO_LIST_ALBUMS="${KEYS_JUMPTO_LIST_ALBUMS:-"alt-s"}"
KEYS_JUMPTO_SEARCH_ARTIST="${KEYS_JUMPTO_SEARCH_ARTIST:-"alt-z"}"
KEYS_JUMPTO_SEARCH_ALBUM="${KEYS_JUMPTO_SEARCH_ALBUM:-"alt-x"}"
KEYS_SELECT_ARTIST="${KEYS_SELECT_ARTIST:-"ctrl-a"}"
KEYS_LIST_ARTISTS="${KEYS_LIST_ARTISTS:-"alt-a"}"
KEYS_LIST_ALBUMS="${KEYS_LIST_ALBUMS:-"alt-s"}"
KEYS_SEARCH_ARTIST="${KEYS_SEARCH_ARTIST:-"alt-z"}"
KEYS_SEARCH_ALBUM="${KEYS_SEARCH_ALBUM:-"alt-x"}"
KEYS_SWITCH_ARTIST_ALBUM="${KEYS_SWITCH_ARTIST_ALBUM:-"tab"}"
KEYS_SWITCH_LOCAL_REMOTE="${KEYS_SWITCH_LOCAL_REMOTE:-"ctrl-/"}"
# ...
@@ -82,8 +90,6 @@ 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"}"