The world's most popular open source database
00001 /* $NetBSD: chared.h,v 1.14 2004/08/13 12:10:39 mycroft 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. Neither the name of the University nor the names of its contributors 00019 * may be used to endorse or promote products derived from this software 00020 * without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00023 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00025 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00026 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00027 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00028 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00029 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00031 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00032 * SUCH DAMAGE. 00033 * 00034 * @(#)chared.h 8.1 (Berkeley) 6/4/93 00035 */ 00036 00037 /* 00038 * el.chared.h: Character editor interface 00039 */ 00040 #ifndef _h_el_chared 00041 #define _h_el_chared 00042 00043 #include <ctype.h> 00044 #include <string.h> 00045 00046 #include "histedit.h" 00047 00048 #define EL_MAXMACRO 10 00049 00050 /* 00051 * This is a issue of basic "vi" look-and-feel. Defining VI_MOVE works 00052 * like real vi: i.e. the transition from command<->insert modes moves 00053 * the cursor. 00054 * 00055 * On the other hand we really don't want to move the cursor, because 00056 * all the editing commands don't include the character under the cursor. 00057 * Probably the best fix is to make all the editing commands aware of 00058 * this fact. 00059 */ 00060 #define VI_MOVE 00061 00062 00063 typedef struct c_macro_t { 00064 int level; 00065 int offset; 00066 char **macro; 00067 } c_macro_t; 00068 00069 /* 00070 * Undo information for vi - no undo in emacs (yet) 00071 */ 00072 typedef struct c_undo_t { 00073 int len; /* length of saved line */ 00074 int cursor; /* position of saved cursor */ 00075 char *buf; /* full saved text */ 00076 } c_undo_t; 00077 00078 /* redo for vi */ 00079 typedef struct c_redo_t { 00080 char *buf; /* redo insert key sequence */ 00081 char *pos; 00082 char *lim; 00083 el_action_t cmd; /* command to redo */ 00084 char ch; /* char that invoked it */ 00085 int count; 00086 int action; /* from cv_action() */ 00087 } c_redo_t; 00088 00089 /* 00090 * Current action information for vi 00091 */ 00092 typedef struct c_vcmd_t { 00093 int action; 00094 char *pos; 00095 } c_vcmd_t; 00096 00097 /* 00098 * Kill buffer for emacs 00099 */ 00100 typedef struct c_kill_t { 00101 char *buf; 00102 char *last; 00103 char *mark; 00104 } c_kill_t; 00105 00106 /* 00107 * Note that we use both data structures because the user can bind 00108 * commands from both editors! 00109 */ 00110 typedef struct el_chared_t { 00111 c_undo_t c_undo; 00112 c_kill_t c_kill; 00113 c_redo_t c_redo; 00114 c_vcmd_t c_vcmd; 00115 c_macro_t c_macro; 00116 } el_chared_t; 00117 00118 00119 #define STReof "^D\b\b" 00120 #define STRQQ "\"\"" 00121 00122 #define isglob(a) (strchr("*[]?", (a)) != NULL) 00123 #define isword(a) (isprint(a)) 00124 00125 #define NOP 0x00 00126 #define DELETE 0x01 00127 #define INSERT 0x02 00128 #define YANK 0x04 00129 00130 #define CHAR_FWD (+1) 00131 #define CHAR_BACK (-1) 00132 00133 #define MODE_INSERT 0 00134 #define MODE_REPLACE 1 00135 #define MODE_REPLACE_1 2 00136 00137 #include "common.h" 00138 #include "vi.h" 00139 #include "emacs.h" 00140 #include "search.h" 00141 #include "fcns.h" 00142 00143 00144 protected int cv__isword(int); 00145 protected int cv__isWord(int); 00146 protected void cv_delfini(EditLine *); 00147 protected char *cv__endword(char *, char *, int, int (*)(int)); 00148 protected int ce__isword(int); 00149 protected void cv_undo(EditLine *); 00150 protected void cv_yank(EditLine *, const char *, int); 00151 protected char *cv_next_word(EditLine*, char *, char *, int, int (*)(int)); 00152 protected char *cv_prev_word(char *, char *, int, int (*)(int)); 00153 protected char *c__next_word(char *, char *, int, int (*)(int)); 00154 protected char *c__prev_word(char *, char *, int, int (*)(int)); 00155 protected void c_insert(EditLine *, int); 00156 protected void c_delbefore(EditLine *, int); 00157 protected void c_delbefore1(EditLine *); 00158 protected void c_delafter(EditLine *, int); 00159 protected void c_delafter1(EditLine *); 00160 protected int c_gets(EditLine *, char *, const char *); 00161 protected int c_hpos(EditLine *); 00162 00163 protected int ch_init(EditLine *); 00164 protected void ch_reset(EditLine *); 00165 protected int ch_enlargebufs(EditLine *, size_t); 00166 protected void ch_end(EditLine *); 00167 00168 #endif /* _h_el_chared */
1.4.7

