[patch] 1/3: images inside urxvt: core patch

Raphaël raphael+sw at droz.eu
Thu May 21 07:19:44 CEST 2026


Dears,

Here is a patch rerolling my previous (2013) attempt ¹ at displaying images *inside* urxvt, hopefully addressing all previous comments:
A. minimal impact to the codebase
B. no gdk pixbuf dependency
C. OSC definition (and layout semantics) on Perl's side


About layout (positioning/padding/inline/...):
- All the format-parsing are definitely better in Perl.

- IMG_EOL_FLAG (IMG_EOL Perl counterpart) defines whether an image sticks to the right most
border. It's the only layout/details flag that calls for screen.C consideration.
Other aspects (padding/size/ratio/wrap/pos/flow) are handled by the extension.

About Perl/core separation and trade-off:

- I went through various iterations and even made one reaching 90% Perl (only exposing
rxvt_term::scr_expose() and rxvt_term::scr_touch() + a 10 lines core-change) **but** it was
simply impossible to avoid glitches:

Resizing, rewrapping, relationship to cursor, ... imply many sequences and states deeply
nested inside src_*() functions: like copy_line(), scr_scroll_text() and even more
scr_refresh().

In one way or another tracking images across refreshes at the cell level or clearing areas
of images' previous position implied trespassing screen.C

That why this v2 only went from 780 LoC to "only" 500 LoC (+ 60 LoC for 3 xs bindings)


Other notes:
- _InTermImage was an initial attempt to make the feature more modular and self-contained.
But a better solution was to store images as attribute of a line_t were all the flags/col/width/height
could live and benefit from the existing line manipulation/display/refresh logic.

- The overlay code ended up not being a good fit because its purpose and mechanism are
entirely different (fixed area vs cell-based/tracking logic)

- Two semi-generic helpers added into rxvt_img (no specific `#if HAVE_IMAGES`)


Main limitation: interactivity:

The implementation assigns no ID to pixmaps.
C maintains persistence when row numbering changes but Perl barely knows the filename and
can't tells whether an image exists in the viewport or under a mouse click.

Having unique IDs to bridge both sides would efficiently provide this information, allowing
the Perl extension to add click handlers/action/file name copy/... features

Given the extensibility potential, it could be worth for the price of another `int` inside
line_image_t? (maybe the file's inode could be used)
(It would also have made the patch a bit more complex for another "extra" feature so I
preferred to ignore it for now)


New bindings:

rxvt_term::has_line_image (int row_number)
rxvt_term::set_line_image (int row_number, rxvt_img *img, int col = 0, int flags = 0)
rxvt_term::clear_line_image (int row_number)



¹ https://lists.schmorp.de/pipermail/rxvt-unicode/2013q1/001736.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: urxvt-images-display.patch
Type: text/x-diff
Size: 26007 bytes
Desc: not available
URL: <http://lists.schmorp.de/pipermail/rxvt-unicode/attachments/20260521/2fc325bd/attachment-0001.patch>


More information about the rxvt-unicode mailing list