]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_refresh.c
ncurses 6.4 - patch 20240420
[ncurses.git] / ncurses / base / lib_refresh.c
index 25b9b40a0fe932607100748b9df0ad50ce137d94..bcaa4624b8a938fe6f3f12924a2ae8d3580e9844 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2007,2009 Free Software Foundation, Inc.              *
+ * Copyright 2020-2021,2023 Thomas E. Dickey                                *
+ * Copyright 1998-2010,2011 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            *
@@ -42,7 +43,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_refresh.c,v 1.42 2009/06/06 20:27:39 tom Exp $")
+MODULE_ID("$Id: lib_refresh.c,v 1.48 2023/05/27 20:13:10 tom Exp $")
 
 NCURSES_EXPORT(int)
 wrefresh(WINDOW *win)
@@ -52,7 +53,7 @@ wrefresh(WINDOW *win)
     SCREEN *SP_PARM = _nc_screen_of(win);
 #endif
 
-    T((T_CALLED("wrefresh(%p)"), win));
+    T((T_CALLED("wrefresh(%p)"), (void *) win));
 
     if (win == 0) {
        code = ERR;
@@ -77,11 +78,11 @@ wrefresh(WINDOW *win)
 NCURSES_EXPORT(int)
 wnoutrefresh(WINDOW *win)
 {
-    NCURSES_SIZE_T limit_x;
-    NCURSES_SIZE_T src_row, src_col;
-    NCURSES_SIZE_T begx;
-    NCURSES_SIZE_T begy;
-    NCURSES_SIZE_T dst_row, dst_col;
+    int limit_x;
+    int src_row, src_col;
+    int begx;
+    int begy;
+    int dst_row, dst_col;
 #if USE_SCROLL_HINTS
     bool wide;
 #endif
@@ -89,7 +90,23 @@ wnoutrefresh(WINDOW *win)
     SCREEN *SP_PARM = _nc_screen_of(win);
 #endif
 
-    T((T_CALLED("wnoutrefresh(%p)"), win));
+    T((T_CALLED("wnoutrefresh(%p)"), (void *) win));
+
+    if (win == NULL)
+       returnCode(ERR);
+
+    /*
+     * Handle pads as a special case.
+     */
+    if (IS_PAD(win)) {
+       returnCode(pnoutrefresh(win,
+                               win->_pad._pad_y,
+                               win->_pad._pad_x,
+                               win->_pad._pad_top,
+                               win->_pad._pad_left,
+                               win->_pad._pad_bottom,
+                               win->_pad._pad_right));
+    }
 #ifdef TRACE
     if (USE_TRACEF(TRACE_UPDATE)) {
        _tracedump("...win", win);
@@ -97,13 +114,6 @@ wnoutrefresh(WINDOW *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;
@@ -150,8 +160,8 @@ wnoutrefresh(WINDOW *win)
     for (src_row = 0, dst_row = begy + win->_yoffset;
         src_row <= win->_maxy && dst_row <= NewScreen(SP_PARM)->_maxy;
         src_row++, dst_row++) {
-       register struct ldat *nline = &(NewScreen(SP_PARM)->_line[dst_row]);
-       register struct ldat *oline = &win->_line[src_row];
+       struct ldat *nline = &(NewScreen(SP_PARM)->_line[dst_row]);
+       struct ldat *oline = &win->_line[src_row];
 
        if (oline->firstchar != _NOCHANGE) {
            int last_src = oline->lastchar;
@@ -163,7 +173,7 @@ wnoutrefresh(WINDOW *win)
            dst_col = src_col + begx;
 
            if_WIDEC({
-               register int j;
+               int j;
 
                /*
                 * Ensure that we will copy complete multi-column characters
@@ -198,13 +208,12 @@ wnoutrefresh(WINDOW *win)
            });
 
            if_WIDEC({
-               static cchar_t blank = BLANK;
                int last_dst = begx + ((last_src < win->_maxx)
                                       ? last_src
                                       : win->_maxx);
                int fix_left = dst_col;
                int fix_right = last_dst;
-               register int j;
+               int j;
 
                /*
                 * Check for boundary cases where we may overwrite part of a
@@ -244,6 +253,7 @@ wnoutrefresh(WINDOW *win)
                 */
                if (fix_left < dst_col || fix_right > last_dst) {
                    for (j = fix_left; j <= fix_right; ++j) {
+                       static cchar_t blank = BLANK;
                        nline->text[j] = blank;
                        CHANGED_CELL(nline, j);
                    }
@@ -281,8 +291,9 @@ wnoutrefresh(WINDOW *win)
     }
 
     if (!win->_leaveok) {
-       NewScreen(SP_PARM)->_cury = win->_cury + win->_begy + win->_yoffset;
-       NewScreen(SP_PARM)->_curx = win->_curx + win->_begx;
+       NewScreen(SP_PARM)->_cury = (NCURSES_SIZE_T) (win->_cury +
+                                                     win->_begy + win->_yoffset);
+       NewScreen(SP_PARM)->_curx = (NCURSES_SIZE_T) (win->_curx + win->_begx);
     }
     NewScreen(SP_PARM)->_leaveok = win->_leaveok;