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

Method processHeader

internal/app/darktile/sixel/decoder.go:76–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

74}
75
76func (d *decoder) processHeader() error {
77
78 data, err := d.readHeader()
79 if err != nil {
80 return err
81 }
82
83 header := string(data)
84
85 if len(header) == 0 {
86 return nil
87 }
88
89 params := strings.Split(header, ";")
90
91 switch params[1] {
92 case "0", "1", "5", "6", "":
93 d.aspectRatio = 2
94 case "2":
95 d.aspectRatio = 5
96 case "3", "4":
97 d.aspectRatio = 3
98 case "7", "8", "9":
99 d.aspectRatio = 1
100 default:
101 return fmt.Errorf("invalid P1 in sixel header")
102 }
103
104 if len(params) == 1 {
105 return nil
106 }
107
108 switch params[1] {
109 case "0", "2", "":
110 // use the configured terminal background colour
111 case "1":
112 d.bg = color.RGBA{A: 0} // transparent bg
113 }
114
115 // NOTE: we currently ignore P3 if it is specified
116
117 if len(params) > 3 {
118 return fmt.Errorf("unexpected extra parameters in sixel header")
119 }
120
121 return nil
122}
123
124func (d *decoder) processBody() error {
125

Callers 1

DecodeMethod · 0.95

Calls 1

readHeaderMethod · 0.95

Tested by

no test coverage detected