1 /* $FreeBSD: src/include/histedit.h,v 1.5 1999/08/27 23:44:50 peter Exp $ */
2 /* $DragonFly: src/include/histedit.h,v 1.3 2003/11/14 01:01:43 dillon Exp $ */
3 /* $NetBSD: histedit.h,v 1.5 1997/04/11 17:52:45 christos Exp $ */
6 * Copyright (c) 1992, 1993
7 * The Regents of the University of California. All rights reserved.
9 * This code is derived from software contributed to Berkeley by
10 * Christos Zoulas of Cornell University.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the University of
23 * California, Berkeley and its contributors.
24 * 4. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * @(#)histedit.h 8.2 (Berkeley) 1/3/94
44 * histedit.h: Line editor and history interface.
49 #include <sys/types.h>
55 typedef struct editline EditLine
;
58 * For user-defined function interface
60 typedef struct lineinfo
{
68 * EditLine editor function return codes.
69 * For user-defined function interface
79 #define CC_REDISPLAY 8
82 * Initialization, cleanup, and resetting
84 EditLine
*el_init (const char *, FILE *, FILE *);
85 void el_reset (EditLine
*);
86 void el_end (EditLine
*);
90 * Get a line, a character or push a string back in the input queue
92 const char *el_gets (EditLine
*, int *);
93 int el_getc (EditLine
*, char *);
94 void el_push (EditLine
*, const char *);
97 * High level function internals control
98 * Parses argc, argv array and executes builtin editline commands
100 int el_parse (EditLine
*, int, char **);
103 * Low level editline access function
105 int el_set (EditLine
*, int, ...);
108 * el_set/el_get parameters
110 #define EL_PROMPT 0 /* , el_pfunc_t); */
111 #define EL_TERMINAL 1 /* , const char *); */
112 #define EL_EDITOR 2 /* , const char *); */
113 #define EL_SIGNAL 3 /* , int); */
114 #define EL_BIND 4 /* , const char *, ..., NULL); */
115 #define EL_TELLTC 5 /* , const char *, ..., NULL); */
116 #define EL_SETTC 6 /* , const char *, ..., NULL); */
117 #define EL_ECHOTC 7 /* , const char *, ..., NULL); */
118 #define EL_SETTY 8 /* , const char *, ..., NULL); */
119 #define EL_ADDFN 9 /* , const char *, const char * */
121 #define EL_HIST 10 /* , hist_fun_t, const char *); */
124 * Source named file or $PWD/.editrc or $HOME/.editrc
126 int el_source (EditLine
*, const char *);
129 * Must be called when the terminal changes size; If EL_SIGNAL
130 * is set this is done automatically otherwise it is the responsibility
133 void el_resize (EditLine
*);
135 void el_data_set (EditLine
*, void *);
136 void * el_data_get (EditLine
*);
140 * User-defined function interface.
142 const LineInfo
*el_line (EditLine
*);
143 int el_insertstr (EditLine
*, char *);
144 void el_deletestr (EditLine
*, int);
150 typedef struct history History
;
152 typedef struct HistEvent
{
158 * History access functions.
160 History
* history_init (void);
161 void history_end (History
*);
163 const HistEvent
* history (History
*, int, ...);
165 #define H_FUNC 0 /* , UTSL */
166 #define H_EVENT 1 /* , const int); */
167 #define H_FIRST 2 /* , void); */
168 #define H_LAST 3 /* , void); */
169 #define H_PREV 4 /* , void); */
170 #define H_NEXT 5 /* , void); */
171 #define H_CURR 6 /* , void); */
172 #define H_ADD 7 /* , const char*); */
173 #define H_ENTER 8 /* , const char*); */
174 #define H_END 9 /* , void); */
175 #define H_NEXT_STR 10 /* , const char*); */
176 #define H_PREV_STR 11 /* , const char*); */
177 #define H_NEXT_EVENT 12 /* , const int); */
178 #define H_PREV_EVENT 13 /* , const int); */
179 #define H_LOAD 14 /* , const char *); */
180 #define H_SAVE 15 /* , const char *); */
181 #define H_CLEAR 16 /* , void); */
183 #endif /* _h_editline */