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