at(1): Print datetime upon job submission as POSIX mandates.
[dragonfly.git] / usr.bin / window / cmd2.c
blob333c92c3b5a46a9d3becfaa34a9927e0972701db
1 /* $NetBSD: cmd2.c,v 1.7 2009/04/14 08:50:06 lukem Exp $ */
3 /*
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Edward Wang at The University of California, Berkeley.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
35 #include <sys/cdefs.h>
36 #ifndef lint
37 #if 0
38 static char sccsid[] = "@(#)cmd2.c 8.1 (Berkeley) 6/6/93";
39 #else
40 __RCSID("$NetBSD: cmd2.c,v 1.7 2009/04/14 08:50:06 lukem Exp $");
41 #endif
42 #endif /* not lint */
44 #include "defs.h"
46 const char *help_shortcmd[] = {
47 "# Select window # and return to conversation mode",
48 "%# Select window # but stay in command mode",
49 "escape Return to conversation mode without changing window",
50 "^^ Return to conversation mode and change to previous window",
51 "c# Close window #",
52 "w Open a new window",
53 "m# Move window #",
54 "M# Move window # to its previous position",
55 "s# Change the size of window #",
56 "S# Change window # to its previous size",
57 "^Y Scroll up one line",
58 "^E Scroll down one line",
59 "^U Scroll up half a window",
60 "^D Scroll down half a window",
61 "^B Scroll up a full window",
62 "^F Scroll down a full window",
63 "h Move cursor left",
64 "j Move cursor down",
65 "k Move cursor up",
66 "l Move cursor right",
67 "y Yank",
68 "p Put",
69 "^S Stop output in current window",
70 "^Q Restart output in current window",
71 "^L Redraw screen",
72 "^Z Suspend",
73 "q Quit",
74 ": Enter a long command",
78 const char *help_longcmd[] = {
79 ":alias name string ... Make `name' an alias for `string ...'",
80 ":alias Show all aliases",
81 ":close # ... Close windows",
82 ":close all Close all windows",
83 ":cursor modes Set the cursor modes",
84 ":echo # string ... Print `string ...' in window #",
85 ":escape c Set escape character to `c'",
86 ":foreground # flag Make # a foreground window, if `flag' is true",
87 ":label # string Set label of window # to `string'",
88 ":list List all open windows",
89 ":default_nline lines Set default window buffer size to `lines'",
90 ":default_shell string ...",
91 " Set default shell to `string ...'",
92 ":default_smooth flag Set default smooth scroll flag",
93 ":select # Select window #",
94 ":smooth # flag Set window # to smooth scroll mode",
95 ":source filename Execute commands in `filename'",
96 ":terse flag Set terse mode",
97 ":unalias name Undefine `name' as an alias",
98 ":unset variable Deallocate `variable'",
99 ":variable List all variables",
100 ":window [row col nrow ncol nline label pty frame mapnl keepopen smooth shell]",
101 " Open a window at `row', `col' of size `nrow', `ncol',",
102 " with `nline' lines in the buffer, and `label'",
103 ":write # string ... Write `string ...' to window # as input",
107 int help_print(struct ww *, const char *, const char **);
109 void
110 c_help(void)
112 struct ww *w;
114 if ((w = openiwin(wwnrow - 3, "Help")) == 0) {
115 error("Can't open help window: %s.", wwerror());
116 return;
118 wwprintf(w, "The escape character is %c.\n", escapec);
119 wwprintf(w, "(# represents one of the digits from 1 to 9.)\n\n");
120 if (help_print(w, "Short commands", help_shortcmd) >= 0)
121 (void) help_print(w, "Long commands", help_longcmd);
122 closeiwin(w);
126 help_print(struct ww *w, const char *name, const char **list)
128 wwprintf(w, "%s:\n\n", name);
129 while (*list)
130 switch (more(w, 0)) {
131 case 0:
132 wwputs(*list++, w);
133 wwputc('\n', w);
134 break;
135 case 1:
136 wwprintf(w, "%s: (continued)\n\n", name);
137 break;
138 case 2:
139 return -1;
141 return more(w, 1) == 2 ? -1 : 0;
144 void
145 c_quit(void)
147 char oldterse = terse;
149 setterse(0);
150 wwputs("Really quit [yn]? ", cmdwin);
151 wwcurtowin(cmdwin);
152 while (wwpeekc() < 0)
153 wwiomux();
154 if (wwgetc() == 'y') {
155 wwputs("Yes", cmdwin);
156 quit++;
157 } else
158 wwputc('\n', cmdwin);
159 setterse(!quit && oldterse);