Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not support 24-bit "truecolor" escape sequences. #101

Closed
jaysonlarose opened this issue Dec 19, 2019 · 7 comments · Fixed by #155
Closed

Does not support 24-bit "truecolor" escape sequences. #101

jaysonlarose opened this issue Dec 19, 2019 · 7 comments · Fixed by #155

Comments

@jaysonlarose
Copy link
Contributor

A good reference for these escape sequences can be found here: https://gist.github.com/XVilka/8346728

I took a quick glance at the Ansi2HTMLConverter, and it looks like the regex you're using to parse the escape sequences is robust enough to do the business, but I haven't gone any further than that.

--Jays

@jaysonlarose
Copy link
Contributor Author

Awesome! Thank you!

@jaysonlarose
Copy link
Contributor Author

I hate to be a nuisance, but I just learned the hard way that there are apparently two different ways of specifying 24-bit color codes:

There's this way, which you added support for, where semicolon (;) is used as the delimiter:

print('\x1b[38;2;0;128;0mhello\x1b[39m')

But there's also this way, where they use colon (:) as the delimiter:

print('\x1b[38:2:0:128:0mhello\x1b[39m')

@hartwork
Copy link
Collaborator

Hi @jaysonlarose can you make a new dedicated ticket for that please? This one is closed and fixed and a bug in it or new scheme deserves a new ticket. Also, it would be great to know which apps you have seen produce this scheme, which terminal you used that did display colors this way, and any online doc links on that format that you are already aware of. Thanks!

@jaysonlarose
Copy link
Contributor Author

@hartwork Sure thing. Definitely! I'll start that off now.

@trygveaa
Copy link

The xterm spec is a good reference: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI--ordered-by-the-final-character_s

These ISO-8613-6 controls (marked in ECMA-48 5th edition as "reserved for future standardization") are supported by xterm:
Ps = 3 8 : 2 : Pi : Pr : Pg : Pb ⇒ Set foreground color using RGB values.
Ps = 3 8 : 5 : Ps ⇒ Set foreground color to Ps, using indexed color.
Ps = 4 8 : 2 : Pi : Pr : Pg : Pb ⇒ Set background color using RGB values.
Ps = 4 8 : 5 : Ps ⇒ Set background color to Ps, using indexed color.

This variation on ISO-8613-6 is supported for compatibility with KDE konsole:
Ps = 3 8 ; 2 ; Pr ; Pg ; Pb ⇒ Set foreground color using RGB values.
Ps = 4 8 ; 2 ; Pr ; Pg ; Pb ⇒ Set background color using RGB values.

So according to that, colon is the standard, and semicolon a deviation by KDE Konsole.

@jaysonlarose
Copy link
Contributor Author

@trygveaa That answers a few questions for me. I spent entirely too much time digging through ITU T.416, which is the same thing as that ISO standard that the xterm folks reference. The good news for me is that they've got a real loose definition of the term "supported". That ITU document talks about all of this stuff like being able to use CMYK color schemes and specifying colorspace conversion tolerances that are just straight up nonexistent in the XTerm spec.

I'd argue that "the version that's most widely adopted" is the standard, personally, but that doesn't really help my case of trying to get this fix to happen :)

Which I'll be submitting a new bug report for Real Soon Now, considering I'm not stuck trying to explain all this color space crap!

@trygveaa
Copy link

@trygveaa That answers a few questions for me. I spent entirely too much time digging through ITU T.416, which is the same thing as that ISO standard that the xterm folks reference. The good news for me is that they've got a real loose definition of the term "supported". That ITU document talks about all of this stuff like being able to use CMYK color schemes and specifying colorspace conversion tolerances that are just straight up nonexistent in the XTerm spec.

I added some more info about the standards in the new issue. Yes, they don't support all the parameters values like CMYK colors, but there's a difference between partially implementing a standard and incorrectly implementing a standard.

I'd argue that "the version that's most widely adopted" is the standard, personally, but that doesn't really help my case of trying to get this fix to happen :)

Well, yes, semicolons has apparently become the de facto standard, which I learned now was because xterm initially incorrectly read the standard in 1999 and used semicolons, before they fixed it in 2012. As noted in my other comment using semicolons breaks the ability to combine multiple SGR parameters in one escape sequence though, so which separator to use is more than just a technicality.

Funny how a misinterpretation of a standard in 1999 can still cause problems today :P

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 a pull request may close this issue.

3 participants