document distributed with 4.3BSD
[unix-history] / usr / src / lib / libcurses / clrtoeol.c
CommitLineData
6e1c93d0
DF
1/*
2 * Copyright (c) 1980 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
7#ifndef lint
8static char sccsid[] = "@(#)clrtoeol.c 5.1 (Berkeley) %G%";
9#endif not lint
10
e6f2eb0e
KA
11# include "curses.ext"
12
13/*
14 * This routine clears up to the end of line
15 *
e6f2eb0e
KA
16 */
17wclrtoeol(win)
18reg WINDOW *win; {
19
20 reg char *sp, *end;
21 reg int y, x;
22 reg char *maxx;
23 reg int minx;
24
25 y = win->_cury;
26 x = win->_curx;
27 end = &win->_y[y][win->_maxx];
28 minx = _NOCHANGE;
29 maxx = &win->_y[y][x];
30 for (sp = maxx; sp < end; sp++)
31 if (*sp != ' ') {
32 maxx = sp;
33 if (minx == _NOCHANGE)
34 minx = sp - win->_y[y];
35 *sp = ' ';
36 }
37 /*
38 * update firstch and lastch for the line
39 */
26a29dea 40 touchline(win, y, win->_curx, win->_maxx - 1);
e6f2eb0e
KA
41# ifdef DEBUG
42 fprintf(outf, "CLRTOEOL: minx = %d, maxx = %d, firstch = %d, lastch = %d\n", minx, maxx - win->_y[y], win->_firstch[y], win->_lastch[y]);
43# endif
e6f2eb0e 44}