diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2023-11-02 00:15:02 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2023-11-02 00:15:42 +0900 |
| commit | a0145cebf284898fce182d78a1edae7270d16f57 (patch) | |
| tree | c1081a17bdc91b8dadd39e0a3aab79e3f0f651c8 /src | |
| parent | 69176fc5f4251b33cd91fbdc43699eb0eaf76b23 (diff) | |
| download | fzf-a0145cebf284898fce182d78a1edae7270d16f57.tar.gz | |
sixel: Better handling of animated GIFs (#2544)
Diffstat (limited to 'src')
| -rw-r--r-- | src/terminal.go | 14 | ||||
| -rw-r--r-- | src/tui/light.go | 1 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/terminal.go b/src/terminal.go index 6e198ba2..494fa462 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -66,7 +66,7 @@ func init() { // * https://github.com/tmux/tmux/wiki/FAQ#what-is-the-passthrough-escape-sequence-and-how-do-i-use-it // * https://sw.kovidgoyal.net/kitty/graphics-protocol // * https://en.wikipedia.org/wiki/Sixel - passThroughRegex = regexp.MustCompile(`\x1bPtmux;\x1b\x1b.*?[^\x1b]\x1b\\|\x1b(_G|P[0-9;]*q).*?\x1b\\`) + passThroughRegex = regexp.MustCompile(`\x1bPtmux;\x1b\x1b.*?[^\x1b]\x1b\\|\x1b(_G|P[0-9;]*q).*?\x1b\\\r?`) } type jumpMode int @@ -1996,6 +1996,7 @@ func (t *Terminal) renderPreviewText(height int, lines []string, lineNo int, unc maxWidth := t.pwindow.Width() var ansi *ansiState spinnerRedraw := t.pwindow.Y() == 0 + wiped := false sixel := false wireframe := false Loop: @@ -2023,7 +2024,7 @@ Loop: t.renderPreviewSpinner() t.pwindow.Move(y, x) } - for _, passThrough := range passThroughs { + for idx, passThrough := range passThroughs { // Handling Sixel output requiredLines := 0 isSixel := strings.HasPrefix(passThrough, "\x1bP") @@ -2050,13 +2051,18 @@ Loop: } // Clear previous wireframe or any other text - if t.previewed.wireframe || isSixel && !t.previewed.sixel { + if (t.previewed.wireframe || isSixel && !t.previewed.sixel) && !wiped { + wiped = true for i := y + 1; i < height; i++ { t.pwindow.MoveAndClear(i, 0) } } sixel = sixel || isSixel - t.pwindow.MoveAndClear(y, x) + if idx == 0 { + t.pwindow.MoveAndClear(y, x) + } else { + t.pwindow.Move(y, x) + } t.tui.PassThrough(passThrough) if requiredLines > 0 { diff --git a/src/tui/light.go b/src/tui/light.go index e5080d1d..e9cf04eb 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -33,7 +33,6 @@ var offsetRegexpBegin *regexp.Regexp = regexp.MustCompile("^\x1b\\[[0-9]+;[0-9]+ func (r *LightRenderer) PassThrough(str string) { r.queued.WriteString("\x1b7" + str + "\x1b8") - r.flush() } func (r *LightRenderer) stderr(str string) { |
