Skip to content
Myr

sixel: Better handling of animated GIFs (#2544)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 69176fc · Browse files · 2 files+10 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−5 removed

  • other:+10 added−5 removed

2 files+10 added−5 removed

modified:src/tui/light.go-1 removed
31 unmodified lines
32var offsetRegexpBegin *regexp.Regexp = regexp.MustCompile("^\x1b\\[[0-9]+;[0-9]+R")3334func (r *LightRenderer) PassThrough(str string) {35 r.queued.WriteString("\x1b7" + str + "\x1b8")36 r.flush()36}3738func (r *LightRenderer) stderr(str string) {39 r.stderrInternal(str, true, "")
1068 unmodified lines
modified:src/terminal.go+10 added-4 removed
64 unmodified lines
65 // Parts of the preview output that should be passed through to the terminal66 // * https://github.com/tmux/tmux/wiki/FAQ#what-is-the-passthrough-escape-sequence-and-how-do-i-use-it67 // * https://sw.kovidgoyal.net/kitty/graphics-protocol68 // * https://en.wikipedia.org/wiki/Sixel69 passThroughRegex = regexp.MustCompile(`\x1bPtmux;\x1b\x1b.*?[^\x1b]\x1b\\|\x1b(_G|P[0-9;]*q).*?\x1b\\`)69 passThroughRegex = regexp.MustCompile(`\x1bPtmux;\x1b\x1b.*?[^\x1b]\x1b\\|\x1b(_G|P[0-9;]*q).*?\x1b\\\r?`)70}7172type jumpMode int73
1921 unmodified lines
1995func (t *Terminal) renderPreviewText(height int, lines []string, lineNo int, unchanged bool) {1996 maxWidth := t.pwindow.Width()1997 var ansi *ansiState1998 spinnerRedraw := t.pwindow.Y() == 01999 wiped := false2000 sixel := false2001 wireframe := false2002Loop:2003 for _, line := range lines {
19 unmodified lines
2023 spinnerRedraw = false2024 t.renderPreviewSpinner()2025 t.pwindow.Move(y, x)2026 }2026 for _, passThrough := range passThroughs {2027 for idx, passThrough := range passThroughs {2028 // Handling Sixel output2029 requiredLines := 02030 isSixel := strings.HasPrefix(passThrough, "\x1bP")2031 if isSixel {
18 unmodified lines
2050 break Loop2051 }20522053 // Clear previous wireframe or any other text2053 if t.previewed.wireframe || isSixel && !t.previewed.sixel {2054 if (t.previewed.wireframe || isSixel && !t.previewed.sixel) && !wiped {2055 wiped = true2056 for i := y + 1; i < height; i++ {2057 t.pwindow.MoveAndClear(i, 0)2058 }2059 }2060 sixel = sixel || isSixel2061 if idx == 0 {2059 t.pwindow.MoveAndClear(y, x)2062 t.pwindow.MoveAndClear(y, x)2063 } else {2064 t.pwindow.Move(y, x)2065 }2066 t.tui.PassThrough(passThrough)20672068 if requiredLines > 0 {2069 if y+requiredLines == height {
1937 unmodified lines