I just started to use ncurses on Linux. I wanted to use more than 8 colors, but there were only 8 available.
How can I use more colors, or create my own by giving them a names, and set their RGB values?
I tried editing a color with init_color, but that will simply replace one of the current 8 instead of creating new ones.
Note: the value of the global var COLORS
is 256, so I believe I can use up to 256 different colors.
If your terminal supports it, you should choose (or customize) a terminal description which has more than 8 colors. As it is, there are a lot of existing terminal descriptions which could be used: most are customized for particular terminals (or terminal emulators).
If your terminal supports it, the corresponding description would have the capability
initc
. That is used by the library callinit_color
. Thexterm-256color
entry has this for instance:which tells the library how to translate the three parameters into an escape sequence. The terminal entries are built up from reusable parts such as xterm+256color, because some terminals lack the feature you are interested in. For those, xterm+256setaf is appropriate.
For reference,