/* $NetBSD: chared.h,v 1.30 2016/05/22 19:44:26 christos Exp $ */12/*-3* Copyright (c) 1992, 19934* The Regents of the University of California. All rights reserved.5*6* This code is derived from software contributed to Berkeley by7* Christos Zoulas of Cornell University.8*9* Redistribution and use in source and binary forms, with or without10* modification, are permitted provided that the following conditions11* are met:12* 1. Redistributions of source code must retain the above copyright13* notice, this list of conditions and the following disclaimer.14* 2. Redistributions in binary form must reproduce the above copyright15* notice, this list of conditions and the following disclaimer in the16* documentation and/or other materials provided with the distribution.17* 3. Neither the name of the University nor the names of its contributors18* may be used to endorse or promote products derived from this software19* without specific prior written permission.20*21* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND22* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE23* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE24* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE25* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL26* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS27* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)28* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT29* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31* SUCH DAMAGE.32*33* @(#)chared.h 8.1 (Berkeley) 6/4/9334*/3536/*37* el.chared.h: Character editor interface38*/39#ifndef _h_el_chared40#define _h_el_chared4142/*43* This is an issue of basic "vi" look-and-feel. Defining VI_MOVE works44* like real vi: i.e. the transition from command<->insert modes moves45* the cursor.46*47* On the other hand we really don't want to move the cursor, because48* all the editing commands don't include the character under the cursor.49* Probably the best fix is to make all the editing commands aware of50* this fact.51*/52#define VI_MOVE5354/*55* Undo information for vi - no undo in emacs (yet)56*/57typedef struct c_undo_t {58ssize_t len; /* length of saved line */59int cursor; /* position of saved cursor */60wchar_t *buf; /* full saved text */61} c_undo_t;6263/* redo for vi */64typedef struct c_redo_t {65wchar_t *buf; /* redo insert key sequence */66wchar_t *pos;67wchar_t *lim;68el_action_t cmd; /* command to redo */69wchar_t ch; /* char that invoked it */70int count;71int action; /* from cv_action() */72} c_redo_t;7374/*75* Current action information for vi76*/77typedef struct c_vcmd_t {78int action;79wchar_t *pos;80} c_vcmd_t;8182/*83* Kill buffer for emacs84*/85typedef struct c_kill_t {86wchar_t *buf;87wchar_t *last;88wchar_t *mark;89} c_kill_t;9091typedef void (*el_zfunc_t)(EditLine *, void *);92typedef const char *(*el_afunc_t)(void *, const char *);9394/*95* Note that we use both data structures because the user can bind96* commands from both editors!97*/98typedef struct el_chared_t {99c_undo_t c_undo;100c_kill_t c_kill;101c_redo_t c_redo;102c_vcmd_t c_vcmd;103el_zfunc_t c_resizefun;104el_afunc_t c_aliasfun;105void * c_resizearg;106void * c_aliasarg;107} el_chared_t;108109110#define STRQQ "\"\""111112#define isglob(a) (strchr("*[]?", (a)) != NULL)113114#define NOP 0x00115#define DELETE 0x01116#define INSERT 0x02117#define YANK 0x04118119#define CHAR_FWD (+1)120#define CHAR_BACK (-1)121122#define MODE_INSERT 0123#define MODE_REPLACE 1124#define MODE_REPLACE_1 2125126127libedit_private int cv__isword(wint_t);128libedit_private int cv__isWord(wint_t);129libedit_private void cv_delfini(EditLine *);130libedit_private wchar_t *cv__endword(wchar_t *, wchar_t *, int, int (*)(wint_t));131libedit_private int ce__isword(wint_t);132libedit_private void cv_undo(EditLine *);133libedit_private void cv_yank(EditLine *, const wchar_t *, int);134libedit_private wchar_t *cv_next_word(EditLine*, wchar_t *, wchar_t *, int,135int (*)(wint_t));136libedit_private wchar_t *cv_prev_word(wchar_t *, wchar_t *, int, int (*)(wint_t));137libedit_private wchar_t *c__next_word(wchar_t *, wchar_t *, int, int (*)(wint_t));138libedit_private wchar_t *c__prev_word(wchar_t *, wchar_t *, int, int (*)(wint_t));139libedit_private void c_insert(EditLine *, int);140libedit_private void c_delbefore(EditLine *, int);141libedit_private void c_delbefore1(EditLine *);142libedit_private void c_delafter(EditLine *, int);143libedit_private void c_delafter1(EditLine *);144libedit_private int c_gets(EditLine *, wchar_t *, const wchar_t *);145libedit_private int c_hpos(EditLine *);146147libedit_private int ch_init(EditLine *);148libedit_private void ch_reset(EditLine *);149libedit_private int ch_resizefun(EditLine *, el_zfunc_t, void *);150libedit_private int ch_aliasfun(EditLine *, el_afunc_t, void *);151libedit_private int ch_enlargebufs(EditLine *, size_t);152libedit_private void ch_end(EditLine *);153154#endif /* _h_el_chared */155156157