added "more" command
[unix-history] / usr / src / usr.bin / window / wwdelline.c
CommitLineData
a4c3355c 1#ifndef lint
60de5df9 2static char sccsid[] = "@(#)wwdelline.c 3.7 %G%";
a4c3355c
EW
3#endif
4
60de5df9
EW
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
a4c3355c
EW
11#include "ww.h"
12
f2a77fe1 13wwdelline(w, row)
a4c3355c 14register struct ww *w;
f2a77fe1 15int row;
a4c3355c
EW
16{
17 register i;
14f251df 18 register union ww_char **cpp, **cqq;
74f2441e 19 register union ww_char *cp;
19f9784c 20 int row1, row2;
14f251df 21 char deleted;
74f2441e 22 int visible;
a4c3355c
EW
23
24 /*
14f251df 25 * Scroll first.
a4c3355c 26 */
f2a77fe1
EW
27 if ((row1 = row) < w->ww_i.t) {
28 row1 = w->ww_i.t;
29 }
30 if ((row2 = w->ww_b.b) > w->ww_i.b) {
31 row2 = w->ww_i.b;
74f2441e
EW
32 visible = 0;
33 } else
34 visible = 1;
19f9784c 35 deleted = wwscroll1(w, row1, row2, 1, visible);
14f251df 36
a4c3355c 37 /*
14f251df
EW
38 * Fix the buffer.
39 * But leave clearing the last line for wwclreol().
a4c3355c 40 */
f2a77fe1 41 cpp = &w->ww_buf[row];
14f251df 42 cqq = cpp + 1;
74f2441e 43 cp = *cpp;
f2a77fe1 44 for (i = w->ww_b.b - row; --i > 0;)
14f251df 45 *cpp++ = *cqq++;
74f2441e 46 *cpp = cp;
a4c3355c 47
a4c3355c 48 /*
14f251df 49 * Now clear the last line.
a4c3355c 50 */
74f2441e 51 if (visible)
f2a77fe1 52 wwclreol1(w, w->ww_b.b - 1, w->ww_b.l, deleted);
74f2441e 53 else
f2a77fe1 54 for (i = w->ww_b.nc; --i >= 0;)
74f2441e 55 cp++->c_w = ' ';
a4c3355c 56}