set_foreground
和set_a_foreground
(以及背景功能)之间的区别在terminfo(5)
手册页的颜色处理部分。请记住,长名称很少使用,您应该寻找setf
vs setaf
:
The setaf/setab and setf/setb capabilities take a single
numeric argument each. Argument values 0-7 of setaf/setab
are portably defined as follows (the middle column is the
symbolic #define available in the header for the curses or
ncurses libraries). The terminal hardware is free to map
these as it likes, but the RGB values indicate normal
locations in color space.
Color #define Value RGB
black COLOR_BLACK 0 0, 0, 0
red COLOR_RED 1 max,0,0
green COLOR_GREEN 2 0,max,0
yellow COLOR_YELLOW 3 max,max,0
blue COLOR_BLUE 4 0,0,max
magenta COLOR_MAGENTA 5 max,0,max
cyan COLOR_CYAN 6 0,max,max
white COLOR_WHITE 7 max,max,max
The argument values of setf/setb historically correspond
to a different mapping, i.e.,
Color #define Value RGB
black COLOR_BLACK 0 0, 0, 0
blue COLOR_BLUE 1 0,0,max
green COLOR_GREEN 2 0,max,0
cyan COLOR_CYAN 3 0,max,max
red COLOR_RED 4 max,0,0
magenta COLOR_MAGENTA 5 max,0,max
yellow COLOR_YELLOW 6 max,max,0
white COLOR_WHITE 7 max,max,max
It is important to not confuse the two sets of color capa-
bilities; otherwise red/blue will be interchanged on the
display.
大多数只使用terminfo(而不是curses)的应用程序使用该tparm
函数来格式化字符串,替换一个(数字)参数,然后使用tputs
结果字符串来实际写入它。这两个帐户用于填充和延迟(通常在颜色功能中不存在,但通常在 terminfo 中)。
ncurses-examples程序dots使用这些函数在屏幕上随机绘制彩色单元格。(在示例中,tparm2
,tparm3
是提供tparm
原型所需的额外参数的宏)。