- /*
- * 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;
+ /*
+ * 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);
+ line = &win->_line[y];
+ CHANGED_TO_EOL(line, x, win->_maxx);
+
+ ptr = &(line->text[x]);
+ end = &(line->text[win->_maxx]);
+
+ while (ptr <= end)
+ *ptr++ = blank;
+
+ _nc_synchook(win);
+ code = OK;