sherouse@unc.UUCP (George W. Sherouse) (01/15/85)
Here is the termcap(3x) version of my datum entry routines. The library also contains a minimum working set of screen and cursor control functions. It is a viable alternative to curses(3x) for simple applications. You are welcome to use this as long as you remember these simple rules: 1) Give credit where credit is due. 2) Don't make any money with it without clearing it with me first. 3) Let me know if you think it's wonderful. 4) Let me know if you fix a bug or add a feature. Good luck, George W. Sherouse Associate Physicist Radiation Oncology North Carolina Memorial Hospital Chapel Hill, NC 27514 (919) 966-1101 <decvax!mcnc!unc!godot!sherouse> ======================================= # This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. -----cut here-----cut here-----cut here-----cut here----- #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # makefile # term.l # term.h # ClearEOL.c # GetBool.c # GetFloat.c # GetHospNum.c # GetInt.c # GetString.c # InitTerm.c # MenuPick.c # PickOne.c # StandOut.c # TermRewind.c # TermSetUp.c # center.c # examp.c # gotoxy.c # page.c # underline.c # This archive created: Tue Jan 15 08:44:27 1985 echo shar: extracting makefile '(1154 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > makefile XXINCDIR = /usr/include XXMANDIR = /usr/man/manl XXLIBDIR = /usr/local/lib XX XXCFLAGS = -O XX XXOBJS = ClearEOL.o GetBool.o GetFloat.o GetHospNum.o GetInt.o GetString.o\ XX InitTerm.o MenuPick.o PickOne.o StandOut.o TermRewind.o TermSetUp.o\ XX center.o gotoxy.o page.o underline.o XX XXlibterm.a: $(OBJS) makefile XX ar rvu libterm.a $(OBJS) XX ranlib libterm.a XX XXClearEOL.o: ClearEOL.c makefile XXGetBool.o: GetBool.c makefile XXGetFloat.o: GetFloat.c makefile XXGetHospNum.o: GetHospNum.c makefile XXGetInt.o: GetInt.c makefile XXGetString.o: GetString.c makefile XXInitTerm.o: InitTerm.c makefile XXMenuPick.o: MenuPick.c makefile XXPickOne.o: PickOne.c makefile XXStandOut.o: StandOut.c makefile XXTermRewind.o: TermRewind.c makefile XXTermSetUp.o: TermSetUp.c makefile XXcenter.o: center.c makefile XXgotoxy.o: gotoxy.c makefile XXpage.o: page.c makefile XXunderline.o: underline.c makefile XX XXexamp: examp.c $(INCDIR)/term.h $(LIBDIR)/libterm.a makefile XX cc $(CFLAGS) -o examp examp.c -lterm -ltermcap XX XXinstall: libterm.a XX mv libterm.a $(LIBDIR) XX ranlib $(LIBDIR)/libterm.a XX cp term.h $(INCDIR) XX XXinstall_man: term.l XX cp term.l $(MANDIR) XX chmod 444 $(MANDIR)/term.l XX XXclean: XX rm -f *.o a.out core libterm.a SHAR_AND_ENJOY if test 1154 -ne "`wc -c makefile`" then echo shar: error transmitting makefile '(should have been 1154 characters)' fi echo shar: extracting term.l '(5472 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > term.l XX.TH TERM L "Radiation Oncology, NCMH" XX.UC 4 XX.SH NAME XXterm \- "crash-proof" datum entry routines using termcap(3x) XX.SH SYNOPSIS XX#include <term.h> XX.sp XX.B cc XX[ flags ] files XX.B \-lterm \-ltermcap XX[ libraries ] XX.SH DESCRIPTION XXThese routines look after datum entry for the basic datum XXtypes and provide some cursor control. XXA call to XX.I InitTerm XXinitializes the XX.I term XXpackage by XXgetting the terminal type from environment variable TERM XXand by reading the appropriate XX.I termcap XXentry. XXIn typical use, the calling program would paint a screen XXand place the cursor at the beginning of a datum field XXusing XX.I page, gotoxy, XXand XX.I printf XXand would then call the appropriate XX.I term XXroutine to enter or edit that datum. XXThe field is highlighted using underline mode and the default value, if any, XXis displayed. XXThe user may then enter a new value of the datum under strict field size XXenforcement or accept the default. XXAcceptance of the displayed value is indicated by a RETURN. XXThe default value can be retrieved by ^X. XXNo abort is possible. XXWhen the value is accepted, the field is rewritten in normal mode and with the XXnew value of the datum, and the cursor is left at the end of the field. XX XXExceptions to the above are XX.I GetBool XXfor which valid inputs are n, N, y, Y, SPACE, and RETURN, for XXno, yes, toggle, and accept respectively, XX.I PickOne XXwhich understands ^ for previous value, SPACE for next value, and RETURN XXfor accept, XXand XX.I MenuPick XXwhich understands ^ for previous value, SPACE for next value, XX> for next page, and RETURN XXfor accept. XX XXMagic cookies are dealt with XXproperly but with the result that the XXfield on the screen is wider XXthan the requested datum field XX.I "during entry". XXThe requested field size is used when the field is rewritten XXin normal mode after acceptance XXof a datum value. XXThis is a feature of XX.I term XXand a bug in the terminals with magic cookies. XX.I Curses(3x) XXdeals with this problem by just not allowing standout mode. XXWhich would you rather buy? XX.SH SEE ALSO XXtermcap(3x) XX.br XXc_term(l), if you have it XX.SH AUTHOR XX.nf XXGeorge W. Sherouse XXRadiation Oncology XXNorth Carolina Memorial Hospital XXUniversity of North Carolina, Chapel Hill XX.SH FUNCTIONS XXInitialize term. XXReturns 0 if successful, -1 if getenv fails, -2 if tgetent cannot XXopen termcap file, -3 if tgetent cannot find entry for terminal. XXIf the return is not zero, do not pass GO. XX.br XX int InitTerm(); XX XXGet a floating point number. Imagine %(field_width).(places)f XXin a printf. XX.br XX float GetFloat(default, field_width, places); XX.br XX float default; XX.br XX int field_width; XX.br XX int places; XX XXGet an integer. XX.br XX int GetInt(default, field_width); XX.br XX int default; XX.br XX int field_width; XX XXGet a boolean. XX.br XX int GetBool(default); XX.br XX int default; XX XXGet a string. String should be at least field_size + 1 long XXto accomodate the appended null. Null_ok is a boolean which XXdeclares whether or not a string of length zero is acceptable. XX.br XX void GetString(string, field_size, null_ok); XX.br XX char *string; XX.br XX int field_size; XX.br XX int null_ok; XX XXGet a hospital number in the format 00-00-00. XX.br XX void GetHospNum(hosp_num); XX.br XX char *hosp_num XX XXPick one string from a list of strings by displaying one choice at a time in XXthe field. XX.br XX int PickOne(list, choice_count); XX.br XX char **list; XX.br XX int choice_count; XX XXA full-screen version of PickOne. The page is cleared, the prompt is displayed XXat the top of the page and the first <some number> choices are displayed. XXThe user may step through the choices with ^ and SPACE. XXIf there are more than <some number> choices, the user may also change pages XXwith >. XXRETURN accepts currently highlighted value. XX.br XX int MenuPick(prompt, list, choice_count); XX.br XX char *prompt; XX.br XX char **list; XX.br XX int choice_count; XX XXClear the screen. XX.br XX void page(); XX XXMove cursor. Coordinates are 1-indexed from upper left. XX.br XX void gotoxy(col, line); XX.br XX int col; XX.br XX int line; XX XXClear to end of line. XX.br XX void ClearEOL(); XX XXPrint string centered on line. Mode == 0 requests normal print, == 1 requests XXunderline, and == 2 requests standout. XX.br XX void center(line, string, mode); XX.br XX int line; XX.br XX char *string; XX.br XX int mode; XX XXSet or clear standout mode. Not very useful at the applications level. XX.br XX void StandOut(on_or_off); XX.br XX int on_or_off; XX XXSet or clear underline mode. Not very useful at the applications level. XX.br XX void underline(on_or_off); XX.br XX int on_or_off; XX XXIssue some backspaces. Not very interesting at the applications level. XX.br XX void TermRewind(count); XX.br XX int count; XX XXPlace stdin into raw mode with no echo on odd calls and restore original modes XXon even calls. XXReturn the terminal's erase character. XXNot intended for use at the applications level. XX.br XX char TermSetUp(); XX.SH BUGS XXMany sorts of stupidity are not checked for. XXThese include but are not limited to string longer than terminal width in XX.I center, XXline or col out of bounds in XX.I center XXor XX.I gotoxy, XXfractional part longer than field_size in XX.I GetFloat, XXand 0 or negative field_size anywhere. XX XXSome unreasonable assumptions are made regarding sanity in the termcap. XXYou will know what they are if you violate them. XXI apologize in advance. XX XX.I GetFloat XXdoes not support scientific notation. XXIt also does not let you back up over the decimal point once it has placed XXit. XXThis is no great hardship since you can always ^X to restart. XX XXSome of the code is a little ugly, having been hacked unmercifully through many XXrevisions. XXIt does seem to work, though. SHAR_AND_ENJOY if test 5472 -ne "`wc -c term.l`" then echo shar: error transmitting term.l '(should have been 5472 characters)' fi echo shar: extracting term.h '(263 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > term.h XXvoid ClearEOL(); XXint GetBool(); XXfloat GetFloat(); XXvoid GetHospNum(); XXint GetInt(); XXvoid GetString(); XXint InitTerm(); XXint MenuPick(); XXint PickOne(); XXvoid StandOut(); XXvoid TermRewind(); XXchar TermSetUp(); XXvoid center(); XXvoid gotoxy(); XXvoid page(); XXvoid underline(); SHAR_AND_ENJOY if test 263 -ne "`wc -c term.h`" then echo shar: error transmitting term.h '(should have been 263 characters)' fi echo shar: extracting ClearEOL.c '(832 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > ClearEOL.c XX XXvoid ClearEOL() XX XX/* XX --------------------------------------------------------------------------- XX XX Last revision - XX 30 March 1984 - GWS XX XX XX NAME XX ClearEOL - clear to the end of line XX XX SYNOPSIS XX void ClearEOL() XX XX DESCRIPTION XX Uses termcap(3x) routines to clear terminal screen. XX XX SEE ALSO XX termcap(3) XX XX DIAGNOSTICS XX If the screen doesn't clear, it didn't work. XX XX AUTHOR XX George W. Sherouse XX 30 March 1984 XX XX --------------------------------------------------------------------------- XX*/ XX XX{ XX static called = 0; XX static char id[] = "ce", page_str[10]; XX static char *point = page_str, **point2 = &point; XX extern char bp[1024]; XX int tgetent(), tputs(); XX int putchar(); XX XX if (!called) XX { XX tgetstr(id, point2); XX called++; XX } XX XX (void) tputs(page_str, 1, putchar); XX return; XX} SHAR_AND_ENJOY if test 832 -ne "`wc -c ClearEOL.c`" then echo shar: error transmitting ClearEOL.c '(should have been 832 characters)' fi echo shar: extracting GetBool.c '(1495 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > GetBool.c XX#include <stdio.h> XX#include <ctype.h> XX XXint GetBool(Default) XXint Default; XX XX/* XX --------------------------------------------------------------------------- XX XX Last revision - XX 16 November 1984 - GWS XX Ignore XON, XOFF XX XX 11 April 1984 - GWS XX XX XX NAME XX GetBool - "crash-proof" routine for terminal input of boolean XX XX SYNOPSIS XX int GetHospNum(Default) XX int Default; XX XX DESCRIPTION XX This routine prompts and nudges the user through entry of a XX boolean value. XX XX SEE ALSO XX XX XX DIAGNOSTICS XX none XX XX BUGS XX none known XX XX AUTHOR XX George W. Sherouse XX 11 April 1984 XX XX --------------------------------------------------------------------------- XX*/ XX XX{ XX int c; XX char erase; XX int val; XX int cookie; XX XX void underline(); XX int tgetnum(); XX char TermSetUp(); XX void TermRewind(); XX XX if ((cookie = tgetnum("ug")) < 0) XX cookie = 0; XX XX underline(1); XX printf(" "); XX XX if (cookie) XX { XX underline(0); XX TermRewind(cookie); XX } XX XX erase = TermSetUp(); /* set no echo, single char input */ XX /* get erase character */ XX val = Default; XX while (1) XX { XX if (val) XX printf("\b\b\byes"); XX else XX printf("\b\b\bno "); XX XX switch (c = (getchar() & 0177)) XX { XX case '\015': XX underline(0); XX TermSetUp(); XX return(val); XX case ' ': XX val = !val; XX break; XX case 'y': XX case 'Y': XX val = 1; XX break; XX case 'n': XX case 'N': XX val = 0; XX break; XX case '\021': XX case '\023': XX break; XX default: XX printf("%c", '\007'); XX } XX } XX} SHAR_AND_ENJOY if test 1495 -ne "`wc -c GetBool.c`" then echo shar: error transmitting GetBool.c '(should have been 1495 characters)' fi echo shar: extracting GetFloat.c '(4407 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > GetFloat.c XX#include <stdio.h> XX#include <ctype.h> XX XXfloat GetFloat(Default, field_width, places) XXfloat Default; XXint field_width, places; XX XX/* XX --------------------------------------------------------------------------- XX XX Last revision - XX 16 November 1984 - GWS XX Ignore XON, XOFF XX XX 11 April 1984 - GWS XX XX XX NAME XX GetFloat - "crash-proof" float from keyboard routine XX XX SYNOPSIS XX float GetFloat(Default, field_width, places) XX float Default; XX int field_width, places; XX XX DESCRIPTION XX On a good day this routine will get a real value from the XX keyboard and return it safely. The terminal is placed in raw XX mode and most non-digit values are beeped at and discarded. Entry XX is terminated by filling the field or by CR. CR as first character XX assumes Default. ^X restarts. XX XX SEE ALSO XX XX XX DIAGNOSTICS XX none - cannot fail :-) XX XX BUGS XX Doesn't check for silly things like Default too big to fit in XX field_width, etc. Watch out for that minus sign!! XX XX Exponential notation is not supported. XX XX This version does not let you erase over the decimal point if XX the integer part of the field is already full. This is not a XX terrible hardship because you are free to ^X and start over, XX but it really should be fixed. XX XX AUTHOR XX George W. Sherouse XX 9 April 1984 XX XX --------------------------------------------------------------------------- XX*/ XX XX{ XX int c; XX float val; XX int loop; XX char line_buff[20]; XX char Format[80]; XX char erase, pad; XX int point, frac_count; XX int count; XX int cookie; XX int int_part; XX XX void underline(); XX void f_clean_up(); XX char TermSetUp(); XX int tgetnum(); XX void TermRewind(); XX XX pad = ' '; XX point = 0; XX frac_count = 0 ; XX if ((cookie = tgetnum("ug")) < 0) XX cookie = 0; XX XX underline(1); XX XX for (loop = 0; loop < field_width; loop++) XX printf(" "); XX if (cookie) XX { XX underline(0); XX TermRewind(cookie); XX } XX TermRewind(field_width); XX XX sprintf(Format, "%%%d.%df", field_width, places); XX printf(Format, Default); XX TermRewind(field_width); XX for (loop = 0; loop <= field_width; loop++) XX line_buff[loop] = 0; XX XX erase = TermSetUp(); /* set no echo, single char input */ XX /* get erase character */ XX count = 0; XX int_part = field_width - places - 1; XX while (1) XX { XX if (!point && count == int_part) XX { XX printf("."); XX line_buff[count++] = '.'; XX point++; XX continue; XX } XX XX switch (c = (getchar() & 0177)) XX { XX case '\015': XX if (count && line_buff[count - 1] != '-') XX { XX sscanf(line_buff, "%f", &val); XX f_clean_up(count, field_width, Format, val); XX return(val); XX } XX else XX { XX f_clean_up(count, field_width, Format, Default); XX return(Default); XX } XX break; XX case 030: XX TermRewind(count); XX for (loop = 0; loop < field_width; loop++) XX line_buff[loop] = 0; XX count = frac_count = point = 0; XX printf(Format, Default); XX TermRewind(field_width); XX break; XX case '.': XX if (!point) XX { XX if (!count) XX { XX for (loop = 0; loop < field_width; loop++) XX printf("%c", pad); XX TermRewind(field_width); XX for (loop = 0; loop < field_width; loop++) XX line_buff[loop] = 0; XX } XX printf("."); XX line_buff[count++] = '.'; XX point++; XX break; XX } XX case '\021': XX case '\023': XX break; XX default: XX if (c == erase && count) XX { XX printf("\b%c\b", pad); XX if (point) XX { XX if (frac_count) XX frac_count--; XX else XX point--; XX } XX line_buff[--count] = 0; XX break; XX } XX XX if (!count && c == '-') XX { XX for (loop = 0; loop < field_width; loop++) XX printf("%c", pad); XX TermRewind(field_width); XX for (loop = 0; loop < field_width; loop++) XX line_buff[loop] = 0; XX XX line_buff[count++] = (char) c; XX printf("-"); XX break; XX } XX XX if (isdigit(c) && count < field_width && frac_count < places) XX { XX if (!count) XX { XX for (loop = 0; loop < field_width; loop++) XX printf("%c", pad); XX TermRewind(field_width); XX for (loop = 0; loop < field_width; loop++) XX line_buff[loop] = 0; XX } XX printf("%c", c); XX line_buff[count++] = (char) c; XX if (point) XX frac_count++; XX } XX else XX printf("%c", '\007'); XX } XX } XX} XX XXvoid f_clean_up(count, field_width, Format, val) XXint count, field_width; XXchar *Format; XXfloat val; XX XX{ XX int loop; XX void underline(); XX char TermSetUp(); XX void TermRewind(); XX XX TermRewind(count); XX printf(Format, val); XX XX underline(0); XX (void) TermSetUp(); XX} SHAR_AND_ENJOY if test 4407 -ne "`wc -c GetFloat.c`" then echo shar: error transmitting GetFloat.c '(should have been 4407 characters)' fi echo shar: extracting GetHospNum.c '(2127 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > GetHospNum.c XX#include <stdio.h> XX#include <ctype.h> XX XXvoid GetHospNum(HospNum) XXchar *HospNum; XX XX/* XX --------------------------------------------------------------------------- XX XX Last revision - XX 16 November 1984 - GWS XX Ignore XON, XOFF XX XX 11 April 1984 - GWS XX XX XX NAME XX GetHospNum - "crash-proof" routine for terminal input of ##-##-## XX XX SYNOPSIS XX void GetHospNum(HospNum) XX char *HospNum; XX XX DESCRIPTION XX This routine prompts and nudges the user through entry of a XX hospital number in the proper format. XX XX SEE ALSO XX XX XX DIAGNOSTICS XX none XX XX BUGS XX Doesn't do any validity checking on the number, only the format. XX XX AUTHOR XX George W. Sherouse XX 9 April 1984 XX XX --------------------------------------------------------------------------- XX*/ XX XX{ XX int c; XX char erase; XX int count; XX int cookie; XX XX void underline(); XX int tgetnum(); XX char TermSetUp(); XX void TermRewind(); XX XX if ((cookie = tgetnum("ug")) < 0) XX cookie = 0; XX XX underline(1); XX XX printf(" - - "); XX if (cookie) XX { XX underline(0); XX TermRewind(cookie); XX } XX TermRewind(8); XX XX erase = TermSetUp(); /* set no echo, single char input */ XX /* get erase character */ XX count = 0; XX while (1) XX { XX switch (count) XX { XX case 2: XX case 5: XX printf("-"); XX HospNum[count++] = '-'; XX break; XX default: XX switch (c = (getchar() & 0177)) XX { XX case '\015': XX if (count == 8) XX { XX HospNum[8] = (char) 0; XX underline(0); XX TermSetUp(); XX return; XX } XX else XX { XX printf("%c", '\007'); XX break; XX } XX case 030: XX TermRewind(count); XX printf(" - - "); XX count = 0; XX TermRewind(8); XX break; XX case '\021': XX case '\023': XX break; XX default: XX if (c == erase && count) XX { XX switch (count) XX { XX case 3: XX case 6: XX printf("\b"); XX count--; XX case 1: XX case 2: XX case 4: XX case 5: XX case 7: XX case 8: XX printf("\b \b"); XX HospNum[--count] = 0; XX break; XX } XX break; XX } XX XX if (isdigit(c) && count < 8) XX { XX printf("%c", c); XX HospNum[count++] = (char) c; XX } XX else XX printf("%c", '\007'); XX } XX } XX } XX} SHAR_AND_ENJOY if test 2127 -ne "`wc -c GetHospNum.c`" then echo shar: error transmitting GetHospNum.c '(should have been 2127 characters)' fi echo shar: extracting GetInt.c '(3374 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > GetInt.c XX#include <stdio.h> XX#include <ctype.h> XX XXint GetInt(Default, field_width) XXint Default, field_width; XX XX/* XX --------------------------------------------------------------------------- XX XX Last revision - XX 16 November 1984 - GWS XX Ignore XON, XOFF XX XX 11 April 1984 - GWS XX XX XX NAME XX GetInt - "crash-proof" integer from keyboard routine XX XX SYNOPSIS XX int GetInt(Default, field_width) XX int Default, field_width; XX XX DESCRIPTION XX On a good day this routine will get an integer value from the XX keyboard and return it safely. The terminal is placed in raw XX mode and most non-digit values are beeped at and discarded. Entry XX is terminated by filling the field or by CR. CR as first character XX assumes Default. ^X restarts. XX XX SEE ALSO XX TermSetUp, TermRewind XX XX DIAGNOSTICS XX none - cannot fail :-) XX XX BUGS XX Doesn't check for silly things like Default too big to fit in XX field_width, etc. Let's be particularly careful out there. XX XX AUTHOR XX George W. Sherouse XX 6 April 1984 XX XX --------------------------------------------------------------------------- XX*/ XX XX{ XX int c, val; XX int loop; XX char line_buff[20]; XX char Format[80]; XX char erase, pad; XX int count; XX int cookie; XX XX void underline(); XX void clean_up(); XX int tgetnum(); XX char TermSetUp(); XX void TermRewind(); XX XX pad = ' '; XX if ((cookie = tgetnum("ug")) < 0) XX cookie = 0; XX XX underline(1); XX XX for (loop = 0; loop < field_width; loop++) XX printf(" "); XX if (cookie) XX { XX underline(0); XX TermRewind(cookie); XX } XX TermRewind(field_width); XX XX sprintf(Format, "%%%dd", field_width); XX printf(Format, Default); XX TermRewind(field_width); XX for (loop = 0; loop <= field_width; loop++) XX line_buff[loop] = 0; XX XX erase = TermSetUp(); /* set no echo, single char input */ XX /* get erase character */ XX count = 0; XX while (1) XX { XX switch (c = (getchar() & 0177)) XX { XX case '\015': XX if (count && line_buff[count - 1] != '-') XX { XX sscanf(line_buff, "%d", &val); XX clean_up(count, field_width, Format, val); XX return(val); XX } XX else XX { XX clean_up(count, field_width, Format, Default); XX return(Default); XX } XX break; XX case 030: XX TermRewind(count); XX for (loop = 0; loop < field_width; loop++) XX line_buff[loop] = 0; XX count = 0; XX printf(Format, Default); XX TermRewind(field_width); XX break; XX case '\021': XX case '\023': XX break; XX default: XX if (c == erase && count) XX { XX printf("\b%c\b", pad); XX line_buff[--count] = 0; XX break; XX } XX XX if (!count && c == '-') XX { XX for (loop = 0; loop < field_width; loop++) XX printf("%c", pad); XX TermRewind(field_width); XX for (loop = 0; loop < field_width; loop++) XX line_buff[loop] = 0; XX XX line_buff[count++] = (char) c; XX printf("-"); XX break; XX } XX XX if (isdigit(c) && count < field_width) XX { XX if (!count) XX { XX for (loop = 0; loop < field_width; loop++) XX printf("%c", pad); XX TermRewind(field_width); XX for (loop = 0; loop < field_width; loop++) XX line_buff[loop] = 0; XX } XX printf("%c", c); XX line_buff[count++] = (char) c; XX } XX else XX printf("%c", '\007'); XX } XX } XX} XX XXvoid clean_up(count, field_width, Format, val) XXint count, field_width; XXchar *Format; XXint val; XX XX{ XX int loop; XX void underline(); XX char TermSetUp(); XX void TermRewind(); XX XX TermRewind(count); XX printf(Format, val); XX XX underline(0); XX (void) TermSetUp(); XX} SHAR_AND_ENJOY if test 3374 -ne "`wc -c GetInt.c`" then echo shar: error transmitting GetInt.c '(should have been 3374 characters)' fi echo shar: extracting GetString.c '(2149 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > GetString.c XX#include <stdio.h> XX#include <ctype.h> XX XXvoid GetString(string, size, nullOK) XXchar *string; XXint size; XXint nullOK; XX XX/* XX --------------------------------------------------------------------------- XX XX Last revision - XX 16 November 1984 - GWS XX Ignore XON, XOFF XX XX 11 April 1984 - GWS XX XX XX NAME XX GetString - "crash-proof" routine for terminal input of string XX XX SYNOPSIS XX void GetString(string, size, nullOK) XX char *string; XX int size; XX int nullOK; XX XX DESCRIPTION XX This routine prompts and nudges the user through entry of a XX character string. 'Size' is the number of characters in'string'. XX 'String' should therefore be dimensioned to size + 1. XX 'NullOK' is a boolean that tells us whether a null string is XX acceptable. XX XX SEE ALSO XX XX XX DIAGNOSTICS XX none XX XX BUGS XX none known XX XX AUTHOR XX George W. Sherouse XX 11 April 1984 XX XX --------------------------------------------------------------------------- XX*/ XX XX{ XX int c; XX char erase; XX int loop; XX int cookie; XX int count; XX XX void underline(); XX int tgetnum(); XX char TermSetUp(); XX void TermRewind(); XX XX if ((cookie = tgetnum("ug")) < 0) XX cookie = 0; XX XX underline(1); XX for (loop = 0; loop < size; loop++) XX { XX printf(" "); XX string[loop] = (char) 0; XX } XX string[size] = (char) 0; XX XX if (cookie) XX { XX underline(0); XX TermRewind(cookie); XX } XX TermRewind(size); XX XX erase = TermSetUp(); /* set no echo, single char input */ XX /* get erase character */ XX XX count = 0; XX while (1) XX { XX switch (c = (getchar() & 0177)) XX { XX case '\015': XX if (count || nullOK) XX { XX for (loop = count; loop < size; loop++) XX printf(" "); XX underline(0); XX (void) TermSetUp(); XX return; XX } XX else XX { XX printf("%c", '\007'); XX break; XX } XX case '\030': XX while (count) XX { XX string[--count] = (char) 0; XX printf("\b \b"); XX } XX break; XX case '\021': XX case '\023': XX break; XX default: XX if (count && c == erase) XX { XX printf("\b \b"); XX string[--count] = (char) 0; XX break; XX } XX XX if (isprint(c) && count < size) XX { XX printf("%c", c); XX string[count++] = c; XX break; XX } XX XX printf("%c", '\007'); XX } XX } XX} SHAR_AND_ENJOY if test 2149 -ne "`wc -c GetString.c`" then echo shar: error transmitting GetString.c '(should have been 2149 characters)' fi echo shar: extracting InitTerm.c '(1074 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > InitTerm.c XX#include <stdio.h> XX XXchar bp[1024]; XX XXint InitTerm() XX XX/* XX --------------------------------------------------------------------------- XX XX Last revision - XX 30 March 1984 - GWS XX XX XX NAME XX InitTerm - initialize data area for screen handling routines XX XX SYNOPSIS XX InitTerm() XX XX DESCRIPTION XX Calls getenv to find out what terminal type to use and XX then calls tgetent to initialize the string containing XX the termcap. XX XX SEE ALSO XX termcap(3x), page, gotoxy, underline, stand_out, clear_eol XX XX DIAGNOSTICS XX Returns 0 if successful XX -1 if getenv fails XX -2 if tgetent cannot open termcap file XX -3 if tgetent cannot find entry for terminal XX XX BUGS XX none known XX XX AUTHOR XX George W. Sherouse XX 30 March 1984 XX XX --------------------------------------------------------------------------- XX*/ XX XX XX{ XX int tgetent(), ret; XX char *getenv(), *cret; XX XX cret = getenv("TERM"); XX if (cret == NULL) XX return(-1); XX XX ret = tgetent(bp, cret); XX switch (ret) XX { XX case -1: XX return(-2); XX case 0: XX return(-3); XX case 1: XX return(0); XX } XX} SHAR_AND_ENJOY if test 1074 -ne "`wc -c InitTerm.c`" then echo shar: error transmitting InitTerm.c '(should have been 1074 characters)' fi echo shar: extracting MenuPick.c '(4175 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > MenuPick.c XX#include <stdio.h> XX#include <ctype.h> XX#include <strings.h> XX#include "term.h" XX XX#define TRUE 1 XX#define FALSE 0 XX#define BASE 3 XX XXint MenuPick(Prompt, ChoiceList, ChoiceCount) XXchar *Prompt; XXchar **ChoiceList; XXint ChoiceCount; XX XX/* XX --------------------------------------------------------------------------- XX XX Last revision - XX 23 October 1984 - GWS XX XX XX NAME XX MenuPick - "crash-proof" routine for picking one of a list of strings XX XX SYNOPSIS XX int MenuPick(Prompt, ChoiceList, ChoiceCount) XX char *Prompt; XX char **ChoiceList; XX int ChoiceCount; XX XX DESCRIPTION XX This routine prompts and nudges the user through selection of a XX string from a table of strings - useful for choosing an item XX from a menu for instance. The options are displayed in a menu XX format with one at a time highlighted. The current item is XX selected by pressing RETURN. The space bar advances, the XX up-arrow backs up. The return value of the function is the XX index of the chosen string (0 indexed). XX XX SEE ALSO XX XX XX DIAGNOSTICS XX none XX XX BUGS XX none known XX XX AUTHOR XX George W. Sherouse XX 22 October 1984 XX XX --------------------------------------------------------------------------- XX*/ XX XX{ XX int c, XX start, XX stop, XX select; XX XX/* XXIn the silly case where there is only one choice, just return the index 0. XX*/ XX if (ChoiceCount == 1) XX return(0); XX XX select = 0; XX paint_screen(Prompt, ChoiceList, ChoiceCount, &start, &stop, select, TRUE); XX while (1) XX { XX switch (c = (getchar() & 0x7f)) XX { XX case '\015': XX TermSetUp(); XX return(select); XX case ' ': XX if (++select == ChoiceCount) XX select = 0; XX paint_screen(Prompt, ChoiceList, ChoiceCount, &start, &stop, XX select, FALSE); XX break; XX case '^': XX if (--select < 0) XX select = ChoiceCount - 1; XX paint_screen(Prompt, ChoiceList, ChoiceCount, &start, &stop, XX select, FALSE); XX break; XX case '>': XX select = stop + 1; XX if (select == ChoiceCount) XX select = 0; XX paint_screen(Prompt, ChoiceList, ChoiceCount, &start, &stop, XX select, FALSE); XX break; XX case '\021': XX case '\023': XX break; XX default: XX printf("%c", '\007'); XX } XX } XX} XX XXpaint_screen(Prompt, ChoiceList, ChoiceCount, start, stop, select, first) XXchar *Prompt; XXchar **ChoiceList; XXint ChoiceCount; XXint *start; XXint *stop; XXint select; XXint first; XX XX{ XX int tgetnum(); XX XX static int too_many = FALSE, XX current, XX previous, XX old_start, XX cookie; XX XX int loop, XX loop1, XX line, XX temp; XX XX char erase; XX XX if (first) XX { XX XX/* XXFind out if we need to cope with magic cookies. XX*/ XX if ((cookie = tgetnum("ug")) < 0) XX cookie = 0; XX XX if (ChoiceCount > 15) XX too_many = TRUE; XX XX current = old_start = -1; XX previous = *start = 0; XX if (too_many) XX *stop = 14; XX else XX *stop = ChoiceCount - 1; XX XX erase = TermSetUp(); /* set no echo, single char input */ XX /* get erase character */ XX XX first = FALSE; XX } XX else XX { XX if (select < *start) XX *start -= 15; XX if (select > *stop) XX *start += 15; XX if (*start >= ChoiceCount) XX *start = 0; XX if (*start < 0) XX *start = ((ChoiceCount - 1) / 15) * 15; XX XX *stop = *start + 14; XX if (*stop >= ChoiceCount) XX *stop = ChoiceCount - 1; XX } XX XX/* XXClear the stage for the action XX*/ XX if (*start == old_start) XX { XX gotoxy(1, BASE + previous); XX ClearEOL(); XX gotoxy(1, BASE + previous); XX for (loop = 0; loop < cookie; loop++) XX printf(" "); XX printf("%s", ChoiceList[*start + previous]); XX XX current = select - *start; XX gotoxy(1, BASE + current); XX ClearEOL(); XX gotoxy(1, BASE + current); XX underline(TRUE); XX printf("%s", ChoiceList[*start + current]); XX underline(FALSE); XX XX previous = current; XX } XX else XX { XX page(); XX center(1, Prompt, 1); XX line = BASE; XX XX for (loop = *start; loop <= *stop; loop++) XX { XX gotoxy(1, line++); XX if (loop == select) XX { XX underline(TRUE); XX printf("%s", ChoiceList[loop]); XX underline(FALSE); XX } XX else XX { XX for (loop1 = 0; loop1 < cookie; loop1++) XX printf(" "); XX printf("%s", ChoiceList[loop]); XX } XX } XX previous = select - *start; XX old_start = *start; XX } XX XX gotoxy(1, 23); XX printf("Press RETURN to accept, SPACE to step forward, ^ to back up"); XX if (too_many) XX printf(", > for next page"); XX} SHAR_AND_ENJOY if test 4175 -ne "`wc -c MenuPick.c`" then echo shar: error transmitting MenuPick.c '(should have been 4175 characters)' fi echo shar: extracting PickOne.c '(2497 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > PickOne.c XX#include <stdio.h> XX#include <ctype.h> XX#include <strings.h> XX XXint PickOne(ChoiceList, ChoiceCount) XXchar **ChoiceList; XXint ChoiceCount; XX XX/* XX --------------------------------------------------------------------------- XX XX Last revision - XX 16 November 1984 - GWS XX Ignore XON, XOFF XX XX 12 April 1984 - GWS XX XX XX NAME XX PickOne - "crash-proof" routine for picking one of a list of XX list of strings XX XX SYNOPSIS XX int PickOne(ChoiceList, ChoiceCount) XX char **ChoiceList; XX int ChoiceCount; XX XX DESCRIPTION XX This routine prompts and nudges the user through selection of a XX string from a table of strings - useful for choosing an item XX from a menu for instance. The options are displayed one at a XX time. The current item is selected by pressing return. The XX space bar advances, the up-arrow backs up. The return XX value of the function is the index of the chosen string. XX XX SEE ALSO XX XX XX DIAGNOSTICS XX none XX XX BUGS XX none known XX XX AUTHOR XX George W. Sherouse XX 11 April 1984 XX XX --------------------------------------------------------------------------- XX*/ XX XX{ XX int c; XX char erase; XX int val; XX int cookie; XX int biggest; XX int temp; XX int loop; XX char Format[80]; XX XX void underline(); XX int tgetnum(); XX char TermSetUp(); XX void TermRewind(); XX int strlen(); XX XX/* XXIn the silly case where there is only one choice, just print it XXand return the index 0. XX*/ XX if (ChoiceCount == 1) XX { XX underline(1); XX printf("%s", ChoiceList[0]); XX underline(0); XX return(0); XX } XX/* XXFind the longest string in the bunch XX*/ XX biggest = strlen(ChoiceList[0]); XX for (loop = 1; loop < ChoiceCount; loop++) XX if ((temp = strlen(ChoiceList[loop])) > biggest) XX biggest = temp; XX XX/* XXFind out if we need to cope with magic cookies. XX*/ XX if ((cookie = tgetnum("ug")) < 0) XX cookie = 0; XX XX underline(1); XX for (loop = 0; loop < biggest; loop++) XX printf(" "); XX XX if (cookie) XX { XX underline(0); XX TermRewind(cookie); XX } XX XX erase = TermSetUp(); /* set no echo, single char input */ XX /* get erase character */ XX sprintf(Format, "%%-%ds", biggest); XX XX val = 0; XX while (1) XX { XX TermRewind(biggest); XX printf(Format, ChoiceList[val]); XX XX switch (c = (getchar() & 0177)) XX { XX case '\015': XX underline(0); XX TermSetUp(); XX return(val); XX case ' ': XX if (++val == ChoiceCount) XX val = 0; XX break; XX case '^': XX if (--val < 0) XX val = ChoiceCount - 1; XX break; XX case '\021': XX case '\023': XX break; XX default: XX printf("%c", '\007'); XX } XX } XX} SHAR_AND_ENJOY if test 2497 -ne "`wc -c PickOne.c`" then echo shar: error transmitting PickOne.c '(should have been 2497 characters)' fi echo shar: extracting StandOut.c '(1086 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > StandOut.c XX XXvoid StandOut(on_or_off) XXint on_or_off; XX XX XX/* XX --------------------------------------------------------------------------- XX XX Last revision - XX 30 March 1984 - GWS XX XX XX NAME XX StandOut - set or clear terminal stand-out mode XX XX SYNOPSIS XX void StandOut(on_or_off) XX int on_or_off; XX XX DESCRIPTION XX Uses termcap(3x) routines to set terminal mode. XX XX SEE ALSO XX termcap(3) XX XX DIAGNOSTICS XX If the mode doesn't change, it didn't work. XX XX AUTHOR XX George W. Sherouse XX 30 March 1984 XX XX --------------------------------------------------------------------------- XX*/ XX XX{ XX static called = 0; XX static char so_id[] = "so", se_id[] = "se", so_str[10], se_str[10]; XX static char *so_point = so_str, **so_point2 = &so_point; XX static char *se_point = se_str, **se_point2 = &se_point; XX extern char bp[1024]; XX int tgetent(), tputs(); XX int putchar(); XX XX if (!called) XX { XX tgetstr(so_id, so_point2); XX tgetstr(se_id, se_point2); XX called++; XX } XX XX if (on_or_off) XX (void) tputs(so_str, 1, putchar); XX else XX (void) tputs(se_str, 1, putchar); XX return; XX} SHAR_AND_ENJOY if test 1086 -ne "`wc -c StandOut.c`" then echo shar: error transmitting StandOut.c '(should have been 1086 characters)' fi echo shar: extracting TermRewind.c '(209 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > TermRewind.c XX XX#include <stdio.h> XX XXvoid TermRewind(count) XXint count; XX/* XX XXvoid TermRewind(count) XXint count; XX XXBacks up the cursor 'count' spaces XX XX*/ XX XX{ XX int loop; XX XX for (loop = 0; loop < count; loop++) XX printf("\b"); XX} SHAR_AND_ENJOY if test 209 -ne "`wc -c TermRewind.c`" then echo shar: error transmitting TermRewind.c '(should have been 209 characters)' fi echo shar: extracting TermSetUp.c '(1713 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > TermSetUp.c XX#include <stdio.h> XX#include <sgtty.h> XX#include <sys/ioctl.h> XX XXchar TermSetUp() XX XX/* XX --------------------------------------------------------------------------- XX XX Last revision - XX 11 April 1984 - GWS XX XX XX NAME XX TermSetUp - set/clear terminal no echo, raw mode XX XX SYNOPSIS XX char TermSetUp() XX XX DESCRIPTION XX This routine is a toggle function which places the terminal XX into RAW and !ECHO modes on odd calls and back to the original XX state on even-number calls. The return character is the terminal's XX erase character. XX XX SEE ALSO XX XX XX DIAGNOSTICS XX Will exit(1) on any error. XX XX BUGS XX none known XX XX AUTHOR XX George W. Sherouse XX 9 April 1984 XX XX --------------------------------------------------------------------------- XX*/ XX XX{ XX struct sgttyb params; XX int ret; XX static int count=0; XX static struct sgttyb old_params; XX int ioctl(); XX XX if (!count) XX { XX ret = ioctl(0, TIOCGETP, &old_params); XX if (ret == -1) XX { XX fprintf(stderr, "ioctl fail\n"); XX perror("TermSetUp"); XX exit(1); XX } XX ret = ioctl(0, TIOCGETP, ¶ms); XX if (ret == -1) XX { XX fprintf(stderr, "ioctl fail\n"); XX perror("TermSetUp"); XX exit(1); XX } XX XX /* single-character activation, disable all character processing */ XX params.sg_flags |= RAW; XX if (params.sg_flags & ECHO) XX params.sg_flags ^= ECHO; XX ret = ioctl(0, TIOCSETP, ¶ms); XX if (ret == -1) XX { XX fprintf(stderr, "ioctl fail\n"); XX perror("TermSetUp"); XX exit(1); XX } XX count++; XX } XX else XX { XX/* put it back the way you found it */ XX ret = ioctl(0, TIOCSETP, &old_params); XX if (ret == -1) XX { XX fprintf(stderr, "ioctl fail\n"); XX perror("TermSetUp"); XX exit(1); XX } XX count = 0; XX } XX XX return(params.sg_erase); XX} SHAR_AND_ENJOY if test 1713 -ne "`wc -c TermSetUp.c`" then echo shar: error transmitting TermSetUp.c '(should have been 1713 characters)' fi echo shar: extracting center.c '(1758 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > center.c XX#include <strings.h> XX XXvoid center(line, string, mode) XXint line; XXchar *string; XXint mode; XX XX/* XX --------------------------------------------------------------------------- XX XX Last revision - XX 2 April 1984 - GWS XX XX XX NAME XX center - center string in 80 column area XX XX SYNOPSIS XX void center(line, string, mode) XX int line; XX char *string; XX int mode; XX XX DESCRIPTION XX This routine uses the termcap(3x) routines to center and XX optionally emphasize a string. 'Line' is the terminal line XX number on which the string is to be placed, numbered starting XX with 1. 'Mode' takes one of three values: XX 0 - no control characters sent XX 1 - underline mode turned on before and off after 'string' XX 2 - stand-out mode turned on before and off after 'string' XX A call to InitTerm must be made before the first call to center. XX XX SEE ALSO XX termcap(3x), InitTerm, underline, StandOut XX XX DIAGNOSTICS XX none XX XX BUGS XX does not check for string too long to fit on one line XX XX AUTHOR XX George W. Sherouse XX 31 March 1984 XX XX --------------------------------------------------------------------------- XX*/ XX XX{ XX int col; XX int cookie; XX XX int strlen(); XX void gotoxy(); XX void underline(); XX void StandOut(); XX XX col = (80 - strlen(string)) / 2; XX switch (mode) XX { XX case 0: XX break; XX case 1: XX cookie = tgetnum("ug"); XX if (cookie > 0) XX col -= cookie; XX break; XX case 2: XX cookie = tgetnum("sg"); XX if (cookie > 0) XX col -= cookie; XX break; XX } XX gotoxy(col, line); XX switch (mode) XX { XX case 0: XX break; XX case 1: XX underline(1); XX break; XX case 2: XX StandOut(1); XX break; XX } XX XX printf(string); XX XX switch (mode) XX { XX case 0: XX break; XX case 1: XX underline(0); XX break; XX case 2: XX StandOut(0); XX break; XX } XX return; XX} SHAR_AND_ENJOY if test 1758 -ne "`wc -c center.c`" then echo shar: error transmitting center.c '(should have been 1758 characters)' fi echo shar: extracting examp.c '(1999 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > examp.c XX#include <stdio.h> XX#include <term.h> XX XXmain() XX XX{ XX int num1, num2; XX float fnum1, fnum2; XX char HospNum[9]; XX char text[20]; XX static char *table[] = XX { XX "Number one", XX "Number two", XX "And even yet another", XX "two turtle moves", XX "a partridge in a directory tree" XX }; XX XX XX if(InitTerm() != 0) XX printf("InitTerm failed\n"); XX page(); XX XX printf("Here are your choices -->"); XX num1 = PickOne(table, 5); XX printf("<--\nNumber %d was chosen\n", num1); XX XX printf("Here are your choices -->"); XX num1 = PickOne(table, 1); XX printf("<--\nNumber %d was chosen\n", num1); XX XX printf("Enter a string -->"); XX GetString(text, 15, 0); XX printf("<--\nString is %s\n", text); XX XX printf("yes or no ? -->"); XX num1 = GetBool(1); XX printf(","); XX num2 = GetBool(num1); XX printf("<---\n"); XX printf("Booleans are %d, %d\n", num1, num2); XX XX printf("Enter a number --->"); XX num1 = GetInt(50, 4); XX printf(","); XX num2 = GetInt(num1, 6); XX printf("<---\n"); XX printf("Numbers were %d, %d\n", num1, num2); XX XX printf("Enter a number --->"); XX fnum1 = GetFloat(50.0, 8, 5); XX printf(","); XX fnum2 = GetFloat(fnum1, 6, 2); XX printf("<---\n"); XX printf("Numbers were %f, %f\n", fnum1, fnum2); XX XX printf("Enter hospital number --->"); XX GetHospNum(HospNum); XX printf("<---\n"); XX printf("Number is %s\n", HospNum); XX XX fflush(stdout); XX sleep(2); XX XX page(); XX num1 = MenuPick("This is a demo of MenuPick", table, 5); XX printf("<--\nNumber %d was chosen\n", num1); XX sleep(2); XX XX XX page(); XX gotoxy(15, 15); XX center(1, "I am normal text centered on line 1", 0); XX center(10, "I am underlined text centered on line 10", 1); XX center(20, "I am standout text centered on line 20", 2); XX gotoxy(1, 1); XX printf("+"); XX gotoxy(80, 1); XX printf("+"); XX gotoxy(40, 12); XX printf("+"); XX gotoxy(1, 24); XX printf("+"); XX gotoxy(79, 24); XX printf("+"); XX fflush(stdout); XX XX sleep(2); XX gotoxy(1, 24); XX exit(0); XX} SHAR_AND_ENJOY if test 1999 -ne "`wc -c examp.c`" then echo shar: error transmitting examp.c '(should have been 1999 characters)' fi echo shar: extracting gotoxy.c '(1077 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > gotoxy.c XX XXvoid gotoxy(col, line) XXint col, line; XX XX/* XX --------------------------------------------------------------------------- XX XX Last revision - XX 29 March 1984 - GWS XX XX XX NAME XX gotoxy - move the cursor to the requested position XX XX SYNOPSIS XX void gotoxy(col, line) XX int col, line; XX XX DESCRIPTION XX Uses termcap(3x) routines to move cursor. The columns and XX lines are numbered starting with 1. XX XX SEE ALSO XX termcap(3) XX XX DIAGNOSTICS XX If the cursor doesn't move, it didn't work. XX XX AUTHOR XX George W. Sherouse XX 29 March 1984 XX XX --------------------------------------------------------------------------- XX*/ XX XX{ XX static called = 0; XX static char id[] = "cm", cm_str[20]; XX static char *point = cm_str, **point2 = &point; XX extern char bp[1024]; XX int tgetent(); XX int tputs(); XX int putchar(); XX char *tgoto(); XX char str[20]; XX int loop; XX XX if (!called) XX { XX tgetstr(id, point2); XX called++; XX } XX XX for (loop = 0; loop < 20; loop++) XX str[loop] = cm_str[loop]; XX XX XX (void) tputs(tgoto(str, col - 1, line - 1), 1, putchar); XX return; XX} SHAR_AND_ENJOY if test 1077 -ne "`wc -c gotoxy.c`" then echo shar: error transmitting gotoxy.c '(should have been 1077 characters)' fi echo shar: extracting page.c '(813 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > page.c XX XXvoid page() XX XX/* XX --------------------------------------------------------------------------- XX XX Last revision - XX 29 March 1984 - GWS XX XX XX NAME XX page - page the terminal XX XX SYNOPSIS XX void page() XX XX DESCRIPTION XX Uses termcap(3x) routines to clear terminal screen. XX XX SEE ALSO XX termcap(3) XX XX DIAGNOSTICS XX If the screen doesn't clear, it didn't work. XX XX AUTHOR XX George W. Sherouse XX 29 March 1984 XX XX --------------------------------------------------------------------------- XX*/ XX XX{ XX static called = 0; XX static char id[] = "cl", page_str[10]; XX static char *point = page_str, **point2 = &point; XX extern char bp[1024]; XX int tgetent(), tputs(); XX int putchar(); XX XX if (!called) XX { XX tgetstr(id, point2); XX called++; XX } XX XX (void) tputs(page_str, 1, putchar); XX return; XX} SHAR_AND_ENJOY if test 813 -ne "`wc -c page.c`" then echo shar: error transmitting page.c '(should have been 813 characters)' fi echo shar: extracting underline.c '(1093 characters)' sed 's/^XX//' << \SHAR_AND_ENJOY > underline.c XX XXvoid underline(on_or_off) XXint on_or_off; XX XX XX/* XX --------------------------------------------------------------------------- XX XX Last revision - XX 30 March 1984 - GWS XX XX XX NAME XX underline - set or clear terminal underline mode XX XX SYNOPSIS XX void underline(on_or_off) XX int on_or_off; XX XX DESCRIPTION XX Uses termcap(3x) routines to set terminal mode. XX XX SEE ALSO XX termcap(3) XX XX DIAGNOSTICS XX If the mode doesn't change, it didn't work. XX XX AUTHOR XX George W. Sherouse XX 30 March 1984 XX XX --------------------------------------------------------------------------- XX*/ XX XX{ XX static int called = 0; XX static char us_id[] = "us", ue_id[] = "ue", us_str[10], ue_str[10]; XX static char *us_point = us_str, **us_point2 = &us_point; XX static char *ue_point = ue_str, **ue_point2 = &ue_point; XX extern char bp[1024]; XX int tgetent(), tputs(); XX int putchar(); XX XX if (!called) XX { XX tgetstr(us_id, us_point2); XX tgetstr(ue_id, ue_point2); XX called++; XX } XX XX if (on_or_off) XX (void) tputs(us_str, 1, putchar); XX else XX (void) tputs(ue_str, 1, putchar); XX return; XX} SHAR_AND_ENJOY if test 1093 -ne "`wc -c underline.c`" then echo shar: error transmitting underline.c '(should have been 1093 characters)' fi # End of shell archive exit 0