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_yank.c,v 8.11 1994/01/09 14:21:17 bostic Exp $ (Berkeley) $Date: 1994/01/09 14:21:17 $";
12 #include <sys/types.h>
18 * v_Yank -- [buffer][count]Y
19 * Yank lines of text into a cut buffer.
22 v_Yank(sp
, ep
, vp
, fm
, tm
, rp
)
28 if (file_gline(sp
, ep
, tm
->lno
, NULL
) == NULL
) {
32 if (cut(sp
, ep
, NULL
, F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
,
33 fm
, tm
, CUT_LINEMODE
))
36 sp
->rptlines
[L_YANKED
] += (tm
->lno
- fm
->lno
) + 1;
41 * v_yank -- [buffer][count]y[count][motion]
42 * Yank text (or lines of text) into a cut buffer.
45 v_yank(sp
, ep
, vp
, fm
, tm
, rp
)
51 if (F_ISSET(vp
, VC_LMODE
)) {
52 if (file_gline(sp
, ep
, tm
->lno
, NULL
) == NULL
) {
57 NULL
, F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
,
58 fm
, tm
, CUT_LINEMODE
))
60 } else if (cut(sp
, ep
,
61 NULL
, F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
, fm
, tm
, 0))
66 * Historic vi moved the cursor to the from MARK if it was before the
67 * current cursor. This makes no sense. For example, "yj" moves the
68 * cursor but "yk" does not. Unfortunately, it's too late to change
69 * this now. Matching the historic semantics isn't easy. The line
70 * number was always changed and column movement was usually relative.
71 * However, "y'a" moved the cursor to the first non-blank of the line
72 * marked by a, while "y`a" moved the cursor to the line and column
75 if (F_ISSET(vp
, VC_REVMOVE
)) {
77 if (vp
->mkp
== &vikeys
['\'']) {
79 (void)nonblank(sp
, ep
, rp
->lno
, &rp
->cno
);
80 } else if (vp
->mkp
== &vikeys
['`'])
83 rp
->cno
= sp
->s_relative(sp
, ep
, rp
->lno
);
86 sp
->rptlines
[L_YANKED
] += (tm
->lno
- fm
->lno
) + 1;