| 1 |
/* $NetBSD: readline.h,v 1.41 2016/10/28 18:32:35 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 Function(const char *, int); |
| 41 |
typedef void VFunction(void); |
| 42 |
typedef void rl_vcpfunc_t(char *); |
| 43 |
typedef char **rl_completion_func_t(const char *, int, int); |
| 44 |
typedef char *rl_compentry_func_t(const char *, int); |
| 45 |
typedef int rl_command_func_t(int, int); |
| 46 |
|
| 47 |
/* only supports length */ |
| 48 |
typedef struct { |
| 49 |
int length; |
| 50 |
} HISTORY_STATE; |
| 51 |
|
| 52 |
typedef void *histdata_t; |
| 53 |
|
| 54 |
typedef struct _hist_entry { |
| 55 |
const char *line; |
| 56 |
histdata_t data; |
| 57 |
} HIST_ENTRY; |
| 58 |
|
| 59 |
typedef struct _keymap_entry { |
| 60 |
char type; |
| 61 |
#define ISFUNC 0 |
| 62 |
#define ISKMAP 1 |
| 63 |
#define ISMACR 2 |
| 64 |
Function *function; |
| 65 |
} KEYMAP_ENTRY; |
| 66 |
|
| 67 |
#define KEYMAP_SIZE 256 |
| 68 |
|
| 69 |
typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE]; |
| 70 |
typedef KEYMAP_ENTRY *Keymap; |
| 71 |
|
| 72 |
#define control_character_threshold 0x20 |
| 73 |
#define control_character_bit 0x40 |
| 74 |
|
| 75 |
#ifndef CTRL |
| 76 |
#include <sys/ioctl.h> |
| 77 |
#if !defined(__sun) && !defined(__hpux) && !defined(_AIX) && !defined(_CYGWIN_) |
| 78 |
#include <sys/ttydefaults.h> |
| 79 |
#endif |
| 80 |
#ifndef CTRL |
| 81 |
#define CTRL(c) ((c) & 037) |
| 82 |
#endif |
| 83 |
#endif |
| 84 |
#ifndef UNCTRL |
| 85 |
#define UNCTRL(c) (((c) - 'a' + 'A')|control_character_bit) |
| 86 |
#endif |
| 87 |
|
| 88 |
#define RUBOUT 0x7f |
| 89 |
#define ABORT_CHAR CTRL('G') |
| 90 |
#define RL_READLINE_VERSION 0x0402 |
| 91 |
#define RL_PROMPT_START_IGNORE '\1' |
| 92 |
#define RL_PROMPT_END_IGNORE '\2' |
| 93 |
|
| 94 |
/* global variables used by readline enabled applications */ |
| 95 |
#ifdef __cplusplus |
| 96 |
extern "C" { |
| 97 |
#endif |
| 98 |
extern const char *rl_library_version; |
| 99 |
extern int rl_readline_version; |
| 100 |
extern char *rl_readline_name; |
| 101 |
extern FILE *rl_instream; |
| 102 |
extern FILE *rl_outstream; |
| 103 |
extern char *rl_line_buffer; |
| 104 |
extern int rl_point, rl_end; |
| 105 |
extern int history_base, history_length; |
| 106 |
extern int max_input_history; |
| 107 |
extern char *rl_basic_word_break_characters; |
| 108 |
extern char *rl_completer_word_break_characters; |
| 109 |
extern char *rl_completer_quote_characters; |
| 110 |
extern rl_compentry_func_t *rl_completion_entry_function; |
| 111 |
extern char *(*rl_completion_word_break_hook)(void); |
| 112 |
extern rl_completion_func_t *rl_attempted_completion_function; |
| 113 |
extern int rl_attempted_completion_over; |
| 114 |
extern int rl_completion_type; |
| 115 |
extern int rl_completion_query_items; |
| 116 |
extern char *rl_special_prefixes; |
| 117 |
extern int rl_completion_append_character; |
| 118 |
extern int rl_inhibit_completion; |
| 119 |
extern Function *rl_pre_input_hook; |
| 120 |
extern Function *rl_startup_hook; |
| 121 |
extern char *rl_terminal_name; |
| 122 |
extern int rl_already_prompted; |
| 123 |
extern char *rl_prompt; |
| 124 |
extern int rl_done; |
| 125 |
/* |
| 126 |
* The following is not implemented |
| 127 |
*/ |
| 128 |
extern int rl_catch_signals; |
| 129 |
extern int rl_catch_sigwinch; |
| 130 |
extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, |
| 131 |
emacs_meta_keymap, |
| 132 |
emacs_ctlx_keymap; |
| 133 |
extern int rl_filename_completion_desired; |
| 134 |
extern int rl_ignore_completion_duplicates; |
| 135 |
extern int (*rl_getc_function)(FILE *); |
| 136 |
extern VFunction *rl_redisplay_function; |
| 137 |
extern VFunction *rl_completion_display_matches_hook; |
| 138 |
extern VFunction *rl_prep_term_function; |
| 139 |
extern VFunction *rl_deprep_term_function; |
| 140 |
extern int readline_echoing_p; |
| 141 |
extern int _rl_print_completions_horizontally; |
| 142 |
|
| 143 |
/* supported functions */ |
| 144 |
char *readline(const char *); |
| 145 |
int rl_initialize(void); |
| 146 |
|
| 147 |
void using_history(void); |
| 148 |
int add_history(const char *); |
| 149 |
void clear_history(void); |
| 150 |
void stifle_history(int); |
| 151 |
int unstifle_history(void); |
| 152 |
int history_is_stifled(void); |
| 153 |
int where_history(void); |
| 154 |
HIST_ENTRY *current_history(void); |
| 155 |
HIST_ENTRY *history_get(int); |
| 156 |
HIST_ENTRY *remove_history(int); |
| 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 |
HIST_ENTRY **history_list(void); |
| 163 |
int history_search(const char *, int); |
| 164 |
int history_search_prefix(const char *, int); |
| 165 |
int history_search_pos(const char *, int, int); |
| 166 |
int read_history(const char *); |
| 167 |
int write_history(const char *); |
| 168 |
int history_truncate_file (const char *, int); |
| 169 |
int history_expand(char *, char **); |
| 170 |
char **history_tokenize(const char *); |
| 171 |
const char *get_history_event(const char *, int *, int); |
| 172 |
char *history_arg_extract(int, int, const char *); |
| 173 |
|
| 174 |
char *tilde_expand(char *); |
| 175 |
char *filename_completion_function(const char *, int); |
| 176 |
char *username_completion_function(const char *, int); |
| 177 |
int rl_complete(int, int); |
| 178 |
int rl_read_key(void); |
| 179 |
char **completion_matches(const char *, rl_compentry_func_t *); |
| 180 |
void rl_display_match_list(char **, int, int); |
| 181 |
|
| 182 |
int rl_insert(int, int); |
| 183 |
int rl_insert_text(const char *); |
| 184 |
void rl_reset_terminal(const char *); |
| 185 |
int rl_bind_key(int, rl_command_func_t *); |
| 186 |
int rl_newline(int, int); |
| 187 |
void rl_callback_read_char(void); |
| 188 |
void rl_callback_handler_install(const char *, rl_vcpfunc_t *); |
| 189 |
void rl_callback_handler_remove(void); |
| 190 |
void rl_redisplay(void); |
| 191 |
int rl_get_previous_history(int, int); |
| 192 |
void rl_prep_terminal(int); |
| 193 |
void rl_deprep_terminal(void); |
| 194 |
int rl_read_init_file(const char *); |
| 195 |
int rl_parse_and_bind(const char *); |
| 196 |
int rl_variable_bind(const char *, const char *); |
| 197 |
void rl_stuff_char(int); |
| 198 |
int rl_add_defun(const char *, rl_command_func_t *, int); |
| 199 |
HISTORY_STATE *history_get_history_state(void); |
| 200 |
void rl_get_screen_size(int *, int *); |
| 201 |
void rl_set_screen_size(int, int); |
| 202 |
char *rl_filename_completion_function (const char *, int); |
| 203 |
int _rl_abort_internal(void); |
| 204 |
int _rl_qsort_string_compare(char **, char **); |
| 205 |
char **rl_completion_matches(const char *, rl_compentry_func_t *); |
| 206 |
void rl_forced_update_display(void); |
| 207 |
int rl_set_prompt(const char *); |
| 208 |
int rl_on_new_line(void); |
| 209 |
|
| 210 |
/* |
| 211 |
* The following are not implemented |
| 212 |
*/ |
| 213 |
int rl_kill_text(int, int); |
| 214 |
Keymap rl_get_keymap(void); |
| 215 |
void rl_set_keymap(Keymap); |
| 216 |
Keymap rl_make_bare_keymap(void); |
| 217 |
int rl_generic_bind(int, const char *, const char *, Keymap); |
| 218 |
int rl_bind_key_in_map(int, rl_command_func_t *, Keymap); |
| 219 |
void rl_cleanup_after_signal(void); |
| 220 |
void rl_free_line_state(void); |
| 221 |
int rl_set_keyboard_input_timeout(int); |
| 222 |
|
| 223 |
#ifdef __cplusplus |
| 224 |
} |
| 225 |
#endif |
| 226 |
|
| 227 |
#endif /* _READLINE_H_ */ |