chared.h revision 1.21 1 1.21 christos /* $NetBSD: chared.h,v 1.21 2010/08/28 15:44:59 christos Exp $ */
2 1.2 lukem
3 1.1 cgd /*-
4 1.1 cgd * Copyright (c) 1992, 1993
5 1.1 cgd * The Regents of the University of California. All rights reserved.
6 1.1 cgd *
7 1.1 cgd * This code is derived from software contributed to Berkeley by
8 1.1 cgd * Christos Zoulas of Cornell University.
9 1.1 cgd *
10 1.1 cgd * Redistribution and use in source and binary forms, with or without
11 1.1 cgd * modification, are permitted provided that the following conditions
12 1.1 cgd * are met:
13 1.1 cgd * 1. Redistributions of source code must retain the above copyright
14 1.1 cgd * notice, this list of conditions and the following disclaimer.
15 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 cgd * notice, this list of conditions and the following disclaimer in the
17 1.1 cgd * documentation and/or other materials provided with the distribution.
18 1.12 agc * 3. Neither the name of the University nor the names of its contributors
19 1.1 cgd * may be used to endorse or promote products derived from this software
20 1.1 cgd * without specific prior written permission.
21 1.1 cgd *
22 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.1 cgd * SUCH DAMAGE.
33 1.1 cgd *
34 1.1 cgd * @(#)chared.h 8.1 (Berkeley) 6/4/93
35 1.1 cgd */
36 1.1 cgd
37 1.1 cgd /*
38 1.1 cgd * el.chared.h: Character editor interface
39 1.1 cgd */
40 1.1 cgd #ifndef _h_el_chared
41 1.5 lukem #define _h_el_chared
42 1.1 cgd
43 1.1 cgd #include <ctype.h>
44 1.1 cgd #include <string.h>
45 1.1 cgd
46 1.1 cgd #include "histedit.h"
47 1.1 cgd
48 1.5 lukem #define EL_MAXMACRO 10
49 1.1 cgd
50 1.1 cgd /*
51 1.16 christos * This is an issue of basic "vi" look-and-feel. Defining VI_MOVE works
52 1.1 cgd * like real vi: i.e. the transition from command<->insert modes moves
53 1.1 cgd * the cursor.
54 1.1 cgd *
55 1.4 simonb * On the other hand we really don't want to move the cursor, because
56 1.1 cgd * all the editing commands don't include the character under the cursor.
57 1.1 cgd * Probably the best fix is to make all the editing commands aware of
58 1.1 cgd * this fact.
59 1.1 cgd */
60 1.5 lukem #define VI_MOVE
61 1.1 cgd
62 1.1 cgd
63 1.1 cgd typedef struct c_macro_t {
64 1.5 lukem int level;
65 1.13 christos int offset;
66 1.19 christos Char **macro;
67 1.1 cgd } c_macro_t;
68 1.1 cgd
69 1.4 simonb /*
70 1.9 christos * Undo information for vi - no undo in emacs (yet)
71 1.1 cgd */
72 1.1 cgd typedef struct c_undo_t {
73 1.18 christos ssize_t len; /* length of saved line */
74 1.9 christos int cursor; /* position of saved cursor */
75 1.19 christos Char *buf; /* full saved text */
76 1.1 cgd } c_undo_t;
77 1.1 cgd
78 1.10 christos /* redo for vi */
79 1.10 christos typedef struct c_redo_t {
80 1.19 christos Char *buf; /* redo insert key sequence */
81 1.19 christos Char *pos;
82 1.19 christos Char *lim;
83 1.10 christos el_action_t cmd; /* command to redo */
84 1.19 christos Char ch; /* char that invoked it */
85 1.10 christos int count;
86 1.10 christos int action; /* from cv_action() */
87 1.10 christos } c_redo_t;
88 1.10 christos
89 1.1 cgd /*
90 1.1 cgd * Current action information for vi
91 1.1 cgd */
92 1.1 cgd typedef struct c_vcmd_t {
93 1.5 lukem int action;
94 1.19 christos Char *pos;
95 1.1 cgd } c_vcmd_t;
96 1.1 cgd
97 1.1 cgd /*
98 1.1 cgd * Kill buffer for emacs
99 1.1 cgd */
100 1.1 cgd typedef struct c_kill_t {
101 1.19 christos Char *buf;
102 1.19 christos Char *last;
103 1.19 christos Char *mark;
104 1.1 cgd } c_kill_t;
105 1.1 cgd
106 1.21 christos typedef void (*el_zfunc_t)(EditLine *, void *);
107 1.21 christos
108 1.1 cgd /*
109 1.1 cgd * Note that we use both data structures because the user can bind
110 1.1 cgd * commands from both editors!
111 1.1 cgd */
112 1.1 cgd typedef struct el_chared_t {
113 1.5 lukem c_undo_t c_undo;
114 1.5 lukem c_kill_t c_kill;
115 1.10 christos c_redo_t c_redo;
116 1.5 lukem c_vcmd_t c_vcmd;
117 1.5 lukem c_macro_t c_macro;
118 1.21 christos el_zfunc_t c_resizefun;
119 1.21 christos void * c_resizearg;
120 1.1 cgd } el_chared_t;
121 1.1 cgd
122 1.1 cgd
123 1.5 lukem #define STRQQ "\"\""
124 1.1 cgd
125 1.5 lukem #define isglob(a) (strchr("*[]?", (a)) != NULL)
126 1.1 cgd
127 1.5 lukem #define NOP 0x00
128 1.5 lukem #define DELETE 0x01
129 1.5 lukem #define INSERT 0x02
130 1.10 christos #define YANK 0x04
131 1.5 lukem
132 1.10 christos #define CHAR_FWD (+1)
133 1.10 christos #define CHAR_BACK (-1)
134 1.5 lukem
135 1.5 lukem #define MODE_INSERT 0
136 1.5 lukem #define MODE_REPLACE 1
137 1.5 lukem #define MODE_REPLACE_1 2
138 1.1 cgd
139 1.1 cgd #include "common.h"
140 1.1 cgd #include "vi.h"
141 1.1 cgd #include "emacs.h"
142 1.1 cgd #include "search.h"
143 1.1 cgd #include "fcns.h"
144 1.1 cgd
145 1.1 cgd
146 1.20 christos protected int cv__isword(Int);
147 1.20 christos protected int cv__isWord(Int);
148 1.5 lukem protected void cv_delfini(EditLine *);
149 1.20 christos protected Char *cv__endword(Char *, Char *, int, int (*)(Int));
150 1.20 christos protected int ce__isword(Int);
151 1.10 christos protected void cv_undo(EditLine *);
152 1.19 christos protected void cv_yank(EditLine *, const Char *, int);
153 1.20 christos protected Char *cv_next_word(EditLine*, Char *, Char *, int, int (*)(Int));
154 1.20 christos protected Char *cv_prev_word(Char *, Char *, int, int (*)(Int));
155 1.20 christos protected Char *c__next_word(Char *, Char *, int, int (*)(Int));
156 1.20 christos protected Char *c__prev_word(Char *, Char *, int, int (*)(Int));
157 1.5 lukem protected void c_insert(EditLine *, int);
158 1.5 lukem protected void c_delbefore(EditLine *, int);
159 1.14 mycroft protected void c_delbefore1(EditLine *);
160 1.5 lukem protected void c_delafter(EditLine *, int);
161 1.14 mycroft protected void c_delafter1(EditLine *);
162 1.19 christos protected int c_gets(EditLine *, Char *, const Char *);
163 1.5 lukem protected int c_hpos(EditLine *);
164 1.5 lukem
165 1.5 lukem protected int ch_init(EditLine *);
166 1.15 christos protected void ch_reset(EditLine *, int);
167 1.21 christos protected int ch_resizefun(EditLine *, el_zfunc_t, void *);
168 1.7 christos protected int ch_enlargebufs(EditLine *, size_t);
169 1.5 lukem protected void ch_end(EditLine *);
170 1.1 cgd
171 1.1 cgd #endif /* _h_el_chared */
172