summaryrefslogtreecommitdiff
path: root/lib/libcurses/lib_clreol.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-12-03 05:21:47 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-12-03 05:21:47 +0000
commit211326e37501ac01a66994a221020b75ab5f63f0 (patch)
tree6d6c7182f1034b1b04c98386a1c3ba44e8accd5f /lib/libcurses/lib_clreol.c
parent7c742f381e7808d0b12c17b534305751f3ebb0cb (diff)
Merge of ncurses-4.1-971129
Diffstat (limited to 'lib/libcurses/lib_clreol.c')
-rw-r--r--lib/libcurses/lib_clreol.c79
1 files changed, 43 insertions, 36 deletions
diff --git a/lib/libcurses/lib_clreol.c b/lib/libcurses/lib_clreol.c
index 6ffd0fcee53..2b04e0a0a79 100644
--- a/lib/libcurses/lib_clreol.c
+++ b/lib/libcurses/lib_clreol.c
@@ -1,3 +1,5 @@
+/* $OpenBSD: lib_clreol.c,v 1.3 1997/12/03 05:21:14 millert Exp $ */
+
/***************************************************************************
* COPYRIGHT NOTICE *
@@ -29,49 +31,54 @@
#include <curses.priv.h>
-MODULE_ID("Id: lib_clreol.c,v 1.9 1997/02/01 23:22:54 tom Exp $")
+MODULE_ID("Id: lib_clreol.c,v 1.13 1997/09/20 15:02:34 juergen Exp $")
int wclrtoeol(WINDOW *win)
{
-chtype *maxx, *ptr, *end;
-short y, x, minx;
+int code = ERR;
+chtype blank;
+chtype *ptr, *end;
+short y, x;
T((T_CALLED("wclrtoeol(%p)"), win));
- y = win->_cury;
- x = win->_curx;
-
- /*
- * We don't want to clear if we just wrapped the cursor. There's no
- * point in clearing if we're not on a legal position, either.
- */
- if (win->_flags & _WRAPPED
- || y > win->_maxy
- || x > win->_maxx)
- returnCode(ERR);
-
- end = &win->_line[y].text[win->_maxx];
- minx = _NOCHANGE;
- maxx = &win->_line[y].text[x];
-
- for (ptr = maxx; ptr <= end; ptr++) {
- chtype blank = _nc_background(win);
-
- if (*ptr != blank) {
- maxx = ptr;
- if (minx == _NOCHANGE)
- minx = ptr - win->_line[y].text;
- *ptr = blank;
- }
- }
+ if (win) {
- if (minx != _NOCHANGE) {
- if (win->_line[y].firstchar > minx || win->_line[y].firstchar == _NOCHANGE)
- win->_line[y].firstchar = minx;
+ y = win->_cury;
+ x = win->_curx;
- if (win->_line[y].lastchar < maxx - win->_line[y].text)
- win->_line[y].lastchar = maxx - win->_line[y].text;
+ /*
+ * If we have just wrapped the cursor, the clear applies to the new
+ * line, unless we are at the lower right corner.
+ */
+ if (win->_flags & _WRAPPED
+ && y < win->_maxy) {
+ win->_flags &= ~_WRAPPED;
+ }
+
+ /*
+ * There's no point in clearing if we're not on a legal position,
+ * either.
+ */
+ if (win->_flags & _WRAPPED
+ || y > win->_maxy
+ || x > win->_maxx)
+ returnCode(ERR);
+
+ blank = _nc_background(win);
+ end = &win->_line[y].text[win->_maxx];
+
+ for (ptr = &win->_line[y].text[x]; ptr <= end; ptr++)
+ *ptr = blank;
+
+ if (win->_line[y].firstchar > win->_curx
+ || win->_line[y].firstchar == _NOCHANGE)
+ win->_line[y].firstchar = win->_curx;
+
+ win->_line[y].lastchar = win->_maxx;
+
+ _nc_synchook(win);
+ code = OK;
}
- _nc_synchook(win);
- returnCode(OK);
+ returnCode(code);
}