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