chared.h

Go to the documentation of this file.
00001 /* $NetBSD: chared.h,v 1.8 2002/03/18 16:00:51 christos Exp $  */
00002 
00003 /*-
00004  * Copyright (c) 1992, 1993
00005  * The Regents of the University of California.  All rights reserved.
00006  *
00007  * This code is derived from software contributed to Berkeley by
00008  * Christos Zoulas of Cornell University.
00009  *
00010  * Redistribution and use in source and binary forms, with or without
00011  * modification, are permitted provided that the following conditions
00012  * are met:
00013  * 1. Redistributions of source code must retain the above copyright
00014  *    notice, this list of conditions and the following disclaimer.
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in the
00017  *    documentation and/or other materials provided with the distribution.
00018  * 3. All advertising materials mentioning features or use of this software
00019  *    must display the following acknowledgement:
00020  * This product includes software developed by the University of
00021  * California, Berkeley and its contributors.
00022  * 4. Neither the name of the University nor the names of its contributors
00023  *    may be used to endorse or promote products derived from this software
00024  *    without specific prior written permission.
00025  *
00026  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00027  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00029  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00030  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00031  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00032  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00033  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00034  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00035  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00036  * SUCH DAMAGE.
00037  *
00038  * @(#)chared.h   8.1 (Berkeley) 6/4/93
00039  */
00040 
00041 /*
00042  * el.chared.h: Character editor interface
00043  */
00044 #ifndef _h_el_chared
00045 #define  _h_el_chared
00046 
00047 #include <ctype.h>
00048 #include <string.h>
00049 
00050 #include "histedit.h"
00051 
00052 #define  EL_MAXMACRO 10
00053 
00054 /*
00055  * This is a issue of basic "vi" look-and-feel. Defining VI_MOVE works
00056  * like real vi: i.e. the transition from command<->insert modes moves
00057  * the cursor.
00058  *
00059  * On the other hand we really don't want to move the cursor, because
00060  * all the editing commands don't include the character under the cursor.
00061  * Probably the best fix is to make all the editing commands aware of
00062  * this fact.
00063  */
00064 #define  VI_MOVE
00065 
00066 
00067 typedef struct c_macro_t {
00068    int     level;
00069    char  **macro;
00070    char   *nline;
00071 } c_macro_t;
00072 
00073 /*
00074  * Undo information for both vi and emacs
00075  */
00076 typedef struct c_undo_t {
00077    int    action;
00078    size_t    isize;
00079    size_t    dsize;
00080    char  *ptr;
00081    char  *buf;
00082 } c_undo_t;
00083 
00084 /*
00085  * Current action information for vi
00086  */
00087 typedef struct c_vcmd_t {
00088    int    action;
00089    char  *pos;
00090    char  *ins;
00091 } c_vcmd_t;
00092 
00093 /*
00094  * Kill buffer for emacs
00095  */
00096 typedef struct c_kill_t {
00097    char  *buf;
00098    char  *last;
00099    char  *mark;
00100 } c_kill_t;
00101 
00102 /*
00103  * Note that we use both data structures because the user can bind
00104  * commands from both editors!
00105  */
00106 typedef struct el_chared_t {
00107    c_undo_t c_undo;
00108    c_kill_t c_kill;
00109    c_vcmd_t c_vcmd;
00110    c_macro_t   c_macro;
00111 } el_chared_t;
00112 
00113 
00114 #define  STReof      "^D\b\b"
00115 #define  STRQQ    "\"\""
00116 
00117 #define  isglob(a)   (strchr("*[]?", (a)) != NULL)
00118 #define  isword(a)   (isprint(a))
00119 
00120 #define  NOP      0x00
00121 #define  DELETE      0x01
00122 #define  INSERT      0x02
00123 #define  CHANGE      0x04
00124 
00125 #define  CHAR_FWD 0
00126 #define  CHAR_BACK   1
00127 
00128 #define  MODE_INSERT 0
00129 #define  MODE_REPLACE   1
00130 #define  MODE_REPLACE_1 2
00131 
00132 #include "common.h"
00133 #include "vi.h"
00134 #include "emacs.h"
00135 #include "search.h"
00136 #include "fcns.h"
00137 
00138 
00139 protected int   cv__isword(int);
00140 protected void  cv_delfini(EditLine *);
00141 protected char *cv__endword(char *, char *, int);
00142 protected int   ce__isword(int);
00143 protected void  cv_undo(EditLine *, int, size_t, char *);
00144 protected char *cv_next_word(EditLine*, char *, char *, int, int (*)(int));
00145 protected char *cv_prev_word(EditLine*, char *, char *, int, int (*)(int));
00146 protected char *c__next_word(char *, char *, int, int (*)(int));
00147 protected char *c__prev_word(char *, char *, int, int (*)(int));
00148 protected void  c_insert(EditLine *, int);
00149 protected void  c_delbefore(EditLine *, int);
00150 protected void  c_delafter(EditLine *, int);
00151 protected int   c_gets(EditLine *, char *);
00152 protected int   c_hpos(EditLine *);
00153 
00154 protected int   ch_init(EditLine *);
00155 protected void  ch_reset(EditLine *);
00156 protected int   ch_enlargebufs(EditLine *, size_t);
00157 protected void  ch_end(EditLine *);
00158 
00159 #endif /* _h_el_chared */

Generated on Thu Apr 16 06:27:30 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6