Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbatt!cbosgd!ucbvax!sdcsvax!noscvax!sloane From: sloane@noscvax.UUCP (Gary K. Sloane) Newsgroups: net.sources Subject: DISPLIB Reposting part 5 of 6 Message-ID: <605@noscvax.UUCP> Date: Fri, 8-Aug-86 20:23:49 EDT Article-I.D.: noscvax.605 Posted: Fri Aug 8 20:23:49 1986 Date-Received: Sun, 10-Aug-86 05:24:29 EDT Organization: Computer Sciences Corporation, San Diego Lines: 457 #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # part3 # This archive created: Fri Aug 8 17:14:03 1986 # By: Gary K. Sloane (Computer Sciences Corporation, San Diego) export PATH; PATH=/bin:/usr/bin:$PATH if test -f 'part3' then echo shar: "will not over-write existing file 'part3'" else cat << \SHAR_EOF > 'part3' /**************************/ /* Enter or Edit a String */ /**************************/ /*VARARGS4*/ edits(string, len, flag, pgm, a1, a2, a3, a4, a5) char *pgm, *string; int flag, len; { register int cnt; int initline, initcol, dline, dcol, i; int mode = FREAD; char *sptr, c; /* save cursor positions and string for ctrl-u */ initline = termctrl.curline; initcol = termctrl.curcol; /* highlight the ':' if requested */ if(flag == COLON) { gotoxy(initcol-2, initline); inverse(); printf(":"); normal(); } /* highlight the entire field if requested */ if(flag == INVERSE) { inverse(); printf("%s", string); for(i=strlen(string); i= len) || (c == ':')) bell(); else { *sptr++ = c; putchar(c); ++termctrl.curcol; ++cnt; } break; } } } /*******************************************/ /* Enter or Edit a Date in mm/dd/yy Format */ /*******************************************/ /*VARARGS7*/ editdate(edate, flag, empty, oldate, date, pgm, a1, a2, a3, a4, a5) char *edate, *date, *pgm; int flag, empty, oldate; { int cnt, cd, chcnt=0, scnt=0, erflg=0; char *sptr, c; int initline, initcol, dline, dcol, i, j; int mode = FREAD; /* save cursor positions and string for ctrl-u */ initline = termctrl.curline; initcol = termctrl.curcol; /* highlight the ':' if requested */ if(flag == COLON) { gotoxy(initcol-2, initline); inverse(); printf(":"); normal(); } /* highlight the entire field if requested */ if(flag == INVERSE) { inverse(); printf("%s", edate); for(j=strlen(edate); j<8; j++) putchar(' '); } /* set up for enter or edit */ cnt = strlen(edate); for(sptr = edate; *sptr != '\0'; sptr++) if(*sptr == '/') scnt++; cnt = strlen(edate); sptr = edate + cnt; chcnt = cntdate(edate, sptr); gotoxy(initcol+cnt,initline); /* flush the type ahead buffer */ if(ioctl(0, (int)TIOCFLUSH, (char *)&mode) != 0) { printf("*** ERROR: Bad call to ioctl in editdate()... ***"); exit(0); } /* go into raw mode */ ttyset("raw"); /* accept characters and process them */ for(;;) { c=getc(stdin); if(erflg) { erflg = 0; clmsg(); } switch(c) { /* Delete entered - abort the program? */ case '\177': dline = termctrl.curline; dcol = termctrl.curcol; bell(); gotoxy(25,21); inverse(); printf(" Restart(y/n)? "); gotoxy(40,21); c = getc(stdin); putchar(c); normal(); if(c != 'y') { gotoxy(25,21); printf("------------------"); gotoxy(dcol, dline); if(flag == INVERSE) inverse(); break; } /* go into cbreak mode and restart the program */ ttyset("cbreak"); if(*pgm != '\0') reload(pgm, a1, a2, a3, a4, a5); termreset(); exit(0); /* ctrl-u entered */ case '\025': gotoxy(initcol,initline); for(i=0; i 2) { msg("Format to enter a date is MM/DD/YY...", BEEP,0); erflg++; break; } else ++scnt; chcnt = -1; } /* If it's not a '/', is the month, day, or year too long? */ else { if(chcnt > 1) { msg("Format to enter a date is MM/DD/YY...", BEEP,0); erflg++; break; } } /* everything's ok, put it on the date and bump the ctrs */ ++chcnt; *sptr++ = c; putchar(c); ++termctrl.curcol; ++cnt; break; } } } SHAR_EOF fi exit 0 # End of shell archive