forgot to change len to save_cmdlen in push code
[nvi.git] / vi / v_z.c
blob425442791162968e226056a7a0921431eab4f50b
1 /*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
6 */
8 #ifndef lint
9 static char sccsid[] = "$Id: v_z.c,v 8.8 1993/12/02 15:19:30 bostic Exp $ (Berkeley) $Date: 1993/12/02 15:19:30 $";
10 #endif /* not lint */
12 #include <sys/types.h>
14 #include "vi.h"
15 #include "vcmd.h"
18 * v_z -- [count]z[count][-.+^<CR>]
19 * Move the screen.
21 int
22 v_z(sp, ep, vp, fm, tm, rp)
23 SCR *sp;
24 EXF *ep;
25 VICMDARG *vp;
26 MARK *fm, *tm, *rp;
28 recno_t last, lno;
29 u_int value;
32 * The first count is the line to use. If the value doesn't
33 * exist, use the last line.
35 if (F_ISSET(vp, VC_C1SET)) {
36 lno = vp->count;
37 if (file_lline(sp, ep, &last))
38 return (1);
39 if (lno > last)
40 lno = last;
41 } else
42 lno = fm->lno;
44 /* Set return cursor values. */
45 rp->lno = lno;
46 rp->cno = fm->cno;
49 * The second count is the displayed window size, i.e. the 'z'
50 * command is another way to get artificially small windows.
52 * !!!
53 * A window size of 0 was historically allowed, and simply ignored.
54 * Also, this could be much more simply done by modifying the value
55 * of the O_WINDOW option, but that's not how it worked historically.
57 if (F_ISSET(vp, VC_C2SET) &&
58 vp->count2 != 0 && sp->s_rrel(sp, vp->count2))
59 return (1);
61 switch (vp->character) {
62 case '-': /* Put the line at the bottom. */
63 if (sp->s_fill(sp, ep, lno, P_BOTTOM))
64 return (1);
65 break;
66 case '.': /* Put the line in the middle. */
67 if (sp->s_fill(sp, ep, lno, P_MIDDLE))
68 return (1);
69 break;
70 default: /* Put the line at the top for <cr>. */
71 value = term_key_val(sp, vp->character);
72 if (value != K_CR && value != K_NL) {
73 msgq(sp, M_ERR, "usage: %s.", vp->kp->usage);
74 return (1);
76 /* FALLTHROUGH */
77 case '+': /* Put the line at the top. */
78 if (sp->s_fill(sp, ep, lno, P_TOP))
79 return (1);
80 break;
81 case '^': /* Print the screen before the z- screen. */
83 * !!!
84 * Historic practice isn't real clear on this one. It seems
85 * that the command "70z^" is the same as ":70<cr>z-z^" with
86 * an off-by-one difference. So, until I find documentation
87 * to the contrary, the z^ command in this implementation
88 * displays the screen immediately before the current one.
89 * Fill the screen with the selected line at the bottom, then,
90 * scroll the screen down a page, and move to the middle line
91 * of the screen. Historic vi moved the cursor to some random
92 * place in the screen, as far as I can tell.
94 if (sp->s_fill(sp, ep, lno, P_BOTTOM))
95 return (1);
96 if (sp->s_down(sp, ep, rp, sp->t_maxrows - 1, 1))
97 return (1);
98 if (sp->s_position(sp, ep, rp, 0, P_MIDDLE))
99 return (1);
100 break;
103 /* If the map changes, have to redraw the entire screen. */
104 F_SET(sp, S_REDRAW);
106 return (0);