date and time created 84/04/08 12:23:13 by edward
[unix-history] / usr / src / usr.bin / window / cmd2.c
CommitLineData
708ccf0a 1#ifndef lint
0e64e422 2static char *sccsid = "@(#)cmd2.c 3.27 84/04/08";
708ccf0a
EW
3#endif
4
5#include "defs.h"
6
d4001d43
EW
7char *help_shortcmd[] = {
8 "{1-9} Select window {1-9} and return to conversation mode.",
9 "%{1-9} Select window {1-9} but stay in command mode.",
e404c17a
EW
10 "escape Return to conversation mode without changing window.",
11 "^^ Return to conversation mode and change to previous window.",
d4001d43 12 "c{1-9} Close window {1-9}.",
d4001d43
EW
13 "w Open a new window.",
14 "m{1-9} Move window {1-9}.",
15 "M{1-9} Move window {1-9} to previous position.",
d4001d43
EW
16 "{^Y^E} Scroll {up, down} one line",
17 "{^U^D} Scroll {up, down} half a window.",
18 "{^B^F} Scroll {up, down} a full window.",
19 "{hjkl} Move cursor {left, down, up, right}.",
20 "^L Redraw screen.",
21 "^Z Suspend.",
22 "q Quit.",
23 0
24};
25char *help_longcmd[] = {
26 ":%{1-9} Select window {1-9}.",
e404c17a
EW
27 ":close {1-9} . . . Close windows.",
28 ":close all Close all windows.",
d4001d43
EW
29 ":cursor modes Set the cursor modes.",
30 ":escape C Set escape character to C.",
e404c17a
EW
31 ":foreground {1-9} [off]",
32 " Make {1-9} a foreground window.",
d4001d43 33 ":label {1-9} string Label window {1-9}.",
e404c17a
EW
34 ":list List all windows.",
35 ":nline lines Set the default number of lines",
36 " in window text buffers.",
d4001d43
EW
37 ":source filename Execute commands in ``filename''.",
38 ":terse [off] Turn on (or off) terse mode.",
2a3029ae 39 ":unset variable Deallocate ``variable''.",
e404c17a 40 ":variable List all variables.",
d4001d43
EW
41 ":window row col nrow ncol [nline label]",
42 " Open a window at ``row'', ``col''",
43 " of size ``nrow'', ``ncol'',",
44 " with ``nline'', and ``label''.",
e404c17a
EW
45 ":write {1-9} string . . .",
46 " Write strings to window {1-9}.",
d4001d43
EW
47 0
48};
49
bb05dfb5 50c_help()
708ccf0a
EW
51{
52 register struct ww *w;
53
39b7960d 54 if ((w = openiwin(wwnrow - 3, "Help")) == 0) {
03e75950 55 error("Can't open help window: %s.", wwerror());
708ccf0a 56 return;
8c4fb896 57 }
0e64e422
EW
58 wwprintf(w, "The escape character is %c, which gets you into command mode.\n\n",
59 escapec);
4a972f7c
EW
60 if (help_print(w, "Short commands", help_shortcmd) >= 0)
61 (void) help_print(w, "Long commands", help_longcmd);
bb05dfb5 62 closeiwin(w);
708ccf0a
EW
63}
64
d4001d43
EW
65help_print(w, name, list)
66register struct ww *w;
67char *name;
4a972f7c 68register char **list;
d4001d43 69{
b1189050 70 wwprintf(w, "%s:\n\n", name);
4a972f7c
EW
71 while (*list)
72 switch (more(w, 0)) {
73 case 0:
b1189050
EW
74 wwputs(*list++, w);
75 wwputc('\n', w);
4a972f7c
EW
76 break;
77 case 1:
b1189050 78 wwprintf(w, "%s: (continued)\n\n", name);
4a972f7c
EW
79 break;
80 case 2:
81 return -1;
d4001d43 82 }
4a972f7c 83 return more(w, 1) == 2 ? -1 : 0;
d4001d43
EW
84}
85
bb05dfb5 86c_quit()
8c4fb896 87{
ffa20db4
EW
88 char oldterse = terse;
89
90 setterse(0);
b1189050 91 wwputs("Really quit [yn]? ", cmdwin);
bb05dfb5 92 wwcurtowin(cmdwin);
8fa6d94c
EW
93 while (wwpeekc() < 0)
94 wwiomux();
95 if (wwgetc() == 'y') {
b1189050 96 wwputs("Yes", cmdwin);
8c4fb896
EW
97 quit++;
98 } else
b1189050 99 wwputs("\r\n", cmdwin);
ffa20db4 100 setterse(!quit && oldterse);
8c4fb896 101}