@@ -2,7 +2,6 @@ package image
@@ -195,50 +194,12 @@ func (e Encoding) Transmit(id string, img image.Image, cs CellSize, cols, rows i
197 var buf bytes.Buffer
196 var buf bytes.Buffer
201− // Read single Kitty graphic chunks from the pipe and wrap them
202− // for tmux if needed.
203− var out bytes.Buffer
207− n, err := rp.Read(p[:])
210− if p[0] == ansi.ESC {
212− } else if seenEsc && p[0] == '\\' {
213− // End of Kitty graphics sequence
220− if !errors.Is(err, io.EOF) {
221− slog.Error("error reading from pipe", "err", err)
229− seq = ansi.TmuxPassthrough(seq)
232− buf.WriteString(seq)
236 img := fitImage(id, img, cs, cols, rows)
197 img := fitImage(id, img, cs, cols, rows)
237 bounds := img.Bounds()
198 bounds := img.Bounds()
238 imgWidth := bounds.Dx()
199 imgWidth := bounds.Dx()
239 imgHeight := bounds.Dy()
200 imgHeight := bounds.Dy()
240 imgID := int(key.Hash())
201 imgID := int(key.Hash())
241− if err := kitty.EncodeGraphics(wp, img, &kitty.Options{
202+ if err := kitty.EncodeGraphics(&buf, img, &kitty.Options{
242 ID: imgID,
203 ID: imgID,
243 Action: kitty.TransmitAndPut,
204 Action: kitty.TransmitAndPut,
244 Transmission: kitty.Direct,
205 Transmission: kitty.Direct,
@@ -250,9 +211,18 @@ func (e Encoding) Transmit(id string, img image.Image, cs CellSize, cols, rows i
250 VirtualPlacement: true,
211 VirtualPlacement: true,
251 Quite: 1,
212 Quite: 1,
252 Chunk: true,
213 Chunk: true,
214+ ChunkFormatter: func(chunk string) string {
216+ return ansi.TmuxPassthrough(chunk)
253 }); err != nil {
220 }); err != nil {
254 slog.Error("failed to encode image for kitty graphics", "err", err)
221 slog.Error("failed to encode image for kitty graphics", "err", err)
222+ return uiutil.InfoMsg{
223+ Type: uiutil.InfoTypeError,
255− return uiutil.ReportError(fmt.Errorf("failed to encode image"))
224+ Msg: "failed to encode image",
258 return tea.RawMsg{Msg: buf.String()}
228 return tea.RawMsg{Msg: buf.String()}