1*12db70c8Szrj /* $NetBSD: chared.h,v 1.30 2016/05/22 19:44:26 christos Exp $ */ 232fe07f8SJohn Marino 332fe07f8SJohn Marino /*- 432fe07f8SJohn Marino * Copyright (c) 1992, 1993 532fe07f8SJohn Marino * The Regents of the University of California. All rights reserved. 632fe07f8SJohn Marino * 732fe07f8SJohn Marino * This code is derived from software contributed to Berkeley by 832fe07f8SJohn Marino * Christos Zoulas of Cornell University. 932fe07f8SJohn Marino * 1032fe07f8SJohn Marino * Redistribution and use in source and binary forms, with or without 1132fe07f8SJohn Marino * modification, are permitted provided that the following conditions 1232fe07f8SJohn Marino * are met: 1332fe07f8SJohn Marino * 1. Redistributions of source code must retain the above copyright 1432fe07f8SJohn Marino * notice, this list of conditions and the following disclaimer. 1532fe07f8SJohn Marino * 2. Redistributions in binary form must reproduce the above copyright 1632fe07f8SJohn Marino * notice, this list of conditions and the following disclaimer in the 1732fe07f8SJohn Marino * documentation and/or other materials provided with the distribution. 1832fe07f8SJohn Marino * 3. Neither the name of the University nor the names of its contributors 1932fe07f8SJohn Marino * may be used to endorse or promote products derived from this software 2032fe07f8SJohn Marino * without specific prior written permission. 2132fe07f8SJohn Marino * 2232fe07f8SJohn Marino * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2332fe07f8SJohn Marino * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2432fe07f8SJohn Marino * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2532fe07f8SJohn Marino * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2632fe07f8SJohn Marino * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2732fe07f8SJohn Marino * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2832fe07f8SJohn Marino * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2932fe07f8SJohn Marino * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3032fe07f8SJohn Marino * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3132fe07f8SJohn Marino * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3232fe07f8SJohn Marino * SUCH DAMAGE. 3332fe07f8SJohn Marino * 3432fe07f8SJohn Marino * @(#)chared.h 8.1 (Berkeley) 6/4/93 3532fe07f8SJohn Marino */ 3632fe07f8SJohn Marino 3732fe07f8SJohn Marino /* 3832fe07f8SJohn Marino * el.chared.h: Character editor interface 3932fe07f8SJohn Marino */ 4032fe07f8SJohn Marino #ifndef _h_el_chared 4132fe07f8SJohn Marino #define _h_el_chared 4232fe07f8SJohn Marino 4332fe07f8SJohn Marino /* 4432fe07f8SJohn Marino * This is an issue of basic "vi" look-and-feel. Defining VI_MOVE works 4532fe07f8SJohn Marino * like real vi: i.e. the transition from command<->insert modes moves 4632fe07f8SJohn Marino * the cursor. 4732fe07f8SJohn Marino * 4832fe07f8SJohn Marino * On the other hand we really don't want to move the cursor, because 4932fe07f8SJohn Marino * all the editing commands don't include the character under the cursor. 5032fe07f8SJohn Marino * Probably the best fix is to make all the editing commands aware of 5132fe07f8SJohn Marino * this fact. 5232fe07f8SJohn Marino */ 5332fe07f8SJohn Marino #define VI_MOVE 5432fe07f8SJohn Marino 5532fe07f8SJohn Marino /* 5632fe07f8SJohn Marino * Undo information for vi - no undo in emacs (yet) 5732fe07f8SJohn Marino */ 5832fe07f8SJohn Marino typedef struct c_undo_t { 5932fe07f8SJohn Marino ssize_t len; /* length of saved line */ 6032fe07f8SJohn Marino int cursor; /* position of saved cursor */ 61*12db70c8Szrj wchar_t *buf; /* full saved text */ 6232fe07f8SJohn Marino } c_undo_t; 6332fe07f8SJohn Marino 6432fe07f8SJohn Marino /* redo for vi */ 6532fe07f8SJohn Marino typedef struct c_redo_t { 66*12db70c8Szrj wchar_t *buf; /* redo insert key sequence */ 67*12db70c8Szrj wchar_t *pos; 68*12db70c8Szrj wchar_t *lim; 6932fe07f8SJohn Marino el_action_t cmd; /* command to redo */ 70*12db70c8Szrj wchar_t ch; /* char that invoked it */ 7132fe07f8SJohn Marino int count; 7232fe07f8SJohn Marino int action; /* from cv_action() */ 7332fe07f8SJohn Marino } c_redo_t; 7432fe07f8SJohn Marino 7532fe07f8SJohn Marino /* 7632fe07f8SJohn Marino * Current action information for vi 7732fe07f8SJohn Marino */ 7832fe07f8SJohn Marino typedef struct c_vcmd_t { 7932fe07f8SJohn Marino int action; 80*12db70c8Szrj wchar_t *pos; 8132fe07f8SJohn Marino } c_vcmd_t; 8232fe07f8SJohn Marino 8332fe07f8SJohn Marino /* 8432fe07f8SJohn Marino * Kill buffer for emacs 8532fe07f8SJohn Marino */ 8632fe07f8SJohn Marino typedef struct c_kill_t { 87*12db70c8Szrj wchar_t *buf; 88*12db70c8Szrj wchar_t *last; 89*12db70c8Szrj wchar_t *mark; 9032fe07f8SJohn Marino } c_kill_t; 9132fe07f8SJohn Marino 9232fe07f8SJohn Marino typedef void (*el_zfunc_t)(EditLine *, void *); 9384b940c1SJohn Marino typedef const char *(*el_afunc_t)(void *, const char *); 9432fe07f8SJohn Marino 9532fe07f8SJohn Marino /* 9632fe07f8SJohn Marino * Note that we use both data structures because the user can bind 9732fe07f8SJohn Marino * commands from both editors! 9832fe07f8SJohn Marino */ 9932fe07f8SJohn Marino typedef struct el_chared_t { 10032fe07f8SJohn Marino c_undo_t c_undo; 10132fe07f8SJohn Marino c_kill_t c_kill; 10232fe07f8SJohn Marino c_redo_t c_redo; 10332fe07f8SJohn Marino c_vcmd_t c_vcmd; 10432fe07f8SJohn Marino el_zfunc_t c_resizefun; 10584b940c1SJohn Marino el_afunc_t c_aliasfun; 10632fe07f8SJohn Marino void * c_resizearg; 10784b940c1SJohn Marino void * c_aliasarg; 10832fe07f8SJohn Marino } el_chared_t; 10932fe07f8SJohn Marino 11032fe07f8SJohn Marino 11132fe07f8SJohn Marino #define STRQQ "\"\"" 11232fe07f8SJohn Marino 11332fe07f8SJohn Marino #define isglob(a) (strchr("*[]?", (a)) != NULL) 11432fe07f8SJohn Marino 11532fe07f8SJohn Marino #define NOP 0x00 11632fe07f8SJohn Marino #define DELETE 0x01 11732fe07f8SJohn Marino #define INSERT 0x02 11832fe07f8SJohn Marino #define YANK 0x04 11932fe07f8SJohn Marino 12032fe07f8SJohn Marino #define CHAR_FWD (+1) 12132fe07f8SJohn Marino #define CHAR_BACK (-1) 12232fe07f8SJohn Marino 12332fe07f8SJohn Marino #define MODE_INSERT 0 12432fe07f8SJohn Marino #define MODE_REPLACE 1 12532fe07f8SJohn Marino #define MODE_REPLACE_1 2 12632fe07f8SJohn Marino 12732fe07f8SJohn Marino 128*12db70c8Szrj libedit_private int cv__isword(wint_t); 129*12db70c8Szrj libedit_private int cv__isWord(wint_t); 130*12db70c8Szrj libedit_private void cv_delfini(EditLine *); 131*12db70c8Szrj libedit_private wchar_t *cv__endword(wchar_t *, wchar_t *, int, int (*)(wint_t)); 132*12db70c8Szrj libedit_private int ce__isword(wint_t); 133*12db70c8Szrj libedit_private void cv_undo(EditLine *); 134*12db70c8Szrj libedit_private void cv_yank(EditLine *, const wchar_t *, int); 135*12db70c8Szrj libedit_private wchar_t *cv_next_word(EditLine*, wchar_t *, wchar_t *, int, 136*12db70c8Szrj int (*)(wint_t)); 137*12db70c8Szrj libedit_private wchar_t *cv_prev_word(wchar_t *, wchar_t *, int, int (*)(wint_t)); 138*12db70c8Szrj libedit_private wchar_t *c__next_word(wchar_t *, wchar_t *, int, int (*)(wint_t)); 139*12db70c8Szrj libedit_private wchar_t *c__prev_word(wchar_t *, wchar_t *, int, int (*)(wint_t)); 140*12db70c8Szrj libedit_private void c_insert(EditLine *, int); 141*12db70c8Szrj libedit_private void c_delbefore(EditLine *, int); 142*12db70c8Szrj libedit_private void c_delbefore1(EditLine *); 143*12db70c8Szrj libedit_private void c_delafter(EditLine *, int); 144*12db70c8Szrj libedit_private void c_delafter1(EditLine *); 145*12db70c8Szrj libedit_private int c_gets(EditLine *, wchar_t *, const wchar_t *); 146*12db70c8Szrj libedit_private int c_hpos(EditLine *); 14732fe07f8SJohn Marino 148*12db70c8Szrj libedit_private int ch_init(EditLine *); 149*12db70c8Szrj libedit_private void ch_reset(EditLine *); 150*12db70c8Szrj libedit_private int ch_resizefun(EditLine *, el_zfunc_t, void *); 151*12db70c8Szrj libedit_private int ch_aliasfun(EditLine *, el_afunc_t, void *); 152*12db70c8Szrj libedit_private int ch_enlargebufs(EditLine *, size_t); 153*12db70c8Szrj libedit_private void ch_end(EditLine *); 15432fe07f8SJohn Marino 15532fe07f8SJohn Marino #endif /* _h_el_chared */ 156