5 static WINDOW
*twin
; /* used by many routines */
7 /****************************************************************/
8 /* Gotoxy() moves the physical cursor to the desired address on */
9 /* The screen. We don't optimize here - on a PC, it takes more */
10 /* Time to optimize than to do things directly. */
11 /****************************************************************/
13 _PROTOTYPE(static void gotoxy
, (int row
, int col
));
14 _PROTOTYPE(static void newattr
, (int ch
));
15 _PROTOTYPE(static void Putchar
, (int ch
));
16 _PROTOTYPE(static void clrupdate
, (WINDOW
*scr
));
17 _PROTOTYPE(static void transformline
, (int lineno
));
19 static void gotoxy(row
, col
)
23 _cursvar
.cursrow
= row
;
24 _cursvar
.curscol
= col
;
27 /* Update attributes */
28 static void newattr(ch
)
31 extern char *me
, *as
, *ae
, *mb
, *md
, *mr
, *so
, *us
;
32 static int lastattr
= 0;
34 if (lastattr
!= (ch
&= ATR_MSK
)) {
38 if (ae
) tputs(ae
, 1, outc
);
40 if (ch
& A_ALTCHARSET
)
41 if (as
) tputs(as
, 1, outc
);
42 if (ch
& A_BLINK
) tputs(mb
, 1, outc
);
43 if (ch
& A_BOLD
) tputs(md
, 1, outc
);
44 if (ch
& A_REVERSE
) tputs(mr
, 1, outc
);
45 if (ch
& A_STANDOUT
) tputs(so
, 1, outc
);
46 if (ch
& A_UNDERLINE
) tputs(us
, 1, outc
);
50 /* Putchar() writes a character, with attributes, to the physical
51 screen, but avoids writing to the lower right screen position.
52 Should it care about am?
55 /* Output char with attribute */
56 static void Putchar(ch
)
59 if ((_cursvar
.cursrow
< LINES
) || (_cursvar
.curscol
< COLS
)) {
65 /****************************************************************/
66 /* Clrupdate(scr) updates the screen by clearing it and then */
67 /* Redraw it in it's entirety. */
68 /****************************************************************/
70 static void clrupdate(scr
)
81 if (scr
!= w
) { /* copy scr to curscr */
82 for (i
= 0; i
< LINES
; i
++) {
85 for (j
= 0; j
< COLS
; j
++) *dst
++ = *src
++;
91 for (i
= 0; i
< LINES
; i
++) { /* update physical screen */
95 if (*src
!= (' ' | ATR_NRM
)) {
97 while (j
< COLS
&& (*src
!= (' ' | ATR_NRM
))) {
110 /****************************************************************/
111 /* Transformline() updates the given physical line to look */
112 /* Like the corresponding line in _cursvar.tmpwin. */
113 /****************************************************************/
115 static void transformline(lineno
)
125 x
= twin
->_minchng
[lineno
];
126 endx
= twin
->_maxchng
[lineno
];
127 dstp
= curscr
->_line
[lineno
] + x
;
128 srcp
= twin
->_line
[lineno
] + x
;
131 if ((*dstp
!= *srcp
) || (dstc
!= srcc
)) {
133 while (x
<= endx
&& ((*dstp
!= *srcp
) || (dstc
!= srcc
))) {
143 twin
->_minchng
[lineno
] = _NO_CHANGE
;
144 twin
->_maxchng
[lineno
] = _NO_CHANGE
;
145 } /* transformline */
147 /****************************************************************/
148 /* Doupdate() updates the physical screen to look like _curs- */
149 /* Var.tmpwin if curscr is not 'Clear-marked'. Otherwise it */
150 /* Updates the screen to look like curscr. */
151 /****************************************************************/
157 twin
= _cursvar
.tmpwin
;
164 for (i
= 0; i
< LINES
; i
++)
165 if (twin
->_minchng
[i
] != _NO_CHANGE
)
169 curscr
->_curx
= twin
->_curx
;
170 curscr
->_cury
= twin
->_cury
;
171 gotoxy(curscr
->_cury
, curscr
->_curx
);