2 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * This code is derived from software contributed to The NetBSD Foundation
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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.
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.
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 $
42 #include <sys/types.h>
44 /* list of readline stuff supported by editline library's readline wrapper */
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);
53 typedef struct _hist_entry {
58 typedef struct _keymap_entry {
66 #define KEYMAP_SIZE 256
68 typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
69 typedef KEYMAP_ENTRY *Keymap;
71 #define control_character_threshold 0x20
72 #define control_character_bit 0x40
75 #include <sys/ioctl.h>
76 #if !defined(__sun__) && !defined(__hpux__)
77 #include <sys/ttydefaults.h>
80 #define CTRL(c) ((c) & 037)
84 #define UNCTRL(c) (((c) - 'a' + 'A')|control_character_bit)
88 #define ABORT_CHAR CTRL('G')
90 /* global variables used by readline enabled applications */
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;
119 * The following is not implemented
121 extern KEYMAP_ENTRY_ARRAY emacs_standard_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;
132 /* supported functions */
133 char *readline(const char *);
134 int rl_initialize(void);
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 *);
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);
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);
185 * The following are not implemented
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);
195 #endif /* _READLINE_H_ */