|
|
1.1 root 1: #include <curses.h>
2:
3: #define min(a,b) (a < b ? a : b)
4:
5: main()
6: {
7: WINDOW *win1, *win2, *newwin();
8:
9: initscr();
10: win1 = newwin(10, 40, 3, 1); /* Origin at (y,x) = (3,1) and
11: * size of (dy,dx) = (10,40) */
12: box(win1, '*', '*');
13:
14: win2 = newwin(LINES-1, COLS-1, 1, 1); /* A large, blank window that
15: * gets the little one written
16: * onto it. */
17:
18: NewOverwrite(win1, win2); /* These three lines write win1 onto win2, */
19: wrefresh(win2); /* refresh win2, and sleep... */
20: sleep(2);
21:
22: mvwin(win1, 1, 3); /* These four lines move win1, erase the */
23: werase(win2); /* old win2, write win1 in its new position */
24: NewOverwrite(win1, win2); /* onto win2, and redisplay win2. Notice */
25: wrefresh(win2); /* irregularities in the border of win1. */
26: sleep(2);
27:
28: mvwin(win1, 1, 5); /* These four lines move win1 OUT OF the */
29: werase(win2); /* first 4 columns and it is displayed */
30: NewOverwrite(win1, win2); /* correctly, except for some traces of */
31: wrefresh(win2); /* the old win1's and a missing '*' near */
32: /* the lower-right corner. */
33:
34: mvcur(0, COLS - 1, LINES - 1, 0);
35: endwin();
36: }
37:
38: NewOverwrite(win1, win2)
39: reg WINDOW *win1, *win2;
40: {
41: reg int i, x, y, minx, miny, starty, startx;
42: /*
43: *
44: * minx and miny were erroneously computed before.
45: * The following assignments do it correctly.
46: *
47: */
48: miny = min(win1->_maxy, win2->_maxy + win2->_begy - win1->_begy);
49: minx = min(win1->_maxx, win2->_maxx + win2->_begx - win1->_begx);
50:
51: starty = win1->_begy - win2->_begy;
52: /*
53: *
54: * The following line was added:
55: *
56: */
57: startx = win1->_begx - win2->_begx;
58:
59: for (y = 0; y < miny; y++)
60: /*
61: *
62: * And this is the only other change...substituted startx
63: * for 0 here ---------------------
64: * |
65: * v */
66: if (wmove(win2, y + starty, startx) != ERR)
67: for (x = 0; x < minx; x++)
68: waddch(win2, win1->_y[y][x]);
69: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.