2 * Copyright (c) 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1992, 1993, 1994, 1995, 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
12 #include <sys/types.h>
13 #include <sys/queue.h>
16 #include <bitstring.h>
20 #include "../common/common.h"
24 * v_z -- [count]z[count][-.+^<CR>]
27 * PUBLIC: int v_z(SCR *, VICMD *);
30 v_z(SCR *sp, VICMD *vp)
36 * The first count is the line to use. If the value doesn't
37 * exist, use the last line.
39 if (F_ISSET(vp, VC_C1SET)) {
41 if (!db_exist(sp, lno) && db_last(sp, &lno))
44 lno = vp->m_start.lno;
46 /* Set default return cursor line. */
47 vp->m_final.lno = lno;
48 vp->m_final.cno = vp->m_start.cno;
51 * The second count is the displayed window size, i.e. the 'z' command
52 * is another way to get artificially small windows. Note, you can't
53 * grow beyond the size of the window.
56 * A window size of 0 was historically allowed, and simply ignored.
57 * This could be much more simply done by modifying the value of the
58 * O_WINDOW option, but that's not how it worked historically.
60 if (F_ISSET(vp, VC_C2SET) && vp->count2 != 0) {
61 if (vp->count2 > O_VAL(sp, O_WINDOW))
62 vp->count2 = O_VAL(sp, O_WINDOW);
63 if (vs_crel(sp, vp->count2))
67 switch (vp->character) {
68 case '-': /* Put the line at the bottom. */
69 if (vs_sm_fill(sp, lno, P_BOTTOM))
72 case '.': /* Put the line in the middle. */
73 if (vs_sm_fill(sp, lno, P_MIDDLE))
78 * If the user specified a line number, put that line at the
79 * top and move the cursor to it. Otherwise, scroll forward
80 * a screen from the current screen.
82 if (F_ISSET(vp, VC_C1SET)) {
83 if (vs_sm_fill(sp, lno, P_TOP))
85 if (vs_sm_position(sp, &vp->m_final, 0, P_TOP))
88 if (vs_sm_scroll(sp, &vp->m_final, sp->t_rows, Z_PLUS))
93 * If the user specified a line number, put that line at the
94 * bottom, move the cursor to it, and then display the screen
95 * before that one. Otherwise, scroll backward a screen from
99 * Note, we match the off-by-one characteristics of historic
102 if (F_ISSET(vp, VC_C1SET)) {
103 if (vs_sm_fill(sp, lno, P_BOTTOM))
105 if (vs_sm_position(sp, &vp->m_final, 0, P_TOP))
107 if (vs_sm_fill(sp, vp->m_final.lno, P_BOTTOM))
110 if (vs_sm_scroll(sp, &vp->m_final, sp->t_rows, Z_CARAT))
113 default: /* Put the line at the top for <cr>. */
114 value = KEY_VAL(sp, vp->character);
115 if (value != K_CR && value != K_NL) {
116 v_emsg(sp, vp->kp->usage, VIM_USAGE);
119 if (vs_sm_fill(sp, lno, P_TOP))
128 * Change the relative size of the current screen.
130 * PUBLIC: int vs_crel(SCR *, long);
133 vs_crel(SCR *sp, long int count)
135 sp->t_minrows = sp->t_rows = count;
136 if (sp->t_rows > sp->rows - 1)
137 sp->t_minrows = sp->t_rows = sp->rows - 1;
138 TMAP = HMAP + (sp->t_rows - 1);
139 F_SET(sp, SC_SCR_REDRAW);