home *** CD-ROM | disk | FTP | other *** search
- From: pjc@pcbox.UUCP (Paul J. Condie)
- Newsgroups: alt.sources
- Subject: menu(1) part 5 of 14
- Message-ID: <439@pcbox.UUCP>
- Date: 26 Dec 90 20:07:38 GMT
-
-
- #!/bin/sh
- # this is part 5 of a multipart archive
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file ParseAuthr.c continued
- #
- CurArch=5
- if test ! -r s2_seq_.tmp
- then echo "Please unpack part 1 first!"
- exit 1; fi
- ( read Scheck
- if test "$Scheck" != $CurArch
- then echo "Please unpack part $Scheck next!"
- exit 1;
- else exit 0; fi
- ) < s2_seq_.tmp || exit 1
- echo "x - Continuing file ParseAuthr.c"
- sed 's/^X//' << 'SHAR_EOF' >> ParseAuthr.c
- X if (strcmp (user, word) == 0)
- X {
- X OKflag = TRUE;
- X break;
- X }
- X lptr = strchr (++lptr, ' ');
- X }
- X
- X if (!OKflag)
- X return (NOWAYJOSE);
- X return (0);
- X}
- SHAR_EOF
- echo "File ParseAuthr.c is complete"
- chmod 0644 ParseAuthr.c || echo "restore of ParseAuthr.c fails"
- echo "x - extracting ParseText.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ParseText.c &&
- X#ifndef LINT
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X#endif
- X
- X/* FUNCTION: ParseText()
- X** Parses keyword "TEXT".
- X** ARGS: keyword the keyword "TEXT"
- X** menufile the unix menu file
- X** menu menu structure
- X** gnames holder of goto menu names
- X** gfiles holder of goto menu names (menu file)
- X** gindex # of gnames
- X** RETURNS: 0
- X*/
- X
- X#include <curses.h>
- X#include <ctype.h>
- X#include "menu.h"
- X
- X
- XParseText (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles,
- X gindex, opnumber)
- X
- X char keyword[];
- X FILE *menufile;
- X struct MenuInfo *menu;
- X char KeyWord[][MAXKEYLENGTH];
- X int (*ParseKey[])();
- X char gnames[][15], gfiles[][15];
- X int *gindex;
- X int *opnumber;
- X{
- X char *fgets(), line[BUFSIZE+1];
- X char *getval();
- X int row;
- X int col;
- X char fline[BUFSIZE+1]; /* formated line */
- X int j;
- X int i;
- X char *ws;
- X
- X fgets (line, BUFSIZE, menufile); /* read row, col */
- X ws = line;
- X SKIPJUNK (ws);
- X sscanf (ws, "%s", fline); /* get row */
- X row = strcmp (fline, "-0") == 0 ? LINES : atoi(fline);
- X ws += strlen(fline);
- X SKIPJUNK (ws);
- X sscanf (ws, "%s", fline); /* get col */
- X col = strcmp (fline, "-0") == 0 ? COLS : atoi(fline);
- X
- X fgets (line, BUFSIZE, menufile); /* read text */
- X line[strlen(line)-1] = '\0';
- X for (j = 0, i = 0; i < strlen (line); j++, i++)
- X if (line[i] == '$')
- X {
- X char *sptr, *b4ptr;
- X
- X sptr = b4ptr = line+i;
- X strcpy (fline+j, getval (&sptr, '$'));
- X i += (int)(sptr - b4ptr);
- X j += strlen (fline+j) - 1;
- X i--;
- X }
- X else
- X {
- X fline[j] = line[i];
- X }
- X fline[j] = '\0';
- X
- X /*
- X ** If the row or column is negative
- X ** then we use relative addressing
- X ** the row or col is subtracted from # of rows on screen.
- X */
- X if (row < 0)
- X row = abs(row) > LINES ? LINES-1 : LINES+row-1;
- X else
- X row = row > LINES-1 ? LINES-1 : row;
- X if (col < 0)
- X col = abs(col) > COLS ? COLS-1 : COLS+col-1;
- X else
- X col = col > COLS-1 ? COLS-1 : col;
- X displaytext (stdscr, row, col, fline);
- X return (0);
- X}
- X/* Paul J. Condie 4/88 */
- SHAR_EOF
- chmod 0644 ParseText.c || echo "restore of ParseText.c fails"
- echo "x - extracting ParseCur.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ParseCur.c &&
- X#ifndef LINT
- Xstatic char Sccsid[] = "@(#)ParseCur.c 1.5 DeltaDate 1/22/90 ExtrDate 1/22/90";
- X#endif
- X
- X
- X/* FUNCTION: ParseCursor()
- X** Parses keyword "CURSOR".
- X** ARGS: keyword the keyword "CURSOR"
- X** menufile the unix menu file
- X** menu menu structure
- X** gnames holder of goto menu names
- X** gfiles holder of goto menu names (menu file)
- X** gindex # of gnames
- X*/
- X
- X#include <curses.h>
- X#include <ctype.h>
- X#include "menu.h"
- X
- X
- XParseCursor (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles,
- X gindex, opnumber)
- X
- X char keyword[];
- X FILE *menufile;
- X struct MenuInfo *menu;
- X char KeyWord[][MAXKEYLENGTH];
- X int (*ParseKey[])();
- X char gnames[][15], gfiles[][15];
- X int *gindex;
- X int *opnumber;
- X{
- X char *fgets(), line[BUFSIZE+1];
- X char *ws;
- X char tmpstr[20];
- X
- X fgets (line, BUFSIZE, menufile);
- X ws = line;
- X SKIPJUNK (ws);
- X sscanf (ws, "%s", tmpstr); /* get row */
- X menu->row_cursor = strcmp (tmpstr, "-0") == 0 ? LINES : atoi(tmpstr);
- X ws += strlen(tmpstr);
- X SKIPJUNK (ws);
- X sscanf (ws, "%s", tmpstr); /* get col */
- X menu->col_cursor = strcmp (tmpstr, "-0") == 0 ? COLS : atoi(tmpstr);
- X
- X /*
- X ** If the row or column is negative
- X ** then we use relative addressing
- X ** the row or col is subtracted from # of rows on screen.
- X */
- X if (menu->row_cursor < 0)
- X menu->row_cursor = abs(menu->row_cursor) > LINES ?
- X LINES-1 : LINES+menu->row_cursor-1;
- X else
- X menu->row_cursor = menu->row_cursor > LINES-1 ?
- X LINES-1 : menu->row_cursor;
- X if (menu->col_cursor < 0)
- X menu->col_cursor = abs(menu->col_cursor) > COLS ?
- X COLS-1 : COLS+menu->col_cursor-1;
- X else
- X menu->col_cursor = menu->col_cursor > COLS-1 ?
- X COLS-1 : menu->col_cursor;
- X return (0);
- X}
- X/* Paul J. Condie 4/88 */
- SHAR_EOF
- chmod 0444 ParseCur.c || echo "restore of ParseCur.c fails"
- echo "x - extracting ParseSpace.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ParseSpace.c &&
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X
- X/* FUNCTION: ParseSpace()
- X** ARGS: keyword the keyword found
- X** menufile the unix menu file
- X** menu menu structure
- X** gnames holder of goto menu names
- X** gfiles holder of goto menu names (menu file)
- X** gindex # of gnames
- X** RETURNS: 0
- X*/
- X
- X#include <curses.h>
- X#include "menu.h"
- X
- Xextern int swin, ewin, longest;
- X
- X
- XParseSpace (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles, gindex, opnumber)
- X
- X char keyword[];
- X FILE *menufile;
- X struct MenuInfo *menu;
- X char KeyWord[][MAXKEYLENGTH];
- X int (*ParseKey[])();
- X char gnames[][15], gfiles[][15];
- X int *gindex;
- X int *opnumber;
- X{
- X struct OptionInfo *malloc();
- X char *fgets(), line[BUFSIZE];
- X
- X
- X if (menu->optioncount >= MAXOPTION)
- X {
- X BEEP;
- X mvprintw (ErrRow, 0, "Exceeded maximum allowable options.");
- X shutdown ();
- X }
- X menu->option[menu->optioncount] = malloc (sizeof (struct OptionInfo));
- X if (menu->option[menu->optioncount] == NULL)
- X {
- X BEEP;
- X mvprintw (ErrRow, 0, "Unable to allocate memory for option.");
- X shutdown ();
- X }
- X
- X strcpy (menu->option[menu->optioncount]->keyword, keyword);
- X menu->option[menu->optioncount]->opnumber = 0; /* no number */
- X strcpy (menu->option[menu->optioncount]->description, "");
- X menu->option[menu->optioncount]->command = (char *) malloc (5);
- X strcpy (menu->option[menu->optioncount]->command, "");
- X
- X fgets (line, sizeof(line)-1, menufile); /* junk rest of line */
- X menu->optioncount++;
- X ewin++;
- X return (0);
- X}
- SHAR_EOF
- chmod 0644 ParseSpace.c || echo "restore of ParseSpace.c fails"
- echo "x - extracting ParInclude.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ParInclude.c &&
- X#ifndef LINT
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X#endif
- X
- X/* FUNCTION: ParInclude()
- X** Parses keyword ".INCLUDE".
- X** ARGS: keyword the keyword "INCLUDE"
- X** menufile the unix menu file
- X** menu menu structure
- X** gnames holder of goto menu names
- X** gfiles holder of goto menu names (menu file)
- X** gindex # of gnames
- X*/
- X
- X#include <curses.h>
- X#include "menu.h"
- X
- X
- XParInclude (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles,
- X gindex, opnumber)
- X
- X char keyword[];
- X FILE *menufile;
- X struct MenuInfo *menu;
- X char KeyWord[][MAXKEYLENGTH];
- X int (*ParseKey[])();
- X char gnames[][15], gfiles[][15];
- X int *gindex;
- X int *opnumber;
- X{
- X FILE *fopen(), *newfile;
- X char *fgets(), line[BUFSIZE+1];
- X char *findfile();
- X char *getenv();
- X char *getval();
- X char unixfile[100];
- X char filename[100];
- X int rc;
- X int KEYFOUND;
- X int idx;
- X char newkey[MAXKEYLENGTH];
- X char *sptr;
- X
- X fgets (line, BUFSIZE, menufile);
- X sscanf (line, "%s", filename);
- X
- X /*
- X ** Open and Parse the new menu file
- X */
- X sptr = filename;
- X strcpy (unixfile, getval (&sptr, 1));
- X strcpy (filename, unixfile);
- X if (filename[0] != '/')
- X strcpy (unixfile, findfile (filename, ".", getenv("MENUDIR"),
- X ""));
- X if ((newfile = fopen (unixfile, "r")) == NULL)
- X {
- X BEEP;
- X mvprintw (ErrRow-2, 0, "Unable to locate .INCLUDE (%s) file.",
- X filename);
- X shutdown ();
- X }
- X
- X
- X /* loop through each keyword */
- X rc = fscanf (newfile, "%s", newkey);
- X while (rc != EOF)
- X {
- X /*
- X ** Check if we found a defined keyword
- X */
- X KEYFOUND = FALSE;
- X for (idx = 1; idx <= MAXKEYS; idx++)
- X {
- X /*
- X if (strcmp (newkey, KeyWord[idx]) == 0)
- X */
- X if (strmatch (newkey, KeyWord[idx]))
- X {
- X KEYFOUND = TRUE;
- X if (ParseKey[idx] != NULL)
- X {
- X rc = (*ParseKey[idx]) (newkey,
- X newfile, menu, KeyWord,
- X ParseKey, gnames, gfiles,
- X gindex, opnumber);
- X if (rc != 0) return (rc);
- X }
- X break;
- X }
- X }
- X if (!KEYFOUND)
- X {
- X BEEP;
- X mvprintw (ErrRow-2, 0, "ERROR: (%s) Key not found.",
- X newkey);
- X shutdown ();
- X }
- X rc = fscanf (newfile, "%s", newkey);
- X } /* end while */
- X
- X /*
- X rc = parsedriver (newfile, KeyWord, ParseKey, menu, gnames, gfiles,
- X &gindex);
- X */
- X fclose (newfile);
- X
- X return (0);
- X}
- SHAR_EOF
- chmod 0644 ParInclude.c || echo "restore of ParInclude.c fails"
- echo "x - extracting ParAssign.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ParAssign.c &&
- X#ifndef LINT
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X#endif
- X
- X/* FUNCTION: ParAssign()
- X** Parses keyword "*=*"
- X** A variable=value assignment.
- X** ARGS: keyword the keyword "*=*"
- X** menufile the unix menu file
- X** menu menu structure
- X** gnames holder of goto menu names
- X** gfiles holder of goto menu names (menu file)
- X** gindex # of gnames
- X*/
- X
- X#include <curses.h>
- X#include "menu.h"
- X
- Xextern int debug;
- X
- X
- XParAssign (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles,
- X gindex, opnumber)
- X
- X char keyword[];
- X FILE *menufile;
- X struct MenuInfo *menu;
- X char KeyWord[][MAXKEYLENGTH];
- X int (*ParseKey[])();
- X char gnames[][15], gfiles[][15];
- X int *gindex;
- X int *opnumber;
- X{
- X char *fgets();
- X char line[BUFSIZE+1];
- X char *assignment;
- X char *aptr;
- X char *sptr;
- X
- X
- X fgets (line, BUFSIZE, menufile);
- X line[strlen(line)-1] = '\0'; /* junk \n */
- X /* if comment (#,###) junk rest of line */
- X for (aptr = line; *aptr; aptr++)
- X if (*aptr == '#' || strncmp (aptr, "###", 3) == 0)
- X {
- X *aptr = '\0'; /* junk comment */
- X for (sptr = aptr-1, aptr = line;
- X sptr >= aptr && (*sptr == ' ' || *sptr == '\t');
- X sptr--)
- X *sptr = '\0'; /* junk trailing white space */
- X break;
- X }
- X assignment = (char *)malloc (strlen(keyword) + strlen(line) + 20);
- X strcpy (assignment, keyword);
- X strcat (assignment, line); /* the rest of the quoted value */
- X aptr = assignment;
- X if (debug)
- X {
- X fprintf (stderr, "\n[ParAssign] command=:%s:", aptr);
- X fflush (stderr);
- X }
- X setvariable (&aptr);
- X free (assignment);
- X return (0);
- X}
- SHAR_EOF
- chmod 0644 ParAssign.c || echo "restore of ParAssign.c fails"
- echo "x - extracting ParAftMenu.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ParAftMenu.c &&
- X#ifndef LINT
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X#endif
- X
- X/* FUNCTION: ParAftMenu()
- X** Parses keyword ".AFTER_MENU".
- X** ARGS: keyword the keyword "unix"
- X** menufile the unix menu file
- X** menu menu structure
- X** gnames holder of goto menu names
- X** gfiles holder of goto menu names (menu file)
- X** gindex # of gnames
- X** RETURNS: none
- X*/
- X
- X#include <curses.h>
- X#include <ctype.h>
- X#include "menu.h"
- X
- X
- Xextern int debug;
- X
- X
- X
- XParAftMenu (keyword, menufile, menu, KeyWord, ParseKey, gnames, gfiles,
- X gindex, opnumber)
- X
- X char keyword[];
- X FILE *menufile;
- X struct MenuInfo *menu;
- X char KeyWord[][MAXKEYLENGTH];
- X int (*ParseKey[])();
- X char gnames[][15], gfiles[][15];
- X int *gindex;
- X int *opnumber;
- X{
- X char command[MAXLEN+1];
- X int rc;
- X char *comptr;
- X char tmpstr[80];
- X int redrawflag = FALSE;
- X
- X
- X
- X /*
- X ** Read in option command
- X ** strcat continuation lines
- X */
- X fgets (command, sizeof(command)-1, menufile);
- X command[strlen(command)-1] = '\0'; /* get rid of \n */
- X while (command[strlen(command)-1] == '\\')
- X {
- X if (strlen(command) > MAXLEN)
- X {
- X BEEP;
- X mvprintw (ErrRow-2, 0,
- X ".AFTER_MENU command is too long. Max = %d",
- X MAXLEN);
- X shutdown ();
- X }
- X command[strlen(command)-1] = '\n'; /* replace \ with \n */
- X fgets (command+strlen(command), sizeof(command)-1, menufile);
- X command[strlen(command)-1] = '\0'; /* get rid of \n */
- X }
- X
- X comptr = command;
- X SKIPJUNK(comptr);
- X
- X /* save command for later */
- X menu->after_menu = (char *)malloc (strlen(comptr)+5);
- X strcpy (menu->after_menu, comptr);
- X return (0);
- X}
- X/* Paul J. Condie 4-90 */
- SHAR_EOF
- chmod 0644 ParAftMenu.c || echo "restore of ParAftMenu.c fails"
- echo "x - extracting ShowOption.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > ShowOption.c &&
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X
- X/* FUNCTION: ShowOption()
- X** Displays a option to the screen.
- X** ARGS: menu menu structure
- X** index option # to display
- X** RETURNS: none
- X*/
- X
- X#include <curses.h>
- X#include "menu.h"
- X
- Xextern int debug;
- X
- X
- XShowOption (menu, index)
- X
- X struct MenuInfo *menu;
- X int index;
- X{
- X
- X
- X /*
- X ** Now display option.
- X */
- X mvprintw (menu->option[index]->row, menu->option[index]->col, "%2d. ",
- X menu->option[index]->opnumber);
- X
- X displaytext (stdscr, menu->option[index]->row,
- X menu->option[index]->col+5,
- X menu->option[index]->description);
- X
- X if (debug)
- X {
- X fprintf (stderr, "\n[ShowOption] <%s> row=%d col=%d",
- X menu->option[index]->keyword,
- X menu->option[index]->row,
- X menu->option[index]->col);
- X }
- X}
- SHAR_EOF
- chmod 0644 ShowOption.c || echo "restore of ShowOption.c fails"
- echo "x - extracting RunSystem.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > RunSystem.c &&
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X
- X/* FUNCTION: RunSystem()
- X** Runs keyword ".SYSTEM".
- X** ARGS: option option info sturcture
- X** RETURNS: none
- X*/
- X
- X#include <curses.h>
- X#include <ctype.h>
- X#include <signal.h>
- X#include "menu.h"
- X
- Xextern int errno;
- Xextern int debug;
- X
- XRunSystem (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey,
- X gnames, gfiles, gindex)
- X struct MenuInfo *menu;
- X int opnumber;
- X int (*ParseKey[MAXKEYS])(),
- X (*ShowKey[MAXKEYS])(),
- X (*RunKey[MAXKEYS])();
- X char KeyWord[MAXKEYS][MAXKEYLENGTH];
- X char gnames[MAXGNAME][15];
- X char gfiles[MAXGNAME][15];
- X int gindex;
- X{
- X int shutdown();
- X char *command = (char *)NULL;
- X int rc; /* return code */
- X char *comptr;
- X int screenflag = FALSE;
- X
- X
- X
- X /*
- X ** we need to allocate enough space to hold the command
- X ** the description and the tput clear stuff
- X */
- X command = (char *)malloc (strlen (menu->option[opnumber]->command) +
- X strlen (menu->option[opnumber]->description) + 100);
- X comptr = menu->option[opnumber]->command;
- X SKIPJUNK(comptr);
- X
- X if (substr (comptr, "GETINPUT") != NULL)
- X {
- X sscanf (comptr, "%s", command);
- X /*
- X ** Loop through each variable=value until GETINPUT is found
- X */
- X do
- X {
- X if (strcmp (command, "GETINPUT") == 0)
- X {
- X screenflag = TRUE;
- X /* get screen name */
- X comptr += strlen(command);
- X SKIPJUNK(comptr);
- X sscanf (comptr, "%s", command);/* screen name */
- X comptr += strlen(command);
- X SKIPJUNK(comptr); /* sitting at system(3) */
- X rc = runscreen (command, menu, opnumber);
- X if (rc == KEY_CANCEL)
- X {
- X free (command);
- X return (0);
- X }
- X break;
- X }
- X else
- X {
- X rc = setvariable (&comptr);
- X if (rc != 0) break;
- X }
- X
- X SKIPJUNK(comptr);
- X rc = sscanf (comptr, "%s", command);/* next var=value */
- X } while (rc != EOF);
- X } /* end if GETINPUT */
- X
- X
- X /* run system command */
- X refresh(); /* force curses to flush attributes */
- X sprintf (command, "%s;echo \"One moment, loading %s%s%s ....\"; %s",
- X#if BSD || SUN
- X "clear",
- X#else
- X "tput clear",
- X#endif
- X#if BSD || SUN
- X "",
- X#else
- X "`tput smul`",
- X#endif
- X menu->option[opnumber]->description,
- X#if BSD || SUN
- X "",
- X#else
- X "`tput rmul`",
- X#endif
- X comptr);
- X reset_shell_mode ();
- X if (debug)
- X {
- X fprintf (stderr, "\n[RunSystem] <%s> command=:%s:",
- X menu->option[opnumber]->keyword, command);
- X }
- X signal (SIGINT, shutdown);
- X signal (SIGQUIT, shutdown);
- X rc = system (command);
- X signal (SIGINT, SIG_IGN);
- X signal (SIGQUIT, SIG_IGN);
- X if (debug)
- X {
- X fprintf (stderr,
- X "\n[RunSystem] <%s> return code = %d, errno = %d",
- X rc, errno);
- X }
- X
- X reset_prog_mode ();
- X clearok (stdscr, TRUE);
- X
- X
- X free (command);
- X
- X if (rc == 0 && screenflag)
- X return (REPARSE);
- X return (rc);
- X}
- SHAR_EOF
- chmod 0644 RunSystem.c || echo "restore of RunSystem.c fails"
- echo "x - extracting RunExit.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > RunExit.c &&
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X
- X/* FUNCTION: RunExit()
- X** Runs keyword ".EXIT".
- X** Exit menu program.
- X** ARGS: option option info sturcture
- X** RETURNS: none
- X*/
- X
- X#include <curses.h>
- X#include <signal.h>
- X#include "menu.h"
- X
- Xextern int trapsigs;
- X
- XRunExit (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey,
- X gnames, gfiles, gindex)
- X struct MenuInfo *menu;
- X int opnumber;
- X int (*ParseKey[MAXKEYS])(),
- X (*ShowKey[MAXKEYS])(),
- X (*RunKey[MAXKEYS])();
- X char KeyWord[MAXKEYS][MAXKEYLENGTH];
- X char gnames[MAXGNAME][15];
- X char gfiles[MAXGNAME][15];
- X int gindex;
- X{
- X int shutdown();
- X int rc; /* return code */
- X
- X refresh ();
- X if (strcmp (menu->option[opnumber]->command, "") != 0)
- X {
- X reset_shell_mode ();
- X signal (SIGINT, shutdown);
- X signal (SIGQUIT, shutdown);
- X rc = system (menu->option[opnumber]->command);
- X if (trapsigs)
- X {
- X signal (SIGINT, SIG_IGN);
- X signal (SIGQUIT, SIG_IGN);
- X }
- X reset_prog_mode ();
- X }
- X return (QUIT);
- X}
- SHAR_EOF
- chmod 0644 RunExit.c || echo "restore of RunExit.c fails"
- echo "x - extracting RunSetenv.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > RunSetenv.c &&
- Xstatic char Sccsid[] = "@(#)RunSetenv.c 1.7 DeltaDate 1/22/90 ExtrDate 1/22/90";
- X
- X/* FUNCTION: RunSetenv()
- X** Runs keyword ".SETENV".
- X** ARGS: option option info sturcture
- X** RETURNS: none
- X*/
- X
- X#include <curses.h>
- X#include <string.h>
- X#include <ctype.h>
- X#include "menu.h"
- X
- X
- XRunSetenv (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey,
- X gnames, gfiles, gindex)
- X struct MenuInfo *menu;
- X int opnumber;
- X int (*ParseKey[MAXKEYS])(),
- X (*ShowKey[MAXKEYS])(),
- X (*RunKey[MAXKEYS])();
- X char KeyWord[MAXKEYS][MAXKEYLENGTH];
- X char gnames[MAXGNAME][15];
- X char gfiles[MAXGNAME][15];
- X int gindex;
- X{
- X char *strchr();
- X int rc;
- X char command[BUFSIZ];
- X char *comptr;
- X int BELLFLAG=FALSE;
- X
- X
- X /*
- X ** The first argument [ BELL ]
- X */
- X comptr = menu->option[opnumber]->command;
- X SKIPJUNK(comptr);
- X sscanf (comptr, "%s", command); /* do we have a BELL */
- X if (strcmp (command, "BELL") == 0)
- X {
- X BELLFLAG = TRUE;
- X comptr += strlen(command);
- X }
- X
- X do
- X {
- X rc = setvariable (&comptr);
- X if (rc != 0) break;
- X rc = sscanf (comptr, "%s", command); /* get next var=value */
- X if (rc == EOF) break;
- X /* if the command has an = sign in it, it is another one */
- X if (!strmatch(command, "*=*"))
- X break;
- X } while (rc != EOF);
- X
- X SKIPJUNK(comptr);
- X mvprintw (ErrRow, 0, "%s", comptr); /* dispaly message */
- X if (BELLFLAG)
- X BEEP;
- X
- X return (REPARSE);
- X}
- X/* Paul J. Condie 10/88 */
- SHAR_EOF
- chmod 0444 RunSetenv.c || echo "restore of RunSetenv.c fails"
- echo "x - extracting RunMenu.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > RunMenu.c &&
- Xstatic char Sccsid[] = "@(#)RunMenu.c 1.7 DeltaDate 1/22/90 ExtrDate 1/22/90";
- X
- X/* FUNCTION: RunMenu()
- X** Runs keyword ".MENU".
- X** ARGS: option option info sturcture
- X** RETURNS: none
- X*/
- X
- X#include <curses.h>
- X#include <ctype.h>
- X#include "menu.h"
- X
- XRunMenu (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey,
- X gnames, gfiles, gindex)
- X struct MenuInfo *menu;
- X int opnumber;
- X int (*ParseKey[MAXKEYS])(),
- X (*ShowKey[MAXKEYS])(),
- X (*RunKey[MAXKEYS])();
- X char KeyWord[MAXKEYS][MAXKEYLENGTH];
- X char gnames[MAXGNAME][15];
- X char gfiles[MAXGNAME][15];
- X int gindex;
- X{
- X char command[BUFSIZ];
- X int rc; /* return code */
- X char *comptr;
- X
- X /*
- X ** The first argument is the menu script filename
- X */
- X comptr = menu->option[opnumber]->command;
- X SKIPJUNK (comptr);
- X sscanf (comptr, "%s", command); /* filename */
- X comptr += strlen(command);
- X SKIPJUNK (comptr);
- X sscanf (comptr, "%s", command); /* next argument */
- X
- X /*
- X ** Loop through each variable=value || GETINPUT
- X */
- X do
- X {
- X if (strcmp (command, "GETINPUT") == 0)
- X {
- X /* get screen name */
- X comptr += strlen(command);
- X SKIPJUNK(comptr);
- X sscanf (comptr, "%s", command); /* screen name */
- X comptr += strlen(command);
- X SKIPJUNK(comptr); /* sitting at next argument */
- X rc = runscreen (command, menu, opnumber);
- X if (rc == KEY_CANCEL)
- X return (0);
- X }
- X else
- X {
- X rc = setvariable (&comptr);
- X if (rc != 0) break;
- X }
- X
- X rc = sscanf (comptr, "%s", command);/* next var=value */
- X } while (rc != EOF);
- X
- X return (SUBMENU);
- X}
- X/* Paul J. Condie 5/88 */
- SHAR_EOF
- chmod 0444 RunMenu.c || echo "restore of RunMenu.c fails"
- echo "x - extracting RunPopMenu.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > RunPopMenu.c &&
- X#ifndef LINT
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X#endif
- X
- X/* FUNCTION: RunPopMenu()
- X** Runs keyword ".POPMENU".
- X** RunPopMenu will use recursion if there is another .POPMENU
- X** within .POPMENU.
- X** ARGS: option option info sturcture
- X** RETURNS: none
- X*/
- X
- X#include <curses.h>
- X#include <string.h>
- X#include <ctype.h>
- X#include "menu.h"
- X
- X#define INITMENU 0
- X#define CREATEMENU -2
- X#define UNHILIGHTBOX -1
- X
- X
- XRunPopMenu (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey,
- X gnames, gfiles, gindex)
- X struct MenuInfo *menu;
- X int opnumber;
- X int (*ParseKey[MAXKEYS])(),
- X (*ShowKey[MAXKEYS])(),
- X (*RunKey[MAXKEYS])();
- X char KeyWord[MAXKEYS][MAXKEYLENGTH];
- X char gnames[MAXGNAME][15];
- X char gfiles[MAXGNAME][15];
- X int gindex;
- X{
- X FILE *fopen(), *menufile;
- X char *strchr();
- X char *findfile();
- X char *getenv();
- X char command[BUFSIZ];
- X int rc; /* return code */
- X char *comptr;
- X int row, col; /* top left corner */
- X char *filename;
- X int i;
- X static int popmid = 9; /* popup menu id */
- X int titleline[200]; /* title 1 on stdscr */
- X char poptitle[200]; /* title for popmenu */
- X int DIMFLAG = TRUE;
- X struct MenuInfo pmenu;
- X char PopMenu[100][80]; /* the pop menu */
- X int AUTOFIG = FALSE; /* figure row/col */
- X
- X
- X comptr = menu->option[opnumber]->command;
- X SKIPJUNK(comptr);
- X sscanf (comptr, "%s", command); /* do we have NoDim */
- X if (strcmp (command, "NoDim") == 0)
- X {
- X DIMFLAG = FALSE;
- X comptr += strlen(command);
- X }
- X
- X SKIPJUNK(comptr);
- X sscanf (comptr, "%s", command); /* menufile name */
- X comptr += strlen(command);
- X SKIPJUNK(comptr);
- X
- X /* do we have a row/column parameter
- X ** we'll use titleline for working storage
- X */
- X sscanf (comptr, "%s", titleline); /* get next argument */
- X if (*comptr != '\0' && strchr (titleline, '=') == (char *)NULL)
- X {
- X /* we have a row/column parameter */
- X /* get row and column */
- X sscanf (comptr, "%d", &row);
- X comptr = strchr (comptr, ' '); /* past row */
- X SKIPJUNK(comptr); /* at begining of col */
- X sscanf (comptr, "%d", &col);
- X comptr = strchr (comptr, ' '); /* past column */
- X }
- X else
- X AUTOFIG = TRUE;
- X
- X
- X /*
- X ** Loop through each variable=value
- X */
- X do
- X {
- X rc = setvariable (&comptr);
- X if (rc != 0) break;
- X } while (rc != EOF);
- X
- X /*
- X ** Open and Parse the popmenu
- X */
- X filename = findfile (command, ".", getenv("MENUDIR"), "");
- X if ((menufile = fopen (filename, "r")) == NULL)
- X {
- X BEEP;
- X mvprintw (ErrRow-2, 0, "Unable to locate (%s) file.", command);
- X shutdown ();
- X }
- X
- X /*
- X ** The ParseTitle will put the .POPMENU title on line 0 of stdscr
- X ** so we need to save original title
- X ** then read and compare title 1 to see what the title for popmenu
- X ** should be.
- X ** Then write the original title back out. (whew)
- X */
- X /* save title line 0 with attributes */
- X for (i = 0; i <= COLS; i++)
- X titleline[i] = mvwinch (stdscr, 0, i);
- X
- X initmenu (&pmenu);
- X
- X rc = parsedriver (menufile, KeyWord, ParseKey, &pmenu, gnames, gfiles,
- X &gindex);
- X fclose (menufile);
- X
- X if (AUTOFIG)
- X {
- X int longest;
- X
- X /*
- X ** try to put menu as close to the option as possible
- X ** menu->option[opnumber]->row holds the
- X ** location on stdscr of the option that selected this.
- X */
- X row = menu->option[opnumber]->row - 1;
- X col = menu->option[opnumber]->col +
- X strlen (menu->option[opnumber]->description);
- X if (popmid == 9)
- X col += 4;
- X
- X /* make sure it fits on the screen */
- X if ((row + pmenu.optioncount + 2) > LINES)
- X row = LINES - pmenu.optioncount - 2;
- X
- X for (i = 0, longest = 0; i < pmenu.optioncount; i++)
- X if (strlen (pmenu.option[i]->description) > longest)
- X longest = strlen (pmenu.option[i]->description);
- X if ((col + longest + 4) > COLS)
- X col = COLS - longest - 4;
- X
- X if (row < 0)
- X row = 0;
- X
- X /*
- X ** Recalculate the options row and col for recursion
- X */
- X for (i = 0; i < pmenu.optioncount; i++)
- X {
- X pmenu.option[i]->row = row + 1 + i;
- X pmenu.option[i]->col = col;
- X }
- X }
- X
- X /* find popmenu title in line 0 */
- X for (i = 0; i <= COLS; i++)
- X {
- X poptitle[i] = ' ';
- X if (mvwinch (stdscr, 0,i) != titleline[i])
- X {
- X poptitle[i] = mvwinch(stdscr, 0,i);
- X }
- X else
- X poptitle[i] = ' ';
- X /* write original title back out */
- X mvwaddch (stdscr, 0,i, titleline[i]);
- X }
- X poptitle[i] = '\0';
- X /* junk trailing spaces */
- X for (i = strlen(poptitle)-1; i >= 0; i--)
- X if (poptitle[i] == ' ')
- X poptitle[i] = '\0';
- X else
- X break;
- X
- X if (rc != 0) return (rc); /* from parsemenu */
- X
- X
- X
- X /* if .BOX||.LINE && DIM then unhilight */
- X if (DIMFLAG)
- X {
- X /* Dim the .BOX */
- X if (menu->boxtype)
- X drawbox (stdscr, 1,1, LINES-1,COLS,
- X (menu->boxtype&0777000)>>9, DumbLine,
- X FALSE, FALSE);
- X
- X /* Dim the .LINE */
- X if (menu->linetype)
- X drawline (stdscr, menu->titlecount-1,
- X (menu->linetype&0777000)>>9, DumbLine,
- X menu->boxtype);
- X
- X wnoutrefresh (stdscr);
- X }
- X
- X /* popmid = 10+ */
- X popmid++;
- X for (i = 0; i < pmenu.optioncount; i++)
- X strcpy (PopMenu[i], pmenu.option[i]->description);
- X strcpy (PopMenu[i], "");
- X popmenu (INITMENU, popmid, row, col, poptitle, HELPFILE,
- X LINES-2, sizeof(PopMenu[0]), PopMenu);
- X
- X rc = popmenu (popmid, (char *)NULL);
- X
- X /* run option selected */
- X if (rc > 0)
- X {
- X for (i = 1; i <= MAXKEYS && strcmp (KeyWord[i], "") != 0; i++)
- X if (strcmp (pmenu.option[rc-1]->keyword,
- X KeyWord[i]) == 0)
- X {
- X if (RunKey[i] != NULL)
- X {
- X /*
- X ** Dim box is option is a .POPMENU or
- X ** a .GETINPUT or a .SYSTEM GETINPUT
- X */
- X comptr = pmenu.option[rc-1]->command;
- X SKIPJUNK(comptr);
- X sscanf (comptr, "%s", command);
- X if (strcmp (pmenu.option[rc-1]->keyword, ".POPMENU") == 0 ||
- X strcmp (pmenu.option[rc-1]->keyword, ".GETINPUT") == 0 ||
- X (strcmp (pmenu.option[rc-1]->keyword, ".SYSTEM") == 0 &&
- X strcmp (command, "GETINPUT") == 0))
- X popmenu (UNHILIGHTBOX, popmid);
- X
- X rc = (*RunKey[i]) (&pmenu, rc-1,
- X KeyWord, ParseKey, ShowKey,
- X RunKey, gnames, gfiles, gindex);
- X }
- X break;
- X }
- X }
- X else
- X rc = 0; /* popmenu was cancelled, continue */
- X
- X popmid--;
- X
- X /* run after_menu if there is one */
- X if (pmenu.after_menu != (char *)NULL)
- X RunAftMenu (&pmenu);
- X
- X clean_menu (&pmenu);
- X
- X if (DIMFLAG)
- X {
- X /* hilight .BOX */
- X if (menu->boxtype)
- X drawbox (stdscr, 1,1, LINES-1,COLS,
- X menu->boxtype & 0777, StandoutLine,
- X FALSE, FALSE);
- X
- X /* hilight .LINE */
- X if (menu->linetype)
- X drawline (stdscr, menu->titlecount-1,
- X menu->linetype & 0777, StandoutLine,
- X menu->boxtype);
- X }
- X
- X touchwin (stdscr);
- X
- X if (rc != 0)
- X return (rc);
- X else
- X return (REPARSE);
- X}
- X/* Paul J. Condie 10/88 */
- SHAR_EOF
- chmod 0644 RunPopMenu.c || echo "restore of RunPopMenu.c fails"
- echo "x - extracting RunGetI.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > RunGetI.c &&
- X#ifndef LINT
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X#endif
- X
- X/* FUNCTION: RunGetInpt()
- X** Runs keyword ".GETINPUT".
- X** ARGS: option option info sturcture
- X** RETURNS: none
- X*/
- X
- X#include <curses.h>
- X#include <term.h>
- X#include <ctype.h>
- X#include "menu.h"
- X
- X
- X
- XRunGetInput (menu, opnumber, KeyWord, ParseKey, ShowKey, RunKey,
- X gnames, gfiles, gindex)
- X struct MenuInfo *menu;
- X int opnumber;
- X int (*ParseKey[MAXKEYS])(),
- X (*ShowKey[MAXKEYS])(),
- X (*RunKey[MAXKEYS])();
- X char KeyWord[MAXKEYS][MAXKEYLENGTH];
- X char gnames[MAXGNAME][15];
- X char gfiles[MAXGNAME][15];
- X int gindex;
- X{
- X char screen_name[50];
- X int rc; /* return code */
- X char *comptr;
- X
- X /*
- X ** The first argument is the screen name
- X */
- X comptr = menu->option[opnumber]->command;
- X SKIPJUNK(comptr);
- X sscanf (menu->option[opnumber]->command, "%s", screen_name);
- X comptr += strlen (screen_name);
- X SKIPJUNK(comptr);
- X
- X /*
- X ** Loop through each variable=value
- X */
- X do
- X {
- X rc = setvariable (&comptr);
- X if (rc != 0) break;
- X } while (rc != EOF);
- X
- X rc = runscreen (screen_name, menu, opnumber);
- X if (rc == KEY_CANCEL)
- X return (0);
- X else
- X return (REPARSE);
- X}
- SHAR_EOF
- chmod 0644 RunGetI.c || echo "restore of RunGetI.c fails"
- echo "x - extracting RunAftMenu.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > RunAftMenu.c &&
- X/* FUNCTION: RunAftMenu()
- X** Runs keyword ".AFTER_MENU".
- X** ARGS:
- X** menu menu structure
- X** RETURNS: none
- X*/
- X
- X#include <curses.h>
- X#include <ctype.h>
- X#include <signal.h>
- X#include "menu.h"
- X
- X
- Xextern int debug;
- Xextern int trapsigs;
- X
- X
- X
- XRunAftMenu (menu)
- X struct MenuInfo *menu;
- X{
- X int shutdown();
- X int rc;
- X char *comptr;
- X char tmpstr[80];
- X int redrawflag = FALSE;
- X
- X
- X
- X comptr = menu->after_menu;
- X SKIPJUNK(comptr);
- X
- X
- X sscanf (comptr, "%s", tmpstr); /* do we have a REDRAW */
- X if (strcmp (tmpstr, "REDRAW") == 0)
- X {
- X redrawflag = TRUE;
- X comptr += strlen(tmpstr);
- X SKIPJUNK(comptr);
- X sscanf (comptr, "%s", tmpstr); /* do we have a GETINPUT */
- X }
- X
- X if (strcmp (tmpstr, "GETINPUT") == 0)
- X {
- X /* get screen name */
- X comptr += strlen(tmpstr);
- X SKIPJUNK(comptr);
- X sscanf (comptr, "%s", tmpstr); /* screen name */
- X comptr += strlen(tmpstr);
- X SKIPJUNK(comptr); /* sitting at system(3) */
- X rc = runscreen (tmpstr, menu, 1);
- X if (rc == KEY_CANCEL)
- X return (0);
- X }
- X
- X reset_shell_mode ();
- X signal (SIGINT, shutdown);
- X signal (SIGQUIT, shutdown);
- X rc = system (comptr);
- X if (trapsigs)
- X {
- X signal (SIGINT, SIG_IGN);
- X signal (SIGQUIT, SIG_IGN);
- X }
- X reset_prog_mode ();
- X keypad (stdscr, TRUE);
- X
- X /*
- X ** Going from a shell return code (char) to a c return code (int)
- X ** the shell return code gets put in the high byte. So we will
- X ** shift the int right 8 bytes.
- X */
- X rc = rc >> 8; /* to get shell rc */
- X if (debug)
- X {
- X fprintf (stderr, "\n[%s] <%s> rc=%d command=%s",
- X __FILE__, ".AFTER_MENU", rc, comptr);
- X fflush (stderr);
- X }
- X
- X /*
- X ** Shell can't handle negative return codes so we will convert
- X ** the return code to negative so menu can use it.
- X ** -1 = QUIT
- X ** -2 = MAINMENU
- X ** -3 = PREVMENU
- X ** -4 = NOWAYJOSE
- X ** 100+offset = GNAME
- X */
- X if (rc < GNAMEOFFSET)
- X rc -= rc * 2; /* make negative */
- X
- X if (redrawflag)
- X clearok (stdscr, TRUE);
- X
- X return (rc);
- X}
- X/* Paul J. Condie 4-90 */
- SHAR_EOF
- chmod 0644 RunAftMenu.c || echo "restore of RunAftMenu.c fails"
- echo "x - extracting GetOption.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > GetOption.c &&
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X#include <curses.h>
- X#include <ctype.h>
- X#include "menu.h"
- X#include "terminal.h"
- X
- Xextern int HotKeys;
- X int ch; /* input character */
- X
- X
- XGetOption (row, col, s)
- X
- X int row; /* row to get user input */
- X int col; /* col to get user input */
- X char *s; /* memory string to store input */
- X{
- X char *findfile();
- X char *getenv();
- X char *ws; /* working string */
- X int cc; /* column count */
- X int i; /* work variable */
- X char hlpfile[100];
- X
- X
- X ws = s; /* set to memory string */
- X cc = col;
- X
- X for (i = col; i <= col+3; i++) /* blank out prompt field */
- X mvaddch (row, i, ' ');
- X /* display default text */
- X while (*ws)
- X {
- X move (row, cc++);
- X addch (*ws);
- X ws++;
- X }
- X /* loop until done */
- X for (;;)
- X {
- X move (row, cc);
- X refresh ();
- X ch = mygetch ();
- X move (ErrRow, 0); clrtoeol ();
- X
- X if (ch == KeyDown) ch = KEY_DOWN;
- X if (ch == KeyUp) ch = KEY_UP;
- X if (ch == KeyTab) ch = KEY_TAB;
- X if (ch == KeyBTab) ch = KEY_BTAB;
- X if (ch == KeyReturn) ch = KEY_RETURN;
- X if (ch == KeyBackspace) ch = KEY_BACKSPACE;
- X if (ch == KeyRedraw) ch = KEY_REFRESH;
- X if (ch == KeyHelp) ch = KEY_HELP;
- X if (ch == KeyMainMenu) ch = KEY_MAINMENU;
- X if (ch == KeyPrevMenu) ch = KEY_PREVMENU;
- X if (ch == KeyExitMenu) ch = KEY_EXITMENU;
- X if (ch == KeyGname) ch = KEY_GNAME;
- X if (ch == KeyPopGname) ch = KEY_POPGNAME;
- X
- X if (ch >= 'a' && ch <= 'z')
- X ch = toupper (ch);
- X
- X switch (ch)
- X {
- X case KEY_DOWN:
- X case KEY_UP:
- X case KEY_TAB:
- X case KEY_BTAB:
- X *s = '\0'; /* reset select to null */
- X case KEY_RETURN:
- X case KEY_LINEFEED:
- X case '0':
- X case '1':
- X case '2':
- X case '3':
- X case '4':
- X case '5':
- X case '6':
- X case '7':
- X case '8':
- X case '9':
- X return (ch);
- X
- X case '!':
- X if (getenv ("SHELL") != (char *)NULL)
- X return (ch);
- X break;
- X
- X case KEY_HELP:
- X case KEY_EXITMENU:
- X case KEY_MAINMENU:
- X case KEY_PREVMENU:
- X case KEY_GNAME:
- X if (HotKeys)
- X {
- X return (ch);
- X }
- X else
- X {
- X if (ch == KEY_HELP)
- X *ws = KeyHelp;
- X else if (ch == KEY_EXITMENU)
- X *ws = KeyExitMenu;
- X else if (ch == KEY_MAINMENU)
- X *ws = KeyMainMenu;
- X else if (ch == KEY_PREVMENU)
- X *ws = KeyPrevMenu;
- X else if (ch == KEY_GNAME)
- X *ws = KeyGname;
- X move (row, cc);
- X addch (*ws);
- X ws++;
- X *ws = '\0';
- X cc++; /*move over one column*/
- X }
- X break;
- X
- X case KEY_BACKSPACE:
- X if (cc == col)
- X continue;
- X else
- X {
- X move (row, --cc); /* back up one column */
- X addch (' ');
- X ws--;
- X *ws = '\0';
- X }
- X break;
- X
- X case KEY_REFRESH:
- X /* redraw screen */
- X clearok (stdscr, TRUE);
- X refresh ();
- X break;
- X
- X case KEY_POPGNAME:
- X return (KeyPopGname);
- X
- X case ' ':
- X case 'A':
- X case 'B':
- X case 'C':
- X case 'D':
- X case 'E':
- X case 'F':
- X case 'G':
- X case 'H':
- X case 'I':
- X case 'J':
- X case 'K':
- X case 'L':
- X case 'M':
- X case 'N':
- X case 'O':
- X case 'P':
- X case 'Q':
- X case 'R':
- X case 'S':
- X case 'T':
- X case 'U':
- X case 'V':
- X case 'W':
- X case 'X':
- X case 'Y':
- X case 'Z':
- X return (ch);
- X
- X default:
- X if (isprint (ch))
- X {
- X *ws = ch;
- X move (row, cc);
- X addch (*ws);
- X ws++;
- X *ws = '\0';
- X cc++; /*move over one column*/
- X }
- X break;
- X } /* end switch */
- X } /* end for */
- X}
- SHAR_EOF
- chmod 0644 GetOption.c || echo "restore of GetOption.c fails"
- echo "x - extracting EndWindow.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > EndWindow.c &&
- Xstatic char Sccsid[] = "@(#)EndWindow.c 1.1 DeltaDate 9/6/87 ExtrDate 1/22/90";
- X/* FUNCTION: EndWindow()
- X** When a "WINDOW" keyword is found this function
- X** recalculates the row and column to begin
- X** displaying the next subwindow.
- X** ARGS: menu current menu structure
- X*/
- X
- X#include "menu.h"
- X
- Xextern int swin, ewin, longest;
- X
- X
- XEndWindow (menu)
- X
- X struct MenuInfo *menu;
- X{
- X int i;
- X
- X
- X if (swin == ewin) return;
- X
- X longest += 5;
- X
- X/*
- X** Calculate what row and column to display option on.
- X*/
- X
- X for (i = swin; i < ewin; i++)
- X {
- X menu->option[i]->row = ((menu->wlrow - menu->wfrow) / 2 + menu->wfrow) -
- X ((ewin - swin) / 2) + i - swin;
- X menu->option[i]->col = (menu->wlcol - menu->wfcol) / 2 -
- X longest / 2 + menu->wfcol;
- X }
- X}
- SHAR_EOF
- chmod 0444 EndWindow.c || echo "restore of EndWindow.c fails"
- echo "x - extracting displaytxt.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > displaytxt.c &&
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X
- X/* FUNCTION: displaytext()
- X** Displays a string to the screen with atributes.
- X** ARGS:
- X** win curses window to display to
- X** row screen row
- X** col screen col
- X** s the string
- X** RETURNS: none
- X*/
- X
- X#include <curses.h>
- X
- Xdisplaytext (win, row, col, s)
- X WINDOW *win;
- X int row, col;
- X char s[];
- X{
- X int i;
- X
- X wmove (win, row, col);
- X
- X/*
- X** Now display looking for terminal attributes.
- X*/
- X for (i = 0; s[i] != '\0'; i++)
- X {
- X if (s[i] == '\\')
- X {
- X#ifdef BSD
- X if (s[i+1] != 'N') s[i+1] = 'S'; /* Berk only supports standout */
- X#endif
- X switch (s[++i])
- X {
- X case 'S':
- X#ifdef BSD
- X wstandout (win);
- X#else
- X wattrset (win, win->_attrs|A_STANDOUT);
- X#endif
- X break;
- X case 'B':
- X#ifdef SYS5
- X wattrset (win, win->_attrs|A_BOLD);
- X#endif
- X break;
- X case 'U':
- X#ifdef SYS5
- X wattrset (win, win->_attrs|A_UNDERLINE);
- X#endif
- X break;
- X case 'D':
- X#ifdef SYS5
- X wattrset (win, win->_attrs|A_DIM);
- X#endif
- X break;
- X case 'R':
- X#ifdef SYS5
- X wattrset (win, win->_attrs|A_REVERSE);
- X#endif
- X break;
- X case 'L':
- X#ifdef SYS5
- X wattrset (win, win->_attrs|A_BLINK);
- X#endif
- X break;
- X case 'N':
- X#ifdef BSD
- X wstandend (win);
- X#else
- X wattrset (win, A_NORMAL);
- X#endif
- X break;
- X }
- X }
- X else
- X waddch (win, s[i]);
- X }
- X}
- SHAR_EOF
- chmod 0644 displaytxt.c || echo "restore of displaytxt.c fails"
- echo "x - extracting SetTerm.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > SetTerm.c &&
- X#ifndef LINT
- Xstatic char Sccsid[] = "%W% DeltaDate %G% ExtrDate %H%";
- X#endif
- X
- X#include <curses.h>
- X#include "menu.h"
- X
- X /* default values for dumb terminals */
- X /* a -1 indicates nokey */
- X/* Mover Keys */
- Xint KeyReturn = '\r'; /* \r - menu & GetInput */
- Xint KeyDown = 10; /* \n - menu & GetInput */
- Xint KeyUp = 11; /* ^k - menu & GetInput */
- Xint KeyTab = '\t'; /* \t - menu & GetInput */
- Xint KeyBTab = -1; /* - menu & GetInput */
- X
- X/* Edit Keys */
- Xint KeyBeg = 2; /* ^b - GetInput */
- Xint KeyEnd = 5; /* ^e - GetInput */
- Xint KeyRight = 12; /* ^l - GetInput */
- Xint KeyLeft = 8; /* \b - GetInput */
- Xint KeyBackspace = '\b'; /* \b - GetInput */
- Xint KeyEOL = 4; /* ^d - GetInput clear to end of field */
- Xint KeyDL = 3; /* ^c - GetInput clear field and home cursor */
- Xint KeyDC = 24; /* ^x - GetInput delete character */
- Xint KeyIC = 20; /* ^t - GetInput typeover/insert mode */
- X
- X/* Other Keys */
- Xint KeyHelp = '?'; /* ? - menu & GetInput */
- Xint KeyTOC = 20; /* ^t - ShowHelp */
- Xint KeyRedraw = 18; /* ^r - menu & GetInput */
- Xint KeyCancel = 27; /* ESC - menu & GetInput pop-up menus */
- SHAR_EOF
- echo "End of part 5"
- echo "File SetTerm.c is continued in part 6"
- echo "6" > s2_seq_.tmp
- exit 0
-