1 /* 2 * CDDL HEADER START 3 * 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. 8 * 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. 13 * 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] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1988 AT&T */ 28 /* All Rights Reserved */ 29 30 /* 31 * University Copyright- Copyright (c) 1982, 1986, 1988 32 * The Regents of the University of California 33 * All Rights Reserved 34 * 35 * University Acknowledgment- Portions of this document are derived from 36 * software developed by the University of California, Berkeley, and its 37 * contributors. 38 */ 39 40 /*LINTLIBRARY*/ 41 42 #include <sys/types.h> 43 #include <stdlib.h> 44 #include "curses_inc.h" 45 46 /* This routine clears up to the end of line. */ 47 48 int 49 wclrtoeol(WINDOW *win) 50 { 51 int y = win->_cury; 52 int x = win->_curx; 53 int maxx = win->_maxx; 54 int cx; 55 chtype wc; 56 57 if (win != curscr) { 58 win->_nbyte = -1; 59 if (_scrmax > 1) { 60 if (ISMBIT(win->_y[y][x])) { 61 win->_insmode = TRUE; 62 if (_mbvalid(win) == ERR) 63 return (ERR); 64 x = win->_curx; 65 } 66 if (ISMBIT(win->_y[y][maxx - 1])) { 67 for (cx = maxx - 1; cx >= x; --cx) 68 if (!ISCBIT(win->_y[y][cx])) 69 break; 70 wc = RBYTE(win->_y[y][cx]); 71 if (cx + _curs_scrwidth[TYPE(wc)] > maxx) 72 maxx = cx - 1; 73 } 74 } 75 } 76 77 memSset(&win->_y[y][x], win->_bkgd, maxx - x); 78 maxx = win->_maxx; 79 80 #ifdef _VR3_COMPAT_CODE 81 if (_y16update) 82 (*_y16update)(win, 1, maxx - x, y, x); 83 #endif /* _VR3_COMPAT_CODE */ 84 85 /* if curscr, reset blank structure */ 86 if (win == curscr) { 87 if (_BEGNS[y] >= x) 88 /* LINTED */ 89 _BEGNS[y] = (short) maxx; 90 if (_ENDNS[y] >= x) 91 _ENDNS[y] = _BEGNS[y] > x ? -1 : x-1; 92 93 _CURHASH[y] = x == 0 ? 0 : _NOHASH; 94 95 if (_MARKS != NULL) { 96 char *mkp = _MARKS[y]; 97 int endx = COLS / 98 BITSPERBYTE + (COLS %BITSPERBYTE ? 1 : 0); 99 int m = x / BITSPERBYTE + 1; 100 101 for (; m < endx; ++m) 102 mkp[m] = 0; 103 mkp += x / BITSPERBYTE; 104 if ((m = x % BITSPERBYTE) == 0) 105 *mkp = 0; 106 else 107 for (; m < BITSPERBYTE; ++m) 108 *mkp &= ~(1 << m); 109 110 /* if color terminal, do the same for color marks */ 111 112 if (_COLOR_MARKS != NULL) { 113 mkp = _COLOR_MARKS[y]; 114 115 m = x / BITSPERBYTE + 1; 116 for (; m < endx; ++m) 117 mkp[m] = 0; 118 mkp += x / BITSPERBYTE; 119 if ((m = x % BITSPERBYTE) == 0) 120 *mkp = 0; 121 else 122 for (; m < BITSPERBYTE; ++m) 123 *mkp &= ~(1 << m); 124 } 125 } 126 return (OK); 127 } else { 128 /* update firstch and lastch for the line. */ 129 #ifdef DEBUG 130 if (outf) 131 fprintf(outf, "CLRTOEOL: line %d begx = %d, maxx = %d, " 132 "lastch = %d, next firstch %d\n", y, win->_begx, 133 win->_firstch[y], win->_lastch[y], win->_firstch[y+1]); 134 #endif /* DEBUG */ 135 136 if (win->_firstch[y] > x) 137 /* LINTED */ 138 win->_firstch[y] = (short) x; 139 win->_lastch[y] = maxx - 1; 140 win->_flags |= _WINCHANGED; 141 /* sync with ancestors structures */ 142 if (win->_sync) 143 wsyncup(win); 144 145 return (win->_immed ? wrefresh(win) : OK); 146 } 147 } 148