tig icon indicating copy to clipboard operation
tig copied to clipboard

Support for True Color (16 millions colors)

Open XVilka opened this issue 11 years ago • 8 comments

Now more terminals bring support for 16 million colors (see references below).

Here's a test case for terminal:

printf "\x1b[${bg};2;${red};${green};${blue}m\n"

The 256 colour palete is configured at start, and it's a 666 cube of colours, each of them defined as a 24bit (888 rgb) colour.

This means that current support can only display 256 different colours in the terminal, while truecolour means that you can display 16 milion different colours at the same time.

Truecolour escape codes doesnt uses a colour palete. It just specifies the colour itself.

Here's a test case:

printf "\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m\n"
  • or https://raw.githubusercontent.com/JohnMorales/dotfiles/master/colors/24-bit-color.sh
  • or http://github.com/robertknight/konsole/tree/master/tests/color-spaces.pl
  • or https://git.gnome.org/browse/vte/tree/perf/img.sh?h=vte-0-36
  • or just run this:
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

Here are terminals discussions:

Now supporting truecolour

  • st (from suckless) [delimeter: semicolon] - http://lists.suckless.org/dev/1307/16688.html
  • konsole [delimeter: colon, semicolon] - https://bugs.kde.org/show_bug.cgi?id=107487
  • iterm2 [delimeter: colon, semicolon] - since v3 version
  • qterminal [delimeter: semicolon] - https://github.com/qterminal/qterminal/issues/78
  • cool-retro-term [delimeter: semicolon]
  • Black Screen [delimeter: semicolon] - crossplatform, HTML/CSS/JS-based
  • Tera Term [delimeter: colon, semicolon] - Windows platform
  • ConEmu [delimeter: semicolon] - Windows platform
  • FinalTerm [delimeter: semicolon] - abandoned, iTerm2 borrowing it's ideas and features.
  • MacTerm [delimeter: semicolon] - Mac OS X platform
  • mintty [delimeter: semicolon] Cygwin and MSYS/MSYS2 since commit https://github.com/mintty/mintty/commit/43f0ed8a46c6549cb9a3ea27abc057b5abe13bdb (2.0.1 release) - Windows platform
  • all libvte based terminals (since 0.36 version) [delimeter: colon, semilocon] - https://bugzilla.gnome.org/show_bug.cgi?id=704449
    • libvte-based Gnome Terminal
    • libvte-based sakura
    • libvte-based xfce4-terminal - since 0.6.90 release, if compiled with GTK+3
    • libvte-based Terminator - use GTK+3 version.
    • libvte-based Terminix - written in D. Similar user interface as for Terminator.
    • libvte-based Lilyterm - since commit https://github.com/Tetralet/LilyTerm/commit/72536e7ba448ad9ef1126ce45fbde3a3407a271b
    • libvte-based ROXTerm
    • libvte-based evilvte - no release yet, version from git https://github.com/caleb-/evilvte
    • libvte-based Termit
    • libvte-based Termite
    • libvte-based Tilda
    • libvte-based tinyterm
    • libvte-based lxterminal - with --enable-gtk3 configure flag.
    • libvte-based mlterm - with --with-gtk=3.0 configure flag

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:

  • asciinema player: https://github.com/asciinema/asciinema-player

Parsing ANSI colour sequences, but approximating them to 256 palette

  • xterm (though doing it wrong: "it uses nearest colour in RGB colour space, with a usualfalse assumption about orthogonal axes")
  • urxvt aka rxvt-unicode - since Revision 1.570 http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002261.html
  • linux console (since v3.16): https://github.com/torvalds/linux/commit/cec5b2a97a11ade56a701e83044d0a2a984c67b4
  • Windows 10 bash console, since build 14352, approximates 256 and 16M colors to 16fg/16bg https://github.com/Microsoft/BashOnWindows/issues/76

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] https://github.com/neovim/neovim/issues/793#issuecomment-48106948

Terminal multiplexers

  • tmux - starting from version 2.2 (support since 427b820...)
  • screen - has support in 'master' branch, need to be enabled (see 'truecolor' option)
  • pymux - tmux clone in pure Python (to enable truecolour run pymux with --truecolor option)
  • dvtm - not yet supporting True Colour https://github.com/martanne/dvtm/issues/10

NOT supporting truecolour

  • Terminology (Enlightenment) - https://phab.enlightenment.org/T746
  • mrxvt (looks abandoned) - https://sourceforge.net/p/materm/feature-requests/41/
  • aterm (looks abandoned) - https://sourceforge.net/p/aterm/feature-requests/23/
  • fbcon (from linux kernel) - https://bugzilla.kernel.org/show_bug.cgi?id=79551
  • FreeBSD console - https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=191652
  • PuTTY (patched version [3] {xterm-like approximation to 256 colors} and [4] {real true colors} available) - Windows platform
  • libvte and GTK2 - based:
    • libvte-based GTKTerm2
    • libvte-based stjerm (looks abandoned) - https://github.com/stjerm/stjerm/issues/39

[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:

  • mutt - http://dev.mutt.org/trac/ticket/3674
  • neomutt - https://github.com/neomutt/neomutt/issues/85
  • ncurses library - https://lists.gnu.org/archive/html/bug-ncurses/2013-10/msg00007.html
  • termbox library - https://github.com/nsf/termbox/issues/37
  • mcabber - https://bitbucket.org/McKael/mcabber-crew/issue/126/support-for-true-color-16-millions-colors
  • emacs - http://emacs.1067599.n5.nabble.com/RFC-Add-tty-True-Color-support-td299962.html and http://emacs.1067599.n5.nabble.com/bug-20243-True-color-terminal-support-tc354040.html

XVilka avatar Jan 10 '14 03:01 XVilka

Provided bug number for konsole is incorrect: correct one is https://bugs.kde.org/show_bug.cgi?id=107487.

ZyX-I avatar Jan 10 '14 04:01 ZyX-I

@ZyX-I thx! fixed.

XVilka avatar Jan 10 '14 04:01 XVilka

Unless ncurses supports True Color, it sounds like it will take a lot of work to get Tig to support it.

jonas avatar Jan 10 '14 05:01 jonas

@jonas starting from version 6.1 ncurses supports this mode.

XVilka avatar Feb 07 '18 04:02 XVilka

@XVilka That's great news, thanks for the update.

jonas avatar Feb 07 '18 08:02 jonas

@jonas is this going to be picked up at some point? This would be a pretty nice feature.

jmera avatar Aug 01 '18 01:08 jmera

What is the purpose of adding RGB support to tig? Is it only for specifying theme colors with more control/options?

spidey avatar Feb 23 '20 11:02 spidey