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