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