2000-04-21 19:56:35 +04:00
|
|
|
/* $NetBSD: refresh.c,v 1.22 2000/04/21 15:56:35 jdc Exp $ */
|
1997-07-22 11:36:20 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1994-08-18 01:51:41 +04:00
|
|
|
* Copyright (c) 1981, 1993, 1994
|
1993-11-09 06:34:01 +03:00
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1997-07-22 11:36:20 +04:00
|
|
|
#include <sys/cdefs.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#ifndef lint
|
1997-07-22 11:36:20 +04:00
|
|
|
#if 0
|
1994-08-18 01:51:41 +04:00
|
|
|
static char sccsid[] = "@(#)refresh.c 8.7 (Berkeley) 8/13/94";
|
1997-07-22 11:36:20 +04:00
|
|
|
#else
|
2000-04-21 19:56:35 +04:00
|
|
|
__RCSID("$NetBSD: refresh.c,v 1.22 2000/04/21 15:56:35 jdc Exp $");
|
1997-07-22 11:36:20 +04:00
|
|
|
#endif
|
1999-04-13 18:08:17 +04:00
|
|
|
#endif /* not lint */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-08-07 09:48:37 +04:00
|
|
|
#include <string.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-08-18 01:51:41 +04:00
|
|
|
#include "curses.h"
|
2000-04-11 17:57:08 +04:00
|
|
|
#include "curses_private.h"
|
1994-08-18 01:51:41 +04:00
|
|
|
|
2000-04-19 17:52:39 +04:00
|
|
|
/* the following is defined and set up in setterm.c */
|
|
|
|
extern struct tinfo *_cursesi_genbuf;
|
2000-04-21 19:56:35 +04:00
|
|
|
|
1993-08-07 09:48:37 +04:00
|
|
|
static int curwin;
|
|
|
|
static short ly, lx;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-08-07 09:48:37 +04:00
|
|
|
static void domvcur __P((int, int, int, int));
|
|
|
|
static int makech __P((WINDOW *, int));
|
1994-08-18 01:51:41 +04:00
|
|
|
static void quickch __P((WINDOW *));
|
1993-11-09 06:34:01 +03:00
|
|
|
static void scrolln __P((WINDOW *, int, int, int, int, int));
|
2000-04-16 13:55:16 +04:00
|
|
|
static void unsetattr __P((int));
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2000-04-15 17:17:02 +04:00
|
|
|
#ifndef _CURSES_USE_MACROS
|
|
|
|
|
|
|
|
/*
|
|
|
|
* refresh --
|
|
|
|
* Make the current screen look like "stdscr" over the area covered by
|
|
|
|
* stdscr.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
refresh(void)
|
|
|
|
{
|
|
|
|
return wrefresh(stdscr);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
1993-08-07 09:48:37 +04:00
|
|
|
/*
|
|
|
|
* wrefresh --
|
|
|
|
* Make the current screen look like "win" over the area coverd by
|
|
|
|
* win.
|
|
|
|
*/
|
|
|
|
int
|
2000-04-15 17:17:02 +04:00
|
|
|
wrefresh(WINDOW *win)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1998-02-03 22:12:13 +03:00
|
|
|
__LINE *wlp;
|
1999-04-13 18:08:17 +04:00
|
|
|
int retval;
|
|
|
|
short wy;
|
|
|
|
int dnum;
|
1994-08-18 01:51:41 +04:00
|
|
|
|
1997-09-13 01:08:22 +04:00
|
|
|
/* Check if we need to restart ... */
|
|
|
|
if (__endwin) {
|
|
|
|
__endwin = 0;
|
|
|
|
__restartwin();
|
|
|
|
}
|
|
|
|
|
1993-08-07 09:48:37 +04:00
|
|
|
/* Initialize loop parameters. */
|
1993-11-09 06:34:01 +03:00
|
|
|
ly = curscr->cury;
|
|
|
|
lx = curscr->curx;
|
1993-03-21 12:45:37 +03:00
|
|
|
wy = 0;
|
|
|
|
curwin = (win == curscr);
|
|
|
|
|
1993-11-09 06:34:01 +03:00
|
|
|
if (!curwin)
|
|
|
|
for (wy = 0; wy < win->maxy; wy++) {
|
|
|
|
wlp = win->lines[wy];
|
|
|
|
if (wlp->flags & __ISDIRTY)
|
1999-06-23 07:27:34 +04:00
|
|
|
wlp->hash = __hash((char *)(void *)wlp->line,
|
1999-04-13 18:08:17 +04:00
|
|
|
(int) (win->maxx * __LDATASIZE));
|
1993-11-09 06:34:01 +03:00
|
|
|
}
|
|
|
|
|
2000-04-19 02:47:01 +04:00
|
|
|
if ((win->flags & __CLEAROK) || (curscr->flags & __CLEAROK) || curwin) {
|
1993-11-09 06:34:01 +03:00
|
|
|
if ((win->flags & __FULLWIN) || curscr->flags & __CLEAROK) {
|
2000-04-21 19:56:35 +04:00
|
|
|
short wx;
|
|
|
|
attr_t bcolor;
|
|
|
|
|
|
|
|
bcolor = win->lines[0]->line[0].battr & __COLOR;
|
|
|
|
for (wy = 0; wy < win->maxy; wy++)
|
|
|
|
for (wx = 0; wx < win->maxx; wx++)
|
|
|
|
if ((win->lines[wy]->line[wx].battr &
|
|
|
|
__COLOR) != bcolor)
|
|
|
|
goto colorchanged;
|
|
|
|
if ((!bcolor || (bcolor && BE)) && win->bch == ' ') {
|
|
|
|
if (bcolor) {
|
|
|
|
if (bcolor !=
|
|
|
|
(curscr->wattr & __COLOR)) {
|
|
|
|
__set_color(bcolor);
|
2000-04-19 02:47:01 +04:00
|
|
|
curscr->wattr &= ~__COLOR;
|
2000-04-21 19:56:35 +04:00
|
|
|
curscr->wattr |= bcolor;
|
2000-04-19 02:47:01 +04:00
|
|
|
}
|
|
|
|
} else if (curscr->wattr & __COLOR) {
|
|
|
|
if (OC != NULL && CC == NULL)
|
|
|
|
tputs(OC, 0, __cputchar);
|
|
|
|
if (OP != NULL) {
|
|
|
|
tputs(OP, 0, __cputchar);
|
|
|
|
if (SE != NULL &&
|
|
|
|
!strcmp(OP, SE))
|
|
|
|
curscr->wattr &=
|
|
|
|
~__STANDOUT;
|
|
|
|
if (UE != NULL &&
|
|
|
|
!strcmp(OP, UE))
|
|
|
|
curscr->wattr &=
|
|
|
|
~__UNDERSCORE;
|
|
|
|
if (ME != NULL &&
|
|
|
|
!strcmp(OP, ME))
|
|
|
|
curscr->wattr &=
|
|
|
|
~__TERMATTR;
|
|
|
|
}
|
|
|
|
curscr->wattr &= ~__COLOR;
|
|
|
|
}
|
|
|
|
tputs(CL, 0, __cputchar);
|
|
|
|
ly = 0;
|
|
|
|
lx = 0;
|
|
|
|
if (!curwin) {
|
|
|
|
curscr->flags &= ~__CLEAROK;
|
|
|
|
curscr->cury = 0;
|
|
|
|
curscr->curx = 0;
|
|
|
|
werase(curscr);
|
|
|
|
}
|
|
|
|
__touchwin(win);
|
|
|
|
} else {
|
2000-04-21 19:56:35 +04:00
|
|
|
colorchanged: if (!curwin)
|
2000-04-19 02:47:01 +04:00
|
|
|
curscr->flags &= ~__CLEAROK;
|
|
|
|
touchwin(win);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
1993-11-09 06:34:01 +03:00
|
|
|
win->flags &= ~__CLEAROK;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
if (!CA) {
|
1993-11-09 06:34:01 +03:00
|
|
|
if (win->curx != 0)
|
1993-08-07 09:48:37 +04:00
|
|
|
putchar('\n');
|
1993-03-21 12:45:37 +03:00
|
|
|
if (!curwin)
|
|
|
|
werase(curscr);
|
|
|
|
}
|
1993-08-07 09:48:37 +04:00
|
|
|
#ifdef DEBUG
|
1993-11-09 06:34:01 +03:00
|
|
|
__CTRACE("wrefresh: (%0.2o): curwin = %d\n", win, curwin);
|
|
|
|
__CTRACE("wrefresh: \tfirstch\tlastch\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if ((win->flags & __FULLWIN) && !curwin) {
|
|
|
|
/*
|
|
|
|
* Invoke quickch() only if more than a quarter of the lines
|
|
|
|
* in the window are dirty.
|
|
|
|
*/
|
|
|
|
for (wy = 0, dnum = 0; wy < win->maxy; wy++)
|
|
|
|
if (win->lines[wy]->flags & (__ISDIRTY | __FORCEPAINT))
|
|
|
|
dnum++;
|
|
|
|
if (!__noqch && dnum > (int) win->maxy / 4)
|
|
|
|
quickch(win);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1999-04-13 18:08:17 +04:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
1993-11-09 06:34:01 +03:00
|
|
|
__CTRACE("#####################################\n");
|
|
|
|
for (i = 0; i < curscr->maxy; i++) {
|
|
|
|
__CTRACE("C: %d:", i);
|
|
|
|
__CTRACE(" 0x%x \n", curscr->lines[i]->hash);
|
1994-08-18 01:51:41 +04:00
|
|
|
for (j = 0; j < curscr->maxx; j++)
|
1999-04-13 18:08:17 +04:00
|
|
|
__CTRACE("%c", curscr->lines[i]->line[j].ch);
|
1993-11-09 06:34:01 +03:00
|
|
|
__CTRACE("\n");
|
1999-09-17 18:21:04 +04:00
|
|
|
__CTRACE(" attr:");
|
1994-08-18 01:51:41 +04:00
|
|
|
for (j = 0; j < curscr->maxx; j++)
|
1999-09-17 18:21:04 +04:00
|
|
|
__CTRACE(" %x", curscr->lines[i]->line[j].attr);
|
1993-11-09 06:34:01 +03:00
|
|
|
__CTRACE("\n");
|
|
|
|
__CTRACE("W: %d:", i);
|
2000-04-11 17:57:08 +04:00
|
|
|
/* Handle small windows */
|
|
|
|
if (i >= win->begy && i < (win->begy + win->maxy)) {
|
|
|
|
__CTRACE(" 0x%x \n",
|
|
|
|
win->lines[i - win->begy]->hash);
|
|
|
|
__CTRACE(" 0x%x ",
|
|
|
|
win->lines[i - win->begy]->flags);
|
|
|
|
for (j = 0; j < win->maxx; j++)
|
|
|
|
__CTRACE("%c", win->lines[i - win
|
|
|
|
->begy]->line[j].ch);
|
|
|
|
__CTRACE("\n");
|
|
|
|
__CTRACE(" attr:");
|
|
|
|
for (j = 0; j < win->maxx; j++)
|
|
|
|
__CTRACE(" %x", win->lines[i - win
|
|
|
|
->begy]->line[j].attr);
|
|
|
|
__CTRACE("\n");
|
2000-04-19 02:47:01 +04:00
|
|
|
__CTRACE(" battr:");
|
|
|
|
for (j = 0; j < win->maxx; j++)
|
|
|
|
__CTRACE(" %x", win->lines[i - win
|
|
|
|
->begy]->line[j].battr);
|
|
|
|
__CTRACE("\n");
|
2000-04-11 17:57:08 +04:00
|
|
|
}
|
1993-11-09 06:34:01 +03:00
|
|
|
}
|
1999-04-13 18:08:17 +04:00
|
|
|
}
|
|
|
|
#endif /* DEBUG */
|
1993-11-09 06:34:01 +03:00
|
|
|
|
|
|
|
for (wy = 0; wy < win->maxy; wy++) {
|
1993-08-07 09:48:37 +04:00
|
|
|
#ifdef DEBUG
|
1999-06-28 17:27:24 +04:00
|
|
|
__CTRACE("wy %d\tf: %d\tl:%d\tflags %x\n",
|
|
|
|
wy, *win->lines[wy]->firstchp, *win->lines[wy]->lastchp,
|
|
|
|
win->lines[wy]->flags);
|
1993-08-07 09:48:37 +04:00
|
|
|
#endif
|
1993-11-09 06:34:01 +03:00
|
|
|
if (!curwin)
|
|
|
|
curscr->lines[wy]->hash = win->lines[wy]->hash;
|
|
|
|
if (win->lines[wy]->flags & (__ISDIRTY | __FORCEPAINT)) {
|
1993-03-21 12:45:37 +03:00
|
|
|
if (makech(win, wy) == ERR)
|
1993-08-07 09:48:37 +04:00
|
|
|
return (ERR);
|
1993-03-21 12:45:37 +03:00
|
|
|
else {
|
1993-11-09 06:34:01 +03:00
|
|
|
if (*win->lines[wy]->firstchp >= win->ch_off)
|
|
|
|
*win->lines[wy]->firstchp = win->maxx +
|
|
|
|
win->ch_off;
|
|
|
|
if (*win->lines[wy]->lastchp < win->maxx +
|
|
|
|
win->ch_off)
|
|
|
|
*win->lines[wy]->lastchp = win->ch_off;
|
1994-08-18 01:51:41 +04:00
|
|
|
if (*win->lines[wy]->lastchp <
|
1993-11-09 06:34:01 +03:00
|
|
|
*win->lines[wy]->firstchp) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
__CTRACE("wrefresh: line %d notdirty \n", wy);
|
|
|
|
#endif
|
|
|
|
win->lines[wy]->flags &= ~__ISDIRTY;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1993-11-09 06:34:01 +03:00
|
|
|
|
|
|
|
}
|
1993-08-07 09:48:37 +04:00
|
|
|
#ifdef DEBUG
|
1994-08-18 01:51:41 +04:00
|
|
|
__CTRACE("\t%d\t%d\n", *win->lines[wy]->firstchp,
|
1999-04-13 18:08:17 +04:00
|
|
|
*win->lines[wy]->lastchp);
|
1993-08-07 09:48:37 +04:00
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1994-08-18 01:51:41 +04:00
|
|
|
|
1993-11-09 06:34:01 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
__CTRACE("refresh: ly=%d, lx=%d\n", ly, lx);
|
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
if (win == curscr)
|
1999-04-13 18:08:17 +04:00
|
|
|
domvcur(ly, lx, (int) win->cury, (int) win->curx);
|
1993-03-21 12:45:37 +03:00
|
|
|
else {
|
1993-11-09 06:34:01 +03:00
|
|
|
if (win->flags & __LEAVEOK) {
|
|
|
|
curscr->cury = ly;
|
|
|
|
curscr->curx = lx;
|
|
|
|
ly -= win->begy;
|
|
|
|
lx -= win->begx;
|
|
|
|
if (ly >= 0 && ly < win->maxy && lx >= 0 &&
|
|
|
|
lx < win->maxx) {
|
|
|
|
win->cury = ly;
|
|
|
|
win->curx = lx;
|
1993-08-07 09:48:37 +04:00
|
|
|
} else
|
1993-11-09 06:34:01 +03:00
|
|
|
win->cury = win->curx = 0;
|
1993-08-07 09:48:37 +04:00
|
|
|
} else {
|
1999-04-13 18:08:17 +04:00
|
|
|
domvcur(ly, lx, (int) (win->cury + win->begy),
|
|
|
|
(int) (win->curx + win->begx));
|
1993-11-09 06:34:01 +03:00
|
|
|
curscr->cury = win->cury + win->begy;
|
|
|
|
curscr->curx = win->curx + win->begx;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
retval = OK;
|
1993-08-07 09:48:37 +04:00
|
|
|
|
1999-04-13 18:08:17 +04:00
|
|
|
(void) fflush(stdout);
|
1993-08-07 09:48:37 +04:00
|
|
|
return (retval);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1993-08-07 09:48:37 +04:00
|
|
|
* makech --
|
|
|
|
* Make a change on the screen.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1993-08-07 09:48:37 +04:00
|
|
|
static int
|
1993-03-21 12:45:37 +03:00
|
|
|
makech(win, wy)
|
1998-02-03 22:12:13 +03:00
|
|
|
WINDOW *win;
|
1999-04-13 18:08:17 +04:00
|
|
|
int wy;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1993-11-09 06:34:01 +03:00
|
|
|
static __LDATA blank = {' ', 0};
|
1994-08-18 01:51:41 +04:00
|
|
|
__LDATA *nsp, *csp, *cp, *cep;
|
1999-04-13 18:08:17 +04:00
|
|
|
u_int force;
|
|
|
|
int clsp, nlsp; /* Last space in lines. */
|
|
|
|
int lch, wx, y;
|
2000-04-19 17:52:39 +04:00
|
|
|
char *ce, cm_buff[1024];
|
2000-04-19 02:47:01 +04:00
|
|
|
attr_t lspb; /* Last space background colour */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-07-22 11:36:20 +04:00
|
|
|
#ifdef __GNUC__
|
|
|
|
nlsp = 0; /* XXX gcc -Wuninitialized */
|
|
|
|
#endif
|
1993-11-09 06:34:01 +03:00
|
|
|
/* Is the cursor still on the end of the last line? */
|
|
|
|
if (wy > 0 && win->lines[wy - 1]->flags & __ISPASTEOL) {
|
|
|
|
domvcur(ly, lx, ly + 1, 0);
|
|
|
|
ly++;
|
|
|
|
lx = 0;
|
|
|
|
}
|
|
|
|
wx = *win->lines[wy]->firstchp - win->ch_off;
|
|
|
|
if (wx < 0)
|
1993-03-21 12:45:37 +03:00
|
|
|
wx = 0;
|
1999-04-13 18:08:17 +04:00
|
|
|
else
|
|
|
|
if (wx >= win->maxx)
|
|
|
|
return (OK);
|
1993-11-09 06:34:01 +03:00
|
|
|
lch = *win->lines[wy]->lastchp - win->ch_off;
|
1993-03-21 12:45:37 +03:00
|
|
|
if (lch < 0)
|
1993-08-07 09:48:37 +04:00
|
|
|
return (OK);
|
1999-04-13 18:08:17 +04:00
|
|
|
else
|
|
|
|
if (lch >= (int) win->maxx)
|
|
|
|
lch = win->maxx - 1;
|
1993-11-09 06:34:01 +03:00
|
|
|
y = wy + win->begy;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
if (curwin)
|
1993-11-09 06:34:01 +03:00
|
|
|
csp = ␣
|
1993-03-21 12:45:37 +03:00
|
|
|
else
|
1993-11-09 06:34:01 +03:00
|
|
|
csp = &curscr->lines[wy + win->begy]->line[wx + win->begx];
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-11-09 06:34:01 +03:00
|
|
|
nsp = &win->lines[wy]->line[wx];
|
|
|
|
force = win->lines[wy]->flags & __FORCEPAINT;
|
|
|
|
win->lines[wy]->flags &= ~__FORCEPAINT;
|
1993-03-21 12:45:37 +03:00
|
|
|
if (CE && !curwin) {
|
2000-04-19 02:47:01 +04:00
|
|
|
cp = &win->lines[wy]->line[win->maxx - 1];
|
|
|
|
if (cp->attr & __COLOR)
|
|
|
|
lspb = cp->attr & __COLOR;
|
|
|
|
else
|
|
|
|
lspb = cp->battr & __COLOR;
|
2000-04-21 19:56:35 +04:00
|
|
|
while (cp->ch == ' ' && cp->bch == ' ' && cp->attr == lspb &&
|
|
|
|
cp->battr == lspb)
|
2000-04-19 02:47:01 +04:00
|
|
|
if (cp-- <= win->lines[wy]->line)
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1993-11-09 06:34:01 +03:00
|
|
|
nlsp = cp - win->lines[wy]->line;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
if (!curwin)
|
1993-08-07 09:48:37 +04:00
|
|
|
ce = CE;
|
1993-03-21 12:45:37 +03:00
|
|
|
else
|
1993-08-07 09:48:37 +04:00
|
|
|
ce = NULL;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-11-09 06:34:01 +03:00
|
|
|
if (force) {
|
2000-04-19 17:52:39 +04:00
|
|
|
if (CM) {
|
|
|
|
t_goto(_cursesi_genbuf, CM, lx, ly, cm_buff, 1023);
|
|
|
|
tputs(cm_buff, 0, __cputchar);
|
|
|
|
} else {
|
1993-11-09 06:34:01 +03:00
|
|
|
tputs(HO, 0, __cputchar);
|
|
|
|
__mvcur(0, 0, ly, lx, 1);
|
|
|
|
}
|
|
|
|
}
|
1994-08-18 01:51:41 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
while (wx <= lch) {
|
1993-11-09 06:34:01 +03:00
|
|
|
if (!force && memcmp(nsp, csp, sizeof(__LDATA)) == 0) {
|
1993-08-07 09:48:37 +04:00
|
|
|
if (wx <= lch) {
|
1993-11-09 06:34:01 +03:00
|
|
|
while (wx <= lch &&
|
1994-08-18 01:51:41 +04:00
|
|
|
memcmp(nsp, csp, sizeof(__LDATA)) == 0) {
|
|
|
|
nsp++;
|
|
|
|
if (!curwin)
|
|
|
|
++csp;
|
|
|
|
++wx;
|
|
|
|
}
|
1993-08-07 09:48:37 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1999-04-13 18:08:17 +04:00
|
|
|
domvcur(ly, lx, y, (int) (wx + win->begx));
|
1993-11-09 06:34:01 +03:00
|
|
|
|
1993-08-07 09:48:37 +04:00
|
|
|
#ifdef DEBUG
|
1994-08-18 01:51:41 +04:00
|
|
|
__CTRACE("makech: 1: wx = %d, ly= %d, lx = %d, newy = %d, newx = %d, force =%d\n",
|
1993-11-09 06:34:01 +03:00
|
|
|
wx, ly, lx, y, wx + win->begx, force);
|
1993-08-07 09:48:37 +04:00
|
|
|
#endif
|
|
|
|
ly = y;
|
1993-11-09 06:34:01 +03:00
|
|
|
lx = wx + win->begx;
|
1994-08-18 01:51:41 +04:00
|
|
|
while ((force || memcmp(nsp, csp, sizeof(__LDATA)) != 0)
|
1993-11-09 06:34:01 +03:00
|
|
|
&& wx <= lch) {
|
|
|
|
|
1994-08-18 01:51:41 +04:00
|
|
|
if (ce != NULL &&
|
|
|
|
win->maxx + win->begx == curscr->maxx &&
|
|
|
|
wx >= nlsp && nsp->ch == ' ' && nsp->attr == 0) {
|
1993-08-07 09:48:37 +04:00
|
|
|
/* Check for clear to end-of-line. */
|
1993-11-09 06:34:01 +03:00
|
|
|
cep = &curscr->lines[wy]->line[win->maxx - 1];
|
2000-04-19 02:47:01 +04:00
|
|
|
while (cep->ch == ' ' && cep->attr == lspb)
|
1993-11-09 06:34:01 +03:00
|
|
|
if (cep-- <= csp)
|
1993-08-07 09:48:37 +04:00
|
|
|
break;
|
1994-08-18 01:51:41 +04:00
|
|
|
clsp = cep - curscr->lines[wy]->line -
|
1999-04-13 18:08:17 +04:00
|
|
|
win->begx * __LDATASIZE;
|
1993-08-07 09:48:37 +04:00
|
|
|
#ifdef DEBUG
|
2000-04-19 02:47:01 +04:00
|
|
|
__CTRACE("makech: clsp = %d, nlsp = %d\n",
|
|
|
|
clsp, nlsp);
|
1993-08-07 09:48:37 +04:00
|
|
|
#endif
|
2000-04-19 02:47:01 +04:00
|
|
|
if (((clsp - nlsp >= strlen(CE) &&
|
|
|
|
clsp < win->maxx * __LDATASIZE) ||
|
|
|
|
wy == win->maxy - 1) &&
|
|
|
|
(!(lspb & __COLOR) ||
|
|
|
|
((lspb & __COLOR) && BE)) &&
|
|
|
|
win->bch == ' ') {
|
2000-04-16 13:55:16 +04:00
|
|
|
unsetattr(0);
|
2000-04-19 02:47:01 +04:00
|
|
|
if ((lspb & __COLOR) !=
|
|
|
|
(curscr->wattr & __COLOR)) {
|
|
|
|
__set_color(lspb);
|
|
|
|
curscr->wattr &= ~__COLOR;
|
|
|
|
curscr->wattr |= lspb & __COLOR;
|
|
|
|
}
|
1993-08-07 09:48:37 +04:00
|
|
|
tputs(CE, 0, __cputchar);
|
1993-11-09 06:34:01 +03:00
|
|
|
lx = wx + win->begx;
|
|
|
|
while (wx++ <= clsp) {
|
|
|
|
csp->ch = ' ';
|
|
|
|
csp->attr = 0;
|
|
|
|
csp++;
|
|
|
|
}
|
1993-08-07 09:48:37 +04:00
|
|
|
return (OK);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1993-08-07 09:48:37 +04:00
|
|
|
ce = NULL;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1993-08-07 09:48:37 +04:00
|
|
|
|
2000-04-13 01:47:20 +04:00
|
|
|
/*
|
|
|
|
* Unset colour if appropriate. Check to see
|
|
|
|
* if we also turn off standout, underscore and
|
|
|
|
* attributes.
|
|
|
|
*/
|
|
|
|
if (!(nsp->attr & __COLOR) &&
|
2000-04-19 02:47:01 +04:00
|
|
|
!(nsp->battr & __COLOR) &&
|
2000-04-13 01:47:20 +04:00
|
|
|
(curscr->wattr & __COLOR)) {
|
|
|
|
if (OC != NULL && CC == NULL)
|
|
|
|
tputs(OC, 0, __cputchar);
|
|
|
|
if (OP != NULL) {
|
|
|
|
tputs(OP, 0, __cputchar);
|
2000-04-19 02:47:01 +04:00
|
|
|
if (SE != NULL &&
|
|
|
|
!strcmp(OP, SE))
|
|
|
|
curscr->wattr &=
|
|
|
|
~__STANDOUT;
|
|
|
|
if (UE != NULL &&
|
|
|
|
!strcmp(OP, UE))
|
|
|
|
curscr->wattr &=
|
|
|
|
~__UNDERSCORE;
|
|
|
|
if (ME != NULL &&
|
|
|
|
!strcmp(OP, ME))
|
|
|
|
curscr->wattr &=
|
|
|
|
~__TERMATTR;
|
2000-04-13 01:47:20 +04:00
|
|
|
}
|
|
|
|
curscr->wattr &= ~__COLOR;
|
|
|
|
}
|
|
|
|
|
1999-04-13 18:08:17 +04:00
|
|
|
/*
|
|
|
|
* Unset attributes as appropriate. Unset first
|
|
|
|
* so that the relevant attributes can be reset
|
2000-04-13 01:47:20 +04:00
|
|
|
* (because 'me' unsets 'mb', 'md', 'mh', 'mk',
|
|
|
|
* 'mp' and 'mr'). Check to see if we also turn off
|
|
|
|
* standout, attributes and colour.
|
1999-04-13 18:08:17 +04:00
|
|
|
*/
|
2000-04-19 02:47:01 +04:00
|
|
|
if (((nsp->attr & __TERMATTR) |
|
|
|
|
(nsp->battr & __TERMATTR)) !=
|
|
|
|
(curscr->wattr & __TERMATTR)) {
|
2000-04-11 17:57:08 +04:00
|
|
|
tputs(ME, 0, __cputchar);
|
2000-04-19 02:47:01 +04:00
|
|
|
curscr->wattr &= ~__TERMATTR;
|
2000-04-11 17:57:08 +04:00
|
|
|
if (SE != NULL && !strcmp(ME, SE))
|
|
|
|
curscr->wattr &= ~__STANDOUT;
|
|
|
|
if (UE != NULL && !strcmp(ME, UE))
|
|
|
|
curscr->wattr &= ~__UNDERSCORE;
|
2000-04-13 01:47:20 +04:00
|
|
|
if (OP != NULL && !strcmp(ME, OP))
|
|
|
|
curscr->wattr &= ~__COLOR;
|
1999-04-13 18:08:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Exit underscore mode if appropriate.
|
2000-04-13 01:47:20 +04:00
|
|
|
* Check to see if we also turn off standout,
|
|
|
|
* attributes and colour.
|
1999-04-13 18:08:17 +04:00
|
|
|
*/
|
|
|
|
if (!(nsp->attr & __UNDERSCORE) &&
|
2000-04-19 02:47:01 +04:00
|
|
|
!(nsp->battr & __UNDERSCORE) &&
|
2000-04-11 17:57:08 +04:00
|
|
|
(curscr->wattr & __UNDERSCORE)) {
|
1999-04-13 18:08:17 +04:00
|
|
|
tputs(UE, 0, __cputchar);
|
2000-04-11 17:57:08 +04:00
|
|
|
curscr->wattr &= ~__UNDERSCORE;
|
|
|
|
if (SE != NULL && !strcmp(UE, SE))
|
|
|
|
curscr->wattr &= ~__STANDOUT;
|
|
|
|
if (ME != NULL && !strcmp(UE, ME))
|
2000-04-19 02:47:01 +04:00
|
|
|
curscr->wattr &= ~__TERMATTR;
|
2000-04-13 01:47:20 +04:00
|
|
|
if (OP != NULL && !strcmp(UE, OP))
|
|
|
|
curscr->wattr &= ~__COLOR;
|
1999-04-13 18:08:17 +04:00
|
|
|
}
|
|
|
|
|
1994-08-18 01:51:41 +04:00
|
|
|
/*
|
|
|
|
* Enter/exit standout mode as appropriate.
|
2000-04-13 01:47:20 +04:00
|
|
|
* Check to see if we also turn off underscore,
|
|
|
|
* attributes and colour.
|
1994-08-18 01:51:41 +04:00
|
|
|
* XXX
|
|
|
|
* Should use UC if SO/SE not available.
|
|
|
|
*/
|
2000-04-19 02:47:01 +04:00
|
|
|
if ((nsp->attr & __STANDOUT) ||
|
|
|
|
(nsp->battr & __STANDOUT)) {
|
2000-04-11 17:57:08 +04:00
|
|
|
if (!(curscr->wattr & __STANDOUT) &&
|
1994-08-18 01:51:41 +04:00
|
|
|
SO != NULL && SE != NULL) {
|
1993-08-07 09:48:37 +04:00
|
|
|
tputs(SO, 0, __cputchar);
|
2000-04-11 17:57:08 +04:00
|
|
|
curscr->wattr |= __STANDOUT;
|
1994-08-18 01:51:41 +04:00
|
|
|
}
|
1999-04-13 18:08:17 +04:00
|
|
|
} else {
|
2000-04-11 17:57:08 +04:00
|
|
|
if (curscr->wattr & __STANDOUT) {
|
1993-08-07 09:48:37 +04:00
|
|
|
tputs(SE, 0, __cputchar);
|
2000-04-11 17:57:08 +04:00
|
|
|
curscr->wattr &= ~__STANDOUT;
|
|
|
|
if (UE != NULL && !strcmp(SE, UE))
|
2000-04-13 01:47:20 +04:00
|
|
|
curscr->wattr &=
|
2000-04-11 17:57:08 +04:00
|
|
|
~__UNDERSCORE;
|
|
|
|
if (ME != NULL && !strcmp(SE, ME))
|
2000-04-19 02:47:01 +04:00
|
|
|
curscr->wattr &= ~__TERMATTR;
|
2000-04-13 01:47:20 +04:00
|
|
|
if (OP != NULL && !strcmp(SE, OP))
|
|
|
|
curscr->wattr &= ~__COLOR;
|
1999-04-13 18:08:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enter underscore mode if appropriate.
|
|
|
|
* XXX
|
|
|
|
* Should use UC if US/UE not available.
|
|
|
|
*/
|
2000-04-19 02:47:01 +04:00
|
|
|
if (((nsp->attr & __UNDERSCORE) ||
|
|
|
|
(nsp->battr & __UNDERSCORE)) &&
|
2000-04-11 17:57:08 +04:00
|
|
|
!(curscr->wattr & __UNDERSCORE) &&
|
1999-04-13 18:08:17 +04:00
|
|
|
US != NULL && UE != NULL) {
|
|
|
|
tputs(US, 0, __cputchar);
|
2000-04-11 17:57:08 +04:00
|
|
|
curscr->wattr |= __UNDERSCORE;
|
1999-04-13 18:08:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set other attributes as appropriate.
|
|
|
|
*/
|
2000-04-19 02:47:01 +04:00
|
|
|
if (((nsp->attr & __BLINK) ||
|
|
|
|
(nsp->battr & __BLINK)) &&
|
|
|
|
!(curscr->wattr & __BLINK) &&
|
|
|
|
MB != NULL && ME != NULL) {
|
|
|
|
tputs(MB, 0, __cputchar);
|
|
|
|
curscr->wattr |= __BLINK;
|
1999-04-13 18:08:17 +04:00
|
|
|
}
|
2000-04-19 02:47:01 +04:00
|
|
|
if (((nsp->attr & __BOLD) ||
|
|
|
|
(nsp->battr & __BOLD)) &&
|
|
|
|
!(curscr->wattr & __BOLD) &&
|
|
|
|
MD != NULL && ME != NULL) {
|
|
|
|
tputs(MD, 0, __cputchar);
|
|
|
|
curscr->wattr |= __BOLD;
|
2000-04-11 17:57:08 +04:00
|
|
|
}
|
2000-04-19 02:47:01 +04:00
|
|
|
if (((nsp->attr & __DIM) ||
|
|
|
|
(nsp->battr & __DIM)) &&
|
|
|
|
!(curscr->wattr & __DIM) &&
|
|
|
|
MH != NULL && ME != NULL) {
|
|
|
|
tputs(MH, 0, __cputchar);
|
|
|
|
curscr->wattr |= __DIM;
|
1999-04-13 18:08:17 +04:00
|
|
|
}
|
2000-04-19 02:47:01 +04:00
|
|
|
if (((nsp->attr & __BLANK) ||
|
|
|
|
(nsp->battr & __BLANK)) &&
|
|
|
|
!(curscr->wattr & __BLANK) &&
|
|
|
|
MK != NULL && ME != NULL) {
|
|
|
|
tputs(MK, 0, __cputchar);
|
|
|
|
curscr->wattr |= __BLANK;
|
1999-04-13 18:08:17 +04:00
|
|
|
}
|
2000-04-19 02:47:01 +04:00
|
|
|
if (((nsp->attr & __PROTECT) ||
|
|
|
|
(nsp->battr & __PROTECT)) &&
|
|
|
|
!(curscr->wattr & __PROTECT) &&
|
|
|
|
MP != NULL && ME != NULL) {
|
|
|
|
tputs(MP, 0, __cputchar);
|
|
|
|
curscr->wattr |= __PROTECT;
|
2000-04-11 17:57:08 +04:00
|
|
|
}
|
2000-04-19 02:47:01 +04:00
|
|
|
if (((nsp->attr & __REVERSE) ||
|
|
|
|
(nsp->battr & __REVERSE)) &&
|
|
|
|
!(curscr->wattr & __REVERSE) &&
|
|
|
|
MR != NULL && ME != NULL) {
|
|
|
|
tputs(MR, 0, __cputchar);
|
|
|
|
curscr->wattr |= __REVERSE;
|
2000-04-11 17:57:08 +04:00
|
|
|
}
|
|
|
|
|
2000-04-13 01:47:20 +04:00
|
|
|
/* Set/change colour as appropriate. */
|
2000-04-19 02:47:01 +04:00
|
|
|
if (((nsp->attr & __COLOR) ||
|
|
|
|
(nsp->battr & __COLOR)) &&
|
|
|
|
cO != NULL && (OC != NULL || OP != NULL)) {
|
|
|
|
if (nsp->attr & __COLOR) {
|
|
|
|
if ((nsp->attr & __COLOR) !=
|
|
|
|
(curscr->wattr & __COLOR)) {
|
|
|
|
__set_color(nsp->attr);
|
|
|
|
curscr->wattr &= ~__COLOR;
|
|
|
|
curscr->wattr |= nsp->attr &
|
|
|
|
__COLOR;
|
|
|
|
}
|
|
|
|
} else if (nsp->battr & __COLOR) {
|
|
|
|
if ((nsp->battr & __COLOR) !=
|
|
|
|
(curscr->wattr & __COLOR)) {
|
|
|
|
__set_color(nsp->battr);
|
|
|
|
curscr->wattr &= ~__COLOR;
|
|
|
|
curscr->wattr |= nsp->battr &
|
|
|
|
__COLOR;
|
|
|
|
}
|
2000-04-13 01:47:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-04-11 17:57:08 +04:00
|
|
|
/* Enter/exit altcharset mode as appropriate. */
|
2000-04-19 02:47:01 +04:00
|
|
|
if ((nsp->attr & __ALTCHARSET) ||
|
|
|
|
(nsp->battr & __ALTCHARSET)) {
|
2000-04-11 17:57:08 +04:00
|
|
|
if (!(curscr->wattr & __ALTCHARSET) &&
|
|
|
|
AS != NULL && AE != NULL) {
|
|
|
|
tputs(AS, 0, __cputchar);
|
|
|
|
curscr->wattr |= __ALTCHARSET;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (curscr->wattr & __ALTCHARSET) {
|
|
|
|
tputs(AE, 0, __cputchar);
|
|
|
|
curscr->wattr &= ~__ALTCHARSET;
|
1999-04-13 18:08:17 +04:00
|
|
|
}
|
|
|
|
}
|
1993-08-07 09:48:37 +04:00
|
|
|
|
|
|
|
wx++;
|
1993-11-09 06:34:01 +03:00
|
|
|
if (wx >= win->maxx && wy == win->maxy - 1 && !curwin)
|
|
|
|
if (win->flags & __SCROLLOK) {
|
2000-04-16 13:55:16 +04:00
|
|
|
if (win->flags & __ENDLINE){
|
|
|
|
unsetattr(1);
|
|
|
|
}
|
1993-11-09 06:34:01 +03:00
|
|
|
if (!(win->flags & __SCROLLWIN)) {
|
|
|
|
if (!curwin) {
|
2000-04-19 02:47:01 +04:00
|
|
|
csp->attr = nsp->attr |
|
|
|
|
(nsp->battr &
|
|
|
|
~__COLOR);
|
|
|
|
if (!(nsp->attr &
|
|
|
|
__COLOR) &&
|
|
|
|
(nsp->battr &
|
|
|
|
__COLOR))
|
|
|
|
csp->attr |=
|
|
|
|
nsp->battr
|
|
|
|
& __COLOR;
|
|
|
|
if (nsp->ch == ' ' &&
|
|
|
|
nsp->bch != ' ')
|
|
|
|
putchar((int)
|
|
|
|
(csp->ch =
|
|
|
|
nsp->bch));
|
|
|
|
else
|
|
|
|
putchar((int)
|
|
|
|
(csp->ch =
|
|
|
|
nsp->ch));
|
1993-11-09 06:34:01 +03:00
|
|
|
} else
|
2000-04-11 17:57:08 +04:00
|
|
|
putchar((int) nsp->ch);
|
1993-08-07 09:48:37 +04:00
|
|
|
}
|
1993-11-09 06:34:01 +03:00
|
|
|
if (wx + win->begx < curscr->maxx) {
|
1999-04-13 18:08:17 +04:00
|
|
|
domvcur(ly, (int) (wx + win->begx),
|
|
|
|
(int) (win->begy + win->maxy - 1),
|
|
|
|
(int) (win->begx + win->maxx - 1));
|
1993-11-09 06:34:01 +03:00
|
|
|
}
|
|
|
|
ly = win->begy + win->maxy - 1;
|
|
|
|
lx = win->begx + win->maxx - 1;
|
|
|
|
return (OK);
|
1994-08-18 01:51:41 +04:00
|
|
|
}
|
|
|
|
if (wx < win->maxx || wy < win->maxy - 1 ||
|
1993-11-09 06:34:01 +03:00
|
|
|
!(win->flags & __SCROLLWIN)) {
|
|
|
|
if (!curwin) {
|
2000-04-19 02:47:01 +04:00
|
|
|
csp->attr = nsp->attr | (nsp->battr &
|
|
|
|
~__COLOR);
|
|
|
|
if (!(nsp->attr & __COLOR) &&
|
|
|
|
(nsp->battr & __COLOR))
|
|
|
|
csp->attr |= nsp->battr &
|
|
|
|
__COLOR;
|
|
|
|
if (nsp->ch == ' ' && nsp->bch != ' ')
|
|
|
|
putchar((int) (csp->ch =
|
|
|
|
nsp->bch));
|
|
|
|
else
|
|
|
|
putchar((int) (csp->ch =
|
|
|
|
nsp->ch));
|
1993-11-09 06:34:01 +03:00
|
|
|
csp++;
|
1994-08-18 01:51:41 +04:00
|
|
|
} else
|
2000-04-11 17:57:08 +04:00
|
|
|
putchar((int) nsp->ch);
|
1993-11-09 06:34:01 +03:00
|
|
|
}
|
1993-08-07 09:48:37 +04:00
|
|
|
#ifdef DEBUG
|
1993-11-09 06:34:01 +03:00
|
|
|
__CTRACE("makech: putchar(%c)\n", nsp->ch & 0177);
|
1993-08-07 09:48:37 +04:00
|
|
|
#endif
|
1999-04-13 18:08:17 +04:00
|
|
|
if (UC && ((nsp->attr & __STANDOUT) ||
|
|
|
|
(nsp->attr & __UNDERSCORE))) {
|
1993-08-07 09:48:37 +04:00
|
|
|
putchar('\b');
|
|
|
|
tputs(UC, 0, __cputchar);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1993-08-07 09:48:37 +04:00
|
|
|
nsp++;
|
|
|
|
#ifdef DEBUG
|
1999-04-13 18:08:17 +04:00
|
|
|
__CTRACE("makech: 2: wx = %d, lx = %d\n", wx, lx);
|
1993-08-07 09:48:37 +04:00
|
|
|
#endif
|
1993-11-09 06:34:01 +03:00
|
|
|
}
|
|
|
|
if (lx == wx + win->begx) /* If no change. */
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1993-11-09 06:34:01 +03:00
|
|
|
lx = wx + win->begx;
|
|
|
|
if (lx >= COLS && AM)
|
|
|
|
lx = COLS - 1;
|
1999-04-13 18:08:17 +04:00
|
|
|
else
|
|
|
|
if (wx >= win->maxx) {
|
|
|
|
domvcur(ly, lx, ly, (int) (win->maxx + win->begx - 1));
|
|
|
|
lx = win->maxx + win->begx - 1;
|
|
|
|
}
|
1993-08-07 09:48:37 +04:00
|
|
|
#ifdef DEBUG
|
1993-11-09 06:34:01 +03:00
|
|
|
__CTRACE("makech: 3: wx = %d, lx = %d\n", wx, lx);
|
1993-08-07 09:48:37 +04:00
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1994-08-18 01:51:41 +04:00
|
|
|
|
2000-04-19 02:47:01 +04:00
|
|
|
/*
|
|
|
|
* Don't leave the screen with attributes set.
|
|
|
|
* XXX Should this be at the end of wrefresh() and not here?
|
|
|
|
*/
|
2000-04-16 13:55:16 +04:00
|
|
|
unsetattr(0);
|
1993-08-07 09:48:37 +04:00
|
|
|
return (OK);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1993-08-07 09:48:37 +04:00
|
|
|
* domvcur --
|
2000-04-16 13:55:16 +04:00
|
|
|
* Do a mvcur, leaving attributes if necessary.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1993-08-07 09:48:37 +04:00
|
|
|
static void
|
1993-03-21 12:45:37 +03:00
|
|
|
domvcur(oy, ox, ny, nx)
|
1999-04-13 18:08:17 +04:00
|
|
|
int oy, ox, ny, nx;
|
1993-08-07 09:48:37 +04:00
|
|
|
{
|
2000-04-16 13:55:16 +04:00
|
|
|
unsetattr(1);
|
1993-11-09 06:34:01 +03:00
|
|
|
__mvcur(oy, ox, ny, nx, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Quickch() attempts to detect a pattern in the change of the window
|
1994-08-18 01:51:41 +04:00
|
|
|
* in order to optimize the change, e.g., scroll n lines as opposed to
|
1993-11-09 06:34:01 +03:00
|
|
|
* repainting the screen line by line.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
quickch(win)
|
|
|
|
WINDOW *win;
|
|
|
|
{
|
|
|
|
#define THRESH (int) win->maxy / 4
|
|
|
|
|
1998-02-03 22:12:13 +03:00
|
|
|
__LINE *clp, *tmp1, *tmp2;
|
1999-04-13 18:08:17 +04:00
|
|
|
int bsize, curs, curw, starts, startw, i, j;
|
|
|
|
int n, target, cur_period, bot, top, sc_region;
|
1993-11-09 06:34:01 +03:00
|
|
|
__LDATA buf[1024];
|
1999-04-13 18:08:17 +04:00
|
|
|
u_int blank_hash;
|
2000-04-21 19:56:35 +04:00
|
|
|
attr_t bcolor;
|
1993-11-09 06:34:01 +03:00
|
|
|
|
1997-07-22 11:36:20 +04:00
|
|
|
#ifdef __GNUC__
|
1999-04-13 18:08:17 +04:00
|
|
|
curs = curw = starts = startw = 0; /* XXX gcc -Wuninitialized */
|
1997-07-22 11:36:20 +04:00
|
|
|
#endif
|
1994-08-18 01:51:41 +04:00
|
|
|
/*
|
1993-11-09 06:34:01 +03:00
|
|
|
* Find how many lines from the top of the screen are unchanged.
|
|
|
|
*/
|
1994-08-18 01:51:41 +04:00
|
|
|
for (top = 0; top < win->maxy; top++)
|
1993-11-09 06:34:01 +03:00
|
|
|
if (win->lines[top]->flags & __FORCEPAINT ||
|
1994-08-18 01:51:41 +04:00
|
|
|
win->lines[top]->hash != curscr->lines[top]->hash
|
|
|
|
|| memcmp(win->lines[top]->line,
|
1999-04-13 18:08:17 +04:00
|
|
|
curscr->lines[top]->line,
|
2000-04-11 17:57:08 +04:00
|
|
|
(size_t) win->maxx * __LDATASIZE) != 0)
|
1993-11-09 06:34:01 +03:00
|
|
|
break;
|
|
|
|
else
|
|
|
|
win->lines[top]->flags &= ~__ISDIRTY;
|
1999-04-13 18:08:17 +04:00
|
|
|
/*
|
|
|
|
* Find how many lines from bottom of screen are unchanged.
|
|
|
|
*/
|
1993-11-09 06:34:01 +03:00
|
|
|
for (bot = win->maxy - 1; bot >= 0; bot--)
|
|
|
|
if (win->lines[bot]->flags & __FORCEPAINT ||
|
1994-08-18 01:51:41 +04:00
|
|
|
win->lines[bot]->hash != curscr->lines[bot]->hash
|
|
|
|
|| memcmp(win->lines[bot]->line,
|
1999-04-13 18:08:17 +04:00
|
|
|
curscr->lines[bot]->line,
|
2000-04-11 17:57:08 +04:00
|
|
|
(size_t) win->maxx * __LDATASIZE) != 0)
|
1993-11-09 06:34:01 +03:00
|
|
|
break;
|
|
|
|
else
|
|
|
|
win->lines[bot]->flags &= ~__ISDIRTY;
|
|
|
|
|
|
|
|
#ifdef NO_JERKINESS
|
|
|
|
/*
|
|
|
|
* If we have a bottom unchanged region return. Scrolling the
|
|
|
|
* bottom region up and then back down causes a screen jitter.
|
|
|
|
* This will increase the number of characters sent to the screen
|
|
|
|
* but it looks better.
|
|
|
|
*/
|
|
|
|
if (bot < win->maxy - 1)
|
|
|
|
return;
|
1999-04-13 18:08:17 +04:00
|
|
|
#endif /* NO_JERKINESS */
|
1993-11-09 06:34:01 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Search for the largest block of text not changed.
|
|
|
|
* Invariants of the loop:
|
|
|
|
* - Startw is the index of the beginning of the examined block in win.
|
1999-04-13 18:08:17 +04:00
|
|
|
* - Starts is the index of the beginning of the examined block in
|
1993-11-09 06:34:01 +03:00
|
|
|
* curscr.
|
|
|
|
* - Curs is the index of one past the end of the exmined block in win.
|
1994-08-18 01:51:41 +04:00
|
|
|
* - Curw is the index of one past the end of the exmined block in
|
1993-11-09 06:34:01 +03:00
|
|
|
* curscr.
|
|
|
|
* - bsize is the current size of the examined block.
|
1999-04-13 18:08:17 +04:00
|
|
|
*/
|
1993-11-09 06:34:01 +03:00
|
|
|
for (bsize = bot - top; bsize >= THRESH; bsize--) {
|
|
|
|
for (startw = top; startw <= bot - bsize; startw++)
|
1994-08-18 01:51:41 +04:00
|
|
|
for (starts = top; starts <= bot - bsize;
|
1999-04-13 18:08:17 +04:00
|
|
|
starts++) {
|
1993-11-09 06:34:01 +03:00
|
|
|
for (curw = startw, curs = starts;
|
1999-04-13 18:08:17 +04:00
|
|
|
curs < starts + bsize; curw++, curs++)
|
1993-11-09 06:34:01 +03:00
|
|
|
if (win->lines[curw]->flags &
|
|
|
|
__FORCEPAINT ||
|
|
|
|
(win->lines[curw]->hash !=
|
1999-04-13 18:08:17 +04:00
|
|
|
curscr->lines[curs]->hash ||
|
|
|
|
memcmp(win->lines[curw]->line,
|
|
|
|
curscr->lines[curs]->line,
|
2000-04-11 17:57:08 +04:00
|
|
|
(size_t) win->maxx * __LDATASIZE) != 0))
|
1993-11-09 06:34:01 +03:00
|
|
|
break;
|
|
|
|
if (curs == starts + bsize)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
1999-04-13 18:08:17 +04:00
|
|
|
done:
|
2000-04-21 19:56:35 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Work round an xterm bug where scrolling the screen and then
|
|
|
|
* setting a background colour causes subsequent lines in the
|
|
|
|
* scrolled region to have the incorrect background colour.
|
|
|
|
* XXX this may fail if the colour changes along the lines.
|
|
|
|
*/
|
|
|
|
if (win->lines[startw]->line[0].attr & __COLOR)
|
|
|
|
bcolor = win->lines[startw]->line[0].attr & __COLOR;
|
|
|
|
else
|
|
|
|
bcolor = win->lines[startw]->line[0].battr & __COLOR;
|
|
|
|
for (i = top, j = 0; i < (top + bsize); i++)
|
|
|
|
if (win->lines[i]->line[win->maxx].attr & __COLOR) {
|
|
|
|
if ((win->lines[i]->line[win->maxx].attr &
|
|
|
|
__COLOR) != bcolor)
|
|
|
|
j = i;
|
|
|
|
} else
|
|
|
|
if ((win->lines[i]->line[win->maxx].battr &
|
|
|
|
__COLOR) != bcolor)
|
|
|
|
j = i;
|
|
|
|
top += j;
|
|
|
|
starts += j;
|
|
|
|
startw += j;
|
|
|
|
bsize -= j;
|
|
|
|
|
1993-11-09 06:34:01 +03:00
|
|
|
/* Did not find anything */
|
1994-08-18 01:51:41 +04:00
|
|
|
if (bsize < THRESH)
|
1993-11-09 06:34:01 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1994-08-18 01:51:41 +04:00
|
|
|
__CTRACE("quickch:bsize=%d,starts=%d,startw=%d,curw=%d,curs=%d,top=%d,bot=%d\n",
|
1999-04-13 18:08:17 +04:00
|
|
|
bsize, starts, startw, curw, curs, top, bot);
|
1993-11-09 06:34:01 +03:00
|
|
|
#endif
|
|
|
|
|
1994-08-18 01:51:41 +04:00
|
|
|
/*
|
|
|
|
* Make sure that there is no overlap between the bottom and top
|
1993-11-09 06:34:01 +03:00
|
|
|
* regions and the middle scrolled block.
|
|
|
|
*/
|
|
|
|
if (bot < curs)
|
|
|
|
bot = curs - 1;
|
|
|
|
if (top > starts)
|
|
|
|
top = starts;
|
|
|
|
|
|
|
|
n = startw - starts;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1999-04-13 18:08:17 +04:00
|
|
|
__CTRACE("#####################################\n");
|
|
|
|
for (i = 0; i < curscr->maxy; i++) {
|
|
|
|
__CTRACE("C: %d:", i);
|
|
|
|
__CTRACE(" 0x%x \n", curscr->lines[i]->hash);
|
|
|
|
for (j = 0; j < curscr->maxx; j++)
|
|
|
|
__CTRACE("%c", curscr->lines[i]->line[j].ch);
|
|
|
|
__CTRACE("\n");
|
1999-09-17 18:21:04 +04:00
|
|
|
__CTRACE(" attr:");
|
1999-04-13 18:08:17 +04:00
|
|
|
for (j = 0; j < curscr->maxx; j++)
|
1999-09-17 18:21:04 +04:00
|
|
|
__CTRACE(" %x", curscr->lines[i]->line[j].attr);
|
1999-04-13 18:08:17 +04:00
|
|
|
__CTRACE("\n");
|
|
|
|
__CTRACE("W: %d:", i);
|
|
|
|
__CTRACE(" 0x%x \n", win->lines[i]->hash);
|
|
|
|
__CTRACE(" 0x%x ", win->lines[i]->flags);
|
|
|
|
for (j = 0; j < win->maxx; j++)
|
|
|
|
__CTRACE("%c", win->lines[i]->line[j].ch);
|
|
|
|
__CTRACE("\n");
|
1999-09-17 18:21:04 +04:00
|
|
|
__CTRACE(" attr:");
|
1999-04-13 18:08:17 +04:00
|
|
|
for (j = 0; j < win->maxx; j++)
|
1999-09-17 18:21:04 +04:00
|
|
|
__CTRACE(" %x", win->lines[i]->line[j].attr);
|
1999-04-13 18:08:17 +04:00
|
|
|
__CTRACE("\n");
|
|
|
|
}
|
1994-08-18 01:51:41 +04:00
|
|
|
#endif
|
|
|
|
|
1993-11-09 06:34:01 +03:00
|
|
|
/* So we don't have to call __hash() each time */
|
|
|
|
for (i = 0; i < win->maxx; i++) {
|
|
|
|
buf[i].ch = ' ';
|
2000-04-19 02:47:01 +04:00
|
|
|
buf[i].bch = ' ';
|
1993-11-09 06:34:01 +03:00
|
|
|
buf[i].attr = 0;
|
2000-04-19 02:47:01 +04:00
|
|
|
buf[i].battr = 0;
|
1993-11-09 06:34:01 +03:00
|
|
|
}
|
1999-06-23 07:27:34 +04:00
|
|
|
blank_hash = __hash((char *)(void *)buf,
|
|
|
|
(int) (win->maxx * __LDATASIZE));
|
1993-11-09 06:34:01 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform the rotation to maintain the consistency of curscr.
|
|
|
|
* This is hairy since we are doing an *in place* rotation.
|
|
|
|
* Invariants of the loop:
|
|
|
|
* - I is the index of the current line.
|
|
|
|
* - Target is the index of the target of line i.
|
|
|
|
* - Tmp1 points to current line (i).
|
|
|
|
* - Tmp2 and points to target line (target);
|
1994-08-18 01:51:41 +04:00
|
|
|
* - Cur_period is the index of the end of the current period.
|
1993-11-09 06:34:01 +03:00
|
|
|
* (see below).
|
|
|
|
*
|
|
|
|
* There are 2 major issues here that make this rotation non-trivial:
|
|
|
|
* 1. Scrolling in a scrolling region bounded by the top
|
|
|
|
* and bottom regions determined (whose size is sc_region).
|
1994-08-18 01:51:41 +04:00
|
|
|
* 2. As a result of the use of the mod function, there may be a
|
1993-11-09 06:34:01 +03:00
|
|
|
* period introduced, i.e., 2 maps to 4, 4 to 6, n-2 to 0, and
|
|
|
|
* 0 to 2, which then causes all odd lines not to be rotated.
|
1994-08-18 01:51:41 +04:00
|
|
|
* To remedy this, an index of the end ( = beginning) of the
|
|
|
|
* current 'period' is kept, cur_period, and when it is reached,
|
|
|
|
* the next period is started from cur_period + 1 which is
|
1993-11-09 06:34:01 +03:00
|
|
|
* guaranteed not to have been reached since that would mean that
|
|
|
|
* all records would have been reached. (think about it...).
|
1994-08-18 01:51:41 +04:00
|
|
|
*
|
1993-11-09 06:34:01 +03:00
|
|
|
* Lines in the rotation can have 3 attributes which are marked on the
|
|
|
|
* line so that curscr is consistent with the visual screen.
|
|
|
|
* 1. Not dirty -- lines inside the scrolled block, top region or
|
|
|
|
* bottom region.
|
1994-08-18 01:51:41 +04:00
|
|
|
* 2. Blank lines -- lines in the differential of the scrolling
|
|
|
|
* region adjacent to top and bot regions
|
1993-11-09 06:34:01 +03:00
|
|
|
* depending on scrolling direction.
|
|
|
|
* 3. Dirty line -- all other lines are marked dirty.
|
|
|
|
*/
|
|
|
|
sc_region = bot - top + 1;
|
|
|
|
i = top;
|
|
|
|
tmp1 = curscr->lines[top];
|
|
|
|
cur_period = top;
|
|
|
|
for (j = top; j <= bot; j++) {
|
|
|
|
target = (i - top + n + sc_region) % sc_region + top;
|
|
|
|
tmp2 = curscr->lines[target];
|
|
|
|
curscr->lines[target] = tmp1;
|
|
|
|
/* Mark block as clean and blank out scrolled lines. */
|
|
|
|
clp = curscr->lines[target];
|
|
|
|
#ifdef DEBUG
|
|
|
|
__CTRACE("quickch: n=%d startw=%d curw=%d i = %d target=%d ",
|
1999-04-13 18:08:17 +04:00
|
|
|
n, startw, curw, i, target);
|
1993-11-09 06:34:01 +03:00
|
|
|
#endif
|
1994-08-18 01:51:41 +04:00
|
|
|
if ((target >= startw && target < curw) || target < top
|
1993-11-09 06:34:01 +03:00
|
|
|
|| target > bot) {
|
|
|
|
#ifdef DEBUG
|
2000-04-21 19:56:35 +04:00
|
|
|
__CTRACE("-- notdirty\n");
|
1993-11-09 06:34:01 +03:00
|
|
|
#endif
|
|
|
|
win->lines[target]->flags &= ~__ISDIRTY;
|
1999-04-13 18:08:17 +04:00
|
|
|
} else
|
|
|
|
if ((n > 0 && target >= top && target < top + n) ||
|
|
|
|
(n < 0 && target <= bot && target > bot + n)) {
|
|
|
|
if (clp->hash != blank_hash || memcmp(clp->line,
|
2000-04-11 17:57:08 +04:00
|
|
|
buf, (size_t) win->maxx * __LDATASIZE) !=0) {
|
1999-04-13 18:08:17 +04:00
|
|
|
(void)memcpy(clp->line, buf,
|
2000-04-11 17:57:08 +04:00
|
|
|
(size_t) win->maxx * __LDATASIZE);
|
1993-11-09 06:34:01 +03:00
|
|
|
#ifdef DEBUG
|
2000-04-21 19:56:35 +04:00
|
|
|
__CTRACE("-- blanked out: dirty\n");
|
1993-11-09 06:34:01 +03:00
|
|
|
#endif
|
1999-04-13 18:08:17 +04:00
|
|
|
clp->hash = blank_hash;
|
|
|
|
__touchline(win, target, 0, (int) win->maxx - 1, 0);
|
|
|
|
} else {
|
1993-11-09 06:34:01 +03:00
|
|
|
#ifdef DEBUG
|
2000-04-21 19:56:35 +04:00
|
|
|
__CTRACE(" -- blank line already: dirty\n");
|
1993-11-09 06:34:01 +03:00
|
|
|
#endif
|
2000-04-21 19:56:35 +04:00
|
|
|
__touchline(win, target, 0, (int) win->maxx - 1, 0);
|
1999-04-13 18:08:17 +04:00
|
|
|
}
|
|
|
|
} else {
|
1993-11-09 06:34:01 +03:00
|
|
|
#ifdef DEBUG
|
2000-04-21 19:56:35 +04:00
|
|
|
__CTRACE(" -- dirty\n");
|
1993-11-09 06:34:01 +03:00
|
|
|
#endif
|
1999-04-13 18:08:17 +04:00
|
|
|
__touchline(win, target, 0, (int) win->maxx - 1, 0);
|
|
|
|
}
|
1993-11-09 06:34:01 +03:00
|
|
|
if (target == cur_period) {
|
|
|
|
i = target + 1;
|
|
|
|
tmp1 = curscr->lines[i];
|
|
|
|
cur_period = i;
|
|
|
|
} else {
|
|
|
|
tmp1 = tmp2;
|
|
|
|
i = target;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
1999-04-13 18:08:17 +04:00
|
|
|
__CTRACE("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");
|
|
|
|
for (i = 0; i < curscr->maxy; i++) {
|
|
|
|
__CTRACE("C: %d:", i);
|
|
|
|
for (j = 0; j < curscr->maxx; j++)
|
|
|
|
__CTRACE("%c", curscr->lines[i]->line[j].ch);
|
|
|
|
__CTRACE("\n");
|
|
|
|
__CTRACE("W: %d:", i);
|
|
|
|
for (j = 0; j < win->maxx; j++)
|
|
|
|
__CTRACE("%c", win->lines[i]->line[j].ch);
|
|
|
|
__CTRACE("\n");
|
|
|
|
}
|
1993-11-09 06:34:01 +03:00
|
|
|
#endif
|
|
|
|
if (n != 0) {
|
|
|
|
WINDOW *wp;
|
|
|
|
scrolln(win, starts, startw, curs, bot, top);
|
|
|
|
/*
|
|
|
|
* Need to repoint any subwindow lines to the rotated
|
1994-08-18 01:51:41 +04:00
|
|
|
* line structured.
|
1993-11-09 06:34:01 +03:00
|
|
|
*/
|
|
|
|
for (wp = win->nextp; wp != win; wp = wp->nextp)
|
|
|
|
__set_subwin(win, wp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1994-08-18 01:51:41 +04:00
|
|
|
* scrolln --
|
|
|
|
* Scroll n lines, where n is starts - startw.
|
1993-11-09 06:34:01 +03:00
|
|
|
*/
|
1999-04-13 18:08:17 +04:00
|
|
|
static void /* ARGSUSED */
|
1993-11-09 06:34:01 +03:00
|
|
|
scrolln(win, starts, startw, curs, bot, top)
|
|
|
|
WINDOW *win;
|
1999-04-13 18:08:17 +04:00
|
|
|
int starts, startw, curs, bot, top;
|
1993-11-09 06:34:01 +03:00
|
|
|
{
|
1999-04-13 18:08:17 +04:00
|
|
|
int i, oy, ox, n;
|
1993-11-09 06:34:01 +03:00
|
|
|
|
|
|
|
oy = curscr->cury;
|
|
|
|
ox = curscr->curx;
|
|
|
|
n = starts - startw;
|
|
|
|
|
1994-08-18 01:51:41 +04:00
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* The initial tests that set __noqch don't let us reach here unless
|
|
|
|
* we have either CS + HO + SF/sf/SR/sr, or AL + DL. SF/sf and SR/sr
|
|
|
|
* scrolling can only shift the entire scrolling region, not just a
|
|
|
|
* part of it, which means that the quickch() routine is going to be
|
|
|
|
* sadly disappointed in us if we don't have CS as well.
|
|
|
|
*
|
|
|
|
* If CS, HO and SF/sf are set, can use the scrolling region. Because
|
|
|
|
* the cursor position after CS is undefined, we need HO which gives us
|
|
|
|
* the ability to move to somewhere without knowledge of the current
|
|
|
|
* location of the cursor. Still call __mvcur() anyway, to update its
|
|
|
|
* idea of where the cursor is.
|
|
|
|
*
|
|
|
|
* When the scrolling region has been set, the cursor has to be at the
|
|
|
|
* last line of the region to make the scroll happen.
|
|
|
|
*
|
|
|
|
* Doing SF/SR or AL/DL appears faster on the screen than either sf/sr
|
|
|
|
* or al/dl, and, some terminals have AL/DL, sf/sr, and CS, but not
|
|
|
|
* SF/SR. So, if we're scrolling almost all of the screen, try and use
|
|
|
|
* AL/DL, otherwise use the scrolling region. The "almost all" is a
|
|
|
|
* shameless hack for vi.
|
|
|
|
*/
|
1993-11-09 06:34:01 +03:00
|
|
|
if (n > 0) {
|
1994-08-18 01:51:41 +04:00
|
|
|
if (CS != NULL && HO != NULL && (SF != NULL ||
|
1997-07-22 11:36:20 +04:00
|
|
|
((AL == NULL || DL == NULL ||
|
|
|
|
top > 3 || bot + 3 < win->maxy) && sf != NULL))) {
|
1994-08-18 01:51:41 +04:00
|
|
|
tputs(__tscroll(CS, top, bot + 1), 0, __cputchar);
|
|
|
|
__mvcur(oy, ox, 0, 0, 1);
|
|
|
|
tputs(HO, 0, __cputchar);
|
|
|
|
__mvcur(0, 0, bot, 0, 1);
|
|
|
|
if (SF != NULL)
|
|
|
|
tputs(__tscroll(SF, n, 0), 0, __cputchar);
|
|
|
|
else
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
tputs(sf, 0, __cputchar);
|
1999-04-13 18:08:17 +04:00
|
|
|
tputs(__tscroll(CS, 0, (int) win->maxy), 0, __cputchar);
|
1994-08-18 01:51:41 +04:00
|
|
|
__mvcur(bot, 0, 0, 0, 1);
|
|
|
|
tputs(HO, 0, __cputchar);
|
|
|
|
__mvcur(0, 0, oy, ox, 1);
|
|
|
|
return;
|
|
|
|
}
|
1993-11-09 06:34:01 +03:00
|
|
|
|
1994-08-18 01:51:41 +04:00
|
|
|
/* Scroll up the block. */
|
|
|
|
if (SF != NULL && top == 0) {
|
|
|
|
__mvcur(oy, ox, bot, 0, 1);
|
|
|
|
tputs(__tscroll(SF, n, 0), 0, __cputchar);
|
|
|
|
} else
|
1999-04-13 18:08:17 +04:00
|
|
|
if (DL != NULL) {
|
|
|
|
__mvcur(oy, ox, top, 0, 1);
|
|
|
|
tputs(__tscroll(DL, n, 0), 0, __cputchar);
|
|
|
|
} else
|
|
|
|
if (dl != NULL) {
|
|
|
|
__mvcur(oy, ox, top, 0, 1);
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
tputs(dl, 0, __cputchar);
|
|
|
|
} else
|
|
|
|
if (sf != NULL && top == 0) {
|
|
|
|
__mvcur(oy, ox, bot, 0, 1);
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
tputs(sf, 0, __cputchar);
|
|
|
|
} else
|
|
|
|
abort();
|
1994-08-18 01:51:41 +04:00
|
|
|
|
|
|
|
/* Push down the bottom region. */
|
1993-11-09 06:34:01 +03:00
|
|
|
__mvcur(top, 0, bot - n + 1, 0, 1);
|
1994-08-18 01:51:41 +04:00
|
|
|
if (AL != NULL)
|
|
|
|
tputs(__tscroll(AL, n, 0), 0, __cputchar);
|
|
|
|
else
|
1999-04-13 18:08:17 +04:00
|
|
|
if (al != NULL)
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
tputs(al, 0, __cputchar);
|
|
|
|
else
|
|
|
|
abort();
|
1993-11-09 06:34:01 +03:00
|
|
|
__mvcur(bot - n + 1, 0, oy, ox, 1);
|
|
|
|
} else {
|
1994-08-18 01:51:41 +04:00
|
|
|
/*
|
|
|
|
* !!!
|
|
|
|
* n < 0
|
|
|
|
*
|
|
|
|
* If CS, HO and SR/sr are set, can use the scrolling region.
|
|
|
|
* See the above comments for details.
|
|
|
|
*/
|
|
|
|
if (CS != NULL && HO != NULL && (SR != NULL ||
|
1997-07-22 11:36:20 +04:00
|
|
|
((AL == NULL || DL == NULL ||
|
|
|
|
top > 3 || bot + 3 < win->maxy) && sr != NULL))) {
|
1994-08-18 01:51:41 +04:00
|
|
|
tputs(__tscroll(CS, top, bot + 1), 0, __cputchar);
|
|
|
|
__mvcur(oy, ox, 0, 0, 1);
|
|
|
|
tputs(HO, 0, __cputchar);
|
|
|
|
__mvcur(0, 0, top, 0, 1);
|
|
|
|
|
|
|
|
if (SR != NULL)
|
|
|
|
tputs(__tscroll(SR, -n, 0), 0, __cputchar);
|
|
|
|
else
|
|
|
|
for (i = n; i < 0; i++)
|
|
|
|
tputs(sr, 0, __cputchar);
|
1999-04-13 18:08:17 +04:00
|
|
|
tputs(__tscroll(CS, 0, (int) win->maxy), 0, __cputchar);
|
1994-08-18 01:51:41 +04:00
|
|
|
__mvcur(top, 0, 0, 0, 1);
|
|
|
|
tputs(HO, 0, __cputchar);
|
|
|
|
__mvcur(0, 0, oy, ox, 1);
|
|
|
|
return;
|
|
|
|
}
|
1993-11-09 06:34:01 +03:00
|
|
|
|
1994-08-18 01:51:41 +04:00
|
|
|
/* Preserve the bottom lines. */
|
|
|
|
__mvcur(oy, ox, bot + n + 1, 0, 1);
|
|
|
|
if (SR != NULL && bot == win->maxy)
|
|
|
|
tputs(__tscroll(SR, -n, 0), 0, __cputchar);
|
1993-11-09 06:34:01 +03:00
|
|
|
else
|
1999-04-13 18:08:17 +04:00
|
|
|
if (DL != NULL)
|
|
|
|
tputs(__tscroll(DL, -n, 0), 0, __cputchar);
|
|
|
|
else
|
|
|
|
if (dl != NULL)
|
|
|
|
for (i = n; i < 0; i++)
|
|
|
|
tputs(dl, 0, __cputchar);
|
|
|
|
else
|
|
|
|
if (sr != NULL && bot == win->maxy)
|
|
|
|
for (i = n; i < 0; i++)
|
|
|
|
tputs(sr, 0, __cputchar);
|
|
|
|
else
|
|
|
|
abort();
|
1994-08-18 01:51:41 +04:00
|
|
|
|
|
|
|
/* Scroll the block down. */
|
|
|
|
__mvcur(bot + n + 1, 0, top, 0, 1);
|
|
|
|
if (AL != NULL)
|
|
|
|
tputs(__tscroll(AL, -n, 0), 0, __cputchar);
|
|
|
|
else
|
1999-04-13 18:08:17 +04:00
|
|
|
if (al != NULL)
|
|
|
|
for (i = n; i < 0; i++)
|
|
|
|
tputs(al, 0, __cputchar);
|
|
|
|
else
|
|
|
|
abort();
|
1993-11-09 06:34:01 +03:00
|
|
|
__mvcur(top, 0, oy, ox, 1);
|
1994-08-18 01:51:41 +04:00
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
2000-04-16 13:55:16 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* unsetattr --
|
|
|
|
* Unset attributes on curscr. Leave standout, attribute and colour
|
|
|
|
* modes if necessary (!MS). Always leave altcharset (xterm at least
|
|
|
|
* ignores a cursor move if we don't).
|
|
|
|
*/
|
|
|
|
static void /* ARGSUSED */
|
|
|
|
unsetattr(int checkms)
|
|
|
|
{
|
|
|
|
int isms;
|
|
|
|
|
|
|
|
if (checkms)
|
|
|
|
if (!MS) {
|
|
|
|
isms = 1;
|
|
|
|
} else {
|
|
|
|
isms = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
isms = 1;
|
2000-04-19 02:47:01 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
__CTRACE("unsetattr: checkms = %d, MS = %s, wattr = %08x\n",
|
|
|
|
checkms, MS ? "TRUE" : "FALSE", curscr->wattr);
|
|
|
|
#endif
|
2000-04-16 13:55:16 +04:00
|
|
|
|
2000-04-19 02:47:01 +04:00
|
|
|
/*
|
|
|
|
* Don't leave the screen in standout mode (check against MS). Check
|
|
|
|
* to see if we also turn off underscore, attributes and colour.
|
|
|
|
*/
|
2000-04-16 13:55:16 +04:00
|
|
|
if (curscr->wattr & __STANDOUT && isms) {
|
|
|
|
tputs(SE, 0, __cputchar);
|
|
|
|
curscr->wattr &= ~__STANDOUT;
|
|
|
|
if (UE != NULL && !strcmp(SE, UE))
|
|
|
|
curscr->wattr &= ~__UNDERSCORE;
|
|
|
|
if (ME != NULL && !strcmp(SE, ME))
|
2000-04-19 02:47:01 +04:00
|
|
|
curscr->wattr &= ~__TERMATTR;
|
2000-04-16 13:55:16 +04:00
|
|
|
if (OP != NULL && !strcmp(SE, OP))
|
|
|
|
curscr->wattr &= ~__COLOR;
|
|
|
|
}
|
2000-04-19 02:47:01 +04:00
|
|
|
/*
|
|
|
|
* Don't leave the screen in underscore mode (check against MS).
|
|
|
|
* Check to see if we also turn off attributes and colour.
|
|
|
|
*/
|
2000-04-16 13:55:16 +04:00
|
|
|
if (curscr->wattr & __UNDERSCORE && isms) {
|
|
|
|
tputs(UE, 0, __cputchar);
|
|
|
|
curscr->wattr &= ~__UNDERSCORE;
|
|
|
|
if (ME != NULL && !strcmp(UE, ME))
|
2000-04-19 02:47:01 +04:00
|
|
|
curscr->wattr &= ~__TERMATTR;
|
2000-04-16 13:55:16 +04:00
|
|
|
if (OP != NULL && !strcmp(UE, OP))
|
|
|
|
curscr->wattr &= ~__COLOR;
|
|
|
|
}
|
2000-04-19 02:47:01 +04:00
|
|
|
/*
|
|
|
|
* Don't leave the screen with attributes set (check against MS).
|
|
|
|
* Check to see if we also turn off colour.
|
|
|
|
*/
|
|
|
|
if (curscr->wattr & __TERMATTR && isms) {
|
2000-04-16 13:55:16 +04:00
|
|
|
tputs(ME, 0, __cputchar);
|
2000-04-19 02:47:01 +04:00
|
|
|
curscr->wattr &= ~__TERMATTR;
|
2000-04-16 13:55:16 +04:00
|
|
|
if (OP != NULL && !strcmp(ME, OP))
|
|
|
|
curscr->wattr &= ~__COLOR;
|
|
|
|
}
|
2000-04-19 02:47:01 +04:00
|
|
|
/* Don't leave the screen with altcharset set (don't check MS). */
|
2000-04-16 13:55:16 +04:00
|
|
|
if (curscr->wattr & __ALTCHARSET) {
|
|
|
|
tputs(AE, 0, __cputchar);
|
|
|
|
curscr->wattr &= ~__ALTCHARSET;
|
|
|
|
}
|
|
|
|
/* Don't leave the screen with colour set (check against MS). */
|
|
|
|
if (curscr->wattr & __COLOR && isms) {
|
|
|
|
if (OC != NULL && CC == NULL)
|
|
|
|
tputs(OC, 0, __cputchar);
|
|
|
|
if (OP != NULL)
|
|
|
|
tputs(OP, 0, __cputchar);
|
|
|
|
curscr->wattr &= ~__COLOR;
|
|
|
|
}
|
|
|
|
}
|