Follow full xparsecolor spec in escape sequences#2504
Follow full xparsecolor spec in escape sequences#2504chrisduerr merged 2 commits intoalacritty:masterfrom
Conversation
|
Besides the issue above I will add this to the changelog. |
a71c151 to
9b50657
Compare
|
Everything looks good from my end now. |
|
Looks like rustfmt failed on CI and it failed a check for cognitive complexity. I will run rustfmt. Any tips for bringing down cognitive complexity is appreciated, since I'm not pretty new to Rust, but I will figure it out if not. I'll run any local checks before pushing next time. |
|
I've only taken a super small peek at this, but this looks like extreme amounts of macros. You'll want to keep macros to a minimum since they add a lot of complexity and compile time, instead you should prefer abstracting over complexity with methods when possible. |
|
Good to know, thanks |
9b50657 to
147ba5a
Compare
|
Hopefully that should fix rustfmt and clippy problems. As far as the issues with macros goes, I removed some unnecessary macros. I was able to cut out one macro that was originally in the function by using |
a7ca650 to
06244cf
Compare
|
I have refactored the function based on the example given above - thank you, that was a much better starting point. All of the issues should be resolved. There are no macros, legacy colors are parsed in the same function, and a simple loop is used. |
|
I am working on the CI issues. |
24a64b0 to
7669aaf
Compare
|
Fixed clippy and rustfmt problems, it's ready to be reviewed again whenever. |
7669aaf to
cdbcd83
Compare
|
I thought I'd answer in a top-level comment for visibility and to make things a bit easier to read. Regarding the way additional depth should be calculated, you can find the full information I know about here: To go into a bit more detail, the legacy #RRGGBB colors are supposed to define the most significant bits of the color. So #RGB would be the same as #R000G000B000. The rgb: colors are handled a bit differently. If not enough depth is specified, they're supposed to be scaled. So
If you're not interested in adding full XParseColor support, we can decide on a subset of it too. Though I feel like it would be nice to get this out of the way. In theory with XLookupColors even colors like If we decide to go all the way, it would probably be a nice idea to separate that into a different workspace module (/crate/library) so we could offer an XParseColor crate for the broader Rust community, however that might be a bigger project than anyone's signed up for with this PR. :) |
43afc4f to
26bca11
Compare
I missed that, thank you. It should now be fixed and tested. I thought you meant that we were supposed to do something with the third and fourth bit.
I think at this point, if I missed a format, I'd be more comfortable with creating an issue than fixing it here. Though obviously, if some color format is parsed incorrectly here, I will fix it.
It's a good idea, but I wouldn't be comfortable with maintaining a rust library of any size right now given my skill level with the language. |
Escape sequences in xterm are parsed according to xparsecolor. xparsecolor supports 1, 2, 3, and 4 digit hex colors. Previously, only 2 digits were supported. This also fixes a bug where "fX" was parsed as "0xf", where X is an invalid character. The response to a request for fg/bg must be a valid escape sequence. The current response uses 4-digit hex, which was previously invalid. All of this required a refactoring of the rgb parsing function.
26bca11 to
6da64f2
Compare
chrisduerr
left a comment
There was a problem hiding this comment.
I've rebased this code and cleaned up some of the remaining style issues.
Thanks for your contribution, I think everything should be good to go now.
|
Awesome, thank you! |
Escape sequences in xterm are parsed according to xparsecolor. xparsecolor supports 1, 2, 3, and 4 digit hex colors. Previously, only 2 digits were supported.
This also fixes a bug where "fX" was parsed as "0xf" instead of "0xf0". xterm handles invalid hex values as 0, except for '/'.
The response to a request for fg/bg must be a valid escape sequence. Most terminals output a 4-digit hex response on request for fg/bg color. This changes the response to 4-digit, improving compatibility.