Repository navigation
Expand file tree
/
Copy pathhelp.c
More file actions
executable file
·107 lines (96 loc) · 2.2 KB
/
Copy pathhelp.c
File metadata and controls
executable file
·107 lines (96 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
8000
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* Copyright (c) 1985 Ceriel J.H. Jacobs */
#ifndef lint
static char rcsid[] = "$Header$";
#endif
#define _HELP_
#include "in_all.h"
#include "help.h"
#include "machine.h"
#include "commands.h"
#include "keys.h"
#include "output.h"
#include "prompt.h"
#include "main.h"
#include "display.h"
#include "term.h"
#include "options.h"
static int h_cnt; /* Count # of lines */
static struct state *origin; /* Keep track of startstate */
/*
* Print a key sequence.
* We arrived at an endstate. The s_next link in the state structure now
* leads us from "origin" to the current state, so that we can print the key
* sequence easily.
*/
STATIC VOID
pr_comm() {
register struct state *p = origin;
register char *pb;
register int c;
char buf[30];
register int i = 0; /* How many characters printed? */
pb = buf;
for (;;) {
c = p->s_char & 0177;
if (c < ' ' || c == 0177) {
/*
* Will take an extra position
*/
i++;
}
*pb++ = c;
i++;
if (!p->s_match) break;
p = p->s_next;
}
do {
*pb++ = ' ';
} while (++i < 12);
*pb = 0;
cputline(buf);
}
/*
* Print out a description of the keymap. This is done, by temporarily using
* the s_next field in the state structure indicate the state matching the
* next character, so that we can walk from "origin" to an endstate.
*/
STATIC VOID
pr_mach(currstate, back) register struct state *currstate, *back; {
struct state *save;
while (currstate) {
if (interrupt) break;
if (back) {
save = back->s_next; /* Save original link */
back->s_next = currstate;
}
if (!currstate->s_match) {
/*
* End state, print command
*/
pr_comm();
putline(commands[currstate->s_cnt].c_descr);
putline("\r\n");
if (++h_cnt >= maxpagesize) {
ret_to_continue();
h_cnt = 0;
}
}
else pr_mach(currstate->s_match, currstate);
currstate = currstate->s_next;
if (back) back->s_next = save; /* restore */
else origin = currstate;
}
}
/*ARGSUSED*/
3A46
div>int
do_help(i) long i; { /* The help command */
startcomm = 0;
h_cnt = 2;
putline("\r\nSummary of yap commands:\r\n");
origin = currmap->k_mach;
pr_mach(currmap->k_mach, (struct state *) 0);
if (h_cnt) {
ret_to_continue();
}
if (!hardcopy && scr_info.currentpos) redraw(1);
}