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.
13 static const char sccsid[] = "@(#)v_right.c 10.7 (Berkeley) 3/6/96";
16 #include <sys/types.h>
17 #include <sys/queue.h>
20 #include <bitstring.h>
24 #include "../common/common.h"
28 * v_right -- [count]' ', [count]l
29 * Move right by columns.
31 * PUBLIC: int v_right __P((SCR *, VICMD *));
41 if (db_eget(sp, vp->m_start.lno, NULL, &len, &isempty)) {
47 /* It's always illegal to move right on empty lines. */
54 * Non-motion commands move to the end of the range. Delete and
55 * yank stay at the start. Ignore others. Adjust the end of the
56 * range for motion commands.
59 * Historically, "[cdsy]l" worked at the end of a line. Also,
60 * EOL is a count sink.
62 vp->m_stop.cno = vp->m_start.cno +
63 (F_ISSET(vp, VC_C1SET) ? vp->count : 1);
64 if (vp->m_start.cno == len - 1 && !ISMOTION(vp)) {
68 if (vp->m_stop.cno >= len) {
69 vp->m_stop.cno = len - 1;
70 vp->m_final = ISMOTION(vp) ? vp->m_start : vp->m_stop;
71 } else if (ISMOTION(vp)) {
73 vp->m_final = vp->m_start;
75 vp->m_final = vp->m_stop;
80 * v_dollar -- [count]$
81 * Move to the last column.
83 * PUBLIC: int v_dollar __P((SCR *, VICMD *));
95 * A count moves down count - 1 rows, so, "3$" is the same as "2j$".
97 if ((F_ISSET(vp, VC_C1SET) ? vp->count : 1) != 1) {
100 * Historically, if the $ is a motion, and deleting from
101 * at or before the first non-blank of the line, it's a
102 * line motion, and the line motion flag is set.
105 if (nonblank(sp, vp->m_start.lno, &vp->m_stop.cno))
107 if (ISMOTION(vp) && vp->m_start.cno <= vp->m_stop.cno)
117 * Historically, it was illegal to use $ as a motion command on
118 * an empty line. Unfortunately, even though C was historically
119 * aliased to c$, it (and not c$) was special cased to work on
120 * empty lines. Since we alias C to c$ too, we have a problem.
121 * To fix it, we let c$ go through, on the assumption that it's
122 * not a problem for it to work.
124 if (db_eget(sp, vp->m_stop.lno, NULL, &len, &isempty)) {
131 if (ISMOTION(vp) && !ISCMD(vp->rkp, 'c')) {
139 * Non-motion commands move to the end of the range. Delete
140 * and yank stay at the start. Ignore others.
142 vp->m_stop.cno = len ? len - 1 : 0;
143 vp->m_final = ISMOTION(vp) ? vp->m_start : vp->m_stop;