Skip to content
Myr

Sixel and Kitty image support on Windows binary (#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 d0466fa · Browse files · 8 files+59 added−16 removed
This commit

State

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

Diff stats

8 files+59 added−16 removed

  • other:+59 added−16 removed

8 files+59 added−16 removed

modified:src/tui/dummy.go+2 added-1 removed
31 unmodified lines
32func (r *FullscreenRenderer) Init() {}33func (r *FullscreenRenderer) Resize(maxHeightFunc func(int) int) {}34func (r *FullscreenRenderer) Pause(bool) {}35func (r *FullscreenRenderer) Resume(bool, bool) {}36func (r *FullscreenRenderer) PassThrough(string) {}36func (r *FullscreenRenderer) PassThrough(int, int, string) {}37func (r *FullscreenRenderer) Sync(bool) {}38func (r *FullscreenRenderer) Clear() {}39func (r *FullscreenRenderer) NeedScrollbarRedraw() bool { return false }40func (r *FullscreenRenderer) Refresh() {}41func (r *FullscreenRenderer) Close() {}
12 unmodified lines
modified:src/tui/light.go+6 added-2 removed
29 unmodified lines
3031var offsetRegexp *regexp.Regexp = regexp.MustCompile("(.*)\x1b\\[([0-9]+);([0-9]+)R")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")34func (r *LightRenderer) PassThrough(y int, x int, data string) {35 r.queued.WriteString("\x1b7" + data + "\x1b8")36}3738func (r *LightRenderer) Sync(bool) {39 // No-op40}4142func (r *LightRenderer) stderr(str string) {43 r.stderrInternal(str, true, "")44}45
1074 unmodified lines
modified:src/tui/tcell.go+19 added-6 removed
96 unmodified lines
97 AttrRegular = Attr(1 << 7)98 AttrClear = Attr(1 << 8)99)100101func (r *FullscreenRenderer) PassThrough(str string) {102 // No-op103 // https://github.com/gdamore/tcell/issues/363#issuecomment-680665073101func (r *FullscreenRenderer) PassThrough(y int, x int, data string) {102 tty, _ := _screen.Tty()103 ti, err := tcell.LookupTerminfo(os.Getenv("TERM"))104 if err != nil {105 return106 }107 ti.TPuts(tty, ti.TGoto(x, y))108 ti.TPuts(tty, data)109}110111func (r *FullscreenRenderer) Sync(hard bool) {112 if hard {113 _screen.Sync()114 } else {115 _screen.Show()116 }117}118119func (r *FullscreenRenderer) Resize(maxHeightFunc func(int) int) {}120121func (r *FullscreenRenderer) defaultTheme() *ColorTheme {122 if _screen.Colors() >= 256 {
96 unmodified lines
219func (r *FullscreenRenderer) Refresh() {220 // noop221}222210// TODO: Pixel width and height not implemented223func (r *FullscreenRenderer) Size() TermSize {212 cols, lines := _screen.Size()213 return TermSize{lines, cols, 0, 0}224 tty, _ := _screen.Tty()225 ws, _ := tty.WindowSize()226 return TermSize{ws.Height, ws.Width, ws.PixelWidth, ws.PixelHeight}227}228229func (r *FullscreenRenderer) GetChar() Event {230 ev := _screen.PollEvent()
572 unmodified lines
modified:src/tui/tui.go+2 added-1 removed
487 unmodified lines
488 Clear()489 RefreshWindows(windows []Window)490 Refresh()491 Close()492 PassThrough(string)492 PassThrough(y int, x int, data string)493 Sync(bool)494 NeedScrollbarRedraw() bool495496 GetChar() Event497
317 unmodified lines
modified:src/terminal.go+7 added-1 removed
1936 unmodified lines
1937func (t *Terminal) renderPreviewArea(unchanged bool) {1938 if t.previewed.wipe && t.previewed.version != t.previewer.version {1939 t.previewed.wipe = false1940 t.pwindow.Erase()1941 // Required for tcell to clear the previous image1942 t.tui.Sync(true)1943 } else if unchanged {1944 t.pwindow.MoveAndClear(0, 0) // Clear scroll offset display1945 } else {1946 t.previewed.filled = false
115 unmodified lines
2062 wiped = true2063 for i := y + 1; i < height; i++ {2064 t.pwindow.MoveAndClear(i, 0)2065 }2066 // Required for tcell to clear the previous text2067 if !t.previewed.sixel {2068 t.tui.Sync(false)2069 }2070 }2071 sixel = sixel || isSixel2072 if idx == 0 {2073 t.pwindow.MoveAndClear(y, x)2074 } else {2075 t.pwindow.Move(y, x)2076 }2071 t.tui.PassThrough(passThrough)2077 t.tui.PassThrough(t.pwindow.Top()+y, t.pwindow.Left()+x, passThrough)20782079 if requiredLines > 0 {2080 if y+requiredLines == height {2081 t.pwindow.Move(height-1, maxWidth-1)
1935 unmodified lines
modified:CHANGELOG.md+3 added-2 removed
1CHANGELOG2=========340.43.140.44.05------6- (Experimental) Sixel image support in preview window (not available on Windows)6- (Experimental) Sixel image support in preview window7 - [bin/fzf-preview.sh](bin/fzf-preview.sh) is added to demonstrate how to8 display an image using Kitty image protocol or Sixel. You can use it9 like so:10 ```sh11 fzf --preview='fzf-preview.sh {}'12 ```13- (Experimental) Sixel and Kitty image support now also available on Windows14- Bug fixes15160.43.017------
1733 unmodified lines
modified:go.mod+4 added-3 removed
1module github.com/junegunn/fzf23require (4 github.com/gdamore/tcell/v2 v2.5.44 // go get github.com/gdamore/tcell/v2@8a50441ee1fd29b18a4a7d51e98423a17ec8ef4c5 github.com/gdamore/tcell/v2 v2.6.1-0.20231031224054-8a50441ee1fd6 github.com/mattn/go-isatty v0.0.177 github.com/mattn/go-runewidth v0.0.148 github.com/mattn/go-shellwords v1.0.129 github.com/rivo/uniseg v0.4.4
4 unmodified lines
1415require (16 github.com/gdamore/encoding v1.0.0 // indirect17 github.com/lucasb-eyer/go-colorful v1.2.0 // indirect17 golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect18 golang.org/x/text v0.5.0 // indirect18 golang.org/x/sync v0.1.0 // indirect19 golang.org/x/text v0.12.0 // indirect20)2122go 1.17
modified:go.sum+16 added
1github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=2github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=3github.com/gdamore/tcell/v2 v2.5.4 h1:TGU4tSjD3sCL788vFNeJnTdzpNKIw1H5dgLnJRQVv/k=4github.com/gdamore/tcell/v2 v2.5.4/go.mod h1:dZgRy5v4iMobMEcWNYBtREnDZAT9DYmfqIkrgEMxLyw=5github.com/gdamore/tcell/v2 v2.6.1-0.20231031224054-8a50441ee1fd h1:DzX6TtJGRMP+AMlU+U4JEgoAVR/gwPNrz3JqPnEm3PM=6github.com/gdamore/tcell/v2 v2.6.1-0.20231031224054-8a50441ee1fd/go.mod h1:pwzJMyH4Hd0AZMJkWQ+/g01dDvYWEvmJuaiRU71Xl8k=7github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=8github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=9github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=10github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
1 unmodified line
12github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=13github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk=14github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=15github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=16github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=17github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=18github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=19github.com/saracen/walker v0.1.3 h1:YtcKKmpRPy6XJTHJ75J2QYXXZYWnZNQxPCVqZSHVV/g=20github.com/saracen/walker v0.1.3/go.mod h1:FU+7qU8DeQQgSZDmmThMJi93kPkLFgy0oVAcLxurjIk=21github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=22golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=23golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=24golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=25golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=26golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=27golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=28golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=29golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=30golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=31golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=32golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=33golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=34golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=35golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=36golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=37golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=38golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=39golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=40golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=41golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=42golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=43golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=44golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=45golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=46golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=47golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=48golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=49golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=50golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo=51golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=52golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=53golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=54golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=55golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=56golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=57golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=58golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=59golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=60golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=61golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=62golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=63golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=64golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=65golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=