xref: /original-bsd/usr.bin/window/wwinsline.c (revision 40192f2d)
1 #ifndef lint
2 static char sccsid[] = "@(#)wwinsline.c	3.7 04/24/85";
3 #endif
4 
5 /*
6  * Copyright (c) 1983 Regents of the University of California,
7  * All rights reserved.  Redistribution permitted subject to
8  * the terms of the Berkeley Software License Agreement.
9  */
10 
11 #include "ww.h"
12 
13 wwinsline(w, row)
14 register struct ww *w;
15 int row;
16 {
17 	register i;
18 	register union ww_char **cpp, **cqq;
19 	register union ww_char *cp;
20 	int row1, row2;
21 	char deleted;
22 	int visible;
23 
24 	/*
25 	 * Scroll first.
26 	 */
27 	if ((row1 = row) < w->ww_i.t) {
28 		row1 = w->ww_i.t;
29 		visible = 0;
30 	} else
31 		visible = 1;
32 	if ((row2 = w->ww_b.b) > w->ww_i.b) {
33 		row2 = w->ww_i.b;
34 	}
35 	deleted = wwscroll1(w, row1, row2, -1, visible);
36 
37 	/*
38 	 * Fix the buffer.
39 	 * But leave clearing the last line for wwclreol().
40 	 */
41 	cpp = &w->ww_buf[w->ww_b.b];
42 	cqq = cpp - 1;
43 	cp = *cqq;
44 	for (i = w->ww_b.b - row; --i > 0;)
45 		*--cpp = *--cqq;
46 	*cqq = cp;
47 
48 	/*
49 	 * Now clear the last line.
50 	 */
51 	if (visible)
52 		wwclreol1(w, row, w->ww_b.l, deleted);
53 	else
54 		for (i = w->ww_b.nc; --i >= 0;)
55 			cp++->c_w = ' ';
56 }
57