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: ex_move.c,v 8.2 1993/07/21 09:00:31 bostic Exp $ (Berkeley) $Date: 1993/07/21 09:00:31 $";
12 #include <sys/types.h>
17 enum which
{COPY
, MOVE
};
18 static int cm
__P((SCR
*, EXF
*, EXCMDARG
*, enum which
));
21 * ex_copy -- :[line [,line]] co[py] line [flags]
22 * Copy selected lines.
30 return (cm(sp
, ep
, cmdp
, COPY
));
34 * ex_move -- :[line [,line]] co[py] line
35 * Move selected lines.
43 return (cm(sp
, ep
, cmdp
, MOVE
));
58 tm
.lno
= cmdp
->lineno
;
61 /* Make sure the destination is valid. */
62 if (cmd
== MOVE
&& tm
.lno
>= fm1
.lno
&& tm
.lno
< fm2
.lno
) {
64 "Destination line is inside move range.");
68 /* Save the text to a cut buffer. */
69 if (cut(sp
, ep
, DEFCB
, &fm1
, &fm2
, 1))
72 /* If we're not copying, delete the old text & adjust tm. */
74 if (delete(sp
, ep
, &fm1
, &fm2
, 1))
76 if (tm
.lno
>= fm1
.lno
)
77 tm
.lno
-= (fm2
.lno
- fm1
.lno
) + 1;
80 /* Add the new text. */
83 if (put(sp
, ep
, DEFCB
, &tm
, &m
, 1))
89 if (file_lline(sp
, ep
, &lline
))
97 COPY
? L_COPIED
: L_MOVED
] += (fm2
.lno
- fm1
.lno
) + 1;
99 F_SET(sp
, S_AUTOPRINT
);