From e7718b92b7a79903bd945244560f1c8015f64ced Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 17 Jan 2024 00:13:14 +0900 Subject: [PATCH] Kitty image support improvements * Use `--unicode-placeholder` for consistent result in and out of tmux * Use updated version of junegunn/go-runewidth that handles diacritics used in Kitty Unicode placeholder Close #3567 --- CHANGELOG.md | 2 +- README.md | 2 +- bin/fzf-preview.sh | 2 +- go.mod | 2 +- go.sum | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f66e0a0..25cabe8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -124,7 +124,7 @@ CHANGELOG # --transfer-mode=memory is the fastest option but if you want fzf to be able # to redraw the image on terminal resize or on 'change-preview-window', # you need to use --transfer-mode=stream. - kitty icat --clear --transfer-mode=memory --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 {} | sed \$d + kitty icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 {} | sed \$d else bat --color=always {} fi diff --git a/README.md b/README.md index 04da4a4..55a3dba 100644 --- a/README.md +++ b/README.md @@ -741,7 +741,7 @@ Kitty, you can make fzf display an image in the preview window. ```sh fzf --preview=' if file --mime-type {} | grep -qF image/; then - kitty icat --clear --transfer-mode=memory --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 {} | sed \$d + kitty icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 {} | sed \$d else bat --color=always {} fi diff --git a/bin/fzf-preview.sh b/bin/fzf-preview.sh index 09cdda7..13beef8 100755 --- a/bin/fzf-preview.sh +++ b/bin/fzf-preview.sh @@ -53,7 +53,7 @@ if [[ $KITTY_WINDOW_ID ]]; then # 2. The last line of the output is the ANSI reset code without newline. # This confuses fzf and makes it render scroll offset indicator. # So we remove the last line and append the reset code to its previous line. - kitty icat --clear --transfer-mode=memory --stdin=no --place="$dim@0x0" "$file" | sed '$d' | sed $'$s/$/\e[m/' + kitty icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place="$dim@0x0" "$file" | sed '$d' | sed $'$s/$/\e[m/' # 2. Use chafa with Sixel output elif command -v chafa > /dev/null; then diff --git a/go.mod b/go.mod index d5ff775..ed4efda 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/junegunn/fzf require ( github.com/gdamore/tcell/v2 v2.5.4 - github.com/junegunn/go-runewidth v0.0.0-20240114080738-1b95d8d53ad8 + github.com/junegunn/go-runewidth v0.0.15-0.20240116150947-31c2dd15ab48 github.com/mattn/go-isatty v0.0.17 github.com/mattn/go-shellwords v1.0.12 github.com/rivo/uniseg v0.4.4 diff --git a/go.sum b/go.sum index 00432fa..3831511 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdk github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/tcell/v2 v2.5.4 h1:TGU4tSjD3sCL788vFNeJnTdzpNKIw1H5dgLnJRQVv/k= github.com/gdamore/tcell/v2 v2.5.4/go.mod h1:dZgRy5v4iMobMEcWNYBtREnDZAT9DYmfqIkrgEMxLyw= -github.com/junegunn/go-runewidth v0.0.0-20240114080738-1b95d8d53ad8 h1:qcSgFcU7GG0oYYbUzJJvv2AcJRPzjVZLwrL4ZahMpOw= -github.com/junegunn/go-runewidth v0.0.0-20240114080738-1b95d8d53ad8/go.mod h1:Mq6NazeZhIIQPMFoInCi35AktcN/MuW2elHsDK5N52w= +github.com/junegunn/go-runewidth v0.0.15-0.20240116150947-31c2dd15ab48 h1:546WmTZE4BUDJXhKlsaqhgdAPt+yWp82cNkzJxsvVDQ= +github.com/junegunn/go-runewidth v0.0.15-0.20240116150947-31c2dd15ab48/go.mod h1:Mq6NazeZhIIQPMFoInCi35AktcN/MuW2elHsDK5N52w= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=