Sync usage with man page.
[netbsd-mini2440.git] / games / larn / help.c
blobc0a4b5f4647c8c5249e1c5f92e3fa0db90b5e1dd
1 /* $NetBSD: help.c,v 1.7 2008/02/03 21:24:58 dholland Exp $ */
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.7 2008/02/03 21:24:58 dholland Exp $");
7 #endif /* not lint */
9 #include <unistd.h>
11 #include "header.h"
12 #include "extern.h"
14 static void retcont(void);
15 static int openhelp(void);
18 * help function to display the help info
20 * format of the .larn.help file
22 * 1st character of file: # of pages of help available (ascii digit)
23 * page (23 lines) for the introductory message (not counted in above)
24 * pages of help text (23 lines per page)
26 void
27 help()
29 int i, j;
30 #ifndef VT100
31 char tmbuf[128]; /* intermediate translation buffer
32 * when not a VT100 */
33 #endif /* VT100 */
34 if ((j = openhelp()) < 0)
35 return; /* open the help file and get # pages */
36 for (i = 0; i < 23; i++)
37 lgetl(); /* skip over intro message */
38 for (; j > 0; j--) {
39 clear();
40 for (i = 0; i < 23; i++)
41 #ifdef VT100
42 lprcat(lgetl()); /* print out each line that
43 * we read in */
44 #else /* VT100 */
46 tmcapcnv(tmbuf, lgetl());
47 lprcat(tmbuf);
48 } /* intercept \33's */
49 #endif /* VT100 */
50 if (j > 1) {
51 lprcat(" ---- Press ");
52 standout("return");
53 lprcat(" to exit, ");
54 standout("space");
55 lprcat(" for more help ---- ");
56 i = 0;
57 while ((i != ' ') && (i != '\n') && (i != '\33'))
58 i = ttgetch();
59 if ((i == '\n') || (i == '\33')) {
60 lrclose();
61 setscroll();
62 drawscreen();
63 return;
67 lrclose();
68 retcont();
69 drawscreen();
73 * function to display the welcome message and background
75 void
76 welcome()
78 int i;
79 #ifndef VT100
80 char tmbuf[128]; /* intermediate translation buffer
81 * when not a VT100 */
82 #endif /* VT100 */
83 if (openhelp() < 0)
84 return; /* open the help file */
85 clear();
86 for (i = 0; i < 23; i++)
87 #ifdef VT100
88 lprcat(lgetl());/* print out each line that we read in */
89 #else /* VT100 */
91 tmcapcnv(tmbuf, lgetl());
92 lprcat(tmbuf);
93 } /* intercept \33's */
94 #endif /* VT100 */
95 lrclose();
96 retcont(); /* press return to continue */
100 * function to say press return to continue and reset scroll when done
102 static void
103 retcont()
105 cursor(1, 24);
106 lprcat("Press ");
107 standout("return");
108 lprcat(" to continue: ");
109 while (ttgetch() != '\n');
110 setscroll();
114 * routine to open the help file and return the first character - '0'
116 static int
117 openhelp(void)
119 if (lopen(helpfile) < 0) {
120 lprintf("Can't open help file \"%s\" ", helpfile);
121 lflush();
122 sleep(4);
123 drawscreen();
124 setscroll();
125 return (-1);
127 resetscroll();
128 return (lgetc() - '0');