X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Flib_refresh.c;h=5d8eab542b8135e9db2eec7a5209ac12ef0dd98d;hp=88e3b75a56a1ac195af5f9b5a4b57d7ac2d16028;hb=55ccd2b959766810cf7db8d1c4462f338ce0afc8;hpb=0eb88fc5281804773e2a0c7a488a4452463535ce diff --git a/ncurses/base/lib_refresh.c b/ncurses/base/lib_refresh.c index 88e3b75a..5d8eab54 100644 --- a/ncurses/base/lib_refresh.c +++ b/ncurses/base/lib_refresh.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998 Free Software Foundation, Inc. * + * Copyright (c) 1998-2002,2005 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,10 +29,9 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * ****************************************************************************/ - - /* * lib_refresh.c * @@ -42,142 +41,150 @@ #include -MODULE_ID("$Id: lib_refresh.c,v 1.24 1999/07/31 11:36:37 juergen Exp $") +MODULE_ID("$Id: lib_refresh.c,v 1.33 2005/04/09 15:20:58 tom Exp $") -int wrefresh(WINDOW *win) +NCURSES_EXPORT(int) +wrefresh(WINDOW *win) { -int code; - - T((T_CALLED("wrefresh(%p)"), win)); - - if (win == curscr) { - curscr->_clear = TRUE; - code = doupdate(); - } else if ((code = wnoutrefresh(win)) == OK) { - if (win->_clear) - newscr->_clear = TRUE; - code = doupdate(); - /* - * 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. - */ - win->_clear = FALSE; - } - returnCode(code); + int code; + + T((T_CALLED("wrefresh(%p)"), win)); + + if (win == 0) { + code = ERR; + } else if (win == curscr) { + curscr->_clear = TRUE; + code = doupdate(); + } else if ((code = wnoutrefresh(win)) == OK) { + if (win->_clear) + newscr->_clear = TRUE; + code = doupdate(); + /* + * 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. + */ + win->_clear = FALSE; + } + returnCode(code); } -int wnoutrefresh(WINDOW *win) +NCURSES_EXPORT(int) +wnoutrefresh(WINDOW *win) { -short limit_x; -short i, j; -short begx; -short begy; -short m, n; -bool wide; - - T((T_CALLED("wnoutrefresh(%p)"), win)); + NCURSES_SIZE_T limit_x; + NCURSES_SIZE_T i, j; + NCURSES_SIZE_T begx; + NCURSES_SIZE_T begy; + NCURSES_SIZE_T m, n; +#if USE_SCROLL_HINTS + bool wide; +#endif + + T((T_CALLED("wnoutrefresh(%p)"), win)); #ifdef TRACE - if (_nc_tracing & TRACE_UPDATE) - _tracedump("...win", win); + if (_nc_tracing & TRACE_UPDATE) + _tracedump("...win", win); #endif /* TRACE */ - /* - * 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; + /* + * This function will break badly if we try to refresh a pad. + */ + if ((win == 0) + || (win->_flags & _ISPAD)) + returnCode(ERR); - newscr->_bkgd = win->_bkgd; - newscr->_attrs = win->_attrs; + /* put them here so "win == 0" won't break our code */ + begx = win->_begx; + begy = win->_begy; - /* merge in change information from all subwindows of this window */ - wsyncdown(win); + newscr->_nc_bkgd = win->_nc_bkgd; + newscr->_attrs = win->_attrs; - /* - * 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)); - - 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) */ - if (limit_x > win->_maxx) - limit_x = win->_maxx; - - for (i = 0, m = begy + win->_yoffset; - i <= win->_maxy && m <= newscr->_maxy; - i++, m++) { - register struct ldat *nline = &newscr->_line[m]; - register struct ldat *oline = &win->_line[i]; - - if (oline->firstchar != _NOCHANGE) { - int last = oline->lastchar; - - if (last > limit_x) - last = limit_x; - - for (j = oline->firstchar, n = j + begx; j <= last; j++, n++) { - if (oline->text[j] != nline->text[n]) { - nline->text[n] = oline->text[j]; - CHANGED_CELL(nline, n); - } - } + /* merge in change information from all subwindows of this window */ + wsyncdown(win); +#if USE_SCROLL_HINTS + /* + * 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)); +#endif + + 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) */ + if (limit_x > newscr->_maxx - begx) + limit_x = newscr->_maxx - begx; + + for (i = 0, m = begy + win->_yoffset; + i <= win->_maxy && m <= newscr->_maxy; + i++, m++) { + register struct ldat *nline = &newscr->_line[m]; + register struct ldat *oline = &win->_line[i]; + + if (oline->firstchar != _NOCHANGE) { + int last = oline->lastchar; + + if (last > limit_x) + last = limit_x; + + for (j = oline->firstchar, n = j + begx; j <= last; j++, n++) { + if (!CharEq(oline->text[j], nline->text[n])) { + nline->text[n] = oline->text[j]; + CHANGED_CELL(nline, n); } + } + } #if USE_SCROLL_HINTS - if (wide) { - int oind = oline->oldindex; + if (wide) { + int oind = oline->oldindex; - nline->oldindex = (oind == _NEWINDEX) ? _NEWINDEX : begy + oind + win->_yoffset; - } + nline->oldindex = (oind == _NEWINDEX) ? _NEWINDEX : begy + oind + + win->_yoffset; + } #endif /* USE_SCROLL_HINTS */ - oline->firstchar = oline->lastchar = _NOCHANGE; - if_USE_SCROLL_HINTS(oline->oldindex = i); - } + oline->firstchar = oline->lastchar = _NOCHANGE; + if_USE_SCROLL_HINTS(oline->oldindex = i); + } - if (win->_clear) { - win->_clear = FALSE; - newscr->_clear = TRUE; - } + 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; - if (! win->_leaveok) { - newscr->_cury = win->_cury + win->_begy + win->_yoffset; - newscr->_curx = win->_curx + win->_begx; - } - newscr->_leaveok = win->_leaveok; - #ifdef TRACE - if (_nc_tracing & TRACE_UPDATE) - _tracedump("newscr", newscr); + if (_nc_tracing & TRACE_UPDATE) + _tracedump("newscr", newscr); #endif /* TRACE */ - returnCode(OK); + returnCode(OK); }