xref: /csrg-svn/usr.bin/window/cmd2.c (revision 18207)
113979Sedward #ifndef lint
2*18207Sedward static char sccsid[] = "@(#)cmd2.c	3.31 03/01/85";
313979Sedward #endif
413979Sedward 
513979Sedward #include "defs.h"
613979Sedward 
715675Sedward char *help_shortcmd[] = {
8*18207Sedward 	"#       Select window # and return to conversation mode.",
9*18207Sedward 	"%#      Select window # but stay in command mode.",
1016301Sedward 	"escape  Return to conversation mode without changing window.",
1116301Sedward 	"^^      Return to conversation mode and change to previous window.",
12*18207Sedward 	"c#      Close window #.",
1315675Sedward 	"w       Open a new window.",
14*18207Sedward 	"m#      Move window #.",
15*18207Sedward 	"M#      Move window # to its previous position.",
16*18207Sedward 	"s#      Change the size of window #.",
17*18207Sedward 	"S#      Change window # to its previous size.",
18*18207Sedward 	"^Y,^E   Scroll up, down one line.",
19*18207Sedward 	"^U,^D   Scroll up, down half a window.",
20*18207Sedward 	"^B,^F   Scroll up, down a full window.",
21*18207Sedward 	"h,j,k,l Move cursor left, down, up, right.",
22*18207Sedward 	"^S,^Q   Stop, start output in current window.",
2315675Sedward 	"^L      Redraw screen.",
2415675Sedward 	"^Z      Suspend.",
2515675Sedward 	"q       Quit.",
26*18207Sedward 	":       Enter a long command.",
2715675Sedward 	0
2815675Sedward };
2915675Sedward char *help_longcmd[] = {
30*18207Sedward 	":%#                   Select window #.",
31*18207Sedward 	":close # . . .        Close windows.",
3216301Sedward 	":close all            Close all windows.",
3315675Sedward 	":cursor modes         Set the cursor modes.",
34*18207Sedward 	":echo # string . . .  Print ``string . . .'' in window #.",
3515675Sedward 	":escape C             Set escape character to C.",
36*18207Sedward 	":foreground # [off]   Make # a foreground window.",
37*18207Sedward 	":label # string       Set label of window # to ``string''.",
38*18207Sedward 	":list                 Give a list of all windows.",
3916301Sedward 	":nline lines          Set the default number of lines",
4016301Sedward 	"                      in window text buffers.",
41*18207Sedward 	":shell string . . .   Set default shell program to ``string . . .''",
4216313Sedward 	":source filename      Execute commands in ``filename.''",
4315675Sedward 	":terse [off]          Turn on (or off) terse mode.",
4415845Sedward 	":unset variable       Deallocate ``variable''.",
4516301Sedward 	":variable             List all variables.",
4616313Sedward 	":window row col nrow ncol [nline label pty frame shell]",
4715675Sedward 	"                      Open a window at ``row'', ``col''",
4815675Sedward 	"                      of size ``nrow'', ``ncol'',",
4915675Sedward 	"                      with ``nline'', and ``label''.",
50*18207Sedward 	":write # string . . . Write ``string . . .'' to window #.",
5115675Sedward 	0
5215675Sedward };
5315675Sedward 
5414408Sedward c_help()
5513979Sedward {
5613979Sedward 	register struct ww *w;
5713979Sedward 
5814665Sedward 	if ((w = openiwin(wwnrow - 3, "Help")) == 0) {
5914857Sedward 		error("Can't open help window: %s.", wwerror());
6013979Sedward 		return;
6114027Sedward 	}
62*18207Sedward 	wwprintf(w, "The escape character is %c.\n", escapec);
63*18207Sedward 	wwprintf(w, "(Below, # is one of the digits from 1 to 9.)\n\n");
6415856Sedward 	if (help_print(w, "Short commands", help_shortcmd) >= 0)
6515856Sedward 		(void) help_print(w, "Long commands", help_longcmd);
6614408Sedward 	closeiwin(w);
6713979Sedward }
6813979Sedward 
6915675Sedward help_print(w, name, list)
7015675Sedward register struct ww *w;
7115675Sedward char *name;
7215856Sedward register char **list;
7315675Sedward {
7416116Sedward 	wwprintf(w, "%s:\n\n", name);
7515856Sedward 	while (*list)
7615856Sedward 		switch (more(w, 0)) {
7715856Sedward 		case 0:
7816116Sedward 			wwputs(*list++, w);
7916116Sedward 			wwputc('\n', w);
8015856Sedward 			break;
8115856Sedward 		case 1:
8216116Sedward 			wwprintf(w, "%s: (continued)\n\n", name);
8315856Sedward 			break;
8415856Sedward 		case 2:
8515856Sedward 			return -1;
8615675Sedward 		}
8715856Sedward 	return more(w, 1) == 2 ? -1 : 0;
8815675Sedward }
8915675Sedward 
9014408Sedward c_quit()
9114027Sedward {
9216281Sedward 	char oldterse = terse;
9316281Sedward 
9416281Sedward 	setterse(0);
9516116Sedward 	wwputs("Really quit [yn]? ", cmdwin);
9614408Sedward 	wwcurtowin(cmdwin);
9715872Sedward 	while (wwpeekc() < 0)
9815872Sedward 		wwiomux();
9915872Sedward 	if (wwgetc() == 'y') {
10016116Sedward 		wwputs("Yes", cmdwin);
10114027Sedward 		quit++;
10214027Sedward 	} else
10316312Sedward 		wwputc('\n', cmdwin);
10416281Sedward 	setterse(!quit && oldterse);
10514027Sedward }
106