(readChan chan MeasuredRune)
| 73 | } |
| 74 | |
| 75 | func (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 | } |
no test coverage detected