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