Annotation of src/usr.bin/window/cmd2.c, Revision 1.1
1.1 ! deraadt 1: /* $NetBSD: cmd2.c,v 1.3 1995/09/28 10:34:05 tls Exp $ */
! 2:
! 3: /*
! 4: * Copyright (c) 1983, 1993
! 5: * The Regents of the University of California. All rights reserved.
! 6: *
! 7: * This code is derived from software contributed to Berkeley by
! 8: * Edward Wang at The University of California, Berkeley.
! 9: *
! 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. All advertising materials mentioning features or use of this software
! 19: * must display the following acknowledgement:
! 20: * This product includes software developed by the University of
! 21: * California, Berkeley and its contributors.
! 22: * 4. Neither the name of the University nor the names of its contributors
! 23: * may be used to endorse or promote products derived from this software
! 24: * without specific prior written permission.
! 25: *
! 26: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 27: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 28: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 29: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 30: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 31: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 32: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 33: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 34: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 35: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 36: * SUCH DAMAGE.
! 37: */
! 38:
! 39: #ifndef lint
! 40: #if 0
! 41: static char sccsid[] = "@(#)cmd2.c 8.1 (Berkeley) 6/6/93";
! 42: #else
! 43: static char rcsid[] = "$NetBSD: cmd2.c,v 1.3 1995/09/28 10:34:05 tls Exp $";
! 44: #endif
! 45: #endif /* not lint */
! 46:
! 47: #include "defs.h"
! 48:
! 49: char *help_shortcmd[] = {
! 50: "# Select window # and return to conversation mode",
! 51: "%# Select window # but stay in command mode",
! 52: "escape Return to conversation mode without changing window",
! 53: "^^ Return to conversation mode and change to previous window",
! 54: "c# Close window #",
! 55: "w Open a new window",
! 56: "m# Move window #",
! 57: "M# Move window # to its previous position",
! 58: "s# Change the size of window #",
! 59: "S# Change window # to its previous size",
! 60: "^Y Scroll up one line",
! 61: "^E Scroll down one line",
! 62: "^U Scroll up half a window",
! 63: "^D Scroll down half a window",
! 64: "^B Scroll up a full window",
! 65: "^F Scroll down a full window",
! 66: "h Move cursor left",
! 67: "j Move cursor down",
! 68: "k Move cursor up",
! 69: "l Move cursor right",
! 70: "y Yank",
! 71: "p Put",
! 72: "^S Stop output in current window",
! 73: "^Q Restart output in current window",
! 74: "^L Redraw screen",
! 75: "^Z Suspend",
! 76: "q Quit",
! 77: ": Enter a long command",
! 78: 0
! 79: };
! 80: char *help_longcmd[] = {
! 81: ":alias name string ... Make `name' an alias for `string ...'",
! 82: ":alias Show all aliases",
! 83: ":close # ... Close windows",
! 84: ":close all Close all windows",
! 85: ":cursor modes Set the cursor modes",
! 86: ":echo # string ... Print `string ...' in window #",
! 87: ":escape c Set escape character to `c'",
! 88: ":foreground # flag Make # a foreground window, if `flag' is true",
! 89: ":label # string Set label of window # to `string'",
! 90: ":list List all open windows",
! 91: ":default_nline lines Set default window buffer size to `lines'",
! 92: ":default_shell string ...",
! 93: " Set default shell to `string ...'",
! 94: ":default_smooth flag Set default smooth scroll flag",
! 95: ":select # Select window #",
! 96: ":smooth # flag Set window # to smooth scroll mode",
! 97: ":source filename Execute commands in `filename'",
! 98: ":terse flag Set terse mode",
! 99: ":unalias name Undefine `name' as an alias",
! 100: ":unset variable Deallocate `variable'",
! 101: ":variable List all variables",
! 102: ":window [row col nrow ncol nline label pty frame mapnl keepopen smooth shell]",
! 103: " Open a window at `row', `col' of size `nrow', `ncol',",
! 104: " with `nline' lines in the buffer, and `label'",
! 105: ":write # string ... Write `string ...' to window # as input",
! 106: 0
! 107: };
! 108:
! 109: c_help()
! 110: {
! 111: register struct ww *w;
! 112:
! 113: if ((w = openiwin(wwnrow - 3, "Help")) == 0) {
! 114: error("Can't open help window: %s.", wwerror());
! 115: return;
! 116: }
! 117: wwprintf(w, "The escape character is %c.\n", escapec);
! 118: wwprintf(w, "(# represents one of the digits from 1 to 9.)\n\n");
! 119: if (help_print(w, "Short commands", help_shortcmd) >= 0)
! 120: (void) help_print(w, "Long commands", help_longcmd);
! 121: closeiwin(w);
! 122: }
! 123:
! 124: help_print(w, name, list)
! 125: register struct ww *w;
! 126: char *name;
! 127: register char **list;
! 128: {
! 129: wwprintf(w, "%s:\n\n", name);
! 130: while (*list)
! 131: switch (more(w, 0)) {
! 132: case 0:
! 133: wwputs(*list++, w);
! 134: wwputc('\n', w);
! 135: break;
! 136: case 1:
! 137: wwprintf(w, "%s: (continued)\n\n", name);
! 138: break;
! 139: case 2:
! 140: return -1;
! 141: }
! 142: return more(w, 1) == 2 ? -1 : 0;
! 143: }
! 144:
! 145: c_quit()
! 146: {
! 147: char oldterse = terse;
! 148:
! 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);
! 160: }