rework ARGS structures as part of ex parser rework
[nvi.git] / ex / ex_delete.c
blob83b9b557ea863993eede78fba79730fc10e8a3ac
1 /*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
6 */
8 #ifndef lint
9 static char sccsid[] = "$Id: ex_delete.c,v 8.3 1993/11/04 16:16:54 bostic Exp $ (Berkeley) $Date: 1993/11/04 16:16:54 $";
10 #endif /* not lint */
12 #include <sys/types.h>
14 #include "vi.h"
15 #include "excmd.h"
17 int
18 ex_delete(sp, ep, cmdp)
19 SCR *sp;
20 EXF *ep;
21 EXCMDARG *cmdp;
23 recno_t lno;
25 /* Yank the lines. */
26 if (cut(sp, ep,
27 F_ISSET(cmdp, E_BUFFER) ? cmdp->buffer : DEFCB,
28 &cmdp->addr1, &cmdp->addr2, 1))
29 return (1);
31 /* Delete the lines. */
32 if (delete(sp, ep, &cmdp->addr1, &cmdp->addr2, 1))
33 return (1);
35 /* Set the cursor to the line after the last line deleted. */
36 sp->lno = cmdp->addr1.lno;
38 /* Or the last line in the file if deleted to the end of the file. */
39 if (file_lline(sp, ep, &lno))
40 return (1);
41 if (sp->lno > lno)
42 sp->lno = lno;
44 /* Set autoprint. */
45 F_SET(sp, S_AUTOPRINT);
47 return (0);