]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tty/tty_update.c
ncurses 5.9 - patch 20121222
[ncurses.git] / ncurses / tty / tty_update.c
index 6de4ecb2f8002db920ce0afdf32f52f7fb775dd1..01feddd9183ae4983d4f21baaaac9c68cf7d4fd4 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2011,2012 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -82,7 +82,7 @@
 
 #include <ctype.h>
 
 
 #include <ctype.h>
 
-MODULE_ID("$Id: tty_update.c,v 1.257 2009/06/06 20:26:16 tom Exp $")
+MODULE_ID("$Id: tty_update.c,v 1.273 2012/12/22 21:38:17 tom Exp $")
 
 /*
  * This define controls the line-breakout optimization.  Every once in a
 
 /*
  * This define controls the line-breakout optimization.  Every once in a
@@ -193,12 +193,14 @@ static NCURSES_INLINE void
 GoTo(NCURSES_SP_DCLx int const row, int const col)
 {
     TR(TRACE_MOVE, ("GoTo(%p, %d, %d) from (%d, %d)",
 GoTo(NCURSES_SP_DCLx int const row, int const col)
 {
     TR(TRACE_MOVE, ("GoTo(%p, %d, %d) from (%d, %d)",
-                   SP_PARM, row, col, SP_PARM->_cursrow, SP_PARM->_curscol));
+                   (void *) SP_PARM, row, col, SP_PARM->_cursrow, SP_PARM->_curscol));
 
     position_check(SP_PARM, SP_PARM->_cursrow, SP_PARM->_curscol, "GoTo");
 
 
     position_check(SP_PARM, SP_PARM->_cursrow, SP_PARM->_curscol, "GoTo");
 
-    NCURSES_SP_NAME(mvcur) (NCURSES_SP_ARGx SP_PARM->_cursrow,
-                           SP_PARM->_curscol, row, col);
+    TINFO_MVCUR(NCURSES_SP_ARGx
+               SP_PARM->_cursrow,
+               SP_PARM->_curscol,
+               row, col);
     position_check(SP_PARM, SP_PARM->_cursrow, SP_PARM->_curscol, "GoTo2");
 }
 
     position_check(SP_PARM, SP_PARM->_cursrow, SP_PARM->_curscol, "GoTo2");
 }
 
@@ -207,7 +209,9 @@ PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch)
 {
     int chlen = 1;
     NCURSES_CH_T my_ch;
 {
     int chlen = 1;
     NCURSES_CH_T my_ch;
+#if USE_WIDEC_SUPPORT
     PUTC_DATA;
     PUTC_DATA;
+#endif
     NCURSES_CH_T tilde;
     NCURSES_CH_T attr = CHDEREF(ch);
 
     NCURSES_CH_T tilde;
     NCURSES_CH_T attr = CHDEREF(ch);
 
@@ -274,6 +278,11 @@ PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch)
            && SP_PARM->_screen_acs_map[CharOf(my_ch)]) {
            RemAttr(attr, A_ALTCHARSET);
            my_ch = _nc_wacs[CharOf(my_ch)];
            && SP_PARM->_screen_acs_map[CharOf(my_ch)]) {
            RemAttr(attr, A_ALTCHARSET);
            my_ch = _nc_wacs[CharOf(my_ch)];
+       } else if (SP_PARM->_screen_unicode
+                  && !SP_PARM->_screen_acs_map[CharOf(my_ch)]
+                  && _nc_wacs[CharOf(my_ch)].chars[0]) {
+           RemAttr(attr, A_ALTCHARSET);
+           my_ch = _nc_wacs[CharOf(my_ch)];
        }
 #endif
        /*
        }
 #endif
        /*
@@ -286,13 +295,12 @@ PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch)
            int j = CharOfD(ch);
            chtype temp = UChar(SP_PARM->_acs_map[j]);
 
            int j = CharOfD(ch);
            chtype temp = UChar(SP_PARM->_acs_map[j]);
 
-           if (!(SP_PARM->_screen_acs_map[j])) {
+           if (temp != 0) {
+               SetChar(my_ch, temp, AttrOf(attr));
+           } else {
+               my_ch = CHDEREF(ch);
                RemAttr(attr, A_ALTCHARSET);
                RemAttr(attr, A_ALTCHARSET);
-               if (temp == 0)
-                   temp = ' ';
            }
            }
-           if (temp != 0)
-               SetChar(my_ch, temp, AttrOf(attr));
        }
        ch = CHREF(my_ch);
     }
        }
        ch = CHREF(my_ch);
     }
@@ -302,18 +310,10 @@ PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch)
     }
 
     UpdateAttrs(SP_PARM, attr);
     }
 
     UpdateAttrs(SP_PARM, attr);
+    PUTC(CHDEREF(ch));
 #if !USE_WIDEC_SUPPORT
 #if !USE_WIDEC_SUPPORT
-    /* FIXME - we do this special case for signal handling, should see how to
-     * make it work for wide characters.
-     */
-    if (SP_PARM->_outch != 0) {
-       SP_PARM->_outch(NCURSES_SP_ARGx UChar(ch));
-    } else
+    COUNT_OUTCHARS(1);
 #endif
 #endif
