/* http://www.cyut.edu.tw/~ckhung/b/mi/ */
/* 1999-06 */
/* how to compile: gcc -Wall charattr.c -lncurses */

#include <ncurses/curses.h>

int main()
{

    initscr();
    attrset(A_BOLD);		mvaddstr(0, 0, "bold (粗體)");
    attrset(A_UNDERLINE);	mvaddstr(1, 0, "underline (底線)");
    attrset(A_BLINK);		mvaddstr(2, 0, "blink (閃爍)");
    attrset(A_REVERSE);		mvaddstr(3, 0, "reverse (反白)");
    attrset(A_NORMAL);
    if (has_colors()) {
	mvaddstr(5, 0, "terminal supports color");
    } else {
	mvaddstr(5, 0, "terminal does not support color");
    }
    start_color();
    init_pair(1, COLOR_CYAN, COLOR_RED);
    attrset(COLOR_PAIR(1));
    mvaddstr(7, 0, "cyan on red (青字紅底)");
    attrset(A_BOLD | A_UNDERLINE | A_BLINK | A_REVERSE | COLOR_PAIR(1));
    mvaddstr(8, 0, "everything (上述全部)");
    attrset(A_NORMAL);

    cbreak();
    noecho();
    getch();
    endwin();
    return 0;
}

