add EX_AUTOPRINT flag to ex private structure, replaces S_AUTOPRINT
[nvi.git] / ex / ex_delete.c
blob99391dd4b59f69aa4563bcf9aea42acfc5526fe8
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.4 1993/12/29 09:50:49 bostic Exp $ (Berkeley) $Date: 1993/12/29 09:50:49 $";
10 #endif /* not lint */
12 #include <sys/types.h>
14 #include "vi.h"
15 #include "excmd.h"
18 * ex_delete: [line [,line]] d[elete] [buffer] [count] [flags]
20 * Delete lines from the file.
22 int
23 ex_delete(sp, ep, cmdp)
24 SCR *sp;
25 EXF *ep;
26 EXCMDARG *cmdp;
28 recno_t lno;
30 /* Yank the lines. */
31 if (cut(sp, ep,
32 F_ISSET(cmdp, E_BUFFER) ? cmdp->buffer : DEFCB,
33 &cmdp->addr1, &cmdp->addr2, 1))
34 return (1);
36 /* Delete the lines. */
37 if (delete(sp, ep, &cmdp->addr1, &cmdp->addr2, 1))
38 return (1);
40 /* Set the cursor to the line after the last line deleted. */
41 sp->lno = cmdp->addr1.lno;
43 /* Or the last line in the file if deleted to the end of the file. */
44 if (file_lline(sp, ep, &lno))
45 return (1);
46 if (sp->lno > lno)
47 sp->lno = lno;
48 return (0);