Commit | Line | Data |
---|---|---|
708ccf0a | 1 | #ifndef lint |
60de5df9 | 2 | static char sccsid[] = "@(#)cmd2.c 3.33 %G%"; |
708ccf0a EW |
3 | #endif |
4 | ||
60de5df9 EW |
5 | /* |
6 | * Copyright (c) 1983 Regents of the University of California, | |
7 | * All rights reserved. Redistribution permitted subject to | |
8 | * the terms of the Berkeley Software License Agreement. | |
9 | */ | |
10 | ||
708ccf0a EW |
11 | #include "defs.h" |
12 | ||
d4001d43 | 13 | char *help_shortcmd[] = { |
0fbd4dc4 EW |
14 | "# Select window # and return to conversation mode", |
15 | "%# Select window # but stay in command mode", | |
16 | "escape Return to conversation mode without changing window", | |
17 | "^^ Return to conversation mode and change to previous window", | |
18 | "c# Close window #", | |
19 | "w Open a new window", | |
20 | "m# Move window #", | |
21 | "M# Move window # to its previous position", | |
22 | "s# Change the size of window #", | |
23 | "S# Change window # to its previous size", | |
24 | "^Y Scroll up one line", | |
25 | "^E Scroll down one line", | |
26 | "^U Scroll up half a window", | |
27 | "^D Scroll down half a window", | |
28 | "^B Scroll up a full window", | |
29 | "^F Scroll down a full window", | |
30 | "h Move cursor left", | |
31 | "j Move cursor down", | |
32 | "k Move cursor up", | |
33 | "l Move cursor right", | |
34 | "^S Stop output in current window", | |
35 | "^Q Restart output in current window", | |
36 | "^L Redraw screen", | |
37 | "^Z Suspend", | |
38 | "q Quit", | |
39 | ": Enter a long command", | |
d4001d43 EW |
40 | 0 |
41 | }; | |
42 | char *help_longcmd[] = { | |
0fbd4dc4 EW |
43 | ":alias name string ... Make `name' an alias for `string ...'", |
44 | ":alias Show all aliases", | |
45 | ":close # ... Close windows", | |
46 | ":close all Close all windows", | |
47 | ":cursor modes Set the cursor modes", | |
48 | ":echo # string ... Print `string ...' in window #", | |
49 | ":escape c Set escape character to `c'", | |
50 | ":foreground # flag Make # a foreground window, if `flag' is true", | |
51 | ":label # string Set label of window # to `string'", | |
52 | ":list List all open windows", | |
53 | ":nline lines Set default window buffer size to `lines'", | |
54 | ":select # Select window #", | |
55 | ":shell string ... Set default shell program to `string ...'", | |
56 | ":source filename Execute commands in `filename'", | |
57 | ":terse flag Set terse mode", | |
58 | ":unalias name Undefine `name' as an alias", | |
59 | ":unset variable Deallocate `variable'", | |
60 | ":variable List all variables", | |
7ecf4dca | 61 | ":window row col nrow ncol [nline label pty frame shell]", |
0fbd4dc4 EW |
62 | " Open a window at `row', `col' of size `nrow', `ncol',", |
63 | " with `nline' lines in the buffer, and `label'", | |
64 | ":write # string ... Write `string ...' to window # as input", | |
d4001d43 EW |
65 | 0 |
66 | }; | |
67 | ||
bb05dfb5 | 68 | c_help() |
708ccf0a EW |
69 | { |
70 | register struct ww *w; | |
71 | ||
39b7960d | 72 | if ((w = openiwin(wwnrow - 3, "Help")) == 0) { |
03e75950 | 73 | error("Can't open help window: %s.", wwerror()); |
708ccf0a | 74 | return; |
8c4fb896 | 75 | } |
99fe01d3 | 76 | wwprintf(w, "The escape character is %c.\n", escapec); |
0fbd4dc4 | 77 | wwprintf(w, "(# represents one of the digits from 1 to 9.)\n\n"); |
4a972f7c EW |
78 | if (help_print(w, "Short commands", help_shortcmd) >= 0) |
79 | (void) help_print(w, "Long commands", help_longcmd); | |
bb05dfb5 | 80 | closeiwin(w); |
708ccf0a EW |
81 | } |
82 | ||
d4001d43 EW |
83 | help_print(w, name, list) |
84 | register struct ww *w; | |
85 | char *name; | |
4a972f7c | 86 | register char **list; |
d4001d43 | 87 | { |
b1189050 | 88 | wwprintf(w, "%s:\n\n", name); |
4a972f7c EW |
89 | while (*list) |
90 | switch (more(w, 0)) { | |
91 | case 0: | |
b1189050 EW |
92 | wwputs(*list++, w); |
93 | wwputc('\n', w); | |
4a972f7c EW |
94 | break; |
95 | case 1: | |
b1189050 | 96 | wwprintf(w, "%s: (continued)\n\n", name); |
4a972f7c EW |
97 | break; |
98 | case 2: | |
99 | return -1; | |
d4001d43 | 100 | } |
4a972f7c | 101 | return more(w, 1) == 2 ? -1 : 0; |
d4001d43 EW |
102 | } |
103 | ||
bb05dfb5 | 104 | c_quit() |
8c4fb896 | 105 | { |
ffa20db4 EW |
106 | char oldterse = terse; |
107 | ||
108 | setterse(0); | |
b1189050 | 109 | wwputs("Really quit [yn]? ", cmdwin); |
bb05dfb5 | 110 | wwcurtowin(cmdwin); |
8fa6d94c EW |
111 | while (wwpeekc() < 0) |
112 | wwiomux(); | |
113 | if (wwgetc() == 'y') { | |
b1189050 | 114 | wwputs("Yes", cmdwin); |
8c4fb896 EW |
115 | quit++; |
116 | } else | |
bf3b96e9 | 117 | wwputc('\n', cmdwin); |
ffa20db4 | 118 | setterse(!quit && oldterse); |
8c4fb896 | 119 | } |