follow my heart...
分类: C/C++
2006-09-21 12:57:57
Curses库是一基于C语言的字符gui库,这里有两个例程,与大家分享.
//程序在winxp+devc++4.9下下载curses库后,建立curses application程序后调试通过
例程-
#i nclude
#i nclude
#i nclude
int main()
{ initscr();
move(5,15);
printw("%s","Hello World!");
***();
}
例程二
/*
Based on:
*/
#i nclude
#i nclude
#define COLOR1 1
#define COLOR2 2
int main () {
int c;
char *s;
initscr ();
cbreak ();
noecho ();
start_color ();
keypad (stdscr, TRUE);
curs_set(0);
if (!has_colors ()) {
endwin ();
fputs ("No colors!", stderr);
exit (1);
}
init_pair (COLOR1, COLOR_RED, COLOR_BLUE);
init_pair (COLOR2, COLOR_YELLOW, COLOR_BLACK);
attron (COLOR_PAIR( COLOR1 ));
mvaddstr (2, 5, "Red on blue.");
attron (COLOR_PAIR( COLOR2 ));
mvaddstr (3, 5, "Yellow on black.");
mvaddstr (LINES-1, COLS-20, "Press F10 for end.");
while ( (c=getch()) != KEY_F(10)) {
s = (char *) keyname(c);
if (s)
mvprintw (10, 20, "'%s'", s);
else
mvprintw (10, 20, "'%c'", (isprint(c) ? c : '.'));
}
erase ();
*** ();
endwin ();
return 0;
}