Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8333891
  • 博文数量: 1413
  • 博客积分: 11128
  • 博客等级: 上将
  • 技术积分: 14685
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-13 10:03
个人简介

follow my heart...

文章分类

全部博文(1413)

文章存档

2013年(1)

2012年(5)

2011年(45)

2010年(176)

2009年(148)

2008年(190)

2007年(293)

2006年(555)

分类: 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;
}

阅读(1045) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~