Path: blob/main/contrib/libedit/readline/readline.h
39507 views
/* $NetBSD: readline.h,v 1.55 2023/04/25 17:51:32 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 rl_linebuf_func_t(const char *, int);40typedef void rl_voidfunc_t(void);41typedef void rl_vintfunc_t(int);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 void rl_compdisp_func_t(char **, int, int);46typedef int rl_command_func_t(int, int);47typedef int rl_hook_func_t(void);48typedef int rl_icppfunc_t(char **);4950/* only supports length */51typedef struct {52int length;53} HISTORY_STATE;5455typedef void *histdata_t;5657typedef struct _hist_entry {58const char *line;59histdata_t data;60} HIST_ENTRY;6162typedef struct _keymap_entry {63char type;64#define ISFUNC 065#define ISKMAP 166#define ISMACR 267rl_linebuf_func_t *function;68} KEYMAP_ENTRY;6970#define KEYMAP_SIZE 2567172typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];73typedef KEYMAP_ENTRY *Keymap;7475#define control_character_threshold 0x2076#define control_character_bit 0x407778#ifndef CTRL79#include <sys/ioctl.h>80#if !defined(__sun) && !defined(__hpux) && !defined(_AIX)81#include <sys/ttydefaults.h>82#endif83#ifndef CTRL84#define CTRL(c) ((c) & 037)85#endif86#endif87#ifndef UNCTRL88#define UNCTRL(c) (((c) - 'a' + 'A')|control_character_bit)89#endif9091#define RUBOUT 0x7f92#define ABORT_CHAR CTRL('G')93#define RL_READLINE_VERSION 0x040294#define RL_PROMPT_START_IGNORE '\1'95#define RL_PROMPT_END_IGNORE '\2'9697#define RL_STATE_NONE 0x00000098#define RL_STATE_DONE 0x00000199100#define RL_SETSTATE(x) (rl_readline_state |= ((unsigned long) x))101#define RL_UNSETSTATE(x) (rl_readline_state &= ~((unsigned long) x))102#define RL_ISSTATE(x) (rl_readline_state & ((unsigned long) x))103104/* global variables used by readline enabled applications */105#ifdef __cplusplus106extern "C" {107#endif108extern const char *rl_library_version;109extern int rl_readline_version;110extern const char *rl_readline_name;111extern FILE *rl_instream;112extern FILE *rl_outstream;113extern char *rl_line_buffer;114extern int rl_point, rl_end;115extern const char *rl_basic_quote_characters;116extern const char *rl_basic_word_break_characters;117extern char *rl_completer_word_break_characters;118extern const char *rl_completer_quote_characters;119extern rl_compentry_func_t *rl_completion_entry_function;120extern char *(*rl_completion_word_break_hook)(void);121extern rl_completion_func_t *rl_attempted_completion_function;122extern int rl_attempted_completion_over;123extern int rl_completion_type;124extern int rl_completion_query_items;125extern const char *rl_special_prefixes;126extern int rl_completion_append_character;127extern int rl_inhibit_completion;128extern rl_hook_func_t *rl_pre_input_hook;129extern rl_hook_func_t *rl_startup_hook;130extern char *rl_terminal_name;131extern int rl_already_prompted;132extern char *rl_prompt;133extern int rl_done;134extern rl_vcpfunc_t *rl_linefunc;135extern rl_hook_func_t *rl_startup1_hook;136extern char *rl_prompt_saved;137extern int history_base, history_length;138extern int history_offset;139extern char history_expansion_char;140extern char history_subst_char;141extern char *history_no_expand_chars;142extern rl_linebuf_func_t *history_inhibit_expansion_function;143extern int max_input_history;144145/*146* The following is not implemented147*/148extern unsigned long rl_readline_state;149extern int rl_catch_signals;150extern int rl_catch_sigwinch;151extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap,152emacs_meta_keymap,153emacs_ctlx_keymap;154extern int rl_filename_completion_desired;155extern int rl_ignore_completion_duplicates;156extern int (*rl_getc_function)(FILE *);157extern rl_voidfunc_t *rl_redisplay_function;158extern rl_compdisp_func_t *rl_completion_display_matches_hook;159extern rl_vintfunc_t *rl_prep_term_function;160extern rl_voidfunc_t *rl_deprep_term_function;161extern rl_hook_func_t *rl_event_hook;162extern int readline_echoing_p;163extern int _rl_print_completions_horizontally;164extern int _rl_complete_mark_directories;165extern rl_icppfunc_t *rl_directory_completion_hook;166extern int rl_completion_suppress_append;167extern int rl_sort_completion_matches;168extern int _rl_completion_prefix_display_length;169extern int _rl_echoing_p;170extern int history_max_entries;171extern char *rl_display_prompt;172extern int rl_erase_empty_line;173174/* supported functions */175char *readline(const char *);176int rl_initialize(void);177178void using_history(void);179int add_history(const char *);180void clear_history(void);181int append_history(int, const char *);182void stifle_history(int);183int unstifle_history(void);184int history_is_stifled(void);185int where_history(void);186HIST_ENTRY *current_history(void);187HIST_ENTRY *history_get(int);188HIST_ENTRY *remove_history(int);189HIST_ENTRY *replace_history_entry(int, const char *, histdata_t);190int history_total_bytes(void);191int history_set_pos(int);192HIST_ENTRY *previous_history(void);193HIST_ENTRY *next_history(void);194HIST_ENTRY **history_list(void);195int history_search(const char *, int);196int history_search_prefix(const char *, int);197int history_search_pos(const char *, int, int);198int read_history(const char *);199int write_history(const char *);200int history_truncate_file(const char *, int);201int history_expand(char *, char **);202char **history_tokenize(const char *);203const char *get_history_event(const char *, int *, int);204char *history_arg_extract(int, int, const char *);205206char *tilde_expand(char *);207char *filename_completion_function(const char *, int);208char *username_completion_function(const char *, int);209int rl_complete(int, int);210int rl_read_key(void);211char **completion_matches(/* const */ char *, rl_compentry_func_t *);212void rl_display_match_list(char **, int, int);213214int rl_insert(int, int);215int rl_insert_text(const char *);216int rl_reset_terminal(const char *);217void rl_resize_terminal(void);218int rl_bind_key(int, rl_command_func_t *);219int rl_newline(int, int);220void rl_callback_read_char(void);221void rl_callback_handler_install(const char *, rl_vcpfunc_t *);222void rl_callback_handler_remove(void);223void rl_redisplay(void);224int rl_get_previous_history(int, int);225void rl_prep_terminal(int);226void rl_deprep_terminal(void);227int rl_read_init_file(const char *);228int rl_parse_and_bind(const char *);229int rl_variable_bind(const char *, const char *);230int rl_stuff_char(int);231int rl_add_defun(const char *, rl_command_func_t *, int);232HISTORY_STATE *history_get_history_state(void);233void rl_get_screen_size(int *, int *);234void rl_set_screen_size(int, int);235char *rl_filename_completion_function(const char *, int);236int _rl_abort_internal(void);237int _rl_qsort_string_compare(char **, char **);238char **rl_completion_matches(const char *, rl_compentry_func_t *);239void rl_forced_update_display(void);240int rl_set_prompt(const char *);241int rl_on_new_line(void);242void rl_reset_after_signal(void);243void rl_echo_signal_char(int);244int rl_crlf(void);245int rl_ding(void);246char *rl_copy_text(int, int);247void rl_replace_line(const char *, int);248int rl_delete_text(int, int);249void rl_message(const char *format, ...)250__attribute__((__format__(__printf__, 1, 2)));251void rl_save_prompt(void);252void rl_restore_prompt(void);253254/*255* The following are not implemented256*/257int rl_kill_text(int, int);258Keymap rl_get_keymap(void);259void rl_set_keymap(Keymap);260Keymap rl_make_bare_keymap(void);261int rl_generic_bind(int, const char *, const char *, Keymap);262int rl_bind_key_in_map(int, rl_command_func_t *, Keymap);263int rl_set_key(const char *, rl_command_func_t *, Keymap);264void rl_cleanup_after_signal(void);265void rl_free_line_state(void);266int rl_set_keyboard_input_timeout(int);267int rl_abort(int, int);268int rl_set_keymap_name(const char *, Keymap);269histdata_t free_history_entry(HIST_ENTRY *);270void _rl_erase_entire_line(void);271272#ifdef __cplusplus273}274#endif275276#endif /* _READLINE_H_ */277278279