jpayne@69: /* $NetBSD: readline.h,v 1.55 2023/04/25 17:51:32 christos Exp $ */ jpayne@69: jpayne@69: /*- jpayne@69: * Copyright (c) 1997 The NetBSD Foundation, Inc. jpayne@69: * All rights reserved. jpayne@69: * jpayne@69: * This code is derived from software contributed to The NetBSD Foundation jpayne@69: * by Jaromir Dolecek. jpayne@69: * jpayne@69: * Redistribution and use in source and binary forms, with or without jpayne@69: * modification, are permitted provided that the following conditions jpayne@69: * are met: jpayne@69: * 1. Redistributions of source code must retain the above copyright jpayne@69: * notice, this list of conditions and the following disclaimer. jpayne@69: * 2. Redistributions in binary form must reproduce the above copyright jpayne@69: * notice, this list of conditions and the following disclaimer in the jpayne@69: * documentation and/or other materials provided with the distribution. jpayne@69: * jpayne@69: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS jpayne@69: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED jpayne@69: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR jpayne@69: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS jpayne@69: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR jpayne@69: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF jpayne@69: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS jpayne@69: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN jpayne@69: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) jpayne@69: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE jpayne@69: * POSSIBILITY OF SUCH DAMAGE. jpayne@69: */ jpayne@69: #ifndef _READLINE_H_ jpayne@69: #define _READLINE_H_ jpayne@69: jpayne@69: #include jpayne@69: #include jpayne@69: jpayne@69: /* list of readline stuff supported by editline library's readline wrapper */ jpayne@69: jpayne@69: /* typedefs */ jpayne@69: typedef int rl_linebuf_func_t(const char *, int); jpayne@69: typedef void rl_voidfunc_t(void); jpayne@69: typedef void rl_vintfunc_t(int); jpayne@69: typedef void rl_vcpfunc_t(char *); jpayne@69: typedef char **rl_completion_func_t(const char *, int, int); jpayne@69: typedef char *rl_compentry_func_t(const char *, int); jpayne@69: typedef void rl_compdisp_func_t(char **, int, int); jpayne@69: typedef int rl_command_func_t(int, int); jpayne@69: typedef int rl_hook_func_t(void); jpayne@69: typedef int rl_icppfunc_t(char **); jpayne@69: jpayne@69: /* only supports length */ jpayne@69: typedef struct { jpayne@69: int length; jpayne@69: } HISTORY_STATE; jpayne@69: jpayne@69: typedef void *histdata_t; jpayne@69: jpayne@69: typedef struct _hist_entry { jpayne@69: const char *line; jpayne@69: histdata_t data; jpayne@69: } HIST_ENTRY; jpayne@69: jpayne@69: typedef struct _keymap_entry { jpayne@69: char type; jpayne@69: #define ISFUNC 0 jpayne@69: #define ISKMAP 1 jpayne@69: #define ISMACR 2 jpayne@69: rl_linebuf_func_t *function; jpayne@69: } KEYMAP_ENTRY; jpayne@69: jpayne@69: #define KEYMAP_SIZE 256 jpayne@69: jpayne@69: typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE]; jpayne@69: typedef KEYMAP_ENTRY *Keymap; jpayne@69: jpayne@69: #define control_character_threshold 0x20 jpayne@69: #define control_character_bit 0x40 jpayne@69: jpayne@69: #ifndef CTRL jpayne@69: #include jpayne@69: #if !defined(__sun) && !defined(__hpux) && !defined(_AIX) jpayne@69: #include jpayne@69: #endif jpayne@69: #ifndef CTRL jpayne@69: #define CTRL(c) ((c) & 037) jpayne@69: #endif jpayne@69: #endif jpayne@69: #ifndef UNCTRL jpayne@69: #define UNCTRL(c) (((c) - 'a' + 'A')|control_character_bit) jpayne@69: #endif jpayne@69: jpayne@69: #define RUBOUT 0x7f jpayne@69: #define ABORT_CHAR CTRL('G') jpayne@69: #define RL_READLINE_VERSION 0x0402 jpayne@69: #define RL_PROMPT_START_IGNORE '\1' jpayne@69: #define RL_PROMPT_END_IGNORE '\2' jpayne@69: jpayne@69: #define RL_STATE_NONE 0x000000 jpayne@69: #define RL_STATE_DONE 0x000001 jpayne@69: jpayne@69: #define RL_SETSTATE(x) (rl_readline_state |= ((unsigned long) x)) jpayne@69: #define RL_UNSETSTATE(x) (rl_readline_state &= ~((unsigned long) x)) jpayne@69: #define RL_ISSTATE(x) (rl_readline_state & ((unsigned long) x)) jpayne@69: jpayne@69: /* global variables used by readline enabled applications */ jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: extern const char *rl_library_version; jpayne@69: extern int rl_readline_version; jpayne@69: extern const char *rl_readline_name; jpayne@69: extern FILE *rl_instream; jpayne@69: extern FILE *rl_outstream; jpayne@69: extern char *rl_line_buffer; jpayne@69: extern int rl_point, rl_end; jpayne@69: extern const char *rl_basic_quote_characters; jpayne@69: extern const char *rl_basic_word_break_characters; jpayne@69: extern char *rl_completer_word_break_characters; jpayne@69: extern const char *rl_completer_quote_characters; jpayne@69: extern rl_compentry_func_t *rl_completion_entry_function; jpayne@69: extern char *(*rl_completion_word_break_hook)(void); jpayne@69: extern rl_completion_func_t *rl_attempted_completion_function; jpayne@69: extern int rl_attempted_completion_over; jpayne@69: extern int rl_completion_type; jpayne@69: extern int rl_completion_query_items; jpayne@69: extern const char *rl_special_prefixes; jpayne@69: extern int rl_completion_append_character; jpayne@69: extern int rl_inhibit_completion; jpayne@69: extern rl_hook_func_t *rl_pre_input_hook; jpayne@69: extern rl_hook_func_t *rl_startup_hook; jpayne@69: extern char *rl_terminal_name; jpayne@69: extern int rl_already_prompted; jpayne@69: extern char *rl_prompt; jpayne@69: extern int rl_done; jpayne@69: extern rl_vcpfunc_t *rl_linefunc; jpayne@69: extern rl_hook_func_t *rl_startup1_hook; jpayne@69: extern char *rl_prompt_saved; jpayne@69: extern int history_base, history_length; jpayne@69: extern int history_offset; jpayne@69: extern char history_expansion_char; jpayne@69: extern char history_subst_char; jpayne@69: extern char *history_no_expand_chars; jpayne@69: extern rl_linebuf_func_t *history_inhibit_expansion_function; jpayne@69: extern int max_input_history; jpayne@69: jpayne@69: /* jpayne@69: * The following is not implemented jpayne@69: */ jpayne@69: extern unsigned long rl_readline_state; jpayne@69: extern int rl_catch_signals; jpayne@69: extern int rl_catch_sigwinch; jpayne@69: extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, jpayne@69: emacs_meta_keymap, jpayne@69: emacs_ctlx_keymap; jpayne@69: extern int rl_filename_completion_desired; jpayne@69: extern int rl_ignore_completion_duplicates; jpayne@69: extern int (*rl_getc_function)(FILE *); jpayne@69: extern rl_voidfunc_t *rl_redisplay_function; jpayne@69: extern rl_compdisp_func_t *rl_completion_display_matches_hook; jpayne@69: extern rl_vintfunc_t *rl_prep_term_function; jpayne@69: extern rl_voidfunc_t *rl_deprep_term_function; jpayne@69: extern rl_hook_func_t *rl_event_hook; jpayne@69: extern int readline_echoing_p; jpayne@69: extern int _rl_print_completions_horizontally; jpayne@69: extern int _rl_complete_mark_directories; jpayne@69: extern rl_icppfunc_t *rl_directory_completion_hook; jpayne@69: extern int rl_completion_suppress_append; jpayne@69: extern int rl_sort_completion_matches; jpayne@69: extern int _rl_completion_prefix_display_length; jpayne@69: extern int _rl_echoing_p; jpayne@69: extern int history_max_entries; jpayne@69: extern char *rl_display_prompt; jpayne@69: extern int rl_erase_empty_line; jpayne@69: jpayne@69: /* supported functions */ jpayne@69: char *readline(const char *); jpayne@69: int rl_initialize(void); jpayne@69: jpayne@69: void using_history(void); jpayne@69: int add_history(const char *); jpayne@69: void clear_history(void); jpayne@69: int append_history(int, const char *); jpayne@69: void stifle_history(int); jpayne@69: int unstifle_history(void); jpayne@69: int history_is_stifled(void); jpayne@69: int where_history(void); jpayne@69: HIST_ENTRY *current_history(void); jpayne@69: HIST_ENTRY *history_get(int); jpayne@69: HIST_ENTRY *remove_history(int); jpayne@69: HIST_ENTRY *replace_history_entry(int, const char *, histdata_t); jpayne@69: int history_total_bytes(void); jpayne@69: int history_set_pos(int); jpayne@69: HIST_ENTRY *previous_history(void); jpayne@69: HIST_ENTRY *next_history(void); jpayne@69: HIST_ENTRY **history_list(void); jpayne@69: int history_search(const char *, int); jpayne@69: int history_search_prefix(const char *, int); jpayne@69: int history_search_pos(const char *, int, int); jpayne@69: int read_history(const char *); jpayne@69: int write_history(const char *); jpayne@69: int history_truncate_file(const char *, int); jpayne@69: int history_expand(char *, char **); jpayne@69: char **history_tokenize(const char *); jpayne@69: const char *get_history_event(const char *, int *, int); jpayne@69: char *history_arg_extract(int, int, const char *); jpayne@69: jpayne@69: char *tilde_expand(char *); jpayne@69: char *filename_completion_function(const char *, int); jpayne@69: char *username_completion_function(const char *, int); jpayne@69: int rl_complete(int, int); jpayne@69: int rl_read_key(void); jpayne@69: char **completion_matches(/* const */ char *, rl_compentry_func_t *); jpayne@69: void rl_display_match_list(char **, int, int); jpayne@69: jpayne@69: int rl_insert(int, int); jpayne@69: int rl_insert_text(const char *); jpayne@69: int rl_reset_terminal(const char *); jpayne@69: void rl_resize_terminal(void); jpayne@69: int rl_bind_key(int, rl_command_func_t *); jpayne@69: int rl_newline(int, int); jpayne@69: void rl_callback_read_char(void); jpayne@69: void rl_callback_handler_install(const char *, rl_vcpfunc_t *); jpayne@69: void rl_callback_handler_remove(void); jpayne@69: void rl_redisplay(void); jpayne@69: int rl_get_previous_history(int, int); jpayne@69: void rl_prep_terminal(int); jpayne@69: void rl_deprep_terminal(void); jpayne@69: int rl_read_init_file(const char *); jpayne@69: int rl_parse_and_bind(const char *); jpayne@69: int rl_variable_bind(const char *, const char *); jpayne@69: int rl_stuff_char(int); jpayne@69: int rl_add_defun(const char *, rl_command_func_t *, int); jpayne@69: HISTORY_STATE *history_get_history_state(void); jpayne@69: void rl_get_screen_size(int *, int *); jpayne@69: void rl_set_screen_size(int, int); jpayne@69: char *rl_filename_completion_function(const char *, int); jpayne@69: int _rl_abort_internal(void); jpayne@69: int _rl_qsort_string_compare(char **, char **); jpayne@69: char **rl_completion_matches(const char *, rl_compentry_func_t *); jpayne@69: void rl_forced_update_display(void); jpayne@69: int rl_set_prompt(const char *); jpayne@69: int rl_on_new_line(void); jpayne@69: void rl_reset_after_signal(void); jpayne@69: void rl_echo_signal_char(int); jpayne@69: int rl_crlf(void); jpayne@69: int rl_ding(void); jpayne@69: char *rl_copy_text(int, int); jpayne@69: void rl_replace_line(const char *, int); jpayne@69: int rl_delete_text(int, int); jpayne@69: void rl_message(const char *format, ...) jpayne@69: __attribute__((__format__(__printf__, 1, 2))); jpayne@69: void rl_save_prompt(void); jpayne@69: void rl_restore_prompt(void); jpayne@69: jpayne@69: /* jpayne@69: * The following are not implemented jpayne@69: */ jpayne@69: int rl_kill_text(int, int); jpayne@69: Keymap rl_get_keymap(void); jpayne@69: void rl_set_keymap(Keymap); jpayne@69: Keymap rl_make_bare_keymap(void); jpayne@69: int rl_generic_bind(int, const char *, const char *, Keymap); jpayne@69: int rl_bind_key_in_map(int, rl_command_func_t *, Keymap); jpayne@69: int rl_set_key(const char *, rl_command_func_t *, Keymap); jpayne@69: void rl_cleanup_after_signal(void); jpayne@69: void rl_free_line_state(void); jpayne@69: int rl_set_keyboard_input_timeout(int); jpayne@69: int rl_abort(int, int); jpayne@69: int rl_set_keymap_name(const char *, Keymap); jpayne@69: histdata_t free_history_entry(HIST_ENTRY *); jpayne@69: void _rl_erase_entire_line(void); jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #endif /* _READLINE_H_ */