From: Art Cancro Date: Wed, 25 Jun 2003 15:40:57 +0000 (+0000) Subject: * setup now uses "newt" instead of "curses" to draw its pretty screens. X-Git-Tag: v7.86~5843 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=bf31d51cb3ec15bfb63442f46ee9adbc62950e98;p=citadel.git * setup now uses "newt" instead of "curses" to draw its pretty screens. Changes were made to setup.c as well as all the autoconf stuff. --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 2813f2c27..a412411dc 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ + Revision 607.7 2003/06/25 15:40:57 ajc + * setup now uses "newt" instead of "curses" to draw its pretty screens. + Changes were made to setup.c as well as all the autoconf stuff. + Revision 607.6 2003/06/25 02:40:05 ajc * Per-user and global flags calling for validation need to be set in the vCard upload thingie, not in the wrapper function that emulates the @@ -4785,3 +4789,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/Makefile.in b/citadel/Makefile.in index b04a12cba..fcfc6812c 100644 --- a/citadel/Makefile.in +++ b/citadel/Makefile.in @@ -68,6 +68,7 @@ INSTALL_DATA=@INSTALL_DATA@ RESOLV=@RESOLV@ SHELL=/bin/sh SERVER_LDFLAGS=@SERVER_LDFLAGS@ +SETUP_LIBS=@SETUP_LIBS@ YACC=@YACC@ # End configuration section @@ -140,7 +141,7 @@ citmail: citmail.o config.o $(CC) citmail.o config.o $(LDFLAGS) -o citmail $(LIBS) setup: setup.o tools.o - $(CC) setup.o tools.o $(LIBS) $(LDFLAGS) -o setup + $(CC) setup.o tools.o $(SETUP_LIBS) $(LDFLAGS) -o setup chkpwd: chkpwd.o auth.o config.o $(CC) chkpwd.o auth.o config.o $(LDFLAGS) -o chkpwd $(chkpwd_LIBS) diff --git a/citadel/acconfig.h b/citadel/acconfig.h index 63e475208..a8a1d2b27 100644 --- a/citadel/acconfig.h +++ b/citadel/acconfig.h @@ -34,5 +34,8 @@ /* define this if you have the libical calendaring library available */ #undef HAVE_LIBICAL +/* define this if you have the newt window library available */ +#undef HAVE_NEWT + /* define this if you have the resolv.h header file. */ #undef HAVE_RESOLV_H diff --git a/citadel/configure.ac b/citadel/configure.ac index d4b29124c..c331e5a4a 100644 --- a/citadel/configure.ac +++ b/citadel/configure.ac @@ -32,6 +32,7 @@ AC_ARG_WITH(ncurses, [ --without-ncurses don't use ncurses]) AC_ARG_WITH(with_zlib, [ --with-zlib use zlib compression if present]) AC_ARG_WITH(with_libical, [ --with-libical use libical calendaring library]) +AC_ARG_WITH(with_newt, [ --with-newt use newt window library]) if test "x$with_db" != xno -a "x$with_db" != xyes -a "$with_db"; then db_dir="$with_db" @@ -354,6 +355,25 @@ fi + +dnl Checks for the newt window library. +if test "x$with_newt" != xno ; then + AC_CHECK_HEADERS(newt.h, + [AC_CHECK_LIB(newt, newtInit, + [ok_newt=yes],, + )]) +fi + +if test "x$ok_newt" = xyes ; then + SETUP_LIBS="-lnewt $SETUP_LIBS" + AC_DEFINE(HAVE_NEWT) +fi + + + + + + dnl Checks for the libical calendaring library. if test "x$with_libical" != xno ; then AC_CHECK_HEADERS(ical.h, @@ -392,6 +412,7 @@ fi + dnl Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC @@ -541,6 +562,7 @@ AC_SUBST(chkpwd_LIBS) AC_SUBST(TARGETS) AC_SUBST(DATABASE) AC_SUBST(SERVER_LDFLAGS) +AC_SUBST(SETUP_LIBS) AC_CONFIG_HEADER(sysdep.h) AC_CONFIG_FILES([Makefile weekly]) AC_OUTPUT diff --git a/citadel/setup.c b/citadel/setup.c index 159a6284e..c2c789fb7 100644 --- a/citadel/setup.c +++ b/citadel/setup.c @@ -27,22 +27,16 @@ #include "config.h" #include "tools.h" -#ifndef DISABLE_CURSES -#if defined(HAVE_CURSES_H) || defined(HAVE_NCURSES_H) -#ifdef HAVE_NCURSES_H -#include -#else -#include -#endif -#endif +#ifdef HAVE_NEWT +#include #endif + #define MAXSETUP 3 /* How many setup questions to ask */ #define UI_TEXT 0 /* Default setup type -- text only */ -#define UI_DIALOG 1 /* Use the 'dialog' program (REMOVED) */ -#define UI_CURSES 2 /* Use curses */ #define UI_SILENT 3 /* Silent running, for use in scripts */ +#define UI_NEWT 4 /* Use the "newt" window library */ #define SERVICE_NAME "citadel" #define PROTO_NAME "tcp" @@ -204,81 +198,15 @@ void start_the_service(void) { void cleanup(int exitcode) { -#if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES) - if (setup_type == UI_CURSES) { - clear(); - refresh(); - endwin(); - } +#ifdef HAVE_NEWT + newtCls(); + newtRefresh(); + newtFinished(); #endif - exit(exitcode); } -/* Gets a line from the terminal */ -/* Where on the screen to start */ -/* Pointer to string buffer */ -/* Maximum length - if negative, no-show */ -#if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES) -void getlin(int yp, int xp, char *string, int lim) { - int a, b; - char flag; - - flag = 0; - if (lim < 0) { - lim = (0 - lim); - flag = 1; - } - move(yp, xp); - standout(); - for (a = 0; a < lim; ++a) - addch('-'); - refresh(); - move(yp, xp); - for (a = 0; a < lim; ++a) - addch(' '); - move(yp, xp); - printw("%s", string); - GLA:move(yp, xp + strlen(string)); - refresh(); - a = getch(); - if (a == 127) - a = 8; - a = (a & 127); - if (a == 10) - a = 13; - if ((a == 8) && (strlen(string) == 0)) - goto GLA; - if ((a != 13) && (a != 8) && (strlen(string) == lim)) - goto GLA; - if ((a == 8) && (string[0] != 0)) { - string[strlen(string) - 1] = 0; - move(yp, xp + strlen(string)); - addch(' '); - goto GLA; - } - if ((a == 13) || (a == 10)) { - standend(); - move(yp, xp); - for (a = 0; a < lim; ++a) - addch(' '); - mvprintw(yp, xp, "%s", string); - refresh(); - return; - } - b = strlen(string); - string[b] = a; - string[b + 1] = 0; - if (flag == 0) - addch(a); - if (flag == 1) - addch('*'); - goto GLA; -} -#endif - - void title(char *text) { @@ -288,35 +216,25 @@ void title(char *text) } -void hit_any_key(void) -{ - char junk[5]; - -#if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES) - if (setup_type == UI_CURSES) { - mvprintw(20, 0, "Press any key to continue... "); - refresh(); - getch(); - return; - } -#endif - if (setup_type == UI_TEXT) { - printf("Press return to continue..."); - fgets(junk, 5, stdin); - } -} int yesno(char *question) { +#ifdef HAVE_NEWT + newtComponent form = NULL; + newtComponent yesbutton = NULL; + newtComponent nobutton = NULL; +#endif + int answer = 0; - char buf[4096]; + int i = 0; + char buf[SIZ]; switch (setup_type) { case UI_TEXT: do { printf("%s\nYes/No --> ", question); - fgets(buf, 4096, stdin); + fgets(buf, sizeof buf, stdin); answer = tolower(buf[0]); if (answer == 'y') answer = 1; @@ -325,24 +243,27 @@ int yesno(char *question) } while ((answer < 0) || (answer > 1)); break; -#if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES) - case UI_CURSES: - do { - clear(); - standout(); - mvprintw(1, 20, "Question"); - standend(); - mvprintw(10, 0, "%-80s", question); - mvprintw(20, 0, "%80s", ""); - mvprintw(20, 0, "Yes/No -> "); - refresh(); - answer = getch(); - answer = tolower(answer); - if (answer == 'y') - answer = 1; - else if (answer == 'n') - answer = 0; - } while ((answer < 0) || (answer > 1)); +#ifdef HAVE_NEWT + case UI_NEWT: + newtCenteredWindow(76, 10, "Question"); + form = newtForm(NULL, NULL, 0); + for (i=0; i 0) && (curr <= cmax)) { + newtScaleSet(scale, curr); + newtRefresh(); + } + if (curr == cmax) { + newtFormDestroy(form); + newtPopWindow(); + newtRefresh(); } break; #endif @@ -543,9 +473,14 @@ void check_inittab_entry(void) void set_str_val(int msgpos, char str[]) { - char buf[4096]; +#ifdef HAVE_NEWT + newtComponent form; + char *result; +#endif + char buf[SIZ]; char tempfile[PATH_MAX]; char setupmsg[SIZ]; + int i; strcpy(tempfile, tmpnam(NULL)); strcpy(setupmsg, ""); @@ -556,23 +491,28 @@ void set_str_val(int msgpos, char str[]) printf("\n%s\n", setup_text[msgpos]); printf("This is currently set to:\n%s\n", str); printf("Enter new value or press return to leave unchanged:\n"); - fgets(buf, 4096, stdin); + fgets(buf, sizeof buf, stdin); buf[strlen(buf) - 1] = 0; if (strlen(buf) != 0) strcpy(str, buf); break; -#if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES) - case UI_CURSES: - clear(); - move(1, ((80 - strlen(setup_titles[msgpos])) / 2)); - standout(); - printw("%s", setup_titles[msgpos]); - standend(); - move(3, 0); - printw("%s", setup_text[msgpos]); - refresh(); - getlin(20, 0, str, 80); - break; +#ifdef HAVE_NEWT + case UI_NEWT: + + newtCenteredWindow(76, 10, setup_titles[msgpos]); + form = newtForm(NULL, NULL, 0); + for (i=0; i