Hello community, here is the log from the commit of package newt for openSUSE:Factory checked in at Mon Sep 12 10:36:02 CEST 2011.
-------- --- newt/newt.changes 2011-03-17 12:44:55.000000000 +0100 +++ /mounts/work_src_done/STABLE/newt/newt.changes 2011-08-08 13:48:08.000000000 +0200 @@ -1,0 +2,17 @@ +Mon Aug 8 11:32:27 UTC 2011 - [email protected] + +- update to 0.52.13: ++ add support for changing colors in individual labels, scrollbars, entries, + textboxes and scales, add custom colorsets ++ add support for NEWT_COLORS and NEWT_COLORS_FILE variables (rh#689903) ++ allow resizing of form ++ fix errors found by coverity ++ fix va_list usage (Gwenole Beauchesne) ++ fix building and installing on Mac OS X (rh#652479) ++ check for slang.h header, support DESTDIR variable, add --without-python + option (Otavio Salvador) ++ add Persian, Low German translations +- added newt-0.52.13-python_version.patch to fix detection of + python version in configure script + +------------------------------------------------------------------- calling whatdependson for head-i586 Old: ---- newt-0.52.12.tar.bz2 New: ---- newt-0.52.13-python_version.patch newt-0.52.13.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ newt.spec ++++++ --- /var/tmp/diff_new_pack.MSYaLy/_old 2011-09-12 10:35:55.000000000 +0200 +++ /var/tmp/diff_new_pack.MSYaLy/_new 2011-09-12 10:35:55.000000000 +0200 @@ -21,18 +21,21 @@ %define libname lib%{name} %define libsoname %{libname}0_52 -Summary: Nifty Erik's Windowing Toolkit -Version: 0.52.12 -Release: 7 +Summary: A library for text mode user interfaces +Version: 0.52.13 +Release: 1 License: LGPLv2.1+ Group: System/Libraries Url: https://fedorahosted.org/newt/ Source: %{name}-%{version}.tar.bz2 Source2: baselibs.conf Source10: %{name}-rpmlintrc +Patch0: newt-0.52.13-python_version.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: pkg-config -BuildRequires: popt-devel python-devel slang-devel +BuildRequires: popt-devel +BuildRequires: python-devel +BuildRequires: slang-devel %if 0%{?suse_version} < 1020 BuildRequires: libpng-devel %endif @@ -119,6 +122,7 @@ %package -n python-%{name} + License: GPLv2 ; GPLv2+ ; LGPLv2.1+ Summary: Python bindings for newt Group: System/Libraries @@ -133,16 +137,18 @@ %prep %setup -q +%patch0 -p1 %build # gpm support seems to smash the stack # --with-gpm-support %configure --without-tcl ## make depend -%{__make} %{?_smp_mflags} +%{__make} CPPFLAGS="%{optflags}" %{?_smp_mflags} all +#docbook2txt tutorial.sgml %install -%{__make} PYTHONVERS="python%{py_ver}" instroot="%{buildroot}" install install-sh +%{__make} PYTHONVERS="python%{py_ver}" instroot="%{buildroot}" DESTDIR="%{buildroot}" install install-sh # currently we don't support these languages # FIXME: add to filesystem ## and rpmlint ++++++ newt-0.52.13-python_version.patch ++++++ Index: newt-0.52.13/configure =================================================================== --- newt-0.52.13.orig/configure +++ newt-0.52.13/configure @@ -3455,7 +3455,7 @@ if test "x$with_python" = "xno"; then $as_echo "skipped" >&6; } PYTHONVERS= else - PYTHONVERS=$(ls /usr/include/python*/Python.h 2> /dev/null | sed "s|/usr/include/||g"| sed "s|/Python.h||g" 2> /dev/null) + PYTHONVERS=$(ls /usr/include/python*/Python.h 2> /dev/null | sed "s|/usr/include/||g"| sed "s|/Python.h||g" | head -n1 2> /dev/null) { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHONVERS" >&5 $as_echo "$PYTHONVERS" >&6; } fi ++++++ newt-0.52.12.tar.bz2 -> newt-0.52.13.tar.bz2 ++++++ ++++ 3234 lines of diff (skipped) ++++ retrying with extended exclude list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/checkboxtree.c new/newt-0.52.13/checkboxtree.c --- old/newt-0.52.12/checkboxtree.c 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/checkboxtree.c 2011-06-27 14:24:04.000000000 +0200 @@ -118,7 +118,6 @@ va_start(argList, index); numIndexes = 0; i = index; - va_start(argList, index); while (i != NEWT_ARG_LAST) { indexes[numIndexes++] = i; i = va_arg(argList, int); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/config.h.in new/newt-0.52.13/config.h.in --- old/newt-0.52.12/config.h.in 2010-08-06 13:46:46.000000000 +0200 +++ new/newt-0.52.13/config.h.in 2011-06-27 14:27:40.000000000 +0200 @@ -9,9 +9,15 @@ /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H +/* Define to 1 if you have the <libintl.h> header file. */ +#undef HAVE_LIBINTL_H + /* Define to 1 if you have the <memory.h> header file. */ #undef HAVE_MEMORY_H +/* Define to 1 if you have the <popt.h> header file. */ +#undef HAVE_POPT_H + /* Define to 1 if you have the <stdint.h> header file. */ #undef HAVE_STDINT_H @@ -36,6 +42,9 @@ /* Define to 1 if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H +/* Default NEWT_COLORS_FILE */ +#undef NEWT_COLORS_FILE + /* Package Name */ #undef PACKAGE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/configure.ac new/newt-0.52.13/configure.ac --- old/newt-0.52.12/configure.ac 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/configure.ac 2011-06-27 14:24:04.000000000 +0200 @@ -13,19 +13,92 @@ AC_PROG_CC AC_PROG_INSTALL AC_PROG_LN_S +AC_PROG_GREP + +# Are we using GNU ld? +AC_MSG_CHECKING([for GNU ld]) +LD=`$CC -print-prog-name=ld 2>&5` + +if test `$LD -v 2>&1 | $ac_cv_path_GREP -c "GNU ld"` = 0; then + # Not + GNU_LD="" + AC_MSG_RESULT([no]) +else + GNU_LD="$LD" + AC_MSG_RESULT([yes]) + AC_SUBST([GNU_LD]) +fi AC_CHECK_HEADERS([sys/select.h alloca.h]) +AC_CHECK_HEADER([slang.h], [], [ + old_CPPFLAGS=${CPPFLAGS} + CPPFLAGS="${CPPFLAGS} -I/opt/local/include" + unset ac_cv_header_slang_h + AC_CHECK_HEADER([slang.h]) + if test x$ac_cv_header_slang_h = x; then + CPPFLAGS="${old_CPPFLAGS}" + else + LDFLAGS="${LDFLAGS} -L/opt/local/lib" + fi +]) +if test x$ac_cv_header_slang_h = x; then + old_CPPFLAGS=${CPPFLAGS} + CPPFLAGS="${CPPFLAGS} -I/sw/include" + AC_CHECK_HEADER([slang.h]) + if test x$ac_cv_header_slang_h = x; then + CPPFLAGS=${old_CPPFLAGS} + else + LDFLAGS="${LDFLAGS} -L/sw/lib" + fi +fi +AC_CHECK_HEADERS([popt.h libintl.h]) AC_MSG_CHECKING([for python versions]) -PYTHONVERS=$(echo /usr/include/python*/Python.h | sed "s|/usr/include/||g"| sed "s|/Python.h||g" 2> /dev/null) -AC_MSG_RESULT([$PYTHONVERS]) +AC_ARG_WITH([python], [ --without-python do not compile python support]) +if test "x$with_python" = "xno"; then + AC_MSG_RESULT([skipped]) + PYTHONVERS= +else + PYTHONVERS=$(ls /usr/include/python*/Python.h 2> /dev/null | sed "s|/usr/include/||g"| sed "s|/Python.h||g" 2> /dev/null) + AC_MSG_RESULT([$PYTHONVERS]) +fi AC_SUBST([PYTHONVERS]) AC_ARG_WITH([tcl], [ --without-tcl do not compile whiptcl.so]) if test "x$with_tcl" = "xno"; then WHIPTCLSO= else - AC_CHECK_HEADER([tcl.h], [WHIPTCLSO=whiptcl.so], [WHIPTCLSO=]) + AC_MSG_CHECKING([for tcl configuration]) + + # check in a few common install locations + if test x"${ac_cv_c_tclconfig}" = x ; then + for i in `ls -d ${libdir} 2>/dev/null` \ + `ls -d /usr/lib 2>/dev/null` \ + `ls -d /usr/lib64 2>/dev/null` \ + `ls -d /usr/local/lib 2>/dev/null` \ + `ls -d /usr/contrib/lib 2>/dev/null` \ + `ls -d /usr/pkg/lib 2>/dev/null` \ + `ls -d /usr/local/lib/tcl8.5 2>/dev/null` \ + `ls -d /usr/local/lib/tcl8.4 2>/dev/null` \ + `ls -d /usr/lib/tcl8.5 2>/dev/null` \ + `ls -d /usr/lib/tcl8.4 2>/dev/null` \ + `ls -d /opt/local/lib 2>/dev/null` \ + ; do + if test -f "$i/tclConfig.sh" ; then + ac_cv_c_tclconfig=`(cd $i; pwd)` + break + fi + done + fi + + if test x"${ac_cv_c_tclconfig}" != x ; then + AC_MSG_RESULT([found]) + . ${ac_cv_c_tclconfig}/tclConfig.sh + AC_SUBST([TCL_LIB_FLAG]) + WHIPTCLSO=whiptcl.so + else + AC_MSG_RESULT([NOT found]) + fi fi AC_SUBST([WHIPTCLSO]) @@ -38,7 +111,30 @@ AC_ARG_ENABLE([nls], [ --disable-nls compile without NLS support]) if test "x$enable_nls" != "xno"; then - AC_DEFINE([ENABLE_NLS], 1, [Define to 1 if NLS support is enabled]) + AC_CHECK_LIB([c], [gettext], [ ], [ + AC_CHECK_LIB([intl], [gettext], [ + LIBS="-lintl" + AC_SUBST([LIBS])], [ + if test "x$enable_nls" != "xcheck"; then + AC_MSG_FAILURE([--enable-nls was specified, but the configure check failed]) + else + enable_nls=no + fi + ]) + ]) + if test "x$enable_nls" != "xno"; then + AC_DEFINE([ENABLE_NLS], 1, [Define to 1 if NLS support is enabled]) + fi +fi + +AC_ARG_WITH(colorsfile, [ --with-colorsfile=file set default location of colors file]) + +if test "x$with_colorsfile" != "xno"; then + if test "x$with_colorsfile" != "xyes"; then + if test "x$with_colorsfile" != "x"; then + AC_DEFINE_UNQUOTED(NEWT_COLORS_FILE, "$with_colorsfile", [Default NEWT_COLORS_FILE ]) + fi + fi fi AC_CONFIG_FILES([Makefile libnewt.pc]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/dialogboxes.c new/newt-0.52.13/dialogboxes.c --- old/newt-0.52.12/dialogboxes.c 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/dialogboxes.c 2011-06-27 14:24:04.000000000 +0200 @@ -186,6 +186,8 @@ } } while (!feof(f)); + newtFormDestroy(form); + return DLG_OKAY; } @@ -217,6 +219,8 @@ *result = val; + newtFormDestroy(form); + return rc; } @@ -344,7 +348,8 @@ int len, j; len = mystrncpyw(buf, itemInfo[i].tag, MAXBUF, &w); for (j = 0; j < tagWidth - w; j++) { - if (len >= MAXBUF) break; + if (len + 1 >= MAXBUF) + break; buf[len++] = ' '; } buf[len] = '\0'; @@ -375,6 +380,9 @@ i = (long) newtListboxGetCurrent(listBox); *result = itemInfo[i].tag; + newtFormDestroy(form); + free(itemInfo); + return rc; } @@ -398,7 +406,7 @@ const char * tag; newtComponent comp; } * cbInfo = malloc(allocedBoxes * sizeof(*cbInfo)); - char * cbStates = malloc(allocedBoxes * sizeof(cbStates)); + char * cbStates = malloc(allocedBoxes * sizeof(*cbStates)); if ( (cbInfo == NULL) || (cbStates == NULL)) return DLG_ERROR; if (!(arg = poptGetArg(optCon))) return DLG_ERROR; @@ -507,6 +515,8 @@ (*selections)[numSelected] = NULL; } + newtFormDestroy(form); + return rc; } @@ -557,8 +567,8 @@ newtDrawForm(form); newtRefresh(); } - + newtFormDestroy(form); return rc; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/entry.c new/newt-0.52.13/entry.c --- old/newt-0.52.12/entry.c 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/entry.c 2011-06-27 14:24:04.000000000 +0200 @@ -23,6 +23,8 @@ int firstChar; /* first character position being shown */ newtEntryFilter filter; void * filterData; + int cs; + int csDisabled; }; static int previous_char(const char *buf, int pos); @@ -117,6 +119,9 @@ en->cursorPosition = 0; } + en->cs = NEWT_COLORSET_ENTRY; + en->csDisabled = NEWT_COLORSET_DISENTRY; + return co; } @@ -184,9 +189,9 @@ if (!co->isMapped) return; if (en->flags & NEWT_FLAG_DISABLED) - SLsmg_set_color(NEWT_COLORSET_DISENTRY); + SLsmg_set_color(en->csDisabled); else - SLsmg_set_color(NEWT_COLORSET_ENTRY); + SLsmg_set_color(en->cs); if (en->flags & NEWT_FLAG_HIDDEN) { newtGotorc(co->top, co->left); @@ -255,6 +260,14 @@ newtGotorc(row, col); } +void newtEntrySetColors(newtComponent co, int normal, int disabled) { + struct entry * en = co->data; + + en->cs = normal; + en->csDisabled = disabled; + entryDraw(co); +} + static void entryDestroy(newtComponent co) { struct entry * en = co->data; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/form.c new/newt-0.52.13/form.c --- old/newt-0.52.12/form.c 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/form.c 2011-06-27 14:24:04.000000000 +0200 @@ -308,6 +308,7 @@ sock_name = 0; } /*if*/ gpm_flag=0; + gpm_fd=-1; return -1; } @@ -372,8 +373,7 @@ *****************************************************************************/ struct element { - int top, left; /* Actual, not virtual. These are translated */ - newtComponent co; /* into actual through vertOffset */ + newtComponent co; }; struct fdInfo { @@ -395,7 +395,6 @@ int * hotKeys; int numHotKeys; int background; - int beenSet; int numFds; struct fdInfo * fds; int maxFd; @@ -428,9 +427,10 @@ struct form * form = co->data; struct element * el = form->elements + compNum; - if ((co->top + form->vertOffset) > el->top) return 0; - if ((co->top + form->vertOffset + co->height) < - (el->top + el->co->height)) return 0; + if (co->top > el->co->top) + return 0; + if (co->top + co->height < el->co->top + el->co->height) + return 0; return 1; } @@ -463,7 +463,6 @@ form->numFds = 0; form->maxFd = 0; form->fds = NULL; - form->beenSet = 0; form->elements = malloc(sizeof(*(form->elements)) * form->numCompsAlloced); form->background = COLORSET_WINDOW; @@ -493,6 +492,26 @@ return form->elements[form->currComp].co; } +static void formScroll(newtComponent co, int delta) { + struct form * form = co->data; + struct element * el; + int i, newVertOffset = form->vertOffset + delta; + + if (newVertOffset < 0) + newVertOffset = 0; + if (newVertOffset > form->numRows - co->height) + newVertOffset = form->numRows - co->height; + + delta = newVertOffset - form->vertOffset; + form->vertOffset = newVertOffset; + + for (i = 0, el = form->elements; i < form->numComps; i++, el++) { + if (el->co == form->vertBar) + continue; + el->co->ops->place(el->co, el->co->left, el->co->top - delta); + } +} + void newtFormSetCurrent(newtComponent co, newtComponent subco) { struct form * form = co->data; int i, new; @@ -506,9 +525,7 @@ if (co->isMapped && !componentFits(co, new)) { gotoComponent(form, -1); - form->vertOffset = form->elements[new].top - co->top - 1; - if (form->vertOffset > (form->numRows - co->height)) - form->vertOffset = form->numRows - co->height; + formScroll(co, form->elements[new].co->top - co->top - 1); } gotoComponent(form, new); @@ -544,9 +561,6 @@ sizeof(*(form->elements)) * form->numCompsAlloced); } - /* we grab real values for these a bit later */ - form->elements[form->numComps].left = -2; - form->elements[form->numComps].top = -2; form->elements[form->numComps].co = newco; if (newco->takesFocus && form->currComp == -1) @@ -573,17 +587,14 @@ struct element * el; int i; - newtFormSetSize(co); - vertDelta = top - co->top; horizDelta = left - co->left; co->top = top; co->left = left; for (i = 0, el = form->elements; i < form->numComps; i++, el++) { - el->top += vertDelta; - el->left += horizDelta; - el->co->ops->place(el->co, el->co->left, el->co->top); + el->co->ops->place(el->co, el->co->left + horizDelta, + el->co->top + vertDelta); } } @@ -598,19 +609,13 @@ newtClearBox(co->left, co->top, co->width, co->height); for (i = 0, el = form->elements; i < form->numComps; i++, el++) { - /* the scrollbar *always* fits somewhere */ - if (el->co == form->vertBar) { + /* only draw it if it'll fit on the screen vertically + (the scrollbar *always* fits somewhere) */ + if (el->co == form->vertBar || componentFits(co, i)) { el->co->ops->mapped(el->co, 1); el->co->ops->draw(el->co); } else { - /* only draw it if it'll fit on the screen vertically */ - if (componentFits(co, i)) { - el->co->ops->place(el->co, el->left, el->top - form->vertOffset); - el->co->ops->mapped(el->co, 1); - el->co->ops->draw(el->co); - } else { - el->co->ops->mapped(el->co, 0); - } + el->co->ops->mapped(el->co, 0); } } @@ -765,22 +770,21 @@ /* make sure this component is visible */ if (!componentFits(co, new)) { + int vertDelta; + gotoComponent(form, -1); if (dir < 0) { /* make the new component the first one */ - form->vertOffset = form->elements[new].top - co->top; + vertDelta = form->elements[new].co->top - co->top; } else { /* make the new component the last one */ - form->vertOffset = (form->elements[new].top + + vertDelta = (form->elements[new].co->top + form->elements[new].co->height) - (co->top + co->height); } - if (form->vertOffset < 0) form->vertOffset = 0; - if (form->vertOffset > (form->numRows - co->height)) - form->vertOffset = form->numRows - co->height; - + formScroll(co, vertDelta); newtDrawForm(co); } @@ -841,7 +845,8 @@ } else { return NULL; } - } + } else if (es.reason == NEWT_EXIT_ERROR) + return NULL; return es.u.co; } @@ -856,20 +861,17 @@ void newtFormSetSize(newtComponent co) { struct form * form = co->data; - int delta, i; + int delta, i, first; struct element * el; - if (form->beenSet) return; - - form->beenSet = 1; - - if (!form->numComps) return; + form->numRows = 0; co->width = 0; if (!form->fixedHeight) co->height = 0; co->top = -1; co->left = -1; + first = 1; for (i = 0, el = form->elements; i < form->numComps; i++, el++) { if (el->co->ops == &formOps) @@ -877,14 +879,12 @@ else if (el->co == form->vertBar) continue; - if (co->top == -1) { + if (first) { co->top = el->co->top; co->left = el->co->left; + first = 0; } - el->left = el->co->left; - el->top = el->co->top; - if (co->left > el->co->left) { delta = co->left - el->co->left; co->left -= delta; @@ -911,6 +911,8 @@ form->numRows = el->co->top + el->co->height - co->top; } } + + co->top += form->vertOffset; } void newtFormRun(newtComponent co, struct newtExitStruct * es) { @@ -935,7 +937,6 @@ Gpm_Open(&conn, 0); #endif - newtFormSetSize(co); /* draw all of the components */ newtDrawForm(co); @@ -1072,6 +1073,12 @@ } } + if (key == NEWT_KEY_ERROR) { + es->u.watch = -1; + es->reason = NEWT_EXIT_ERROR; + done = 1; + } + if (!done) { ev.event = EV_KEYPRESS; ev.u.key = key; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/grid.c new/newt-0.52.13/grid.c --- old/newt-0.52.12/grid.c 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/grid.c 2011-06-27 14:24:04.000000000 +0200 @@ -319,7 +319,7 @@ grid = stackem(0, type1, what1, args, 1); - va_start(args, what1); + va_end(args); return grid; } @@ -332,7 +332,7 @@ grid = stackem(1, type1, what1, args, 1); - va_start(args, what1); + va_end(args); return grid; } @@ -345,7 +345,7 @@ grid = stackem(1, type1, what1, args, 0); - va_start(args, what1); + va_end(args); return grid; } @@ -358,7 +358,7 @@ grid = stackem(0, type1, what1, args, 0); - va_start(args, what1); + va_end(args); return grid; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/label.c new/newt-0.52.13/label.c --- old/newt-0.52.12/label.c 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/label.c 2011-06-27 14:24:04.000000000 +0200 @@ -8,6 +8,7 @@ struct label { char * text; int length; + int cs; }; static void labelDraw(newtComponent co); @@ -41,6 +42,7 @@ la->length = strlen(text); la->text = strdup(text); + la->cs = COLORSET_LABEL; return co; } @@ -63,12 +65,19 @@ labelDraw(co); } +void newtLabelSetColors(newtComponent co, int colorset) { + struct label * la = co->data; + + la->cs = colorset; + labelDraw(co); +} + static void labelDraw(newtComponent co) { struct label * la = co->data; if (!co->isMapped) return; - SLsmg_set_color(COLORSET_LABEL); + SLsmg_set_color(la->cs); newtGotorc(co->top, co->left); SLsmg_write_string(la->text); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/listbox.c new/newt-0.52.13/listbox.c --- old/newt-0.52.12/listbox.c 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/listbox.c 2011-06-27 14:24:04.000000000 +0200 @@ -315,7 +315,8 @@ for(i = 0, item = li->boxItems; item != NULL && i < num; i++, item = item->next); - item->data = data; + if (item) + item->data = data; } int newtListboxAppendEntry(newtComponent co, const char * text, @@ -669,7 +670,7 @@ li->currItem > li->startShowItem) li->startShowItem = li->currItem > li->numItems - li->curHeight ? - li->startShowItem = li->numItems - li->curHeight : + li->numItems - li->curHeight : li->currItem; if(li->sb) newtScrollbarSet(li->sb, li->currItem + 1, li->numItems); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/newt.0.52.ver new/newt-0.52.13/newt.0.52.ver --- old/newt-0.52.12/newt.0.52.ver 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/newt.0.52.ver 2011-06-27 14:24:04.000000000 +0200 @@ -152,3 +152,12 @@ global: newtRadioSetCurrent; } NEWT_0.52.9; + +NEWT_0.52.13 { + global: + newtEntrySetColors; + newtLabelSetColors; + newtScaleSetColors; + newtScrollbarSetColors; + newtTextboxSetColors; +} NEWT_0.52.11; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/newt.c new/newt-0.52.13/newt.c --- old/newt-0.52.12/newt.c 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/newt.c 2011-06-27 14:24:04.000000000 +0200 @@ -223,6 +223,111 @@ } +static void updateColorset(char *fg, char *bg, char **fg_p, char **bg_p) +{ + if (*fg && fg_p) + *fg_p = fg; + if (*bg && bg_p) + *bg_p = bg; +} + +/* parse color specifications (e.g. root=,black:border=red,blue) + * and update the palette + */ +static void parseColors(char *s, struct newtColors *palette) +{ + char *name, *str, *fg, *bg; + + for (str = s; (s = strtok(str, ";:\n\r\t ")); str = NULL) { + name = s; + if (!(s = strchr(s, '=')) || !*s) + continue; + *s = '\0'; + fg = ++s; + if (!(s = strchr(s, ',')) || !*s) + continue; + *s = '\0'; + bg = ++s; + + if (!strcmp(name, "root")) + updateColorset(fg, bg, &palette->rootFg, &palette->rootBg); + else if (!strcmp(name, "border")) + updateColorset(fg, bg, &palette->borderFg, &palette->borderBg); + else if (!strcmp(name, "window")) + updateColorset(fg, bg, &palette->windowFg, &palette->windowBg); + else if (!strcmp(name, "shadow")) + updateColorset(fg, bg, &palette->shadowFg, &palette->shadowBg); + else if (!strcmp(name, "title")) + updateColorset(fg, bg, &palette->titleFg, &palette->titleBg); + else if (!strcmp(name, "button")) + updateColorset(fg, bg, &palette->buttonFg, &palette->buttonBg); + else if (!strcmp(name, "actbutton")) + updateColorset(fg, bg, &palette->actButtonFg, &palette->actButtonBg); + else if (!strcmp(name, "checkbox")) + updateColorset(fg, bg, &palette->checkboxFg, &palette->checkboxBg); + else if (!strcmp(name, "actcheckbox")) + updateColorset(fg, bg, &palette->actCheckboxFg, &palette->actCheckboxBg); + else if (!strcmp(name, "entry")) + updateColorset(fg, bg, &palette->entryFg, &palette->entryBg); + else if (!strcmp(name, "label")) + updateColorset(fg, bg, &palette->labelFg, &palette->labelBg); + else if (!strcmp(name, "listbox")) + updateColorset(fg, bg, &palette->listboxFg, &palette->listboxBg); + else if (!strcmp(name, "actlistbox")) + updateColorset(fg, bg, &palette->actListboxFg, &palette->actListboxBg); + else if (!strcmp(name, "textbox")) + updateColorset(fg, bg, &palette->textboxFg, &palette->textboxBg); + else if (!strcmp(name, "acttextbox")) + updateColorset(fg, bg, &palette->actTextboxFg, &palette->actTextboxBg); + else if (!strcmp(name, "helpline")) + updateColorset(fg, bg, &palette->helpLineFg, &palette->helpLineBg); + else if (!strcmp(name, "roottext")) + updateColorset(fg, bg, &palette->rootTextFg, &palette->rootTextBg); + else if (!strcmp(name, "emptyscale")) + updateColorset(fg, bg, NULL, &palette->emptyScale); + else if (!strcmp(name, "fullscale")) + updateColorset(fg, bg, NULL, &palette->fullScale); + else if (!strcmp(name, "disentry")) + updateColorset(fg, bg, &palette->disabledEntryFg, &palette->disabledEntryBg); + else if (!strcmp(name, "compactbutton")) + updateColorset(fg, bg, &palette->compactButtonFg, &palette->compactButtonBg); + else if (!strcmp(name, "actsellistbox")) + updateColorset(fg, bg, &palette->actSelListboxFg, &palette->actSelListboxBg); + else if (!strcmp(name, "sellistbox")) + updateColorset(fg, bg, &palette->selListboxFg, &palette->selListboxBg); + } +} + +static void initColors(void) +{ + char *colors, *colors_file, buf[16384]; + FILE *f; + struct newtColors palette; + + palette = newtDefaultColorPalette; + + colors_file = getenv("NEWT_COLORS_FILE"); +#ifdef NEWT_COLORS_FILE + if (colors_file == NULL) + colors_file = NEWT_COLORS_FILE; +#endif + + if ((colors = getenv("NEWT_COLORS"))) { + strncpy(buf, colors, sizeof (buf)); + buf[sizeof (buf) - 1] = '\0'; + parseColors(buf, &palette); + } else if (colors_file && *colors_file && (f = fopen(colors_file, "r"))) { + size_t r; + if ((r = fread(buf, 1, sizeof (buf) - 1, f)) > 0) { + buf[r] = '\0'; + parseColors(buf, &palette); + } + fclose(f); + } + + newtSetColors(palette); +} + void newtFlushInput(void) { while (SLang_input_pending(0)) { getkey(); @@ -308,7 +413,7 @@ if ((ret = SLang_init_tty(0, 0, 0)) < 0) return ret; - newtSetColors(newtDefaultColorPalette); + initColors(); newtCursorOff(); initKeymap(); @@ -417,7 +522,8 @@ } void newtSetColor(int colorset, char *fg, char *bg) { - if (colorset < NEWT_COLORSET_ROOT || colorset > NEWT_COLORSET_SELLISTBOX || + if (colorset < NEWT_COLORSET_ROOT || + (colorset > NEWT_COLORSET_SELLISTBOX && colorset < NEWT_COLORSET_CUSTOM(0)) || !SLtt_Use_Ansi_Colors) return; @@ -555,32 +661,30 @@ } int newtGetKey(void) { - int key; + int key, lastcode, errors = 0; unsigned char *chptr = keyreader_buf, *lastmatch; - int lastcode; struct kmap_trie_entry *curr = kmap_trie_root; do { key = getkey(); if (key == SLANG_GETKEY_ERROR) { - /* Either garbage was read, or stdin disappeared - * (the parent terminal was proably closed) - * if the latter, die. - */ - if (feof(stdin)) - exit(1); if (needResize) { needResize = 0; return NEWT_KEY_RESIZE; } - /* ignore other signals */ + /* Ignore other signals, but assume that stdin disappeared (the + * parent terminal was proably closed) if the error persists. + */ + if (errors++ > 10) + return NEWT_KEY_ERROR; + continue; } if (key == NEWT_KEY_SUSPEND && suspendCallback) suspendCallback(suspendCallbackData); - } while (key == NEWT_KEY_SUSPEND); + } while (key == NEWT_KEY_SUSPEND || key == SLANG_GETKEY_ERROR); /* Read more characters, matching against the trie as we go */ lastcode = *chptr = key; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/newt.h new/newt-0.52.13/newt.h --- old/newt-0.52.12/newt.h 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/newt.h 2011-06-27 14:24:04.000000000 +0200 @@ -31,6 +31,8 @@ #define NEWT_COLORSET_ACTSELLISTBOX 23 #define NEWT_COLORSET_SELLISTBOX 24 +#define NEWT_COLORSET_CUSTOM(x) (30 + (x)) + #define NEWT_ARG_LAST -100000 #define NEWT_ARG_APPEND -1 @@ -159,9 +161,11 @@ newtComponent newtLabel(int left, int top, const char * text); void newtLabelSetText(newtComponent co, const char * text); +void newtLabelSetColors(newtComponent co, int colorset); newtComponent newtVerticalScrollbar(int left, int top, int height, int normalColorset, int thumbColorset); void newtScrollbarSet(newtComponent co, int where, int total); +void newtScrollbarSetColors(newtComponent co, int normal, int thumb); newtComponent newtListbox(int left, int top, int height, int flags); void * newtListboxGetCurrent(newtComponent co); @@ -212,12 +216,13 @@ void newtTextboxSetText(newtComponent co, const char * text); void newtTextboxSetHeight(newtComponent co, int height); int newtTextboxGetNumLines(newtComponent co); +void newtTextboxSetColors(newtComponent co, int normal, int active); char * newtReflowText(char * text, int width, int flexDown, int flexUp, int * actualWidth, int * actualHeight); struct newtExitStruct { enum { NEWT_EXIT_HOTKEY, NEWT_EXIT_COMPONENT, NEWT_EXIT_FDREADY, - NEWT_EXIT_TIMER } reason; + NEWT_EXIT_TIMER, NEWT_EXIT_ERROR } reason; union { int watch; int key; @@ -249,9 +254,11 @@ void newtEntrySetFilter(newtComponent co, newtEntryFilter filter, void * data); char * newtEntryGetValue(newtComponent co); void newtEntrySetFlags(newtComponent co, int flags, enum newtFlagsSense sense); +void newtEntrySetColors(newtComponent co, int normal, int disabled); newtComponent newtScale(int left, int top, int width, long long fullValue); void newtScaleSet(newtComponent co, unsigned long long amount); +void newtScaleSetColors(newtComponent co, int empty, int full); void newtComponentAddCallback(newtComponent co, newtCallback f, void * data); void newtComponentTakesFocus(newtComponent co, int val); @@ -307,6 +314,7 @@ /* not really a key, but newtGetKey returns it */ #define NEWT_KEY_RESIZE NEWT_KEY_EXTRA_BASE + 113 +#define NEWT_KEY_ERROR NEWT_KEY_EXTRA_BASE + 114 #define NEWT_ANCHOR_LEFT (1 << 0) #define NEWT_ANCHOR_RIGHT (1 << 1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/newt.spec new/newt-0.52.13/newt.spec --- old/newt-0.52.12/newt.spec 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/newt.spec 2011-06-27 14:24:04.000000000 +0200 @@ -1,7 +1,7 @@ %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} Summary: A library for text mode user interfaces Name: newt -Version: 0.52.12 +Version: 0.52.13 Release: 1%{?dist} License: LGPLv2 Group: System Environment/Libraries @@ -68,7 +68,7 @@ %install rm -rf $RPM_BUILD_ROOT -make instroot=$RPM_BUILD_ROOT install +make DESTDIR=$RPM_BUILD_ROOT install %find_lang %{name} @@ -104,6 +104,24 @@ %{python_sitearch}/*.py* %changelog +* Mon Jun 27 2011 Miroslav Lichvar <[email protected]> - 0.52.13-1 +- add support for changing colors in individual labels, scrollbars, entries, + textboxes and scales, add custom colorsets +- add support for NEWT_COLORS and NEWT_COLORS_FILE variables (#689903) +- allow resizing of form +- fix errors found by coverity +- fix va_list usage (Gwenole Beauchesne) +- fix building and installing on Mac OS X (#652479) +- check for slang.h header, support DESTDIR variable, add --without-python + option (Otavio Salvador) +- add Persian, Low German translations + +* Tue Feb 08 2011 Fedora Release Engineering <[email protected]> - 0.52.12-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Wed Nov 10 2010 Miroslav Lichvar <[email protected]> - 0.52.12-2 +- don't hang in form when stdin disappears + * Fri Aug 06 2010 Miroslav Lichvar <[email protected]> - 0.52.12-1 - fix whiptail --gauge and its description in man page (#620083) - remove space after \n in whiptail texts (#620083) Files old/newt-0.52.12/po/et.mo and new/newt-0.52.13/po/et.mo differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/po/et.po new/newt-0.52.13/po/et.po --- old/newt-0.52.12/po/et.po 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/po/et.po 2011-06-27 14:24:04.000000000 +0200 @@ -2,7 +2,7 @@ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. -# +# msgid "" msgstr "" "Project-Id-Version: Newt\n" @@ -21,10 +21,6 @@ msgid "Ok" msgstr "Olgu" -#: ../dialogboxes.c:51 -msgid "Cancel" -msgstr "Tühista" - #: ../dialogboxes.c:498 msgid "Yes" msgstr "Jah" @@ -32,3 +28,7 @@ #: ../dialogboxes.c:500 msgid "No" msgstr "Ei" + +#: ../dialogboxes.c:51 +msgid "Cancel" +msgstr "Loobu" Files old/newt-0.52.12/po/fa.mo and new/newt-0.52.13/po/fa.mo differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/po/fa.po new/newt-0.52.13/po/fa.po --- old/newt-0.52.12/po/fa.po 1970-01-01 01:00:00.000000000 +0100 +++ new/newt-0.52.13/po/fa.po 2011-06-27 14:24:04.000000000 +0200 @@ -0,0 +1,37 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: 1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2006-09-14 16:03+0200\n" +"PO-Revision-Date: 2010-08-20 05:02+0330\n" +"Last-Translator: Mostafa <[email protected]>\n" +"Language-Team: Persian <[email protected]>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Persian\n" +"X-Poedit-Country: Iran\n" + +#: ../dialogboxes.c:43 +#: ../dialogboxes.c:48 +#: ../dialogboxes.c:493 +msgid "Ok" +msgstr "تایید" + +#: ../dialogboxes.c:51 +msgid "Cancel" +msgstr "لغو" + +#: ../dialogboxes.c:498 +msgid "Yes" +msgstr "بله" + +#: ../dialogboxes.c:500 +msgid "No" +msgstr "نه" + Files old/newt-0.52.12/po/nb.mo and new/newt-0.52.13/po/nb.mo differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/po/nb.po new/newt-0.52.13/po/nb.po --- old/newt-0.52.12/po/nb.po 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/po/nb.po 2011-06-27 14:24:04.000000000 +0200 @@ -9,9 +9,9 @@ "POT-Creation-Date: 2006-09-14 16:03+0200\n" "PO-Revision-Date: 2003-07-13 13:25+0100\n" "Last-Translator: Alastair McKinstry <[email protected]>\n" -"Language-Team: Norwegian <[email protected]>\n" +"Language-Team: Norwegian <[email protected]>\n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=ISO-8859-15\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../dialogboxes.c:43 ../dialogboxes.c:48 ../dialogboxes.c:493 Files old/newt-0.52.12/po/nds.mo and new/newt-0.52.13/po/nds.mo differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/po/nds.po new/newt-0.52.13/po/nds.po --- old/newt-0.52.12/po/nds.po 1970-01-01 01:00:00.000000000 +0100 +++ new/newt-0.52.13/po/nds.po 2011-06-27 14:24:04.000000000 +0200 @@ -0,0 +1,35 @@ +# Low German translations for newt +# Copyright (C) 2003 Free Software Foundation +# This file is distributed under the same license as the newt package. +# Nils-Christoph Fiedler <[email protected]>, 2010. +# +msgid "" +msgstr "" +"Project-Id-Version: newt 0.51.4\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2006-09-14 16:03+0200\n" +"PO-Revision-Date: 2010-12-03 15:30+0100\n" +"Last-Translator: Nils-Christoph Fiedler <[email protected]>\n" +"Language-Team: Fedora Low German <[email protected]>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-15\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../dialogboxes.c:43 +#: ../dialogboxes.c:48 +#: ../dialogboxes.c:493 +msgid "Ok" +msgstr "Ok" + +#: ../dialogboxes.c:51 +msgid "Cancel" +msgstr "Avbreken" + +#: ../dialogboxes.c:498 +msgid "Yes" +msgstr "Jau" + +#: ../dialogboxes.c:500 +msgid "No" +msgstr "Nee" + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/scale.c new/newt-0.52.13/scale.c --- old/newt-0.52.12/scale.c 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/scale.c 2011-06-27 14:24:04.000000000 +0200 @@ -9,6 +9,8 @@ long long fullValue; int charsSet; unsigned int percentage; + int csEmpty; + int csFull; }; static void scaleDraw(newtComponent co); @@ -41,6 +43,8 @@ sc->fullValue = fullValue; sc->charsSet = 0; sc->percentage = 0; + sc->csEmpty = NEWT_COLORSET_EMPTYSCALE; + sc->csFull = NEWT_COLORSET_FULLSCALE; return co; } @@ -67,6 +71,14 @@ } } +void newtScaleSetColors(newtComponent co, int empty, int full) { + struct scale * sc = co->data; + + sc->csEmpty = empty; + sc->csFull = full; + scaleDraw(co); +} + static void scaleDraw(newtComponent co) { struct scale * sc = co->data; int i; @@ -79,11 +91,11 @@ sprintf(percent, "%3d%%", sc->percentage); - SLsmg_set_color(NEWT_COLORSET_FULLSCALE); + SLsmg_set_color(sc->csFull); for (i = 0; i < co->width; i++) { if (i == sc->charsSet) - SLsmg_set_color(NEWT_COLORSET_EMPTYSCALE); + SLsmg_set_color(sc->csEmpty); if (i >= xlabel && i < xlabel+4) SLsmg_write_char(percent[i-xlabel]); else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/scrollbar.c new/newt-0.52.13/scrollbar.c --- old/newt-0.52.12/scrollbar.c 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/scrollbar.c 2011-06-27 14:24:04.000000000 +0200 @@ -69,6 +69,14 @@ return co; } +void newtScrollbarSetColors(newtComponent co, int normal, int thumb) { + struct scrollbar * sb = co->data; + + sb->cs = normal; + sb->csThumb = thumb; + sbDraw(co); +} + static void sbDraw(newtComponent co) { struct scrollbar * sb = co->data; int i; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/snack.py new/newt-0.52.13/snack.py --- old/newt-0.52.12/snack.py 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/snack.py 2011-06-27 14:24:04.000000000 +0200 @@ -240,6 +240,7 @@ - Label(self,text) : create label - setText(self,text) : change text. + - setColors(self, colorset) : change individual colors """ def setText(self, text): self.w.labelText(text) @@ -247,6 +248,9 @@ def __init__(self, text): self.w = _snack.label(text) + def setColors(self, colorset): + self.w.labelSetColors(colorset) + class Scale(Widget): """A Scale (progress bar). @@ -517,7 +521,11 @@ return _snack.refresh() def setColor(self, colorset, fg, bg): - return _snack.setcolor(colorsets[colorset], fg, bg) + if colorset in colorsets: + return _snack.setcolor(colorsets[colorset], fg, bg) + else: + # assume colorset is an integer for the custom color set + return _snack.setcolor(colorset, fg, bg) def reflow(text, width, flexDown = 5, flexUp = 5): """ returns a tuple of the wrapped text, the actual width, and the actual height @@ -982,3 +990,6 @@ def clear(self): self.listbox.clear() + +def customColorset(x): + return 30 + x diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/snackmodule.c new/newt-0.52.13/snackmodule.c --- old/newt-0.52.12/snackmodule.c 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/snackmodule.c 2011-06-27 14:24:04.000000000 +0200 @@ -195,6 +195,7 @@ static void widgetDestructor(PyObject * s); static PyObject * widgetEntrySetValue(snackWidget * s, PyObject * args); static PyObject * widgetLabelText(snackWidget * s, PyObject * args); +static PyObject * widgetLabelSetColors(snackWidget * s, PyObject * args); static PyObject * widgetListboxSetW(snackWidget * s, PyObject * args); static PyObject * widgetListboxAdd(snackWidget * s, PyObject * args); static PyObject * widgetListboxIns(snackWidget * s, PyObject * args); @@ -219,6 +220,7 @@ static PyMethodDef widgetMethods[] = { { "setCallback", (PyCFunction) widgetAddCallback, METH_VARARGS, NULL }, + { "labelSetColors", (PyCFunction) widgetLabelSetColors, METH_VARARGS, NULL }, { "labelText", (PyCFunction) widgetLabelText, METH_VARARGS, NULL }, { "textboxText", (PyCFunction) widgetTextboxText, METH_VARARGS, NULL }, { "textboxHeight", (PyCFunction) widgetTextboxHeight, METH_VARARGS, NULL }, @@ -660,6 +662,17 @@ Py_INCREF(Py_None); return Py_None; +} + +static PyObject * widgetLabelSetColors(snackWidget * s, PyObject * args) { + int colorset; + + if (!PyArg_ParseTuple(args, "i", &colorset)) return NULL; + + newtLabelSetColors(s->co, colorset); + + Py_INCREF(Py_None); + return Py_None; } static PyObject * widgetTextboxText(snackWidget * s, PyObject * args) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/textbox.c new/newt-0.52.13/textbox.c --- old/newt-0.52.12/textbox.c 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/textbox.c 2011-06-27 14:24:04.000000000 +0200 @@ -14,10 +14,12 @@ int numLines; int linesAlloced; int doWrap; - newtComponent sb_act, sb; + newtComponent sb; int topLine; int textWidth; int isActive; + int cs; + int csActive; }; static char * expandTabs(const char * text); @@ -45,7 +47,6 @@ co->isMapped = isMapped; if (tb->sb) { tb->sb->ops->mapped(tb->sb, isMapped); - tb->sb_act->ops->mapped(tb->sb_act, isMapped); } } @@ -57,7 +58,6 @@ if (tb->sb) { tb->sb->ops->place(tb->sb, co->left + co->width - 1, co->top); - tb->sb_act->ops->place(tb->sb_act, co->left + co->width - 1, co->top); } } @@ -115,21 +115,29 @@ tb->topLine = 0; tb->textWidth = width; tb->isActive = 0; + tb->cs = COLORSET_TEXTBOX; + tb->csActive = COLORSET_ACTTEXTBOX; if (flags & NEWT_FLAG_SCROLL) { co->width += 2; - tb->sb_act = newtVerticalScrollbar(co->left + co->width - 1, co->top, - co->height, COLORSET_ACTTEXTBOX, COLORSET_TEXTBOX); tb->sb = newtVerticalScrollbar(co->left + co->width - 1, co->top, - co->height, COLORSET_TEXTBOX, COLORSET_TEXTBOX); + co->height, tb->cs, tb->cs); co->takesFocus = 1; } else { - tb->sb_act = tb->sb = NULL; + tb->sb = NULL; } return co; } +void newtTextboxSetColors(newtComponent co, int normal, int active) { + struct textbox * tb = co->data; + + tb->cs = normal; + tb->csActive = active; + textboxDraw(co); +} + static char * expandTabs(const char * text) { int bufAlloced = strlen(text) + 40; char * buf, * dest; @@ -369,16 +377,12 @@ if (tb->sb) { size = tb->numLines - c->height; - if (tb->isActive) { - newtScrollbarSet(tb->sb_act, tb->topLine, size ? size : 0); - tb->sb_act->ops->draw(tb->sb_act); - } else { - newtScrollbarSet(tb->sb, tb->topLine, size ? size : 0); - tb->sb->ops->draw(tb->sb); - } + newtScrollbarSet(tb->sb, tb->topLine, size ? size : 0); + newtScrollbarSetColors(tb->sb, tb->isActive ? tb->csActive : + tb->cs, tb->cs); } - SLsmg_set_color(NEWT_COLORSET_TEXTBOX); + SLsmg_set_color(tb->cs); for (i = 0; (i + tb->topLine) < tb->numLines && i < c->height; i++) { newtGotorc(c->top + i, c->left); @@ -469,8 +473,6 @@ if (tb->sb) tb->sb->ops->destroy(tb->sb); - if (tb->sb_act) - tb->sb_act->ops->destroy(tb->sb_act); for (i = 0; i < tb->numLines; i++) free(tb->lines[i]); free(tb->lines); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/whiptail.c new/newt-0.52.13/whiptail.c --- old/newt-0.52.12/whiptail.c 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/whiptail.c 2011-06-27 14:24:04.000000000 +0200 @@ -8,6 +8,7 @@ #include <unistd.h> #include <wchar.h> #include <slang.h> +#include <sys/stat.h> #include "nls.h" #include "dialogboxes.h" @@ -305,8 +306,10 @@ exit(DLG_ERROR); } - if ( (buf = malloc(s.st_size + 1)) == 0 ) + if ( (buf = malloc(s.st_size + 1)) == 0 ) { fprintf(stderr, _("%s: too large to display.\n"), filename); + exit(DLG_ERROR); + } if ( read(fd, buf, s.st_size) != s.st_size ) { perror(filename); @@ -321,7 +324,6 @@ enum mode mode = MODE_NONE; poptContext optCon; int arg; - const char * optArg; char * text; const char * nextArg; char * end; @@ -395,8 +397,6 @@ optCon = poptGetContext("whiptail", argc, argv, optionsTable, 0); while ((arg = poptGetNextOpt(optCon)) > 0) { - optArg = poptGetOptArg(optCon); - switch (arg) { case OPT_INFOBOX: if (mode != MODE_NONE) usage(WAS_ERROR); @@ -482,7 +482,11 @@ if (!(nextArg = poptGetArg(optCon))) usage(WAS_ERROR); text = strdup(nextArg); - if (mode == MODE_TEXTBOX ) text = readTextFile(text); + if (mode == MODE_TEXTBOX) { + char *t = text; + text = readTextFile(t); + free(t); + } if (!(nextArg = poptGetArg(optCon))) usage(WAS_ERROR); height = strtoul(nextArg, &end, 10); @@ -494,8 +498,14 @@ if (mode == MODE_GAUGE) { fd = dup(0); - close(0); - if (open("/dev/tty", O_RDWR) != 0) perror("open /dev/tty"); + if (fd < 0 || close(0) < 0) { + perror("dup/close stdin"); + exit(DLG_ERROR); + } + if (open("/dev/tty", O_RDWR) != 0) { + perror("open /dev/tty"); + exit(DLG_ERROR); + } } newtInit(); @@ -601,5 +611,8 @@ newtPopWindow(); newtFinished(); + free(text); + poptFreeContext(optCon); + return ( rc == DLG_ESCAPE ) ? -1 : rc; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/newt-0.52.12/windows.c new/newt-0.52.13/windows.c --- old/newt-0.52.12/windows.c 2010-08-06 13:45:34.000000000 +0200 +++ new/newt-0.52.13/windows.c 2011-06-27 14:24:04.000000000 +0200 @@ -167,7 +167,7 @@ ++totalButtons; va_end(args); - buttons = (newtComponent *)alloca(sizeof(newtComponent*)*(totalButtons)); + buttons = (newtComponent *)alloca(sizeof(newtComponent)*(totalButtons)); va_start(args, button1); for (buttonName = button1; buttonName; buttonName = va_arg(args, char *)) buttons[numButtons++] = newtButton(-1, -1, buttonName); @@ -226,7 +226,7 @@ ++totalButtons; va_end(args); - buttons = (newtComponent *)alloca(sizeof(newtComponent*)*(totalButtons)); + buttons = (newtComponent *)alloca(sizeof(newtComponent)*(totalButtons)); va_start(args, button1); for (buttonName = button1; buttonName; buttonName = va_arg(args, char *)) buttons[numButtons++] = newtButton(-1, -1, buttonName); ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
