VERSION=$(awk '/^%define version/ {print $3}' $srcdir/newt.spec)
-VERSION=0.51.3
+VERSION=0.51.4
SONAME=0.51
AC_SUBST(VERSION)
AC_SUBST(SONAME)
chptr = tmpptr;
}
- len = strlen(chptr);
+ len = wstrlen(chptr, -1);
if (len <= co->width) {
i = len;
int newLength;
struct label * la = co->data;
+ co->width = wstrlen(text,-1);
newLength = strlen(text);
if (newLength <= la->length) {
memset(la->text, ' ', la->length);
free(la->text);
la->text = strdup(text);
la->length = newLength;
- co->width = wstrlen(text,-1);
}
labelDraw(co);
SLsmg_set_color(NEWT_COLORSET_HELPLINE);
- buf = alloca(SLtt_Screen_Cols + 1);
- memset(buf, ' ', SLtt_Screen_Cols);
- buf[SLtt_Screen_Cols] = '\0';
-
if (currentHelpline) {
- int len = wstrlen(*currentHelpline, -1);
- if (SLtt_Screen_Cols < len)
- len = SLtt_Screen_Cols;
- memcpy(buf, *currentHelpline, len);
+ /* buffer size needs to be wide enough to hold all the multibyte
+ currentHelpline + all the single byte ' ' to fill the line */
+ int wlen = wstrlen(*currentHelpline, -1);
+ int len;
+
+ if (wlen > SLtt_Screen_Cols)
+ wlen = SLtt_Screen_Cols;
+ len = strlen(*currentHelpline) + (SLtt_Screen_Cols - wlen);
+ buf = alloca(len + 1);
+ memset(buf, ' ', len);
+ memcpy(buf, *currentHelpline, strlen(*currentHelpline));
+ buf[len] = '\0';
+ } else {
+ buf = alloca(SLtt_Screen_Cols + 1);
+ memset(buf, ' ', SLtt_Screen_Cols);
+ buf[SLtt_Screen_Cols] = '\0';
}
SLsmg_gotorc(SLtt_Screen_Rows - 1, 0);
SLsmg_write_string(buf);
Summary: A development library for text mode user interfaces.
Name: newt
-%define version 0.51.3
+%define version 0.51.4
Version: %{version}
-Release: 2
+Release: 1
License: LGPL
Group: System Environment/Libraries
Source: newt-%{version}.tar.gz
%{_libdir}/libnewt.so
%changelog
+* Wed Feb 5 2003 Matt Wilson <msw@redhat.com> 0.51.4-1
+- fixed help line drawing in UTF-8 (#81718)
+- calculate the width of text in entries using wstrlen
+- always set component width to the new label width in newtLabelSetText
+- fixed snack.CListbox to work properly with UTF-8 (#81718)
+
* Tue Feb 04 2003 Florian La Roche <Florian.LaRoche@redhat.de>
- add symlink to shared lib
return (bb.buttonPressed(result), tuple(entryValues))
class CListbox(Grid):
- def __init__(self, height, cols, col_widths, scroll = 0, returnExit = 0,
- width = 0, col_pad = 1, col_text_align = None,
- col_labels = None, col_label_align = None):
+ def __init__(self, height, cols, col_widths, scroll = 0,
+ returnExit = 0, width = 0, col_pad = 1,
+ col_text_align = None, col_labels = None,
+ col_label_align = None, adjust_width=0):
self.cols = cols
self.col_widths = col_widths[:]
Grid.__init__(self, 1, 2)
box_y = 1
- lstr = self.colFormText(col_labels, col_label_align)
+ lstr = self.colFormText(col_labels, col_label_align,
+ adjust_width=adjust_width)
self.label = Label(lstr)
-
self.setField(self.label, 0, 0, anchorLeft=1)
else:
self.listbox = Listbox(height, scroll, returnExit, width)
self.setField(self.listbox, 0, box_y, anchorRight=1)
- def colFormText(self, col_text, align = None):
+ def colFormText(self, col_text, align = None, adjust_width=0):
i = 0
str = ""
c_len = len(col_text)
while (i < self.cols) and (i < c_len):
- cstr = col_text[i][:self.col_widths[i]]
- delta = self.col_widths[i] - len(cstr)
+ cstr = col_text[i]
+ cstrlen = _snack.wstrlen(cstr)
+ if self.col_widths[i] < cstrlen:
+ if adjust_width:
+ self.col_widths[i] = cstrlen
+ else:
+ cstr = cstr[:self.col_widths[i]]
+
+ delta = self.col_widths[i] - _snack.wstrlen(cstr)
+
if delta > 0:
if align == None:
a = LEFT
#include "Python.h"
#include "newt.h"
+#include "newt_pr.h"
typedef struct snackWidget_s snackWidget;
typedef struct snackGrid_s snackGrid;
static snackWidget * textWidget(PyObject * s, PyObject * args);
static PyObject * ternaryWindow(PyObject * s, PyObject * args);
static snackWidget * checkboxTreeWidget(PyObject * s, PyObject * args, PyObject * kwargs);
+static PyObject * pywstrlen(PyObject * s, PyObject * args);
static PyMethodDef snackModuleMethods[] = {
{ "button", (PyCFunction) buttonWidget, METH_VARARGS, NULL },
{ "ternary", ternaryWindow, METH_VARARGS, NULL },
{ "textbox", (PyCFunction) textWidget, METH_VARARGS, NULL },
{ "checkboxtree", (PyCFunction) checkboxTreeWidget, METH_VARARGS | METH_KEYWORDS, NULL },
+ { "wstrlen", (PyCFunction) pywstrlen, METH_VARARGS | METH_KEYWORDS, NULL },
{ NULL }
} ;
return sel;
}
+static PyObject * pywstrlen(PyObject * s, PyObject * args)
+{
+ char *str;
+ int len = -1;
+
+ if (!PyArg_ParseTuple(args, "s|i", &str, &len)) return NULL;
+
+ return PyInt_FromLong(wstrlen(str, len));
+}
+
void init_snack(void) {
PyObject * d, * m;