diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2023-10-07 18:20:27 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2023-10-07 18:36:33 +0900 |
| commit | d8188fce7b7bea982e7f9050c35e488e49fb8fd0 (patch) | |
| tree | 5391297645ff3d5d19b4dba6885b92a388e21633 /src/tui/light.go | |
| parent | 0f15f1ab73826b615caf395473160efc355143cb (diff) | |
| download | fzf-d8188fce7b7bea982e7f9050c35e488e49fb8fd0.tar.gz | |
Experimental support for Kitty image protocol in preview window
Close #3228
* Works inside and outside of tmux
* There is a problem where fzf unnecessarily displays the scroll offset
indicator at the topbright of the screen when the image just fits the
preview window. This is because `kitty icat` generates an extra line
after the image area.
# A 5-row images; an extra row at the end confuses fzf
["\e_Ga ... \e[9C̅̅ࠪ̅̍ࠪ̅̎ࠪ̅̐ࠪ̅̒ࠪ̅̽ࠪ̅̾ࠪ̅̿ࠪ̅͆ࠪ̅͊ࠪ̅͋ࠪ\n",
"\r\e[9C̍̅ࠪ̍̍ࠪ̍̎ࠪ̍̐ࠪ̍̒ࠪ̍̽ࠪ̍̾ࠪ̍̿ࠪ̍͆ࠪ̍͊ࠪ̍͋ࠪ\n",
"\r\e[9C̎̅ࠪ̎̍ࠪ̎̎ࠪ̎̐ࠪ̎̒ࠪ̎̽ࠪ̎̾ࠪ̎̿ࠪ̎͆ࠪ̎͊ࠪ̎͋ࠪ\n",
"\r\e[9C̐̅ࠪ̐̍ࠪ̐̎ࠪ̐̐ࠪ̐̒ࠪ̐̽ࠪ̐̾ࠪ̐̿ࠪ̐͆ࠪ̐͊ࠪ̐͋ࠪ\n",
"\r\e[9C̒̅ࠪ̒̍ࠪ̒̎ࠪ̒̐ࠪ̒̒ࠪ̒̽ࠪ̒̾ࠪ̒̿ࠪ̒͆ࠪ̒͊ࠪ̒͋ࠪ\n",
"\r\e[39m\e8"]
* Example:
fzf --preview='
if file --mime-type {} | grep -qF 'image/'; then
# --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 {}
else
bat --color=always {}
fi
'
Diffstat (limited to 'src/tui/light.go')
| -rw-r--r-- | src/tui/light.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/tui/light.go b/src/tui/light.go index cff59c90..cc828fa9 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -31,6 +31,11 @@ const consoleDevice string = "/dev/tty" var offsetRegexp *regexp.Regexp = regexp.MustCompile("(.*)\x1b\\[([0-9]+);([0-9]+)R") var offsetRegexpBegin *regexp.Regexp = regexp.MustCompile("^\x1b\\[[0-9]+;[0-9]+R") +func (r *LightRenderer) PassThrough(str string) { + r.queued.WriteString(str) + r.flush() +} + func (r *LightRenderer) stderr(str string) { r.stderrInternal(str, true, "") } |
