Skip to content

fix(graphics): ignore a sixel colour with a component over 100 - #874

Merged
vyncint merged 2 commits into
vyncint:mainfrom
alvaroalonsoparrondo-a11y:fix/sixel-component-over-100
Nov 27, 2026
Merged

vyncint merged 2 commits into
vyncint:mainfrom
alvaroalonsoparrondo-a11y:fix/sixel-component-over-100

Conversation

@alvaroalonsoparrondo-a11y

Copy link
Copy Markdown
Contributor

Fixes #845

decode_sixel applied #Pc;2;Pr;Pg;Pb whatever its components, and percent clamped each one to 100. xterm checks the components first: an RGB component over 100 is a DATA_ERROR that returns before update_color_register (graphics_sixel.c:788-793), so the register keeps its colour. An encoder that writes 0-255 values gets its image in the registers' earlier colours on xterm, and termlens decoded it in other ones.

  • crates/termlens/src/graphics.rs: an RGB definition is applied only when all three components are 100 or less; otherwise it is ignored and the register stays as it was. The register is still selected. percent keeps its clamp, with a comment that a definition over 100 no longer reaches it.
  • Not done: xterm also discards the byte that ends such a definition (the $ in the issue's example). Here the $ is still read as a graphics carriage return; as the issue says, at the left margin that changes nothing, so I left it alone.
  • Test: a_colour_with_a_component_over_100_is_ignored is the issue's case (register 1 defined blue, then #1;2;150;0;0): the three columns are blue. It also checks that 100 itself still applies. Without the guard it fails with the issue's left: [[255, 0, 0, 255], ...].
  • CHANGELOG: entry under Unreleased → Fixed.

This touches the lines next to #873 (#846), so whichever merges second will need a small rebase; I can do it.

Checked on macOS: cargo fmt --all --check, cargo clippy -p termlens --all-targets --all-features -- -D warnings, the sixel colour tests in cargo test -p termlens --features decode --lib, check-dco.sh and check-no-ai-attribution.sh.

Álvaro Alonso
242080768+alvaroalonsoparrondo-a11y@users.noreply.github.com

Fixes vyncint#845

Signed-off-by: Álvaro Alonso <242080768+alvaroalonsoparrondo-a11y@users.noreply.github.com>
vyncint
vyncint previously approved these changes Nov 27, 2026

@vyncint vyncint left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed against the issue; CI is green. Thank you.

Combine the range check with vyncint#873's colour-space match: a component
over 100 is ignored inside the RGB arm. Keep both tests, and the
CHANGELOG entries without a blank line between them.

Signed-off-by: Vyncint Ng <115854244+vyncint@users.noreply.github.com>
@vyncint
vyncint merged commit 93a54a3 into vyncint:main Nov 27, 2026
17 checks passed
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.

A sixel colour with a component over 100 is clamped and applied; xterm ignores the definition

2 participants