Skip to content

Parse rgba: colors, dropping the alpha channel - #33

Open
smohekey wants to merge 1 commit into
helix-editor:masterfrom
smohekey:pr/rgba-colors
Open

smohekey wants to merge 1 commit into
helix-editor:masterfrom
smohekey:pr/rgba-colors

Conversation

@smohekey

Copy link
Copy Markdown

rxvt-unicode answers an OSC 10/11 color query with rgba:<red>/<green>/<blue>/<alpha> when the color isn't opaque (process_color_seq in its src/command.C, in builds with Xft). RgbColor's FromStr accepted only rgb: and #…, so the parser emitted no event for such a reply at all.

This accepts rgba: with exactly four channels, each 1 to 4 hex digits as for rgb:. The alpha channel must be valid but is dropped, as the xterm-color crate does: the color actually seen depends on whatever shows through.

Tests cover FromStr with an rgba: color, malformed rgba: strings (three or five channels, an empty or invalid alpha, a five-digit channel), and an OSC 11 reply with rgba: through the parser.

rxvt-unicode answers an OSC 10/11 color query with
rgba:<red>/<green>/<blue>/<alpha> when the color isn't opaque (its
process_color_seq, in builds with Xft). RgbColor's FromStr rejected that
form, so the parser emitted no event for the answer at all.

Accept it with exactly four channels, each 1 to 4 hex digits as for rgb:.
The alpha channel must be valid but is dropped, as xterm-color does: the
color actually seen depends on whatever shows through.
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