]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - form/frm_driver.c
ncurses 5.7 - patch 20091212
[ncurses.git] / form / frm_driver.c
index e919163edecb9a04e127893d77be961d6abeb467..5a8f6b08cc9df1dbd9601f38bd449a5ab328f21a 100644 (file)
@@ -32,7 +32,7 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_driver.c,v 1.94 2009/11/07 19:54:03 tom Exp $")
+MODULE_ID("$Id: frm_driver.c,v 1.96 2009/12/12 23:19:29 tom Exp $")
 
 /*----------------------------------------------------------------------------
   This is the core module of the form library. It contains the majority
@@ -4430,11 +4430,11 @@ set_field_buffer(FIELD *field, int buffer, const char *value)
    * and other special cases that we really do not want to handle here.
    */
 #if NCURSES_EXT_FUNCS
-  if (wresize(field->working, field->drows, field->dcols) == ERR)
+  if (wresize(field->working, 1, Buffer_Length(field) + 1) == ERR)
 #endif
     {
       delwin(field->working);
-      field->working = newpad(field->drows, field->dcols);
+      field->working = newpad(1, Buffer_Length(field) + 1);
     }
   len = Buffer_Length(field);
   wclear(field->working);
@@ -4448,7 +4448,7 @@ set_field_buffer(FIELD *field, int buffer, const char *value)
     {
       for (i = 0; i < (unsigned)field->drows; ++i)
        {
-         mvwin_wchnstr(field->working, i, 0,
+         mvwin_wchnstr(field->working, 0, i * field->dcols,
                        widevalue + (i * field->dcols),
                        field->dcols);
        }
@@ -4517,7 +4517,7 @@ field_buffer(const FIELD *field, int buffer)
       /* determine the number of bytes needed to store the expanded string */
       for (n = 0; n < size; ++n)
        {
-         if (!isWidecExt(data[n]))
+         if (!isWidecExt(data[n]) && data[n].chars[0] != L'\0')
            {
              mbstate_t state;
              size_t next;
@@ -4534,12 +4534,25 @@ field_buffer(const FIELD *field, int buffer)
        free(field->expanded[buffer]);
       field->expanded[buffer] = typeMalloc(char, need + 1);
 
-      /* expand the multibyte data */
+      /*
+       * Expand the multibyte data.
+       *
+       * It may also be multi-column data.  In that case, the data for a row
+       * may be null-padded to align to the dcols/drows layout (or it may
+       * contain embedded wide-character extensions).  Change the null-padding
+       * to blanks as needed.
+       */
       if ((result = field->expanded[buffer]) != 0)
        {
          wclear(field->working);
-         mvwadd_wchnstr(field->working, 0, 0, data, size);
-         mvwinnstr(field->working, 0, 0, result, (int)need);
+         wmove(field->working, 0, 0);
+         for (n = 0; n < size; ++n)
+           {
+             if (!isWidecExt(data[n]) && data[n].chars[0] != L'\0')
+               wadd_wch(field->working, &data[n]);
+           }
+         wmove(field->working, 0, 0);
+         winnstr(field->working, result, (int)need);
        }
 #else
       result = Address_Of_Nth_Buffer(field, buffer);