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