1: #ifndef lint 2: static char sccsid[] = "@(#)cmd2.c 3.33 4/24/85"; 3: #endif 4: 5: /* 6: * Copyright (c) 1983 Regents of the University of California, 7: * All rights reserved. Redistribution permitted subject to 8: * the terms of the Berkeley Software License Agreement. 9: */ 10: 11: #include "defs.h" 12: 13: char *help_shortcmd[] = { 14: "# Select window # and return to conversation mode", 15: "%# Select window # but stay in command mode", 16: "escape Return to conversation mode without changing window", 17: "^^ Return to conversation mode and change to previous window", 18: "c# Close window #", 19: "w Open a new window", 20: "m# Move window #", 21: "M# Move window # to its previous position", 22: "s# Change the size of window #", 23: "S# Change window # to its previous size", 24: "^Y Scroll up one line", 25: "^E Scroll down one line", 26: "^U Scroll up half a window", 27: "^D Scroll down half a window", 28: "^B Scroll up a full window", 29: "^F Scroll down a full window", 30: "h Move cursor left", 31: "j Move cursor down", 32: "k Move cursor up", 33: "l Move cursor right", 34: "^S Stop output in current window", 35: "^Q Restart output in current window", 36: "^L Redraw screen", 37: "^Z Suspend", 38: "q Quit", 39: ": Enter a long command", 40: 0 41: }; 42: char *help_longcmd[] = { 43: ":alias name string ... Make `name' an alias for `string ...'", 44: ":alias Show all aliases", 45: ":close # ... Close windows", 46: ":close all Close all windows", 47: ":cursor modes Set the cursor modes", 48: ":echo # string ... Print `string ...' in window #", 49: ":escape c Set escape character to `c'", 50: ":foreground # flag Make # a foreground window, if `flag' is true", 51: ":label # string Set label of window # to `string'", 52: ":list List all open windows", 53: ":nline lines Set default window buffer size to `lines'", 54: ":select # Select window #", 55: ":shell string ... Set default shell program to `string ...'", 56: ":source filename Execute commands in `filename'", 57: ":terse flag Set terse mode", 58: ":unalias name Undefine `name' as an alias", 59: ":unset variable Deallocate `variable'", 60: ":variable List all variables", 61: ":window row col nrow ncol [nline label pty frame shell]", 62: " Open a window at `row', `col' of size `nrow', `ncol',", 63: " with `nline' lines in the buffer, and `label'", 64: ":write # string ... Write `string ...' to window # as input", 65: 0 66: }; 67: 68: c_help() 69: { 70: register struct ww *w; 71: 72: if ((w = openiwin(wwnrow - 3, "Help")) == 0) { 73: error("Can't open help window: %s.", wwerror()); 74: return; 75: } 76: wwprintf(w, "The escape character is %c.\n", escapec); 77: wwprintf(w, "(# represents one of the digits from 1 to 9.)\n\n"); 78: if (help_print(w, "Short commands", help_shortcmd) >= 0) 79: (void) help_print(w, "Long commands", help_longcmd); 80: closeiwin(w); 81: } 82: 83: help_print(w, name, list) 84: register struct ww *w; 85: char *name; 86: register char **list; 87: { 88: wwprintf(w, "%s:\n\n", name); 89: while (*list) 90: switch (more(w, 0)) { 91: case 0: 92: wwputs(*list++, w); 93: wwputc('\n', w); 94: break; 95: case 1: 96: wwprintf(w, "%s: (continued)\n\n", name); 97: break; 98: case 2: 99: return -1; 100: } 101: return more(w, 1) == 2 ? -1 : 0; 102: } 103: 104: c_quit() 105: { 106: char oldterse = terse; 107: 108: setterse(0); 109: wwputs("Really quit [yn]? ", cmdwin); 110: wwcurtowin(cmdwin); 111: while (wwpeekc() < 0) 112: wwiomux(); 113: if (wwgetc() == 'y') { 114: wwputs("Yes", cmdwin); 115: quit++; 116: } else 117: wwputc('\n', cmdwin); 118: setterse(!quit && oldterse); 119: }