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