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 $ */
5 * Copyright (c) 1992, 1993
6 * The Regents of the University of California. All rights reserved.
8 * This code is derived from software contributed to Berkeley by
9 * Christos Zoulas of Cornell University.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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
35 * @(#)chared.h 8.1 (Berkeley) 6/4/93
39 * el.chared.h: Character editor interface
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
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
57 * Undo information for vi - no undo in emacs (yet)
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 */
66 typedef struct c_redo_t
{
67 wchar_t *buf
; /* redo insert key sequence */
70 el_action_t cmd
; /* command to redo */
71 wchar_t ch
; /* char that invoked it */
73 int action
; /* from cv_action() */
77 * Current action information for vi
79 typedef struct c_vcmd_t
{
85 * Kill buffer for emacs
87 typedef struct c_kill_t
{
93 typedef void (*el_zfunc_t
)(EditLine
*, void *);
96 * Note that we use both data structures because the user can bind
97 * commands from both editors!
99 typedef struct el_chared_t
{
104 el_zfunc_t c_resizefun
;
111 #define isglob(a) (strchr("*[]?", (a)) != NULL)
118 #define CHAR_FWD (+1)
119 #define CHAR_BACK (-1)
121 #define MODE_INSERT 0
122 #define MODE_REPLACE 1
123 #define MODE_REPLACE_1 2
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,
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
*);
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
*);
152 #endif /* _h_el_chared */