Skip to content

Using go-termimg in other programs #10

@xxxserxxx

Description

@xxxserxxx

This is not a bug report. Maybe it's a feature request.

go-termimg works in tmux, even outside of iTerm or Kitty, so the README section on protocols seems as if it may be out of date. It appears that there is some support for multiplexers such as tmux and screen, and indeed within even a terminal such as Rio images are rendered. This is despite the fact that within Rio itself (outside of tmux), go-termimg merely generates an "unsupported protocal error. My first question is whether some clarity could be provided about in which environments go-termimg can be expected to work?

Second, within tmux go-termimg does not leave the terminal in a reasonable state. This may be related to the fact that the parent terminal is neither iTerm nor Kitty; however, since the image does render, the protocal is clearly working. My second question is, then, is there a way to ensure correct positioning? Examples are given at the end.

I am trying to use go-termimg as the image renderer in a terminal pager for the djot markup language. I'm using a bespoke terminal library to write terminal escape sequences; since the markup format has a document structure (where children elements can be affected by their parent layout), many nodes need to rendered into strings. For this, I'm using TermImg.Build() to get the string and am simply writing it out with io.Writer.Write(). It works fine, except for the positioning issue -- which behavior is replicated by go-termimg/cmd/imgcat. It may very well be an issue with Rio's support for whatever protocol go-termimg is using.

Here's a tmux terminal split vertically and then right-split horizontally, with the image printed when the cursor is at the bottom of the window:

Image

This can be cleared by a carriage return in the pane below the one in which the image was printed. Here's the same image printed when the cursor (prompt) is at the top of a pane. This can be cleared by a carriage return in the same pane:

Image

It isn't clear to me by which magic go-termimg is generating such clear images; I suspect sixel, since go-termimg in tmux in Alacritty (which does not support sixel) does not print any image, nor an error. In does work in a raw ghosttty, where the cursor is correctly positioned, but not a tmux in a ghosttty terminal (again, no error, no image). ghostty IIRC supports both kitty and sixel.

TL;DR I'm not filing a bug because it's not clear what constitutes a valid, supported environment, and I seek clarity. I am having trouble with render positioning, and would like to know if there's something I can do to debug or correct this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions