开发者

How to get more colors out of C++/Ncurses

How d开发者_如何转开发o I get more than the 7 preset colors using the NCurses library with C++?


If the colors terminfo capability returns 8, then you can't. If it returns a value higher than that then examine the result of the cc capability to see if you can change them via the initc capability.


Some terminals allow you to change color definitions of the preset colors:

init_color(COLOR_RED, 900, 200, 200);

The first parameter is the color you want to change; the next three are the new RGB values of that color (all values must be between 0 and 1000). can_change_color() can tell you whether this is supported by your terminal.

Unfortunately, this automatically changes all instances of that color on the screen to the new color. So you can really only use 8 colors, even if you can choose what those 8 colors are.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