keybinding help

This commit is contained in:
2025-09-12 13:26:19 +02:00
parent 98145031d3
commit 173c717be5
5 changed files with 272 additions and 115 deletions

View File

@@ -80,6 +80,9 @@ MODE_INSERT="show"
# FZF handlers
. "sh/fzf.sh"
# Load keys
. "sh/keys.sh"
# Command-line options that may only be used internally.
# --lines
# --playback
@@ -89,7 +92,8 @@ MODE_INSERT="show"
# --action-gotoartist
# --action-draw
# --mbsearch
# --preview-artist
# --preview
# --show-keybindings
case "${1:-}" in
"--lines")
# Print lines that are fed into fzf.
@@ -301,14 +305,26 @@ case "${1:-}" in
mb_search_async "$2"
exit 0
;;
"--preview-artist")
# Generate content for artist preview
"--preview")
# Generate content for preview window
#
# @argument $2: MusicBrainz Artist ID
# @argument $2: view
# @argument $3: MusicBrainz ID of selected item
#
# This prints the text to be displayed in the preview window for the
# specified artist.
preview_artist "$2"
# This prints the text to be displayed in the preview window.
view=$2
mbid="${3:-}"
case "$view" in
"$VIEW_LIST_ARTISTS" | "$VIEW_SEARCH_ARTIST") preview_artist "$mbid" ;;
*) preview_nothing ;;
esac
exit 0
;;
"--show-keybindings")
# Print keybindings for current view
#
# @argument $2: view
print_keybindings "$2"
exit 0
;;
esac
@@ -432,7 +448,6 @@ esac
# Start application:
# - load and export preset filters
# - load and export keys
# - set title
# - check for missing data from MusicBrainz
# - precompute main views
@@ -443,9 +458,6 @@ esac
# Load filters
. "sh/filter.sh"
# Load keys
. "sh/keys.sh"
# Set window title
printf '\033]0;%s\007' "$WINDOW_TITLE"
@@ -641,13 +653,18 @@ open \"\$(dirname {4})\"" \
--bind="$KEYS_N_YANK:transform:$IN_NORMAL_MODE && echo \"execute-silent(printf {3} | $CLIP)\" || $PUT_FZF_KEY_LOGIC" \
--bind="$KEYS_YANK_CURRENT:execute-silent:printf {2} | $CLIP" \
--bind="$KEYS_SHOW_PLAYLIST:transform:echo \"print($VIEW_PLAYLIST)+print()+print($FZF_CURRENT_VIEW)+print({2})+accept\"" \
--bind="$KEYS_KEYBINDINGS:preview:$0 --show-keybindings $FZF_CURRENT_VIEW" \
--bind="$KEYS_QUIT:print($VIEW_QUIT)+accept" \
--bind="$KEYS_N_QUIT:transform:$IN_NORMAL_MODE && ($IN_LIST_ARTISTS_VIEW && echo \"print($VIEW_QUIT)+accept\" || $0 --action-draw $MODE_NORMAL $VIEW_LIST_ARTISTS) || $PUT_FZF_KEY_LOGIC" \
--bind="$KEYS_SCROLL_PREVIEW_DOWN:preview-down" \
--bind="$KEYS_SCROLL_PREVIEW_UP:preview-up" \
--bind="$KEYS_PREVIEW_OPEN:show-preview" \
--bind="$KEYS_PREVIEW_CLOSE:hide-preview" \
--bind="$KEYS_PLAYBACK:transform:$0 --playback $FZF_CURRENT_VIEW {2} {3} {4}" \
--bind="$KEYS_N_PLAYBACK:transform:$IN_NORMAL_MODE && $0 --playback $FZF_CURRENT_VIEW {2} {3} {4} || $PUT_FZF_KEY_LOGIC" \
--bind="change:execute-silent($0 --mbsearch $FZF_CURRENT_VIEW &)+reload:$0 --lines $FZF_CURRENT_VIEW" \
--preview-window="right,25%,border-left,wrap,<30(hidden)" \
--preview="$0 --preview-artist {3}" \
--preview="$0 --preview $FZF_CURRENT_VIEW {3}" \
--delimiter="\t" \
--with-nth="{1}" || true
)