Live data from Hacker News

True Colour support in various terminals

gist.github.com

11–20 of 28 posts

Re: True Colour support in various terminals

#11
post #5

Earlier quoted context omitted.

It's a wider color space. It improves the color range of everything, assuming the source hasn't been flattened to SRGB.

Well, yes, but what are the benefits for text over 24-bit colour? To have two even less different shades of a colour adjacent to each other? For images there's a very clear benefit, but for a text frame buffer I'd say not so much.

See my comment above: it would allow more precise specification of a color by avoiding the need of indexing an implementation-dependent palette.

Re: True Colour support in various terminals

#13
post #2

Serious question: will terminals ever support P3 color? Maybe that's too much to ask for? https://webkit.org/blog/6682/improving-color-on-the-web/ https://webkit.org/blog-files/color-gamut/comparison.html

Why P3? It is better to go directly to Rec. 2100 with HDR which is more future-proof.

Re: True Colour support in various terminals

#14
post #5

Earlier quoted context omitted.

It's a wider color space. It improves the color range of everything, assuming the source hasn't been flattened to SRGB.

Well, yes, but what are the benefits for text over 24-bit colour? To have two even less different shades of a colour adjacent to each other? For images there's a very clear benefit, but for a text frame buffer I'd say not so much.

What you are talking about is bit-depth which is not related to color spaces (although for wider color spaces you need higher bit-depth to avoid banding).

Re: True Colour support in various terminals

#15
post #12
post #6

Sad infodrop: the main reason this is a nonevent is because ncurses encodes fg/bg colors in an unsigned int. :(

I don't understand the problem, could you please elaborate?

Sorry, sure.

Emitting colors to terminals is trivial, but ncurses - the dominant text UI library (since the 1980s!) - needs to hold the color information for the "windows" or frames that it maintains for you so that it knows how to repaint things when you switch from one view to the next (eg, if some kind of popup opens and then gets closed, ncurses maintains state about what was underneath so it can redraw it for you. This was novel in the 80s because of the number of competing terminals; see /etc/termcap for a very good idea of why everyone was happy to let a library do this for you).

* The following is my understanding of the situation; I welcome corrections *

Unfortunately, ncurses encodes the foreground and background as an unsigned int, which only stores 0-255. That bit I said before about ncurses existing since the 80s - unfortunately that's more important than I wish it was; ncurses ("new curses") is merely the OSS variant you find on Linux, it has existed on UNIX (as the "curses" library) in many forms. For Reasons™, the commercial curses implementations of the day all tried to stay binary-compatible with each other. Of course, ncurses did the same.

And so, ncurses is pretty much based on a de-facto ad-hoc standard (AFAIK) that's not really ratified anywhere (it might be, not sure) and which specifies very strict in-memory data structures because of the way the API was originally built. Changing any of this would break binary compatibility.

IIRC, ncurses' author/maintainer, Thomas E. Dickey, hasn't really made any noises about for example adding a new function and doing some kind of backward-compatibility dance to allow ncurses to preserve but ignore the legacy color data. I'm not sure if this would actually be technically impossible or whether it's a case of "eeeeh, that doesn't sound like fun, I don't feel like doing that". I can understand the latter, but I definitely hope the former is not true, as it would be the death knell for truecolor for at least the next 10 years - ncurses isn't going anywhere anytime soon, and it would be the canonical way to get the capability popularized.

In case you were curious to see how much depends on ncurses on your system (uses ldd and assumes "libncurses"; unsure if Linux specific):

  (IFS=:; for x in $PATH; do ldd $x/* 2>/dev/null; done) |\
    awk '/^\//{FS=":";p=$1;}/^[ \t].*libncurses/{print p;}'
There are some obvious things in here like htop/top, alsamixer, dialog, vim, irssi, links, mc, etc; I assume most of what I'm seeeing is depending on ncurses as a result of pulling in another library.

Your package manager's "list packages that depend on this package" may produce faster results.

Re: True Colour support in various terminals

#16
You know I tried to hack to play a gif upon SSH login, /etc/issue.net does not accept ANSI chars, but /etc/motd does.

So I mkfifo /etc/motd, use some monkey patched shell commands to stream gif to /etc/motd, tried SSH login, the animation totally works, adjust the sleep you get different speeds.

I was totally satisfied with this and logged out of my VPS server. Oh wait....

Since my scripts was not in a loop, so it only feeds data into /etc/motd once, after I logout every SSH session, I can no longer login. Even local login fails because Linux would stuck forever reading the fifo /etc/motd.

I had to mount the disk into another machine and restore /etc/motd to normal.

Lessons learned, don't mkfifo /etc/motd.

Re: True Colour support in various terminals

#17
post #5

Earlier quoted context omitted.

Well, yes, but what are the benefits for text over 24-bit colour? To have two even less different shades of a colour adjacent to each other? For images there's a very clear benefit, but for a text frame buffer I'd say not so much.

See my comment above: it would allow more precise specification of a color by avoiding the need of indexing an implementation-dependent palette.

citrusui originally asked about DCI-P3 color space, ygra then confused this wider color space with higher bit-depth. Now you want to further confuse everyone by referring to your comment about advantages of 24-bit RGB over paletted colors which is completely irrelevant to the original comment about DCI-P3 color space. DCI-P3 contains colors which are outside of the gamut representable by the 24-bit RGB (which uses sRGB color space).

Re: True Colour support in various terminals

#18
post #15
post #12

Earlier quoted context omitted.

I don't understand the problem, could you please elaborate?

Sorry, sure. Emitting colors to terminals is trivial, but ncurses - the dominant text UI library (since the 1980s!) - needs to hold the color information for the "windows" or frames that it maintains for you so that it knows how to repaint things when you switch from one view to the next (eg, if some kind of popup opens and then gets closed, ncurses maintains state about what was underneath so it can redraw it for yo…

This sounds like an opportunity for somebody write a backwards-compatible ncurses replacement in a modern systems language. I promise to try using whichever language manages to do this first.

Re: True Colour support in various terminals

#19
post #7

What I think is really interesting in this is not the possibility to use 16 millions colors per se, but rather the ability to directly specify the RGB components of the color to use. The current approach used by terminfo and ncurses is to refer to an index within a palette, which has the drawback of giving little guarantees about the final shade of the color. (Look at the color table here [1] for a comparison among d…

Except you can already query/set the color palette to arbitrary RGB values with control sequences (at least with xterm, rxvt-unicode, and I imagine others).

As far as I've been able to tell, "truecolor" terminal support is about simultaneous display of a range of colors beyond what fits in a palette. Which, eh...seems a bit much for a terminal.

Re: True Colour support in various terminals

#20
post #17

Earlier quoted context omitted.

See my comment above: it would allow more precise specification of a color by avoiding the need of indexing an implementation-dependent palette.

citrusui originally asked about DCI-P3 color space, ygra then confused this wider color space with higher bit-depth. Now you want to further confuse everyone by referring to your comment about advantages of 24-bit RGB over paletted colors which is completely irrelevant to the original comment about DCI-P3 color space. DCI-P3 contains colors which are outside of the gamut representable by the 24-bit RGB (which uses sR…

Sorry, it wasn't my intention to hurt you with my comment.
Post reply on HN