2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
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 $";
12 #include <sys/types.h>
18 * v_z -- [count]z[count][-.+^<CR>]
22 v_z(sp
, ep
, vp
, fm
, tm
, rp
)
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
)) {
37 if (file_lline(sp
, ep
, &last
))
44 /* Set return cursor values. */
49 * The second count is the displayed window size, i.e. the 'z'
50 * command is another way to get artificially small windows.
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
))
61 switch (vp
->character
) {
62 case '-': /* Put the line at the bottom. */
63 if (sp
->s_fill(sp
, ep
, lno
, P_BOTTOM
))
66 case '.': /* Put the line in the middle. */
67 if (sp
->s_fill(sp
, ep
, lno
, P_MIDDLE
))
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
);
77 case '+': /* Put the line at the top. */
78 if (sp
->s_fill(sp
, ep
, lno
, P_TOP
))
81 case '^': /* Print the screen before the z- screen. */
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
))
96 if (sp
->s_down(sp
, ep
, rp
, sp
->t_maxrows
- 1, 1))
98 if (sp
->s_position(sp
, ep
, rp
, 0, P_MIDDLE
))
103 /* If the map changes, have to redraw the entire screen. */