MCPcopy
hub / github.com/liamg/darktile / handleSixel

Method handleSixel

internal/app/darktile/termutil/sixel.go:75–106  ·  view source on GitHub ↗
(readChan chan MeasuredRune)

Source from the content-addressed store, hash-verified

73}
74
75func (t *Terminal) handleSixel(readChan chan MeasuredRune) (renderRequired bool) {
76
77 var data []rune
78
79 var inEscape bool
80
81 for {
82 r := <-readChan
83
84 switch r.Rune {
85 case 0x1b:
86 inEscape = true
87 continue
88 case 0x5c:
89 if inEscape {
90 img, err := sixel.Decode(strings.NewReader(string(data)), t.theme.DefaultBackground())
91 if err != nil {
92 return false
93 }
94 w, h := t.windowManipulator.CellSizeInPixels()
95 cw := int(math.Ceil(float64(img.Bounds().Dx()) / float64(w)))
96 ch := int(math.Ceil(float64(img.Bounds().Dy()) / float64(h)))
97 t.activeBuffer.addSixel(img, cw, ch)
98 return true
99 }
100 }
101
102 inEscape = false
103
104 data = append(data, r.Rune)
105 }
106}

Callers 1

handleANSIMethod · 0.95

Calls 4

DecodeFunction · 0.92
DefaultBackgroundMethod · 0.80
addSixelMethod · 0.80
CellSizeInPixelsMethod · 0.65

Tested by

no test coverage detected