menu(1) part 10 of 14

Paul J. Condie pjc at pcbox.UUCP
Thu Dec 27 07:13:13 AEST 1990


#!/bin/sh
# this is part 10 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file utilities.d/libgeti.d/RingMenu.c continued
#
CurArch=10
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/RingMenu.c"
sed 's/^X//' << 'SHAR_EOF' >> utilities.d/libgeti.d/RingMenu.c
X	menu[0].page = 1 ;
X	/*
X	 * beyond the 1st option
X	 */
X	for ( i=1; i<Noptions ; i++ )
X	{
X		menu[i].page = menu[i-1].page ;
X		menu[i].column = menu[i-1].column
X				+ strlen( opt_table[i-1][0] ) + 2 ;
X		/*
X		 * about to roll off the right edge?
X		 */
X		if ( menu[i].column+strlen( opt_table[i][0] ) > COLS ||
X		     ( i < Noptions-1 &&
X		       menu[i].column+strlen( opt_table[i][0] )+5 > COLS ) )
X		{
X			menu[i].page++ ;	/* bump a page */
X			if ( title != NULL )	/* and wrap around */
X				menu[i].column = strlen( title ) + 7 ;
X			else
X				menu[i].column = 5 ;
X		}
X	}
X
X	i = ( opt<=Noptions && opt>0 ) ? opt-1 : 0 ;	/* set highlight */
X
X	/*
X	 * The LOOP
X	 */
X	while ( TRUE )
X	{
X		_showring( win, line, title, i, opt_table ) ;
X		ch = wgetch( win ) ;		/* get input */
X
X		if ( ch == KeyBackspace )	ch = KEY_BACKSPACE ;
X		if ( ch == KeyHelp )		ch = KEY_HELP ;
X		if ( ch == KeyRedraw )		ch = KEY_REFRESH ;
X		if ( ch == KeyPrint )		ch = KEY_PRINT ;
X
X		switch (ch)
X		{
X	 	case KEY_UP:
X		case KEY_LEFT:
X		case KEY_CTLK:
X		case KEY_CTLH:
X	 	case KEY_BACKSPACE:
X	 	case KEY_BTAB:
X			if ( --i < 0 )
X				i = Noptions - 1 ;
X			break ;
X
X	 	case KEY_DOWN:
X		case KEY_RIGHT:
X		case KEY_CTLJ:
X		case KEY_CTLL:
X	 	case ' ':
X	 	case KEY_TAB:
X			if ( ++i >= Noptions )
X				i = 0 ;
X		        break ;
X
X		case KEY_RETURN:
X		case KEY_ENTER:
X			_wclrring( win, line ) ;
X			putp( cursor_visible ) ;
X			return( i+1 ) ;
X			break ;
X
X		case KEY_HELP:
X			/*
X			ShowHelp( GENERAL, SPECIALKEYS, MSGLINE ) ;
X			*/
X			break ;
X
X		case KEY_REFRESH:
X			clearok( win, TRUE ) ;
X			break ;
X			
X		case KEY_PRINT:
X            		ScrnPrnt(win, LINES, COLS, MSGLINE) ;
X            		clearok(win, TRUE ) ;
X			break ;
X			
X		default:
X			for ( ii=0; ii<=Noptions-1; ii++ )
X			{
X				/* upper char match */
X				if ( strchr( opt_table[ii][0], toupper(ch) ) != NULL )
X				{
X					_wclrring( win, line ) ;
X					putp( cursor_visible ) ;
X		        		return ( ii+1 );
X				}
X			}
X			flash() ;
X		        break;
X		}
X	}
X}
X
X/*
X * _wclrring:  Erase the ring menu from screen
X */
X_wclrring( win, line )
X	WINDOW	*win ;
X	short	line ;
X{
X	wmove( win, line, 0 ) ; wclrtoeol( win ) ;
X	wmove( win, line+1, 0 ) ; wclrtoeol( win ) ;
X}
X
X/*
X * _showring: Display one lineful of RingMenu depending on the page
X *	      current option is on.
X */
X_showring( win, line, title, opt, opt_table )
X	WINDOW	*win ;
X	short 	line, opt ;
X	char	*title, *opt_table[][2] ;
X{
X	register short	i ;
X
X	wmove( win, line, 0 ) ;			/* go there */
X	if ( title != NULL )			/* title? */
X		wprintw( win, "%s  ", title ) ;
X	if ( menu[opt].page != 1 )		/* not 1st page? */
X		waddstr( win, "...  " ) ;
X		
X	/*
X	 * show options
X	 */
X	for ( i=0; i<Noptions && menu[i].page<=menu[opt].page; i++ )
X		if ( menu[i].page == menu[opt].page )	/* same page? */
X		{
X			if ( i == opt )		/* need highlight? */
X				wattrset( win, A_REVERSE );
X			waddstr( win, opt_table[i][0] );
X			wattrset( win, A_NORMAL ) ;
X			waddstr( win, "  " ) ;
X		}
X
X	if ( menu[opt].page < menu[Noptions-1].page )	/* not last page? */
X		waddstr( win, "..." ) ;
X	wclrtoeol( win ) ;
X
X	/*
X	 * show description
X	 */
X	wmove( win, line+1, 0 ) ;
X	wclrtoeol( win ) ;
X	mvwprintw( win, line+1,menu[0].column, "%s", opt_table[opt][1] ) ;
X
X	/*
X	 * fix cursor
X	 */
X	if ( menu[0].column >= 2 )
X		wmove(win, line, menu[0].column-2 );	/* before 1st option */
X	else
X		/* behind the last option */
X		wmove(win, line, menu[i-1].column+strlen(opt_table[i-1][0])+2 ) ;
X
X	wrefresh( win );
X}
SHAR_EOF
echo "File utilities.d/libgeti.d/RingMenu.c is complete"
chmod 0444 utilities.d/libgeti.d/RingMenu.c || echo "restore of utilities.d/libgeti.d/RingMenu.c fails"
echo "x - extracting utilities.d/libgeti.d/ScrnOut.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ScrnOut.c &&
Xstatic char Sccsid[] = "@(#)ScrnOut.c	1.2   DeltaDate 1/22/90   ExtrDate 1/22/90";
X
X#include	<curses.h>
X#include	"GetInput.h"
X
XScrnOut(win, y, x, fpout)
X	WINDOW	*win ;
X	int	y, x ;
X	FILE	*fpout ;
X{
X	int	xx, yy ;
X
X	for(yy = 0 ; yy < y ; yy++) {
X		for(xx = 0 ; xx < x ; xx++)
X			fputc( mvwinch( win, yy, xx ) & A_CHARTEXT, fpout) ;
X		fputc( '\n', fpout ) ;
X	}
X
X	return( 0 ) ;
X}
X
X
X
XScrnPrnt(win, y, x, msgLine)
X	WINDOW	*win ;
X	int	y, x ;
X	int	msgLine ;
X{
X	FILE	*fp ;
X
X	BELL;
X	mvaddstr(msgLine, 0, "Printing Screen ") ;
X	wattrOn(stdscr, A_BLINK) ;
X	addstr("...") ;
X	wattrOff(stdscr) ;
X	refresh() ;
X	BELL;
X
X	if( (fp = popen("lp -s", "w")) == NULL )
X		return(1) ;
X
X	ScrnOut(win, y, x, fp) ;
X
X	pclose(fp) ;
X
X	move(msgLine, 0) ;
X	clrtoeol() ;
X	refresh() ;
X
X	return(0) ;
X}
X
X
X
XScrnFile(win, y, x)
X	WINDOW	*win ;
X	int	y, x ;
X{
X	WINDOW	*twin ;
X	FILE	*fp ;
X	char	cmdstr[17] ;
X	union 	FldUnion Fld ;
X
X	twin = newwin(LINES, COLS, 0, 0) ;
X	mvwaddstr(twin, 10, 0, "File Name: ") ;
X	BELL;
X	cmdstr[0] = '\0' ;
X	Fld.strVal = cmdstr ;
X	GetInput (twin, 10, 11, &Fld, A_REVERSE, NOMASK, NORANGE, 16, 0, 
X		ALPHANUM, NOFILL, CHAR, AUTONEXT, NOMUST, LINES-1, LINES-1, 
X		"Enter the name of the file that will contain the image of the screen.", 
X		NULL, NULL) ;
X
X	if(cmdstr[0] == '\0')
X		return(1) ;
X
X	if( (fp = fopen(cmdstr, "w")) == NULL )
X		return(1) ;
X
X	ScrnOut(win, y, x, fp) ;
X
X	fclose(fp) ;
X
X	delwin(twin) ;
X
X	return(0) ;
X}
SHAR_EOF
chmod 0444 utilities.d/libgeti.d/ScrnOut.c || echo "restore of utilities.d/libgeti.d/ScrnOut.c fails"
echo "x - extracting utilities.d/libgeti.d/ShowChar.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/ShowChar.c &&
X#ifndef LINT
Xstatic char Sccsid[] = "@(#)ShowChar.c	1.3   DeltaDate 1/22/90   ExtrDate 1/22/90";
X#endif
X
X/*
X**  ShowChar()
X**	Validate character against the mask and convert to upper is neccessary.
X**	Display char to screen.
X*/
X
X#include 	<curses.h>
X#include 	<ctype.h>
X#include 	"GetInput.h"
X
Xextern int	insertmode;
X
XShowChar (win, rowStart, colStart, fldAttrib, fldMask, fldRange, fldLength, 
X	fldCharType, fldDispRow, fldType, keyStream, fldErrRow, charKeyed, 
X	colEnd, ch, origAttr)
X
X	WINDOW      	*win ;      	/* Window                */
X	int   		rowStart ;
X	int   		colStart ;
X	int   		fldAttrib ; 	/* Curses attribute         */
X	char  		*fldMask ;  	/* mask for character string      */
X	char  		*fldRange ; 	/* allowable range for field      */
X	unsigned	fldLength ; 	/* Maximum length of output       */
X	char  		fldCharType;	/* type of character           */
X	int   		fldDispRow ;   	/* where to display help message    */
X	char  		fldType ;   	/* type of field         */
X	int   		keyStream ; 	/* if TRUE then the function will
X                  			exit when the last character is
X                  			keyed           */
X	int   		fldErrRow ; 	/* where to display error message   */
X	char  		*charKeyed ;   	/* characters keyed array      */
X	int   		colEnd ; 	/* column start of field */
X	int   		*ch ;     	/* contains character keyed or being
X                  			moved */
X	int   		origAttr[] ;   	/* original attributes for field */
X{
X	int		row ;       /* working row field */
X   	int   		col ;       /* working column field */
X   	char  		charType ;
X   	char  		cmdstr[16] ;
X	int		junk;
X
X
X   	getyx(win, row, col) ;
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		{
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         		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 ALPHANUM:
X   	   case UPPER_AN:
X   	   case STATE:
X      		if (isprint(*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         		if (charType == UPPER_AN  ||  charType == STATE)
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/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
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")) == (FILE *)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 == (FILE *)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), 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-1,wcols-1);
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, (char *)NULL);
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/* MENU */
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 13, 0, &Fld, A_REVERSE, NOMASK, 
X	"one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,13,14,15,16,17,18,19,20,21,22,23", 6, 0, MENU,
X	NOFILL, CHAR, NOAUTO, NOMUST, 20, 21, "Menu Field", 
X	"testfile", "FIELD 2") ;
X
X   mvprintw (4, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
X
X/* SET */
X/*
X   cmdstr[0] = '\0' ;
X   Fld.strVal = cmdstr ;
X   retCode = GetInput (stdscr, 4, 0, &Fld, A_REVERSE, NOMASK, 
X	"one,two,three,four,five,six,seven,sevab", 6, 0, SET,
X	NOFILL, CHAR, NOAUTO, NOMUST, 20, 21, "Set Field", 
X	"testfile", "FIELD 2") ;
X
X   mvprintw (4, 40, "return code = :%d: value = :%s:", retCode, cmdstr);
X   refresh ();
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", 
X	"sun,wed,no_holidays,gt_today", 6, 6, DATE,
X	NOFILL, CHAR, NOAUTO, 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/* CHAR */
X   cmdstr[0]='\0';
X   Fld.strVal = cmdstr;
X   retCode = GetInput (stdscr, 2, 1, &Fld, A_REVERSE, NOMASK, NORANGE,
X       5, 0, ALPHANUM, NOFILL, 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/* 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
X#ifndef LINT
Xstatic char Sccsid[] = "%W%    DeltaDate %G%    ExtrDate %H%";
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, percent)
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	float	percent;		/* percent into list for vscroll
X					   indicator */
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	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 = '+';
SHAR_EOF
echo "End of part 10"
echo "File utilities.d/libgeti.d/drawbox.c is continued in part 11"
echo "11" > s2_seq_.tmp
exit 0



More information about the Alt.sources mailing list