xref: /original-bsd/lib/libedit/chared.h (revision c3e32dec)
1 /*-
2  * Copyright (c) 1992, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Christos Zoulas of Cornell University.
7  *
8  * %sccs.include.redist.c%
9  *
10  *	@(#)chared.h	8.1 (Berkeley) 06/04/93
11  */
12 
13 /*
14  * el.chared.h: Character editor interface
15  */
16 #ifndef _h_el_chared
17 #define _h_el_chared
18 
19 #include <ctype.h>
20 #include <string.h>
21 
22 #include "histedit.h"
23 
24 #define EL_MAXMACRO 10
25 
26 /*
27  * This is a issue of basic "vi" look-and-feel. Defining VI_MOVE works
28  * like real vi: i.e. the transition from command<->insert modes moves
29  * the cursor.
30  *
31  * On the other hand we really don't want to move the cursor, because
32  * all the editing commands don't include the character under the cursor.
33  * Probably the best fix is to make all the editing commands aware of
34  * this fact.
35  */
36 #define VI_MOVE
37 
38 
39 typedef struct c_macro_t {
40     int    level;
41     char **macro;
42     char  *nline;
43 } c_macro_t;
44 
45 /*
46  * Undo information for both vi and emacs
47  */
48 typedef struct c_undo_t {
49     int   action;
50     int   isize;
51     int   dsize;
52     char *ptr;
53     char *buf;
54 } c_undo_t;
55 
56 /*
57  * Current action information for vi
58  */
59 typedef struct c_vcmd_t {
60     int   action;
61     char *pos;
62     char *ins;
63 } c_vcmd_t;
64 
65 /*
66  * Kill buffer for emacs
67  */
68 typedef struct c_kill_t {
69     char *buf;
70     char *last;
71     char *mark;
72 } c_kill_t;
73 
74 /*
75  * Note that we use both data structures because the user can bind
76  * commands from both editors!
77  */
78 typedef struct el_chared_t {
79     c_undo_t    c_undo;
80     c_kill_t    c_kill;
81     c_vcmd_t    c_vcmd;
82     c_macro_t   c_macro;
83 } el_chared_t;
84 
85 
86 #define STReof "^D\b\b"
87 #define STRQQ  "\"\""
88 
89 #define isglob(a) (strchr("*[]?", (a)) != NULL)
90 #define isword(a) (isprint(a))
91 
92 #define NOP    	  0x00
93 #define DELETE 	  0x01
94 #define INSERT 	  0x02
95 #define CHANGE 	  0x04
96 
97 #define CHAR_FWD	0
98 #define CHAR_BACK	1
99 
100 #define MODE_INSERT	0
101 #define MODE_REPLACE	1
102 #define MODE_REPLACE_1	2
103 
104 #include "common.h"
105 #include "vi.h"
106 #include "emacs.h"
107 #include "search.h"
108 #include "fcns.h"
109 
110 
111 protected int   cv__isword	__P((int));
112 protected void  cv_delfini	__P((EditLine *));
113 protected char *cv__endword	__P((char *, char *, int));
114 protected int   ce__isword	__P((int));
115 protected void  cv_undo		__P((EditLine *, int, int, char *));
116 protected char *cv_next_word	__P((EditLine*, char *, char *, int,
117 				     int (*)(int)));
118 protected char *cv_prev_word	__P((EditLine*, char *, char *, int,
119 				     int (*)(int)));
120 protected char *c__next_word	__P((char *, char *, int, int (*)(int)));
121 protected char *c__prev_word	__P((char *, char *, int, int (*)(int)));
122 protected void  c_insert	__P((EditLine *, int));
123 protected void  c_delbefore	__P((EditLine *, int));
124 protected void  c_delafter	__P((EditLine *, int));
125 protected int   c_gets		__P((EditLine *, char *));
126 protected int   c_hpos		__P((EditLine *));
127 
128 protected int   ch_init		__P((EditLine *));
129 protected void  ch_reset	__P((EditLine *));
130 protected void  ch_end		__P((EditLine *));
131 
132 #endif /* _h_el_chared */
133