]> ncurses.scripts.mit.edu Git - ncurses.git/commitdiff
ncurses 5.7 - patch 20101211
authorThomas E. Dickey <dickey@invisible-island.net>
Sun, 12 Dec 2010 01:44:54 +0000 (01:44 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Sun, 12 Dec 2010 01:44:54 +0000 (01:44 +0000)
+ suppress ncv in screen entry, allowing underline (patch by Alejandro
  R Sedeno).
+ also suppress ncv in konsole-base -TD
+ fixes in wins_nwstr() and related functions to ensure that special
  characters, i.e., control characters are handled properly with the
  wide-character configuration.
+ correct a comparison in wins_nwstr() (Redhat #661506).
+ correct help-messages in some of the test-programs, which still
  referred to quitting with 'q'.

NEWS
dist.mk
misc/terminfo.src
ncurses/widechar/lib_ins_wch.c
test/ins_wide.c
test/inserts.c
test/newdemo.c
test/test_add_wchstr.c
test/test_addchstr.c
test/test_addstr.c
test/test_addwstr.c

diff --git a/NEWS b/NEWS
index 6955d2f7479afbb7beaf6ed015d31673bfefa564..0dacd15ce9850950a0b0f542dfd5b63d92cc624f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,7 +25,7 @@
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
 -- sale, use or other dealings in this Software without prior written        --
 -- authorization.                                                            --
 -------------------------------------------------------------------------------
--- $Id: NEWS,v 1.1617 2010/12/04 20:21:40 tom Exp $
+-- $Id: NEWS,v 1.1621 2010/12/11 23:42:36 tom Exp $
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
 -------------------------------------------------------------------------------
 
 This is a log of changes that ncurses has gone through since Zeyd started
@@ -45,6 +45,17 @@ See the AUTHORS file for the corresponding full names.
 Changes through 1.9.9e did not credit all contributions;
 it is not possible to add this information.
 
 Changes through 1.9.9e did not credit all contributions;
 it is not possible to add this information.
 
+20101211
+       + suppress ncv in screen entry, allowing underline (patch by Alejandro
+         R Sedeno).
+       + also suppress ncv in konsole-base -TD
+       + fixes in wins_nwstr() and related functions to ensure that special
+         characters, i.e., control characters are handled properly with the
+         wide-character configuration.
+       + correct a comparison in wins_nwstr() (Redhat #661506).
+       + correct help-messages in some of the test-programs, which still
+         referred to quitting with 'q'.
+
 20101204
        + add special case to _nc_infotocap() to recognize the setaf/setab
          strings from xterm+256color and xterm+88color, and provide a reduced
 20101204
        + add special case to _nc_infotocap() to recognize the setaf/setab
          strings from xterm+256color and xterm+88color, and provide a reduced
diff --git a/dist.mk b/dist.mk
index 5944dabd1fc1115a35c99286223ab6e60d21ee13..5e004ee7a9136172220aa6bc09c2a0e514efac9e 100644 (file)
--- a/dist.mk
+++ b/dist.mk
@@ -25,7 +25,7 @@
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
 # use or other dealings in this Software without prior written               #
 # authorization.                                                             #
 ##############################################################################
-# $Id: dist.mk,v 1.784 2010/12/04 16:06:24 tom Exp $
+# $Id: dist.mk,v 1.785 2010/12/11 17:04:22 tom Exp $
 # Makefile for creating ncurses distributions.
 #
 # This only needs to be used directly as a makefile by developers, but
 # Makefile for creating ncurses distributions.
 #
 # This only needs to be used directly as a makefile by developers, but
@@ -37,7 +37,7 @@ SHELL = /bin/sh
 # These define the major/minor/patch versions of ncurses.
 NCURSES_MAJOR = 5
 NCURSES_MINOR = 7
 # These define the major/minor/patch versions of ncurses.
 NCURSES_MAJOR = 5
 NCURSES_MINOR = 7
-NCURSES_PATCH = 20101204
+NCURSES_PATCH = 20101211
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
index cca518fb4002aa7301336379a92523b5a963920c..458d473306a3e510b4f3c631f0b783f59d3c1a3f 100644 (file)
@@ -6,8 +6,8 @@
 # Report bugs and new terminal descriptions to
 #      bug-ncurses@gnu.org
 #
 # Report bugs and new terminal descriptions to
 #      bug-ncurses@gnu.org
 #
-#      $Revision: 1.380 $
-#      $Date: 2010/12/04 18:38:55 $
+#      $Revision: 1.381 $
+#      $Date: 2010/12/11 23:39:36 $
 #
 # The original header is preserved below for reference.  It is noted that there
 # is a "newer" version which differs in some cosmetic details (but actually
 #
 # The original header is preserved below for reference.  It is noted that there
 # is a "newer" version which differs in some cosmetic details (but actually
@@ -3912,6 +3912,7 @@ kvt|KDE terminal,
 # detail, but it is unclear which copies the other.
 konsole-base|KDE console window,
        bce, km@, npc, XT,
 # detail, but it is unclear which copies the other.
 konsole-base|KDE console window,
        bce, km@, npc, XT,
+       ncv@,
        bel@, blink=\E[5m, civis=\E[?25l, cnorm=\E[?25h,
        ech=\E[%p1%dX, flash=\E[?5h$<100/>\E[?5l,
        hpa=\E[%i%p1%dG, indn=\E[%p1%dS, kbs=\177, kdch1@,
        bel@, blink=\E[5m, civis=\E[?25l, cnorm=\E[?25h,
        ech=\E[%p1%dX, flash=\E[?5h$<100/>\E[?5l,
        hpa=\E[%i%p1%dG, indn=\E[%p1%dS, kbs=\177, kdch1@,
@@ -4665,7 +4666,7 @@ eterm-color|Emacs term.el terminal emulator term-protocol-version 0.96,
 # tested with screen 3.09.08
 screen|VT 100/ANSI X3.64 virtual terminal,
        OTbs, OTpt, am, km, mir, msgr, xenl, G0,
 # tested with screen 3.09.08
 screen|VT 100/ANSI X3.64 virtual terminal,
        OTbs, OTpt, am, km, mir, msgr, xenl, G0,
-       colors#8, cols#80, it#8, lines#24, pairs#64,
+       colors#8, cols#80, it#8, lines#24, ncv@, pairs#64,
        acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
        bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
        clear=\E[H\E[J, cnorm=\E[34h\E[?25h, cr=^M,
        acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
        bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
        clear=\E[H\E[J, cnorm=\E[34h\E[?25h, cr=^M,
@@ -22336,4 +22337,8 @@ v3220|LANPAR Vision II model 3220/3221/3222,
 # 2010-11-27
 #      * fix typo in rmso for tek4106 -Goran Weinholt
 #
 # 2010-11-27
 #      * fix typo in rmso for tek4106 -Goran Weinholt
 #
+# 2010-12-11
+#      * suppress ncv in screen entry, allowing underline -Alejandro R. Sedeno
+#      * also suppress ncv in konsole-base -TD
+#
 ######## SHANTIH!  SHANTIH!  SHANTIH!
 ######## SHANTIH!  SHANTIH!  SHANTIH!
index e44f091b639f71fecbd565e0e469da2f708f95c7..4f62d365314ade52c623ebc28e773b9f3e732f72 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 2002-2005,2009 Free Software Foundation, Inc.              *
+ * Copyright (c) 2002-2009,2010 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            *
@@ -39,7 +39,7 @@
 
 #include <curses.priv.h>
 
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_ins_wch.c,v 1.11 2009/10/24 22:43:14 tom Exp $")
+MODULE_ID("$Id: lib_ins_wch.c,v 1.15 2010/12/11 19:58:39 tom Exp $")
 
 /*
  * Insert the given character, updating the current location to simplify
 
 /*
  * Insert the given character, updating the current location to simplify
@@ -50,28 +50,33 @@ _nc_insert_wch(WINDOW *win, const cchar_t *wch)
 {
     int cells = wcwidth(CharOf(CHDEREF(wch)));
     int cell;
 {
     int cells = wcwidth(CharOf(CHDEREF(wch)));
     int cell;
+    int code = OK;
+
+    if (cells < 0) {
+       code = winsch(win, CharOf(CHDEREF(wch)));
+    } else {
+       if (cells == 0)
+           cells = 1;
+
+       if (win->_curx <= win->_maxx) {
+           struct ldat *line = &(win->_line[win->_cury]);
+           NCURSES_CH_T *end = &(line->text[win->_curx]);
+           NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
+           NCURSES_CH_T *temp2 = temp1 - cells;
+
+           CHANGED_TO_EOL(line, win->_curx, win->_maxx);
+           while (temp1 > end)
+               *temp1-- = *temp2--;
+
+           *temp1 = _nc_render(win, *wch);
+           for (cell = 1; cell < cells; ++cell) {
+               SetWidecExt(temp1[cell], cell);
+           }
 
 
-    if (cells <= 0)
-       cells = 1;
-
-    if (win->_curx <= win->_maxx) {
-       struct ldat *line = &(win->_line[win->_cury]);
-       NCURSES_CH_T *end = &(line->text[win->_curx]);
-       NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
-       NCURSES_CH_T *temp2 = temp1 - cells;
-
-       CHANGED_TO_EOL(line, win->_curx, win->_maxx);
-       while (temp1 > end)
-           *temp1-- = *temp2--;
-
-       *temp1 = _nc_render(win, *wch);
-       for (cell = 1; cell < cells; ++cell) {
-           SetWidecExt(temp1[cell], cell);
+           win->_curx++;
        }
        }
-
-       win->_curx++;
     }
     }
-    return OK;
+    return code;
 }
 
 NCURSES_EXPORT(int)
 }
 
 NCURSES_EXPORT(int)
@@ -120,7 +125,7 @@ wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
            for (cp = wstr; *cp && ((cp - wstr) < n); cp++) {
                int len = wcwidth(*cp);
 
            for (cp = wstr; *cp && ((cp - wstr) < n); cp++) {
                int len = wcwidth(*cp);
 
-               if (len != 1 || !is8bits(*cp)) {
+               if ((len >= 0 && len != 1) || !is7bits(*cp)) {
                    cchar_t tmp_cchar;
                    wchar_t tmp_wchar = *cp;
                    memset(&tmp_cchar, 0, sizeof(tmp_cchar));
                    cchar_t tmp_cchar;
                    wchar_t tmp_wchar = *cp;
                    memset(&tmp_cchar, 0, sizeof(tmp_cchar));
index 60de9249ba8e4119786c18cd69389e527c548fc9..87deb1a14d53b75eb8cb102399c9437452666045 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: ins_wide.c,v 1.13 2010/11/13 23:40:32 tom Exp $
+ * $Id: ins_wide.c,v 1.15 2010/12/12 00:20:14 tom Exp $
  *
  * Demonstrate the wins_wstr() and wins_wch functions.
  * Thomas Dickey - 2002/11/23
  *
  * Demonstrate the wins_wstr() and wins_wch functions.
  * Thomas Dickey - 2002/11/23
@@ -74,7 +74,7 @@ static int n_opt = -1;
 static void
 legend(WINDOW *win, int level, Options state, wchar_t *buffer, int length)
 {
 static void
 legend(WINDOW *win, int level, Options state, wchar_t *buffer, int length)
 {
-    NCURSES_CONST char *showstate;
+    const char *showstate;
 
     switch (state) {
     default:
 
     switch (state) {
     default:
@@ -96,7 +96,7 @@ legend(WINDOW *win, int level, Options state, wchar_t *buffer, int length)
     wprintw(win,
            "The Strings/Chars displays should match.  Enter any characters, except:\n");
     wprintw(win,
     wprintw(win,
            "The Strings/Chars displays should match.  Enter any characters, except:\n");
     wprintw(win,
-           "down-arrow or ^N to repeat on next line, 'w' for inner window, 'q' to exit.\n");
+           "down-arrow or ^N to repeat on next line, ^W for inner window, ESC to exit.\n");
     wclrtoeol(win);
     wprintw(win, "Level %d,%s inserted %d characters <", level,
            showstate, length);
     wclrtoeol(win);
     wprintw(win, "Level %d,%s inserted %d characters <", level,
            showstate, length);
index 308793e03f25c4c7578e1ae1d4d765ba4361ac46..a12fa4011283d28a66bab5400bf8483e5e047ffd 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: inserts.c,v 1.21 2010/05/01 19:12:26 tom Exp $
+ * $Id: inserts.c,v 1.23 2010/12/12 00:19:55 tom Exp $
  *
  * Demonstrate the winsstr() and winsch functions.
  * Thomas Dickey - 2002/10/19
  *
  * Demonstrate the winsstr() and winsch functions.
  * Thomas Dickey - 2002/10/19
@@ -68,7 +68,7 @@ static int n_opt = -1;
 static void
 legend(WINDOW *win, int level, Options state, char *buffer, int length)
 {
 static void
 legend(WINDOW *win, int level, Options state, char *buffer, int length)
 {
-    NCURSES_CONST char *showstate;
+    const char *showstate;
 
     switch (state) {
     default:
 
     switch (state) {
     default:
@@ -90,7 +90,7 @@ legend(WINDOW *win, int level, Options state, char *buffer, int length)
     wprintw(win,
            "The Strings/Chars displays should match.  Enter any characters, except:\n");
     wprintw(win,
     wprintw(win,
            "The Strings/Chars displays should match.  Enter any characters, except:\n");
     wprintw(win,
-           "down-arrow or ^N to repeat on next line, 'w' for inner window, 'q' to exit.\n");
+           "down-arrow or ^N to repeat on next line, ^W for inner window, ESC to exit.\n");
     wclrtoeol(win);
     wprintw(win, "Level %d,%s inserted %d characters <%s>", level,
            showstate, length, buffer);
     wclrtoeol(win);
     wprintw(win, "Level %d,%s inserted %d characters <%s>", level,
            showstate, length, buffer);
index 72e1d093c48344150192a64a1838f0842973469f..75626a9051e174043b6891d64fa5a47b65bf25df 100644 (file)
@@ -2,7 +2,7 @@
  *  newdemo.c  -       A demo program using PDCurses. The program illustrate
  *                     the use of colours for text output.
  *
  *  newdemo.c  -       A demo program using PDCurses. The program illustrate
  *                     the use of colours for text output.
  *
- * $Id: newdemo.c,v 1.34 2010/11/13 23:33:42 tom Exp $
+ * $Id: newdemo.c,v 1.35 2010/12/12 00:19:15 tom Exp $
  */
 
 #include <test.priv.h>
  */
 
 #include <test.priv.h>
@@ -33,7 +33,7 @@ static CONST_MENUS char *AusMap[16] =
  */
 #define NMESSAGES   6
 
  */
 #define NMESSAGES   6
 
-static NCURSES_CONST char *messages[] =
+static const char *messages[] =
 {
     "Hello from the Land Down Under",
     "The Land of crocs. and a big Red Rock",
 {
     "Hello from the Land Down Under",
     "The Land of crocs. and a big Red Rock",
index 3413a37b969782cd7ece067189ebef0620a1dc8a..08ff6ee06f1c80b186df0efb4b9e57d6fcb70a41 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_add_wchstr.c,v 1.9 2010/11/13 21:14:50 tom Exp $
+ * $Id: test_add_wchstr.c,v 1.12 2010/12/12 00:17:13 tom Exp $
  *
  * Demonstrate the waddwchstr() and wadd_wch functions.
  * Thomas Dickey - 2009/9/12
  *
  * Demonstrate the waddwchstr() and wadd_wch functions.
  * Thomas Dickey - 2009/9/12
@@ -73,6 +73,7 @@ typedef enum {
 } Options;
 
 static bool m_opt = FALSE;
 } Options;
 
 static bool m_opt = FALSE;
+static bool pass_ctls = FALSE;
 static bool w_opt = FALSE;
 static int n_opt = -1;
 
 static bool w_opt = FALSE;
 static int n_opt = -1;
 
@@ -81,6 +82,7 @@ static size_t temp_length;
 
 #define TempBuffer(source_len, source_cast) \
     if (source != 0) { \
 
 #define TempBuffer(source_len, source_cast) \
     if (source != 0) { \
+       const char *temp; \
        size_t need = source_len + 1; \
        wchar_t have[2]; \
        int n = 0; \
        size_t need = source_len + 1; \
        wchar_t have[2]; \
        int n = 0; \
@@ -93,7 +95,18 @@ static size_t temp_length;
        have[1] = 0; \
        do { \
            have[0] = source_cast; \
        have[1] = 0; \
        do { \
            have[0] = source_cast; \
-           setcchar(&temp_buffer[n++], have, A_NORMAL, 0, NULL); \
+           if (!pass_ctls \
+            && have[0] != 0 \
+            && have[0] < 256 \
+            && (temp = unctrl((chtype) have[0])) != 0 \
+            && strlen(temp) > 1) { \
+               while (*temp != '\0') { \
+                   have[0] = *temp++; \
+                   setcchar(&temp_buffer[n++], have, A_NORMAL, 0, NULL); \
+               } \
+           } else { \
+               setcchar(&temp_buffer[n++], have, A_NORMAL, 0, NULL); \
+           } \
        } while (have[0] != 0); \
     } else if (temp_buffer != 0) { \
        free(temp_buffer); \
        } while (have[0] != 0); \
     } else if (temp_buffer != 0) { \
        free(temp_buffer); \
@@ -102,6 +115,26 @@ static size_t temp_length;
     } \
     return temp_buffer;
 
     } \
     return temp_buffer;
 
+static size_t
+ChWLen(const wchar_t *source)
+{
+    size_t result = wcslen(source);
+
+    if (!pass_ctls) {
+       size_t adjust = 0;
+       size_t n;
+       char *s;
+
+       for (n = 0; n < result; ++n) {
+           if (source[n] < 256 && (s = unctrl((chtype) source[n])) != 0) {
+               adjust += (strlen(s) - 1);
+           }
+       }
+       result += adjust;
+    }
+    return result;
+}
+
 static cchar_t *
 ChStr(const char *source)
 {
 static cchar_t *
 ChStr(const char *source)
 {
@@ -111,13 +144,13 @@ ChStr(const char *source)
 static cchar_t *
 ChWStr(const wchar_t *source)
 {
 static cchar_t *
 ChWStr(const wchar_t *source)
 {
-    TempBuffer(wcslen(source), *source++);
+    TempBuffer(ChWLen(source), *source++);
 }
 
 static void
 legend(WINDOW *win, int level, Options state, wchar_t *buffer, int length)
 {
 }
 
 static void
 legend(WINDOW *win, int level, Options state, wchar_t *buffer, int length)
 {
-    NCURSES_CONST char *showstate;
+    const char *showstate;
 
     switch (state) {
     default:
 
     switch (state) {
     default:
@@ -139,7 +172,7 @@ legend(WINDOW *win, int level, Options state, wchar_t *buffer, int length)
     wprintw(win,
            "The Strings/Chars displays should match.  Enter any characters, except:\n");
     wprintw(win,
     wprintw(win,
            "The Strings/Chars displays should match.  Enter any characters, except:\n");
     wprintw(win,
-           "down-arrow or ^N to repeat on next line, 'w' for inner window, 'q' to exit.\n");
+           "down-arrow or ^N to repeat on next line, ^W for inner window, ESC to exit.\n");
     wclrtoeol(win);
     wprintw(win, "Level %d,%s added %d characters <", level,
            showstate, length);
     wclrtoeol(win);
     wprintw(win, "Level %d,%s added %d characters <", level,
            showstate, length);
@@ -499,6 +532,7 @@ usage(void)
        ,"  -f FILE read data from given file"
        ,"  -n NUM  limit string-adds to NUM bytes on ^N replay"
        ,"  -m      perform wmove/move separately from add-functions"
        ,"  -f FILE read data from given file"
        ,"  -n NUM  limit string-adds to NUM bytes on ^N replay"
        ,"  -m      perform wmove/move separately from add-functions"
+       ,"  -p      pass-thru control characters without using unctrl()"
        ,"  -w      use window-parameter even when stdscr would be implied"
     };
     unsigned n;
        ,"  -w      use window-parameter even when stdscr would be implied"
     };
     unsigned n;
@@ -514,7 +548,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
 
     setlocale(LC_ALL, "");
 
 
     setlocale(LC_ALL, "");
 
-    while ((ch = getopt(argc, argv, "f:mn:w")) != -1) {
+    while ((ch = getopt(argc, argv, "f:mn:pw")) != -1) {
        switch (ch) {
        case 'f':
            init_linedata(optarg);
        switch (ch) {
        case 'f':
            init_linedata(optarg);
@@ -527,6 +561,9 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
            if (n_opt == 0)
                n_opt = -1;
            break;
            if (n_opt == 0)
                n_opt = -1;
            break;
+       case 'p':
+           pass_ctls = TRUE;
+           break;
        case 'w':
            w_opt = TRUE;
            break;
        case 'w':
            w_opt = TRUE;
            break;
index 3cb43135c7616825fea0f357e1c9afc8ffa6fab5..815ccc595bf98648942ffe65b45ec144110fd186 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_addchstr.c,v 1.6 2010/05/01 19:13:46 tom Exp $
+ * $Id: test_addchstr.c,v 1.13 2010/12/12 01:28:24 tom Exp $
  *
  * Demonstrate the waddchstr() and waddch functions.
  * Thomas Dickey - 2009/9/12
  *
  * Demonstrate the waddchstr() and waddch functions.
  * Thomas Dickey - 2009/9/12
@@ -61,31 +61,59 @@ typedef enum {
 } Options;
 
 static bool m_opt = FALSE;
 } Options;
 
 static bool m_opt = FALSE;
+static bool pass_ctls = FALSE;
 static bool w_opt = FALSE;
 static int n_opt = -1;
 
 static bool w_opt = FALSE;
 static int n_opt = -1;
 
+static attr_t show_attr;
 static chtype *temp_buffer;
 static size_t temp_length;
 
 #define TempBuffer(source_cast)
 
 static chtype *temp_buffer;
 static size_t temp_length;
 
 #define TempBuffer(source_cast)
 
+static size_t
+ChLen(const char *source)
+{
+    size_t result = strlen(source);
+
+    if (!pass_ctls) {
+       size_t adjust = 0;
+       size_t n;
+
+       for (n = 0; n < result; ++n) {
+           const char *s = unctrl(UChar(source[n]));
+           if (s != 0) {
+               adjust += (strlen(s) - 1);
+           }
+       }
+       result += adjust;
+    }
+    return result;
+}
+
 static chtype *
 ChStr(const char *source)
 {
     if (source != 0) {
 static chtype *
 ChStr(const char *source)
 {
     if (source != 0) {
-       size_t need = strlen(source) + 1;
-       wchar_t have[2];
+       size_t need = ChLen(source) + 1;
        int n = 0;
 
        if (need > temp_length) {
            temp_length = need * 2;
            temp_buffer = typeRealloc(chtype, temp_length, temp_buffer);
        }
        int n = 0;
 
        if (need > temp_length) {
            temp_length = need * 2;
            temp_buffer = typeRealloc(chtype, temp_length, temp_buffer);
        }
-       have[0] = 0;
-       have[1] = 0;
        do {
        do {
-           temp_buffer[n++] = UChar(*source++);
-       } while (have[0] != 0);
+           const char *s;
+           chtype ch = UChar(*source++);
+           if (!pass_ctls && (s = unctrl(ch)) != 0) {
+               while (*s != '\0') {
+                   temp_buffer[n++] = UChar(*s++);
+               }
+           } else {
+               temp_buffer[n++] = ch;
+           }
+       } while (source[0] != 0);
+       temp_buffer[n] = 0;
     } else if (temp_buffer != 0) {
        free(temp_buffer);
        temp_buffer = 0;
     } else if (temp_buffer != 0) {
        free(temp_buffer);
        temp_buffer = 0;
@@ -94,10 +122,23 @@ ChStr(const char *source)
     return temp_buffer;
 }
 
     return temp_buffer;
 }
 
+/* color the strings drawn in the workspace */
+static chtype *
+ChStr2(const char *source)
+{
+    size_t len = ChLen(source);
+    size_t n;
+    chtype *result = ChStr(source);
+    for (n = 0; n < len; ++n) {
+       result[n] |= show_attr;
+    }
+    return result;
+}
+
 static void
 legend(WINDOW *win, int level, Options state, char *buffer, int length)
 {
 static void
 legend(WINDOW *win, int level, Options state, char *buffer, int length)
 {
-    NCURSES_CONST char *showstate;
+    const char *showstate;
 
     switch (state) {
     default:
 
     switch (state) {
     default:
@@ -119,7 +160,7 @@ legend(WINDOW *win, int level, Options state, char *buffer, int length)
     wprintw(win,
            "The Strings/Chars displays should match.  Enter any characters, except:\n");
     wprintw(win,
     wprintw(win,
            "The Strings/Chars displays should match.  Enter any characters, except:\n");
     wprintw(win,
-           "down-arrow or ^N to repeat on next line, 'w' for inner window, 'q' to exit.\n");
+           "down-arrow or ^N to repeat on next line, ^W for inner window, ESC to exit.\n");
     wclrtoeol(win);
     wprintw(win, "Level %d,%s added %d characters <%s>", level,
            showstate, length, buffer);
     wclrtoeol(win);
     wprintw(win, "Level %d,%s added %d characters <%s>", level,
            showstate, length, buffer);
@@ -236,7 +277,10 @@ test_adds(int level)
     if (has_colors()) {
        start_color();
        init_pair(1, COLOR_WHITE, COLOR_BLUE);
     if (has_colors()) {
        start_color();
        init_pair(1, COLOR_WHITE, COLOR_BLUE);
-       wbkgdset(work, COLOR_PAIR(1) | ' ');
+       show_attr = COLOR_PAIR(1);
+       wbkgdset(work, show_attr | ' ');
+    } else {
+       show_attr = A_STANDOUT;
     }
 
     while ((ch = read_linedata(work)) != ERR && !isQUIT(ch)) {
     }
 
     while ((ch = read_linedata(work)) != ERR && !isQUIT(ch)) {
@@ -266,12 +310,12 @@ test_adds(int level)
                        for (col = 0; col < length; col += n_opt) {
                            col2 = ColOf(buffer, col, margin);
                            if (move(row, col2) != ERR) {
                        for (col = 0; col < length; col += n_opt) {
                            col2 = ColOf(buffer, col, margin);
                            if (move(row, col2) != ERR) {
-                               AddNStr(ChStr(buffer + col), LEN(col));
+                               AddNStr(ChStr2(buffer + col), LEN(col));
                            }
                        }
                    } else {
                        if (move(row, col2) != ERR) {
                            }
                        }
                    } else {
                        if (move(row, col2) != ERR) {
-                           AddStr(ChStr(buffer));
+                           AddStr(ChStr2(buffer));
                        }
                    }
                    break;
                        }
                    }
                    break;
@@ -279,10 +323,10 @@ test_adds(int level)
                    if (n_opt > 1) {
                        for (col = 0; col < length; col += n_opt) {
                            col2 = ColOf(buffer, col, margin);
                    if (n_opt > 1) {
                        for (col = 0; col < length; col += n_opt) {
                            col2 = ColOf(buffer, col, margin);
-                           MvAddNStr(row, col2, ChStr(buffer + col), LEN(col));
+                           MvAddNStr(row, col2, ChStr2(buffer + col), LEN(col));
                        }
                    } else {
                        }
                    } else {
-                       MvAddStr(row, col2, ChStr(buffer));
+                       MvAddStr(row, col2, ChStr2(buffer));
                    }
                    break;
                case oWindow:
                    }
                    break;
                case oWindow:
@@ -290,12 +334,12 @@ test_adds(int level)
                        for (col = 0; col < length; col += n_opt) {
                            col2 = ColOf(buffer, col, margin);
                            if (wmove(work, row, col2) != ERR) {
                        for (col = 0; col < length; col += n_opt) {
                            col2 = ColOf(buffer, col, margin);
                            if (wmove(work, row, col2) != ERR) {
-                               WAddNStr(work, ChStr(buffer + col), LEN(col));
+                               WAddNStr(work, ChStr2(buffer + col), LEN(col));
                            }
                        }
                    } else {
                        if (wmove(work, row, col2) != ERR) {
                            }
                        }
                    } else {
                        if (wmove(work, row, col2) != ERR) {
-                           WAddStr(work, ChStr(buffer));
+                           WAddStr(work, ChStr2(buffer));
                        }
                    }
                    break;
                        }
                    }
                    break;
@@ -303,11 +347,11 @@ test_adds(int level)
                    if (n_opt > 1) {
                        for (col = 0; col < length; col += n_opt) {
                            col2 = ColOf(buffer, col, margin);
                    if (n_opt > 1) {
                        for (col = 0; col < length; col += n_opt) {
                            col2 = ColOf(buffer, col, margin);
-                           MvWAddNStr(work, row, col2, ChStr(buffer + col),
+                           MvWAddNStr(work, row, col2, ChStr2(buffer + col),
                                       LEN(col));
                        }
                    } else {
                                       LEN(col));
                        }
                    } else {
-                       MvWAddStr(work, row, col2, ChStr(buffer));
+                       MvWAddStr(work, row, col2, ChStr2(buffer));
                    }
                    break;
                }
                    }
                    break;
                }
@@ -355,19 +399,19 @@ test_adds(int level)
            switch (option) {
            case oDefault:
                if (move(row, col) != ERR) {
            switch (option) {
            case oDefault:
                if (move(row, col) != ERR) {
-                   AddStr(ChStr(buffer + length - 1));
+                   AddStr(ChStr2(buffer + length - 1));
                }
                break;
            case oMove:
                }
                break;
            case oMove:
-               MvAddStr(row, col, ChStr(buffer + length - 1));
+               MvAddStr(row, col, ChStr2(buffer + length - 1));
                break;
            case oWindow:
                if (wmove(work, row, col) != ERR) {
                break;
            case oWindow:
                if (wmove(work, row, col) != ERR) {
-                   WAddStr(work, ChStr(buffer + length - 1));
+                   WAddStr(work, ChStr2(buffer + length - 1));
                }
                break;
            case oMoveWindow:
                }
                break;
            case oMoveWindow:
-               MvWAddStr(work, row, col, ChStr(buffer + length - 1));
+               MvWAddStr(work, row, col, ChStr2(buffer + length - 1));
                break;
            }
 
                break;
            }
 
@@ -418,6 +462,7 @@ usage(void)
        ,"  -f FILE read data from given file"
        ,"  -n NUM  limit string-adds to NUM bytes on ^N replay"
        ,"  -m      perform wmove/move separately from add-functions"
        ,"  -f FILE read data from given file"
        ,"  -n NUM  limit string-adds to NUM bytes on ^N replay"
        ,"  -m      perform wmove/move separately from add-functions"
+       ,"  -p      pass-thru control characters without using unctrl()"
        ,"  -w      use window-parameter even when stdscr would be implied"
     };
     unsigned n;
        ,"  -w      use window-parameter even when stdscr would be implied"
     };
     unsigned n;
@@ -433,7 +478,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
 
     setlocale(LC_ALL, "");
 
 
     setlocale(LC_ALL, "");
 
-    while ((ch = getopt(argc, argv, "f:mn:w")) != -1) {
+    while ((ch = getopt(argc, argv, "f:mn:pw")) != -1) {
        switch (ch) {
        case 'f':
            init_linedata(optarg);
        switch (ch) {
        case 'f':
            init_linedata(optarg);
@@ -446,6 +491,9 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
            if (n_opt == 0)
                n_opt = -1;
            break;
            if (n_opt == 0)
                n_opt = -1;
            break;
+       case 'p':
+           pass_ctls = TRUE;
+           break;
        case 'w':
            w_opt = TRUE;
            break;
        case 'w':
            w_opt = TRUE;
            break;
index ea3f5c9c9555517f3950bd845d7a5ddb91353f4f..5cc184a2d4b23a2e806d78b9c6c5040555376d06 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_addstr.c,v 1.4 2010/05/01 19:13:46 tom Exp $
+ * $Id: test_addstr.c,v 1.6 2010/12/12 00:17:37 tom Exp $
  *
  * Demonstrate the waddstr() and waddch functions.
  * Thomas Dickey - 2009/9/12
  *
  * Demonstrate the waddstr() and waddch functions.
  * Thomas Dickey - 2009/9/12
@@ -62,7 +62,7 @@ static int n_opt = -1;
 static void
 legend(WINDOW *win, int level, Options state, char *buffer, int length)
 {
 static void
 legend(WINDOW *win, int level, Options state, char *buffer, int length)
 {
-    NCURSES_CONST char *showstate;
+    const char *showstate;
 
     switch (state) {
     default:
 
     switch (state) {
     default:
@@ -84,7 +84,7 @@ legend(WINDOW *win, int level, Options state, char *buffer, int length)
     wprintw(win,
            "The Strings/Chars displays should match.  Enter any characters, except:\n");
     wprintw(win,
     wprintw(win,
            "The Strings/Chars displays should match.  Enter any characters, except:\n");
     wprintw(win,
-           "down-arrow or ^N to repeat on next line, 'w' for inner window, 'q' to exit.\n");
+           "down-arrow or ^N to repeat on next line, ^W for inner window, ESC to exit.\n");
     wclrtoeol(win);
     wprintw(win, "Level %d,%s added %d characters <%s>", level,
            showstate, length, buffer);
     wclrtoeol(win);
     wprintw(win, "Level %d,%s added %d characters <%s>", level,
            showstate, length, buffer);
index 5a45a9c1a750dd2a0b7ccf10f287c6d6512d639e..92334aee3b16b6b5b93bdc7b58936842389bf846 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: test_addwstr.c,v 1.4 2010/11/13 21:13:53 tom Exp $
+ * $Id: test_addwstr.c,v 1.6 2010/12/12 00:18:00 tom Exp $
  *
  * Demonstrate the waddwstr() and wadd_wch functions.
  * Thomas Dickey - 2009/9/12
  *
  * Demonstrate the waddwstr() and wadd_wch functions.
  * Thomas Dickey - 2009/9/12
@@ -79,7 +79,7 @@ static int n_opt = -1;
 static void
 legend(WINDOW *win, int level, Options state, wchar_t *buffer, int length)
 {
 static void
 legend(WINDOW *win, int level, Options state, wchar_t *buffer, int length)
 {
-    NCURSES_CONST char *showstate;
+    const char *showstate;
 
     switch (state) {
     default:
 
     switch (state) {
     default:
@@ -101,7 +101,7 @@ legend(WINDOW *win, int level, Options state, wchar_t *buffer, int length)
     wprintw(win,
            "The Strings/Chars displays should match.  Enter any characters, except:\n");
     wprintw(win,
     wprintw(win,
            "The Strings/Chars displays should match.  Enter any characters, except:\n");
     wprintw(win,
-           "down-arrow or ^N to repeat on next line, 'w' for inner window, 'q' to exit.\n");
+           "down-arrow or ^N to repeat on next line, ^W for inner window, ESC to exit.\n");
     wclrtoeol(win);
     wprintw(win, "Level %d,%s inserted %d characters <", level,
            showstate, length);
     wclrtoeol(win);
     wprintw(win, "Level %d,%s inserted %d characters <", level,
            showstate, length);