#include <curses.h>
void init(void){
initscr();
cbreak();
noecho();
nonl();
intrflush(stdscr,FALSE);
keypad(stdscr,TRUE);
nodelay(stdscr,FALSE);
}
int main(){
init();
attron(A_NORMAL); addstr("Normal display (no highlight)\n");
attron(A_STANDOUT); addstr("Best highlighting mode of the terminal.\n");
attroff(A_STANDOUT);
attron(A_UNDERLINE); addstr("Underlining\n");
attroff(A_UNDERLINE);
attron(A_REVERSE); addstr("Reverse video\n");
attroff(A_REVERSE);
attron(A_BLINK); addstr("Blinking\n");
attroff(A_BLINK);
attron(A_DIM); addstr("Half bright\n");
attroff(A_DIM);
attron(A_BOLD); addstr("Extra bright or bold\n");
attroff(A_BOLD);
attron(A_PROTECT); addstr("Protected mode\n");
attroff(A_PROTECT);
attron(A_INVIS); addstr("Invisible or blank mode\n");
attroff(A_INVIS);
attron(A_ALTCHARSET); addstr("Alternate character set\n");
attroff(A_ALTCHARSET);
attron(A_CHARTEXT); addstr("Bit-mask to extract a character\n");
attroff(A_CHARTEXT);
refresh();
getch();
clear(),refresh();
start_color();
init_pair(12,COLOR_YELLOW,COLOR_BLUE);
attron(COLOR_PAIR(12));
mvprintw(3,3,"你好嗎? \n");
attroff(COLOR_PAIR(12));
mvprintw(4,3,"你好嗎? \n");
getch();
clear();
mvaddstr(3,3,"Type something: ");
int c;
while((c=getch())!=27){
addch(c | A_BOLD);
}
clear();
refresh();
WINDOW* yes=newwin(5,5,5,5);
wborder(yes, '.', '.', '.','.','.','.','.','.');
mvwaddch(yes,6,6,'a');
refresh();
wrefresh(yes);
getch();
delwin(yes);
refresh();
getch();
clear();
refresh();
getch();
mvaddstr(3,3,"getstr test: ");
char a[100];
echo();
getstr(a);
mvaddstr(23,3,a);
noecho();
getch();
int i,j;
clear();
move(0,0);
refresh();
for(i=0;i<24;i++){
for(j=0;j<80;j++){
addch('*');
}
}
move(1,3);
while(1){
switch(getch()){
case '1': insch('#'); break;
case '2': insertln(); break;
case '3': delch(); break;
case '4': deleteln();
}}
endwin();
return 0;
}