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.38 (Berkeley) 08/05/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 ":default_nline lines Set default window buffer size to `lines'", 65 ":default_shell string ...", 66 " Set default shell to `string ...'", 67 ":default_smooth flag Set default smooth scroll flag", 68 ":select # Select window #", 69 ":smooth # flag Set window # to smooth scroll mode", 70 ":source filename Execute commands in `filename'", 71 ":terse flag Set terse mode", 72 ":unalias name Undefine `name' as an alias", 73 ":unset variable Deallocate `variable'", 74 ":variable List all variables", 75 ":window [row col nrow ncol nline label pty frame mapnl keepopen smooth shell]", 76 " Open a window at `row', `col' of size `nrow', `ncol',", 77 " with `nline' lines in the buffer, and `label'", 78 ":write # string ... Write `string ...' to window # as input", 79 0 80 }; 81 82 c_help() 83 { 84 register struct ww *w; 85 86 if ((w = openiwin(wwnrow - 3, "Help")) == 0) { 87 error("Can't open help window: %s.", wwerror()); 88 return; 89 } 90 wwprintf(w, "The escape character is %c.\n", escapec); 91 wwprintf(w, "(# represents one of the digits from 1 to 9.)\n\n"); 92 if (help_print(w, "Short commands", help_shortcmd) >= 0) 93 (void) help_print(w, "Long commands", help_longcmd); 94 closeiwin(w); 95 } 96 97 help_print(w, name, list) 98 register struct ww *w; 99 char *name; 100 register char **list; 101 { 102 wwprintf(w, "%s:\n\n", name); 103 while (*list) 104 switch (more(w, 0)) { 105 case 0: 106 wwputs(*list++, w); 107 wwputc('\n', w); 108 break; 109 case 1: 110 wwprintf(w, "%s: (continued)\n\n", name); 111 break; 112 case 2: 113 return -1; 114 } 115 return more(w, 1) == 2 ? -1 : 0; 116 } 117 118 c_quit() 119 { 120 char oldterse = terse; 121 122 setterse(0); 123 wwputs("Really quit [yn]? ", cmdwin); 124 wwcurtowin(cmdwin); 125 while (wwpeekc() < 0) 126 wwiomux(); 127 if (wwgetc() == 'y') { 128 wwputs("Yes", cmdwin); 129 quit++; 130 } else 131 wwputc('\n', cmdwin); 132 setterse(!quit && oldterse); 133 } 134