#include <ncurses.h>
/* 사용 가능한 색상의 속성 필드 ====================================== #define COLOR_BLACK 0 #define COLOR_RED 1 #define COLOR_GREEN 2 #define COLOR_YELLOW 3 #define COLOR_BLUE 4 #define COLOR_MAGENTA 5 #define COLOR_CYAN 6 #define COLOR_WHITE 7 */
// // Ncurse 폰트 컬러 속성 // int main(void) { int y, x;
initscr();
/* set default init mode */ noecho(); raw();
// sector #01 if(has_colors() == FALSE) { endwin(); printf("Your terminal does not support color\n"); exit(1); } start_color();
// sector #02 if(init_color(COLOR_BLUE, 0, 0, 300) == ERR) { printw("your terminal cannot change the color definitions\n"); printw("press any key to continue . . .\n"); getch(); move(0,0); }
// sector #03 init_pair(1, COLOR_RED, COLOR_BLACK); init_pair(2, COLOR_GREEN, COLOR_BLACK); init_pair(3, COLOR_YELLOW, COLOR_BLACK); init_pair(4, COLOR_BLUE, COLOR_BLACK); init_pair(5, COLOR_MAGENTA, COLOR_BLACK); init_pair(6, COLOR_CYAN, COLOR_BLACK); init_pair(7, COLOR_WHITE, COLOR_BLACK); init_pair(8, COLOR_CYAN, COLOR_MAGENTA);
// sector #04 attron(A_BOLD);
// sector #05 attron(COLOR_PAIR(1)); printw("What's your favorite color(COLOR_RED)\n"); attron(COLOR_PAIR(2)); printw("What's your favorite color(COLOR_GREEN)\n"); attron(COLOR_PAIR(3)); printw("What's your favorite color(COLOR_YELLOW)\n"); attron(COLOR_PAIR(4)); printw("What's your favorite color(COLOR_BLUE)\n"); attron(COLOR_PAIR(5)); printw("What's your favorite color(COLOR_MAGENTA)\n"); attron(COLOR_PAIR(6)); printw("What's your favorite color(COLOR_CYAN)\n"); attron(COLOR_PAIR(7)); printw("What's your favorite color(COLOR_WHITE)\n"); attron(COLOR_PAIR(8)); printw("What's your favorite color(NORMAL)\n");
attrset(A_BOLD); getmaxyx(stdscr,y,x); mvprintw(y-1,0,"%s","Enter the any button to exit!"); getch();
endwin(); return 0; }
/* 04_color.c */
|