Path: blob/main/core/libedit/src/readline/readline.h
1070 views
/* $NetBSD: readline.h,v 1.46 2019/06/07 15:19:29 christos Exp $ */12/*-3* Copyright (c) 1997 The NetBSD Foundation, Inc.4* All rights reserved.5*6* This code is derived from software contributed to The NetBSD Foundation7* by Jaromir Dolecek.8*9* Redistribution and use in source and binary forms, with or without10* modification, are permitted provided that the following conditions11* are met:12* 1. Redistributions of source code must retain the above copyright13* notice, this list of conditions and the following disclaimer.14* 2. Redistributions in binary form must reproduce the above copyright15* notice, this list of conditions and the following disclaimer in the16* documentation and/or other materials provided with the distribution.17*18* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS19* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED20* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR21* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS22* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR23* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF24* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS25* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN26* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)27* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE28* POSSIBILITY OF SUCH DAMAGE.29*/30#ifndef _READLINE_H_31#define _READLINE_H_3233#include <sys/types.h>34#include <stdio.h>3536/* list of readline stuff supported by editline library's readline wrapper */3738/* typedefs */39typedef int Function(const char *, int);40typedef char *CPFunction(const char *, int);41typedef void VFunction(void);42typedef void rl_vcpfunc_t(char *);43typedef char **rl_completion_func_t(const char *, int, int);44typedef char *rl_compentry_func_t(const char *, int);45typedef int rl_command_func_t(int, int);46typedef int rl_hook_func_t(void);4748/* only supports length */49typedef struct {50int length;51} HISTORY_STATE;5253typedef void *histdata_t;5455typedef struct _hist_entry {56const char *line;57histdata_t data;58} HIST_ENTRY;5960typedef struct _keymap_entry {61char type;62#define ISFUNC 063#define ISKMAP 164#define ISMACR 265Function *function;66} KEYMAP_ENTRY;6768#define KEYMAP_SIZE 2566970typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];71typedef KEYMAP_ENTRY *Keymap;7273#define control_character_threshold 0x2074#define control_character_bit 0x407576#ifndef CTRL77#include <sys/ioctl.h>78#if !defined(__sun) && !defined(__hpux) && !defined(_AIX)79#include <sys/ttydefaults.h>80#endif81#ifndef CTRL82#define CTRL(c) ((c) & 037)83#endif84#endif85#ifndef UNCTRL86#define UNCTRL(c) (((c) - 'a' + 'A')|control_character_bit)87#endif8889#define RUBOUT 0x7f90#define ABORT_CHAR CTRL('G')91#define RL_READLINE_VERSION 0x040292#define RL_PROMPT_START_IGNORE '\1'93#define RL_PROMPT_END_IGNORE '\2'9495/* global variables used by readline enabled applications */96#ifdef __cplusplus97extern "C" {98#endif99extern const char *rl_library_version;100extern int rl_readline_version;101extern const char *rl_readline_name;102extern FILE *rl_instream;103extern FILE *rl_outstream;104extern char *rl_line_buffer;105extern int rl_point, rl_end;106extern int history_base, history_length;107extern int max_input_history;108extern const char *rl_basic_word_break_characters;109extern char *rl_completer_word_break_characters;110extern const char *rl_completer_quote_characters;111extern rl_compentry_func_t *rl_completion_entry_function;112extern char *(*rl_completion_word_break_hook)(void);113extern rl_completion_func_t *rl_attempted_completion_function;114extern int rl_attempted_completion_over;115extern int rl_completion_type;116extern int rl_completion_query_items;117extern const char *rl_special_prefixes;118extern int rl_completion_append_character;119extern int rl_inhibit_completion;120extern Function *rl_pre_input_hook;121extern Function *rl_startup_hook;122extern char *rl_terminal_name;123extern int rl_already_prompted;124extern char *rl_prompt;125extern int rl_done;126/*127* The following is not implemented128*/129extern int rl_catch_signals;130extern int rl_catch_sigwinch;131extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap,132emacs_meta_keymap,133emacs_ctlx_keymap;134extern int rl_filename_completion_desired;135extern int rl_ignore_completion_duplicates;136extern int (*rl_getc_function)(FILE *);137extern VFunction *rl_redisplay_function;138extern VFunction *rl_completion_display_matches_hook;139extern VFunction *rl_prep_term_function;140extern VFunction *rl_deprep_term_function;141extern rl_hook_func_t *rl_event_hook;142extern int readline_echoing_p;143extern int _rl_print_completions_horizontally;144145/* supported functions */146char *readline(const char *);147int rl_initialize(void);148149void using_history(void);150int add_history(const char *);151void clear_history(void);152int append_history(int, const char *);153void stifle_history(int);154int unstifle_history(void);155int history_is_stifled(void);156int where_history(void);157HIST_ENTRY *current_history(void);158HIST_ENTRY *history_get(int);159HIST_ENTRY *remove_history(int);160HIST_ENTRY *replace_history_entry(int, const char *, histdata_t);161int history_total_bytes(void);162int history_set_pos(int);163HIST_ENTRY *previous_history(void);164HIST_ENTRY *next_history(void);165HIST_ENTRY **history_list(void);166int history_search(const char *, int);167int history_search_prefix(const char *, int);168int history_search_pos(const char *, int, int);169int read_history(const char *);170int write_history(const char *);171int history_truncate_file (const char *, int);172int history_expand(char *, char **);173char **history_tokenize(const char *);174const char *get_history_event(const char *, int *, int);175char *history_arg_extract(int, int, const char *);176177char *tilde_expand(char *);178char *filename_completion_function(const char *, int);179char *username_completion_function(const char *, int);180int rl_complete(int, int);181int rl_read_key(void);182char **completion_matches(/* const */ char *, rl_compentry_func_t *);183void rl_display_match_list(char **, int, int);184185int rl_insert(int, int);186int rl_insert_text(const char *);187int rl_reset_terminal(const char *);188void rl_resize_terminal(void);189int rl_bind_key(int, rl_command_func_t *);190int rl_newline(int, int);191void rl_callback_read_char(void);192void rl_callback_handler_install(const char *, rl_vcpfunc_t *);193void rl_callback_handler_remove(void);194void rl_redisplay(void);195int rl_get_previous_history(int, int);196void rl_prep_terminal(int);197void rl_deprep_terminal(void);198int rl_read_init_file(const char *);199int rl_parse_and_bind(const char *);200int rl_variable_bind(const char *, const char *);201int rl_stuff_char(int);202int rl_add_defun(const char *, rl_command_func_t *, int);203HISTORY_STATE *history_get_history_state(void);204void rl_get_screen_size(int *, int *);205void rl_set_screen_size(int, int);206char *rl_filename_completion_function (const char *, int);207int _rl_abort_internal(void);208int _rl_qsort_string_compare(char **, char **);209char **rl_completion_matches(const char *, rl_compentry_func_t *);210void rl_forced_update_display(void);211int rl_set_prompt(const char *);212int rl_on_new_line(void);213void rl_reset_after_signal(void);214void rl_echo_signal_char(int);215216/*217* The following are not implemented218*/219int rl_kill_text(int, int);220Keymap rl_get_keymap(void);221void rl_set_keymap(Keymap);222Keymap rl_make_bare_keymap(void);223int rl_generic_bind(int, const char *, const char *, Keymap);224int rl_bind_key_in_map(int, rl_command_func_t *, Keymap);225void rl_cleanup_after_signal(void);226void rl_free_line_state(void);227int rl_set_keyboard_input_timeout(int);228229#ifdef __cplusplus230}231#endif232233#endif /* _READLINE_H_ */234235236