1296435Spfg/* $NetBSD: chared.h,v 1.22 2014/06/18 18:12:28 christos Exp $ */ 2276881Sbapt 31573Srgrimes/*- 41573Srgrimes * Copyright (c) 1992, 1993 51573Srgrimes * The Regents of the University of California. All rights reserved. 61573Srgrimes * 71573Srgrimes * This code is derived from software contributed to Berkeley by 81573Srgrimes * Christos Zoulas of Cornell University. 91573Srgrimes * 101573Srgrimes * Redistribution and use in source and binary forms, with or without 111573Srgrimes * modification, are permitted provided that the following conditions 121573Srgrimes * are met: 131573Srgrimes * 1. Redistributions of source code must retain the above copyright 141573Srgrimes * notice, this list of conditions and the following disclaimer. 151573Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 161573Srgrimes * notice, this list of conditions and the following disclaimer in the 171573Srgrimes * documentation and/or other materials provided with the distribution. 18148834Sstefanf * 3. Neither the name of the University nor the names of its contributors 191573Srgrimes * may be used to endorse or promote products derived from this software 201573Srgrimes * without specific prior written permission. 211573Srgrimes * 221573Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 231573Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 241573Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 251573Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 261573Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 271573Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 281573Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 291573Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 301573Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 311573Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 321573Srgrimes * SUCH DAMAGE. 331573Srgrimes * 341573Srgrimes * @(#)chared.h 8.1 (Berkeley) 6/4/93 3584260Sobrien * $FreeBSD: releng/11.0/lib/libedit/chared.h 296435 2016-03-06 21:32:54Z pfg $ 361573Srgrimes */ 371573Srgrimes 381573Srgrimes/* 391573Srgrimes * el.chared.h: Character editor interface 401573Srgrimes */ 411573Srgrimes#ifndef _h_el_chared 4284260Sobrien#define _h_el_chared 431573Srgrimes 44296435Spfg#include <ctype.h> 45296435Spfg#include <string.h> 46296435Spfg 47296435Spfg#include "histedit.h" 48296435Spfg 4984260Sobrien#define EL_MAXMACRO 10 501573Srgrimes 511573Srgrimes/* 52108533Sschweikh * This is an issue of basic "vi" look-and-feel. Defining VI_MOVE works 531573Srgrimes * like real vi: i.e. the transition from command<->insert modes moves 541573Srgrimes * the cursor. 551573Srgrimes * 568870Srgrimes * On the other hand we really don't want to move the cursor, because 571573Srgrimes * all the editing commands don't include the character under the cursor. 581573Srgrimes * Probably the best fix is to make all the editing commands aware of 591573Srgrimes * this fact. 601573Srgrimes */ 6184260Sobrien#define VI_MOVE 621573Srgrimes 631573Srgrimes 641573Srgrimestypedef struct c_macro_t { 6584260Sobrien int level; 66148834Sstefanf int offset; 67276881Sbapt Char **macro; 681573Srgrimes} c_macro_t; 691573Srgrimes 708870Srgrimes/* 71148834Sstefanf * Undo information for vi - no undo in emacs (yet) 721573Srgrimes */ 731573Srgrimestypedef struct c_undo_t { 74238178Spfg ssize_t len; /* length of saved line */ 75148834Sstefanf int cursor; /* position of saved cursor */ 76276881Sbapt Char *buf; /* full saved text */ 771573Srgrimes} c_undo_t; 781573Srgrimes 79148834Sstefanf/* redo for vi */ 80148834Sstefanftypedef struct c_redo_t { 81276881Sbapt Char *buf; /* redo insert key sequence */ 82276881Sbapt Char *pos; 83276881Sbapt Char *lim; 84148834Sstefanf el_action_t cmd; /* command to redo */ 85276881Sbapt Char ch; /* char that invoked it */ 86148834Sstefanf int count; 87148834Sstefanf int action; /* from cv_action() */ 88148834Sstefanf} c_redo_t; 89148834Sstefanf 901573Srgrimes/* 911573Srgrimes * Current action information for vi 921573Srgrimes */ 931573Srgrimestypedef struct c_vcmd_t { 9484260Sobrien int action; 95276881Sbapt Char *pos; 961573Srgrimes} c_vcmd_t; 971573Srgrimes 981573Srgrimes/* 991573Srgrimes * Kill buffer for emacs 1001573Srgrimes */ 1011573Srgrimestypedef struct c_kill_t { 102276881Sbapt Char *buf; 103276881Sbapt Char *last; 104276881Sbapt Char *mark; 1051573Srgrimes} c_kill_t; 1061573Srgrimes 107276881Sbapttypedef void (*el_zfunc_t)(EditLine *, void *); 108276881Sbapttypedef const char *(*el_afunc_t)(void *, const char *); 109276881Sbapt 1101573Srgrimes/* 1111573Srgrimes * Note that we use both data structures because the user can bind 1121573Srgrimes * commands from both editors! 1131573Srgrimes */ 1141573Srgrimestypedef struct el_chared_t { 11584260Sobrien c_undo_t c_undo; 11684260Sobrien c_kill_t c_kill; 117148834Sstefanf c_redo_t c_redo; 11884260Sobrien c_vcmd_t c_vcmd; 11984260Sobrien c_macro_t c_macro; 120276881Sbapt el_zfunc_t c_resizefun; 121276881Sbapt el_afunc_t c_aliasfun; 122276881Sbapt void * c_resizearg; 123276881Sbapt void * c_aliasarg; 1241573Srgrimes} el_chared_t; 1251573Srgrimes 1261573Srgrimes 12784260Sobrien#define STRQQ "\"\"" 1281573Srgrimes 12984260Sobrien#define isglob(a) (strchr("*[]?", (a)) != NULL) 1301573Srgrimes 13184260Sobrien#define NOP 0x00 13284260Sobrien#define DELETE 0x01 13384260Sobrien#define INSERT 0x02 134148834Sstefanf#define YANK 0x04 1351573Srgrimes 136148834Sstefanf#define CHAR_FWD (+1) 137148834Sstefanf#define CHAR_BACK (-1) 1381573Srgrimes 13984260Sobrien#define MODE_INSERT 0 14084260Sobrien#define MODE_REPLACE 1 14184260Sobrien#define MODE_REPLACE_1 2 1421573Srgrimes 143296435Spfg#include "common.h" 144296435Spfg#include "vi.h" 145296435Spfg#include "emacs.h" 146296435Spfg#include "search.h" 147296435Spfg#include "fcns.h" 1481573Srgrimes 149296435Spfg 150296435Spfgprotected int cv__isword(Int); 151296435Spfgprotected int cv__isWord(Int); 15284260Sobrienprotected void cv_delfini(EditLine *); 153296435Spfgprotected Char *cv__endword(Char *, Char *, int, int (*)(Int)); 154296435Spfgprotected int ce__isword(Int); 155148834Sstefanfprotected void cv_undo(EditLine *); 156276881Sbaptprotected void cv_yank(EditLine *, const Char *, int); 157296435Spfgprotected Char *cv_next_word(EditLine*, Char *, Char *, int, int (*)(Int)); 158296435Spfgprotected Char *cv_prev_word(Char *, Char *, int, int (*)(Int)); 159296435Spfgprotected Char *c__next_word(Char *, Char *, int, int (*)(Int)); 160296435Spfgprotected Char *c__prev_word(Char *, Char *, int, int (*)(Int)); 16184260Sobrienprotected void c_insert(EditLine *, int); 16284260Sobrienprotected void c_delbefore(EditLine *, int); 163148834Sstefanfprotected void c_delbefore1(EditLine *); 16484260Sobrienprotected void c_delafter(EditLine *, int); 165148834Sstefanfprotected void c_delafter1(EditLine *); 166276881Sbaptprotected int c_gets(EditLine *, Char *, const Char *); 16784260Sobrienprotected int c_hpos(EditLine *); 1681573Srgrimes 16984260Sobrienprotected int ch_init(EditLine *); 170148834Sstefanfprotected void ch_reset(EditLine *, int); 171276881Sbaptprotected int ch_resizefun(EditLine *, el_zfunc_t, void *); 172276881Sbaptprotected int ch_aliasfun(EditLine *, el_afunc_t, void *); 17392917Sobrienprotected int ch_enlargebufs(EditLine *, size_t); 17484260Sobrienprotected void ch_end(EditLine *); 1751573Srgrimes 1761573Srgrimes#endif /* _h_el_chared */ 177