Annotation of src/games/larn/help.c, Revision 1.5
1.5 ! christos 1: /* $NetBSD: help.c,v 1.4 1997/10/18 20:03:24 christos Exp $ */
1.4 christos 2:
3: /* help.c Larn is copyrighted 1986 by Noah Morgan. */
4: #include <sys/cdefs.h>
1.2 mycroft 5: #ifndef lint
1.5 ! christos 6: __RCSID("$NetBSD: help.c,v 1.4 1997/10/18 20:03:24 christos Exp $");
1.2 mycroft 7: #endif /* not lint */
8:
1.4 christos 9: #include <unistd.h>
10:
1.1 cgd 11: #include "header.h"
1.4 christos 12: #include "extern.h"
1.1 cgd 13: /*
1.4 christos 14: * help function to display the help info
1.1 cgd 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: */
1.4 christos 22: void
1.1 cgd 23: help()
1.4 christos 24: {
25: int i, j;
1.1 cgd 26: #ifndef VT100
1.4 christos 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--) {
1.1 cgd 35: clear();
1.4 christos 36: for (i = 0; i < 23; i++)
1.1 cgd 37: #ifdef VT100
1.4 christos 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");
1.1 cgd 51: lprcat(" for more help ---- ");
1.4 christos 52: i = 0;
53: while ((i != ' ') && (i != '\n') && (i != '\33'))
1.5 ! christos 54: i = lgetchar();
1.4 christos 55: if ((i == '\n') || (i == '\33')) {
56: lrclose();
57: setscroll();
58: drawscreen();
59: return;
1.1 cgd 60: }
61: }
62: }
1.4 christos 63: lrclose();
64: retcont();
65: drawscreen();
66: }
1.1 cgd 67:
68: /*
69: * function to display the welcome message and background
70: */
1.4 christos 71: void
1.1 cgd 72: welcome()
1.4 christos 73: {
74: int i;
1.1 cgd 75: #ifndef VT100
1.4 christos 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 */
1.1 cgd 81: clear();
1.4 christos 82: for (i = 0; i < 23; i++)
1.1 cgd 83: #ifdef VT100
1.4 christos 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: }
1.1 cgd 94:
95: /*
96: * function to say press return to continue and reset scroll when done
97: */
1.4 christos 98: void
1.1 cgd 99: retcont()
1.4 christos 100: {
101: cursor(1, 24);
102: lprcat("Press ");
103: standout("return");
104: lprcat(" to continue: ");
1.5 ! christos 105: while (lgetchar() != '\n');
1.1 cgd 106: setscroll();
1.4 christos 107: }
1.1 cgd 108:
109: /*
110: * routine to open the help file and return the first character - '0'
111: */
1.4 christos 112: int
1.1 cgd 113: openhelp()
1.4 christos 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);
1.1 cgd 122: }
1.4 christos 123: resetscroll();
124: return (lgetc() - '0');
125: }
CVSweb <webmaster@jp.NetBSD.org>