diff options
| author | Jordan K. Hubbard <jkh@FreeBSD.org> | 1997-01-03 06:32:39 +0000 |
|---|---|---|
| committer | Jordan K. Hubbard <jkh@FreeBSD.org> | 1997-01-03 06:32:39 +0000 |
| commit | e5b09b7d10efaa025da90b61eec0e06b2c411d7d (patch) | |
| tree | 896ba9fcb9176c55630520639c25dbe04e995774 /usr.sbin/sade | |
| parent | f2400d465896a8e4f6fdc57eba840cf49b25bbbd (diff) | |
Notes
Diffstat (limited to 'usr.sbin/sade')
| -rw-r--r-- | usr.sbin/sade/devices.c | 5 | ||||
| -rw-r--r-- | usr.sbin/sade/dmenu.c | 3 | ||||
| -rw-r--r-- | usr.sbin/sade/keymap.c | 4 | ||||
| -rw-r--r-- | usr.sbin/sade/main.c | 3 | ||||
| -rw-r--r-- | usr.sbin/sade/misc.c | 120 | ||||
| -rw-r--r-- | usr.sbin/sade/sade.h | 31 | ||||
| -rw-r--r-- | usr.sbin/sade/termcap.c | 7 | ||||
| -rw-r--r-- | usr.sbin/sade/wizard.c | 9 |
8 files changed, 155 insertions, 27 deletions
diff --git a/usr.sbin/sade/devices.c b/usr.sbin/sade/devices.c index 73806de2f30d..f1405f4b70c2 100644 --- a/usr.sbin/sade/devices.c +++ b/usr.sbin/sade/devices.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: devices.c,v 1.55 1996/12/14 23:08:52 jkh Exp $ + * $Id: devices.c,v 1.56 1996/12/26 21:03:04 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -35,20 +35,17 @@ */ #include "sysinstall.h" - #include <sys/fcntl.h> #include <sys/param.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <sys/errno.h> #include <sys/time.h> - #include <net/if.h> #include <net/if_dl.h> #include <netinet/in.h> #include <netinet/in_var.h> #include <arpa/inet.h> - #include <ctype.h> static Device *Devices[DEV_MAX]; diff --git a/usr.sbin/sade/dmenu.c b/usr.sbin/sade/dmenu.c index 9470f04fda55..5cb913cc1547 100644 --- a/usr.sbin/sade/dmenu.c +++ b/usr.sbin/sade/dmenu.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated for what's essentially a complete rewrite. * - * $Id: dmenu.c,v 1.27 1996/11/09 16:46:56 joerg Exp $ + * $Id: dmenu.c,v 1.28 1996/12/09 08:22:12 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -36,7 +36,6 @@ #include "sysinstall.h" #include <errno.h> -#include <sys/types.h> #define MAX_MENU 15 diff --git a/usr.sbin/sade/keymap.c b/usr.sbin/sade/keymap.c index 5613e94f790d..d0402b18db38 100644 --- a/usr.sbin/sade/keymap.c +++ b/usr.sbin/sade/keymap.c @@ -21,10 +21,11 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id$ + * $Id: keymap.c,v 1.1 1996/11/09 16:47:02 joerg Exp $ * */ +#include "sysinstall.h" #include <errno.h> #include <stdlib.h> #include <string.h> @@ -37,7 +38,6 @@ struct keymapInfo { }; #include "keymap.h" -#include "sysinstall.h" /* * keymap.h is being automatically generated by the Makefile. It diff --git a/usr.sbin/sade/main.c b/usr.sbin/sade/main.c index c8a9025cf350..64003453d51c 100644 --- a/usr.sbin/sade/main.c +++ b/usr.sbin/sade/main.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated for what's essentially a complete rewrite. * - * $Id: main.c,v 1.31 1996/12/12 08:23:49 jkh Exp $ + * $Id: main.c,v 1.32 1996/12/12 08:33:37 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -35,7 +35,6 @@ */ #include "sysinstall.h" -#include <stdio.h> #include <sys/signal.h> #include <sys/fcntl.h> diff --git a/usr.sbin/sade/misc.c b/usr.sbin/sade/misc.c index ebca91f33576..5c2de594f622 100644 --- a/usr.sbin/sade/misc.c +++ b/usr.sbin/sade/misc.c @@ -1,7 +1,7 @@ /* * Miscellaneous support routines.. * - * $Id: misc.c,v 1.25 1996/12/12 22:38:41 jkh Exp $ + * $Id: misc.c,v 1.26 1996/12/17 00:00:14 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -345,6 +345,123 @@ Mount(char *mountp, void *dev) } WINDOW * +openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height) +{ + WINDOW *win; + char help[FILENAME_MAX]; + + /* We need a curses window */ + win = newwin(LINES, COLS, 0, 0); + if (win) { + /* Say where our help comes from */ + if (helpfile) { + systemHelpFile(helpfile, help); + use_helpfile(help); + } + + /* Setup a nice screen for us to splat stuff onto */ + draw_box(win, y, x, height, width, dialog_attr, border_attr); + wattrset(win, dialog_attr); + mvwaddstr(win, y, x + 20, title); + } + return win; +} + +ComposeObj * +initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max) +{ + ComposeObj *obj = NULL, *first; + int n; + + /* Loop over the layout list, create the objects, and add them + onto the chain of objects that dialog uses for traversal*/ + + n = 0; + while (layout[n].help != NULL) { + switch (layout[n].type) { + case STRINGOBJ: + layout[n].obj = NewStringObj(win, layout[n].prompt, layout[n].var, + layout[n].y + y, layout[n].x + x, layout[n].len, layout[n].maxlen); + break; + + case BUTTONOBJ: + layout[n].obj = NewButtonObj(win, layout[n].prompt, layout[n].var, layout[n].y + y, layout[n].x + x); + break; + + default: + msgFatal("Don't support this object yet!"); + } + AddObj(&obj, layout[n].type, (void *) layout[n].obj); + n++; + } + *max = n - 1; + /* Find the first object in the list */ + for (first = obj; first->prev; first = first->prev); + return first; +} + +int +layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj, int *n, int max, int *cbutton, int *cancel) +{ + char help_line[80]; + int ret, i, len = strlen(layout[*n].help); + + /* Display the help line at the bottom of the screen */ + for (i = 0; i < 79; i++) + help_line[i] = (i < len) ? layout[*n].help[i] : ' '; + help_line[i] = '\0'; + use_helpline(help_line); + display_helpline(win, LINES - 1, COLS - 1); + + /* Ask for libdialog to do its stuff */ + ret = PollObj(obj); + /* Handle special case stuff that libdialog misses. Sigh */ + switch (ret) { + case SEL_ESC: /* Bail out */ + *cancel = TRUE; + return FALSE; + + /* This doesn't work for list dialogs. Oh well. Perhaps + should special case the move from the OK button ``up'' + to make it go to the interface list, but then it gets + awkward for the user to go back and correct screw up's + in the per-interface section */ + case KEY_DOWN: + case SEL_CR: + case SEL_TAB: + if (*n < max) + ++*n; + else + *n = 0; + break; + + /* The user has pressed enter over a button object */ + case SEL_BUTTON: + if (cbutton && *cbutton) + *cancel = TRUE; + else + *cancel = FALSE; + return FALSE; + + case KEY_UP: + case SEL_BACKTAB: + if (*n) + --*n; + else + *n = max; + break; + + case KEY_F(1): + display_helpfile(); + + /* They tried some key combination we don't support - tootle them forcefully! */ + default: + beep(); + } + return TRUE; +} + +WINDOW * savescr(void) { WINDOW *w; @@ -360,3 +477,4 @@ restorescr(WINDOW *w) wrefresh(w); delwin(w); } + diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h index af1cbf3eed95..d650bce3b164 100644 --- a/usr.sbin/sade/sade.h +++ b/usr.sbin/sade/sade.h @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: sysinstall.h,v 1.95 1996/12/17 00:00:15 jkh Exp $ + * $Id: sysinstall.h,v 1.96 1996/12/29 05:51:39 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -37,13 +37,17 @@ #ifndef _SYSINSTALL_H_INCLUDE #define _SYSINSTALL_H_INCLUDE +#include <sys/types.h> +#include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <dialog.h> -#include <sys/types.h> -#include <sys/wait.h> +#include <dialog.h> +#include "ui_objects.h" +#include "dir.h" +#include "colors.h" #include "libdisk.h" #include "dist.h" #include "version.h" @@ -173,6 +177,19 @@ typedef struct _variable { char *value; } Variable; +/* A screen layout structure */ +typedef struct _layout { + int y; /* x & Y co-ordinates */ + int x; + int len; /* The size of the dialog on the screen */ + int maxlen; /* How much the user can type in ... */ + char *prompt; /* The string for the prompt */ + char *help; /* The display for the help line */ + void *var; /* The var to set when this changes */ + int type; /* The type of the dialog to create */ + void *obj; /* The obj pointer returned by libdialog */ +} Layout; + /* For attribs */ #define MAX_ATTRIBS 200 #define MAX_NAME 64 @@ -342,6 +359,9 @@ extern DMenu MenuHTMLDoc; /* HTML Documentation menu */ extern DMenu MenuUsermgmt; /* User management menu */ extern DMenu MenuFixit; /* Fixit floppy/CDROM/shell menu */ +/* Stuff from libdialog which isn't properly declared outside */ +extern void display_helpfile(void); +extern void display_helpline(WINDOW *w, int y, int width); /*** Prototypes ***/ @@ -562,6 +582,11 @@ extern dialogMenuItem *item_add(dialogMenuItem *list, char *prompt, char *title, extern void items_free(dialogMenuItem *list, int *curr, int *max); extern int Mkdir(char *); extern int Mount(char *, void *data); +extern WINDOW *openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height); +extern ComposeObj *initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max); +extern int layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj, + int *n, int max, int *cbutton, int *cancel); + extern WINDOW *savescr(void); extern void restorescr(WINDOW *w); extern char *sstrncpy(char *dst, const char *src, int size); diff --git a/usr.sbin/sade/termcap.c b/usr.sbin/sade/termcap.c index 5771e5f44eb6..4b93f1e1fc3d 100644 --- a/usr.sbin/sade/termcap.c +++ b/usr.sbin/sade/termcap.c @@ -11,18 +11,13 @@ * incurred with its use. */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> +#include "sysinstall.h" #include <stdarg.h> #include <fcntl.h> #include <sys/errno.h> #include <sys/ioctl.h> #include <machine/console.h> -#include "sysinstall.h" - #define VTY_STATUS_LINE 24 #define TTY_STATUS_LINE 23 diff --git a/usr.sbin/sade/wizard.c b/usr.sbin/sade/wizard.c index ae6dc7859e2e..35385fcdd8ea 100644 --- a/usr.sbin/sade/wizard.c +++ b/usr.sbin/sade/wizard.c @@ -6,18 +6,13 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: wizard.c,v 1.7 1995/12/07 10:34:25 peter Exp $ + * $Id: wizard.c,v 1.8 1996/04/28 20:54:11 jkh Exp $ * */ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> +#include "sysinstall.h" #include <fcntl.h> -#include <string.h> #include <err.h> -#include <sys/types.h> -#include "sysinstall.h" u_char mbr[] = { 250,51,192,142,208,188,0,124,139,244,80,7,80,31,251,252,191,0,6,185,0,1, |
