xref: /csrg-svn/lib/libedit/chared.h (revision 61275)
154211Sbostic /*-
2*61275Sbostic  * Copyright (c) 1992, 1993
3*61275Sbostic  *	The Regents of the University of California.  All rights reserved.
454211Sbostic  *
554211Sbostic  * This code is derived from software contributed to Berkeley by
654211Sbostic  * Christos Zoulas of Cornell University.
754211Sbostic  *
854211Sbostic  * %sccs.include.redist.c%
954211Sbostic  *
10*61275Sbostic  *	@(#)chared.h	8.1 (Berkeley) 06/04/93
1154211Sbostic  */
1254211Sbostic 
1354211Sbostic /*
1454211Sbostic  * el.chared.h: Character editor interface
1554211Sbostic  */
1654211Sbostic #ifndef _h_el_chared
1754211Sbostic #define _h_el_chared
1854211Sbostic 
1954211Sbostic #include <ctype.h>
2054211Sbostic #include <string.h>
2154211Sbostic 
2254246Smarc #include "histedit.h"
2354211Sbostic 
2454211Sbostic #define EL_MAXMACRO 10
2554211Sbostic 
2654211Sbostic /*
2754211Sbostic  * This is a issue of basic "vi" look-and-feel. Defining VI_MOVE works
2854211Sbostic  * like real vi: i.e. the transition from command<->insert modes moves
2954211Sbostic  * the cursor.
3054211Sbostic  *
3154211Sbostic  * On the other hand we really don't want to move the cursor, because
3254211Sbostic  * all the editing commands don't include the character under the cursor.
3354211Sbostic  * Probably the best fix is to make all the editing commands aware of
3454211Sbostic  * this fact.
3554211Sbostic  */
3654211Sbostic #define VI_MOVE
3754211Sbostic 
3854211Sbostic 
3954211Sbostic typedef struct c_macro_t {
4054211Sbostic     int    level;
4154211Sbostic     char **macro;
4254624Schristos     char  *nline;
4354211Sbostic } c_macro_t;
4454211Sbostic 
4554211Sbostic /*
4654211Sbostic  * Undo information for both vi and emacs
4754211Sbostic  */
4854211Sbostic typedef struct c_undo_t {
4954211Sbostic     int   action;
5054211Sbostic     int   isize;
5154211Sbostic     int   dsize;
5254211Sbostic     char *ptr;
5354211Sbostic     char *buf;
5454211Sbostic } c_undo_t;
5554211Sbostic 
5654211Sbostic /*
5754211Sbostic  * Current action information for vi
5854211Sbostic  */
5954211Sbostic typedef struct c_vcmd_t {
6054211Sbostic     int   action;
6154211Sbostic     char *pos;
6254211Sbostic     char *ins;
6354211Sbostic } c_vcmd_t;
6454211Sbostic 
6554211Sbostic /*
6654211Sbostic  * Kill buffer for emacs
6754211Sbostic  */
6854211Sbostic typedef struct c_kill_t {
6954211Sbostic     char *buf;
7054211Sbostic     char *last;
7154211Sbostic     char *mark;
7254211Sbostic } c_kill_t;
7354211Sbostic 
7454211Sbostic /*
7554211Sbostic  * Note that we use both data structures because the user can bind
7654211Sbostic  * commands from both editors!
7754211Sbostic  */
7854211Sbostic typedef struct el_chared_t {
7954211Sbostic     c_undo_t    c_undo;
8054211Sbostic     c_kill_t    c_kill;
8154211Sbostic     c_vcmd_t    c_vcmd;
8254211Sbostic     c_macro_t   c_macro;
8354211Sbostic } el_chared_t;
8454211Sbostic 
8554211Sbostic 
8654211Sbostic #define STReof "^D\b\b"
8754211Sbostic #define STRQQ  "\"\""
8854211Sbostic 
8954211Sbostic #define isglob(a) (strchr("*[]?", (a)) != NULL)
9054211Sbostic #define isword(a) (isprint(a))
9154211Sbostic 
9254211Sbostic #define NOP    	  0x00
9354211Sbostic #define DELETE 	  0x01
9454211Sbostic #define INSERT 	  0x02
9554211Sbostic #define CHANGE 	  0x04
9654211Sbostic 
9754211Sbostic #define CHAR_FWD	0
9854211Sbostic #define CHAR_BACK	1
9954211Sbostic 
10054211Sbostic #define MODE_INSERT	0
10154211Sbostic #define MODE_REPLACE	1
10254211Sbostic #define MODE_REPLACE_1	2
10354211Sbostic 
10454624Schristos #include "common.h"
10554211Sbostic #include "vi.h"
10654211Sbostic #include "emacs.h"
10754211Sbostic #include "search.h"
10854211Sbostic #include "fcns.h"
10954211Sbostic 
11054211Sbostic 
11154211Sbostic protected int   cv__isword	__P((int));
11254211Sbostic protected void  cv_delfini	__P((EditLine *));
11354211Sbostic protected char *cv__endword	__P((char *, char *, int));
11454211Sbostic protected int   ce__isword	__P((int));
11554211Sbostic protected void  cv_undo		__P((EditLine *, int, int, char *));
11654211Sbostic protected char *cv_next_word	__P((EditLine*, char *, char *, int,
11754211Sbostic 				     int (*)(int)));
11854211Sbostic protected char *cv_prev_word	__P((EditLine*, char *, char *, int,
11954211Sbostic 				     int (*)(int)));
12054211Sbostic protected char *c__next_word	__P((char *, char *, int, int (*)(int)));
12154211Sbostic protected char *c__prev_word	__P((char *, char *, int, int (*)(int)));
12254211Sbostic protected void  c_insert	__P((EditLine *, int));
12354211Sbostic protected void  c_delbefore	__P((EditLine *, int));
12454211Sbostic protected void  c_delafter	__P((EditLine *, int));
12554211Sbostic protected int   c_gets		__P((EditLine *, char *));
12654211Sbostic protected int   c_hpos		__P((EditLine *));
12754211Sbostic 
12854211Sbostic protected int   ch_init		__P((EditLine *));
12954211Sbostic protected void  ch_reset	__P((EditLine *));
13054211Sbostic protected void  ch_end		__P((EditLine *));
13154211Sbostic 
13254211Sbostic #endif /* _h_el_chared */
133