1 /** $MirOS: src/lib/libedit/readline/readline.h,v 1.7 2005/04/19 19:14:54 tg Exp $ */ 2 /* $OpenBSD: readline.h,v 1.2 2003/11/25 20:12:39 otto Exp $ */ 3 /* $NetBSD: readline.h,v 1.13 2005/04/12 22:01:40 christos Exp $ */ 4 5 /*- 6 * Copyright (c) 1997 The NetBSD Foundation, Inc. 7 * All rights reserved. 8 * 9 * This code is derived from software contributed to The NetBSD Foundation 10 * by Jaromir Dolecek. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 3. All advertising materials mentioning features or use of this software 21 * must display the following acknowledgement: 22 * This product includes software developed by the NetBSD 23 * Foundation, Inc. and its contributors. 24 * 4. Neither the name of The NetBSD Foundation nor the names of its 25 * contributors may be used to endorse or promote products derived 26 * from this software without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 29 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 31 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 32 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 * POSSIBILITY OF SUCH DAMAGE. 39 */ 40 41 #ifndef _READLINE_H_ 42 #define _READLINE_H_ 43 44 #include <sys/types.h> 45 46 /* list of readline stuff supported by editline library's readline wrapper */ 47 48 /* typedefs */ 49 typedef int Function(const char *, int); 50 typedef void VFunction(void); 51 typedef void VFunctionC(char *); 52 typedef char *CPFunction(const char *, int); 53 typedef char **CPPFunction(const char *, int, int); 54 55 typedef struct _hist_entry { 56 const char *line; 57 const char *data; 58 } HIST_ENTRY; 59 60 typedef struct _keymap_entry { 61 char type; 62 #define ISFUNC 0 63 #define ISKMAP 1 64 #define ISMACR 2 65 Function *function; 66 } KEYMAP_ENTRY; 67 68 #define KEYMAP_SIZE 256 69 70 typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE]; 71 typedef KEYMAP_ENTRY *Keymap; 72 73 #define control_character_threshold 0x20 74 #define control_character_bit 0x40 75 76 #ifndef CTRL 77 #include <sys/ioctl.h> 78 #if !defined(__sun__) && !defined(__hpux__) 79 #include <sys/ttydefaults.h> 80 #endif 81 #ifndef CTRL 82 #define CTRL(c) ((c) & 037) 83 #endif 84 #endif 85 #ifndef UNCTRL 86 #define UNCTRL(c) (((c) - 'a' + 'A') | control_character_bit) 87 #endif 88 89 #define RUBOUT 0x7f 90 #define ABORT_CHAR CTRL('G') 91 92 /* global variables used by readline enabled applications */ 93 __BEGIN_DECLS 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; 118 extern VFunction *rl_event_hook; 119 120 /* 121 * The following is not implemented 122 */ 123 extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, 124 emacs_meta_keymap, 125 emacs_ctlx_keymap; 126 extern int rl_filename_completion_desired; 127 extern int rl_ignore_completion_duplicates; 128 extern Function *rl_getc_function; 129 extern VFunction *rl_redisplay_function; 130 extern VFunction *rl_completion_display_matches_hook; 131 extern VFunction *rl_prep_term_function; 132 extern VFunction *rl_deprep_term_function; 133 134 /* supported functions */ 135 char *readline(const char *); 136 int rl_initialize(void); 137 138 void using_history(void); 139 int add_history(const char *); 140 void clear_history(void); 141 void stifle_history(int); 142 int unstifle_history(void); 143 int history_is_stifled(void); 144 int where_history(void); 145 HIST_ENTRY *current_history(void); 146 HIST_ENTRY *history_get(int); 147 int history_total_bytes(void); 148 int history_set_pos(int); 149 HIST_ENTRY *previous_history(void); 150 HIST_ENTRY *next_history(void); 151 int history_search(const char *, int); 152 int history_search_prefix(const char *, int); 153 int history_search_pos(const char *, int, int); 154 int read_history(const char *); 155 int write_history(const char *); 156 int history_expand(char *, char **); 157 char **history_tokenize(const char *); 158 const char *get_history_event(const char *, int *, int); 159 char *history_arg_extract(int, int, const char *); 160 161 char *tilde_expand(char *); 162 char *rl_filename_completion_function(const char *, int); 163 char *rl_username_completion_function(const char *, int); 164 int rl_complete(int, int); 165 int rl_read_key(void); 166 char **completion_matches(const char *, CPFunction *); 167 void rl_display_match_list(char **, int, int); 168 169 int rl_insert(int, int); 170 void rl_reset_terminal(const char *); 171 int rl_bind_key(int, int (*)(int, int)); 172 int rl_newline(int, int); 173 void rl_callback_read_char(void); 174 void rl_callback_handler_install(const char *, VFunctionC *); 175 void rl_callback_handler_remove(void); 176 void rl_redisplay(void); 177 int rl_get_previous_history(int, int); 178 void rl_prep_terminal(int); 179 void rl_deprep_terminal(void); 180 int rl_read_init_file(const char *); 181 int rl_parse_and_bind(const char *); 182 int rl_variable_bind(const char *, const char *); 183 void rl_stuff_char(int); 184 int rl_add_defun(const char *, Function *, int); 185 186 void rl_get_screen_size(int *, int *); 187 void rl_set_screen_size(int, int); 188 189 /* 190 * The following are not implemented 191 */ 192 Keymap rl_get_keymap(void); 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 __END_DECLS 197 198 #endif /* _READLINE_H_ */ 199