如何在ncurses中使用8种以上的颜色? [英] How do i use more than 8 colors in ncurses?
问题描述
我刚刚开始在Linux上使用ncurses.我想使用8种以上的颜色,但是只有8种可用.
I just started to use ncurses on Linux. I wanted to use more than 8 colors, but there were only 8 available.
如何使用更多颜色,或者通过给它们命名来创建自己的颜色并设置其RGB值?
How can I use more colors, or create my own by giving them a names, and set their RGB values?
我尝试使用init_color编辑一种颜色,但这只会替换当前8种颜色中的一种,而不是创建新的颜色.
I tried editing a color with init_color, but that will simply replace one of the current 8 instead of creating new ones.
注意:全局var COLORS
的值为256,所以我相信我最多可以使用256种不同的颜色.
Note: the value of the global var COLORS
is 256, so I believe I can use up to 256 different colors.
推荐答案
如果您的终端支持,则应该选择(或自定义)具有8种以上颜色的终端描述.实际上,有很多可用的现有终端描述:大多数是为特定终端(或终端仿真器)定制的.
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).
如果您的终端支持,相应的描述将具有功能initc
.这由库调用init_color
使用.在 xterm-256color
条目中,例如:
If your terminal supports it, the corresponding description would have the capability initc
. That is used by the library call init_color
. The xterm-256color
entry has this for instance:
initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\,
告诉库如何将三个参数转换为转义序列.终端条目由可重复使用的部分构成,例如 xterm + 256color ,因为某些终端缺少您感兴趣的功能.对于这些终端,请 xterm + 256setaf 是合适的.
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.
供参考,
- 终端数据库大多数系统都以此为基础(小型),并以其他形式(大)包.
- start_color,init_pair,init_color,has_colors,can_change_color,color_content,pair_content,COLOR_PAIR-诅咒色彩处理程序
- 我的终端无法识别颜色
- 为什么只有16种(或256种)颜色?
- Terminal Database Most systems have this as base (small) and extra (large) packages.
- start_color, init_pair, init_color, has_colors, can_change_color, color_content, pair_content, COLOR_PAIR - curses color manipulation routines
- My terminal doesn't recognize color
- Why only 16 (or 256) colors?
这篇关于如何在ncurses中使用8种以上的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!