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