Skip to content

images inside urxvt: core patch#7

Open
drzraf wants to merge 1 commit into
exg:mainfrom
drzraf:line-attr
Open

images inside urxvt: core patch#7
drzraf wants to merge 1 commit into
exg:mainfrom
drzraf:line-attr

Conversation

@drzraf
Copy link
Copy Markdown

@drzraf drzraf commented May 31, 2026

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)

Example:

example

(test sizing, aligning, inlining, left border sticking, transparency, compatibility with backgrounds and pseudo-transparency, etc...)

Posting a PR here because the mailing-list seems dead ATM. My patch got moderated (exceeding the 20kb attachment size) but there seem to be no moderator available anymore. I really wish urxvt itself is not dead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant