source: trunk/minix/lib/curses/overlay.c@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 3.3 KB
Line 
1/****************************************************************/
2/* Overlay() and overwrite() functions of the PCcurses package */
3/* */
4/****************************************************************/
5/* This version of curses is based on ncurses, a curses version */
6/* Originally written by Pavel Curtis at Cornell University. */
7/* I have made substantial changes to make it run on IBM PC's, */
8/* And therefore consider myself free to make it public domain. */
9/* Bjorn Larsson (...mcvax!enea!infovax!bl) */
10/****************************************************************/
11/* 1.0: Release: 870515 */
12/****************************************************************/
13/* Modified to run under the MINIX operating system by Don Cope */
14/* These changes are also released into the public domain. */
15/* 900906 */
16/****************************************************************/
17
18#include <curses.h>
19#include "curspriv.h"
20
21/****************************************************************/
22/* Overlay() overwrites 'win1' upon 'win2', with origins alig- */
23/* Ned. Overlay is transparent; blanks from 'win1' are not */
24/* Copied to 'win2'. */
25/****************************************************************/
26void overlay(win1, win2)
27WINDOW *win1, *win2;
28{
29 int *minchng;
30 int *maxchng;
31 int *w1ptr;
32 int *w2ptr;
33 int attrs;
34 int col;
35 int line;
36 int last_line;
37 int last_col;
38
39 last_col = min(win1->_maxx, win2->_maxx);
40 last_line = min(win1->_maxy, win2->_maxy);
41 attrs = win2->_attrs & ATR_MSK;
42 minchng = win2->_minchng;
43 maxchng = win2->_maxchng;
44
45 for (line = 0; line <= last_line; line++) {
46 register short fc, lc = 0;
47 w1ptr = win1->_line[line];
48 w2ptr = win2->_line[line];
49 fc = _NO_CHANGE;
50 for (col = 0; col <= last_col; col++) {
51 if ((*w1ptr & CHR_MSK) != ' ') {
52 *w2ptr = (*w1ptr & CHR_MSK) | attrs;
53 if (fc == _NO_CHANGE) fc = col;
54 lc = col;
55 }
56 w1ptr++;
57 w2ptr++;
58 }
59
60 if (*minchng == _NO_CHANGE) {
61 *minchng = fc;
62 *maxchng = lc;
63 } else if (fc != _NO_CHANGE) {
64 if (fc < *minchng) *minchng = fc;
65 if (lc > *maxchng) *maxchng = lc;
66 }
67 minchng++;
68 maxchng++;
69 } /* for */
70} /* overlay */
71
72/****************************************************************/
73/* Overwrite() overwrites 'win1' upon 'win2', with origins */
74/* Aligned. Overwrite is non-transparent; blanks from 'win1' */
75/* Are copied to 'win2'. */
76/****************************************************************/
77void overwrite(win1, win2)
78WINDOW *win1, *win2;
79{
80 int *minchng;
81 int *maxchng;
82 int *w1ptr;
83 int *w2ptr;
84 int attrs;
85 int col;
86 int line;
87 int last_line;
88 int last_col;
89
90 last_col = min(win1->_maxx, win2->_maxx);
91 last_line = min(win1->_maxy, win2->_maxy);
92 attrs = win2->_attrs & ATR_MSK;
93 minchng = win2->_minchng;
94 maxchng = win2->_maxchng;
95
96 for (line = 0; line <= last_line; line++) {
97 register short fc, lc = 0;
98
99 w1ptr = win1->_line[line];
100 w2ptr = win2->_line[line];
101 fc = _NO_CHANGE;
102
103 for (col = 0; col <= last_col; col++) {
104 if ((*w1ptr & CHR_MSK) != (*w2ptr & CHR_MSK)) {
105 *w2ptr = (*w1ptr & CHR_MSK) | attrs;
106
107 if (fc == _NO_CHANGE) fc = col;
108 lc = col;
109 }
110 w1ptr++;
111 w2ptr++;
112 } /* for */
113
114 if (*minchng == _NO_CHANGE) {
115 *minchng = fc;
116 *maxchng = lc;
117 } else if (fc != _NO_CHANGE) {
118 if (fc < *minchng) *minchng = fc;
119 if (lc > *maxchng) *maxchng = lc;
120 }
121 minchng++;
122 maxchng++;
123 }
124}
Note: See TracBrowser for help on using the repository browser.