|
CS256 - Fundamentals of Structured Programming
|
Displaying ./code/curses/ex.c
#include <curses.h>
#include <string.h>
// Compile:
// gcc -o example3 example3.c -lncurses
int main(void)
{
initscr();
start_color();
// Define some color pairs:
init_pair(1, COLOR_WHITE, COLOR_RED);
init_pair(2, COLOR_WHITE, COLOR_GREEN);
init_pair(3, COLOR_WHITE, COLOR_BLUE);
// Draw three rows of colors:
for(int col=5; col < COLS-5; col++) {
mvaddch(5, col, '+' | COLOR_PAIR(1));
mvaddch(6, col, '-' | COLOR_PAIR(2));
mvaddch(7, col, '/' | COLOR_PAIR(3));
}
refresh();
attrset(A_NORMAL);
mvprintw(LINES-1,0, "Press any key to exit.");
getch();
endwin();
return 0;
}
|