]>
git.saurik.com Git - apple/shell_cmds.git/blob - window/xxflush.c
1 /* $NetBSD: xxflush.c,v 1.4 1997/11/21 08:38:05 lukem Exp $ */
4 * Copyright (c) 1989, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Edward Wang at The University of California, Berkeley.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 #include <sys/cdefs.h>
42 static char sccsid
[] = "@(#)xxflush.c 8.1 (Berkeley) 6/6/93";
44 __RCSID("$NetBSD: xxflush.c,v 1.4 1997/11/21 08:38:05 lukem Exp $");
58 for (xp
= xx_head
; xp
!= 0 && !(intr
&& wwinterrupt()); xp
= xq
) {
62 (*tt
.tt_move
)(xp
->arg0
, xp
->arg1
);
68 (*tt
.tt_move
)(xp
->arg0
, xp
->arg1
);
69 tt
.tt_nmodes
= xp
->arg3
;
70 (*tt
.tt_inschar
)(xp
->arg2
);
73 (*tt
.tt_move
)(xp
->arg0
, xp
->arg1
);
74 (*tt
.tt_insspace
)(xp
->arg2
);
77 (*tt
.tt_move
)(xp
->arg0
, xp
->arg1
);
78 (*tt
.tt_delchar
)(xp
->arg2
);
84 (*tt
.tt_move
)(xp
->arg0
, xp
->arg1
);
88 (*tt
.tt_move
)(xp
->arg0
, xp
->arg1
);
92 (*tt
.tt_move
)(xp
->arg0
, xp
->arg1
);
93 tt
.tt_nmodes
= xp
->arg3
;
94 (*tt
.tt_write
)(xp
->buf
, xp
->arg2
);
100 if ((xx_head
= xp
) == 0) {
117 * We handle retain (da and db) by putting the burden on scrolling up,
118 * which is the less common operation. It must ensure that
119 * text is not pushed below the screen, so scrolling down doesn't
120 * have to worry about it.
122 * Try scrolling region (or scrolling the whole screen) first.
123 * Can we assume "sr" doesn't push text below the screen
124 * so we don't have to worry about retain below?
125 * What about scrolling down with a newline? It probably does
126 * push text above (with da). Scrolling up would then have
127 * to take care of that.
128 * It's easy to be fool proof, but that slows things down.
129 * The current solution is to disallow tt_scroll_up if da or db is true
130 * but cs (scrolling region) is not. Again, we sacrifice scrolling
131 * up in favor of scrolling down. The idea is having scrolling regions
132 * probably means we can scroll (even the whole screen) with impunity.
133 * This lets us work efficiently on simple terminals (use newline
134 * on the bottom to scroll), on any terminal without retain, and
135 * on vt100 style scrolling regions (I think).
138 if ((xq
= xp
->link
) != 0 && xq
->cmd
== xc_scroll
&&
139 xp
->arg2
== xq
->arg2
&& xq
->arg0
< 0) {
140 if (xp
->arg1
< xq
->arg1
) {
141 if (xp
->arg2
- xp
->arg0
<= xq
->arg1
) {
147 xp
->arg2
= xq
->arg1
+ xp
->arg0
;
148 xq
->arg0
+= xp
->arg0
;
151 xq
->arg1
-= xq
->arg0
;
154 if (xp
->arg1
- xq
->arg0
>= xp
->arg2
)
156 xq
->arg2
= xp
->arg1
- xq
->arg0
;
157 xp
->arg0
+= xq
->arg0
;
160 xp
->arg1
+= xp
->arg0
;
164 if (xp
->arg0
> xp
->arg2
- xp
->arg1
)
165 xp
->arg0
= xp
->arg2
- xp
->arg1
;
166 if (tt
.tt_scroll_down
) {
167 if (tt
.tt_scroll_top
!= xp
->arg1
||
168 tt
.tt_scroll_bot
!= xp
->arg2
- 1) {
169 if (tt
.tt_setscroll
== 0)
171 (*tt
.tt_setscroll
)(xp
->arg1
, xp
->arg2
- 1);
173 tt
.tt_scroll_down(xp
->arg0
);
176 (*tt
.tt_move
)(xp
->arg1
, 0);
177 (*tt
.tt_delline
)(xp
->arg0
);
178 if (xp
->arg2
< tt
.tt_nrow
) {
179 (*tt
.tt_move
)(xp
->arg2
- xp
->arg0
, 0);
180 (*tt
.tt_insline
)(xp
->arg0
);
184 xp
->arg0
= - xp
->arg0
;
185 if (xp
->arg0
> xp
->arg2
- xp
->arg1
)
186 xp
->arg0
= xp
->arg2
- xp
->arg1
;
187 if (tt
.tt_scroll_up
) {
188 if (tt
.tt_scroll_top
!= xp
->arg1
||
189 tt
.tt_scroll_bot
!= xp
->arg2
- 1) {
190 if (tt
.tt_setscroll
== 0)
192 (*tt
.tt_setscroll
)(xp
->arg1
, xp
->arg2
- 1);
194 tt
.tt_scroll_up(xp
->arg0
);
197 if (tt
.tt_retain
|| xp
->arg2
!= tt
.tt_nrow
) {
198 (*tt
.tt_move
)(xp
->arg2
- xp
->arg0
, 0);
199 (*tt
.tt_delline
)(xp
->arg0
);
201 (*tt
.tt_move
)(xp
->arg1
, 0);
202 (*tt
.tt_insline
)(xp
->arg0
);