1157188Sache/* $FreeBSD$ */ 221308Sache/* Readline.h -- the names of functions callable from within readline. */ 321308Sache 4157188Sache/* Copyright (C) 1987-2005 Free Software Foundation, Inc. 521308Sache 621308Sache This file is part of the GNU Readline Library, a library for 721308Sache reading lines of text with interactive input and history editing. 821308Sache 921308Sache The GNU Readline Library is free software; you can redistribute it 1021308Sache and/or modify it under the terms of the GNU General Public License 1158314Sache as published by the Free Software Foundation; either version 2, or 1221308Sache (at your option) any later version. 1321308Sache 1421308Sache The GNU Readline Library is distributed in the hope that it will be 1521308Sache useful, but WITHOUT ANY WARRANTY; without even the implied warranty 1621308Sache of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1721308Sache GNU General Public License for more details. 1821308Sache 1921308Sache The GNU General Public License is often shipped with GNU software, and 2021308Sache is generally kept in a file called COPYING or LICENSE. If you do not 2121308Sache have a copy of the license, write to the Free Software Foundation, 2258314Sache 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ 23123279Sobrien 2421308Sache#if !defined (_READLINE_H_) 2521308Sache#define _READLINE_H_ 2621308Sache 2747563Sache#ifdef __cplusplus 2847563Sacheextern "C" { 2947563Sache#endif 3047563Sache 3121308Sache#if defined (READLINE_LIBRARY) 3247563Sache# include "rlstdc.h" 33119614Sache# include "rltypedefs.h" 3421308Sache# include "keymaps.h" 3521308Sache# include "tilde.h" 3621308Sache#else 3747563Sache# include <readline/rlstdc.h> 38119614Sache# include <readline/rltypedefs.h> 3921308Sache# include <readline/keymaps.h> 4021308Sache# include <readline/tilde.h> 4121308Sache#endif 4221308Sache 43119614Sache/* Hex-encoded Readline version number. */ 44165675Sache#define RL_READLINE_VERSION 0x0502 /* Readline 5.2 */ 45136652Sache#define RL_VERSION_MAJOR 5 46165675Sache#define RL_VERSION_MINOR 2 47119614Sache 4821308Sache/* Readline data structures. */ 4921308Sache 5021308Sache/* Maintaining the state of undo. We remember individual deletes and inserts 5121308Sache on a chain of things to do. */ 5221308Sache 5321308Sache/* The actions that undo knows how to undo. Notice that UNDO_DELETE means 5421308Sache to insert some text, and UNDO_INSERT means to delete some text. I.e., 5521308Sache the code tells undo what to undo, not how to undo it. */ 5621308Sacheenum undo_code { UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END }; 5721308Sache 5821308Sache/* What an element of THE_UNDO_LIST looks like. */ 5921308Sachetypedef struct undo_list { 6021308Sache struct undo_list *next; 6121308Sache int start, end; /* Where the change took place. */ 6221308Sache char *text; /* The text to insert, if undoing a delete. */ 6321308Sache enum undo_code what; /* Delete, Insert, Begin, End. */ 6421308Sache} UNDO_LIST; 6521308Sache 6621308Sache/* The current undo list for RL_LINE_BUFFER. */ 6721308Sacheextern UNDO_LIST *rl_undo_list; 6821308Sache 6921308Sache/* The data structure for mapping textual names to code addresses. */ 7021308Sachetypedef struct _funmap { 7175409Sache const char *name; 7275409Sache rl_command_func_t *function; 7321308Sache} FUNMAP; 7421308Sache 7521308Sacheextern FUNMAP **funmap; 7621308Sache 7747563Sache/* **************************************************************** */ 7847563Sache/* */ 7947563Sache/* Functions available to bind to key sequences */ 8047563Sache/* */ 8147563Sache/* **************************************************************** */ 8221308Sache 8347563Sache/* Bindable commands for numeric arguments. */ 84119614Sacheextern int rl_digit_argument PARAMS((int, int)); 85119614Sacheextern int rl_universal_argument PARAMS((int, int)); 8621308Sache 8747563Sache/* Bindable commands for moving the cursor. */ 88119614Sacheextern int rl_forward_byte PARAMS((int, int)); 89119614Sacheextern int rl_forward_char PARAMS((int, int)); 90119614Sacheextern int rl_forward PARAMS((int, int)); 91119614Sacheextern int rl_backward_byte PARAMS((int, int)); 92119614Sacheextern int rl_backward_char PARAMS((int, int)); 93119614Sacheextern int rl_backward PARAMS((int, int)); 94119614Sacheextern int rl_beg_of_line PARAMS((int, int)); 95119614Sacheextern int rl_end_of_line PARAMS((int, int)); 96119614Sacheextern int rl_forward_word PARAMS((int, int)); 97119614Sacheextern int rl_backward_word PARAMS((int, int)); 98119614Sacheextern int rl_refresh_line PARAMS((int, int)); 99119614Sacheextern int rl_clear_screen PARAMS((int, int)); 100119614Sacheextern int rl_arrow_keys PARAMS((int, int)); 10121308Sache 10247563Sache/* Bindable commands for inserting and deleting text. */ 103119614Sacheextern int rl_insert PARAMS((int, int)); 104119614Sacheextern int rl_quoted_insert PARAMS((int, int)); 105119614Sacheextern int rl_tab_insert PARAMS((int, int)); 106119614Sacheextern int rl_newline PARAMS((int, int)); 107119614Sacheextern int rl_do_lowercase_version PARAMS((int, int)); 108119614Sacheextern int rl_rubout PARAMS((int, int)); 109119614Sacheextern int rl_delete PARAMS((int, int)); 110119614Sacheextern int rl_rubout_or_delete PARAMS((int, int)); 111119614Sacheextern int rl_delete_horizontal_space PARAMS((int, int)); 112119614Sacheextern int rl_delete_or_show_completions PARAMS((int, int)); 113119614Sacheextern int rl_insert_comment PARAMS((int, int)); 11447563Sache 11547563Sache/* Bindable commands for changing case. */ 116119614Sacheextern int rl_upcase_word PARAMS((int, int)); 117119614Sacheextern int rl_downcase_word PARAMS((int, int)); 118119614Sacheextern int rl_capitalize_word PARAMS((int, int)); 11947563Sache 12047563Sache/* Bindable commands for transposing characters and words. */ 121119614Sacheextern int rl_transpose_words PARAMS((int, int)); 122119614Sacheextern int rl_transpose_chars PARAMS((int, int)); 12347563Sache 12447563Sache/* Bindable commands for searching within a line. */ 125119614Sacheextern int rl_char_search PARAMS((int, int)); 126119614Sacheextern int rl_backward_char_search PARAMS((int, int)); 12747563Sache 12847563Sache/* Bindable commands for readline's interface to the command history. */ 129119614Sacheextern int rl_beginning_of_history PARAMS((int, int)); 130119614Sacheextern int rl_end_of_history PARAMS((int, int)); 131119614Sacheextern int rl_get_next_history PARAMS((int, int)); 132119614Sacheextern int rl_get_previous_history PARAMS((int, int)); 13347563Sache 13447563Sache/* Bindable commands for managing the mark and region. */ 135119614Sacheextern int rl_set_mark PARAMS((int, int)); 136119614Sacheextern int rl_exchange_point_and_mark PARAMS((int, int)); 13747563Sache 13847563Sache/* Bindable commands to set the editing mode (emacs or vi). */ 139119614Sacheextern int rl_vi_editing_mode PARAMS((int, int)); 140119614Sacheextern int rl_emacs_editing_mode PARAMS((int, int)); 14147563Sache 142119614Sache/* Bindable commands to change the insert mode (insert or overwrite) */ 143119614Sacheextern int rl_overwrite_mode PARAMS((int, int)); 144119614Sache 14547563Sache/* Bindable commands for managing key bindings. */ 146119614Sacheextern int rl_re_read_init_file PARAMS((int, int)); 147119614Sacheextern int rl_dump_functions PARAMS((int, int)); 148119614Sacheextern int rl_dump_macros PARAMS((int, int)); 149119614Sacheextern int rl_dump_variables PARAMS((int, int)); 15047563Sache 15147563Sache/* Bindable commands for word completion. */ 152119614Sacheextern int rl_complete PARAMS((int, int)); 153119614Sacheextern int rl_possible_completions PARAMS((int, int)); 154119614Sacheextern int rl_insert_completions PARAMS((int, int)); 155119614Sacheextern int rl_menu_complete PARAMS((int, int)); 15647563Sache 15747563Sache/* Bindable commands for killing and yanking text, and managing the kill ring. */ 158119614Sacheextern int rl_kill_word PARAMS((int, int)); 159119614Sacheextern int rl_backward_kill_word PARAMS((int, int)); 160119614Sacheextern int rl_kill_line PARAMS((int, int)); 161119614Sacheextern int rl_backward_kill_line PARAMS((int, int)); 162119614Sacheextern int rl_kill_full_line PARAMS((int, int)); 163119614Sacheextern int rl_unix_word_rubout PARAMS((int, int)); 164136652Sacheextern int rl_unix_filename_rubout PARAMS((int, int)); 165119614Sacheextern int rl_unix_line_discard PARAMS((int, int)); 166119614Sacheextern int rl_copy_region_to_kill PARAMS((int, int)); 167119614Sacheextern int rl_kill_region PARAMS((int, int)); 168119614Sacheextern int rl_copy_forward_word PARAMS((int, int)); 169119614Sacheextern int rl_copy_backward_word PARAMS((int, int)); 170119614Sacheextern int rl_yank PARAMS((int, int)); 171119614Sacheextern int rl_yank_pop PARAMS((int, int)); 172119614Sacheextern int rl_yank_nth_arg PARAMS((int, int)); 173119614Sacheextern int rl_yank_last_arg PARAMS((int, int)); 17475409Sache/* Not available unless __CYGWIN__ is defined. */ 17575409Sache#ifdef __CYGWIN__ 176119614Sacheextern int rl_paste_from_clipboard PARAMS((int, int)); 17735493Sache#endif 17835493Sache 17947563Sache/* Bindable commands for incremental searching. */ 180119614Sacheextern int rl_reverse_search_history PARAMS((int, int)); 181119614Sacheextern int rl_forward_search_history PARAMS((int, int)); 18221308Sache 18347563Sache/* Bindable keyboard macro commands. */ 184119614Sacheextern int rl_start_kbd_macro PARAMS((int, int)); 185119614Sacheextern int rl_end_kbd_macro PARAMS((int, int)); 186119614Sacheextern int rl_call_last_kbd_macro PARAMS((int, int)); 18721308Sache 18847563Sache/* Bindable undo commands. */ 189119614Sacheextern int rl_revert_line PARAMS((int, int)); 190119614Sacheextern int rl_undo_command PARAMS((int, int)); 19147563Sache 19247563Sache/* Bindable tilde expansion commands. */ 193119614Sacheextern int rl_tilde_expand PARAMS((int, int)); 19447563Sache 19547563Sache/* Bindable terminal control commands. */ 196119614Sacheextern int rl_restart_output PARAMS((int, int)); 197119614Sacheextern int rl_stop_output PARAMS((int, int)); 19847563Sache 19947563Sache/* Miscellaneous bindable commands. */ 200119614Sacheextern int rl_abort PARAMS((int, int)); 201119614Sacheextern int rl_tty_status PARAMS((int, int)); 20247563Sache 20347563Sache/* Bindable commands for incremental and non-incremental history searching. */ 204119614Sacheextern int rl_history_search_forward PARAMS((int, int)); 205119614Sacheextern int rl_history_search_backward PARAMS((int, int)); 206119614Sacheextern int rl_noninc_forward_search PARAMS((int, int)); 207119614Sacheextern int rl_noninc_reverse_search PARAMS((int, int)); 208119614Sacheextern int rl_noninc_forward_search_again PARAMS((int, int)); 209119614Sacheextern int rl_noninc_reverse_search_again PARAMS((int, int)); 21047563Sache 21158314Sache/* Bindable command used when inserting a matching close character. */ 212119614Sacheextern int rl_insert_close PARAMS((int, int)); 21347563Sache 21447563Sache/* Not available unless READLINE_CALLBACKS is defined. */ 215119614Sacheextern void rl_callback_handler_install PARAMS((const char *, rl_vcpfunc_t *)); 216119614Sacheextern void rl_callback_read_char PARAMS((void)); 217119614Sacheextern void rl_callback_handler_remove PARAMS((void)); 21847563Sache 21921308Sache/* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */ 22047563Sache/* VI-mode bindable commands. */ 221119614Sacheextern int rl_vi_redo PARAMS((int, int)); 222119614Sacheextern int rl_vi_undo PARAMS((int, int)); 223119614Sacheextern int rl_vi_yank_arg PARAMS((int, int)); 224119614Sacheextern int rl_vi_fetch_history PARAMS((int, int)); 225119614Sacheextern int rl_vi_search_again PARAMS((int, int)); 226119614Sacheextern int rl_vi_search PARAMS((int, int)); 227119614Sacheextern int rl_vi_complete PARAMS((int, int)); 228119614Sacheextern int rl_vi_tilde_expand PARAMS((int, int)); 229119614Sacheextern int rl_vi_prev_word PARAMS((int, int)); 230119614Sacheextern int rl_vi_next_word PARAMS((int, int)); 231119614Sacheextern int rl_vi_end_word PARAMS((int, int)); 232119614Sacheextern int rl_vi_insert_beg PARAMS((int, int)); 233119614Sacheextern int rl_vi_append_mode PARAMS((int, int)); 234119614Sacheextern int rl_vi_append_eol PARAMS((int, int)); 235119614Sacheextern int rl_vi_eof_maybe PARAMS((int, int)); 236119614Sacheextern int rl_vi_insertion_mode PARAMS((int, int)); 237119614Sacheextern int rl_vi_movement_mode PARAMS((int, int)); 238119614Sacheextern int rl_vi_arg_digit PARAMS((int, int)); 239119614Sacheextern int rl_vi_change_case PARAMS((int, int)); 240119614Sacheextern int rl_vi_put PARAMS((int, int)); 241119614Sacheextern int rl_vi_column PARAMS((int, int)); 242119614Sacheextern int rl_vi_delete_to PARAMS((int, int)); 243119614Sacheextern int rl_vi_change_to PARAMS((int, int)); 244119614Sacheextern int rl_vi_yank_to PARAMS((int, int)); 245157188Sacheextern int rl_vi_rubout PARAMS((int, int)); 246119614Sacheextern int rl_vi_delete PARAMS((int, int)); 247119614Sacheextern int rl_vi_back_to_indent PARAMS((int, int)); 248119614Sacheextern int rl_vi_first_print PARAMS((int, int)); 249119614Sacheextern int rl_vi_char_search PARAMS((int, int)); 250119614Sacheextern int rl_vi_match PARAMS((int, int)); 251119614Sacheextern int rl_vi_change_char PARAMS((int, int)); 252119614Sacheextern int rl_vi_subst PARAMS((int, int)); 253119614Sacheextern int rl_vi_overstrike PARAMS((int, int)); 254119614Sacheextern int rl_vi_overstrike_delete PARAMS((int, int)); 255119614Sacheextern int rl_vi_replace PARAMS((int, int)); 256119614Sacheextern int rl_vi_set_mark PARAMS((int, int)); 257119614Sacheextern int rl_vi_goto_mark PARAMS((int, int)); 25821308Sache 25947563Sache/* VI-mode utility functions. */ 260119614Sacheextern int rl_vi_check PARAMS((void)); 261119614Sacheextern int rl_vi_domove PARAMS((int, int *)); 262119614Sacheextern int rl_vi_bracktype PARAMS((int)); 26321308Sache 264136652Sacheextern void rl_vi_start_inserting PARAMS((int, int, int)); 265136652Sache 26647563Sache/* VI-mode pseudo-bindable commands, used as utility functions. */ 267119614Sacheextern int rl_vi_fWord PARAMS((int, int)); 268119614Sacheextern int rl_vi_bWord PARAMS((int, int)); 269119614Sacheextern int rl_vi_eWord PARAMS((int, int)); 270119614Sacheextern int rl_vi_fword PARAMS((int, int)); 271119614Sacheextern int rl_vi_bword PARAMS((int, int)); 272119614Sacheextern int rl_vi_eword PARAMS((int, int)); 27321308Sache 27421308Sache/* **************************************************************** */ 27521308Sache/* */ 27621308Sache/* Well Published Functions */ 27721308Sache/* */ 27821308Sache/* **************************************************************** */ 27921308Sache 28021308Sache/* Readline functions. */ 28121308Sache/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means none. */ 282119614Sacheextern char *readline PARAMS((const char *)); 28321308Sache 284119614Sacheextern int rl_set_prompt PARAMS((const char *)); 285119614Sacheextern int rl_expand_prompt PARAMS((char *)); 28675409Sache 287119614Sacheextern int rl_initialize PARAMS((void)); 28821308Sache 28975409Sache/* Undocumented; unused by readline */ 290119614Sacheextern int rl_discard_argument PARAMS((void)); 29121308Sache 29247563Sache/* Utility functions to bind keys to readline commands. */ 293119614Sacheextern int rl_add_defun PARAMS((const char *, rl_command_func_t *, int)); 294119614Sacheextern int rl_bind_key PARAMS((int, rl_command_func_t *)); 295119614Sacheextern int rl_bind_key_in_map PARAMS((int, rl_command_func_t *, Keymap)); 296119614Sacheextern int rl_unbind_key PARAMS((int)); 297119614Sacheextern int rl_unbind_key_in_map PARAMS((int, Keymap)); 298136652Sacheextern int rl_bind_key_if_unbound PARAMS((int, rl_command_func_t *)); 299136652Sacheextern int rl_bind_key_if_unbound_in_map PARAMS((int, rl_command_func_t *, Keymap)); 300119614Sacheextern int rl_unbind_function_in_map PARAMS((rl_command_func_t *, Keymap)); 301119614Sacheextern int rl_unbind_command_in_map PARAMS((const char *, Keymap)); 302136652Sacheextern int rl_bind_keyseq PARAMS((const char *, rl_command_func_t *)); 303136652Sacheextern int rl_bind_keyseq_in_map PARAMS((const char *, rl_command_func_t *, Keymap)); 304136652Sacheextern int rl_bind_keyseq_if_unbound PARAMS((const char *, rl_command_func_t *)); 305136652Sacheextern int rl_bind_keyseq_if_unbound_in_map PARAMS((const char *, rl_command_func_t *, Keymap)); 306119614Sacheextern int rl_generic_bind PARAMS((int, const char *, char *, Keymap)); 307157188Sache 308157188Sacheextern char *rl_variable_value PARAMS((const char *)); 309119614Sacheextern int rl_variable_bind PARAMS((const char *, const char *)); 31047563Sache 311136652Sache/* Backwards compatibility, use rl_bind_keyseq_in_map instead. */ 312136652Sacheextern int rl_set_key PARAMS((const char *, rl_command_func_t *, Keymap)); 313136652Sache 31421308Sache/* Backwards compatibility, use rl_generic_bind instead. */ 315119614Sacheextern int rl_macro_bind PARAMS((const char *, const char *, Keymap)); 31621308Sache 31747563Sache/* Undocumented in the texinfo manual; not really useful to programs. */ 318119614Sacheextern int rl_translate_keyseq PARAMS((const char *, char *, int *)); 319119614Sacheextern char *rl_untranslate_keyseq PARAMS((int)); 32021308Sache 321119614Sacheextern rl_command_func_t *rl_named_function PARAMS((const char *)); 322119614Sacheextern rl_command_func_t *rl_function_of_keyseq PARAMS((const char *, Keymap, int *)); 32321308Sache 324119614Sacheextern void rl_list_funmap_names PARAMS((void)); 325119614Sacheextern char **rl_invoking_keyseqs_in_map PARAMS((rl_command_func_t *, Keymap)); 326119614Sacheextern char **rl_invoking_keyseqs PARAMS((rl_command_func_t *)); 32747563Sache 328119614Sacheextern void rl_function_dumper PARAMS((int)); 329119614Sacheextern void rl_macro_dumper PARAMS((int)); 330119614Sacheextern void rl_variable_dumper PARAMS((int)); 33121308Sache 332119614Sacheextern int rl_read_init_file PARAMS((const char *)); 333119614Sacheextern int rl_parse_and_bind PARAMS((char *)); 33421308Sache 33547563Sache/* Functions for manipulating keymaps. */ 336119614Sacheextern Keymap rl_make_bare_keymap PARAMS((void)); 337119614Sacheextern Keymap rl_copy_keymap PARAMS((Keymap)); 338119614Sacheextern Keymap rl_make_keymap PARAMS((void)); 339119614Sacheextern void rl_discard_keymap PARAMS((Keymap)); 340119614Sache 341119614Sacheextern Keymap rl_get_keymap_by_name PARAMS((const char *)); 342119614Sacheextern char *rl_get_keymap_name PARAMS((Keymap)); 343119614Sacheextern void rl_set_keymap PARAMS((Keymap)); 344119614Sacheextern Keymap rl_get_keymap PARAMS((void)); 34575409Sache/* Undocumented; used internally only. */ 346119614Sacheextern void rl_set_keymap_from_edit_mode PARAMS((void)); 347119614Sacheextern char *rl_get_keymap_name_from_edit_mode PARAMS((void)); 34847563Sache 34947563Sache/* Functions for manipulating the funmap, which maps command names to functions. */ 350119614Sacheextern int rl_add_funmap_entry PARAMS((const char *, rl_command_func_t *)); 351119614Sacheextern const char **rl_funmap_names PARAMS((void)); 35275409Sache/* Undocumented, only used internally -- there is only one funmap, and this 35375409Sache function may be called only once. */ 354119614Sacheextern void rl_initialize_funmap PARAMS((void)); 35547563Sache 35647563Sache/* Utility functions for managing keyboard macros. */ 357119614Sacheextern void rl_push_macro_input PARAMS((char *)); 35847563Sache 35947563Sache/* Functions for undoing, from undo.c */ 360119614Sacheextern void rl_add_undo PARAMS((enum undo_code, int, int, char *)); 361119614Sacheextern void rl_free_undo_list PARAMS((void)); 362119614Sacheextern int rl_do_undo PARAMS((void)); 363119614Sacheextern int rl_begin_undo_group PARAMS((void)); 364119614Sacheextern int rl_end_undo_group PARAMS((void)); 365119614Sacheextern int rl_modifying PARAMS((int, int)); 36647563Sache 36721308Sache/* Functions for redisplay. */ 368119614Sacheextern void rl_redisplay PARAMS((void)); 369119614Sacheextern int rl_on_new_line PARAMS((void)); 370119614Sacheextern int rl_on_new_line_with_prompt PARAMS((void)); 371119614Sacheextern int rl_forced_update_display PARAMS((void)); 372119614Sacheextern int rl_clear_message PARAMS((void)); 373119614Sacheextern int rl_reset_line_state PARAMS((void)); 374119614Sacheextern int rl_crlf PARAMS((void)); 37521308Sache 376136652Sache#if defined (USE_VARARGS) && defined (PREFER_STDARG) 377119614Sacheextern int rl_message (const char *, ...) __attribute__((__format__ (printf, 1, 2))); 37821308Sache#else 37921308Sacheextern int rl_message (); 38021308Sache#endif 38121308Sache 382119614Sacheextern int rl_show_char PARAMS((int)); 38375409Sache 38421308Sache/* Undocumented in texinfo manual. */ 385119614Sacheextern int rl_character_len PARAMS((int, int)); 38621308Sache 38747563Sache/* Save and restore internal prompt redisplay information. */ 388119614Sacheextern void rl_save_prompt PARAMS((void)); 389119614Sacheextern void rl_restore_prompt PARAMS((void)); 39047563Sache 39121308Sache/* Modifying text. */ 392119614Sacheextern void rl_replace_line PARAMS((const char *, int)); 393119614Sacheextern int rl_insert_text PARAMS((const char *)); 394119614Sacheextern int rl_delete_text PARAMS((int, int)); 395119614Sacheextern int rl_kill_text PARAMS((int, int)); 396119614Sacheextern char *rl_copy_text PARAMS((int, int)); 39721308Sache 39847563Sache/* Terminal and tty mode management. */ 399119614Sacheextern void rl_prep_terminal PARAMS((int)); 400119614Sacheextern void rl_deprep_terminal PARAMS((void)); 401119614Sacheextern void rl_tty_set_default_bindings PARAMS((Keymap)); 402136652Sacheextern void rl_tty_unset_default_bindings PARAMS((Keymap)); 40321308Sache 404119614Sacheextern int rl_reset_terminal PARAMS((const char *)); 405119614Sacheextern void rl_resize_terminal PARAMS((void)); 406119614Sacheextern void rl_set_screen_size PARAMS((int, int)); 407119614Sacheextern void rl_get_screen_size PARAMS((int *, int *)); 408157188Sacheextern void rl_reset_screen_size PARAMS((void)); 40921308Sache 410119614Sacheextern char *rl_get_termcap PARAMS((const char *)); 411119614Sache 41247563Sache/* Functions for character input. */ 413119614Sacheextern int rl_stuff_char PARAMS((int)); 414119614Sacheextern int rl_execute_next PARAMS((int)); 415119614Sacheextern int rl_clear_pending_input PARAMS((void)); 416119614Sacheextern int rl_read_key PARAMS((void)); 417119614Sacheextern int rl_getc PARAMS((FILE *)); 418119614Sacheextern int rl_set_keyboard_input_timeout PARAMS((int)); 41947563Sache 42075409Sache/* `Public' utility functions . */ 421119614Sacheextern void rl_extend_line_buffer PARAMS((int)); 422119614Sacheextern int rl_ding PARAMS((void)); 423119614Sacheextern int rl_alphabetic PARAMS((int)); 42475409Sache 42547563Sache/* Readline signal handling, from signals.c */ 426119614Sacheextern int rl_set_signals PARAMS((void)); 427119614Sacheextern int rl_clear_signals PARAMS((void)); 428119614Sacheextern void rl_cleanup_after_signal PARAMS((void)); 429119614Sacheextern void rl_reset_after_signal PARAMS((void)); 430119614Sacheextern void rl_free_line_state PARAMS((void)); 43147563Sache 432119614Sacheextern int rl_set_paren_blink_timeout PARAMS((int)); 43321308Sache 43475409Sache/* Undocumented. */ 435119614Sacheextern int rl_maybe_save_line PARAMS((void)); 436119614Sacheextern int rl_maybe_unsave_line PARAMS((void)); 437119614Sacheextern int rl_maybe_replace_line PARAMS((void)); 43847563Sache 43921308Sache/* Completion functions. */ 440119614Sacheextern int rl_complete_internal PARAMS((int)); 441119614Sacheextern void rl_display_match_list PARAMS((char **, int, int)); 44221308Sache 443119614Sacheextern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *)); 444119614Sacheextern char *rl_username_completion_function PARAMS((const char *, int)); 445119614Sacheextern char *rl_filename_completion_function PARAMS((const char *, int)); 44621308Sache 447119614Sacheextern int rl_completion_mode PARAMS((rl_command_func_t *)); 448119614Sache 449124575Sobrien#if !defined(RL_NO_COMPAT) 45075409Sache/* Backwards compatibility (compat.c). These will go away sometime. */ 451119614Sacheextern void free_undo_list PARAMS((void)); 452119614Sacheextern int maybe_save_line PARAMS((void)); 453119614Sacheextern int maybe_unsave_line PARAMS((void)); 454119614Sacheextern int maybe_replace_line PARAMS((void)); 45575409Sache 456119614Sacheextern int ding PARAMS((void)); 457119614Sacheextern int alphabetic PARAMS((int)); 458119614Sacheextern int crlf PARAMS((void)); 45975409Sache 460119614Sacheextern char **completion_matches PARAMS((char *, rl_compentry_func_t *)); 461119614Sacheextern char *username_completion_function PARAMS((const char *, int)); 462119614Sacheextern char *filename_completion_function PARAMS((const char *, int)); 463119614Sache#endif 46475409Sache 46521308Sache/* **************************************************************** */ 46621308Sache/* */ 46721308Sache/* Well Published Variables */ 46821308Sache/* */ 46921308Sache/* **************************************************************** */ 47021308Sache 47121308Sache/* The version of this incarnation of the readline library. */ 472119614Sacheextern const char *rl_library_version; /* e.g., "4.2" */ 473119614Sacheextern int rl_readline_version; /* e.g., 0x0402 */ 47421308Sache 47558314Sache/* True if this is real GNU readline. */ 47658314Sacheextern int rl_gnu_readline_p; 47758314Sache 47875409Sache/* Flags word encapsulating the current readline state. */ 47975409Sacheextern int rl_readline_state; 48075409Sache 48175409Sache/* Says which editing mode readline is currently using. 1 means emacs mode; 48275409Sache 0 means vi mode. */ 48375409Sacheextern int rl_editing_mode; 48475409Sache 485119614Sache/* Insert or overwrite mode for emacs mode. 1 means insert mode; 0 means 486119614Sache overwrite mode. Reset to insert mode on each input line. */ 487119614Sacheextern int rl_insert_mode; 488119614Sache 48921308Sache/* The name of the calling program. You should initialize this to 49021308Sache whatever was in argv[0]. It is used when parsing conditionals. */ 49175409Sacheextern const char *rl_readline_name; 49221308Sache 49326500Sache/* The prompt readline uses. This is set from the argument to 49426500Sache readline (), and should not be assigned to directly. */ 49526500Sacheextern char *rl_prompt; 49626500Sache 49721308Sache/* The line buffer that is in use. */ 49821308Sacheextern char *rl_line_buffer; 49921308Sache 50021308Sache/* The location of point, and end. */ 50175409Sacheextern int rl_point; 50275409Sacheextern int rl_end; 50321308Sache 50447563Sache/* The mark, or saved cursor position. */ 50521308Sacheextern int rl_mark; 50621308Sache 50747563Sache/* Flag to indicate that readline has finished with the current input 50847563Sache line and should return it. */ 50921308Sacheextern int rl_done; 51021308Sache 51147563Sache/* If set to a character value, that will be the next keystroke read. */ 51221308Sacheextern int rl_pending_input; 51321308Sache 51426500Sache/* Non-zero if we called this function from _rl_dispatch(). It's present 51526500Sache so functions can find out whether they were called from a key binding 51626500Sache or directly from an application. */ 51730974Sacheextern int rl_dispatching; 51826500Sache 51975409Sache/* Non-zero if the user typed a numeric argument before executing the 52075409Sache current function. */ 52175409Sacheextern int rl_explicit_arg; 52275409Sache 52375409Sache/* The current value of the numeric argument specified by the user. */ 52475409Sacheextern int rl_numeric_arg; 52575409Sache 52675409Sache/* The address of the last command function Readline executed. */ 52775409Sacheextern rl_command_func_t *rl_last_func; 52875409Sache 52921308Sache/* The name of the terminal to use. */ 53075409Sacheextern const char *rl_terminal_name; 53121308Sache 53221308Sache/* The input and output streams. */ 53375409Sacheextern FILE *rl_instream; 53475409Sacheextern FILE *rl_outstream; 53521308Sache 536157188Sache/* If non-zero, Readline gives values of LINES and COLUMNS from the environment 537157188Sache greater precedence than values fetched from the kernel when computing the 538157188Sache screen dimensions. */ 539157188Sacheextern int rl_prefer_env_winsize; 540157188Sache 54121308Sache/* If non-zero, then this is the address of a function to call just 54221308Sache before readline_internal () prints the first prompt. */ 54375409Sacheextern rl_hook_func_t *rl_startup_hook; 54421308Sache 54547563Sache/* If non-zero, this is the address of a function to call just before 54647563Sache readline_internal_setup () returns and readline_internal starts 54747563Sache reading input characters. */ 54875409Sacheextern rl_hook_func_t *rl_pre_input_hook; 54947563Sache 55021308Sache/* The address of a function to call periodically while Readline is 55121308Sache awaiting character input, or NULL, for no event handling. */ 55275409Sacheextern rl_hook_func_t *rl_event_hook; 55321308Sache 55475409Sache/* The address of the function to call to fetch a character from the current 55575409Sache Readline input stream */ 55675409Sacheextern rl_getc_func_t *rl_getc_function; 55721308Sache 55875409Sacheextern rl_voidfunc_t *rl_redisplay_function; 55975409Sache 56075409Sacheextern rl_vintfunc_t *rl_prep_term_function; 56175409Sacheextern rl_voidfunc_t *rl_deprep_term_function; 56275409Sache 56321308Sache/* Dispatch variables. */ 56421308Sacheextern Keymap rl_executing_keymap; 56521308Sacheextern Keymap rl_binding_keymap; 56621308Sache 56747563Sache/* Display variables. */ 56847563Sache/* If non-zero, readline will erase the entire line, including any prompt, 56947563Sache if the only thing typed on an otherwise-blank line is something bound to 57047563Sache rl_newline. */ 57147563Sacheextern int rl_erase_empty_line; 57247563Sache 57358314Sache/* If non-zero, the application has already printed the prompt (rl_prompt) 57458314Sache before calling readline, so readline should not output it the first time 57558314Sache redisplay is done. */ 57658314Sacheextern int rl_already_prompted; 57758314Sache 57858314Sache/* A non-zero value means to read only this many characters rather than 57958314Sache up to a character bound to accept-line. */ 58058314Sacheextern int rl_num_chars_to_read; 58158314Sache 58275409Sache/* The text of a currently-executing keyboard macro. */ 58375409Sacheextern char *rl_executing_macro; 58475409Sache 58547563Sache/* Variables to control readline signal handling. */ 58647563Sache/* If non-zero, readline will install its own signal handlers for 58747563Sache SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */ 58847563Sacheextern int rl_catch_signals; 58947563Sache 59047563Sache/* If non-zero, readline will install a signal handler for SIGWINCH 59147563Sache that also attempts to call any calling application's SIGWINCH signal 59247563Sache handler. Note that the terminal is not cleaned up before the 59347563Sache application's signal handler is called; use rl_cleanup_after_signal() 59447563Sache to do that. */ 59547563Sacheextern int rl_catch_sigwinch; 59647563Sache 59721308Sache/* Completion variables. */ 59821308Sache/* Pointer to the generator function for completion_matches (). 599119614Sache NULL means to use rl_filename_completion_function (), the default 600119614Sache filename completer. */ 60175409Sacheextern rl_compentry_func_t *rl_completion_entry_function; 60221308Sache 60321308Sache/* If rl_ignore_some_completions_function is non-NULL it is the address 60421308Sache of a function to call after all of the possible matches have been 60521308Sache generated, but before the actual completion is done to the input line. 60621308Sache The function is called with one argument; a NULL terminated array 60721308Sache of (char *). If your function removes any of the elements, they 60821308Sache must be free()'ed. */ 60975409Sacheextern rl_compignore_func_t *rl_ignore_some_completions_function; 61021308Sache 61121308Sache/* Pointer to alternative function to create matches. 61221308Sache Function is called with TEXT, START, and END. 61321308Sache START and END are indices in RL_LINE_BUFFER saying what the boundaries 61421308Sache of TEXT are. 61521308Sache If this function exists and returns NULL then call the value of 61621308Sache rl_completion_entry_function to try to match, otherwise use the 61721308Sache array of strings returned. */ 61875409Sacheextern rl_completion_func_t *rl_attempted_completion_function; 61921308Sache 62021308Sache/* The basic list of characters that signal a break between words for the 62121308Sache completer routine. The initial contents of this variable is what 62221308Sache breaks words in the shell, i.e. "n\"\\'`@$>". */ 62375409Sacheextern const char *rl_basic_word_break_characters; 62421308Sache 62521308Sache/* The list of characters that signal a break between words for 62621308Sache rl_complete_internal. The default list is the contents of 62721308Sache rl_basic_word_break_characters. */ 628136652Sacheextern /*const*/ char *rl_completer_word_break_characters; 62921308Sache 630136652Sache/* Hook function to allow an application to set the completion word 631136652Sache break characters before readline breaks up the line. Allows 632136652Sache position-dependent word break characters. */ 633136652Sacheextern rl_cpvfunc_t *rl_completion_word_break_hook; 634136652Sache 63521308Sache/* List of characters which can be used to quote a substring of the line. 63621308Sache Completion occurs on the entire substring, and within the substring 63721308Sache rl_completer_word_break_characters are treated as any other character, 63821308Sache unless they also appear within this list. */ 63975409Sacheextern const char *rl_completer_quote_characters; 64021308Sache 64121308Sache/* List of quote characters which cause a word break. */ 64275409Sacheextern const char *rl_basic_quote_characters; 64321308Sache 64421308Sache/* List of characters that need to be quoted in filenames by the completer. */ 64575409Sacheextern const char *rl_filename_quote_characters; 64621308Sache 64721308Sache/* List of characters that are word break characters, but should be left 64821308Sache in TEXT when it is passed to the completion function. The shell uses 64921308Sache this to help determine what kind of completing to do. */ 65075409Sacheextern const char *rl_special_prefixes; 65121308Sache 65221308Sache/* If non-zero, then this is the address of a function to call when 65321308Sache completing on a directory name. The function is called with 65475409Sache the address of a string (the current directory name) as an arg. It 65575409Sache changes what is displayed when the possible completions are printed 65675409Sache or inserted. */ 65775409Sacheextern rl_icppfunc_t *rl_directory_completion_hook; 65821308Sache 65975409Sache/* If non-zero, this is the address of a function to call when completing 66075409Sache a directory name. This function takes the address of the directory name 66175409Sache to be modified as an argument. Unlike rl_directory_completion_hook, it 66275409Sache only modifies the directory name used in opendir(2), not what is displayed 66375409Sache when the possible completions are printed or inserted. It is called 66475409Sache before rl_directory_completion_hook. I'm not happy with how this works 66575409Sache yet, so it's undocumented. */ 66675409Sacheextern rl_icppfunc_t *rl_directory_rewrite_hook; 66775409Sache 66821308Sache/* Backwards compatibility with previous versions of readline. */ 66921308Sache#define rl_symbolic_link_hook rl_directory_completion_hook 67021308Sache 67147563Sache/* If non-zero, then this is the address of a function to call when 67247563Sache completing a word would normally display the list of possible matches. 67347563Sache This function is called instead of actually doing the display. 67447563Sache It takes three arguments: (char **matches, int num_matches, int max_length) 67547563Sache where MATCHES is the array of strings that matched, NUM_MATCHES is the 67647563Sache number of strings in that array, and MAX_LENGTH is the length of the 67747563Sache longest string in that array. */ 67875409Sacheextern rl_compdisp_func_t *rl_completion_display_matches_hook; 67947563Sache 68021308Sache/* Non-zero means that the results of the matches are to be treated 68121308Sache as filenames. This is ALWAYS zero on entry, and can only be changed 68221308Sache within a completion entry finder function. */ 68321308Sacheextern int rl_filename_completion_desired; 68421308Sache 68521308Sache/* Non-zero means that the results of the matches are to be quoted using 68621308Sache double quotes (or an application-specific quoting mechanism) if the 68721308Sache filename contains any characters in rl_word_break_chars. This is 68821308Sache ALWAYS non-zero on entry, and can only be changed within a completion 68921308Sache entry finder function. */ 69021308Sacheextern int rl_filename_quoting_desired; 69121308Sache 69221308Sache/* Set to a function to quote a filename in an application-specific fashion. 69321308Sache Called with the text to quote, the type of match found (single or multiple) 69421308Sache and a pointer to the quoting character to be used, which the function can 69521308Sache reset if desired. */ 69675409Sacheextern rl_quote_func_t *rl_filename_quoting_function; 69721308Sache 69821308Sache/* Function to call to remove quoting characters from a filename. Called 69921308Sache before completion is attempted, so the embedded quotes do not interfere 70021308Sache with matching names in the file system. */ 70175409Sacheextern rl_dequote_func_t *rl_filename_dequoting_function; 70221308Sache 70321308Sache/* Function to call to decide whether or not a word break character is 70421308Sache quoted. If a character is quoted, it does not break words for the 70521308Sache completer. */ 70675409Sacheextern rl_linebuf_func_t *rl_char_is_quoted_p; 70721308Sache 70821308Sache/* Non-zero means to suppress normal filename completion after the 70921308Sache user-specified completion function has been called. */ 71021308Sacheextern int rl_attempted_completion_over; 71121308Sache 71221308Sache/* Set to a character describing the type of completion being attempted by 71321308Sache rl_complete_internal; available for use by application completion 71421308Sache functions. */ 71521308Sacheextern int rl_completion_type; 71621308Sache 717136652Sache/* Up to this many items will be displayed in response to a 718136652Sache possible-completions call. After that, we ask the user if she 719136652Sache is sure she wants to see them all. The default value is 100. */ 720136652Sacheextern int rl_completion_query_items; 721136652Sache 72221308Sache/* Character appended to completed words when at the end of the line. The 72321308Sache default is a space. Nothing is added if this is '\0'. */ 72421308Sacheextern int rl_completion_append_character; 72521308Sache 726119614Sache/* If set to non-zero by an application completion function, 727119614Sache rl_completion_append_character will not be appended. */ 728119614Sacheextern int rl_completion_suppress_append; 729119614Sache 730136652Sache/* Set to any quote character readline thinks it finds before any application 731136652Sache completion function is called. */ 732136652Sacheextern int rl_completion_quote_character; 73326500Sache 734136652Sache/* Set to a non-zero value if readline found quoting anywhere in the word to 735136652Sache be completed; set before any application completion function is called. */ 736136652Sacheextern int rl_completion_found_quote; 737136652Sache 738136652Sache/* If non-zero, the completion functions don't append any closing quote. 739136652Sache This is set to 0 by rl_complete_internal and may be changed by an 740136652Sache application-specific completion function. */ 741136652Sacheextern int rl_completion_suppress_quote; 742136652Sache 743119614Sache/* If non-zero, a slash will be appended to completed filenames that are 744119614Sache symbolic links to directory names, subject to the value of the 745119614Sache mark-directories variable (which is user-settable). This exists so 746119614Sache that application completion functions can override the user's preference 747119614Sache (set via the mark-symlinked-directories variable) if appropriate. 748119614Sache It's set to the value of _rl_complete_mark_symlink_dirs in 749119614Sache rl_complete_internal before any application-specific completion 750119614Sache function is called, so without that function doing anything, the user's 751119614Sache preferences are honored. */ 752119614Sacheextern int rl_completion_mark_symlink_dirs; 753119614Sache 75426500Sache/* If non-zero, then disallow duplicates in the matches. */ 75526500Sacheextern int rl_ignore_completion_duplicates; 75626500Sache 75721308Sache/* If this is non-zero, completion is (temporarily) inhibited, and the 75821308Sache completion character will be inserted as any other. */ 75921308Sacheextern int rl_inhibit_completion; 760119614Sache 761165675Sache/* Input error; can be returned by (*rl_getc_function) if readline is reading 762165675Sache a top-level command (RL_ISSTATE (RL_STATE_READCMD)). */ 763165675Sache#define READERR (-2) 764165675Sache 76521308Sache/* Definitions available for use by readline clients. */ 76621308Sache#define RL_PROMPT_START_IGNORE '\001' 76721308Sache#define RL_PROMPT_END_IGNORE '\002' 76821308Sache 76921308Sache/* Possible values for do_replace argument to rl_filename_quoting_function, 77021308Sache called by rl_complete_internal. */ 77121308Sache#define NO_MATCH 0 77221308Sache#define SINGLE_MATCH 1 77321308Sache#define MULT_MATCH 2 77421308Sache 77575409Sache/* Possible state values for rl_readline_state */ 776157188Sache#define RL_STATE_NONE 0x000000 /* no state; before first call */ 77775409Sache 778157188Sache#define RL_STATE_INITIALIZING 0x000001 /* initializing */ 779157188Sache#define RL_STATE_INITIALIZED 0x000002 /* initialization done */ 780157188Sache#define RL_STATE_TERMPREPPED 0x000004 /* terminal is prepped */ 781157188Sache#define RL_STATE_READCMD 0x000008 /* reading a command key */ 782157188Sache#define RL_STATE_METANEXT 0x000010 /* reading input after ESC */ 783157188Sache#define RL_STATE_DISPATCHING 0x000020 /* dispatching to a command */ 784157188Sache#define RL_STATE_MOREINPUT 0x000040 /* reading more input in a command function */ 785157188Sache#define RL_STATE_ISEARCH 0x000080 /* doing incremental search */ 786157188Sache#define RL_STATE_NSEARCH 0x000100 /* doing non-inc search */ 787157188Sache#define RL_STATE_SEARCH 0x000200 /* doing a history search */ 788157188Sache#define RL_STATE_NUMERICARG 0x000400 /* reading numeric argument */ 789157188Sache#define RL_STATE_MACROINPUT 0x000800 /* getting input from a macro */ 790157188Sache#define RL_STATE_MACRODEF 0x001000 /* defining keyboard macro */ 791157188Sache#define RL_STATE_OVERWRITE 0x002000 /* overwrite mode */ 792157188Sache#define RL_STATE_COMPLETING 0x004000 /* doing completion */ 793157188Sache#define RL_STATE_SIGHANDLER 0x008000 /* in readline sighandler */ 794157188Sache#define RL_STATE_UNDOING 0x010000 /* doing an undo */ 795157188Sache#define RL_STATE_INPUTPENDING 0x020000 /* rl_execute_next called */ 796157188Sache#define RL_STATE_TTYCSAVED 0x040000 /* tty special chars saved */ 797157188Sache#define RL_STATE_CALLBACK 0x080000 /* using the callback interface */ 798157188Sache#define RL_STATE_VIMOTION 0x100000 /* reading vi motion arg */ 799157188Sache#define RL_STATE_MULTIKEY 0x200000 /* reading multiple-key command */ 800157188Sache#define RL_STATE_VICMDONCE 0x400000 /* entered vi command mode at least once */ 80175409Sache 802157188Sache#define RL_STATE_DONE 0x800000 /* done; accepted line */ 80375409Sache 80475409Sache#define RL_SETSTATE(x) (rl_readline_state |= (x)) 80575409Sache#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x)) 80675409Sache#define RL_ISSTATE(x) (rl_readline_state & (x)) 80775409Sache 808119614Sachestruct readline_state { 809119614Sache /* line state */ 810119614Sache int point; 811119614Sache int end; 812119614Sache int mark; 813119614Sache char *buffer; 814119614Sache int buflen; 815119614Sache UNDO_LIST *ul; 816119614Sache char *prompt; 817119614Sache 818119614Sache /* global state */ 819119614Sache int rlstate; 820119614Sache int done; 821119614Sache Keymap kmap; 822119614Sache 823119614Sache /* input state */ 824119614Sache rl_command_func_t *lastfunc; 825119614Sache int insmode; 826119614Sache int edmode; 827119614Sache int kseqlen; 828119614Sache FILE *inf; 829119614Sache FILE *outf; 830119614Sache int pendingin; 831119614Sache char *macro; 832119614Sache 833119614Sache /* signal state */ 834119614Sache int catchsigs; 835119614Sache int catchsigwinch; 836119614Sache 837136652Sache /* search state */ 838136652Sache 839136652Sache /* completion state */ 840136652Sache 841136652Sache /* options state */ 842136652Sache 843119614Sache /* reserved for future expansion, so the struct size doesn't change */ 844119614Sache char reserved[64]; 845119614Sache}; 846119614Sache 847119614Sacheextern int rl_save_state PARAMS((struct readline_state *)); 848119614Sacheextern int rl_restore_state PARAMS((struct readline_state *)); 849119614Sache 850124575Sobrien#if !defined(RL_NO_COMPAT) 85121308Sache#if !defined (savestring) 85221334Sache#define savestring rl_savestring 85375409Sacheextern char *savestring __P((char *)); /* XXX backwards compatibility */ 85421308Sache#endif 855124575Sobrien#endif 85621308Sache 85747563Sache#ifdef __cplusplus 85847563Sache} 85947563Sache#endif 86047563Sache 86121308Sache#endif /* _READLINE_H_ */ 862