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