6811333 Remove prom_printf() message in emlxs driver
[opensolaris.git] / usr / src / lib / libcurses / screen / wclrtoeol.c
blobd24d5736fa4a803c88daba15ccdbf15a1c696459
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
33 * All Rights Reserved
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
37 * contributors.
40 #pragma ident "%Z%%M% %I% %E% SMI"
42 /*LINTLIBRARY*/
44 #include <sys/types.h>
45 #include <stdlib.h>
46 #include "curses_inc.h"
48 /* This routine clears up to the end of line. */
50 int
51 wclrtoeol(WINDOW *win)
53 int y = win->_cury;
54 int x = win->_curx;
55 int maxx = win->_maxx;
56 int cx;
57 chtype wc;
59 if (win != curscr) {
60 win->_nbyte = -1;
61 if (_scrmax > 1) {
62 if (ISMBIT(win->_y[y][x])) {
63 win->_insmode = TRUE;
64 if (_mbvalid(win) == ERR)
65 return (ERR);
66 x = win->_curx;
68 if (ISMBIT(win->_y[y][maxx - 1])) {
69 for (cx = maxx - 1; cx >= x; --cx)
70 if (!ISCBIT(win->_y[y][cx]))
71 break;
72 wc = RBYTE(win->_y[y][cx]);
73 if (cx + _curs_scrwidth[TYPE(wc)] > maxx)
74 maxx = cx - 1;
79 memSset(&win->_y[y][x], win->_bkgd, maxx - x);
80 maxx = win->_maxx;
82 #ifdef _VR3_COMPAT_CODE
83 if (_y16update)
84 (*_y16update)(win, 1, maxx - x, y, x);
85 #endif /* _VR3_COMPAT_CODE */
87 /* if curscr, reset blank structure */
88 if (win == curscr) {
89 if (_BEGNS[y] >= x)
90 /* LINTED */
91 _BEGNS[y] = (short) maxx;
92 if (_ENDNS[y] >= x)
93 _ENDNS[y] = _BEGNS[y] > x ? -1 : x-1;
95 _CURHASH[y] = x == 0 ? 0 : _NOHASH;
97 if (_MARKS != NULL) {
98 char *mkp = _MARKS[y];
99 int endx = COLS /
100 BITSPERBYTE + (COLS %BITSPERBYTE ? 1 : 0);
101 int m = x / BITSPERBYTE + 1;
103 for (; m < endx; ++m)
104 mkp[m] = 0;
105 mkp += x / BITSPERBYTE;
106 if ((m = x % BITSPERBYTE) == 0)
107 *mkp = 0;
108 else
109 for (; m < BITSPERBYTE; ++m)
110 *mkp &= ~(1 << m);
112 /* if color terminal, do the same for color marks */
114 if (_COLOR_MARKS != NULL) {
115 mkp = _COLOR_MARKS[y];
117 m = x / BITSPERBYTE + 1;
118 for (; m < endx; ++m)
119 mkp[m] = 0;
120 mkp += x / BITSPERBYTE;
121 if ((m = x % BITSPERBYTE) == 0)
122 *mkp = 0;
123 else
124 for (; m < BITSPERBYTE; ++m)
125 *mkp &= ~(1 << m);
128 return (OK);
129 } else {
130 /* update firstch and lastch for the line. */
131 #ifdef DEBUG
132 if (outf)
133 fprintf(outf, "CLRTOEOL: line %d begx = %d, maxx = %d, "
134 "lastch = %d, next firstch %d\n", y, win->_begx,
135 win->_firstch[y], win->_lastch[y], win->_firstch[y+1]);
136 #endif /* DEBUG */
138 if (win->_firstch[y] > x)
139 /* LINTED */
140 win->_firstch[y] = (short) x;
141 win->_lastch[y] = maxx - 1;
142 win->_flags |= _WINCHANGED;
143 /* sync with ancestors structures */
144 if (win->_sync)
145 wsyncup(win);
147 return (win->_immed ? wrefresh(win) : OK);