xref: /original-bsd/usr.bin/window/cmd7.c (revision 331bfa8d)
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[] = "@(#)cmd7.c	3.7 (Berkeley) 06/06/90";
13 #endif /* not lint */
14 
15 #include "defs.h"
16 
17 /*
18  * Window size.
19  */
20 
21 c_size(w)
22 register struct ww *w;
23 {
24 	int col, row;
25 
26 	if (!terse)
27 		wwputs("New window size (lower right corner): ", cmdwin);
28 	col = MIN(w->ww_w.r, wwncol) - 1;
29 	row = MIN(w->ww_w.b, wwnrow) - 1;
30 	wwadd(boxwin, framewin->ww_back);
31 	for (;;) {
32 		wwbox(boxwin, w->ww_w.t - 1, w->ww_w.l - 1,
33 			row - w->ww_w.t + 3, col - w->ww_w.l + 3);
34 		wwsetcursor(row, col);
35 		while (wwpeekc() < 0)
36 			wwiomux();
37 		switch (getpos(&row, &col, w->ww_w.t, w->ww_w.l,
38 			wwnrow - 1, wwncol - 1)) {
39 		case 3:
40 			wwunbox(boxwin);
41 			wwdelete(boxwin);
42 			return;
43 		case 2:
44 			wwunbox(boxwin);
45 			break;
46 		case 1:
47 			wwunbox(boxwin);
48 		case 0:
49 			continue;
50 		}
51 		break;
52 	}
53 	wwdelete(boxwin);
54 	if (!terse)
55 		wwputc('\n', cmdwin);
56 	wwcurtowin(cmdwin);
57 	sizewin(w, row - w->ww_w.t + 1, col - w->ww_w.l + 1);
58 }
59