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