1 1.2 mycroft #ifndef lint 2 1.2 mycroft static char rcsid[] = "$Id: help.c,v 1.2 1993/08/02 17:20:04 mycroft Exp $"; 3 1.2 mycroft #endif /* not lint */ 4 1.2 mycroft 5 1.1 cgd /* help.c Larn is copyrighted 1986 by Noah Morgan. */ 6 1.1 cgd #include "header.h" 7 1.1 cgd /* 8 1.1 cgd * help function to display the help info 9 1.1 cgd * 10 1.1 cgd * format of the .larn.help file 11 1.1 cgd * 12 1.1 cgd * 1st character of file: # of pages of help available (ascii digit) 13 1.1 cgd * page (23 lines) for the introductory message (not counted in above) 14 1.1 cgd * pages of help text (23 lines per page) 15 1.1 cgd */ 16 1.1 cgd extern char helpfile[]; 17 1.1 cgd help() 18 1.1 cgd { 19 1.1 cgd register int i,j; 20 1.1 cgd #ifndef VT100 21 1.1 cgd char tmbuf[128]; /* intermediate translation buffer when not a VT100 */ 22 1.1 cgd #endif VT100 23 1.1 cgd if ((j=openhelp()) < 0) return; /* open the help file and get # pages */ 24 1.1 cgd for (i=0; i<23; i++) lgetl(); /* skip over intro message */ 25 1.1 cgd for (; j>0; j--) 26 1.1 cgd { 27 1.1 cgd clear(); 28 1.1 cgd for (i=0; i<23; i++) 29 1.1 cgd #ifdef VT100 30 1.1 cgd lprcat(lgetl()); /* print out each line that we read in */ 31 1.1 cgd #else VT100 32 1.1 cgd { tmcapcnv(tmbuf,lgetl()); lprcat(tmbuf); } /* intercept \33's */ 33 1.1 cgd #endif VT100 34 1.1 cgd if (j>1) 35 1.1 cgd { 36 1.1 cgd lprcat(" ---- Press "); standout("return"); 37 1.1 cgd lprcat(" to exit, "); standout("space"); 38 1.1 cgd lprcat(" for more help ---- "); 39 1.1 cgd i=0; while ((i!=' ') && (i!='\n') && (i!='\33')) i=getchar(); 40 1.1 cgd if ((i=='\n') || (i=='\33')) 41 1.1 cgd { 42 1.1 cgd lrclose(); setscroll(); drawscreen(); return; 43 1.1 cgd } 44 1.1 cgd } 45 1.1 cgd } 46 1.1 cgd lrclose(); retcont(); drawscreen(); 47 1.1 cgd } 48 1.1 cgd 49 1.1 cgd /* 50 1.1 cgd * function to display the welcome message and background 51 1.1 cgd */ 52 1.1 cgd welcome() 53 1.1 cgd { 54 1.1 cgd register int i; 55 1.1 cgd #ifndef VT100 56 1.1 cgd char tmbuf[128]; /* intermediate translation buffer when not a VT100 */ 57 1.1 cgd #endif VT100 58 1.1 cgd if (openhelp() < 0) return; /* open the help file */ 59 1.1 cgd clear(); 60 1.1 cgd for(i=0; i<23; i++) 61 1.1 cgd #ifdef VT100 62 1.1 cgd lprcat(lgetl()); /* print out each line that we read in */ 63 1.1 cgd #else VT100 64 1.1 cgd { tmcapcnv(tmbuf,lgetl()); lprcat(tmbuf); } /* intercept \33's */ 65 1.1 cgd #endif VT100 66 1.1 cgd lrclose(); retcont(); /* press return to continue */ 67 1.1 cgd } 68 1.1 cgd 69 1.1 cgd /* 70 1.1 cgd * function to say press return to continue and reset scroll when done 71 1.1 cgd */ 72 1.1 cgd retcont() 73 1.1 cgd { 74 1.1 cgd cursor(1,24); lprcat("Press "); standout("return"); 75 1.1 cgd lprcat(" to continue: "); while (getchar() != '\n'); 76 1.1 cgd setscroll(); 77 1.1 cgd } 78 1.1 cgd 79 1.1 cgd /* 80 1.1 cgd * routine to open the help file and return the first character - '0' 81 1.1 cgd */ 82 1.1 cgd openhelp() 83 1.1 cgd { 84 1.1 cgd if (lopen(helpfile)<0) 85 1.1 cgd { 86 1.1 cgd lprintf("Can't open help file \"%s\" ",helpfile); 87 1.1 cgd lflush(); sleep(4); drawscreen(); setscroll(); return(-1); 88 1.1 cgd } 89 1.1 cgd resetscroll(); return(lgetc() - '0'); 90 1.1 cgd } 91 1.1 cgd 92