免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1138 | 回复: 0
打印 上一主题 下一主题

《Linux 程序设计入门》 第四版 §6.9 pads [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-12-15 10:52 |只看该作者 |倒序浏览

§6.9  pads
       Pads可以处理比物理屏幕更大的逻辑屏幕。
       pad
structure和WINDOW structure类似。Curses可用的写屏例程在pads都可用。Pads有自己的创建和刷新例程。删除使用delwin。
#include
WINDOW *newpad(int
number_of_lines, int number_of_columns);

刷新:
#include
int prefresh(WINDOW *pad_ptr, int pad_row, int
pad_column,

int screen_row_min, int screen_col_min,
int
screen_row_max, int screen_col_max);



       例程pnoutrefresh和类似,用于更有效的屏幕刷新。

实例:

# cat pad.c   
/*
At the start of this program, we initialize the pad structure
   
and then create a pad, which returns a pointer to that pad.
   
We add characters to fill the pad structure
   
(which is 50 characters wider and longer than the terminal display.  */

#include
#include
#include

int main()
{
   
WINDOW *pad_ptr;
   
int x, y;
   
int pad_lines;
   
int pad_cols;
   
char disp_char;

   
initscr();

   
pad_lines = LINES + 50;
   
pad_cols = COLS + 50;

    pad_ptr = newpad(pad_lines, pad_cols);

   
disp_char = 'a';
   
for (x = 0; x
      
for (y = 0; y
           
mvwaddch(pad_ptr, x, y, disp_char);
           
if (disp_char == 'z') disp_char = 'a';
           
else disp_char++;
      
}
    }

/*
We can now draw different areas of the pad on the screen at different
locations
   
before quitting.  */

   
prefresh(pad_ptr, 5, 7, 2, 2, 9, 9);
   
sleep(1);

   
prefresh(pad_ptr, LINES + 5, COLS + 7, 5, 5, 21, 19);
   
sleep(1);

   
delwin(pad_ptr);

   
endwin();
   
exit(EXIT_SUCCESS);
}
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/21908/showart_1721512.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP