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