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