- 论坛徽章:
- 0
|
§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 |
|