ncurses フォーム ライブラリのカーソルの色を緑から他の色に変更する方法が見つかりません。カーソルまたは色のマンページをグーグルで検索しても役に立ちませんでした。これがどのように行われるか知っている人はいますか?
1735 次
1 に答える
2
\e]12;COLOR\a
またはと書くことで色を変更できます\033]12;COLOR\007
。これらはすべて同じです。ここに簡単な例を示します。
#include <stdio.h>
#include <unistd.h>
void cursor_set_color_string(const char *color) {
printf("\e]12;%s\a", color);
fflush(stdout);
}
int main(int argc, char **argv) {
cursor_set_color_string("yellow"); sleep(1);
cursor_set_color_string("gray"); sleep(1);
cursor_set_color_string("blue"); sleep(1);
cursor_set_color_string("red"); sleep(1);
cursor_set_color_string("brown"); sleep(1);
return 0;
}
色名のリストは次のとおりです: Xterm Colors。
次の形式で RGB カラーを使用することもできるようです\e]12;#XXXXXX\a
。
#include <stdio.h>
#include <unistd.h>
void cursor_set_color_rgb(unsigned char red,
unsigned char green,
unsigned char blue) {
printf("\e]12;#%.2x%.2x%.2x\a", red, green, blue);
fflush(stdout);
}
int main(int argc, char **argv) {
cursor_set_color_rgb(0xff, 0xff, 0xff); sleep(1);
cursor_set_color_rgb(0xff, 0xff, 0x00); sleep(1);
cursor_set_color_rgb(0xff, 0x00, 0xff); sleep(1);
cursor_set_color_rgb(0x00, 0xff, 0xff); sleep(1);
return 0;
}
于 2013-08-25T22:30:21.627 に答える