-1

According to Wiki's https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit article there are 8 "Standard colors" and 8 "High-intensity colors". When I checked terminal capability of the Linux' virtual console (tty) by tput colors it showed 8. However, if I print them in VT I get 16 distinct colors. Why is so that?

Here is the screenshot:

enter image description here

I see that there is no 256 color support. Console just mix existing ones causing such "effect". So I do not ask why it doesn't support X or something like that.

2

According to Wiki's https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit article there are 8 "Standard colors" and 8 "High-intensity colors". When I checked terminal capability of the Linux' virtual console (tty) by tput colors it showed 8. However, if I print them in VT I get 16 distinct colors. Why is so that?

If you look closely, you can see that colors 0-7 are darker versions of 8 through 15.

This scheme is based on early text-mode hardware that used 4 bits to determine Red, Green, Blue and Intensity, like this:

-----------------
| 8 | 4 | 2 | 1 |
-----------------
| I | R | G | B |
-----------------

Add up the values for what you want. Light red = 8+4 = 12, for example.

Bits are arranged differently in your example, looks like 1=red, 2=green, 4=blue.

In this scheme there are 3 color bits, so 8 different colors (000 or black is a color) with 1 selectable brightness or intensity bit. This is what is meant by "8 standard colors and 8 high-intensity colors."

(These bits were stored in a section of memory called "attribute memory" - the other 4 bits could select a background color and turn on/off blinking mode.)

As far as why you are not seeing 256 colors, your terminal is probably not in 256 color mode or something like that.

  • The screenshot is from actual Linux console rather than terminal emulator. So by default the kernel's vt driver emulates old-days 8 color behavior? Can I actually set 16 distinct colors using RGB (where each color is 8 bit)? – Timur Fayzrakhmanov Jul 31 '18 at 15:05
  • 1
    You can choose between any 1 of 16 colors (black + 15 others). If you are working from actual hardware text mode then it's not an emulation and you probably can't choose more than those colors no matter what. Linux supports a "framebuffer" console which should support that. – LawrenceC Jul 31 '18 at 15:08
  • I don't think I get the final point but I have too much question in mind so I end here :], thank you anyway. In general, I have difficulties by distinguishing what is actually supported by "framebuffer" console (or as you said "hardware text mode") vs X terminal emulator. It would be great if there is some good article out there where I can go deeper on the topic.. – Timur Fayzrakhmanov Jul 31 '18 at 15:15
  • This might help: robmeerman.co.uk/unix/256colours – LawrenceC Jul 31 '18 at 15:16
  • Unfortunately, it didn't much help since it's more about configuring X "thing"s rather than classic VT mode and its capabilities, how it renders, how it reacts to input, how /dev/tty and /dev/pty related, etc. Maybe a bit more theory behind the internal working. – Timur Fayzrakhmanov Aug 1 '18 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.