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