menu(1) part 9 of 11

Paul J. Condie pjc at pcbox.UUCP
Sat Apr 7 03:56:28 AEST 1990


#!/bin/sh
# this is part 9 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file utilities.d/libgeti.d/ShowChar.c continued
#
CurArch=9
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 utilities.d/libgeti.d/ShowChar.c"
sed 's/^X//' << 'SHAR_EOF' >> utilities.d/libgeti.d/ShowChar.c
X		((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
X		((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
X				"Only alpha/numberic characters allowed.") ;
X			wattrOff (stdscr);
X         		wmove(win, rowStart, col) ;
X         		BELL;
X      		}
X      		break ;
X
X   	   case UPPER:
X      		if (isalpha(*ch)) 
X		{
X			if (insertmode)
X			{
X				junk = doinsert (win, row, col, colStart, 
X						colEnd, charKeyed, fldMask,
X						fldCharType, fldType, rowStart,
X						fldAttrib, fldRange, fldLength,
X						fldErrRow, origAttr);
X				if (junk != 0)
X					break;
X			}
X
X         		*ch = toupper(*ch);
X         		wattrset(win, fldAttrib) ;
X         		waddch(win, *ch) ;
X         		wattrset(win, 0) ;
X         		*(charKeyed + col - colStart) = 'Y' ;
X      		} 
X		else 
X		{
X			CLEARROW (fldErrRow);
X			wattrOn (stdscr, A_REVERSE|A_BOLD);
X         		mvwaddstr(stdscr,
X		((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
X		((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
X				"Only alpha characters allowed.") ;
X			wattrOff (stdscr);
X         		wmove(win, rowStart, col) ;
X         		BELL;
X      		}
X      		break;
X
X   	   case NUMERIC:
X      		if (isdigit(*ch)  ||
X          	   ((fldType == FLOAT ||
X          	     fldType == DOUBLE ||
X          	     fldType == MONEY) && *ch == '.') ) 
X		{
X			if (insertmode)
X			{
X				junk = doinsert (win, row, col, colStart, 
X						colEnd, charKeyed, fldMask,
X						fldCharType, fldType, rowStart,
X						fldAttrib, fldRange, fldLength,
X						fldErrRow, origAttr);
X				if (junk != 0)
X					break;
X			}
X
X         		wattrset(win, fldAttrib) ;
X         		waddch(win, *ch) ;
X         		wattrset(win, 0) ;
X         		*(charKeyed + col - colStart) = 'Y' ;
X         		if (fldType == FLOAT || fldType == DOUBLE ||
X             			fldType == MONEY) 
X			{
X            			int   firstCol ;
X
X            			firstCol = colStart ;
X            			while (*(charKeyed + firstCol - colStart) == 'M')
X               				firstCol++;
X            			if (col == firstCol) 
X				{
X               				cmdstr[0] = *ch ;
X               				cmdstr[1] = '\0' ;
X               				while (++col < colEnd)
X                  				*(charKeyed + col - colStart) = 'N' ;
X               				ReDispFld(win, rowStart, colStart, fldAttrib, fldMask, fldRange, fldLength, fldCharType,
X                    				fldType, cmdstr, colEnd, charKeyed, 0, origAttr) ;
X               					wattrOn(win, fldAttrib) ;
X               				mvwaddstr(win, rowStart, colStart + 1, "   ") ;
X               				wattrOff(win) ;
X               				wmove(win, rowStart, colStart + 1) ;
X            			}
X         		}
X
X    		} 
X		else 
X		{
X			CLEARROW (fldErrRow);
X			wattrOn (stdscr, A_REVERSE|A_BOLD);
X         		mvwaddstr(stdscr,
X		((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
X		((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
X					"Only numbers allowed.") ;
X			wattrOff (stdscr);
X         		wmove(win, rowStart, col) ;
X         		BELL;
X      		}
X      		break ;
X
X   	   default:
X      		BELL;
X      		break ;
X
X   	} /* end switch */
X
X   	getyx(win, row, col) ;
X   	if (col == colEnd && keyStream == TRUE)
X	{
X		*ch = KEY_RETURN;
X      		return(FALSE) ;
X	}
X   	else 
X      		if (col != colEnd && fldMask != NULL) 
X      		{
X	 		/* skip cursor over format characters in the mask */
X         		while (col != colEnd && 
X			       *(charKeyed+col-colStart) == 'M')
X            			col++;
X         		wmove(win, rowStart, col) ;
X         		return(TRUE) ;
X      		}
X
X   	return (TRUE);
X}
SHAR_EOF
echo "File utilities.d/libgeti.d/ShowChar.c is complete"
chmod 0444 utilities.d/libgeti.d/ShowChar.c || echo "restore of utilities.d/libgeti.d/ShowChar.c fails"
echo "x - extracting utilities.d/libgeti.d/ShowHelp.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ShowHelp.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X#include 	<curses.h>
X#include	<ctype.h>
X#include	"keys.h"
X#include	"GetInput.h"
X
X
X#ifndef	KEY_BEG
X#define	KEY_BEG		0542
X#endif
X#ifndef	KEY_END
X#define	KEY_END		0550
X#endif
X#ifndef	KEY_HELP
X#define	KEY_HELP	0553
X#endif
X#ifndef	KEY_CANCEL
X#define	KEY_CANCEL	0543
X#endif
X
X#ifndef BELL
X#define BELL	printf ("%c", 7);
X#endif
X#define	NEXTPAGE	1
X#define	PREVPAGE	2
X#define	SCROLLDOWN	3
X#define	SCROLLUP	4
X#define	FIRSTPAGE	5
X#define	LASTPAGE	6
X
X#define	SCROLLRATE	(wrows/2)			/* # lines to scroll */
X#define	MAXTOC		24				/* max TOC entries */
X#define	TOCTAG		"TABLE_OF_CONTENTS"		/* helptag for TOC */
X
X#define	SKIPJUNK(s) 	/* \
X			**  This macro skips over spaces, tabs, etc. \
X			**  ARGS:  char  *s \
X			*/ \
X			for (;*s != '\0' && (isspace(*s)); s++) \
X				;
X
Xstruct TableOfContents
X{
X	char	helpfile[16];
X	char	helptag[30];
X	char	text[100];
X};
X
X
XShowHelp (HelpFile, Tag, fldErrRow)
X	char	HelpFile[];
X	char	Tag[];
X	int	fldErrRow;
X{
X	WINDOW	*helpWin;
X   	FILE	*fopen(), *fp;
X	char	*fgets();
X	char	*getenv();
X	long	ftell();
X	char	line[100];
X	char	*sptr;
X	int	row;
X	int	col;
X	int	wrows;
X	int	wcols;
X	char	helpfile[80];
X	int	longline; /*0*/
X	int	ch;
X	char	title[100];
X	int	scrollflag;
X	int	linecount;
X	long	lineoffset[200];		/* start of line in file */
X	static int	helpHelp = FALSE;
X	struct TableOfContents	TOC[MAXTOC];
X	int	rc;
X	int	TOCflag = FALSE;
X	char	fileName[100];
X	char	tag[80];
X
X
X	strcpy (fileName, HelpFile);
X	strcpy (tag, Tag);
Xrestart:
X	strcat (tag, "\n");
X	linecount = 0;
X	/* do we have a help tag ? */
X	if (strcmp (tag, "") == 0)
X	{
X       		BELL;
X		CLEARROW (fldErrRow);
X		wattrOn (stdscr, A_REVERSE|A_BOLD);
X       		mvwaddstr(stdscr,
X		    ((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
X		    ((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
X				"No help available.");
X		wattrOff (stdscr);
X		return (1);
X	}
X
X	/*
X	**  open help file
X	*/
X   	if ((fp = fopen (fileName, "r")) == NULL)
X   	{
X		if (getenv("HELPDIR") != (char *)NULL)
X      			sprintf (helpfile, "%s/%s", getenv ("HELPDIR"), 
X				 fileName);
X      		fp = fopen (helpfile, "r");
X      		if (fp == NULL) 
X      		{
X         		BELL;
X			CLEARROW (fldErrRow);
X			wattrOn (stdscr, A_REVERSE|A_BOLD);
X               		mvwaddstr(stdscr,
X		((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
X		((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
X				"No help available.");
X			wattrOff (stdscr);
X         		return(1) ;
X      		}
X   	}
X
X	if (!TOCflag) 
X		TOCflag = loadTOC (fp, TOC) == 0 ? TRUE : FALSE;
X
X	/*
X	**  Locate starting tag.
X	*/
X	while ((sptr = fgets (line, sizeof(line)-1, fp)) != (char *)NULL)
X		if (strncmp (line, tag, strlen(tag)) == 0)
X			break;
X
X	if (sptr == (char *)NULL)
X	{
X		/* Did not find starting tag */
X      		BELL;
X		CLEARROW (fldErrRow);
X		wattrOn (stdscr, A_REVERSE|A_BOLD);
X               	mvwaddstr(stdscr,
X		((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
X		((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
X			"No help available.");
X		wattrOff (stdscr);
X      		fclose(fp) ;
X      		return(1) ;
X	}
X
X	/*
X	**	Found starting tag.
X	**	determine how big of a window to make by searching for 
X	**  	ending tag
X	**	check for a .TITLE line
X	*/
X	lineoffset[linecount+1] = ftell (fp);
X	fscanf (fp, "%s", title);
X	if (strcmp (title, ".TITLE") == 0)
X	{
X		fseek (fp, 1, 1);			/* skip 1 byte */
X		sptr = fgets (title, sizeof(title)-1, fp);
X		title[strlen(title)-1] = '\0';		/* junk \n */
X		lineoffset[linecount+1] = ftell (fp); 	/* reset beg of help */
X	}
X	else
X		strcpy (title, "");
X	longline = strlen(title)+2;
X
X	fseek (fp, lineoffset[1], 0);		/* back to row 1 */
X	while ((sptr = fgets (line, sizeof(line)-1, fp)) != (char *)NULL)
X	{
X		/* check for ending tag */
X		if (strncmp (line, tag, strlen(tag)) == 0)
X			break;
X		
X		/* calculate longest line */
X		if (strlen(line) > longline)
X			longline = strlen(line);
X		linecount++;
X		lineoffset[linecount+1] = ftell (fp);
X	}
X
X	wrows = (linecount+2 < (LINES-2)) ? linecount+2 : (LINES-2);
X	wcols = (longline+1 < COLS) ? longline+1 : COLS;	/* 1 for \n */
X	/* center window on the screen */
X   	helpWin = newwin(wrows, wcols, LINES/2-wrows/2,COLS/2-wcols/2) ;
X	keypad (helpWin, TRUE);
X	scrollflag = (linecount+2 <= LINES) ? FALSE : TRUE;
X	drawbox (helpWin, 1,1, wrows,wcols, 2,2, scrollflag,
X			(helpHelp == FALSE ? TRUE : FALSE));
X	if (strcmp (title, "") != 0)
X	{
X		wattrset (helpWin, A_STANDOUT);
X		mvwprintw (helpWin, 0,2, "%s", title);
X		wattrset (helpWin, A_NORMAL);
X	}
X
X	row = 1;
X	fseek (fp, lineoffset[row], 0);		/* back to row 1 */
X	ch = KEY_BEG;
X	do
X	{
X		switch (ch)
X		{
X		   case KEY_TOC:
X			if (!TOCflag)
X				break;
X			rc = showTOC (TOC);
X			if (rc > 0)
X			{
X				fclose (fp);
X				delwin (helpWin);
X				strcpy (fileName,TOC[rc-1].helpfile);
X				strcpy (tag,TOC[rc-1].helptag);
X				goto restart;
X			}
X			touchwin (helpWin);
X			break;
X		   case KEY_BEG:
X			showpage (FIRSTPAGE,fp, wrows-2, wcols-2, helpWin,
X				linecount, lineoffset);
X			break;
X		   case KEY_DOWN:
X			showpage (SCROLLDOWN,fp,wrows-2, wcols-2, helpWin,
X				linecount, lineoffset);
X			break;
X		   case KEY_UP:
X			showpage (SCROLLUP, fp, wrows-2, wcols-2, helpWin,
X				linecount, lineoffset);
X			break;
X		   case KEY_END:
X			showpage (LASTPAGE, fp, wrows-2, wcols-2, helpWin,
X				linecount, lineoffset);
X			break;
X		   case KEY_HELP:
X			if (!helpHelp)
X			{
X				helpHelp = TRUE;
X				ShowHelp (fileName, "help", fldErrRow);
X				helpHelp = FALSE;
X			}
X			touchwin (helpWin);
X			break;
X		} /* end switch */
X		wattrset (helpWin, A_STANDOUT);
X		if (ftell(fp) != lineoffset[linecount+1])
X		{
X			/* we are not at end of file yet */
X			mvwprintw (helpWin, wrows-1, 2, "--More--(%d%c)",
X		     	   (int)((double)((double)(ftell(fp)-lineoffset[1]) / 
X		     	   (lineoffset[linecount+1]-lineoffset[1])) * 100), 
X			   '%');
X		}
X		else
X		{
X			if (linecount+2 >= LINES)
X				mvwprintw (helpWin, wrows-1, 2, 
X						"--End--       ");
X			else
X				mvwprintw (helpWin, wrows-1, 2, 
X						"              ");
X		}
X
X		wattrset (helpWin, A_NORMAL);
X		wmove (helpWin, wrows-2,wcols-2);
X		wrefresh (helpWin);
X		ch = wgetch (helpWin);
X
X		if (ch == KeyBeg || ch == KEY_BEG)
X			ch = KEY_BEG;
X		else if (ch == KeyDown || ch == KEY_DOWN)
X			ch = KEY_DOWN;
X		else if (ch == KeyUp || ch == KEY_UP)
X			ch = KEY_UP;
X		else if (ch == KeyCancel || ch == KEY_CANCEL)
X			ch = KEY_CANCEL;
X		else if (ch == KeyEnd || ch == KEY_END)
X			ch = KEY_END;
X		else if (ch == KeyHelp || ch == KEY_HELP)
X			ch = KEY_HELP;
X		else if (ch == KeyTOC || ch == KEY_TOC)
X			ch = KEY_TOC;
X		else
X		{
X			if (ftell(fp) != lineoffset[linecount+1])
X				ch = KEY_DOWN;
X			else
X				ch = KEY_CANCEL;
X		}
X	} while (ch != KEY_CANCEL);
X
X   	fclose(fp) ;
X	delwin (helpWin);
X	touchwin (stdscr);
X	wnoutrefresh (stdscr);
X   	return(0) ;
X}
X
X/*
X**  RETURNS:
X**		0	more info
X**		-1	end of file or tag
X*/
Xshowpage (action, fp, wrows, wcols, helpWin, linecount, lineoffset)
X	int	action;
X	FILE	*fp;
X	int	wrows;
X	int	wcols;
X	WINDOW	*helpWin;
X	int	linecount;
X	long	lineoffset[];		/* start of line in file */
X{
X	char		line[100];
X	static int	here;				/* line top of screen */
X	int		rowcount;
X	int		i,j;
X
X
X	switch (action)
X	{
X	   case FIRSTPAGE:
X		here = 1;
X		break;
X
X	   case LASTPAGE:
X		if (here == linecount - wrows + 1) return (-1);
X		here = linecount - wrows + 1;
X		break;
X
X	   case SCROLLDOWN:
X		if (here + wrows > linecount)
X			return(-1);				/* at EOF */
X		if (here + wrows + SCROLLRATE <= linecount+1)
X			here += SCROLLRATE;
X		else
X			here = linecount - wrows + 1;
X		break;
X
X	   case SCROLLUP:
X		if (here == 1)
X			return (-1);				/* at BOF */
X		if (here - SCROLLRATE >= 1)
X			here -= SCROLLRATE;
X		else
X			here = 1;
X		break;
X
X	   case NEXTPAGE:
X		break;
X
X	   case PREVPAGE:
X		break;
X	}
X
X	/* clear screen */
X	for (i=1; i<=wrows; i++)
X		for (j=1; j<=wcols; j++)
X			mvwprintw (helpWin, i,j, " ");
X	fseek (fp, lineoffset[here], 0);		/* first of screen */
X	for (rowcount=1; rowcount<=wrows && rowcount<=linecount; rowcount++)
X	{
X		fgets (line, sizeof(line)-1, fp);
X		line[strlen(line)-1] = '\0';		/* junk \n */
X		showline (helpWin, rowcount, 1, line);
X	}
X	return (0);
X}
X
X
X
X/*  FUNCTION:	displaytext()
X**		Displays a string to the screen with atributes.
X**  ARGS:	row	screen row
X**		col	screen col
X**		s	the string
X**  RETURNS:	none
X*/
X#ifndef SYSV
X#define	SYSV	1
X#endif
Xshowline (helpWin, row, col, s)
X	WINDOW	*helpWin;
X	int	row, col;
X	char	s[];
X{
X	int	i;
X
X   	wmove (helpWin, 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	    		/* Berkeley curses only supports standout */
X	    		if (s[i+1] != 'N') s[i+1] = 'S';
X#endif
X            		switch (s[++i])
X            		{
X	       		   case 'S':
X#ifdef BSD
X				standout ();
X#else
X	   			wattrset (helpWin, A_STANDOUT);
X#endif
X				break;
X	       		   case 'B':
X#ifdef SYSV
X				wattrset (helpWin, A_BOLD);
X#endif
X				break;
X	       		   case 'U':
X#ifdef SYSV
X				wattrset (helpWin, A_UNDERLINE);
X#endif
X				break;
X	       		   case 'D':
X#ifdef SYSV
X				wattrset (helpWin, A_DIM);
X#endif
X				break;
X	       		   case 'R':
X#ifdef SYSV
X				wattrset (helpWin, A_REVERSE);
X#endif
X				break;
X	       		   case 'L':
X#ifdef SYSV
X				wattrset (helpWin, A_BLINK);
X#endif
X				break;
X	       		   case 'N': 
X#ifdef BSD
X				standend ();
X#else
X				wattrset (helpWin, A_NORMAL);
X#endif
X				break;
X			}
X		}
X         	else
X            		waddch (helpWin, s[i]);
X	}
X}
X
X
X
XloadTOC (fp, TOC)
X	FILE			*fp;
X	struct TableOfContents	TOC[];
X{
X	char	line[100];
X	char	*sptr;
X	int	count = 0;
X
X
X	strcpy (TOC[0].text, "");
X	/*
X	**  Locate TABLE_OF_CONTENT tag.
X	*/
X	while ((sptr = fgets (line, sizeof(line)-1, fp)) != (char *)NULL)
X		if (strncmp (line, TOCTAG, strlen(TOCTAG)) == 0)
X			break;
X
X	if (sptr == (char *)NULL) 
X	{
X		rewind (fp);
X		return (-1);				/* no TOC */
X	}
X
X	while ((sptr = fgets (line, sizeof(line)-1, fp)) != (char *)NULL)
X	{
X		/* check for ending tag */
X		if (strncmp (line, TOCTAG, strlen(TOCTAG)) == 0)
X			break;
X		
X   		sscanf (sptr, "%s", TOC[count].helpfile);
X		sptr += strlen(TOC[count].helpfile);
X		SKIPJUNK(sptr);
X   		sscanf (sptr, "%s", TOC[count].helptag);
X		sptr += strlen(TOC[count].helptag);
X		SKIPJUNK(sptr);
X		strcpy (TOC[count].text, sptr);
X		TOC[count].text[strlen(TOC[count].text)-1] = '\0'; /* junk \n */
X		count++;
X	}
X	strcpy (TOC[count].text, "");
X	rewind (fp);
X	return (0);
X}
X
X
X
XshowTOC (TOC)
X	struct TableOfContents	TOC[];
X{
X	int	count;
X	int	length = 0;
X	char	menu[MAXTOC+2][80];		/* popmenu items */
X	int	menuid = 99;
X	int	rc;
X
X
X	for (count = 0; strcmp (TOC[count].text, "") != 0; count++)
X	{
X		strcpy (menu[count], TOC[count].text);
X		if (strlen(menu[count]) > length)
X			length = strlen(menu[count]);
X	}
X	strcpy (menu[count], "");
X
X	/* center on screen */
X	popmenu (-2, menuid, (LINES/2)-(count/2)-3, (COLS/2)-(length/2)-2, 
X			"Help - Table Of Contents", "", count, sizeof(menu[0]), 
X			menu);
X	rc = popmenu (menuid);
X	return (rc);
X}
X/* Paul J. Condie  12/88 */
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/ShowHelp.c || echo "restore of utilities.d/libgeti.d/ShowHelp.c fails"
echo "x - extracting utilities.d/libgeti.d/ShowSet.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ShowSet.c &&
Xstatic char Sccsid[] = "@(#)ShowSet.c	1.1   DeltaDate 8/30/87   ExtrDate 1/22/90";
X#include	<curses.h>
X#include	"GetInput.h"
X
XShowSet(win, rowStart, colStart, fldAttrib, fldRange, fldLength, pNum, colEnd, charKeyed, origAttr)
X	WINDOW		*win ;		/* Window	    		    */
X	int		rowStart ;
X	int		colStart ;
X	int		fldAttrib ;	/* Curses attribute		    */
X	char		*fldRange ;	/* enumeration list for SET 	    */
X	unsigned	fldLength ;	/* Maximum length of output 	    */
X	int		*pNum ;		/* enum to display */
X	int		colEnd ;
X	char		*charKeyed ;	/* characters keyed */
X	int		origAttr[] ;	/* original attributes for field */
X{
X	char	*fldWrk ;
X	int	count ;
X	int	col ;
X
X	wmove (win, rowStart, colStart) ;
X
X	fldWrk = fldRange ;
X
X	count = 0 ;
X
X	while (*fldWrk != '\0') {
X
X		if (count == *pNum)
X			break ;
X
X		while (*fldWrk != ','  &&  *fldWrk != '\0')
X			fldWrk++ ;
X
X		if (*fldWrk == '\0') {
X			fldWrk = fldRange ;
X			*pNum = 0 ;
X			break ;
X		}
X
X		while (*fldWrk == ','  ||  *fldWrk == ' ')
X			fldWrk++ ;
X
X		count++ ;
X	}
X
X	if(fldAttrib != -1)
X		wattrset (win, fldAttrib) ;
X
X	col = colStart ;
X	while (*fldWrk != ','  &&  *fldWrk != '\0') {
X		if(fldAttrib == -1)
X			wattrset(win, origAttr[col++ - colStart]) ;
X		waddch (win, *fldWrk++) ;
X		*charKeyed++ = 'Y' ;
X		fldLength-- ;
X	}
X
X	if(fldAttrib != -1)
X		wattrset (win, 0) ;
X
X	while (fldLength--) {
X		*charKeyed++ = 'N' ;
X		if(fldAttrib == -1)
X			wattrset(win, origAttr[col++ - colStart]) ;
X		waddch (win, ' ') ;
X	}
X
X	wmove (win, rowStart, colStart) ;
X	wattrset(win, 0) ;
X
X	return(0) ;
X
X}
X
X
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/ShowSet.c || echo "restore of utilities.d/libgeti.d/ShowSet.c fails"
echo "x - extracting utilities.d/libgeti.d/_Main.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/_Main.c &&
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X
X#include 	<curses.h>
X#include 	"GetInput.h"
X#include 	"keys.h"
X
X
Xmain (argc, argv)
X
X	int   argc;
X	char  *argv[];
X{
X   int   	intV ;
X   long  	longV ;
X   double   	doubleV ;
X   int   	retCode ;
X   char  	cmdstr[128] ;
X   union FldUnion Fld ;
X
X
X   Initialize() ;
X
X   cmdstr[0]='\0';
X   strcpy (cmdstr, "hi");
X   Fld.strVal = cmdstr;
X   retCode = GetInput (stdscr, 1, 1, &Fld, A_REVERSE, NOMASK, NORANGE,
X       5, 0, ALPHANUM, RTADJ_BFILL, CHAR, NOAUTO, NOMUST, 20, 22,
X       "Prompt", "GetInput.hlp", "GETINPUT");
X
X   mvprintw (1, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X
X   /* Double */
X   doubleV = 123.45 ;
X   Fld.doubleVal = &doubleV ;
X   retCode = GetInput (stdscr, 18, 0, &Fld, A_REVERSE, NOMASK, NORANGE, 
X	10, 0, NUMERIC, RTADJ_ZFILL, DOUBLE, NOAUTO,
X        NOMUST, 20, 21, "Double: ") ;
X   mvprintw (18, 40, "return code = :%d: value = :%f:", retCode, doubleV);
X   refresh ();
X
X   /*
X   cmdstr[0]='\0';
X   Fld.strVal = cmdstr;
X   retCode = GetInput (stdscr, 1, 1, &Fld, A_PROTECT, NOMASK, NORANGE,
X       5, 2, ALPHANUM, NOFILL, CHAR, NOAUTO, MUSTENTER, 2010, 22,
X       "Prompt                   %", "junk.hlp", "GETINPUT");
X
X   mvprintw (1, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X
X
X   strcpy(cmdstr, "AA") ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 2, 1, &Fld, A_STANDOUT, 
X	"[VV][VV][  ][  ][  ][  ][  ][  ]", NORANGE, 16, 2, UPPER_AN, NOFILL, 
X	CHAR, NOAUTO, MUSTENTER, 23, 22, "Character field:", "testfile", 
X	"FIELD 1") ;
X
X   mvprintw (2, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X   */
X
X
X/*
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 3, 1, &Fld, A_REVERSE, "HH:MM:SS:TT", NULL, 6, 6, 
X	TIME, NOFILL, CHAR, AUTONEXT, NOMUST, 20, 21, 
X	"Time Field HH:MM:SS:TT: ", "testfile", "FIELD 2") ;
X
X   mvprintw (3, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X*/
X
X
X/* DATE */
X/*
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 4, 0, &Fld, A_BOLD, "MM/DD/YY", NULL, 6, 6, DATE,
X	NOFILL, CHAR, AUTONEXT, NOMUST, 20, 21, "Date Field MM/DD/YY: ", 
X	"testfile", "FIELD 2") ;
X
X   mvprintw (4, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X*/
X
X/* ZIP */
X/*
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 9, 0, &Fld, A_REVERSE, NOMASK, NORANGE, 9, 0, 
X	ZIP, NOFILL, CHAR, AUTONEXT, NOMUST, 20, 21, "Zip Field XXXXX-XXXX",
X	NOHELP, NOTAG) ;
X
X   mvprintw (9, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X*/
X
X/*
X   flash () ;
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 8, 0, &Fld, A_REVERSE, "(999) 999-9999", NULL, 10, 5, NUMERIC, RTADJ_ZFILL, CHAR, NOAUTO, NOMUST, 20, 21, "Phone Number:", NULL, NULL) ;
X
X   flash () ;
X   strcpy(cmdstr, "ABC") ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 10, 0, &Fld, A_REVERSE, NULL, NULL, 9, 0, UPPER_AN, NOFILL, CHAR, AUTONEXT, NOMUST, 20, 21, "Job Number:", NULL, NULL) ;
X   mvprintw(12, 0, "strlen %d", strlen(cmdstr) ) ;
X   refresh() ;
X*/
X
X
X/*
X   strcpy(cmdstr, ";lkj") ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 12, 0, &Fld, A_REVERSE, NOMASK, 
X		", INTeger, CHARacter, HEXdecimal, DATE", 12, 0, SET, NOFILL, 
X		CHAR, NOAUTO, NOMUST, 20, 21, "enumeration field: ", 
X		NOMSG, NOTAG) ;
X   mvprintw (12, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh () ;
X*/
X
X/*
X   flash () ;
X   intV = 200 ;
X   Fld.intVal = &intV ;
X   retCode = GetInput (stdscr, 13, 0, &Fld, A_REVERSE, NOMASK, "100, 200, 300", 
X		12, 0, SET, NOFILL, INT, NOAUTO, MUSTENTER, 23, 22, 
X		"enumeration field - int: ", NULL, NULL) ;
X   mvprintw (13, 20, "return code = :%d: value = :%d:", retCode, intV);
X   refresh () ;
X
X   flash () ;
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 14, 0, &Fld, A_REVERSE, NOMASK, NORANGE, 2, 2, STATE, NOFILL, CHAR, AUTONEXT, MUSTENTER, 20, 21, "State Field: ", NULL, NULL) ;
X   refresh () ;
X
X   flash () ;
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 16, 0, &Fld, A_REVERSE, NOMASK, NORANGE, 6, 6, UPPER_AN, NOFILL, CHAR, NOAUTO, NOMUST,
X        20, 21, "Six char field") ;
X
X   refresh () ;
X
X   */
X
X   refresh () ;
X   sleep (4) ;
X   Windup () ;
X   exit (0) ;
X}
X
X
XInitialize ()
X{
X   initscr() ;
X   cbreak() ;
X   noecho() ;
X   nonl() ;
X   keypad(stdscr, TRUE) ;
X   InitGetI() ;
X   return(0) ;
X}
X
X
XWindup()
X{
X	/*
X	**
X	**	Take care of curses.
X	**
X	*/
X	endwin() ;
X
X	return(0) ;
X}
X
X
SHAR_EOF
chmod 0644 utilities.d/libgeti.d/_Main.c || echo "restore of utilities.d/libgeti.d/_Main.c fails"
echo "x - extracting utilities.d/libgeti.d/checkmask.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/checkmask.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)checkmask.c	1.1   DeltaDate 11/21/88   ExtrDate 1/22/90";
X#endif
X
X#include 	<curses.h>
X#include 	<ctype.h>
X#include 	"GetInput.h"
X
Xcheckmask (col, colStart, fldMask, fldCharType, fldType, ch)
X
X	int	col ;
X	int   colStart ;
X	char  *fldMask ;  	/* mask for character string      */
X	char  fldCharType ;  	/* type of character           */
X	char  fldType ;   	/* type of field         */
X	int   ch ;     		/* contains character keyed or being
X                  			moved */
X{
X   	char  charType ;
X   	char  cmdstr[16] ;
X
X
X
X   	if (fldCharType == STATE  || fldMask == NULL)
X      		charType = fldCharType ;
X   	else 
X      		if (fldCharType == DATE  ||  fldCharType == TIME)
X         		charType = NUMERIC ;
X      		else
X         		charType = *(fldMask + col - colStart) ;
X
X   	switch (charType) 
X   	{
X   	   case HEX:
X      		break ;
X
X   	   case ALPHA:
X      		if (isalpha(ch)) 
X			return (ch);
X		else 
X			return (-1);
X      		break ;
X
X   	   case ALPHANUM:
X   	   case UPPER_AN:
X   	   case STATE:
X      		if (isprint(ch)) 
X      		{
X         		if (charType == UPPER_AN  ||  charType == STATE)
X            			ch = toupper(ch);
X			return (ch);
X      		} 
X      		else 
X			return (-1);
X      		break ;
X
X   	   case UPPER:
X      		if (isalpha(ch)) 
X		{
X         		ch = toupper(ch);
X			return (ch);
X      		}
X		else
X			return (-1);
X      		break ;
X
X   	   case NUMERIC:
X      		if (isdigit(ch)  ||
X          	   ( (fldType == FLOAT ||
X          	      fldType == DOUBLE ||
X          	      fldType == MONEY) && ch == '.') ) 
X		{
X			return (ch);
X      		} 
X		else 
X			return (-1);
X      		break ;
X
X   	   default:
X		return (-1);
X   	} /* end switch */
X	return (-1);
X}
X/* Paul J. Condie  11/88 */
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/checkmask.c || echo "restore of utilities.d/libgeti.d/checkmask.c fails"
echo "x - extracting utilities.d/libgeti.d/doinsert.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/doinsert.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)doinsert.c	1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/*
X**  doinsert()
X**	Shifts characters to the right of cursor location over one and
X**	places a space where the new character will go.
X**  RETURNS:
X**		-1	field is full
X**		-2	didn't pass mask edits
X*/
X
X#include	<curses.h>
X#include	"GetInput.h"
X
X
Xdoinsert (win, row, col, colStart, colEnd, charKeyed, fldMask, fldCharType,
X	fldType, rowStart, fldAttrib, fldRange, fldLength, fldErrRow, origAttr)
X	WINDOW	*win;
X	int	row;
X	int	col;
X	int	colStart;
X	int	colEnd;
X	char	*charKeyed;
X	char	*fldMask;
X	char	fldCharType;
X	char	fldType;
X	int	rowStart;
X	int	fldAttrib;
X	char	*fldRange;
X	int	fldLength;
X	int	fldErrRow;
X	int	origAttr[];
X{
X	int	colSave;
X	char	fldStr[100];
X	char	*fldWrk;
X	int	junk;
X
X
X	colSave = col;		/* cursor location */
X
X	/* if we're sitting at end of field then no need to insert */
X	if (*(charKeyed+col-colStart) == 'N')
X		return (0);
X
X	/* do we have room to shift right on position ? */
X	col = colEnd;
X	while (col >= colStart)
X	{
X		if (*(charKeyed+col-colStart) == 'N')
X			break;				/* looks like we do */
X		if (*(charKeyed+col-colStart) == 'Y')
X		{
X			BELL;
X			return (-1);			/* no room */
X		}
X		col--;
X	}
X	if (col < colStart)
X	{
X		BELL;
X		return (-1);				/* all 'M' characters */
X	}
X
X	/* get field content & insert a space */
X	col = colStart;
X	fldWrk = fldStr;
X	while (col < colEnd)
X	{
X		if (col == colSave)
X			*fldWrk++ = ' ';	/* insert space */
X       		if (*(charKeyed+col-colStart) == 'Y')
X       			*fldWrk++ = mvwinch(win, row, col) & A_CHARTEXT ;
X	   	col++;
X	}
X	*fldWrk = '\0';
X
X	/* validate new field against the mask */
X	if (fldMask != NOMASK)
X	{
X		junk = 0;
X		/* fldWrk - fldWrk, col - charKeyed */
X		for (fldWrk = fldStr, col = colStart; 
X		     col < colEnd && *fldWrk != '\0'; col++)
X		{
X			/* only check shifted chars */
X			if (col <= colSave  || *(charKeyed+col-colStart) == 'M')
X			{
X				if (*(charKeyed+col-colStart) == 'Y')
X					fldWrk++;
X				continue;
X			}
X
X       			junk = checkmask (col, colStart, fldMask, fldCharType,
X					   fldType, *fldWrk);
X
X			if (junk == -1)
X				break;
X			*fldWrk++ = junk;
X			junk = 0;
X		} /* end for */
X		if (junk == -1)
X		{
X			CLEARROW (fldErrRow);
X			wattrOn (stdscr, A_REVERSE|A_BOLD);
X       			mvwaddstr(stdscr,
X		((fldErrRow%100) == fldErrRow) ? fldErrRow : fldErrRow/100, 
X		((fldErrRow%100) == fldErrRow) ? 0 : fldErrRow%100, 
X	    			"Unable to insert character due to edits.");
X			wattrOff (stdscr);
X			BELL;
X			col = colSave;
X			wmove (win, rowStart, colSave);
X			return (-2);
X		}
X	}
X
X	/* set last N in charKeyd to Y */
X	col = colEnd;
X	while (col >= colStart)
X	{
X		if (*(charKeyed+col-colStart) == 'N')
X			junk = col;
X		if (*(charKeyed+col-colStart) == 'Y')
X		{
X			*(charKeyed+junk-colStart) = 'Y';
X			break;
X		}
X		col--;
X	}
X
X
X       	ReDispFld(win, rowStart, colStart, fldAttrib, fldMask, fldRange, 
X			fldLength, fldCharType, fldType,
X			fldStr, colEnd, charKeyed, 0, origAttr);
X
X	col = colSave;
X	wmove (win, rowStart, colSave);
X	return (0);
X}
X/* Paul J. Condie  11/88 */
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/doinsert.c || echo "restore of utilities.d/libgeti.d/doinsert.c fails"
echo "x - extracting utilities.d/libgeti.d/drawbox.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/drawbox.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)drawbox.c	1.2   DeltaDate 2/1/90   ExtrDate 2/1/90";
X#endif
X
X#include	<curses.h>
X#include	<term.h>
X#include	<ctype.h>
X
X#define	DumbLine	1	/* A_NORMAL */
X#define	StandoutLine	2	/* A_STANDOUT */
X#define	SingleLine	3	/* A_ALTCHARSET */
X#define	MosaicLine	4	/* A_ALTCHARSET */
X#define	DiamondLine	5	/* A_ALTCHARSET */
X#define	DotLine		6	/* A_ALTCHARSET */
X#define	PlusLine	7	/* A_ALTCHARSET */
X
X#define	CANDRAWGRAPHICS	(enter_alt_charset_mode != NULL  && \
X			 strcmp(enter_alt_charset_mode, "") != 0)
X
Xextern	int	KeyHelp;
X
X
Xvoid drawbox (win, frow, fcol, trow, tcol, trythis, trythat, vscroll, help)
X	WINDOW	*win;
X	int	frow;			/* from row base 1 */
X	int	fcol;
X	int	trow;
X	int	tcol;
X	int	trythis;
X	int	trythat;
X	int	vscroll;
X	int	help;
X{
X	int	row;
X	int	col;
X	int	vchar;
X	int	hchar;
X	int	tlchar;				/* top left corner */
X	int	trchar;				/* top right corner */
X	int	brchar;				/* bottom right corner */
X	int	blchar;				/* bottom left corner */
X	int	attribute;
X	int	boxtype;
X
X
X
X	boxtype = trythis;
X	attribute = (boxtype == DumbLine || boxtype == StandoutLine) ? A_NORMAL : A_ALTCHARSET;
X	if (attribute == A_ALTCHARSET)
X		/* can this terminal do graphics ? */
X		boxtype = CANDRAWGRAPHICS ? trythis : trythat;
X
X	switch (boxtype)
X	{
X	   case DumbLine:
X		/* draw a dumb line */
X		vchar = '|';
X		hchar = '-';
X		tlchar = '+';
X		trchar = '+';
X		brchar = '+';
X		blchar = '+';
X		break;
X
X	   case StandoutLine:
X		/* draw a standout line */
X		attribute = A_STANDOUT;
X		vchar = ' ';
X		hchar = ' ';
X		tlchar = ' ';
X		trchar = ' ';
X		brchar = ' ';
X		blchar = ' ';
X		break;
X
X	   case SingleLine:
X		/* attempt to draw a graphic single line */
X		vchar = 'x';
X		hchar = 'q';
X		tlchar = 'l';
X		trchar = 'k';
X		brchar = 'j';
X		blchar = 'm';
X		break;
X
X	   case MosaicLine:
X		vchar = 'a';
X		hchar = 'a';
X		tlchar = 'a';
X		trchar = 'a';
X		brchar = 'a';
X		blchar = 'a';
X		break;
X
X	   case DiamondLine:
X		vchar = '`';
X		hchar = '`';
X		tlchar = '`';
X		trchar = '`';
X		brchar = '`';
X		blchar = '`';
X		break;
X
X	   case DotLine:
X		vchar = '~';
X		hchar = '~';
X		tlchar = '~';
X		trchar = '~';
X		brchar = '~';
X		blchar = '~';
X		break;
X
X	   case PlusLine:
X		vchar = 'n';
X		hchar = 'n';
X		tlchar = 'n';
X		trchar = 'n';
X		brchar = 'n';
X		blchar = 'n';
X		break;
X
X	   default:
X		return;
X	}
X
X#ifdef BSD
X	standout ();
X#else
X   	wattrset (win, attribute);
X#endif
X   	for (row = frow-1; row <= trow-1; row++)
X   	{
X      		if (row == frow-1  ||  row == trow-1)
X         		for (col = fcol-1; col <= tcol-1; col++)
X            			mvwaddch (win, row, col, hchar);
X      		else
X      		{
X         		mvwaddch (win, row, fcol-1, vchar);
X         		mvwaddch (win, row, tcol-1, vchar);
X      		}
X   	}
X	/* draw the corners */
X	mvwaddch (win, frow-1,fcol-1, tlchar);	/* top left */
X	mvwaddch (win, frow-1,tcol-1, trchar);	/* top right */
X	mvwaddch (win, trow-1,fcol-1, blchar);	/* bottom left */
X	mvwaddch (win, trow-1,tcol-1, brchar);	/* bottom right */
X
X	/* draw vertical scroll bars */
X	if (vscroll)
X	{
X		wattrset (win, A_REVERSE|A_BOLD);
X		mvwaddch (win, trow-7,tcol-1, '^');
X		mvwaddch (win, trow-6,tcol-1, 'v');
X	}
X	if (help)
X	{
X		wattrset (win, A_STANDOUT);
X		if (isprint(KeyHelp))
X			mvwprintw (win, trow-1,tcol-6, "Help %c", KeyHelp);
X		else
X			mvwprintw (win, trow-1,tcol-7, "Help %c", KeyHelp);
X	}
X
X#ifdef BSD
X   	standend ();
X#else
X   	wattrset (win, A_NORMAL);
X#endif
X}
X/* Paul J. Condie  10/88 */
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/drawbox.c || echo "restore of utilities.d/libgeti.d/drawbox.c fails"
echo "x - extracting utilities.d/libgeti.d/popmenu.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/popmenu.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "%W%   DeltaDate %G%   ExtrDate %H%";
X#endif
X
X#include	<curses.h>
X#include	<term.h>
X#include	<varargs.h>
X
X#define	MAXMENUS	10
X#define	MAXITEMS	100
X#define	NEWMENU		0
X#define	DIMWINDOW	-1
X#define	CREATEMENU	-2	/* only if it does not exist */
X#define WRAPAROUND	TRUE
X#define	DumbLine	1	/* A_NORMAL */
X#define	StandoutLine	2	/* A_STANDOUT */
X#define	SingleLine	3	/* A_ALTCHARSET */
X
X#ifndef	KEY_RETURN
X#   define KEY_RETURN	'\r'
X#endif
X#ifndef KEY_HELP
X#   define KEY_HELP	0553
X#endif
X#ifndef KEY_CANCEL
X#   define KEY_CANCEL	0543
X#endif
X#ifndef KEY_DOWN
X#   define KEY_DOWN	0402
X#endif
X#ifndef KEY_UP
X#   define KEY_UP	0403
X#endif
X#ifndef KEY_REFRESH
X#   define KEY_REFRESH	565
X#endif
X
Xextern	int	KeyDown;
Xextern	int	KeyUp;
Xextern	int	KeyHelp;
Xextern	int	KeyCancel;
Xextern	int	KeyRedraw;
Xextern	int	KeyReturn;
X
Xtypedef struct	_menu
X{
X	int	MenuId;			/* numerical menu identifier */
X	int	row;
X	int	col;
X	char	*title ;		/* menu title */
X	char	*helpfile;		/* helpfile */
X	int	winSize ;		/* pop up window length */
X	WINDOW	*win;
X	int	NumItems;		/* number of items in menu */
X	int	width;			/* largest item */
X	char	*items[MAXITEMS+1];
X	int	ActiveItem;		/* last item selected */
X} MENU;
X
X
Xstatic MENU	*THEmenu[MAXMENUS+1];
X
X
X/*VARARGS*/
Xpopmenu (va_alist)
X
X	va_dcl
X{
X	va_list		ap;
X	int		action;
X	int		MenuId;
X	static int	midx = -1;		/* defined menus */
X	char		*ws;			/* base address of table */
X	char		**wws;			/* base address of table */
X	int		wssize;			/* size of one element */
X						/*  or 0 if **wws is used */
X	register int	i, j;
X	int	rc;				/* return code */
X	int	idx;				/* tmp menu index */
X	int	NewMenu;			/* New Menu Flag */
X	static int	_runMenu();
X
X
X	va_start (ap);
X	action = va_arg (ap, int);
X
X	switch (action)
X	{
X	   /*
X	   **	Initialize a new popup menu
X	   */
X	   case NEWMENU:
X	   case CREATEMENU:
X		MenuId = va_arg (ap, int);
X
X		/* do we already have this MenuId */
X		NewMenu = TRUE;
X		for (i = 0; i <= midx; i++)
X			if (THEmenu[i]->MenuId == MenuId)
X			{
X				/* Menu already exists */
X				NewMenu = FALSE;
X				if (action == CREATEMENU)
X					break;	/* don't re-create it */
X
X				/* junk old menu */
X				delwin (THEmenu[i]->win);
X				free (THEmenu[i]);
X				idx = i;
X				break;
X			}
X		if (NewMenu == FALSE  && action == CREATEMENU)
X		{
X			va_end (ap);
X			break;
X		}
X		if (NewMenu == TRUE)
X			idx = ++midx;
X
X
X		/* build the new menu */
X		THEmenu[idx] = (MENU *)malloc (sizeof(MENU));
X		THEmenu[idx]->MenuId = MenuId;
X		THEmenu[idx]->row = va_arg (ap, int);	/* upper left corner */
X		THEmenu[idx]->col = va_arg (ap, int);
X		THEmenu[idx]->title = va_arg (ap, char *);
X		THEmenu[idx]->helpfile = va_arg (ap, char *);
X		if (THEmenu[idx]->helpfile != (char *)NULL  &&
X		    strcmp (THEmenu[idx]->helpfile, "") == 0)
X			THEmenu[idx]->helpfile = (char *)NULL;
X		THEmenu[idx]->winSize = va_arg (ap, int);
X		THEmenu[idx]->NumItems = -1;
X		THEmenu[idx]->width = strlen (THEmenu[idx]->title);
X		wssize = va_arg (ap, int);	/* size of one element */
X		/* for char array, ws is used, otherwise, wws is used for
X		** char *array.
X		*/
X		if ( wssize > 0 )
X		{
X			ws = va_arg (ap, char *);    /* base address of table */
X			while (*ws != NULL)
X			{
X				THEmenu[idx]->NumItems++;
X				THEmenu[idx]->items[THEmenu[idx]->NumItems] = ws ;
X				if (strlen(ws) > THEmenu[idx]->width)
X					THEmenu[idx]->width = strlen(ws);
X				ws += wssize ;
X			}
X		}
X		else		/* this is basically dup code as above */
X		{
X			wws = va_arg (ap, char **);  /* base address of table */
X			while (*wws != NULL)
X			{
X				THEmenu[idx]->NumItems++;
X				THEmenu[idx]->items[THEmenu[idx]->NumItems] = *wws ;
X				if (strlen(*wws) > THEmenu[idx]->width)
X					THEmenu[idx]->width = strlen(*wws);
X				wws++ ;
X			}
X		}
X		/*
X		 * adjust length of popmenu
X		 */
X		if (THEmenu[idx]->winSize <= 0)		/* default length */
X			THEmenu[idx]->winSize = 6;
X		/* not enough items? */
X		if (THEmenu[idx]->winSize > THEmenu[idx]->NumItems+1 ) 
X			THEmenu[idx]->winSize = THEmenu[idx]->NumItems + 1 ;
X		/* roll off bottom of screen? */
X		if ( THEmenu[idx]->winSize > LINES-THEmenu[idx]->row-2 ) 
X			THEmenu[idx]->winSize = LINES - THEmenu[idx]->row - 2 ;
X
X		/*
X		 * adjust the starting col of popmenu if the menu
X		 * will roll off the right edge of screen
X		 *      NOTE: col is 0 offset while width is not
X		 */
X		if ( THEmenu[idx]->col > COLS-THEmenu[idx]->width-4 )
X			THEmenu[idx]->col = COLS - THEmenu[idx]->width - 4 ;
X
X		va_end (ap);
X		THEmenu[idx]->ActiveItem = 1;
X
X		THEmenu[idx]->win = newwin (THEmenu[idx]->winSize+2, 
X				THEmenu[idx]->width+4,
X			        THEmenu[idx]->row, THEmenu[idx]->col);
X
X		keypad (THEmenu[idx]->win, TRUE);
X		rc = 0;			/* 0 return code */
X		break;
X
X	   case DIMWINDOW:
X		MenuId = va_arg (ap, int);
X		va_end (ap);
X
X		for (i = 0; i <= midx; i++)
X			if (THEmenu[i]->MenuId == MenuId)
X			{
X				drawbox( THEmenu[i]->win, 1, 1,
X					 THEmenu[i]->winSize+2,
X					 THEmenu[i]->width+4,
X					SingleLine, DumbLine,
X					(THEmenu[i]->winSize >= 4  &&
X					    THEmenu[i]->NumItems+1 >
X						THEmenu[i]->winSize),
X					(THEmenu[i]->helpfile !=
X						(char *)NULL) ) ;
X				mvwprintw (THEmenu[i]->win, 0, 
X					((THEmenu[i]->width+4-
X						strlen(THEmenu[i]->title))/2),
X				    	"%s", THEmenu[i]->title);
X				wrefresh (THEmenu[i]->win);
X				break;
X			}
X		break;
X
X	   default:
X		/*
X		**  Lets try to run a menu
X		*/
X		va_end (ap);
X		MenuId = action;
X
X		/* Find the menu. */
X		for (i = 0; i <= midx; i++)
X			if (MenuId == THEmenu[i]->MenuId)
X				break;
X		if (i > midx)   return (-1);		/* invalid MenuId */
X		rc = _runMenu (THEmenu[i]);
X		break;
X	} /* end switch (action) */
X	return (rc);
X}
X
X
X
X_runMenu (menu)
X
X	MENU	*menu;
X{
X	register int	ch;
X	register int	fptr;			/* field pointer */
X	register int	i;
X	register int	top;
X	register int	inc;
X
X	putp ( cursor_invisible ) ;
X	inc = (int)( menu->winSize / 2 ) ;	/* window increment */
X	fptr = menu->ActiveItem;		/* set current item */
X	top = fptr - menu->winSize + 1 ;	/* set top item of window */
X	if ( top < 1 ) top = 1 ;		/* out of bound? */
X
X	/*
X	**	Display the menu.
X	*/
X	for (i=0; i < menu->winSize && top+i-1 < menu->NumItems+1; i++)
X		mvwprintw (menu->win, i+1, 2, "%s", menu->items[top+i-1]);
X	drawbox( menu->win, 1, 1, menu->winSize+2, menu->width+4,
X			StandoutLine, StandoutLine,
X			(menu->winSize >= 4  &&
X				menu->NumItems+1 > menu->winSize),
X			(menu->helpfile != (char *)NULL) ) ;
X
X	/* display title */
X	wattrset (menu->win, A_STANDOUT);
X	mvwprintw (menu->win, 0, ((menu->width+4)/2)-(strlen(menu->title)/2), 
X		"%s", menu->title);
X	wattrset (menu->win, A_NORMAL);
X
X	while (1)
X	{
X		wattrset (menu->win, A_REVERSE);
X		mvwprintw (menu->win, fptr-top+1, 2, "%s", menu->items[fptr-1]);
X		wattrset (menu->win, A_NORMAL);
X		wmove( menu->win, menu->winSize+1, menu->width+3 ) ;
X		touchwin (menu->win);
X		wrefresh (menu->win);
X
X		ch = wgetch (menu->win);
X		mvwprintw (menu->win, fptr-top+1, 2, "%s", menu->items[fptr-1]);
X
X		if (ch == KeyReturn)   	ch = KEY_RETURN;
X		if (ch == KeyDown)   	ch = KEY_DOWN;
X		if (ch == KeyUp)   	ch = KEY_UP;
X		if (ch == KeyHelp)   	ch = KEY_HELP;
X		if (ch == KeyCancel)	ch = KEY_CANCEL;
X		if (ch == KeyRedraw)	ch = KEY_REFRESH;
X
X		if ( ch >= 'a' && ch <= 'z' )
X			ch = toupper( ch ) ;	/* deals in upper case only */
SHAR_EOF
echo "End of part 9"
echo "File utilities.d/libgeti.d/popmenu.c is continued in part 10"
echo "10" > s2_seq_.tmp
exit 0



More information about the Alt.sources mailing list