2002-12-23 15:17:55 +03:00
|
|
|
/* $NetBSD: refresh.c,v 1.50 2002/12/23 12:17:55 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
|
2002-12-23 15:17:55 +03:00
|
|
|
__RCSID("$NetBSD: refresh.c,v 1.50 2002/12/23 12:17:55 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
|
|
|
|
2000-07-03 07:56:20 +04:00
|
|
|
#include <stdlib.h>
|
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
|
|
|
|
1993-08-07 09:48:37 +04:00
|
|
|
static void domvcur __P((int, int, int, int));
|
2000-04-27 04:26:19 +04:00
|
|
|
static int makech __P((int));
|
|
|
|
static void quickch __P((void));
|
|
|
|
static void scrolln __P((int, int, int, int, 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
|
|
|
|
|
2000-04-27 04:26:19 +04:00
|
|
|
/*
|
|
|
|
* wnoutrefresh --
|
|
|
|
* Add the contents of "win" to the virtual window.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
wnoutrefresh(WINDOW *win)
|
|
|
|
{
|
2002-12-23 15:17:55 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
__CTRACE("wnoutrefresh: win %0.2o\n", win);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return _cursesi_wnoutrefresh(_cursesi_screen, win, 0, 0, win->begy,
|
|
|
|
win->begx, win->maxy, win->maxx);
|
2001-12-31 17:23:11 +03:00
|
|
|
}
|
|
|
|
|
2002-12-23 15:17:55 +03:00
|
|
|
/*
|
|
|
|
* pnoutrefresh --
|
|
|
|
* Add the contents of "pad" to the virtual window.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
pnoutrefresh(WINDOW *pad, int pbegy, int pbegx, int sbegy, int sbegx,
|
|
|
|
int smaxy, int smaxx)
|
|
|
|
{
|
|
|
|
int pmaxy, pmaxx;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
__CTRACE("pnoutrefresh: pad %0.2o, flags 0x%08x\n", pad, pad->flags);
|
|
|
|
__CTRACE("pnoutrefresh: (%d, %d), (%d, %d), (%d, %d)\n", pbegy, pbegx,
|
|
|
|
sbegy, sbegx, smaxy, smaxx);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* SUS says if these are negative, they should be treated as zero */
|
|
|
|
if (pbegy < 0)
|
|
|
|
pbegy = 0;
|
|
|
|
if (pbegx < 0)
|
|
|
|
pbegx = 0;
|
|
|
|
if (sbegy < 0)
|
|
|
|
sbegy = 0;
|
|
|
|
if (sbegx < 0)
|
|
|
|
sbegx = 0;
|
|
|
|
|
|
|
|
/* Calculate rectangle on pad - used bu _cursesi_wnoutrefresh */
|
|
|
|
pmaxy = pbegy + smaxy - sbegy + 1;
|
|
|
|
pmaxx = pbegx + smaxx - sbegx + 1;
|
|
|
|
|
|
|
|
/* Check rectangle fits in pad */
|
|
|
|
if (pmaxy > pad->maxy - pad->begy)
|
|
|
|
pmaxy = pad->maxy - pad->begy;
|
|
|
|
if (pmaxx > pad->maxx - pad->begx)
|
|
|
|
pmaxx = pad->maxx - pad->begx;
|
|
|
|
|
|
|
|
if (smaxy - sbegy < 0 || smaxx - sbegx < 0 )
|
|
|
|
return ERR;
|
|
|
|
|
|
|
|
return _cursesi_wnoutrefresh(_cursesi_screen, pad,
|
|
|
|
pad->begy + pbegy, pad->begx + pbegx, pad->begy + sbegy,
|
|
|
|
pad->begx + sbegx, pmaxy, pmaxx);
|
|
|
|
}
|
2001-12-31 17:23:11 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* _cursesi_wnoutrefresh --
|
|
|
|
* Does the grunt work for wnoutrefresh to the given screen.
|
2002-12-23 15:17:55 +03:00
|
|
|
* Copies the part of the window given by the rectangle
|
|
|
|
* (begy, begx) to (maxy, maxx) at screen position (wbegy, wbegx).
|
2001-12-31 17:23:11 +03:00
|
|
|
*/
|
|
|
|
int
|
2002-12-23 15:17:55 +03:00
|
|
|
_cursesi_wnoutrefresh(SCREEN *screen, WINDOW *win, int begy, int begx,
|
|
|
|
int wbegy, int wbegx, int maxy, int maxx)
|
2001-12-31 17:23:11 +03:00
|
|
|
{
|
2002-01-02 13:38:27 +03:00
|
|
|
|
2002-12-23 15:17:55 +03:00
|
|
|
short wy, wx, y_off, x_off;
|
2000-05-19 11:39:02 +04:00
|
|
|
__LINE *wlp, *vlp;
|
2000-04-27 04:26:19 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
__CTRACE("wnoutrefresh: win %0.2o, flags 0x%08x\n", win, win->flags);
|
2002-12-23 15:17:55 +03:00
|
|
|
__CTRACE("wnoutrefresh: (%d, %d), (%d, %d), (%d, %d)\n", begy, begx,
|
|
|
|
wbegy, wbegx, maxy, maxx);
|
2000-04-27 04:26:19 +04:00
|
|
|
#endif
|
|
|
|
|
2001-12-31 17:23:11 +03:00
|
|
|
if (screen->curwin)
|
2000-04-27 04:26:19 +04:00
|
|
|
return(OK);
|
2002-12-23 15:17:55 +03:00
|
|
|
|
|
|
|
/* Check that cursor position on "win" is valid for "__virtscr" */
|
|
|
|
if (win->cury + wbegy - begy < screen->__virtscr->maxy &&
|
|
|
|
win->cury + wbegy - begy >= 0 && win->cury < maxy - begy)
|
|
|
|
screen->__virtscr->cury = win->cury + wbegy - begy;
|
|
|
|
if (win->curx + wbegx - begx < screen->__virtscr->maxx &&
|
|
|
|
win->curx + wbegx - begx >= 0 && win->curx < maxx - begx)
|
|
|
|
screen->__virtscr->curx = win->curx + wbegx - begx;
|
2000-04-27 04:26:19 +04:00
|
|
|
|
|
|
|
/* Copy the window flags from "win" to "__virtscr" */
|
2000-05-19 11:39:02 +04:00
|
|
|
if (win->flags & __CLEAROK) {
|
2002-12-23 15:17:55 +03:00
|
|
|
if (win->flags & __FULLWIN) {
|
2001-12-31 17:23:11 +03:00
|
|
|
screen->__virtscr->flags |= __CLEAROK;
|
2002-12-23 15:17:55 +03:00
|
|
|
werase(screen->__virtscr);
|
|
|
|
}
|
2000-04-27 04:26:19 +04:00
|
|
|
win->flags &= ~__CLEAROK;
|
2000-05-19 11:39:02 +04:00
|
|
|
}
|
2001-12-31 17:23:11 +03:00
|
|
|
screen->__virtscr->flags &= ~__LEAVEOK;
|
|
|
|
screen->__virtscr->flags |= win->flags;
|
2000-04-27 04:26:19 +04:00
|
|
|
|
2002-12-23 15:17:55 +03:00
|
|
|
for (wy = begy, y_off = wbegy; wy < maxy &&
|
|
|
|
y_off < screen->__virtscr->maxy; wy++, y_off++) {
|
|
|
|
wlp = win->lines[wy];
|
2000-04-27 04:26:19 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
__CTRACE("wnoutrefresh: wy %d\tf: %d\tl:%d\tflags %x\n", wy,
|
2000-05-19 11:39:02 +04:00
|
|
|
*wlp->firstchp, *wlp->lastchp, wlp->flags);
|
2000-04-27 04:26:19 +04:00
|
|
|
#endif
|
2000-05-20 19:12:15 +04:00
|
|
|
if ((wlp->flags & __ISDIRTY) == 0)
|
2000-05-19 11:39:02 +04:00
|
|
|
continue;
|
2002-12-23 15:17:55 +03:00
|
|
|
vlp = screen->__virtscr->lines[y_off];
|
2000-05-19 11:39:02 +04:00
|
|
|
|
2002-12-23 15:17:55 +03:00
|
|
|
if (*wlp->firstchp < maxx + win->ch_off &&
|
2000-05-19 11:39:02 +04:00
|
|
|
*wlp->lastchp >= win->ch_off) {
|
2000-04-27 04:26:19 +04:00
|
|
|
/* Copy line from "win" to "__virtscr". */
|
2002-12-23 15:17:55 +03:00
|
|
|
for (wx = begx + *wlp->firstchp - win->ch_off,
|
|
|
|
x_off = wbegx + *wlp->firstchp - win->ch_off;
|
|
|
|
wx <= *wlp->lastchp && wx < maxx &&
|
2001-12-31 17:23:11 +03:00
|
|
|
x_off < screen->__virtscr->maxx; wx++, x_off++) {
|
2000-05-19 11:39:02 +04:00
|
|
|
vlp->line[x_off].attr = wlp->line[wx].attr;
|
2000-06-13 00:51:39 +04:00
|
|
|
if (wlp->line[wx].attr & __COLOR)
|
2000-05-19 11:39:02 +04:00
|
|
|
vlp->line[x_off].attr |=
|
2000-06-13 00:51:39 +04:00
|
|
|
wlp->line[wx].battr & ~__COLOR;
|
|
|
|
else
|
|
|
|
vlp->line[x_off].attr |=
|
|
|
|
wlp->line[wx].battr;
|
2000-05-19 11:39:02 +04:00
|
|
|
if (wlp->line[wx].ch == ' ' &&
|
|
|
|
wlp->line[wx].bch != ' ')
|
|
|
|
vlp->line[x_off].ch
|
|
|
|
= wlp->line[wx].bch;
|
2000-04-27 04:26:19 +04:00
|
|
|
else
|
2000-05-19 11:39:02 +04:00
|
|
|
vlp->line[x_off].ch
|
|
|
|
= wlp->line[wx].ch;
|
2000-04-27 04:26:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set flags on "__virtscr" and unset on "win". */
|
2000-05-19 11:39:02 +04:00
|
|
|
if (wlp->flags & __ISPASTEOL)
|
|
|
|
vlp->flags |= __ISPASTEOL;
|
2000-04-27 04:26:19 +04:00
|
|
|
else
|
2000-05-19 11:39:02 +04:00
|
|
|
vlp->flags &= ~__ISPASTEOL;
|
|
|
|
if (wlp->flags & __ISDIRTY)
|
|
|
|
vlp->flags |= __ISDIRTY;
|
2000-04-27 04:26:19 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
__CTRACE("win: firstch = %d, lastch = %d\n",
|
2000-05-19 11:39:02 +04:00
|
|
|
*wlp->firstchp, *wlp->lastchp);
|
2000-04-27 04:26:19 +04:00
|
|
|
#endif
|
|
|
|
/* Set change pointers on "__virtscr". */
|
2000-05-19 11:39:02 +04:00
|
|
|
if (*vlp->firstchp >
|
2002-12-23 15:17:55 +03:00
|
|
|
*wlp->firstchp + wbegx - win->ch_off)
|
2000-05-19 11:39:02 +04:00
|
|
|
*vlp->firstchp =
|
2002-12-23 15:17:55 +03:00
|
|
|
*wlp->firstchp + wbegx - win->ch_off;
|
2000-05-19 11:39:02 +04:00
|
|
|
if (*vlp->lastchp <
|
2002-12-23 15:17:55 +03:00
|
|
|
*wlp->lastchp + wbegx - win->ch_off)
|
2000-05-19 11:39:02 +04:00
|
|
|
*vlp->lastchp =
|
2002-12-23 15:17:55 +03:00
|
|
|
*wlp->lastchp + wbegx - win->ch_off;
|
2000-04-27 04:26:19 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
__CTRACE("__virtscr: firstch = %d, lastch = %d\n",
|
2000-05-19 11:39:02 +04:00
|
|
|
*vlp->firstchp, *vlp->lastchp);
|
2000-04-27 04:26:19 +04:00
|
|
|
#endif
|
2002-12-23 15:17:55 +03:00
|
|
|
/*
|
|
|
|
* Unset change pointers only if a window, as a pad
|
|
|
|
* can be displayed again without any of the contents
|
|
|
|
* changing.
|
|
|
|
*/
|
|
|
|
if (!(win->flags & __ISPAD)) {
|
|
|
|
/* Set change pointers on "win". */
|
|
|
|
if (*wlp->firstchp >= win->ch_off)
|
|
|
|
*wlp->firstchp = maxx + win->ch_off;
|
|
|
|
if (*wlp->lastchp < maxx + win->ch_off)
|
|
|
|
*wlp->lastchp = win->ch_off;
|
|
|
|
if (*wlp->lastchp < *wlp->firstchp) {
|
2000-04-27 04:26:19 +04:00
|
|
|
#ifdef DEBUG
|
2002-12-23 15:17:55 +03:00
|
|
|
__CTRACE("wnoutrefresh: line %d notdirty\n", wy);
|
2000-04-27 04:26:19 +04:00
|
|
|
#endif
|
2002-12-23 15:17:55 +03:00
|
|
|
wlp->flags &= ~__ISDIRTY;
|
|
|
|
}
|
2000-04-27 04:26:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (OK);
|
|
|
|
}
|
|
|
|
|
1993-08-07 09:48:37 +04:00
|
|
|
/*
|
|
|
|
* wrefresh --
|
2002-12-23 15:17:55 +03:00
|
|
|
* Make the current screen look like "win" over the area covered by
|
1993-08-07 09:48:37 +04:00
|
|
|
* win.
|
|
|
|
*/
|
|
|
|
int
|
2000-04-15 17:17:02 +04:00
|
|
|
wrefresh(WINDOW *win)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2001-12-31 17:23:11 +03:00
|
|
|
int retval;
|
2002-01-02 13:38:27 +03:00
|
|
|
|
2002-12-23 15:17:55 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
__CTRACE("wrefresh: win %0.2o\n", win);
|
|
|
|
#endif
|
|
|
|
|
2001-12-31 17:23:11 +03:00
|
|
|
_cursesi_screen->curwin = (win == _cursesi_screen->curscr);
|
2001-12-02 12:14:20 +03:00
|
|
|
if (!_cursesi_screen->curwin)
|
2002-12-23 15:17:55 +03:00
|
|
|
retval = _cursesi_wnoutrefresh(_cursesi_screen, win, 0, 0,
|
|
|
|
win->begy, win->begx, win->maxy, win->maxx);
|
2000-04-27 04:26:19 +04:00
|
|
|
else
|
|
|
|
retval = OK;
|
|
|
|
if (retval == OK) {
|
|
|
|
retval = doupdate();
|
2000-04-28 02:12:36 +04:00
|
|
|
if (!win->flags & __LEAVEOK) {
|
|
|
|
win->cury = max(0, curscr->cury - win->begy);
|
|
|
|
win->curx = max(0, curscr->curx - win->begx);
|
|
|
|
}
|
2000-04-27 04:26:19 +04:00
|
|
|
}
|
2001-12-02 12:14:20 +03:00
|
|
|
_cursesi_screen->curwin = 0;
|
2000-04-27 04:26:19 +04:00
|
|
|
return(retval);
|
|
|
|
}
|
|
|
|
|
2002-12-23 15:17:55 +03:00
|
|
|
/*
|
|
|
|
* prefresh --
|
|
|
|
* Make the current screen look like "pad" over the area coverd by
|
|
|
|
* the specified area of pad.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
prefresh(WINDOW *pad, int pbegy, int pbegx, int sbegy, int sbegx,
|
|
|
|
int smaxy, int smaxx)
|
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
__CTRACE("prefresh: pad %0.2o, flags 0x%08x\n", pad, pad->flags);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Use pnoutrefresh() to avoid duplicating code here */
|
|
|
|
retval = pnoutrefresh(pad, pbegy, pbegx, sbegy, sbegx, smaxy, smaxx);
|
|
|
|
if (retval == OK) {
|
|
|
|
retval = doupdate();
|
|
|
|
if (!pad->flags & __LEAVEOK) {
|
|
|
|
pad->cury = max(0, curscr->cury - pad->begy);
|
|
|
|
pad->curx = max(0, curscr->curx - pad->begx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(retval);
|
|
|
|
}
|
|
|
|
|
2000-04-27 04:26:19 +04:00
|
|
|
/*
|
|
|
|
* doupdate --
|
|
|
|
* Make the current screen look like the virtual window "__virtscr".
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
doupdate(void)
|
|
|
|
{
|
|
|
|
WINDOW *win;
|
|
|
|
__LINE *wlp;
|
|
|
|
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 ... */
|
2001-12-02 12:14:20 +03:00
|
|
|
if (_cursesi_screen->endwin)
|
1997-09-13 01:08:22 +04:00
|
|
|
__restartwin();
|
|
|
|
|
2001-12-02 12:14:20 +03:00
|
|
|
if (_cursesi_screen->curwin)
|
2000-04-27 04:26:19 +04:00
|
|
|
win = curscr;
|
|
|
|
else
|
2001-12-31 17:23:11 +03:00
|
|
|
win = _cursesi_screen->__virtscr;
|
2000-04-27 04:26:19 +04:00
|
|
|
|
1993-08-07 09:48:37 +04:00
|
|
|
/* Initialize loop parameters. */
|
2001-12-02 12:14:20 +03:00
|
|
|
_cursesi_screen->ly = curscr->cury;
|
|
|
|
_cursesi_screen->lx = curscr->curx;
|
1993-03-21 12:45:37 +03:00
|
|
|
wy = 0;
|
|
|
|
|
2001-12-02 12:14:20 +03:00
|
|
|
if (!_cursesi_screen->curwin)
|
1993-11-09 06:34:01 +03:00
|
|
|
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,
|
2002-10-22 15:37:34 +04:00
|
|
|
(size_t) (win->maxx * __LDATASIZE));
|
1993-11-09 06:34:01 +03:00
|
|
|
}
|
|
|
|
|
2001-12-02 12:14:20 +03:00
|
|
|
if ((win->flags & __CLEAROK) || (curscr->flags & __CLEAROK) ||
|
|
|
|
_cursesi_screen->curwin) {
|
2000-04-27 04:26:19 +04:00
|
|
|
if (curscr->wattr & __COLOR)
|
|
|
|
__unsetattr(0);
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_cl, 0, __cputchar);
|
2001-12-02 12:14:20 +03:00
|
|
|
_cursesi_screen->ly = 0;
|
|
|
|
_cursesi_screen->lx = 0;
|
|
|
|
if (!_cursesi_screen->curwin) {
|
2000-04-27 04:26:19 +04:00
|
|
|
curscr->flags &= ~__CLEAROK;
|
|
|
|
curscr->cury = 0;
|
|
|
|
curscr->curx = 0;
|
|
|
|
werase(curscr);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
2000-04-27 04:26:19 +04:00
|
|
|
__touchwin(win);
|
1993-11-09 06:34:01 +03:00
|
|
|
win->flags &= ~__CLEAROK;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
2000-12-20 00:34:24 +03:00
|
|
|
if (!__CA) {
|
1993-11-09 06:34:01 +03:00
|
|
|
if (win->curx != 0)
|
2000-08-01 08:17:09 +04:00
|
|
|
__cputchar('\n');
|
2001-12-02 12:14:20 +03:00
|
|
|
if (!_cursesi_screen->curwin)
|
1993-03-21 12:45:37 +03:00
|
|
|
werase(curscr);
|
|
|
|
}
|
1993-08-07 09:48:37 +04:00
|
|
|
#ifdef DEBUG
|
2001-12-02 12:14:20 +03:00
|
|
|
__CTRACE("doupdate: (%0.2o): curwin = %d\n", win,
|
|
|
|
_cursesi_screen->curwin);
|
2000-04-27 04:26:19 +04:00
|
|
|
__CTRACE("doupdate: \tfirstch\tlastch\n");
|
1993-11-09 06:34:01 +03:00
|
|
|
#endif
|
|
|
|
|
2001-12-02 12:14:20 +03:00
|
|
|
if (!_cursesi_screen->curwin) {
|
1993-11-09 06:34:01 +03:00
|
|
|
/*
|
|
|
|
* 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++)
|
2000-05-20 19:12:15 +04:00
|
|
|
if (win->lines[wy]->flags & __ISDIRTY)
|
1993-11-09 06:34:01 +03:00
|
|
|
dnum++;
|
|
|
|
if (!__noqch && dnum > (int) win->maxy / 4)
|
2000-04-27 04:26:19 +04:00
|
|
|
quickch();
|
1993-11-09 06:34:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#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++)
|
2001-12-02 12:14:20 +03: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-27 04:26:19 +04:00
|
|
|
__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");
|
|
|
|
__CTRACE(" attr:");
|
|
|
|
for (j = 0; j < win->maxx; j++)
|
|
|
|
__CTRACE(" %x",
|
|
|
|
win->lines[i]->line[j].attr);
|
|
|
|
__CTRACE("\n");
|
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++) {
|
2000-05-19 11:39:02 +04:00
|
|
|
wlp = win->lines[wy];
|
2000-04-27 04:26:19 +04:00
|
|
|
/* XXX: remove this debug */
|
1993-08-07 09:48:37 +04:00
|
|
|
#ifdef DEBUG
|
2000-04-27 04:26:19 +04:00
|
|
|
__CTRACE("doupdate: wy %d\tf: %d\tl:%d\tflags %x\n", wy,
|
2000-05-19 11:39:02 +04:00
|
|
|
*wlp->firstchp, *wlp->lastchp, wlp->flags);
|
1993-08-07 09:48:37 +04:00
|
|
|
#endif
|
2001-12-02 12:14:20 +03:00
|
|
|
if (!_cursesi_screen->curwin)
|
2000-05-19 11:39:02 +04:00
|
|
|
curscr->lines[wy]->hash = wlp->hash;
|
2000-05-20 19:12:15 +04:00
|
|
|
if (wlp->flags & __ISDIRTY) {
|
2000-04-27 04:26:19 +04:00
|
|
|
if (makech(wy) == ERR)
|
1993-08-07 09:48:37 +04:00
|
|
|
return (ERR);
|
1993-03-21 12:45:37 +03:00
|
|
|
else {
|
2000-05-19 11:39:02 +04:00
|
|
|
if (*wlp->firstchp >= 0)
|
|
|
|
*wlp->firstchp = win->maxx;
|
|
|
|
if (*wlp->lastchp < win->maxx)
|
|
|
|
*wlp->lastchp = 0;
|
|
|
|
if (*wlp->lastchp < *wlp->firstchp) {
|
1993-11-09 06:34:01 +03:00
|
|
|
#ifdef DEBUG
|
2000-04-27 04:26:19 +04:00
|
|
|
__CTRACE("doupdate: line %d notdirty\n", wy);
|
1993-11-09 06:34:01 +03:00
|
|
|
#endif
|
2000-05-19 11:39:02 +04:00
|
|
|
wlp->flags &= ~__ISDIRTY;
|
1993-11-09 06:34:01 +03:00
|
|
|
}
|
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
|
2000-05-19 11:39:02 +04:00
|
|
|
__CTRACE("\t%d\t%d\n", *wlp->firstchp, *wlp->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
|
2001-12-02 12:14:20 +03:00
|
|
|
__CTRACE("doupdate: ly=%d, lx=%d\n", _cursesi_screen->ly,
|
|
|
|
_cursesi_screen->lx);
|
1993-11-09 06:34:01 +03:00
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2001-12-02 12:14:20 +03:00
|
|
|
if (_cursesi_screen->curwin)
|
|
|
|
domvcur(_cursesi_screen->ly, _cursesi_screen->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) {
|
2001-12-02 12:14:20 +03:00
|
|
|
curscr->cury = _cursesi_screen->ly;
|
|
|
|
curscr->curx = _cursesi_screen->lx;
|
1993-08-07 09:48:37 +04:00
|
|
|
} else {
|
2001-12-02 12:14:20 +03:00
|
|
|
domvcur(_cursesi_screen->ly, _cursesi_screen->lx,
|
|
|
|
win->cury, win->curx);
|
2000-04-27 04:26:19 +04:00
|
|
|
curscr->cury = win->cury;
|
|
|
|
curscr->curx = win->curx;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
2000-04-27 04:26:19 +04:00
|
|
|
|
2000-04-29 06:51:16 +04:00
|
|
|
/* Don't leave the screen with attributes set. */
|
|
|
|
__unsetattr(0);
|
2001-12-02 12:14:20 +03:00
|
|
|
(void) fflush(_cursesi_screen->outfd);
|
2000-04-29 06:51:16 +04:00
|
|
|
return (OK);
|
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
|
2000-04-27 04:26:19 +04:00
|
|
|
makech(wy)
|
1999-04-13 18:08:17 +04:00
|
|
|
int wy;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2000-04-27 04:26:19 +04:00
|
|
|
WINDOW *win;
|
2000-05-19 20:00:52 +04:00
|
|
|
static __LDATA blank = {' ', 0, ' ', 0};
|
1994-08-18 01:51:41 +04:00
|
|
|
__LDATA *nsp, *csp, *cp, *cep;
|
1999-04-13 18:08:17 +04:00
|
|
|
int clsp, nlsp; /* Last space in lines. */
|
2000-04-27 04:26:19 +04:00
|
|
|
int lch, wx;
|
2000-05-20 19:12:15 +04:00
|
|
|
char *ce;
|
2000-04-27 04:26:19 +04:00
|
|
|
attr_t lspc; /* Last space colour */
|
2000-04-29 04:42:26 +04:00
|
|
|
attr_t off, on;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-07-22 11:36:20 +04:00
|
|
|
#ifdef __GNUC__
|
2000-04-27 04:26:19 +04:00
|
|
|
nlsp = lspc = 0; /* XXX gcc -Wuninitialized */
|
1997-07-22 11:36:20 +04:00
|
|
|
#endif
|
2001-12-02 12:14:20 +03:00
|
|
|
if (_cursesi_screen->curwin)
|
2000-04-27 04:26:19 +04:00
|
|
|
win = curscr;
|
|
|
|
else
|
|
|
|
win = __virtscr;
|
1993-11-09 06:34:01 +03:00
|
|
|
/* Is the cursor still on the end of the last line? */
|
2000-08-02 14:50:49 +04:00
|
|
|
if (wy > 0 && curscr->lines[wy - 1]->flags & __ISPASTEOL) {
|
2001-12-02 12:14:20 +03:00
|
|
|
domvcur(_cursesi_screen->ly, _cursesi_screen->lx,
|
|
|
|
_cursesi_screen->ly + 1, 0);
|
|
|
|
_cursesi_screen->ly++;
|
|
|
|
_cursesi_screen->lx = 0;
|
1993-11-09 06:34:01 +03:00
|
|
|
}
|
2000-04-27 04:26:19 +04:00
|
|
|
wx = *win->lines[wy]->firstchp;
|
1993-11-09 06:34:01 +03:00
|
|
|
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);
|
2000-04-27 04:26:19 +04:00
|
|
|
lch = *win->lines[wy]->lastchp;
|
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-03-21 12:45:37 +03:00
|
|
|
|
2001-12-02 12:14:20 +03:00
|
|
|
if (_cursesi_screen->curwin)
|
1993-11-09 06:34:01 +03:00
|
|
|
csp = ␣
|
1993-03-21 12:45:37 +03:00
|
|
|
else
|
2000-04-27 04:26:19 +04:00
|
|
|
csp = &curscr->lines[wy]->line[wx];
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1993-11-09 06:34:01 +03:00
|
|
|
nsp = &win->lines[wy]->line[wx];
|
2001-12-02 12:14:20 +03:00
|
|
|
if (__tc_ce && !_cursesi_screen->curwin) {
|
2000-04-19 02:47:01 +04:00
|
|
|
cp = &win->lines[wy]->line[win->maxx - 1];
|
2000-04-27 04:26:19 +04:00
|
|
|
lspc = cp->attr & __COLOR;
|
|
|
|
while (cp->ch == ' ' && cp->attr == lspc)
|
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;
|
2001-09-20 15:11:54 +04:00
|
|
|
if (nlsp < 0)
|
|
|
|
nlsp = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
2001-12-02 12:14:20 +03:00
|
|
|
if (!_cursesi_screen->curwin)
|
2000-12-20 00:34:24 +03:00
|
|
|
ce = __tc_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
|
|
|
|
|
|
|
while (wx <= lch) {
|
2000-05-20 19:12:15 +04:00
|
|
|
if (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++;
|
2001-12-02 12:14:20 +03:00
|
|
|
if (!_cursesi_screen->curwin)
|
1994-08-18 01:51:41 +04:00
|
|
|
++csp;
|
|
|
|
++wx;
|
|
|
|
}
|
1993-08-07 09:48:37 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2001-12-02 12:14:20 +03:00
|
|
|
domvcur(_cursesi_screen->ly, _cursesi_screen->lx, wy, wx);
|
1993-11-09 06:34:01 +03:00
|
|
|
|
1993-08-07 09:48:37 +04:00
|
|
|
#ifdef DEBUG
|
2000-05-20 19:12:15 +04:00
|
|
|
__CTRACE("makech: 1: wx = %d, ly= %d, lx = %d, newy = %d, newx = %d\n",
|
2001-12-02 12:14:20 +03:00
|
|
|
wx, _cursesi_screen->ly, _cursesi_screen->lx, wy, wx);
|
1993-08-07 09:48:37 +04:00
|
|
|
#endif
|
2001-12-02 12:14:20 +03:00
|
|
|
_cursesi_screen->ly = wy;
|
|
|
|
_cursesi_screen->lx = wx;
|
2000-05-20 19:12:15 +04:00
|
|
|
while (memcmp(nsp, csp, sizeof(__LDATA)) != 0 && wx <= lch) {
|
1994-08-18 01:51:41 +04:00
|
|
|
if (ce != NULL &&
|
2000-04-27 04:26:19 +04:00
|
|
|
wx >= nlsp && nsp->ch == ' ' && nsp->attr == lspc) {
|
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-27 04:26:19 +04:00
|
|
|
while (cep->ch == ' ' && cep->attr == lspc)
|
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-12-20 00:34:24 +03:00
|
|
|
if (((clsp - nlsp >= strlen(__tc_ce) &&
|
2000-04-19 02:47:01 +04:00
|
|
|
clsp < win->maxx * __LDATASIZE) ||
|
|
|
|
wy == win->maxy - 1) &&
|
2000-04-27 04:26:19 +04:00
|
|
|
(!(lspc & __COLOR) ||
|
2000-12-20 00:34:24 +03:00
|
|
|
((lspc & __COLOR) && __tc_ut))) {
|
2000-04-27 04:26:19 +04:00
|
|
|
__unsetattr(0);
|
2002-08-04 20:43:04 +04:00
|
|
|
if (__using_color &&
|
|
|
|
((lspc & __COLOR) !=
|
|
|
|
(curscr->wattr & __COLOR)))
|
|
|
|
__set_color(curscr, lspc &
|
|
|
|
__COLOR);
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_ce, 0, __cputchar);
|
2001-12-02 12:14:20 +03:00
|
|
|
_cursesi_screen->lx = wx + win->begx;
|
1993-11-09 06:34:01 +03:00
|
|
|
while (wx++ <= clsp) {
|
|
|
|
csp->ch = ' ';
|
2000-04-27 04:26:19 +04:00
|
|
|
csp->attr = lspc;
|
1993-11-09 06:34:01 +03:00
|
|
|
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
|
|
|
|
2002-08-04 20:43:04 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
__CTRACE("makech: have attributes %08x, need attributes %08x\n", curscr->wattr, nsp->attr);
|
|
|
|
#endif
|
2000-04-29 04:42:26 +04:00
|
|
|
|
|
|
|
off = ~nsp->attr & curscr->wattr;
|
2000-04-13 01:47:20 +04:00
|
|
|
|
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
|
2000-04-29 04:42:26 +04:00
|
|
|
* standout, attributes and colour.
|
1999-04-13 18:08:17 +04:00
|
|
|
*/
|
2000-12-20 00:34:24 +03:00
|
|
|
if (off & __TERMATTR && __tc_me != NULL) {
|
|
|
|
tputs(__tc_me, 0, __cputchar);
|
|
|
|
curscr->wattr &= __mask_me;
|
|
|
|
off &= __mask_me;
|
1999-04-13 18:08:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Exit underscore mode if appropriate.
|
2000-04-29 04:42:26 +04:00
|
|
|
* Check to see if we also turn off standout,
|
|
|
|
* attributes and colour.
|
1999-04-13 18:08:17 +04:00
|
|
|
*/
|
2000-12-20 00:34:24 +03:00
|
|
|
if (off & __UNDERSCORE && __tc_ue != NULL) {
|
|
|
|
tputs(__tc_ue, 0, __cputchar);
|
|
|
|
curscr->wattr &= __mask_ue;
|
|
|
|
off &= __mask_ue;
|
1999-04-13 18:08:17 +04:00
|
|
|
}
|
|
|
|
|
1994-08-18 01:51:41 +04:00
|
|
|
/*
|
2000-04-29 04:42:26 +04:00
|
|
|
* Exit standout mode as appropriate.
|
|
|
|
* Check to see if we also turn off underscore,
|
|
|
|
* attributes and colour.
|
1994-08-18 01:51:41 +04:00
|
|
|
* XXX
|
2000-12-20 00:34:24 +03:00
|
|
|
* Should use uc if so/se not available.
|
1994-08-18 01:51:41 +04:00
|
|
|
*/
|
2000-12-20 00:34:24 +03:00
|
|
|
if (off & __STANDOUT && __tc_se != NULL) {
|
|
|
|
tputs(__tc_se, 0, __cputchar);
|
|
|
|
curscr->wattr &= __mask_se;
|
|
|
|
off &= __mask_se;
|
2000-04-29 04:42:26 +04:00
|
|
|
}
|
|
|
|
|
2000-12-20 00:34:24 +03:00
|
|
|
if (off & __ALTCHARSET && __tc_ae != NULL) {
|
|
|
|
tputs(__tc_ae, 0, __cputchar);
|
2000-04-29 04:42:26 +04:00
|
|
|
curscr->wattr &= ~__ALTCHARSET;
|
|
|
|
}
|
|
|
|
|
2002-08-04 20:43:04 +04:00
|
|
|
/* Set/change colour as appropriate. */
|
|
|
|
if (__using_color)
|
|
|
|
__set_color(curscr, nsp->attr & __COLOR);
|
|
|
|
|
2000-04-29 04:42:26 +04:00
|
|
|
on = nsp->attr & ~curscr->wattr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enter standout mode if appropriate.
|
|
|
|
*/
|
2000-12-20 00:34:24 +03:00
|
|
|
if (on & __STANDOUT && __tc_so != NULL && __tc_se
|
|
|
|
!= NULL) {
|
|
|
|
tputs(__tc_so, 0, __cputchar);
|
2000-04-29 04:42:26 +04:00
|
|
|
curscr->wattr |= __STANDOUT;
|
1999-04-13 18:08:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enter underscore mode if appropriate.
|
|
|
|
* XXX
|
2000-12-20 00:34:24 +03:00
|
|
|
* Should use uc if us/ue not available.
|
1999-04-13 18:08:17 +04:00
|
|
|
*/
|
2000-12-20 00:34:24 +03:00
|
|
|
if (on & __UNDERSCORE && __tc_us != NULL &&
|
|
|
|
__tc_ue != NULL) {
|
|
|
|
tputs(__tc_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-12-20 00:34:24 +03:00
|
|
|
if (__tc_me != NULL) {
|
|
|
|
if (on & __BLINK && __tc_mb != NULL) {
|
|
|
|
tputs(__tc_mb, 0, __cputchar);
|
2000-04-29 04:42:26 +04:00
|
|
|
curscr->wattr |= __BLINK;
|
|
|
|
}
|
2000-12-20 00:34:24 +03:00
|
|
|
if (on & __BOLD && __tc_md != NULL) {
|
|
|
|
tputs(__tc_md, 0, __cputchar);
|
2000-04-29 04:42:26 +04:00
|
|
|
curscr->wattr |= __BOLD;
|
|
|
|
}
|
2000-12-20 00:34:24 +03:00
|
|
|
if (on & __DIM && __tc_mh != NULL) {
|
|
|
|
tputs(__tc_mh, 0, __cputchar);
|
2000-04-29 04:42:26 +04:00
|
|
|
curscr->wattr |= __DIM;
|
|
|
|
}
|
2000-12-20 00:34:24 +03:00
|
|
|
if (on & __BLANK && __tc_mk != NULL) {
|
|
|
|
tputs(__tc_mk, 0, __cputchar);
|
2000-04-29 04:42:26 +04:00
|
|
|
curscr->wattr |= __BLANK;
|
|
|
|
}
|
2000-12-20 00:34:24 +03:00
|
|
|
if (on & __PROTECT && __tc_mp != NULL) {
|
|
|
|
tputs(__tc_mp, 0, __cputchar);
|
2000-04-29 04:42:26 +04:00
|
|
|
curscr->wattr |= __PROTECT;
|
|
|
|
}
|
2000-12-20 00:34:24 +03:00
|
|
|
if (on & __REVERSE && __tc_mr != NULL) {
|
|
|
|
tputs(__tc_mr, 0, __cputchar);
|
2000-04-29 04:42:26 +04:00
|
|
|
curscr->wattr |= __REVERSE;
|
|
|
|
}
|
2000-04-11 17:57:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Enter/exit altcharset mode as appropriate. */
|
2000-12-20 00:34:24 +03:00
|
|
|
if (on & __ALTCHARSET && __tc_as != NULL &&
|
|
|
|
__tc_ae != NULL) {
|
|
|
|
tputs(__tc_as, 0, __cputchar);
|
2000-04-29 04:42:26 +04:00
|
|
|
curscr->wattr |= __ALTCHARSET;
|
1999-04-13 18:08:17 +04:00
|
|
|
}
|
1993-08-07 09:48:37 +04:00
|
|
|
|
|
|
|
wx++;
|
2000-04-27 04:26:19 +04:00
|
|
|
if (wx >= win->maxx &&
|
2001-12-02 12:14:20 +03:00
|
|
|
wy == win->maxy - 1 && !_cursesi_screen->curwin)
|
1993-11-09 06:34:01 +03:00
|
|
|
if (win->flags & __SCROLLOK) {
|
2000-04-29 06:51:16 +04:00
|
|
|
if (win->flags & __ENDLINE)
|
2000-04-27 04:26:19 +04:00
|
|
|
__unsetattr(1);
|
1993-11-09 06:34:01 +03:00
|
|
|
if (!(win->flags & __SCROLLWIN)) {
|
2001-12-02 12:14:20 +03:00
|
|
|
if (!_cursesi_screen->curwin) {
|
2000-04-27 04:26:19 +04:00
|
|
|
csp->attr = nsp->attr;
|
2000-08-01 08:17:09 +04:00
|
|
|
__cputchar((int)
|
2000-04-27 04:26:19 +04:00
|
|
|
(csp->ch =
|
|
|
|
nsp->ch));
|
1993-11-09 06:34:01 +03:00
|
|
|
} else
|
2000-08-01 08:17:09 +04:00
|
|
|
__cputchar((int) nsp->ch);
|
1993-08-07 09:48:37 +04:00
|
|
|
}
|
2000-04-27 04:26:19 +04:00
|
|
|
if (wx < curscr->maxx) {
|
2001-12-02 12:14:20 +03:00
|
|
|
domvcur(_cursesi_screen->ly, wx,
|
2000-04-27 04:26:19 +04:00
|
|
|
(int) (win->maxy - 1),
|
|
|
|
(int) (win->maxx - 1));
|
1993-11-09 06:34:01 +03:00
|
|
|
}
|
2001-12-02 12:14:20 +03:00
|
|
|
_cursesi_screen->ly = win->maxy - 1;
|
|
|
|
_cursesi_screen->lx = win->maxx - 1;
|
1993-11-09 06:34:01 +03:00
|
|
|
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)) {
|
2001-12-02 12:14:20 +03:00
|
|
|
if (!_cursesi_screen->curwin) {
|
2000-04-27 04:26:19 +04:00
|
|
|
csp->attr = nsp->attr;
|
2000-08-01 08:17:09 +04:00
|
|
|
__cputchar((int) (csp->ch = nsp->ch));
|
1993-11-09 06:34:01 +03:00
|
|
|
csp++;
|
1994-08-18 01:51:41 +04:00
|
|
|
} else
|
2000-08-01 08:17:09 +04:00
|
|
|
__cputchar((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
|
2000-12-20 00:34:24 +03:00
|
|
|
if (__tc_uc && ((nsp->attr & __STANDOUT) ||
|
1999-04-13 18:08:17 +04:00
|
|
|
(nsp->attr & __UNDERSCORE))) {
|
2000-08-01 08:17:09 +04:00
|
|
|
__cputchar('\b');
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_uc, 0, __cputchar);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1993-08-07 09:48:37 +04:00
|
|
|
nsp++;
|
|
|
|
#ifdef DEBUG
|
2001-12-02 12:14:20 +03:00
|
|
|
__CTRACE("makech: 2: wx = %d, lx = %d\n", wx, _cursesi_screen->lx);
|
1993-08-07 09:48:37 +04:00
|
|
|
#endif
|
1993-11-09 06:34:01 +03:00
|
|
|
}
|
2001-12-02 12:14:20 +03:00
|
|
|
if (_cursesi_screen->lx == wx) /* If no change. */
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
2001-12-02 12:14:20 +03:00
|
|
|
_cursesi_screen->lx = wx;
|
|
|
|
if (_cursesi_screen->lx >= COLS && __tc_am)
|
|
|
|
_cursesi_screen->lx = COLS - 1;
|
1999-04-13 18:08:17 +04:00
|
|
|
else
|
|
|
|
if (wx >= win->maxx) {
|
2001-12-02 12:14:20 +03:00
|
|
|
domvcur(_cursesi_screen->ly,
|
|
|
|
_cursesi_screen->lx,
|
|
|
|
_cursesi_screen->ly,
|
|
|
|
(int) (win->maxx - 1));
|
|
|
|
_cursesi_screen->lx = win->maxx - 1;
|
1999-04-13 18:08:17 +04:00
|
|
|
}
|
1993-08-07 09:48:37 +04:00
|
|
|
#ifdef DEBUG
|
2001-12-02 12:14:20 +03:00
|
|
|
__CTRACE("makech: 3: wx = %d, lx = %d\n", wx,
|
|
|
|
_cursesi_screen->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
|
|
|
|
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-27 04:26:19 +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.
|
|
|
|
*/
|
|
|
|
|
2002-06-26 22:13:59 +04:00
|
|
|
static __LDATA buf[128];
|
|
|
|
static u_int last_hash;
|
|
|
|
static size_t last_hash_len;
|
|
|
|
#define BLANKSIZE (sizeof(buf) / sizeof(buf[0]))
|
|
|
|
|
1993-11-09 06:34:01 +03:00
|
|
|
static void
|
2000-04-27 04:26:19 +04:00
|
|
|
quickch(void)
|
1993-11-09 06:34:01 +03:00
|
|
|
{
|
2000-04-27 04:26:19 +04:00
|
|
|
#define THRESH (int) __virtscr->maxy / 4
|
1993-11-09 06:34:01 +03:00
|
|
|
|
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;
|
|
|
|
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.
|
|
|
|
*/
|
2000-04-27 04:26:19 +04:00
|
|
|
for (top = 0; top < __virtscr->maxy; top++)
|
2000-05-20 19:12:15 +04:00
|
|
|
if (__virtscr->lines[top]->flags & __ISDIRTY &&
|
|
|
|
(__virtscr->lines[top]->hash != curscr->lines[top]->hash ||
|
|
|
|
memcmp(__virtscr->lines[top]->line,
|
2000-05-19 08:15:55 +04:00
|
|
|
curscr->lines[top]->line,
|
2000-05-20 19:12:15 +04:00
|
|
|
(size_t) __virtscr->maxx * __LDATASIZE) != 0))
|
1993-11-09 06:34:01 +03:00
|
|
|
break;
|
|
|
|
else
|
2000-04-27 04:26:19 +04:00
|
|
|
__virtscr->lines[top]->flags &= ~__ISDIRTY;
|
1999-04-13 18:08:17 +04:00
|
|
|
/*
|
|
|
|
* Find how many lines from bottom of screen are unchanged.
|
|
|
|
*/
|
2000-04-27 04:26:19 +04:00
|
|
|
for (bot = __virtscr->maxy - 1; bot >= 0; bot--)
|
2000-05-20 19:12:15 +04:00
|
|
|
if (__virtscr->lines[bot]->flags & __ISDIRTY &&
|
|
|
|
(__virtscr->lines[bot]->hash != curscr->lines[bot]->hash ||
|
|
|
|
memcmp(__virtscr->lines[bot]->line,
|
2000-05-19 08:15:55 +04:00
|
|
|
curscr->lines[bot]->line,
|
2000-05-20 19:12:15 +04:00
|
|
|
(size_t) __virtscr->maxx * __LDATASIZE) != 0))
|
1993-11-09 06:34:01 +03:00
|
|
|
break;
|
|
|
|
else
|
2000-04-27 04:26:19 +04:00
|
|
|
__virtscr->lines[bot]->flags &= ~__ISDIRTY;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Work round an xterm bug where inserting lines causes all the
|
|
|
|
* inserted lines to be covered with the background colour we
|
|
|
|
* set on the first line (even if we unset it for subsequent
|
|
|
|
* lines).
|
|
|
|
*/
|
|
|
|
bcolor = __virtscr->lines[min(top,
|
|
|
|
__virtscr->maxy - 1)]->line[0].attr & __COLOR;
|
|
|
|
for (i = top + 1, j = 0; i < bot; i++) {
|
|
|
|
if ((__virtscr->lines[i]->line[0].attr & __COLOR) != bcolor) {
|
|
|
|
bcolor = __virtscr->lines[i]->line[__virtscr->maxx].
|
|
|
|
attr & __COLOR;
|
|
|
|
j = i - top;
|
|
|
|
} else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
top += j;
|
1993-11-09 06:34:01 +03:00
|
|
|
|
|
|
|
#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.
|
|
|
|
*/
|
2000-04-27 04:26:19 +04:00
|
|
|
if (bot < __virtscr->maxy - 1)
|
1993-11-09 06:34:01 +03:00
|
|
|
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:
|
2000-04-27 04:26:19 +04:00
|
|
|
* - Startw is the index of the beginning of the examined block in
|
|
|
|
* __virtscr.
|
1999-04-13 18:08:17 +04:00
|
|
|
* - Starts is the index of the beginning of the examined block in
|
2000-04-27 04:26:19 +04:00
|
|
|
* curscr.
|
1994-08-18 01:51:41 +04:00
|
|
|
* - Curw is the index of one past the end of the exmined block in
|
2000-04-27 04:26:19 +04:00
|
|
|
* __virtscr.
|
|
|
|
* - Curs 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
|
|
|
*/
|
2000-04-27 04:26:19 +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++)
|
2000-05-20 19:12:15 +04:00
|
|
|
if (__virtscr->lines[curw]->hash !=
|
|
|
|
curscr->lines[curs]->hash)
|
2000-05-19 08:15:55 +04:00
|
|
|
break;
|
|
|
|
if (curs != starts + bsize)
|
|
|
|
continue;
|
|
|
|
for (curw = startw, curs = starts;
|
|
|
|
curs < starts + bsize; curw++, curs++)
|
|
|
|
if (memcmp(__virtscr->lines[curw]->line,
|
|
|
|
curscr->lines[curs]->line,
|
|
|
|
(size_t) __virtscr->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
|
|
|
|
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);
|
2000-04-27 04:26:19 +04:00
|
|
|
__CTRACE(" 0x%x \n", __virtscr->lines[i]->hash);
|
|
|
|
__CTRACE(" 0x%x ", __virtscr->lines[i]->flags);
|
|
|
|
for (j = 0; j < __virtscr->maxx; j++)
|
|
|
|
__CTRACE("%c", __virtscr->lines[i]->line[j].ch);
|
1999-04-13 18:08:17 +04:00
|
|
|
__CTRACE("\n");
|
1999-09-17 18:21:04 +04:00
|
|
|
__CTRACE(" attr:");
|
2000-04-27 04:26:19 +04:00
|
|
|
for (j = 0; j < __virtscr->maxx; j++)
|
|
|
|
__CTRACE(" %x", __virtscr->lines[i]->line[j].attr);
|
1999-04-13 18:08:17 +04:00
|
|
|
__CTRACE("\n");
|
|
|
|
}
|
1994-08-18 01:51:41 +04:00
|
|
|
#endif
|
|
|
|
|
2002-06-26 22:13:59 +04:00
|
|
|
if (buf[0].ch != ' ') {
|
|
|
|
for (i = 0; i < BLANKSIZE; i++) {
|
|
|
|
buf[i].ch = ' ';
|
|
|
|
buf[i].bch = ' ';
|
|
|
|
buf[i].attr = 0;
|
|
|
|
buf[i].battr = 0;
|
|
|
|
}
|
1993-11-09 06:34:01 +03:00
|
|
|
}
|
2002-06-26 22:13:59 +04:00
|
|
|
|
|
|
|
if (__virtscr->maxx != last_hash_len) {
|
|
|
|
blank_hash = 0;
|
|
|
|
for (i = __virtscr->maxx; i > BLANKSIZE; i -= BLANKSIZE) {
|
|
|
|
blank_hash = __hash_more((char *)(void *)buf, sizeof(buf),
|
|
|
|
blank_hash);
|
|
|
|
}
|
|
|
|
blank_hash = __hash_more((char *)(void *)buf,
|
|
|
|
i * sizeof(buf[0]), blank_hash);
|
|
|
|
/* cache result in static data - screen width doesn't change often */
|
|
|
|
last_hash_len = __virtscr->maxx;
|
|
|
|
last_hash = blank_hash;
|
|
|
|
} else
|
|
|
|
blank_hash = last_hash;
|
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
|
2000-04-27 04:26:19 +04:00
|
|
|
__virtscr->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,
|
2002-06-26 22:13:59 +04:00
|
|
|
clp->line + 1, (__virtscr->maxx - 1) *
|
|
|
|
__LDATASIZE) || memcmp(clp->line, buf,
|
|
|
|
__LDATASIZE)) {
|
|
|
|
for (i = __virtscr->maxx; i > BLANKSIZE;
|
|
|
|
i -= BLANKSIZE) {
|
|
|
|
(void)memcpy(clp->line + i -
|
|
|
|
BLANKSIZE, buf, sizeof(buf));
|
|
|
|
}
|
|
|
|
(void)memcpy(clp->line , buf, i *
|
|
|
|
sizeof(buf[0]));
|
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;
|
2000-05-20 19:12:15 +04:00
|
|
|
__touchline(__virtscr, target, 0, (int) __virtscr->maxx - 1);
|
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(" -- blank line already: dirty\n");
|
1993-11-09 06:34:01 +03:00
|
|
|
#endif
|
2000-05-20 19:12:15 +04:00
|
|
|
__touchline(__virtscr, target, 0, (int) __virtscr->maxx - 1);
|
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
|
2000-05-20 19:12:15 +04:00
|
|
|
__touchline(__virtscr, target, 0, (int) __virtscr->maxx - 1);
|
1999-04-13 18:08:17 +04:00
|
|
|
}
|
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);
|
2000-04-27 04:26:19 +04:00
|
|
|
for (j = 0; j < __virtscr->maxx; j++)
|
|
|
|
__CTRACE("%c", __virtscr->lines[i]->line[j].ch);
|
1999-04-13 18:08:17 +04:00
|
|
|
__CTRACE("\n");
|
|
|
|
}
|
1993-11-09 06:34:01 +03:00
|
|
|
#endif
|
2000-04-27 04:26:19 +04:00
|
|
|
if (n != 0)
|
|
|
|
scrolln(starts, startw, curs, bot, top);
|
1993-11-09 06:34:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
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 */
|
2000-04-27 04:26:19 +04:00
|
|
|
scrolln(starts, startw, curs, bot, top)
|
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
|
2000-12-20 00:34:24 +03:00
|
|
|
* we have either cs + ho + SF/sf/SR/sr, or AL + DL. SF/sf and SR/sr
|
1994-08-18 01:51:41 +04:00
|
|
|
* scrolling can only shift the entire scrolling region, not just a
|
|
|
|
* part of it, which means that the quickch() routine is going to be
|
2000-12-20 00:34:24 +03:00
|
|
|
* sadly disappointed in us if we don't have cs as well.
|
1994-08-18 01:51:41 +04:00
|
|
|
*
|
2000-12-20 00:34:24 +03:00
|
|
|
* 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
|
1994-08-18 01:51:41 +04:00
|
|
|
* 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
|
2000-12-20 00:34:24 +03:00
|
|
|
* or AL/DL, and, some terminals have AL/DL, sf/sr, and cs, but not
|
1994-08-18 01:51:41 +04:00
|
|
|
* 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) {
|
2000-12-20 00:34:24 +03:00
|
|
|
if (__tc_cs != NULL && __tc_ho != NULL && (__tc_SF != NULL ||
|
|
|
|
((__tc_AL == NULL || __tc_DL == NULL ||
|
|
|
|
top > 3 || bot + 3 < __virtscr->maxy) &&
|
|
|
|
__tc_sf != NULL))) {
|
|
|
|
tputs(__tscroll(__tc_cs, top, bot + 1), 0, __cputchar);
|
1994-08-18 01:51:41 +04:00
|
|
|
__mvcur(oy, ox, 0, 0, 1);
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_ho, 0, __cputchar);
|
1994-08-18 01:51:41 +04:00
|
|
|
__mvcur(0, 0, bot, 0, 1);
|
2000-12-20 00:34:24 +03:00
|
|
|
if (__tc_SF != NULL)
|
|
|
|
tputs(__tscroll(__tc_SF, n, 0), 0, __cputchar);
|
1994-08-18 01:51:41 +04:00
|
|
|
else
|
|
|
|
for (i = 0; i < n; i++)
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_sf, 0, __cputchar);
|
|
|
|
tputs(__tscroll(__tc_cs, 0, (int) __virtscr->maxy), 0,
|
|
|
|
__cputchar);
|
1994-08-18 01:51:41 +04:00
|
|
|
__mvcur(bot, 0, 0, 0, 1);
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_ho, 0, __cputchar);
|
1994-08-18 01:51:41 +04:00
|
|
|
__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. */
|
2000-12-20 00:34:24 +03:00
|
|
|
if (__tc_SF != NULL && top == 0) {
|
1994-08-18 01:51:41 +04:00
|
|
|
__mvcur(oy, ox, bot, 0, 1);
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tscroll(__tc_SF, n, 0), 0, __cputchar);
|
1994-08-18 01:51:41 +04:00
|
|
|
} else
|
2000-12-20 00:34:24 +03:00
|
|
|
if (__tc_DL != NULL) {
|
1999-04-13 18:08:17 +04:00
|
|
|
__mvcur(oy, ox, top, 0, 1);
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tscroll(__tc_DL, n, 0), 0, __cputchar);
|
1999-04-13 18:08:17 +04:00
|
|
|
} else
|
2000-12-20 00:34:24 +03:00
|
|
|
if (__tc_dl != NULL) {
|
1999-04-13 18:08:17 +04:00
|
|
|
__mvcur(oy, ox, top, 0, 1);
|
|
|
|
for (i = 0; i < n; i++)
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_dl, 0, __cputchar);
|
1999-04-13 18:08:17 +04:00
|
|
|
} else
|
2000-12-20 00:34:24 +03:00
|
|
|
if (__tc_sf != NULL && top == 0) {
|
1999-04-13 18:08:17 +04:00
|
|
|
__mvcur(oy, ox, bot, 0, 1);
|
|
|
|
for (i = 0; i < n; i++)
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_sf, 0,
|
|
|
|
__cputchar);
|
1999-04-13 18:08:17 +04:00
|
|
|
} 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);
|
2000-12-20 00:34:24 +03:00
|
|
|
if (__tc_AL != NULL)
|
|
|
|
tputs(__tscroll(__tc_AL, n, 0), 0, __cputchar);
|
1994-08-18 01:51:41 +04:00
|
|
|
else
|
2000-12-20 00:34:24 +03:00
|
|
|
if (__tc_al != NULL)
|
1999-04-13 18:08:17 +04:00
|
|
|
for (i = 0; i < n; i++)
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_al, 0, __cputchar);
|
1999-04-13 18:08:17 +04:00
|
|
|
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
|
|
|
|
*
|
2000-12-20 00:34:24 +03:00
|
|
|
* If cs, ho and SR/sr are set, can use the scrolling region.
|
1994-08-18 01:51:41 +04:00
|
|
|
* See the above comments for details.
|
|
|
|
*/
|
2000-12-20 00:34:24 +03:00
|
|
|
if (__tc_cs != NULL && __tc_ho != NULL && (__tc_SR != NULL ||
|
|
|
|
((__tc_AL == NULL || __tc_DL == NULL || top > 3 ||
|
|
|
|
bot + 3 < __virtscr->maxy) && __tc_sr != NULL))) {
|
|
|
|
tputs(__tscroll(__tc_cs, top, bot + 1), 0, __cputchar);
|
1994-08-18 01:51:41 +04:00
|
|
|
__mvcur(oy, ox, 0, 0, 1);
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_ho, 0, __cputchar);
|
1994-08-18 01:51:41 +04:00
|
|
|
__mvcur(0, 0, top, 0, 1);
|
|
|
|
|
2000-12-20 00:34:24 +03:00
|
|
|
if (__tc_SR != NULL)
|
|
|
|
tputs(__tscroll(__tc_SR, -n, 0), 0, __cputchar);
|
1994-08-18 01:51:41 +04:00
|
|
|
else
|
|
|
|
for (i = n; i < 0; i++)
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_sr, 0, __cputchar);
|
|
|
|
tputs(__tscroll(__tc_cs, 0, (int) __virtscr->maxy), 0,
|
|
|
|
__cputchar);
|
1994-08-18 01:51:41 +04:00
|
|
|
__mvcur(top, 0, 0, 0, 1);
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_ho, 0, __cputchar);
|
1994-08-18 01:51:41 +04:00
|
|
|
__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);
|
2000-12-20 00:34:24 +03:00
|
|
|
if (__tc_SR != NULL && bot == __virtscr->maxy)
|
|
|
|
tputs(__tscroll(__tc_SR, -n, 0), 0, __cputchar);
|
1993-11-09 06:34:01 +03:00
|
|
|
else
|
2000-12-20 00:34:24 +03:00
|
|
|
if (__tc_DL != NULL)
|
|
|
|
tputs(__tscroll(__tc_DL, -n, 0), 0, __cputchar);
|
1999-04-13 18:08:17 +04:00
|
|
|
else
|
2000-12-20 00:34:24 +03:00
|
|
|
if (__tc_dl != NULL)
|
1999-04-13 18:08:17 +04:00
|
|
|
for (i = n; i < 0; i++)
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_dl, 0, __cputchar);
|
1999-04-13 18:08:17 +04:00
|
|
|
else
|
2000-12-20 00:34:24 +03:00
|
|
|
if (__tc_sr != NULL &&
|
|
|
|
bot == __virtscr->maxy)
|
1999-04-13 18:08:17 +04:00
|
|
|
for (i = n; i < 0; i++)
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_sr, 0,
|
|
|
|
__cputchar);
|
1999-04-13 18:08:17 +04:00
|
|
|
else
|
|
|
|
abort();
|
1994-08-18 01:51:41 +04:00
|
|
|
|
|
|
|
/* Scroll the block down. */
|
|
|
|
__mvcur(bot + n + 1, 0, top, 0, 1);
|
2000-12-20 00:34:24 +03:00
|
|
|
if (__tc_AL != NULL)
|
|
|
|
tputs(__tscroll(__tc_AL, -n, 0), 0, __cputchar);
|
1994-08-18 01:51:41 +04:00
|
|
|
else
|
2000-12-20 00:34:24 +03:00
|
|
|
if (__tc_al != NULL)
|
1999-04-13 18:08:17 +04:00
|
|
|
for (i = n; i < 0; i++)
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_al, 0, __cputchar);
|
1999-04-13 18:08:17 +04:00
|
|
|
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
|
|
|
|
|
|
|
/*
|
2000-04-27 04:26:19 +04:00
|
|
|
* __unsetattr --
|
2000-04-16 13:55:16 +04:00
|
|
|
* Unset attributes on curscr. Leave standout, attribute and colour
|
2000-12-20 00:34:24 +03:00
|
|
|
* modes if necessary (!ms). Always leave altcharset (xterm at least
|
2000-04-16 13:55:16 +04:00
|
|
|
* ignores a cursor move if we don't).
|
|
|
|
*/
|
2000-04-27 04:26:19 +04:00
|
|
|
void /* ARGSUSED */
|
|
|
|
__unsetattr(int checkms)
|
2000-04-16 13:55:16 +04:00
|
|
|
{
|
|
|
|
int isms;
|
|
|
|
|
|
|
|
if (checkms)
|
2000-12-20 00:34:24 +03:00
|
|
|
if (!__tc_ms) {
|
2000-04-16 13:55:16 +04:00
|
|
|
isms = 1;
|
|
|
|
} else {
|
|
|
|
isms = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
isms = 1;
|
2000-04-19 02:47:01 +04:00
|
|
|
#ifdef DEBUG
|
2000-12-20 00:34:24 +03:00
|
|
|
__CTRACE("__unsetattr: checkms = %d, ms = %s, wattr = %08x\n",
|
|
|
|
checkms, __tc_ms ? "TRUE" : "FALSE", curscr->wattr);
|
2000-04-19 02:47:01 +04:00
|
|
|
#endif
|
2000-04-16 13:55:16 +04:00
|
|
|
|
2000-04-19 02:47:01 +04:00
|
|
|
/*
|
2000-12-20 00:34:24 +03:00
|
|
|
* Don't leave the screen in standout mode (check against ms). Check
|
2000-04-29 04:42:26 +04:00
|
|
|
* to see if we also turn off underscore, attributes and colour.
|
2000-04-19 02:47:01 +04:00
|
|
|
*/
|
2000-04-16 13:55:16 +04:00
|
|
|
if (curscr->wattr & __STANDOUT && isms) {
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_se, 0, __cputchar);
|
|
|
|
curscr->wattr &= __mask_se;
|
2000-04-16 13:55:16 +04:00
|
|
|
}
|
2000-04-19 02:47:01 +04:00
|
|
|
/*
|
2000-12-20 00:34:24 +03:00
|
|
|
* Don't leave the screen in underscore mode (check against ms).
|
2000-04-28 21:11:51 +04:00
|
|
|
* Check to see if we also turn off attributes. Assume that we
|
|
|
|
* also turn off colour.
|
2000-04-19 02:47:01 +04:00
|
|
|
*/
|
2000-04-16 13:55:16 +04:00
|
|
|
if (curscr->wattr & __UNDERSCORE && isms) {
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_ue, 0, __cputchar);
|
|
|
|
curscr->wattr &= __mask_ue;
|
2000-04-16 13:55:16 +04:00
|
|
|
}
|
2000-04-19 02:47:01 +04:00
|
|
|
/*
|
2000-12-20 00:34:24 +03:00
|
|
|
* Don't leave the screen with attributes set (check against ms).
|
2000-04-28 21:11:51 +04:00
|
|
|
* Assume that also turn off colour.
|
2000-04-19 02:47:01 +04:00
|
|
|
*/
|
|
|
|
if (curscr->wattr & __TERMATTR && isms) {
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_me, 0, __cputchar);
|
|
|
|
curscr->wattr &= __mask_me;
|
2000-04-16 13:55:16 +04:00
|
|
|
}
|
2000-12-20 00:34:24 +03: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) {
|
2000-12-20 00:34:24 +03:00
|
|
|
tputs(__tc_ae, 0, __cputchar);
|
2000-04-16 13:55:16 +04:00
|
|
|
curscr->wattr &= ~__ALTCHARSET;
|
|
|
|
}
|
2000-12-20 00:34:24 +03:00
|
|
|
/* Don't leave the screen with colour set (check against ms). */
|
2002-08-04 20:43:04 +04:00
|
|
|
if (__using_color && isms)
|
|
|
|
__unset_color(curscr);
|
2000-04-16 13:55:16 +04:00
|
|
|
}
|