[英]Color at specific point - ncurses
I'm trying to color at a specific point of the screen using ncurses lib. 我正在尝试使用ncurses lib在屏幕的特定位置进行着色。
I have written this code: 我写了这段代码:
#include<curses.h>
int main(void)
{
initscr();
start_color();
init_pair(1, COLOR_BLACK, COLOR_RED);
attron(COLOR_PAIR(1));
move(10, 10);
printw(" \n");
refresh();
getch();
endwin();
return 0;
}
There is a better way to do this? 有更好的方法吗? Or this is the only way? 还是这是唯一的方法?
Have a look at mvchgat()
for changing the color (and other attributes) of an already-existing character. 看一下mvchgat()
来更改已经存在的字符的颜色(和其他属性)。
You can also use mvaddch
(10, 10, ' ' | COLOR_PAIR(1))
to move the cursor and output a space character with a custom color (or other attributes). 您也可以使用mvaddch
(10, 10, ' ' | COLOR_PAIR(1))
移动光标并输出带有自定义颜色(或其他属性)的空格字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.