jpayne@69
|
1 /* $NetBSD: readline.h,v 1.55 2023/04/25 17:51:32 christos Exp $ */
|
jpayne@69
|
2
|
jpayne@69
|
3 /*-
|
jpayne@69
|
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
|
jpayne@69
|
5 * All rights reserved.
|
jpayne@69
|
6 *
|
jpayne@69
|
7 * This code is derived from software contributed to The NetBSD Foundation
|
jpayne@69
|
8 * by Jaromir Dolecek.
|
jpayne@69
|
9 *
|
jpayne@69
|
10 * Redistribution and use in source and binary forms, with or without
|
jpayne@69
|
11 * modification, are permitted provided that the following conditions
|
jpayne@69
|
12 * are met:
|
jpayne@69
|
13 * 1. Redistributions of source code must retain the above copyright
|
jpayne@69
|
14 * notice, this list of conditions and the following disclaimer.
|
jpayne@69
|
15 * 2. Redistributions in binary form must reproduce the above copyright
|
jpayne@69
|
16 * notice, this list of conditions and the following disclaimer in the
|
jpayne@69
|
17 * documentation and/or other materials provided with the distribution.
|
jpayne@69
|
18 *
|
jpayne@69
|
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
jpayne@69
|
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
jpayne@69
|
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
jpayne@69
|
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
jpayne@69
|
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
jpayne@69
|
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
jpayne@69
|
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
jpayne@69
|
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
jpayne@69
|
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
jpayne@69
|
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
jpayne@69
|
29 * POSSIBILITY OF SUCH DAMAGE.
|
jpayne@69
|
30 */
|
jpayne@69
|
31 #ifndef _READLINE_H_
|
jpayne@69
|
32 #define _READLINE_H_
|
jpayne@69
|
33
|
jpayne@69
|
34 #include <sys/types.h>
|
jpayne@69
|
35 #include <stdio.h>
|
jpayne@69
|
36
|
jpayne@69
|
37 /* list of readline stuff supported by editline library's readline wrapper */
|
jpayne@69
|
38
|
jpayne@69
|
39 /* typedefs */
|
jpayne@69
|
40 typedef int rl_linebuf_func_t(const char *, int);
|
jpayne@69
|
41 typedef void rl_voidfunc_t(void);
|
jpayne@69
|
42 typedef void rl_vintfunc_t(int);
|
jpayne@69
|
43 typedef void rl_vcpfunc_t(char *);
|
jpayne@69
|
44 typedef char **rl_completion_func_t(const char *, int, int);
|
jpayne@69
|
45 typedef char *rl_compentry_func_t(const char *, int);
|
jpayne@69
|
46 typedef void rl_compdisp_func_t(char **, int, int);
|
jpayne@69
|
47 typedef int rl_command_func_t(int, int);
|
jpayne@69
|
48 typedef int rl_hook_func_t(void);
|
jpayne@69
|
49 typedef int rl_icppfunc_t(char **);
|
jpayne@69
|
50
|
jpayne@69
|
51 /* only supports length */
|
jpayne@69
|
52 typedef struct {
|
jpayne@69
|
53 int length;
|
jpayne@69
|
54 } HISTORY_STATE;
|
jpayne@69
|
55
|
jpayne@69
|
56 typedef void *histdata_t;
|
jpayne@69
|
57
|
jpayne@69
|
58 typedef struct _hist_entry {
|
jpayne@69
|
59 const char *line;
|
jpayne@69
|
60 histdata_t data;
|
jpayne@69
|
61 } HIST_ENTRY;
|
jpayne@69
|
62
|
jpayne@69
|
63 typedef struct _keymap_entry {
|
jpayne@69
|
64 char type;
|
jpayne@69
|
65 #define ISFUNC 0
|
jpayne@69
|
66 #define ISKMAP 1
|
jpayne@69
|
67 #define ISMACR 2
|
jpayne@69
|
68 rl_linebuf_func_t *function;
|
jpayne@69
|
69 } KEYMAP_ENTRY;
|
jpayne@69
|
70
|
jpayne@69
|
71 #define KEYMAP_SIZE 256
|
jpayne@69
|
72
|
jpayne@69
|
73 typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
|
jpayne@69
|
74 typedef KEYMAP_ENTRY *Keymap;
|
jpayne@69
|
75
|
jpayne@69
|
76 #define control_character_threshold 0x20
|
jpayne@69
|
77 #define control_character_bit 0x40
|
jpayne@69
|
78
|
jpayne@69
|
79 #ifndef CTRL
|
jpayne@69
|
80 #include <sys/ioctl.h>
|
jpayne@69
|
81 #if !defined(__sun) && !defined(__hpux) && !defined(_AIX)
|
jpayne@69
|
82 #include <sys/ttydefaults.h>
|
jpayne@69
|
83 #endif
|
jpayne@69
|
84 #ifndef CTRL
|
jpayne@69
|
85 #define CTRL(c) ((c) & 037)
|
jpayne@69
|
86 #endif
|
jpayne@69
|
87 #endif
|
jpayne@69
|
88 #ifndef UNCTRL
|
jpayne@69
|
89 #define UNCTRL(c) (((c) - 'a' + 'A')|control_character_bit)
|
jpayne@69
|
90 #endif
|
jpayne@69
|
91
|
jpayne@69
|
92 #define RUBOUT 0x7f
|
jpayne@69
|
93 #define ABORT_CHAR CTRL('G')
|
jpayne@69
|
94 #define RL_READLINE_VERSION 0x0402
|
jpayne@69
|
95 #define RL_PROMPT_START_IGNORE '\1'
|
jpayne@69
|
96 #define RL_PROMPT_END_IGNORE '\2'
|
jpayne@69
|
97
|
jpayne@69
|
98 #define RL_STATE_NONE 0x000000
|
jpayne@69
|
99 #define RL_STATE_DONE 0x000001
|
jpayne@69
|
100
|
jpayne@69
|
101 #define RL_SETSTATE(x) (rl_readline_state |= ((unsigned long) x))
|
jpayne@69
|
102 #define RL_UNSETSTATE(x) (rl_readline_state &= ~((unsigned long) x))
|
jpayne@69
|
103 #define RL_ISSTATE(x) (rl_readline_state & ((unsigned long) x))
|
jpayne@69
|
104
|
jpayne@69
|
105 /* global variables used by readline enabled applications */
|
jpayne@69
|
106 #ifdef __cplusplus
|
jpayne@69
|
107 extern "C" {
|
jpayne@69
|
108 #endif
|
jpayne@69
|
109 extern const char *rl_library_version;
|
jpayne@69
|
110 extern int rl_readline_version;
|
jpayne@69
|
111 extern const char *rl_readline_name;
|
jpayne@69
|
112 extern FILE *rl_instream;
|
jpayne@69
|
113 extern FILE *rl_outstream;
|
jpayne@69
|
114 extern char *rl_line_buffer;
|
jpayne@69
|
115 extern int rl_point, rl_end;
|
jpayne@69
|
116 extern const char *rl_basic_quote_characters;
|
jpayne@69
|
117 extern const char *rl_basic_word_break_characters;
|
jpayne@69
|
118 extern char *rl_completer_word_break_characters;
|
jpayne@69
|
119 extern const char *rl_completer_quote_characters;
|
jpayne@69
|
120 extern rl_compentry_func_t *rl_completion_entry_function;
|
jpayne@69
|
121 extern char *(*rl_completion_word_break_hook)(void);
|
jpayne@69
|
122 extern rl_completion_func_t *rl_attempted_completion_function;
|
jpayne@69
|
123 extern int rl_attempted_completion_over;
|
jpayne@69
|
124 extern int rl_completion_type;
|
jpayne@69
|
125 extern int rl_completion_query_items;
|
jpayne@69
|
126 extern const char *rl_special_prefixes;
|
jpayne@69
|
127 extern int rl_completion_append_character;
|
jpayne@69
|
128 extern int rl_inhibit_completion;
|
jpayne@69
|
129 extern rl_hook_func_t *rl_pre_input_hook;
|
jpayne@69
|
130 extern rl_hook_func_t *rl_startup_hook;
|
jpayne@69
|
131 extern char *rl_terminal_name;
|
jpayne@69
|
132 extern int rl_already_prompted;
|
jpayne@69
|
133 extern char *rl_prompt;
|
jpayne@69
|
134 extern int rl_done;
|
jpayne@69
|
135 extern rl_vcpfunc_t *rl_linefunc;
|
jpayne@69
|
136 extern rl_hook_func_t *rl_startup1_hook;
|
jpayne@69
|
137 extern char *rl_prompt_saved;
|
jpayne@69
|
138 extern int history_base, history_length;
|
jpayne@69
|
139 extern int history_offset;
|
jpayne@69
|
140 extern char history_expansion_char;
|
jpayne@69
|
141 extern char history_subst_char;
|
jpayne@69
|
142 extern char *history_no_expand_chars;
|
jpayne@69
|
143 extern rl_linebuf_func_t *history_inhibit_expansion_function;
|
jpayne@69
|
144 extern int max_input_history;
|
jpayne@69
|
145
|
jpayne@69
|
146 /*
|
jpayne@69
|
147 * The following is not implemented
|
jpayne@69
|
148 */
|
jpayne@69
|
149 extern unsigned long rl_readline_state;
|
jpayne@69
|
150 extern int rl_catch_signals;
|
jpayne@69
|
151 extern int rl_catch_sigwinch;
|
jpayne@69
|
152 extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
|
jpayne@69
|
153 emacs_meta_keymap,
|
jpayne@69
|
154 emacs_ctlx_keymap;
|
jpayne@69
|
155 extern int rl_filename_completion_desired;
|
jpayne@69
|
156 extern int rl_ignore_completion_duplicates;
|
jpayne@69
|
157 extern int (*rl_getc_function)(FILE *);
|
jpayne@69
|
158 extern rl_voidfunc_t *rl_redisplay_function;
|
jpayne@69
|
159 extern rl_compdisp_func_t *rl_completion_display_matches_hook;
|
jpayne@69
|
160 extern rl_vintfunc_t *rl_prep_term_function;
|
jpayne@69
|
161 extern rl_voidfunc_t *rl_deprep_term_function;
|
jpayne@69
|
162 extern rl_hook_func_t *rl_event_hook;
|
jpayne@69
|
163 extern int readline_echoing_p;
|
jpayne@69
|
164 extern int _rl_print_completions_horizontally;
|
jpayne@69
|
165 extern int _rl_complete_mark_directories;
|
jpayne@69
|
166 extern rl_icppfunc_t *rl_directory_completion_hook;
|
jpayne@69
|
167 extern int rl_completion_suppress_append;
|
jpayne@69
|
168 extern int rl_sort_completion_matches;
|
jpayne@69
|
169 extern int _rl_completion_prefix_display_length;
|
jpayne@69
|
170 extern int _rl_echoing_p;
|
jpayne@69
|
171 extern int history_max_entries;
|
jpayne@69
|
172 extern char *rl_display_prompt;
|
jpayne@69
|
173 extern int rl_erase_empty_line;
|
jpayne@69
|
174
|
jpayne@69
|
175 /* supported functions */
|
jpayne@69
|
176 char *readline(const char *);
|
jpayne@69
|
177 int rl_initialize(void);
|
jpayne@69
|
178
|
jpayne@69
|
179 void using_history(void);
|
jpayne@69
|
180 int add_history(const char *);
|
jpayne@69
|
181 void clear_history(void);
|
jpayne@69
|
182 int append_history(int, const char *);
|
jpayne@69
|
183 void stifle_history(int);
|
jpayne@69
|
184 int unstifle_history(void);
|
jpayne@69
|
185 int history_is_stifled(void);
|
jpayne@69
|
186 int where_history(void);
|
jpayne@69
|
187 HIST_ENTRY *current_history(void);
|
jpayne@69
|
188 HIST_ENTRY *history_get(int);
|
jpayne@69
|
189 HIST_ENTRY *remove_history(int);
|
jpayne@69
|
190 HIST_ENTRY *replace_history_entry(int, const char *, histdata_t);
|
jpayne@69
|
191 int history_total_bytes(void);
|
jpayne@69
|
192 int history_set_pos(int);
|
jpayne@69
|
193 HIST_ENTRY *previous_history(void);
|
jpayne@69
|
194 HIST_ENTRY *next_history(void);
|
jpayne@69
|
195 HIST_ENTRY **history_list(void);
|
jpayne@69
|
196 int history_search(const char *, int);
|
jpayne@69
|
197 int history_search_prefix(const char *, int);
|
jpayne@69
|
198 int history_search_pos(const char *, int, int);
|
jpayne@69
|
199 int read_history(const char *);
|
jpayne@69
|
200 int write_history(const char *);
|
jpayne@69
|
201 int history_truncate_file(const char *, int);
|
jpayne@69
|
202 int history_expand(char *, char **);
|
jpayne@69
|
203 char **history_tokenize(const char *);
|
jpayne@69
|
204 const char *get_history_event(const char *, int *, int);
|
jpayne@69
|
205 char *history_arg_extract(int, int, const char *);
|
jpayne@69
|
206
|
jpayne@69
|
207 char *tilde_expand(char *);
|
jpayne@69
|
208 char *filename_completion_function(const char *, int);
|
jpayne@69
|
209 char *username_completion_function(const char *, int);
|
jpayne@69
|
210 int rl_complete(int, int);
|
jpayne@69
|
211 int rl_read_key(void);
|
jpayne@69
|
212 char **completion_matches(/* const */ char *, rl_compentry_func_t *);
|
jpayne@69
|
213 void rl_display_match_list(char **, int, int);
|
jpayne@69
|
214
|
jpayne@69
|
215 int rl_insert(int, int);
|
jpayne@69
|
216 int rl_insert_text(const char *);
|
jpayne@69
|
217 int rl_reset_terminal(const char *);
|
jpayne@69
|
218 void rl_resize_terminal(void);
|
jpayne@69
|
219 int rl_bind_key(int, rl_command_func_t *);
|
jpayne@69
|
220 int rl_newline(int, int);
|
jpayne@69
|
221 void rl_callback_read_char(void);
|
jpayne@69
|
222 void rl_callback_handler_install(const char *, rl_vcpfunc_t *);
|
jpayne@69
|
223 void rl_callback_handler_remove(void);
|
jpayne@69
|
224 void rl_redisplay(void);
|
jpayne@69
|
225 int rl_get_previous_history(int, int);
|
jpayne@69
|
226 void rl_prep_terminal(int);
|
jpayne@69
|
227 void rl_deprep_terminal(void);
|
jpayne@69
|
228 int rl_read_init_file(const char *);
|
jpayne@69
|
229 int rl_parse_and_bind(const char *);
|
jpayne@69
|
230 int rl_variable_bind(const char *, const char *);
|
jpayne@69
|
231 int rl_stuff_char(int);
|
jpayne@69
|
232 int rl_add_defun(const char *, rl_command_func_t *, int);
|
jpayne@69
|
233 HISTORY_STATE *history_get_history_state(void);
|
jpayne@69
|
234 void rl_get_screen_size(int *, int *);
|
jpayne@69
|
235 void rl_set_screen_size(int, int);
|
jpayne@69
|
236 char *rl_filename_completion_function(const char *, int);
|
jpayne@69
|
237 int _rl_abort_internal(void);
|
jpayne@69
|
238 int _rl_qsort_string_compare(char **, char **);
|
jpayne@69
|
239 char **rl_completion_matches(const char *, rl_compentry_func_t *);
|
jpayne@69
|
240 void rl_forced_update_display(void);
|
jpayne@69
|
241 int rl_set_prompt(const char *);
|
jpayne@69
|
242 int rl_on_new_line(void);
|
jpayne@69
|
243 void rl_reset_after_signal(void);
|
jpayne@69
|
244 void rl_echo_signal_char(int);
|
jpayne@69
|
245 int rl_crlf(void);
|
jpayne@69
|
246 int rl_ding(void);
|
jpayne@69
|
247 char *rl_copy_text(int, int);
|
jpayne@69
|
248 void rl_replace_line(const char *, int);
|
jpayne@69
|
249 int rl_delete_text(int, int);
|
jpayne@69
|
250 void rl_message(const char *format, ...)
|
jpayne@69
|
251 __attribute__((__format__(__printf__, 1, 2)));
|
jpayne@69
|
252 void rl_save_prompt(void);
|
jpayne@69
|
253 void rl_restore_prompt(void);
|
jpayne@69
|
254
|
jpayne@69
|
255 /*
|
jpayne@69
|
256 * The following are not implemented
|
jpayne@69
|
257 */
|
jpayne@69
|
258 int rl_kill_text(int, int);
|
jpayne@69
|
259 Keymap rl_get_keymap(void);
|
jpayne@69
|
260 void rl_set_keymap(Keymap);
|
jpayne@69
|
261 Keymap rl_make_bare_keymap(void);
|
jpayne@69
|
262 int rl_generic_bind(int, const char *, const char *, Keymap);
|
jpayne@69
|
263 int rl_bind_key_in_map(int, rl_command_func_t *, Keymap);
|
jpayne@69
|
264 int rl_set_key(const char *, rl_command_func_t *, Keymap);
|
jpayne@69
|
265 void rl_cleanup_after_signal(void);
|
jpayne@69
|
266 void rl_free_line_state(void);
|
jpayne@69
|
267 int rl_set_keyboard_input_timeout(int);
|
jpayne@69
|
268 int rl_abort(int, int);
|
jpayne@69
|
269 int rl_set_keymap_name(const char *, Keymap);
|
jpayne@69
|
270 histdata_t free_history_entry(HIST_ENTRY *);
|
jpayne@69
|
271 void _rl_erase_entire_line(void);
|
jpayne@69
|
272
|
jpayne@69
|
273 #ifdef __cplusplus
|
jpayne@69
|
274 }
|
jpayne@69
|
275 #endif
|
jpayne@69
|
276
|
jpayne@69
|
277 #endif /* _READLINE_H_ */
|