1998-03-01 12:21:12 +08:00
|
|
|
/****************************************************************************
|
2006-12-18 12:32:42 +08:00
|
|
|
* Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
|
1998-03-01 12:21:12 +08:00
|
|
|
* *
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a *
|
|
|
|
* copy of this software and associated documentation files (the *
|
|
|
|
* "Software"), to deal in the Software without restriction, including *
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish, *
|
|
|
|
* distribute, distribute with modifications, sublicense, and/or sell *
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is *
|
|
|
|
* furnished to do so, subject to the following conditions: *
|
|
|
|
* *
|
|
|
|
* The above copyright notice and this permission notice shall be included *
|
|
|
|
* in all copies or substantial portions of the Software. *
|
|
|
|
* *
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
|
|
|
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
|
|
|
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
|
|
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
|
|
|
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
|
|
|
* *
|
|
|
|
* Except as contained in this notice, the name(s) of the above copyright *
|
|
|
|
* holders shall not be used in advertising or otherwise to promote the *
|
|
|
|
* sale, use or other dealings in this Software without prior written *
|
|
|
|
* authorization. *
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
|
|
|
|
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
|
2005-10-10 02:41:57 +08:00
|
|
|
* and: Thomas E. Dickey 1996-on *
|
1998-03-01 12:21:12 +08:00
|
|
|
****************************************************************************/
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* lib_refresh.c
|
|
|
|
*
|
1998-03-01 12:21:12 +08:00
|
|
|
* The routines wrefresh() and wnoutrefresh().
|
1997-05-15 12:00:00 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <curses.priv.h>
|
|
|
|
|
2006-12-18 12:32:42 +08:00
|
|
|
MODULE_ID("$Id: lib_refresh.c,v 1.34 2006/05/27 19:21:19 tom Exp $")
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
NCURSES_EXPORT(int)
|
2000-07-09 10:46:08 +08:00
|
|
|
wrefresh(WINDOW *win)
|
1997-05-15 12:00:00 +08:00
|
|
|
{
|
2000-07-09 10:46:08 +08:00
|
|
|
int code;
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2000-07-09 10:46:08 +08:00
|
|
|
T((T_CALLED("wrefresh(%p)"), win));
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2005-10-10 02:41:57 +08:00
|
|
|
if (win == 0) {
|
|
|
|
code = ERR;
|
|
|
|
} else if (win == curscr) {
|
2000-07-09 10:46:08 +08:00
|
|
|
curscr->_clear = TRUE;
|
|
|
|
code = doupdate();
|
|
|
|
} else if ((code = wnoutrefresh(win)) == OK) {
|
|
|
|
if (win->_clear)
|
|
|
|
newscr->_clear = TRUE;
|
|
|
|
code = doupdate();
|
1997-05-15 12:00:00 +08:00
|
|
|
/*
|
2000-07-09 10:46:08 +08:00
|
|
|
* Reset the clearok() flag in case it was set for the special
|
|
|
|
* case in hardscroll.c (if we don't reset it here, we'll get 2
|
|
|
|
* refreshes because the flag is copied from stdscr to newscr).
|
|
|
|
* Resetting the flag shouldn't do any harm, anyway.
|
1997-05-15 12:00:00 +08:00
|
|
|
*/
|
2000-07-09 10:46:08 +08:00
|
|
|
win->_clear = FALSE;
|
|
|
|
}
|
|
|
|
returnCode(code);
|
|
|
|
}
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
NCURSES_EXPORT(int)
|
2000-07-09 10:46:08 +08:00
|
|
|
wnoutrefresh(WINDOW *win)
|
|
|
|
{
|
|
|
|
NCURSES_SIZE_T limit_x;
|
|
|
|
NCURSES_SIZE_T i, j;
|
|
|
|
NCURSES_SIZE_T begx;
|
|
|
|
NCURSES_SIZE_T begy;
|
|
|
|
NCURSES_SIZE_T m, n;
|
2002-10-13 11:35:53 +08:00
|
|
|
#if USE_SCROLL_HINTS
|
2000-07-09 10:46:08 +08:00
|
|
|
bool wide;
|
2002-10-13 11:35:53 +08:00
|
|
|
#endif
|
2000-07-09 10:46:08 +08:00
|
|
|
|
|
|
|
T((T_CALLED("wnoutrefresh(%p)"), win));
|
|
|
|
#ifdef TRACE
|
|
|
|
if (_nc_tracing & TRACE_UPDATE)
|
|
|
|
_tracedump("...win", win);
|
|
|
|
#endif /* TRACE */
|
1999-10-24 12:32:42 +08:00
|
|
|
|
2000-07-09 10:46:08 +08:00
|
|
|
/*
|
|
|
|
* This function will break badly if we try to refresh a pad.
|
|
|
|
*/
|
|
|
|
if ((win == 0)
|
|
|
|
|| (win->_flags & _ISPAD))
|
|
|
|
returnCode(ERR);
|
|
|
|
|
|
|
|
/* put them here so "win == 0" won't break our code */
|
|
|
|
begx = win->_begx;
|
|
|
|
begy = win->_begy;
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
newscr->_nc_bkgd = win->_nc_bkgd;
|
2006-12-18 12:32:42 +08:00
|
|
|
WINDOW_ATTRS(newscr) = WINDOW_ATTRS(win);
|
2000-07-09 10:46:08 +08:00
|
|
|
|
|
|
|
/* merge in change information from all subwindows of this window */
|
|
|
|
wsyncdown(win);
|
|
|
|
|
2002-10-13 11:35:53 +08:00
|
|
|
#if USE_SCROLL_HINTS
|
2000-07-09 10:46:08 +08:00
|
|
|
/*
|
|
|
|
* For pure efficiency, we'd want to transfer scrolling information
|
|
|
|
* from the window to newscr whenever the window is wide enough that
|
|
|
|
* its update will dominate the cost of the update for the horizontal
|
|
|
|
* band of newscr that it occupies. Unfortunately, this threshold
|
|
|
|
* tends to be complex to estimate, and in any case scrolling the
|
|
|
|
* whole band and rewriting the parts outside win's image would look
|
|
|
|
* really ugly. So. What we do is consider the window "wide" if it
|
|
|
|
* either (a) occupies the whole width of newscr, or (b) occupies
|
|
|
|
* all but at most one column on either vertical edge of the screen
|
|
|
|
* (this caters to fussy people who put boxes around full-screen
|
|
|
|
* windows). Note that changing this formula will not break any code,
|
|
|
|
* merely change the costs of various update cases.
|
|
|
|
*/
|
|
|
|
wide = (begx <= 1 && win->_maxx >= (newscr->_maxx - 1));
|
2002-10-13 11:35:53 +08:00
|
|
|
#endif
|
2000-07-09 10:46:08 +08:00
|
|
|
|
|
|
|
win->_flags &= ~_HASMOVED;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Microtweaking alert! This double loop is one of the genuine
|
|
|
|
* hot spots in the code. Even gcc doesn't seem to do enough
|
|
|
|
* common-subexpression chunking to make it really tense,
|
|
|
|
* so we'll force the issue.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* limit(n) */
|
|
|
|
limit_x = win->_maxx;
|
|
|
|
/* limit(j) */
|
2002-10-13 11:35:53 +08:00
|
|
|
if (limit_x > newscr->_maxx - begx)
|
|
|
|
limit_x = newscr->_maxx - begx;
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2000-07-09 10:46:08 +08:00
|
|
|
for (i = 0, m = begy + win->_yoffset;
|
2002-10-13 11:35:53 +08:00
|
|
|
i <= win->_maxy && m <= newscr->_maxy;
|
|
|
|
i++, m++) {
|
2000-07-09 10:46:08 +08:00
|
|
|
register struct ldat *nline = &newscr->_line[m];
|
|
|
|
register struct ldat *oline = &win->_line[i];
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2000-07-09 10:46:08 +08:00
|
|
|
if (oline->firstchar != _NOCHANGE) {
|
|
|
|
int last = oline->lastchar;
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2000-07-09 10:46:08 +08:00
|
|
|
if (last > limit_x)
|
|
|
|
last = limit_x;
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2000-07-09 10:46:08 +08:00
|
|
|
for (j = oline->firstchar, n = j + begx; j <= last; j++, n++) {
|
2002-10-13 11:35:53 +08:00
|
|
|
if (!CharEq(oline->text[j], nline->text[n])) {
|
2000-07-09 10:46:08 +08:00
|
|
|
nline->text[n] = oline->text[j];
|
|
|
|
CHANGED_CELL(nline, n);
|
1997-05-15 12:00:00 +08:00
|
|
|
}
|
2000-07-09 10:46:08 +08:00
|
|
|
}
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2000-07-09 10:46:08 +08:00
|
|
|
}
|
1998-03-01 12:21:12 +08:00
|
|
|
#if USE_SCROLL_HINTS
|
2000-07-09 10:46:08 +08:00
|
|
|
if (wide) {
|
|
|
|
int oind = oline->oldindex;
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2000-07-09 10:46:08 +08:00
|
|
|
nline->oldindex = (oind == _NEWINDEX) ? _NEWINDEX : begy + oind
|
|
|
|
+ win->_yoffset;
|
|
|
|
}
|
1998-03-01 12:21:12 +08:00
|
|
|
#endif /* USE_SCROLL_HINTS */
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2000-07-09 10:46:08 +08:00
|
|
|
oline->firstchar = oline->lastchar = _NOCHANGE;
|
|
|
|
if_USE_SCROLL_HINTS(oline->oldindex = i);
|
|
|
|
}
|
1997-05-15 12:00:00 +08:00
|
|
|
|
2000-07-09 10:46:08 +08:00
|
|
|
if (win->_clear) {
|
|
|
|
win->_clear = FALSE;
|
|
|
|
newscr->_clear = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!win->_leaveok) {
|
|
|
|
newscr->_cury = win->_cury + win->_begy + win->_yoffset;
|
|
|
|
newscr->_curx = win->_curx + win->_begx;
|
|
|
|
}
|
|
|
|
newscr->_leaveok = win->_leaveok;
|
1997-05-15 12:00:00 +08:00
|
|
|
|
|
|
|
#ifdef TRACE
|
2000-07-09 10:46:08 +08:00
|
|
|
if (_nc_tracing & TRACE_UPDATE)
|
|
|
|
_tracedump("newscr", newscr);
|
1997-05-15 12:00:00 +08:00
|
|
|
#endif /* TRACE */
|
2000-07-09 10:46:08 +08:00
|
|
|
returnCode(OK);
|
1997-05-15 12:00:00 +08:00
|
|
|
}
|