termstandard / colors

Color standards for terminal emulators
The Unlicense
1.1k stars 44 forks source link

Update delimiter support for alacritty terminal emulator #56

Closed kylefhartzenberg closed 1 year ago

kylefhartzenberg commented 1 year ago

Using colons or semi-colons as the escape sequence colour delimiter shows no discernable difference in colour output for the alacritty terminal emulator. For example: printf "\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m\n" is equivalent to printf "\x1b[38:2:255:100:0mTRUECOLOR\x1b[0m\n".

kurahaupo commented 1 year ago

As described in Wikipedia's ANSI escape code page, 24-bit colours are encoded in different ways when using ; and : separators; in particular, the R/G/B components are not in the same parameter positions:

If Alacritty shows the latter as orange, that would be a bug, and so marking it as "supported" would be misleading.

That said, many terminal emulators make the same error, so I'm not entirely sure how to proceed.

What does Alacritty do when provided with a valid colon-delimited sequence, such as \e[38:2::255:100:0:::m?

kylefhartzenberg commented 1 year ago

@kurahaupo Thanks for the prompt response. The first paragraph in that section on 24-bit colour points to no standard, rather, it simply states that many terminals support the following escape sequences:

ESC[38;2;⟨r⟩;⟨g⟩;⟨b⟩ m Select RGB foreground color
ESC[48;2;⟨r⟩;⟨g⟩;⟨b⟩ m Select RGB background color

And that "the syntax is likely based on the ITU's T.416 ODA and interchange format". It then goes onto detail that the ODA version has some differences/elaborations that make it incompatible with the above syntax. I don't believe there is a 24-bit colour escape code "standard"? What is listed on that page for colon delimiter use is an example of the ITU-RGB variation used by xterm (and possibly others).

So is this GitHub page's section attempting to let people know what 24-bit colour delimiters are supported in a terminal? Or, what colour escape sequence standards are being used? Thereby defining what constitutes a "valid" semi-colon or colon delimited escape sequence? It seems like the two are being conflated from my perspective. To make matters worse, there doesn't actually seem to be a standard beyond the very limited original ANSI one, and that specified by ITU? It's basically a design choice by the terminal emulator developer which is why I think that most have implemented the intuitive one-for-one semi-colon to colon exchange (which makes sense as one would expect that a change in delimiter doesn't also require a change in the structure of the escape sequence).

To answer your question, the following commands are all visually identical (print "TRUECOLOR" in orange):

printf "\x1b[38:2::255:100:0:::mTRUECOLOR\x1b[0m\n"
printf "\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m\n"
printf "\x1b[38:2:255:100:0mTRUECOLOR\x1b[0m\n"

I'm not sure how to proceed either and don't have authoritative advice to give. I raised the pull request as I thought that, as a user of alacritty, support for both colon and semi-colon delimiters appeared to work fine.

kurahaupo commented 1 year ago

To answer your question, the following commands are all visually identical (print "TRUECOLOR" in orange):

printf "\x1b[38:2::255:100:0:::mTRUECOLOR\x1b[0m\n"
printf "\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m\n"
printf "\x1b[38:2:255:100:0mTRUECOLOR\x1b[0m\n"

Since the first and second are identical, that counts as "supported" , so I will approve this PR.