1 /* $NetBSD: help.c,v 1.5 2001/02/05 00:57:33 christos Exp $ */ 2 3 /* help.c Larn is copyrighted 1986 by Noah Morgan. */ 4 #include <sys/cdefs.h> 5 #ifndef lint 6 __RCSID("$NetBSD: help.c,v 1.5 2001/02/05 00:57:33 christos Exp $"); 7 #endif /* not lint */ 8 9 #include <unistd.h> 10 11 #include "header.h" 12 #include "extern.h" 13 /* 14 * help function to display the help info 15 * 16 * format of the .larn.help file 17 * 18 * 1st character of file: # of pages of help available (ascii digit) 19 * page (23 lines) for the introductory message (not counted in above) 20 * pages of help text (23 lines per page) 21 */ 22 void 23 help() 24 { 25 int i, j; 26 #ifndef VT100 27 char tmbuf[128]; /* intermediate translation buffer 28 * when not a VT100 */ 29 #endif /* VT100 */ 30 if ((j = openhelp()) < 0) 31 return; /* open the help file and get # pages */ 32 for (i = 0; i < 23; i++) 33 lgetl(); /* skip over intro message */ 34 for (; j > 0; j--) { 35 clear(); 36 for (i = 0; i < 23; i++) 37 #ifdef VT100 38 lprcat(lgetl()); /* print out each line that 39 * we read in */ 40 #else /* VT100 */ 41 { 42 tmcapcnv(tmbuf, lgetl()); 43 lprcat(tmbuf); 44 } /* intercept \33's */ 45 #endif /* VT100 */ 46 if (j > 1) { 47 lprcat(" ---- Press "); 48 standout("return"); 49 lprcat(" to exit, "); 50 standout("space"); 51 lprcat(" for more help ---- "); 52 i = 0; 53 while ((i != ' ') && (i != '\n') && (i != '\33')) 54 i = lgetchar(); 55 if ((i == '\n') || (i == '\33')) { 56 lrclose(); 57 setscroll(); 58 drawscreen(); 59 return; 60 } 61 } 62 } 63 lrclose(); 64 retcont(); 65 drawscreen(); 66 } 67 68 /* 69 * function to display the welcome message and background 70 */ 71 void 72 welcome() 73 { 74 int i; 75 #ifndef VT100 76 char tmbuf[128]; /* intermediate translation buffer 77 * when not a VT100 */ 78 #endif /* VT100 */ 79 if (openhelp() < 0) 80 return; /* open the help file */ 81 clear(); 82 for (i = 0; i < 23; i++) 83 #ifdef VT100 84 lprcat(lgetl());/* print out each line that we read in */ 85 #else /* VT100 */ 86 { 87 tmcapcnv(tmbuf, lgetl()); 88 lprcat(tmbuf); 89 } /* intercept \33's */ 90 #endif /* VT100 */ 91 lrclose(); 92 retcont(); /* press return to continue */ 93 } 94 95 /* 96 * function to say press return to continue and reset scroll when done 97 */ 98 void 99 retcont() 100 { 101 cursor(1, 24); 102 lprcat("Press "); 103 standout("return"); 104 lprcat(" to continue: "); 105 while (lgetchar() != '\n'); 106 setscroll(); 107 } 108 109 /* 110 * routine to open the help file and return the first character - '0' 111 */ 112 int 113 openhelp() 114 { 115 if (lopen(helpfile) < 0) { 116 lprintf("Can't open help file \"%s\" ", helpfile); 117 lflush(); 118 sleep(4); 119 drawscreen(); 120 setscroll(); 121 return (-1); 122 } 123 resetscroll(); 124 return (lgetc() - '0'); 125 } 126