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_right.c,v 8.3 1993/12/16 12:04:11 bostic Exp $ (Berkeley) $Date: 1993/12/16 12:04:11 $";
12 #include <sys/types.h>
18 * v_right -- [count]' ', [count]l
19 * Move right by columns.
21 * Special case: the 'c' and 'd' commands can move past the end of line.
24 v_right(sp
, ep
, vp
, fm
, tm
, rp
)
34 if (file_gline(sp
, ep
, fm
->lno
, &len
) == NULL
) {
35 if (file_lline(sp
, ep
, &lno
))
40 GETLINE_ERR(sp
, fm
->lno
);
45 if (len
== 0 || fm
->cno
== len
- 1) {
46 if (F_ISSET(vp
, VC_C
| VC_D
| VC_Y
)) {
54 cnt
= F_ISSET(vp
, VC_C1SET
) ? vp
->count
: 1;
55 rp
->cno
= fm
->cno
+ cnt
;
56 if (rp
->cno
> len
- 1)
57 if (F_ISSET(vp
, VC_C
| VC_D
| VC_Y
))
65 * v_dollar -- [count]$
66 * Move to the last column.
69 v_dollar(sp
, ep
, vp
, fm
, tm
, rp
)
80 * A count moves down count - 1 rows, so, "3$" is the same as "2j$".
83 * Historically, if the $ is a motion, and deleting from at or before
84 * the first non-blank of the line, it's a line motion, and the line
87 cnt
= F_ISSET(vp
, VC_C1SET
) ? vp
->count
: 1;
90 if (v_down(sp
, ep
, vp
, fm
, tm
, rp
))
93 if (nonblank(sp
, ep
, rp
->lno
, &rp
->cno
))
95 if (fm
->cno
<= rp
->cno
&& F_ISSET(vp
, VC_C
| VC_D
| VC_Y
))
100 if (file_gline(sp
, ep
, rp
->lno
, &len
) == NULL
) {
101 if (file_lline(sp
, ep
, &lno
))
106 GETLINE_ERR(sp
, rp
->lno
);
115 /* If it's a motion component, move one past the end of the line. */
116 rp
->cno
= F_ISSET(vp
, VC_C
| VC_D
| VC_Y
) ? len
: len
- 1;