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