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_init.c,v 8.11 1994/01/09 16:45:46 bostic Exp $ (Berkeley) $Date: 1994/01/09 16:45:46 $";
12 #include <sys/types.h>
27 ex_screen_copy(orig
, sp
)
30 EX_PRIVATE
*oexp
, *nexp
;
32 /* Create the private ex structure. */
33 CALLOC_RET(orig
, nexp
, EX_PRIVATE
*, 1, sizeof(EX_PRIVATE
));
34 sp
->ex_private
= nexp
;
36 /* Initialize queues. */
37 TAILQ_INIT(&nexp
->tagq
);
38 TAILQ_INIT(&nexp
->tagfq
);
39 CIRCLEQ_INIT(&nexp
->rangeq
);
42 nexp
->at_lbuf_set
= 0;
46 nexp
->at_lbuf
= oexp
->at_lbuf
;
47 nexp
->at_lbuf_set
= oexp
->at_lbuf_set
;
49 if (oexp
->lastbcomm
!= NULL
&&
50 (nexp
->lastbcomm
= strdup(oexp
->lastbcomm
)) == NULL
) {
51 msgq(sp
, M_SYSERR
, NULL
);
55 if (ex_tagcopy(orig
, sp
))
59 nexp
->lastcmd
= &cmds
[C_PRINT
];
81 FREE(exp
->ibp
, exp
->ibp_len
);
83 if (exp
->lastbcomm
!= NULL
)
84 FREE(exp
->lastbcomm
, strlen(exp
->lastbcomm
) + 1);
86 /* Free private memory. */
87 FREE(exp
, sizeof(EX_PRIVATE
));
88 sp
->ex_private
= NULL
;
105 * The default address is the last line of the file. If the address
106 * set bit is on for this file, load the address, ensuring that it
109 if (F_ISSET(sp
->frp
, FR_CURSORSET
)) {
110 sp
->lno
= sp
->frp
->lno
;
111 sp
->cno
= sp
->frp
->cno
;
113 if (file_gline(sp
, ep
, sp
->lno
, &len
) == NULL
) {
114 if (file_lline(sp
, ep
, &sp
->lno
))
119 } else if (sp
->cno
>= len
)
122 if (file_lline(sp
, ep
, &sp
->lno
))
129 /* Display the status line. */
130 return (status(sp
, ep
, sp
->lno
, 0));
141 /* Save the cursor location. */
142 sp
->frp
->lno
= sp
->lno
;
143 sp
->frp
->cno
= sp
->cno
;
144 F_SET(sp
->frp
, FR_CURSORSET
);
151 * Handle change of options for vi.
154 ex_optchange(sp
, opt
)
160 return (ex_tagalloc(sp
, O_STR(sp
, O_TAGS
)));