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

True color support #49

Open
XVilka opened this issue Apr 19, 2017 · 2 comments
Open

True color support #49

XVilka opened this issue Apr 19, 2017 · 2 comments

Comments

@XVilka
Copy link

XVilka commented Apr 19, 2017

Supporting truecolour means that you can display 16 milion
different colours at the same time.

Truecolour escape codes doesn't use a colour palete. They just specify the
colour itself.

Here's a test case:

printf "\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m\n"
awk 'BEGIN{
    s="/\\/\\/\\/\\/\\"; s=s s s s s s s s;
    for (colnum = 0; colnum<77; colnum++) {
        r = 255-(colnum*255/76);
        g = (colnum*510/76);
        b = (colnum*255/76);
        if (g>255) g = 510-g;
        printf "\033[48;2;%d;%d;%dm", r,g,b;
        printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
        printf "%s\033[0m", substr(s,colnum+1,1);
    }
    printf "\n";
}'

Keep in mind that it is possible to use both ';' and ':' as parameters delimiter.

According to Wikipedia[1], this is only supported by xterm and konsole.

[1] https://en.wikipedia.org/wiki/ANSI_color

Currently, there is no support for the 24-bit colour descriptions in the terminfo/termcap database and utilites.
See the discussion thread here: https://lists.gnu.org/archive/html/bug-ncurses/2013-10/msg00007.html

Detection

There's no reliable way, and ncurses/terminfo's maintainer expressed he has no intent on introducing support. S-Lang author added a check for $COLORTERM containing either "truecolor" or "24bit" (case sensitive). In turn, VTE, Konsole and iTerm2 set this variable to "truecolor" (it's been there in VTE for a while, it's relatively new and maybe still git-only in Konsole and iTerm2).

This is obviously not a reliable method, and is not forwarded via sudo, ssh etc. However, whenever it errs, it errs on the safe side: does not advertise support whereas it's actually supported. App developers can freely choose to check for this same variable, or introduce their own method (e.g. an option in their config file), whichever matches better the overall design of the given app. Checking $COLORTERM is recommended though, since that would lead to a more unique desktop experience where the user has to set one variable only and it takes effect across all the apps, rather than something separately for each app.

Here are terminals discussions:

Now supporting truecolour

But there are bunch of libvte-based terminals for GTK2 so they are listed in the another section.

Also, while this one is not exactly a terminal, but a terminal replayer, it still worth mentioning:

Parsing ANSI colour sequences, but approximating them to 256 palette

Note about colour differences: a) RGB axes are not orthogonal, so you cannot use sqrt(R^2+G^2+B^2) formula, b) for colour differences there is more correct (but much more complex) CIEDE2000 formula (which may easily blow up performance if used blindly) [2].

[2] neovim/neovim#793 (comment)

Terminal multiplexers

NOT supporting truecolour

[3] You can download patched version here https://github.com/rdebath/PuTTY

[4] You can download patched version here https://github.com/halcy/PuTTY

Here are another console programs discussions:

Supporting True Colour:

Not supporting True Colour:

@lmorg
Copy link

lmorg commented Jun 7, 2018

True colour means your users cannot define the colour palette which means if they use a while background (like xterm on Linux and most of the OS X terms do) then the text will be hard to read vs those with black backgrounds.

As it is this package already suffers from that problem - I suspect it's using 256 colours? - which makes it completely unusable for me.

@AXGKl
Copy link
Member

AXGKl commented Sep 26, 2018

finally found some time to work on it a little, especially the config mechanics. will consider both extremes.

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

No branches or pull requests

3 participants