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