diff --git a/docs/graphics-protocol.rst b/docs/graphics-protocol.rst index c49b535e6..363e31f56 100644 --- a/docs/graphics-protocol.rst +++ b/docs/graphics-protocol.rst @@ -332,7 +332,7 @@ sequence of escape codes to the terminal emulator:: Note that only the first escape code needs to have the full set of control codes such as width, height, format, etc. Subsequent chunks **must** have only the ``m`` and optionally ``q`` keys. When sending animation frame data, subsequent -chunks must also specify the ``a=f`` key. The client **must** finish sending +chunks **must** also specify the ``a=f`` key. The client **must** finish sending all chunks for a single image before sending any other graphics related escape codes. Note that the cursor position used to display the image **must** be the position when the final chunk is received. Finally, terminals must not display diff --git a/tools/tui/graphics/command.go b/tools/tui/graphics/command.go index c502318a3..9b1d91ea4 100644 --- a/tools/tui/graphics/command.go +++ b/tools/tui/graphics/command.go @@ -544,14 +544,14 @@ func (self *GraphicsCommand) WriteWithPayloadTo(o io.StringWriter, payload []byt return self.serialize_to(o, base64.StdEncoding.EncodeToString(payload)) } gc := *self - compressed := compress_with_zlib(payload) - if len(compressed) < len(payload) { - gc.SetCompression(GRT_compression_zlib) - gc.SetDataSize(uint64(len(payload))) - payload = compressed + if self.Format() != GRT_format_png { + compressed := compress_with_zlib(payload) + if len(compressed) < len(payload) { + gc.SetCompression(GRT_compression_zlib) + payload = compressed + } } data := base64.StdEncoding.EncodeToString(payload) - is_first := true for len(data) > 0 && err == nil { chunk := data if len(data) > 4096 { @@ -569,10 +569,7 @@ func (self *GraphicsCommand) WriteWithPayloadTo(o io.StringWriter, payload []byt if err != nil { return err } - if !is_first { - gc = GraphicsCommand{} - } - is_first = false + gc = GraphicsCommand{q: self.q, a: self.a} } return }