1 /* $NetBSD: readline.h,v 1.31 2010/08/04 20:29:18 christos Exp $ */
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
36 #include <sys/types.h>
39 /* list of readline stuff supported by editline library's readline wrapper */
42 typedef int Function(const char *, int);
43 typedef void VFunction(void);
44 typedef void VCPFunction(char *);
45 typedef char *CPFunction(const char *, int);
46 typedef char **CPPFunction(const char *, int, int);
47 typedef char *rl_compentry_func_t(const char *, int);
48 typedef int rl_command_func_t(int, int);
50 /* only supports length */
55 typedef void *histdata_t;
57 typedef struct _hist_entry {
62 typedef struct _keymap_entry {
70 #define KEYMAP_SIZE 256
72 typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
73 typedef KEYMAP_ENTRY *Keymap;
75 #define control_character_threshold 0x20
76 #define control_character_bit 0x40
79 #include <sys/ioctl.h>
80 #if !defined(__sun) && !defined(__hpux) && !defined(_AIX)
81 #include <sys/ttydefaults.h>
84 #define CTRL(c) ((c) & 037)
88 #define UNCTRL(c) (((c) - 'a' + 'A')|control_character_bit)
92 #define ABORT_CHAR CTRL('G')
93 #define RL_READLINE_VERSION 0x0402
94 #define RL_PROMPT_START_IGNORE '\1'
95 #define RL_PROMPT_END_IGNORE '\2'
97 /* global variables used by readline enabled applications */
101 extern const char *rl_library_version;
102 extern int rl_readline_version;
103 extern char *rl_readline_name;
104 extern FILE *rl_instream;
105 extern FILE *rl_outstream;
106 extern char *rl_line_buffer;
107 extern int rl_point, rl_end;
108 extern int history_base, history_length;
109 extern int max_input_history;
110 extern char *rl_basic_word_break_characters;
111 extern char *rl_completer_word_break_characters;
112 extern char *rl_completer_quote_characters;
113 extern Function *rl_completion_entry_function;
114 extern CPPFunction *rl_attempted_completion_function;
115 extern int rl_attempted_completion_over;
116 extern int rl_completion_type;
117 extern int rl_completion_query_items;
118 extern char *rl_special_prefixes;
119 extern int rl_completion_append_character;
120 extern int rl_inhibit_completion;
121 extern Function *rl_pre_input_hook;
122 extern Function *rl_startup_hook;
123 extern char *rl_terminal_name;
124 extern int rl_already_prompted;
125 extern char *rl_prompt;
127 * The following is not implemented
129 extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
132 extern int rl_filename_completion_desired;
133 extern int rl_ignore_completion_duplicates;
134 extern int (*rl_getc_function)(FILE *);
135 extern VFunction *rl_redisplay_function;
136 extern VFunction *rl_completion_display_matches_hook;
137 extern VFunction *rl_prep_term_function;
138 extern VFunction *rl_deprep_term_function;
139 extern int readline_echoing_p;
140 extern int _rl_print_completions_horizontally;
142 /* supported functions */
143 char *readline(const char *);
144 int rl_initialize(void);
146 void using_history(void);
147 int add_history(const char *);
148 void clear_history(void);
149 void stifle_history(int);
150 int unstifle_history(void);
151 int history_is_stifled(void);
152 int where_history(void);
153 HIST_ENTRY *current_history(void);
154 HIST_ENTRY *history_get(int);
155 HIST_ENTRY *remove_history(int);
156 /*###152 [lint] syntax error 'histdata_t' [249]%%%*/
157 HIST_ENTRY *replace_history_entry(int, const char *, histdata_t);
158 int history_total_bytes(void);
159 int history_set_pos(int);
160 HIST_ENTRY *previous_history(void);
161 HIST_ENTRY *next_history(void);
162 int history_search(const char *, int);
163 int history_search_prefix(const char *, int);
164 int history_search_pos(const char *, int, int);
165 int read_history(const char *);
166 int write_history(const char *);
167 int history_truncate_file (const char *, int);
168 int history_expand(char *, char **);
169 char **history_tokenize(const char *);
170 const char *get_history_event(const char *, int *, int);
171 char *history_arg_extract(int, int, const char *);
173 char *tilde_expand(char *);
174 char *filename_completion_function(const char *, int);
175 char *username_completion_function(const char *, int);
176 int rl_complete(int, int);
177 int rl_read_key(void);
178 char **completion_matches(const char *, CPFunction *);
179 void rl_display_match_list(char **, int, int);
181 int rl_insert(int, int);
182 int rl_insert_text(const char *);
183 void rl_reset_terminal(const char *);
184 int rl_bind_key(int, rl_command_func_t *);
185 int rl_newline(int, int);
186 void rl_callback_read_char(void);
187 void rl_callback_handler_install(const char *, VCPFunction *);
188 void rl_callback_handler_remove(void);
189 void rl_redisplay(void);
190 int rl_get_previous_history(int, int);
191 void rl_prep_terminal(int);
192 void rl_deprep_terminal(void);
193 int rl_read_init_file(const char *);
194 int rl_parse_and_bind(const char *);
195 int rl_variable_bind(const char *, const char *);
196 void rl_stuff_char(int);
197 int rl_add_defun(const char *, Function *, int);
198 HISTORY_STATE *history_get_history_state(void);
199 void rl_get_screen_size(int *, int *);
200 void rl_set_screen_size(int, int);
201 char *rl_filename_completion_function (const char *, int);
202 int _rl_abort_internal(void);
203 int _rl_qsort_string_compare(char **, char **);
204 char **rl_completion_matches(const char *, rl_compentry_func_t *);
205 void rl_forced_update_display(void);
206 int rl_set_prompt(const char *);
207 int rl_on_new_line(void);
210 * The following are not implemented
212 int rl_kill_text(int, int);
213 Keymap rl_get_keymap(void);
214 void rl_set_keymap(Keymap);
215 Keymap rl_make_bare_keymap(void);
216 int rl_generic_bind(int, const char *, const char *, Keymap);
217 int rl_bind_key_in_map(int, rl_command_func_t *, Keymap);
218 void rl_cleanup_after_signal(void);
219 void rl_free_line_state(void);
224 #endif /* _READLINE_H_ */