Update libedit from NetBSD.
[dragonfly.git] / lib / libedit / readline / readline.h
1 /*-
2  * Copyright (c) 1997 The NetBSD Foundation, Inc.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to The NetBSD Foundation
6  * by Jaromir Dolecek.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *      This product includes software developed by the NetBSD
19  *      Foundation, Inc. and its contributors.
20  * 4. Neither the name of The NetBSD Foundation nor the names of its
21  *    contributors may be used to endorse or promote products derived
22  *    from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
25  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
28  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  * $NetBSD: readline.h,v 1.16 2005/06/11 18:18:59 christos Exp $
37  * $DragonFly: src/lib/libedit/readline/readline.h,v 1.1 2005/11/13 11:58:30 corecode Exp $
38  */
39 #ifndef _READLINE_H_
40 #define _READLINE_H_
41
42 #include <sys/types.h>
43
44 /* list of readline stuff supported by editline library's readline wrapper */
45
46 /* typedefs */
47 typedef int       Function(const char *, int);
48 typedef void      VFunction(void);
49 typedef void      VCPFunction(char *);
50 typedef char     *CPFunction(const char *, int);
51 typedef char    **CPPFunction(const char *, int, int);
52
53 typedef struct _hist_entry {
54         const char      *line;
55         const char      *data;
56 } HIST_ENTRY;
57
58 typedef struct _keymap_entry {
59         char type;
60 #define ISFUNC  0
61 #define ISKMAP  1
62 #define ISMACR  2
63         Function *function;
64 } KEYMAP_ENTRY;
65
66 #define KEYMAP_SIZE     256
67
68 typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
69 typedef KEYMAP_ENTRY *Keymap;
70
71 #define control_character_threshold     0x20
72 #define control_character_bit           0x40
73
74 #ifndef CTRL
75 #include <sys/ioctl.h>
76 #if !defined(__sun__) && !defined(__hpux__)
77 #include <sys/ttydefaults.h>
78 #endif
79 #ifndef CTRL
80 #define CTRL(c)         ((c) & 037)
81 #endif
82 #endif
83 #ifndef UNCTRL
84 #define UNCTRL(c)       (((c) - 'a' + 'A')|control_character_bit)
85 #endif
86
87 #define RUBOUT          0x7f
88 #define ABORT_CHAR      CTRL('G')
89
90 /* global variables used by readline enabled applications */
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94 extern const char       *rl_library_version;
95 extern char             *rl_readline_name;
96 extern FILE             *rl_instream;
97 extern FILE             *rl_outstream;
98 extern char             *rl_line_buffer;
99 extern int               rl_point, rl_end;
100 extern int               history_base, history_length;
101 extern int               max_input_history;
102 extern char             *rl_basic_word_break_characters;
103 extern char             *rl_completer_word_break_characters;
104 extern char             *rl_completer_quote_characters;
105 extern Function         *rl_completion_entry_function;
106 extern CPPFunction      *rl_attempted_completion_function;
107 extern int               rl_attempted_completion_over;
108 extern int              rl_completion_type;
109 extern int              rl_completion_query_items;
110 extern char             *rl_special_prefixes;
111 extern int              rl_completion_append_character;
112 extern int              rl_inhibit_completion;
113 extern Function         *rl_pre_input_hook;
114 extern Function         *rl_startup_hook;
115 extern char             *rl_terminal_name;
116 extern int              rl_already_prompted;
117 extern char             *rl_prompt;
118 /*
119  * The following is not implemented
120  */
121 extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
122                         emacs_meta_keymap,
123                         emacs_ctlx_keymap;
124 extern int              rl_filename_completion_desired;
125 extern int              rl_ignore_completion_duplicates;
126 extern Function         *rl_getc_function;
127 extern VFunction        *rl_redisplay_function;
128 extern VFunction        *rl_completion_display_matches_hook;
129 extern VFunction        *rl_prep_term_function;
130 extern VFunction        *rl_deprep_term_function;
131
132 /* supported functions */
133 char            *readline(const char *);
134 int              rl_initialize(void);
135
136 void             using_history(void);
137 int              add_history(const char *);
138 void             clear_history(void);
139 void             stifle_history(int);
140 int              unstifle_history(void);
141 int              history_is_stifled(void);
142 int              where_history(void);
143 HIST_ENTRY      *current_history(void);
144 HIST_ENTRY      *history_get(int);
145 int              history_total_bytes(void);
146 int              history_set_pos(int);
147 HIST_ENTRY      *previous_history(void);
148 HIST_ENTRY      *next_history(void);
149 int              history_search(const char *, int);
150 int              history_search_prefix(const char *, int);
151 int              history_search_pos(const char *, int, int);
152 int              read_history(const char *);
153 int              write_history(const char *);
154 int              history_expand(char *, char **);
155 char           **history_tokenize(const char *);
156 const char      *get_history_event(const char *, int *, int);
157 char            *history_arg_extract(int, int, const char *);
158
159 char            *tilde_expand(char *);
160 char            *filename_completion_function(const char *, int);
161 char            *username_completion_function(const char *, int);
162 int              rl_complete(int, int);
163 int              rl_read_key(void);
164 char           **completion_matches(const char *, CPFunction *);
165 void             rl_display_match_list(char **, int, int);
166
167 int              rl_insert(int, int);
168 void             rl_reset_terminal(const char *);
169 int              rl_bind_key(int, int (*)(int, int));
170 int              rl_newline(int, int);
171 void             rl_callback_read_char(void);
172 void             rl_callback_handler_install(const char *, VCPFunction *);
173 void             rl_callback_handler_remove(void);
174 void             rl_redisplay(void);
175 int              rl_get_previous_history(int, int);
176 void             rl_prep_terminal(int);
177 void             rl_deprep_terminal(void);
178 int              rl_read_init_file(const char *);
179 int              rl_parse_and_bind(const char *);
180 int              rl_variable_bind(const char *, const char *);
181 void             rl_stuff_char(int);
182 int              rl_add_defun(const char *, Function *, int);
183
184 /*
185  * The following are not implemented
186  */
187 Keymap           rl_get_keymap(void);
188 Keymap           rl_make_bare_keymap(void);
189 int              rl_generic_bind(int, const char *, const char *, Keymap);
190 int              rl_bind_key_in_map(int, Function *, Keymap);
191 #ifdef __cplusplus
192 }
193 #endif
194
195 #endif /* _READLINE_H_ */