2 * Copyright (c) 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1992, 1993, 1994, 1995, 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
13 static const char sccsid[] = "$Id: v_init.c,v 10.10 2012/02/11 00:33:46 zy Exp $";
16 #include <sys/types.h>
17 #include <sys/queue.h>
20 #include <bitstring.h>
27 #include "../common/common.h"
34 * PUBLIC: int v_screen_copy(SCR *, SCR *);
37 v_screen_copy(SCR *orig, SCR *sp)
39 VI_PRIVATE *ovip, *nvip;
41 /* Create the private vi structure. */
42 CALLOC_RET(orig, nvip, VI_PRIVATE *, 1, sizeof(VI_PRIVATE));
43 sp->vi_private = nvip;
45 /* Invalidate the line size cache. */
49 nvip->csearchdir = CNOTSET;
53 /* User can replay the last input, but nothing else. */
54 if (ovip->rep_len != 0) {
55 MALLOC_RET(orig, nvip->rep, EVENT *, ovip->rep_len);
56 memmove(nvip->rep, ovip->rep, ovip->rep_len);
57 nvip->rep_len = ovip->rep_len;
60 /* Copy the match characters information. */
61 if (ovip->mcs != NULL && (nvip->mcs =
62 v_wstrdup(sp, ovip->mcs, STRLEN(ovip->mcs))) == NULL)
65 /* Copy the paragraph/section information. */
66 if (ovip->ps != NULL && (nvip->ps =
67 v_strdup(sp, ovip->ps, strlen(ovip->ps))) == NULL)
70 nvip->lastckey = ovip->lastckey;
71 nvip->csearchdir = ovip->csearchdir;
73 nvip->srows = ovip->srows;
82 * PUBLIC: int v_screen_end(SCR *);
89 if ((vip = VIP(sp)) == NULL)
91 if (vip->keyw != NULL)
104 sp->vi_private = NULL;
111 * Handle change of options for vi.
113 * PUBLIC: int v_optchange(SCR *, int, char *, u_long *);
116 v_optchange(SCR *sp, int offset, char *str, u_long *valp)
120 return (v_buildmcs(sp, str));
122 return (v_buildps(sp, str, O_STR(sp, O_SECTIONS)));
124 return (v_buildps(sp, O_STR(sp, O_PARAGRAPHS), str));
126 return (vs_crel(sp, *valp));