-    {
-       PUTC(CHDEREF(ch), SP_PARM->_ofp);       /* macro's fastest... */
-       COUNT_OUTCHARS(1);
-    }
     SP_PARM->_curscol += chlen;
     if (char_padding) {
        TPUTS_TRACE("char_padding");
     SP_PARM->_curscol += chlen;
     if (char_padding) {
        TPUTS_TRACE("char_padding");
@@ -340,7 +340,7 @@ check_pending(NCURSES_SP_DCL0)
        struct pollfd fds[1];
        fds[0].fd = SP_PARM->_checkfd;
        fds[0].events = POLLIN;
        struct pollfd fds[1];
        fds[0].fd = SP_PARM->_checkfd;
        fds[0].events = POLLIN;
-       if (poll(fds, 1, 0) > 0) {
+       if (poll(fds, (size_t) 1, 0) > 0) {
            have_pending = TRUE;
        }
 #elif defined(__BEOS__)
            have_pending = TRUE;
        }
 #elif defined(__BEOS__)
@@ -495,7 +495,9 @@ can_clear_with(NCURSES_SP_DCLx ARG_CH_T ch)
            return FALSE;
        if ((pair = GetPair(CHDEREF(ch))) != 0) {
            short fg, bg;
            return FALSE;
        if ((pair = GetPair(CHDEREF(ch))) != 0) {
            short fg, bg;
-           NCURSES_SP_NAME(pair_content) (NCURSES_SP_ARGx pair, &fg, &bg);
+           NCURSES_SP_NAME(pair_content) (NCURSES_SP_ARGx
+                                          (short) pair,
+                                          &fg, &bg);
            if (fg != C_MASK || bg != C_MASK)
                return FALSE;
        }
            if (fg != C_MASK || bg != C_MASK)
                return FALSE;
        }
@@ -626,7 +628,10 @@ PutRange(NCURSES_SP_DCLx
     int i, j, same;
 
     TR(TRACE_CHARPUT, ("PutRange(%p, %p, %p, %d, %d, %d)",
     int i, j, same;
 
     TR(TRACE_CHARPUT, ("PutRange(%p, %p, %p, %d, %d, %d)",
-                      SP_PARM, otext, ntext, row, first, last));
+                      (void *) SP_PARM,
+                      (const void *) otext,
+                      (const void *) ntext,
+                      row, first, last));
 
     if (otext != ntext
        && (last - first + 1) > SP_PARM->_inline_cost) {
 
     if (otext != ntext
        && (last - first + 1) > SP_PARM->_inline_cost) {
@@ -660,7 +665,7 @@ PutRange(NCURSES_SP_DCLx
                if_USE_SCROLL_HINTS(win->_line[row].oldindex = row)
 
 NCURSES_EXPORT(int)
                if_USE_SCROLL_HINTS(win->_line[row].oldindex = row)
 
 NCURSES_EXPORT(int)
-NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0)
+TINFO_DOUPDATE(NCURSES_SP_DCL0)
 {
     int i;
     int nonempty;
 {
     int i;
     int nonempty;
@@ -668,7 +673,10 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0)
     struct tms before, after;
 #endif /* USE_TRACE_TIMES */
 
     struct tms before, after;
 #endif /* USE_TRACE_TIMES */
 
-    T((T_CALLED("_nc_tinfo:doupdate(%p)"), SP_PARM));
+    T((T_CALLED("_nc_tinfo:doupdate(%p)"), (void *) SP_PARM));
+
+    if (SP_PARM == 0)
+       returnCode(ERR);
 
 #if !USE_REENTRANT
     /*
 
 #if !USE_REENTRANT
     /*
@@ -1003,11 +1011,11 @@ NCURSES_SP_NAME(doupdate) (NCURSES_SP_DCL0)
     returnCode(OK);
 }
 
     returnCode(OK);
 }
 
-#if NCURSES_SP_FUNCS
+#if NCURSES_SP_FUNCS && !defined(USE_TERM_DRIVER)
 NCURSES_EXPORT(int)
 doupdate(void)
 {
 NCURSES_EXPORT(int)
 doupdate(void)
 {
-    return NCURSES_SP_NAME(doupdate) (CURRENT_SCREEN);
+    return TINFO_DOUPDATE(CURRENT_SCREEN);
 }
 #endif
 
 }
 #endif
 
@@ -1069,11 +1077,11 @@ ClrUpdate(NCURSES_SP_DCL0)
 */
 
 static void
 */
 
 static void
-ClrToEOL(NCURSES_SP_DCLx NCURSES_CH_T blank, bool needclear)
+ClrToEOL(NCURSES_SP_DCLx NCURSES_CH_T blank, int needclear)
 {
     int j;
 
 {
     int j;
 
-    if (SP_PARM != 0 && CurScreen(SP_PARM) != 0
+    if (CurScreen(SP_PARM) != 0
        && SP_PARM->_cursrow >= 0) {
        for (j = SP_PARM->_curscol; j < screen_columns(SP_PARM); j++) {
            if (j >= 0) {
        && SP_PARM->_cursrow >= 0) {
        for (j = SP_PARM->_curscol; j < screen_columns(SP_PARM); j++) {
            if (j >= 0) {
@@ -1086,8 +1094,6 @@ ClrToEOL(NCURSES_SP_DCLx NCURSES_CH_T blank, bool needclear)
                }
            }
        }
                }
            }
        }
-    } else {
-       needclear = TRUE;
     }
 
     if (needclear) {
     }
 
     if (needclear) {
@@ -1114,9 +1120,6 @@ ClrToEOS(NCURSES_SP_DCLx NCURSES_CH_T blank)
 {
     int row, col;
 
 {
     int row, col;
 
-    if (0 == SP_PARM)
-       return;
-
     row = SP_PARM->_cursrow;
     col = SP_PARM->_curscol;
 
     row = SP_PARM->_cursrow;
     col = SP_PARM->_curscol;
 
@@ -1199,7 +1202,7 @@ ClrBottom(NCURSES_SP_DCLx int total)
 **     TransformLine(lineno)
 **
 **     Transform the given line in curscr to the one in newscr, using
 **     TransformLine(lineno)
 **
 **     Transform the given line in curscr to the one in newscr, using
-**     Insert/Delete Character if _nc_idcok && has_ic().
+**     Insert/Delete Character if idcok && has_ic().
 **
 **             firstChar = position of first different character in line
 **             oLastChar = position of last different character in old line
 **
 **             firstChar = position of first different character in line
 **             oLastChar = position of last different character in old line
@@ -1222,7 +1225,7 @@ TransformLine(NCURSES_SP_DCLx int const lineno)
     int n;
     bool attrchanged = FALSE;
 
     int n;
     bool attrchanged = FALSE;
 
-    TR(TRACE_UPDATE, (T_CALLED("TransformLine(%p, %d)"), SP_PARM, lineno));
+    TR(TRACE_UPDATE, (T_CALLED("TransformLine(%p, %d)"), (void *) SP_PARM, lineno));
 
     /* copy new hash value to old one */
     if (SP_PARM->oldhash && SP_PARM->newhash)
 
     /* copy new hash value to old one */
     if (SP_PARM->oldhash && SP_PARM->newhash)
@@ -1408,7 +1411,7 @@ TransformLine(NCURSES_SP_DCLx int const lineno)
                         nLastChar);
                memcpy(oldLine + firstChar,
                       newLine + firstChar,
                         nLastChar);
                memcpy(oldLine + firstChar,
                       newLine + firstChar,
-                      (nLastChar - firstChar + 1) * sizeof(NCURSES_CH_T));
+                      (unsigned) (nLastChar - firstChar + 1) * sizeof(NCURSES_CH_T));
            }
            TR(TRACE_UPDATE, (T_RETURN("")));
            return;
            }
            TR(TRACE_UPDATE, (T_RETURN("")));
            return;
@@ -1530,7 +1533,7 @@ TransformLine(NCURSES_SP_DCLx int const lineno)
     if (screen_columns(SP_PARM) > firstChar)
        memcpy(oldLine + firstChar,
               newLine + firstChar,
     if (screen_columns(SP_PARM) > firstChar)
        memcpy(oldLine + firstChar,
               newLine + firstChar,
-              (screen_columns(SP_PARM) - firstChar) * sizeof(NCURSES_CH_T));
+              (unsigned) (screen_columns(SP_PARM) - firstChar) * sizeof(NCURSES_CH_T));
     TR(TRACE_UPDATE, (T_RETURN("")));
     return;
 }
     TR(TRACE_UPDATE, (T_RETURN("")));
     return;
 }
@@ -1554,7 +1557,7 @@ ClearScreen(NCURSES_SP_DCLx NCURSES_CH_T blank)
     if (SP_PARM->_coloron
        && !SP_PARM->_default_color) {
        NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx
     if (SP_PARM->_coloron
        && !SP_PARM->_default_color) {
        NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx
-                                      GET_SCREEN_PAIR(SP_PARM),
+                                      (short) GET_SCREEN_PAIR(SP_PARM),
                                       0,
                                       FALSE,
                                       NCURSES_SP_NAME(_nc_outch));
                                       0,
                                       FALSE,
                                       NCURSES_SP_NAME(_nc_outch));
@@ -1621,7 +1624,9 @@ ClearScreen(NCURSES_SP_DCLx NCURSES_CH_T blank)
 static void
 InsStr(NCURSES_SP_DCLx NCURSES_CH_T * line, int count)
 {
 static void
 InsStr(NCURSES_SP_DCLx NCURSES_CH_T * line, int count)
 {
-    TR(TRACE_UPDATE, ("InsStr(%p, %p,%d) called", SP_PARM, line, count));
+    TR(TRACE_UPDATE, ("InsStr(%p, %p,%d) called",
+                     (void *) SP_PARM,
+                     (void *) line, count));
 
     /* Prefer parm_ich as it has the smallest cost - no need to shift
      * the whole line on each character. */
 
     /* Prefer parm_ich as it has the smallest cost - no need to shift
      * the whole line on each character. */
@@ -1680,7 +1685,7 @@ DelChar(NCURSES_SP_DCLx int count)
     int n;
 
     TR(TRACE_UPDATE, ("DelChar(%p, %d) called, position = (%ld,%ld)",
     int n;
 
     TR(TRACE_UPDATE, ("DelChar(%p, %d) called, position = (%ld,%ld)",
-                     SP_PARM, count,
+                     (void *) SP_PARM, count,
                      (long) NewScreen(SP_PARM)->_cury,
                      (long) NewScreen(SP_PARM)->_curx));
 
                      (long) NewScreen(SP_PARM)->_cury,
                      (long) NewScreen(SP_PARM)->_curx));
 
@@ -1937,7 +1942,8 @@ NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_DCLx
     bool cursor_saved = FALSE;
     int res;
 
     bool cursor_saved = FALSE;
     int res;
 
-    TR(TRACE_MOVE, ("_nc_scrolln(%p, %d, %d, %d, %d)", SP_PARM, n, top, bot, maxy));
+    TR(TRACE_MOVE, ("_nc_scrolln(%p, %d, %d, %d, %d)",
+                   (void *) SP_PARM, n, top, bot, maxy));
 
     if (!IsValidScreen(SP_PARM))
        return (ERR);
 
     if (!IsValidScreen(SP_PARM))
        return (ERR);
@@ -2056,7 +2062,10 @@ NCURSES_SP_NAME(_nc_scrolln) (NCURSES_SP_DCLx
     if (res == ERR)
        return (ERR);
 
     if (res == ERR)
        return (ERR);
 
-    _nc_scroll_window(CurScreen(SP_PARM), n, top, bot, blank);
+    _nc_scroll_window(CurScreen(SP_PARM), n,
+                     (NCURSES_SIZE_T) top,
+                     (NCURSES_SIZE_T) bot,
+                     blank);
 
     /* shift hash values too - they can be reused */
     NCURSES_SP_NAME(_nc_scroll_oldhash) (NCURSES_SP_ARGx n, top, bot);
 
     /* shift hash values too - they can be reused */
     NCURSES_SP_NAME(_nc_scroll_oldhash) (NCURSES_SP_ARGx n, top, bot);
@@ -2091,7 +2100,8 @@ NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_DCL0)
        SP_PARM->_color_defs = -(SP_PARM->_color_defs);
        for (n = 0; n < SP_PARM->_color_defs; ++n) {
            if (SP_PARM->_color_table[n].init) {
        SP_PARM->_color_defs = -(SP_PARM->_color_defs);
        for (n = 0; n < SP_PARM->_color_defs; ++n) {
            if (SP_PARM->_color_table[n].init) {
-               NCURSES_SP_NAME(init_color) (NCURSES_SP_ARGx n,
+               NCURSES_SP_NAME(init_color) (NCURSES_SP_ARGx
+                                            (short) n,
                                             SP_PARM->_color_table[n].r,
                                             SP_PARM->_color_table[n].g,
                                             SP_PARM->_color_table[n].b);
                                             SP_PARM->_color_table[n].r,
                                             SP_PARM->_color_table[n].g,
                                             SP_PARM->_color_table[n].b);
@@ -2145,33 +2155,33 @@ _nc_screen_init(void)
 NCURSES_EXPORT(void)
 NCURSES_SP_NAME(_nc_screen_wrap) (NCURSES_SP_DCL0)
 {
 NCURSES_EXPORT(void)
 NCURSES_SP_NAME(_nc_screen_wrap) (NCURSES_SP_DCL0)
 {
-    if (SP_PARM == 0)
-       return;
+    if (SP_PARM != 0) {
 
 
-    UpdateAttrs(SP_PARM, normal);
+       UpdateAttrs(SP_PARM, normal);
 #if NCURSES_EXT_FUNCS
 #if NCURSES_EXT_FUNCS
-    if (SP_PARM->_coloron
-       && !SP_PARM->_default_color) {
-       static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
-       SP_PARM->_default_color = TRUE;
-       NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx
-                                      -1,
-                                      0,
-                                      FALSE,
-                                      NCURSES_SP_NAME(_nc_outch));
-       SP_PARM->_default_color = FALSE;
-
-       NCURSES_SP_NAME(mvcur) (NCURSES_SP_ARGx
-                               SP_PARM->_cursrow,
-                               SP_PARM->_curscol,
-                               screen_lines(SP_PARM) - 1,
-                               0);
-
-       ClrToEOL(NCURSES_SP_ARGx blank, TRUE);
-    }
+       if (SP_PARM->_coloron
+           && !SP_PARM->_default_color) {
+           static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
+           SP_PARM->_default_color = TRUE;
+           NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_ARGx
+                                          -1,
+                                          0,
+                                          FALSE,
+                                          NCURSES_SP_NAME(_nc_outch));
+           SP_PARM->_default_color = FALSE;
+
+           TINFO_MVCUR(NCURSES_SP_ARGx
+                       SP_PARM->_cursrow,
+                       SP_PARM->_curscol,
+                       screen_lines(SP_PARM) - 1,
+                       0);
+
+           ClrToEOL(NCURSES_SP_ARGx blank, TRUE);
+       }
 #endif
 #endif
-    if (SP_PARM->_color_defs) {
-       NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_ARG);
+       if (SP_PARM->_color_defs) {
+           NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_ARG);
+       }
     }
 }
 
     }
 }