1 /* @(#)cmd2.c 8.1 (Berkeley) 6/6/93 */
2 /* $NetBSD: cmd2.c,v 1.7 2009/04/14 08:50:06 lukem Exp $ */
5 * Copyright (c) 1983, 1993
6 * The Regents of the University of California. All rights reserved.
8 * This code is derived from software contributed to Berkeley by
9 * Edward Wang at The University of California, Berkeley.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 const char *help_shortcmd
[] = {
39 "# Select window # and return to conversation mode",
40 "%# Select window # but stay in command mode",
41 "escape Return to conversation mode without changing window",
42 "^^ Return to conversation mode and change to previous window",
44 "w Open a new window",
46 "M# Move window # to its previous position",
47 "s# Change the size of window #",
48 "S# Change window # to its previous size",
49 "^Y Scroll up one line",
50 "^E Scroll down one line",
51 "^U Scroll up half a window",
52 "^D Scroll down half a window",
53 "^B Scroll up a full window",
54 "^F Scroll down a full window",
58 "l Move cursor right",
61 "^S Stop output in current window",
62 "^Q Restart output in current window",
66 ": Enter a long command",
70 const char *help_longcmd
[] = {
71 ":alias name string ... Make `name' an alias for `string ...'",
72 ":alias Show all aliases",
73 ":close # ... Close windows",
74 ":close all Close all windows",
75 ":cursor modes Set the cursor modes",
76 ":echo # string ... Print `string ...' in window #",
77 ":escape c Set escape character to `c'",
78 ":foreground # flag Make # a foreground window, if `flag' is true",
79 ":label # string Set label of window # to `string'",
80 ":list List all open windows",
81 ":default_nline lines Set default window buffer size to `lines'",
82 ":default_shell string ...",
83 " Set default shell to `string ...'",
84 ":default_smooth flag Set default smooth scroll flag",
85 ":select # Select window #",
86 ":smooth # flag Set window # to smooth scroll mode",
87 ":source filename Execute commands in `filename'",
88 ":terse flag Set terse mode",
89 ":unalias name Undefine `name' as an alias",
90 ":unset variable Deallocate `variable'",
91 ":variable List all variables",
92 ":window [row col nrow ncol nline label pty frame mapnl keepopen smooth shell]",
93 " Open a window at `row', `col' of size `nrow', `ncol',",
94 " with `nline' lines in the buffer, and `label'",
95 ":write # string ... Write `string ...' to window # as input",
99 int help_print(struct ww
*, const char *, const char **);
106 if ((w
= openiwin(wwnrow
- 3, "Help")) == NULL
) {
107 error("Can't open help window: %s.", wwerror());
110 wwprintf(w
, "The escape character is %c.\n", escapec
);
111 wwprintf(w
, "(# represents one of the digits from 1 to 9.)\n\n");
112 if (help_print(w
, "Short commands", help_shortcmd
) >= 0)
113 (void) help_print(w
, "Long commands", help_longcmd
);
118 help_print(struct ww
*w
, const char *name
, const char **list
)
120 wwprintf(w
, "%s:\n\n", name
);
122 switch (more(w
, 0)) {
128 wwprintf(w
, "%s: (continued)\n\n", name
);
133 return more(w
, 1) == 2 ? -1 : 0;
139 char oldterse
= terse
;
142 wwputs("Really quit [yn]? ", cmdwin
);
144 while (wwpeekc() < 0)
146 if (wwgetc() == 'y') {
147 wwputs("Yes", cmdwin
);
150 wwputc('\n', cmdwin
);
151 setterse(!quit
&& oldterse
);