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_append.c,v 8.4 1993/11/05 11:08:33 bostic Exp $ (Berkeley) $Date: 1993/11/05 11:08:33 $";
12 #include <sys/types.h>
17 enum which
{APPEND
, CHANGE
};
19 static int ac
__P((SCR
*, EXF
*, EXCMDARG
*, enum which
));
22 * ex_append -- :address append[!]
23 * Append one or more lines of new text after the specified line,
24 * or the current line if no address is specified.
27 ex_append(sp
, ep
, cmdp
)
32 return (ac(sp
, ep
, cmdp
, APPEND
));
36 * ex_change -- :range change[!] [count]
37 * Change one or more lines to the input text.
40 ex_change(sp
, ep
, cmdp
)
45 return (ac(sp
, ep
, cmdp
, CHANGE
));
60 /* The ! flag turns off autoindent for change and append. */
61 if (F_ISSET(cmdp
, E_FORCE
)) {
62 aiset
= O_ISSET(sp
, O_AUTOINDENT
);
63 O_CLR(sp
, O_AUTOINDENT
);
70 * If doing a change, replace lines as long as possible.
71 * Then, append more lines, or delete remaining lines.
78 if (m
.lno
> cmdp
->addr2
.lno
) {
83 switch (sp
->s_get(sp
, ep
, &sp
->txthdr
, 0,
84 TXT_BEAUTIFY
| TXT_CR
| TXT_NLECHO
)) {
93 if (tp
->len
== 1 && tp
->lb
[0] == '.') {
94 cnt
= cmdp
->addr2
.lno
- m
.lno
;
96 if (file_dline(sp
, ep
, m
.lno
)) {
102 if (file_sline(sp
, ep
, m
.lno
, tp
->lb
, tp
->len
)) {
110 switch (sp
->s_get(sp
, ep
, &sp
->txthdr
, 0,
111 TXT_BEAUTIFY
| TXT_CR
| TXT_NLECHO
)) {
119 tp
= sp
->txthdr
.next
;
120 if (tp
->len
== 1 && tp
->lb
[0] == '.')
122 if (file_aline(sp
, ep
, 1, m
.lno
, tp
->lb
, tp
->len
)) {
132 O_SET(sp
, O_AUTOINDENT
);