|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1983 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * This code is derived from software contributed to Berkeley by ! 6: * Edward Wang at The University of California, Berkeley. ! 7: * ! 8: * Redistribution and use in source and binary forms are permitted provided ! 9: * that: (1) source distributions retain this entire copyright notice and ! 10: * comment, and (2) distributions including binaries display the following ! 11: * acknowledgement: ``This product includes software developed by the ! 12: * University of California, Berkeley and its contributors'' in the ! 13: * documentation or other materials provided with the distribution and in ! 14: * all advertising materials mentioning features or use of this software. ! 15: * Neither the name of the University nor the names of its contributors may ! 16: * be used to endorse or promote products derived from this software without ! 17: * specific prior written permission. ! 18: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 19: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 20: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 21: */ ! 22: ! 23: #ifndef lint ! 24: static char sccsid[] = "@(#)cmd2.c 3.40 (Berkeley) 6/6/90"; ! 25: #endif /* not lint */ ! 26: ! 27: #include "defs.h" ! 28: ! 29: char *help_shortcmd[] = { ! 30: "# Select window # and return to conversation mode", ! 31: "%# Select window # but stay in command mode", ! 32: "escape Return to conversation mode without changing window", ! 33: "^^ Return to conversation mode and change to previous window", ! 34: "c# Close window #", ! 35: "w Open a new window", ! 36: "m# Move window #", ! 37: "M# Move window # to its previous position", ! 38: "s# Change the size of window #", ! 39: "S# Change window # to its previous size", ! 40: "^Y Scroll up one line", ! 41: "^E Scroll down one line", ! 42: "^U Scroll up half a window", ! 43: "^D Scroll down half a window", ! 44: "^B Scroll up a full window", ! 45: "^F Scroll down a full window", ! 46: "h Move cursor left", ! 47: "j Move cursor down", ! 48: "k Move cursor up", ! 49: "l Move cursor right", ! 50: "^S Stop output in current window", ! 51: "^Q Restart output in current window", ! 52: "^L Redraw screen", ! 53: "^Z Suspend", ! 54: "q Quit", ! 55: ": Enter a long command", ! 56: 0 ! 57: }; ! 58: char *help_longcmd[] = { ! 59: ":alias name string ... Make `name' an alias for `string ...'", ! 60: ":alias Show all aliases", ! 61: ":close # ... Close windows", ! 62: ":close all Close all windows", ! 63: ":cursor modes Set the cursor modes", ! 64: ":echo # string ... Print `string ...' in window #", ! 65: ":escape c Set escape character to `c'", ! 66: ":foreground # flag Make # a foreground window, if `flag' is true", ! 67: ":label # string Set label of window # to `string'", ! 68: ":list List all open windows", ! 69: ":default_nline lines Set default window buffer size to `lines'", ! 70: ":default_shell string ...", ! 71: " Set default shell to `string ...'", ! 72: ":default_smooth flag Set default smooth scroll flag", ! 73: ":select # Select window #", ! 74: ":smooth # flag Set window # to smooth scroll mode", ! 75: ":source filename Execute commands in `filename'", ! 76: ":terse flag Set terse mode", ! 77: ":unalias name Undefine `name' as an alias", ! 78: ":unset variable Deallocate `variable'", ! 79: ":variable List all variables", ! 80: ":window [row col nrow ncol nline label pty frame mapnl keepopen smooth shell]", ! 81: " Open a window at `row', `col' of size `nrow', `ncol',", ! 82: " with `nline' lines in the buffer, and `label'", ! 83: ":write # string ... Write `string ...' to window # as input", ! 84: 0 ! 85: }; ! 86: ! 87: c_help() ! 88: { ! 89: register struct ww *w; ! 90: ! 91: if ((w = openiwin(wwnrow - 3, "Help")) == 0) { ! 92: error("Can't open help window: %s.", wwerror()); ! 93: return; ! 94: } ! 95: wwprintf(w, "The escape character is %c.\n", escapec); ! 96: wwprintf(w, "(# represents one of the digits from 1 to 9.)\n\n"); ! 97: if (help_print(w, "Short commands", help_shortcmd) >= 0) ! 98: (void) help_print(w, "Long commands", help_longcmd); ! 99: closeiwin(w); ! 100: } ! 101: ! 102: help_print(w, name, list) ! 103: register struct ww *w; ! 104: char *name; ! 105: register char **list; ! 106: { ! 107: wwprintf(w, "%s:\n\n", name); ! 108: while (*list) ! 109: switch (more(w, 0)) { ! 110: case 0: ! 111: wwputs(*list++, w); ! 112: wwputc('\n', w); ! 113: break; ! 114: case 1: ! 115: wwprintf(w, "%s: (continued)\n\n", name); ! 116: break; ! 117: case 2: ! 118: return -1; ! 119: } ! 120: return more(w, 1) == 2 ? -1 : 0; ! 121: } ! 122: ! 123: c_quit() ! 124: { ! 125: char oldterse = terse; ! 126: ! 127: setterse(0); ! 128: wwputs("Really quit [yn]? ", cmdwin); ! 129: wwcurtowin(cmdwin); ! 130: while (wwpeekc() < 0) ! 131: wwiomux(); ! 132: if (wwgetc() == 'y') { ! 133: wwputs("Yes", cmdwin); ! 134: quit++; ! 135: } else ! 136: wwputc('\n', cmdwin); ! 137: setterse(!quit && oldterse); ! 138: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.