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