/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
#include <stdlib.h>
#include <string.h>
#include "curses_inc.h"
/*
* Make the screen look like "win" over the area covered by win.
* win : the window being updated
*/
extern int outchcount;
static void _updateln(int), _turn_off_background(void),
_useceod(int, int);
_getceod(int, int);
#ifdef _VR2_COMPAT_CODE
extern char _endwin;
#endif /* _VR2_COMPAT_CODE */
int
{
/* don't allow curscr refresh if the screen was just created */
return (OK);
/* go thru _stdbody */
(void) wnoutrefresh(win);
/* if there is typeahead */
if (curwin)
return (OK);
}
/* save curscr cursor coordinates */
/* to simplify code in some cases */
outchcount = 0;
/* make sure we're in program mode */
/* If endwin is equal to 2 it means we just did a newscreen. */
(void) reset_prog_mode();
if (slk)
(*_do_slk_tch)();
_cursorstate], 0);
}
if (exit_attribute_mode)
else
/*
* If there is no exit_attribute mode, then vidupdate
* could only possibly turn off one of the below three
* so that's all we ask it turn off.
*/
A_UNDERLINE), _outch);
#ifdef _VR2_COMPAT_CODE
#endif /* _VR2_COMPAT_CODE */
}
/* clear the screen if required */
/* SS: colors */
if (back_color_erase)
/* _sync indicates that this a new screen */
else {
BITSPERBYTE ? 0 : 1);
*ensch++ = -1;
*hs++ = 0;
if (marks)
}
}
if (slk)
(*_do_slk_tch)();
/* pretend _virtscr has been totally changed */
_VIRTTOP = 0;
} else
/* Software soft labels; if _changed == 2, slk's are in clear mode. */
(*_do_slk_noref)();
/* do line updating */
/* this line is up-to-date */
goto next;
/* there is type-ahead */
/* LINTED */
goto done;
}
if (clby < 0) {
/* now we have to work, check for ceod */
}
/* try clear-to-eod */
(*_useidln)();
}
next:
*ensch = -1;
}
/* do hardware soft labels; if _changed == 2, */
/* slk's are in clear mode. */
(*_do_slk_ref)();
/* move cursor */
/* LINTED */
/* LINTED */
}
/* reset the flags */
/* virtual image is now up-to-date */
_VIRTBOT = -1;
done :
return (outchcount);
}
/* Shift appropriate portions of a line to leave space for cookies. */
static chtype *
{
short curx;
static int length;
/* allocate space for shifted line */
if (line)
}
/* no space to do it */
if (!line)
/* use existing blank */
/* use previous blank */
else
} else {
++curx;
--wcp;
}
} else
}
/* make sure that the end of the line is normal */
}
return (line);
}
/*
* Update a line.
* Three schemes of coloring are allowed. The first is the usual
* In this case, colorings are specified by intervals, the left
* side of the interval has the coloring mark, the right side
* has the end-coloring mark. We assume that clear sequences will
* clear ALL marks in the affected regions. The second case is
* signified by the boolean flag ceol_standout_glitch.
* The third case is for terminals that leave visible cookies on
* the screen. This last case is at most an approximation of what
* can be done right.
*/
static void
{
/* easy case */
return;
/* line images */
/* the interval to be updated */
if (redraw || magic_cookie_glitch >= 0) {
wx = 0;
} else {
}
/* skip equal parts */
if (!redraw) {
/* skip the starting equal part */
break;
return;
/* start update at an entire character */
break;
/* skip the ending equal part */
break;
++wp;
++wp;
++sp;
++sp;
break;
}
/* place to do clear-eol */
else
blnkx = -1;
else {
break;
break;
}
/* on cookie terminals, we may need to do more work */
if (marks) {
/* video_attrx = color_attrx = scrco; */
/* find the last video attribute on the line */
break;
/* find the last color attribute on the line */
if (color_marks) {
break;
if (color_attrx < lastx)
color_attrx++;
}
if (video_attrx < lastx)
video_attrx++;
if (video_attrx >= scrco)
--video_attrx;
--color_attrx;
--video_attrx;
if (color_marks && magic_cookie_glitch > 0 &&
--color_attrx;
break;
}
} else
if (!marks)
idcx = -1;
else {
/* on cookie term, only do idch where no attrs */
/* are used */
break;
}
/* max amount of insert allow */
maxi = 0;
else
else
/* go */
/* skip things that are already right */
if (!redraw) {
multi_col = 0;
break;
goto done;
break;
multi_col = 1;
}
}
/* try clear-bol, we'll assume exclusive clr_bol */
break;
/* clearing only whole screen characters */
break;
x -= 1;
/* MORE?: colors - mvcur will shuts of */
/* colors when msgr is not defined */
/* SS: colors */
if (back_color_erase)
/* LINTED */
/* LINTED */
cx = (short) x;
wx = x;
}
}
/* screen image is changing */
/* move to the point to start refresh */
/* LINTED */
/* LINTED */
/* update screen image */
break;
/* real video attributes */
if (marks)
/* blanks only */
/* SS: colors */
if (back_color_erase)
/* LINTED */
/* LINTED */
A_NORMAL) {
}
goto done;
}
break;
}
/* about to output chars, make sure insert */
/* mode is off */
_OFFINSERT();
/* color and video attributes */
if (marks)
video_change = TRUE;
if (color_marks)
color_change = TRUE;
/* the following may occurs when, for */
/* example the application */
/* is written for color terminal and then */
/* run on a monocrome */
goto no_change;
/* prevent spilling out of line */
video_attrx)) || (color_change &&
int tempx;
if (!didvideo && video_change &&
wy, video_attrx);
[video_attrx]),
[video_attrx-1]));
NULL);
}
if (!didcolor && color_change &&
if (tempx != color_attrx)
/*
* sc = _COLOR(curscr->_y[wy][color_attrx]);
*_VIDS(sc, (~sc & A_COLOR));
*/
[color_attrx]),
[color_attrx-1]));
}
}
}
/* on cookie terminals mark the interval */
if (video_change)
if (color_change)
}
/* end-of-line */
x = 1;
if (_scrmax > 1)
goto done;
}
if (transparent_underline && erase_overstrike &&
(void) _outch(' ');
}
/* put out the character */
wcp++;
wx++;
cx++;
/* output entire multi-byte chars */
wx++;
cx++;
}
}
}
done:
if (changed) {
/* update the blank structure */
break;
/* LINTED */
else {
break;
/* LINTED */
}
/* update the hash structure */
}
}
/*
* See if a left or right shift is apppropriate
* This routine is called only if !cookie_glitch or no video attributes
* are used in the affected part.
* The main idea is to find a longest common substring which is a
* prefix of one of 'wcp' or 'scp', then either delete or
* insert depending on where the prefix is.
*
* wcp : what we want the screen to look like
* scp : what the screen looks like now
* length: the length to be updated
* maxi: maximum possible insert amount
*
* Return the number of chars matched after the shift.
*/
static int
{
/* try deletion */
else
/* SS: colors */
if (back_color_erase)
_ONINSERT();
} else {
_OFFINSERT();
}
}
if (parm_dch)
else
}
/* update screen image */
return (match);
}
}
/* no insertion wanted or possible */
return (0);
/* see if insertion is worth it */
return (0);
/* see if inserting blanks only */
blnk = 0;
break;
}
/* see if doing insertion is worth it */
else
if (insert_character)
} else {
else
}
return (0);
/* perform the insertions */
/* SS: colors */
if (back_color_erase)
_ONINSERT();
else
if (insert_character)
goto do_insert_char;
else
/* so that we'll do real char insertions */
blnk = 0;
} else {
else {
}
}
/* inserting desired characters */
if (!blnk)
++cx;
}
/* update the screen image */
}
/*
* Find a substring of s2 that match a prefix of s1.
* The substring is such that:
* 1. it does not start with an element
* that is in perfect alignment with one in s1 and
* 2: it is at least as long as the displacement.
*
* length: the length of s1, s2.
* maxs: only search for match in [1,maxs] of s2.
* begm: *begm returns where the match begins.
*
* Return the number of matches.
*/
static int
{
int m, n, k;
n = 0;
for (m = 1; m <= maxs; ++m)
/* testing for s1[m] != s2[m] is condition 1 */
/* see if it's long enough (condition 2) */
for (k = 2 * m - 1; k > m; --k)
break;
/* found a match with a good length */
if (k == m) {
*begm = m;
/* count the # of matches */
s2 += m;
length -= m;
for (n = m; n < length; ++n)
break;
goto done;
}
}
done:
return (n);
}
/* Set video markers for cookie terminal. */
static void
{
long a;
/* set the mark map */
if (s) {
/* set the video attr of the first char here */
/* LINTED */
/* now the video attr of the rest of the affected interval */
if (_ISMARK1(y, x))
break;
else
/* LINTED */
}
}
/* Set color markers for cookie terminal. */
static void
{
long a;
/* set the mark map */
if (s) {
/* set the video attr of the first char here */
/* LINTED */
/* now the video attr of the rest of the affected interval */
if (_ISMARK2(y, x))
break;
else
/* LINTED */
}
}
/* At the right margin various weird things can happen. We treat them here. */
/* At the right margin various weird things can happen. We treat them here. */
static void
{
int x, w, ix;
/* screen may scroll */
/* can't do anything */
return;
/* the width of the new character */
/* the place to put it without causing scrolling */
for (x = wx - 1; x > 0; --x)
break;
(void) _outwch(tilde_glitch &&
}
/* insert sc back in and push wcp[wx] right */
/* SS: colors */
if (back_color_erase)
_ONINSERT();
/* width of the old character that was overwritten */
if (insert_character)
else
/* make sure the video attrs are ok */
/* update screen image */
/* LINTED */
}
return;
}
/* put char out and update screen image */
}
/* make sure that wrap-around happens */
if (!auto_right_margin || eat_newline_glitch) {
(void) _outch('\r');
(void) _outch('\n');
}
cx = 0;
++cy;
}
/*
* Find the top-most line to do clear-to-eod.
*
* topy, boty: the region to consider
*/
static int
{
int wy;
/* do nothing */
return (boty);
continue;
break;
break;
}
return (wy + 1);
}
/* Use hardware clear-to-bottom. */
static void
{
/* skip lines already blanked */
break;
else
/* nothing to do */
return;
/* see if bottom is clear */
return;
/* use clear-screen if appropriate */
if (topy == 0) {
/* SS: colors */
if (back_color_erase)
} else
/* use clear-to-end-of-display or delete lines */
/* LINTED */
cx = 0;
/* SS: colors */
if (back_color_erase)
/* update curscr */
/* LINTED */
} else
/* no hardware support */
return;
/* correct the update structure */
}
static void
_turn_off_background(void)
{
/* this routine turn the background color to zero. This need to be */
/* done only in forllowing cases: */
/* 1) We are using Tek type terminal (which has bce terminfo */
/* variable) */
/* 2) The current background is not already zero */
}
}