Skip to content

v0.19.0

Choose a tag to compare

@tya5 tya5 released this 12 Aug 23:34
· 7 commits to main since this release

Images in the feed need no image library

Following the chain from the Sixel report:

  1. Sixel is unplaceable here — it draws relative to the cursor and occupies no cells, so a virtualized painter can't position or clip it.
  2. Kitty placeholders can't be relied on — they work on Kitty, but WezTerm and Konsole report Kitty-graphics support and then draw the placeholders as visible glyphs (verified first-hand on WezTerm 20240203), and there is no query for "do placeholders actually draw", so it can't be detected at runtime.
  3. ∴ the only workable form is coloured half-block cells — which need no protocol machinery at all.

And a renderable is a Rich concept, not a Textual one. So a complete image renderable is ~15 lines:

class HalfBlockImage:                     # pixels: rows of (r, g, b)
    def __rich_console__(self, console, options):
        for y in range(0, self.h - 1, 2):          # two pixel rows per text row
            for x in range(self.w):
                t, b = self.px[y][x], self.px[y + 1][x]
                yield Segment("▀", Style(color=f"rgb{t}", bgcolor=f"rgb{b}"))
            yield Segment("\n")

examples/image.py now does exactly that — no textual-image, no rich-pixels (pillow only, and only to generate the demo images). Verified in a real WezTerm with neither library installed: avatars and a gradient picture render cleanly and scroll like any row.

This removes the footgun rather than documenting around it — textual_image.renderable.Image auto-selects Sixel, so the convenient import was the broken one, and the library's one remaining useful mode is the one you can write yourself. (rich-pixels is the same idea as a one-liner if you'd rather not.)

Full Changelog: v0.18.3...v0.19.0