new options to "window": shell, pty, frame
[unix-history] / usr / src / usr.bin / window / cmd2.c
CommitLineData
708ccf0a 1#ifndef lint
7ecf4dca 2static char *sccsid = "@(#)cmd2.c 3.29 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.",
7ecf4dca
EW
37 ":shell string Set default shell program to ``string.''",
38 ":source filename Execute commands in ``filename.''",
d4001d43 39 ":terse [off] Turn on (or off) terse mode.",
2a3029ae 40 ":unset variable Deallocate ``variable''.",
e404c17a 41 ":variable List all variables.",
7ecf4dca 42 ":window row col nrow ncol [nline label pty frame shell]",
d4001d43
EW
43 " Open a window at ``row'', ``col''",
44 " of size ``nrow'', ``ncol'',",
45 " with ``nline'', and ``label''.",
e404c17a
EW
46 ":write {1-9} string . . .",
47 " Write strings to window {1-9}.",
d4001d43
EW
48 0
49};
50
bb05dfb5 51c_help()
708ccf0a
EW
52{
53 register struct ww *w;
54
39b7960d 55 if ((w = openiwin(wwnrow - 3, "Help")) == 0) {
03e75950 56 error("Can't open help window: %s.", wwerror());
708ccf0a 57 return;
8c4fb896 58 }
0e64e422
EW
59 wwprintf(w, "The escape character is %c, which gets you into command mode.\n\n",
60 escapec);
4a972f7c
EW
61 if (help_print(w, "Short commands", help_shortcmd) >= 0)
62 (void) help_print(w, "Long commands", help_longcmd);
bb05dfb5 63 closeiwin(w);
708ccf0a
EW
64}
65
d4001d43
EW
66help_print(w, name, list)
67register struct ww *w;
68char *name;
4a972f7c 69register char **list;
d4001d43 70{
b1189050 71 wwprintf(w, "%s:\n\n", name);
4a972f7c
EW
72 while (*list)
73 switch (more(w, 0)) {
74 case 0:
b1189050
EW
75 wwputs(*list++, w);
76 wwputc('\n', w);
4a972f7c
EW
77 break;
78 case 1:
b1189050 79 wwprintf(w, "%s: (continued)\n\n", name);
4a972f7c
EW
80 break;
81 case 2:
82 return -1;
d4001d43 83 }
4a972f7c 84 return more(w, 1) == 2 ? -1 : 0;
d4001d43
EW
85}
86
bb05dfb5 87c_quit()
8c4fb896 88{
ffa20db4
EW
89 char oldterse = terse;
90
91 setterse(0);
b1189050 92 wwputs("Really quit [yn]? ", cmdwin);
bb05dfb5 93 wwcurtowin(cmdwin);
8fa6d94c
EW
94 while (wwpeekc() < 0)
95 wwiomux();
96 if (wwgetc() == 'y') {
b1189050 97 wwputs("Yes", cmdwin);
8c4fb896
EW
98 quit++;
99 } else
bf3b96e9 100 wwputc('\n', cmdwin);
ffa20db4 101 setterse(!quit && oldterse);
8c4fb896 102}