From: havill Date: Sat, 4 Jan 2003 19:15:25 +0000 (+0000) Subject: - cleaned up const qualifiers in interfaces X-Git-Tag: r0-51-3~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=16e8af2f4d8a1c9777fa4b95d87e1c25f0b6cf96;p=thirdparty%2Fnewt.git - cleaned up const qualifiers in interfaces - added Ctrl-L screen refresh - fixed segfault in test.c when listbox items are selected - accessibility: made newt useable with monochrome terms (#60931) - leave the symbols in the libs (#60400) - fixed grammar in tutorial (#63496) - removed obsolete URL reference in tutorial.sgml - error checking (curcomp exists) for formEvent, newtFormGetCurrent, removed fifty button limit (#59027) - allowed the test progs showchars and showkey to be build via the makefile --- diff --git a/Makefile.in b/Makefile.in index b2eee73..3c65d9d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -17,7 +17,7 @@ PYTHONVERS = $(shell ls -d /usr/include/python* | sed "s|/usr/include/||g") WHIPTCLSO= #WHIPTCLSO=whiptcl.so -PROGS = test whiptail $(WHIPTCLSO) testgrid testtree +PROGS = test whiptail $(WHIPTCLSO) testgrid testtree showchars showkey TESTOBJS = test.o NDIALOGOBJS = whiptail.o dialogboxes.o WHIPTCLOBJS = whiptcl.o dialogboxes.o @@ -60,6 +60,12 @@ testgrid: testgrid.o $(LIBNEWT) testtree: testtree.o $(LIBNEWT) gcc -g -o testtree testtree.o $(LIBNEWT) $(LIBS) +showchars: showchars.o $(LIBNEWT) + gcc -g -o showchars showchars.o $(LIBNEWT) $(LIBS) + +showkey: showkey.o $(LIBNEWT) + gcc -g -o showkey showkey.o $(LIBNEWT) $(LIBS) + _snackmodule.so: snackmodule.c $(LIBNEWTSH) for ver in $(PYTHONVERS) ; do \ if [ ! -f "$$ver/_snackmodule.so" -o $(LIBNEWTSH) -nt "$$ver/_snackmodule.so" ]; then \ diff --git a/form.c b/form.c index 3dd87c3..534ca29 100644 --- a/form.c +++ b/form.c @@ -1013,7 +1013,7 @@ void newtFormRun(newtComponent co, struct newtExitStruct * es) { key = newtGetKey(); if (key == NEWT_KEY_RESIZE) { - /* newtResizeScreen(1); */ + newtResizeScreen(1); continue; } diff --git a/newt.c b/newt.c index 97a7f52..3b6dae0 100644 --- a/newt.c +++ b/newt.c @@ -37,7 +37,7 @@ static char * helplineStack[20]; static char ** currentHelpline = NULL; static int cursorRow, cursorCol; -static int needResize; +static int needResize = 0; static int cursorOn = 1; static int trashScreen = 0; @@ -124,11 +124,10 @@ static const struct keymap keymap[] = { }; static char keyPrefix = '\033'; -static const char *const version = // ident friendly - "$Version: Newt windowing library version " VERSION "$" - "$License: (C) 1996-2003 Red Hat, Inc. " - "Licensed under the terms of the Lesser GNU Public License. " - "Originally written by Erik Troan $"; +static const char ident[] = // ident friendly + "$Version: Newt windowing library v" VERSION " $" + "$Copyright: (C) 1996-2003 Red Hat, Inc. Written by Erik Troan $" + "$License: Lesser GNU Public License. $"; static newtSuspendCallback suspendCallback = NULL; static void * suspendCallbackData = NULL; @@ -170,9 +169,20 @@ int wstrlen(const char *str, int len) { return nchars; } +static int getkey() { + int c; + + while ((c = SLang_getkey()) == '\xC') { /* if Ctrl-L redraw whole screen */ + SLsmg_touch_lines (0, SLtt_Screen_Rows - 1); + SLsmg_refresh(); + } + return c; + +} + void newtFlushInput(void) { while (SLang_input_pending(0)) { - SLang_getkey(); + getkey(); } } @@ -201,34 +211,27 @@ void newtCls(void) { newtRefresh(); } -#if defined(THIS_DOESNT_WORK) void newtResizeScreen(int redraw) { - newtPushHelpLine(""); - SLtt_get_screen_size(); - SLang_init_tty(0, 0, 0); - - SLsmg_touch_lines (0, SLtt_Screen_Rows - 1); - - /* I don't know why I need this */ - SLsmg_refresh(); - - newtPopHelpLine(); - - if (redraw) - SLsmg_refresh(); + SLsmg_reinit_smg(); + if (redraw) { + SLsmg_touch_lines (0, SLtt_Screen_Rows - 1); + newtRefresh(); + } } -#endif int newtInit(void) { - char * MonoValue, * MonoEnv = "NEWT_MONO", * lang; - - lang = getenv ("LANG"); - if (lang && !strcasecmp (lang, "ja_JP.eucJP")) + char * MonoValue, * MonoEnv = "NEWT_MONO"; + const char *lang; + + if ((lang = getenv("LC_ALL")) == NULL) + if ((lang = getenv("LC_CTYPE")) == NULL) + if ((lang = getenv("LANG")) == NULL) + lang = ""; + if (strstr (lang, ".euc") != NULL) trashScreen = 1; - /* use the version variable just to be sure it gets included */ - strlen(version); + (void) strlen(ident); SLtt_get_terminfo(); SLtt_get_screen_size(); @@ -270,6 +273,26 @@ int newtFinished(void) { } void newtSetColors(struct newtColors colors) { + if (!SLtt_Use_Ansi_Colors) { + int i; + + for (i = 2; i < 25; i++) + SLtt_set_mono(i, NULL, 0); + + SLtt_set_mono(NEWT_COLORSET_SELLISTBOX, NULL, SLTT_BOLD_MASK); + + SLtt_set_mono(NEWT_COLORSET_ACTBUTTON, NULL, SLTT_REV_MASK); + SLtt_set_mono(NEWT_COLORSET_ACTCHECKBOX, NULL, SLTT_REV_MASK); + SLtt_set_mono(NEWT_COLORSET_ACTLISTBOX, NULL, SLTT_REV_MASK); + SLtt_set_mono(NEWT_COLORSET_ACTTEXTBOX, NULL, SLTT_REV_MASK); + + SLtt_set_mono(NEWT_COLORSET_ACTSELLISTBOX, NULL, SLTT_REV_MASK | SLTT_BOLD_MASK); + + SLtt_set_mono(NEWT_COLORSET_DISENTRY, NULL, 0); // FIXME + SLtt_set_mono(NEWT_COLORSET_FULLSCALE, NULL, SLTT_ULINE_MASK | SLTT_REV_MASK); + SLtt_set_mono(NEWT_COLORSET_EMPTYSCALE, NULL, SLTT_ULINE_MASK); + return; + } SLtt_set_color(NEWT_COLORSET_ROOT, "", colors.rootFg, colors.rootBg); SLtt_set_color(NEWT_COLORSET_BORDER, "", colors.borderFg, colors.borderBg); SLtt_set_color(NEWT_COLORSET_WINDOW, "", colors.windowFg, colors.windowBg); @@ -319,10 +342,12 @@ int newtGetKey(void) { const struct keymap * curr; do { - key = SLang_getkey(); + key = getkey(); if (key == 0xFFFF) { - if (needResize) + if (needResize) { + needResize = 0; return NEWT_KEY_RESIZE; + } /* ignore other signals */ continue; @@ -355,7 +380,7 @@ int newtGetKey(void) { *chptr++ = key; while (SLang_input_pending(5)) { - key = SLang_getkey(); + key = getkey(); if (key == keyPrefix) { /* he hit unknown keys too many times -- start over */ memset(buf, 0, sizeof(buf)); @@ -397,13 +422,13 @@ int newtGetKey(void) { void newtWaitForKey(void) { newtRefresh(); - SLang_getkey(); + getkey(); newtClearKeyBuffer(); } void newtClearKeyBuffer(void) { while (SLang_input_pending(1)) { - SLang_getkey(); + getkey(); } } diff --git a/newt.spec b/newt.spec index 2c7f6d8..c713e78 100644 --- a/newt.spec +++ b/newt.spec @@ -4,7 +4,7 @@ Summary: A development library for text mode user interfaces. Name: newt %define version 0.52.0 Version: %{version} -Release: 1 +Release: 3 License: LGPL Group: System Environment/Libraries Source: newt-%{version}.tar.gz @@ -81,12 +81,15 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libnewt.so %changelog -* Fri Jan 3 2003 Adrian Havill 0.52.0-1 +* Sun Jan 5 2003 Adrian Havill 0.52.0-3 - cleaned up const qualifiers in interfaces +- added Ctrl-L screen refresh +- fixed segfault in test.c when listbox items are selected +- accessibility: made newt useable with monochrome terms (#60931) - leave the symbols in the libs (#60400) - fixed grammar in tutorial (#63496) -- removed fifty button limit (#59027) -- error checking (curcomp exists) for formEvent, newtFormGetCurrent (#59027) +- error checking (curcomp exists) for formEvent, newtFormGetCurrent, + removed fifty button limit (#59027) * Tue Dec 17 2002 Matt Wilson 0.51.2-1 - fixed wstrlen() it was calculating wcwidth(first wide char in diff --git a/showchars.c b/showchars.c index 71d0adb..eb999ed 100644 --- a/showchars.c +++ b/showchars.c @@ -17,8 +17,6 @@ void printall(int offset) { } int main(void) { - char n = 0; - SLtt_get_terminfo(); SLtt_Use_Ansi_Colors = 1; diff --git a/showkey.c b/showkey.c index 5f465b5..14baf6c 100644 --- a/showkey.c +++ b/showkey.c @@ -2,7 +2,6 @@ #include int main(void) { - char n = 0; int i; char * buf; @@ -38,4 +37,5 @@ int main(void) { printf("\n\r"); SLang_reset_tty(); + return 0; } diff --git a/test.c b/test.c index 33be2c8..c1b9aa8 100644 --- a/test.c +++ b/test.c @@ -154,10 +154,10 @@ int main(void) { printf("got string 2: %s\n", enr2); printf("got string 3: %s\n", enr3); + printf("\nSelected listbox items (%d):\n", numsel); if(selectedList) { - printf("\nSelected listbox items:\n"); for(i = 0; i < numsel; i++) - puts(selectedList[i]); + printf("#%d\n", (int) selectedList[i]); } return 0; diff --git a/tutorial.sgml b/tutorial.sgml index 91e58b7..e15a338 100644 --- a/tutorial.sgml +++ b/tutorial.sgml @@ -8,7 +8,7 @@ Erik Troan, <ewt@redhat.com> -v0.30, 13 May 1998 +v0.31, 2003-Jan-06 @@ -35,7 +35,7 @@ makes it significantly easier to craft robust newt tutorial documents newt 0.30 --- older versions of newt had annoying inconsistencies in it (which writing this tutorial pointed out), which were removed while this tutorial was written. The latest version of -newt is always available from ftp.redhat.com. +newt is always available from Red Hat. Background