Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:07

0001 /* Readline.h -- the names of functions callable from within readline. */
0002 
0003 /* Copyright (C) 1987-2022 Free Software Foundation, Inc.
0004 
0005    This file is part of the GNU Readline Library (Readline), a library
0006    for reading lines of text with interactive input and history editing.      
0007 
0008    Readline is free software: you can redistribute it and/or modify
0009    it under the terms of the GNU General Public License as published by
0010    the Free Software Foundation, either version 3 of the License, or
0011    (at your option) any later version.
0012 
0013    Readline is distributed in the hope that it will be useful,
0014    but WITHOUT ANY WARRANTY; without even the implied warranty of
0015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0016    GNU General Public License for more details.
0017 
0018    You should have received a copy of the GNU General Public License
0019    along with Readline.  If not, see <http://www.gnu.org/licenses/>.
0020 */
0021 
0022 #if !defined (_READLINE_H_)
0023 #define _READLINE_H_
0024 
0025 #ifdef __cplusplus
0026 extern "C" {
0027 #endif
0028 
0029 #if defined (READLINE_LIBRARY)
0030 #  include "rlstdc.h"
0031 #  include "rltypedefs.h"
0032 #  include "keymaps.h"
0033 #  include "tilde.h"
0034 #else
0035 #  include <readline/rlstdc.h>
0036 #  include <readline/rltypedefs.h>
0037 #  include <readline/keymaps.h>
0038 #  include <readline/tilde.h>
0039 #endif
0040 
0041 /* Hex-encoded Readline version number. */
0042 #define RL_READLINE_VERSION 0x0802      /* Readline 8.2 */
0043 #define RL_VERSION_MAJOR    8
0044 #define RL_VERSION_MINOR    2
0045 
0046 /* Readline data structures. */
0047 
0048 /* Maintaining the state of undo.  We remember individual deletes and inserts
0049    on a chain of things to do. */
0050 
0051 /* The actions that undo knows how to undo.  Notice that UNDO_DELETE means
0052    to insert some text, and UNDO_INSERT means to delete some text.   I.e.,
0053    the code tells undo what to undo, not how to undo it. */
0054 enum undo_code { UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END };
0055 
0056 /* What an element of THE_UNDO_LIST looks like. */
0057 typedef struct undo_list {
0058   struct undo_list *next;
0059   int start, end;       /* Where the change took place. */
0060   char *text;           /* The text to insert, if undoing a delete. */
0061   enum undo_code what;      /* Delete, Insert, Begin, End. */
0062 } UNDO_LIST;
0063 
0064 /* The current undo list for RL_LINE_BUFFER. */
0065 extern UNDO_LIST *rl_undo_list;
0066 
0067 /* The data structure for mapping textual names to code addresses. */
0068 typedef struct _funmap {
0069   const char *name;
0070   rl_command_func_t *function;
0071 } FUNMAP;
0072 
0073 extern FUNMAP **funmap;
0074 
0075 /* **************************************************************** */
0076 /*                                  */
0077 /*       Functions available to bind to key sequences       */
0078 /*                                  */
0079 /* **************************************************************** */
0080 
0081 /* Bindable commands for numeric arguments. */
0082 extern int rl_digit_argument (int, int);
0083 extern int rl_universal_argument (int, int);
0084 
0085 /* Bindable commands for moving the cursor. */
0086 extern int rl_forward_byte (int, int);
0087 extern int rl_forward_char (int, int);
0088 extern int rl_forward (int, int);
0089 extern int rl_backward_byte (int, int);
0090 extern int rl_backward_char (int, int);
0091 extern int rl_backward (int, int);
0092 extern int rl_beg_of_line (int, int);
0093 extern int rl_end_of_line (int, int);
0094 extern int rl_forward_word (int, int);
0095 extern int rl_backward_word (int, int);
0096 extern int rl_refresh_line (int, int);
0097 extern int rl_clear_screen (int, int);
0098 extern int rl_clear_display (int, int);
0099 extern int rl_skip_csi_sequence (int, int);
0100 extern int rl_arrow_keys (int, int);
0101 
0102 extern int rl_previous_screen_line (int, int);
0103 extern int rl_next_screen_line (int, int);
0104 
0105 /* Bindable commands for inserting and deleting text. */
0106 extern int rl_insert (int, int);
0107 extern int rl_quoted_insert (int, int);
0108 extern int rl_tab_insert (int, int);
0109 extern int rl_newline (int, int);
0110 extern int rl_do_lowercase_version (int, int);
0111 extern int rl_rubout (int, int);
0112 extern int rl_delete (int, int);
0113 extern int rl_rubout_or_delete (int, int);
0114 extern int rl_delete_horizontal_space (int, int);
0115 extern int rl_delete_or_show_completions (int, int);
0116 extern int rl_insert_comment (int, int);
0117 
0118 /* Bindable commands for changing case. */
0119 extern int rl_upcase_word (int, int);
0120 extern int rl_downcase_word (int, int);
0121 extern int rl_capitalize_word (int, int);
0122 
0123 /* Bindable commands for transposing characters and words. */
0124 extern int rl_transpose_words (int, int);
0125 extern int rl_transpose_chars (int, int);
0126 
0127 /* Bindable commands for searching within a line. */
0128 extern int rl_char_search (int, int);
0129 extern int rl_backward_char_search (int, int);
0130 
0131 /* Bindable commands for readline's interface to the command history. */
0132 extern int rl_beginning_of_history (int, int);
0133 extern int rl_end_of_history (int, int);
0134 extern int rl_get_next_history (int, int);
0135 extern int rl_get_previous_history (int, int);
0136 extern int rl_operate_and_get_next (int, int);
0137 extern int rl_fetch_history (int, int);
0138 
0139 /* Bindable commands for managing the mark and region. */
0140 extern int rl_set_mark (int, int);
0141 extern int rl_exchange_point_and_mark (int, int);
0142 
0143 /* Bindable commands to set the editing mode (emacs or vi). */
0144 extern int rl_vi_editing_mode (int, int);
0145 extern int rl_emacs_editing_mode (int, int);
0146 
0147 /* Bindable commands to change the insert mode (insert or overwrite) */
0148 extern int rl_overwrite_mode (int, int);
0149 
0150 /* Bindable commands for managing key bindings. */
0151 extern int rl_re_read_init_file (int, int);
0152 extern int rl_dump_functions (int, int);
0153 extern int rl_dump_macros (int, int);
0154 extern int rl_dump_variables (int, int);
0155 
0156 /* Bindable commands for word completion. */
0157 extern int rl_complete (int, int);
0158 extern int rl_possible_completions (int, int);
0159 extern int rl_insert_completions (int, int);
0160 extern int rl_old_menu_complete (int, int);
0161 extern int rl_menu_complete (int, int);
0162 extern int rl_backward_menu_complete (int, int);
0163 
0164 /* Bindable commands for killing and yanking text, and managing the kill ring. */
0165 extern int rl_kill_word (int, int);
0166 extern int rl_backward_kill_word (int, int);
0167 extern int rl_kill_line (int, int);
0168 extern int rl_backward_kill_line (int, int);
0169 extern int rl_kill_full_line (int, int);
0170 extern int rl_unix_word_rubout (int, int);
0171 extern int rl_unix_filename_rubout (int, int);
0172 extern int rl_unix_line_discard (int, int);
0173 extern int rl_copy_region_to_kill (int, int);
0174 extern int rl_kill_region (int, int);
0175 extern int rl_copy_forward_word (int, int);
0176 extern int rl_copy_backward_word (int, int);
0177 extern int rl_yank (int, int);
0178 extern int rl_yank_pop (int, int);
0179 extern int rl_yank_nth_arg (int, int);
0180 extern int rl_yank_last_arg (int, int);
0181 extern int rl_bracketed_paste_begin (int, int);
0182 /* Not available unless _WIN32 is defined. */
0183 #if defined (_WIN32)
0184 extern int rl_paste_from_clipboard (int, int);
0185 #endif
0186 
0187 /* Bindable commands for incremental searching. */
0188 extern int rl_reverse_search_history (int, int);
0189 extern int rl_forward_search_history (int, int);
0190 
0191 /* Bindable keyboard macro commands. */
0192 extern int rl_start_kbd_macro (int, int);
0193 extern int rl_end_kbd_macro (int, int);
0194 extern int rl_call_last_kbd_macro (int, int);
0195 extern int rl_print_last_kbd_macro (int, int);
0196 
0197 /* Bindable undo commands. */
0198 extern int rl_revert_line (int, int);
0199 extern int rl_undo_command (int, int);
0200 
0201 /* Bindable tilde expansion commands. */
0202 extern int rl_tilde_expand (int, int);
0203 
0204 /* Bindable terminal control commands. */
0205 extern int rl_restart_output (int, int);
0206 extern int rl_stop_output (int, int);
0207 
0208 /* Miscellaneous bindable commands. */
0209 extern int rl_abort (int, int);
0210 extern int rl_tty_status (int, int);
0211 
0212 /* Bindable commands for incremental and non-incremental history searching. */
0213 extern int rl_history_search_forward (int, int);
0214 extern int rl_history_search_backward (int, int);
0215 extern int rl_history_substr_search_forward (int, int);
0216 extern int rl_history_substr_search_backward (int, int);
0217 extern int rl_noninc_forward_search (int, int);
0218 extern int rl_noninc_reverse_search (int, int);
0219 extern int rl_noninc_forward_search_again (int, int);
0220 extern int rl_noninc_reverse_search_again (int, int);
0221 
0222 /* Bindable command used when inserting a matching close character. */
0223 extern int rl_insert_close (int, int);
0224 
0225 /* Not available unless READLINE_CALLBACKS is defined. */
0226 extern void rl_callback_handler_install (const char *, rl_vcpfunc_t *);
0227 extern void rl_callback_read_char (void);
0228 extern void rl_callback_handler_remove (void);
0229 extern void rl_callback_sigcleanup (void);
0230 
0231 /* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */
0232 /* VI-mode bindable commands. */
0233 extern int rl_vi_redo (int, int);
0234 extern int rl_vi_undo (int, int);
0235 extern int rl_vi_yank_arg (int, int);
0236 extern int rl_vi_fetch_history (int, int);
0237 extern int rl_vi_search_again (int, int);
0238 extern int rl_vi_search (int, int);
0239 extern int rl_vi_complete (int, int);
0240 extern int rl_vi_tilde_expand (int, int);
0241 extern int rl_vi_prev_word (int, int);
0242 extern int rl_vi_next_word (int, int);
0243 extern int rl_vi_end_word (int, int);
0244 extern int rl_vi_insert_beg (int, int);
0245 extern int rl_vi_append_mode (int, int);
0246 extern int rl_vi_append_eol (int, int);
0247 extern int rl_vi_eof_maybe (int, int);
0248 extern int rl_vi_insertion_mode (int, int);
0249 extern int rl_vi_insert_mode (int, int);
0250 extern int rl_vi_movement_mode (int, int);
0251 extern int rl_vi_arg_digit (int, int);
0252 extern int rl_vi_change_case (int, int);
0253 extern int rl_vi_put (int, int);
0254 extern int rl_vi_column (int, int);
0255 extern int rl_vi_delete_to (int, int);
0256 extern int rl_vi_change_to (int, int);
0257 extern int rl_vi_yank_to (int, int);
0258 extern int rl_vi_yank_pop (int, int);
0259 extern int rl_vi_rubout (int, int);
0260 extern int rl_vi_delete (int, int);
0261 extern int rl_vi_back_to_indent (int, int);
0262 extern int rl_vi_unix_word_rubout (int, int);
0263 extern int rl_vi_first_print (int, int);
0264 extern int rl_vi_char_search (int, int);
0265 extern int rl_vi_match (int, int);
0266 extern int rl_vi_change_char (int, int);
0267 extern int rl_vi_subst (int, int);
0268 extern int rl_vi_overstrike (int, int);
0269 extern int rl_vi_overstrike_delete (int, int);
0270 extern int rl_vi_replace (int, int);
0271 extern int rl_vi_set_mark (int, int);
0272 extern int rl_vi_goto_mark (int, int);
0273 
0274 /* VI-mode utility functions. */
0275 extern int rl_vi_check (void);
0276 extern int rl_vi_domove (int, int *);
0277 extern int rl_vi_bracktype (int);
0278 
0279 extern void rl_vi_start_inserting (int, int, int);
0280 
0281 /* VI-mode pseudo-bindable commands, used as utility functions. */
0282 extern int rl_vi_fWord (int, int);
0283 extern int rl_vi_bWord (int, int);
0284 extern int rl_vi_eWord (int, int);
0285 extern int rl_vi_fword (int, int);
0286 extern int rl_vi_bword (int, int);
0287 extern int rl_vi_eword (int, int);
0288 
0289 /* **************************************************************** */
0290 /*                                  */
0291 /*          Well Published Functions            */
0292 /*                                  */
0293 /* **************************************************************** */
0294 
0295 /* Readline functions. */
0296 /* Read a line of input.  Prompt with PROMPT.  A NULL PROMPT means none. */
0297 extern char *readline (const char *);
0298 
0299 extern int rl_set_prompt (const char *);
0300 extern int rl_expand_prompt (char *);
0301 
0302 extern int rl_initialize (void);
0303 
0304 /* Undocumented; unused by readline */
0305 extern int rl_discard_argument (void);
0306 
0307 /* Utility functions to bind keys to readline commands. */
0308 extern int rl_add_defun (const char *, rl_command_func_t *, int);
0309 extern int rl_bind_key (int, rl_command_func_t *);
0310 extern int rl_bind_key_in_map (int, rl_command_func_t *, Keymap);
0311 extern int rl_unbind_key (int);
0312 extern int rl_unbind_key_in_map (int, Keymap);
0313 extern int rl_bind_key_if_unbound (int, rl_command_func_t *);
0314 extern int rl_bind_key_if_unbound_in_map (int, rl_command_func_t *, Keymap);
0315 extern int rl_unbind_function_in_map (rl_command_func_t *, Keymap);
0316 extern int rl_unbind_command_in_map (const char *, Keymap);
0317 extern int rl_bind_keyseq (const char *, rl_command_func_t *);
0318 extern int rl_bind_keyseq_in_map (const char *, rl_command_func_t *, Keymap);
0319 extern int rl_bind_keyseq_if_unbound (const char *, rl_command_func_t *);
0320 extern int rl_bind_keyseq_if_unbound_in_map (const char *, rl_command_func_t *, Keymap);
0321 extern int rl_generic_bind (int, const char *, char *, Keymap);
0322 
0323 extern char *rl_variable_value (const char *);
0324 extern int rl_variable_bind (const char *, const char *);
0325 
0326 /* Backwards compatibility, use rl_bind_keyseq_in_map instead. */
0327 extern int rl_set_key (const char *, rl_command_func_t *, Keymap);
0328 
0329 /* Backwards compatibility, use rl_generic_bind instead. */
0330 extern int rl_macro_bind (const char *, const char *, Keymap);
0331 
0332 /* Undocumented in the texinfo manual; not really useful to programs. */
0333 extern int rl_translate_keyseq (const char *, char *, int *);
0334 extern char *rl_untranslate_keyseq (int);
0335 
0336 extern rl_command_func_t *rl_named_function (const char *);
0337 extern rl_command_func_t *rl_function_of_keyseq (const char *, Keymap, int *);
0338 extern rl_command_func_t *rl_function_of_keyseq_len (const char *, size_t, Keymap, int *);
0339 extern int rl_trim_arg_from_keyseq (const char *, size_t, Keymap);
0340 
0341 extern void rl_list_funmap_names (void);
0342 extern char **rl_invoking_keyseqs_in_map (rl_command_func_t *, Keymap);
0343 extern char **rl_invoking_keyseqs (rl_command_func_t *);
0344  
0345 extern void rl_function_dumper (int);
0346 extern void rl_macro_dumper (int);
0347 extern void rl_variable_dumper (int);
0348 
0349 extern int rl_read_init_file (const char *);
0350 extern int rl_parse_and_bind (char *);
0351 
0352 /* Functions for manipulating keymaps. */
0353 extern Keymap rl_make_bare_keymap (void);
0354 extern int rl_empty_keymap (Keymap);
0355 extern Keymap rl_copy_keymap (Keymap);
0356 extern Keymap rl_make_keymap (void);
0357 extern void rl_discard_keymap (Keymap);
0358 extern void rl_free_keymap (Keymap);
0359 
0360 extern Keymap rl_get_keymap_by_name (const char *);
0361 extern char *rl_get_keymap_name (Keymap);
0362 extern void rl_set_keymap (Keymap);
0363 extern Keymap rl_get_keymap (void);
0364 
0365 extern int rl_set_keymap_name (const char *, Keymap);
0366 
0367 /* Undocumented; used internally only. */
0368 extern void rl_set_keymap_from_edit_mode (void);
0369 extern char *rl_get_keymap_name_from_edit_mode (void);
0370 
0371 /* Functions for manipulating the funmap, which maps command names to functions. */
0372 extern int rl_add_funmap_entry (const char *, rl_command_func_t *);
0373 extern const char **rl_funmap_names (void);
0374 /* Undocumented, only used internally -- there is only one funmap, and this
0375    function may be called only once. */
0376 extern void rl_initialize_funmap (void);
0377 
0378 /* Utility functions for managing keyboard macros. */
0379 extern void rl_push_macro_input (char *);
0380 
0381 /* Functions for undoing, from undo.c */
0382 extern void rl_add_undo (enum undo_code, int, int, char *);
0383 extern void rl_free_undo_list (void);
0384 extern int rl_do_undo (void);
0385 extern int rl_begin_undo_group (void);
0386 extern int rl_end_undo_group (void);
0387 extern int rl_modifying (int, int);
0388 
0389 /* Functions for redisplay. */
0390 extern void rl_redisplay (void);
0391 extern int rl_on_new_line (void);
0392 extern int rl_on_new_line_with_prompt (void);
0393 extern int rl_forced_update_display (void);
0394 extern int rl_clear_visible_line (void);
0395 extern int rl_clear_message (void);
0396 extern int rl_reset_line_state (void);
0397 extern int rl_crlf (void);
0398 
0399 /* Functions to manage the mark and region, especially the notion of an
0400    active mark and an active region. */
0401 extern void rl_keep_mark_active (void);
0402 
0403 extern void rl_activate_mark (void);
0404 extern void rl_deactivate_mark (void);
0405 extern int rl_mark_active_p (void);
0406 
0407 #if defined (USE_VARARGS) && defined (PREFER_STDARG)
0408 extern int rl_message (const char *, ...)  __attribute__((__format__ (printf, 1, 2)));
0409 #else
0410 extern int rl_message ();
0411 #endif
0412 
0413 extern int rl_show_char (int);
0414 
0415 /* Undocumented in texinfo manual. */
0416 extern int rl_character_len (int, int);
0417 extern void rl_redraw_prompt_last_line (void);
0418 
0419 /* Save and restore internal prompt redisplay information. */
0420 extern void rl_save_prompt (void);
0421 extern void rl_restore_prompt (void);
0422 
0423 /* Modifying text. */
0424 extern void rl_replace_line (const char *, int);
0425 extern int rl_insert_text (const char *);
0426 extern int rl_delete_text (int, int);
0427 extern int rl_kill_text (int, int);
0428 extern char *rl_copy_text (int, int);
0429 
0430 /* Terminal and tty mode management. */
0431 extern void rl_prep_terminal (int);
0432 extern void rl_deprep_terminal (void);
0433 extern void rl_tty_set_default_bindings (Keymap);
0434 extern void rl_tty_unset_default_bindings (Keymap);
0435 
0436 extern int rl_tty_set_echoing (int);
0437 extern int rl_reset_terminal (const char *);
0438 extern void rl_resize_terminal (void);
0439 extern void rl_set_screen_size (int, int);
0440 extern void rl_get_screen_size (int *, int *);
0441 extern void rl_reset_screen_size (void);
0442 
0443 extern char *rl_get_termcap (const char *);
0444 
0445 /* Functions for character input. */
0446 extern int rl_stuff_char (int);
0447 extern int rl_execute_next (int);
0448 extern int rl_clear_pending_input (void);
0449 extern int rl_read_key (void);
0450 extern int rl_getc (FILE *);
0451 extern int rl_set_keyboard_input_timeout (int);
0452 
0453 /* Functions to set and reset timeouts. */
0454 extern int rl_set_timeout (unsigned int, unsigned int);
0455 extern int rl_timeout_remaining (unsigned int *, unsigned int *);
0456 
0457 #undef rl_clear_timeout
0458 #define rl_clear_timeout() rl_set_timeout (0, 0)
0459 
0460 /* `Public' utility functions . */
0461 extern void rl_extend_line_buffer (int);
0462 extern int rl_ding (void);
0463 extern int rl_alphabetic (int);
0464 extern void rl_free (void *);
0465 
0466 /* Readline signal handling, from signals.c */
0467 extern int rl_set_signals (void);
0468 extern int rl_clear_signals (void);
0469 extern void rl_cleanup_after_signal (void);
0470 extern void rl_reset_after_signal (void);
0471 extern void rl_free_line_state (void);
0472 
0473 extern int rl_pending_signal (void);
0474 extern void rl_check_signals (void);
0475 
0476 extern void rl_echo_signal_char (int); 
0477 
0478 extern int rl_set_paren_blink_timeout (int);
0479 
0480 /* History management functions. */
0481 
0482 extern void rl_clear_history (void);
0483 
0484 /* Undocumented. */
0485 extern int rl_maybe_save_line (void);
0486 extern int rl_maybe_unsave_line (void);
0487 extern int rl_maybe_replace_line (void);
0488 
0489 /* Completion functions. */
0490 extern int rl_complete_internal (int);
0491 extern void rl_display_match_list (char **, int, int);
0492 
0493 extern char **rl_completion_matches (const char *, rl_compentry_func_t *);
0494 extern char *rl_username_completion_function (const char *, int);
0495 extern char *rl_filename_completion_function (const char *, int);
0496 
0497 extern int rl_completion_mode (rl_command_func_t *);
0498 
0499 #if 0
0500 /* Backwards compatibility (compat.c).  These will go away sometime. */
0501 extern void free_undo_list (void);
0502 extern int maybe_save_line (void);
0503 extern int maybe_unsave_line (void);
0504 extern int maybe_replace_line (void);
0505 
0506 extern int ding (void);
0507 extern int alphabetic (int);
0508 extern int crlf (void);
0509 
0510 extern char **completion_matches (char *, rl_compentry_func_t *);
0511 extern char *username_completion_function (const char *, int);
0512 extern char *filename_completion_function (const char *, int);
0513 #endif
0514 
0515 /* **************************************************************** */
0516 /*                                  */
0517 /*          Well Published Variables            */
0518 /*                                  */
0519 /* **************************************************************** */
0520 
0521 /* The version of this incarnation of the readline library. */
0522 extern const char *rl_library_version;      /* e.g., "4.2" */
0523 extern int rl_readline_version;         /* e.g., 0x0402 */
0524 
0525 /* True if this is real GNU readline. */
0526 extern int rl_gnu_readline_p;
0527 
0528 /* Flags word encapsulating the current readline state. */
0529 extern unsigned long rl_readline_state;
0530 
0531 /* Says which editing mode readline is currently using.  1 means emacs mode;
0532    0 means vi mode. */
0533 extern int rl_editing_mode;
0534 
0535 /* Insert or overwrite mode for emacs mode.  1 means insert mode; 0 means
0536    overwrite mode.  Reset to insert mode on each input line. */
0537 extern int rl_insert_mode;
0538 
0539 /* The name of the calling program.  You should initialize this to
0540    whatever was in argv[0].  It is used when parsing conditionals. */
0541 extern const char *rl_readline_name;
0542 
0543 /* The prompt readline uses.  This is set from the argument to
0544    readline (), and should not be assigned to directly. */
0545 extern char *rl_prompt;
0546 
0547 /* The prompt string that is actually displayed by rl_redisplay.  Public so
0548    applications can more easily supply their own redisplay functions. */
0549 extern char *rl_display_prompt;
0550 
0551 /* The line buffer that is in use. */
0552 extern char *rl_line_buffer;
0553 
0554 /* The location of point, and end. */
0555 extern int rl_point;
0556 extern int rl_end;
0557 
0558 /* The mark, or saved cursor position. */
0559 extern int rl_mark;
0560 
0561 /* Flag to indicate that readline has finished with the current input
0562    line and should return it. */
0563 extern int rl_done;
0564 
0565 /* Flag to indicate that readline has read an EOF character or read has
0566    returned 0 or error, and is returning a NULL line as a result. */
0567 extern int rl_eof_found;
0568 
0569 /* If set to a character value, that will be the next keystroke read. */
0570 extern int rl_pending_input;
0571 
0572 /* Non-zero if we called this function from _rl_dispatch().  It's present
0573    so functions can find out whether they were called from a key binding
0574    or directly from an application. */
0575 extern int rl_dispatching;
0576 
0577 /* Non-zero if the user typed a numeric argument before executing the
0578    current function. */
0579 extern int rl_explicit_arg;
0580 
0581 /* The current value of the numeric argument specified by the user. */
0582 extern int rl_numeric_arg;
0583 
0584 /* The address of the last command function Readline executed. */
0585 extern rl_command_func_t *rl_last_func;
0586 
0587 /* The name of the terminal to use. */
0588 extern const char *rl_terminal_name;
0589 
0590 /* The input and output streams. */
0591 extern FILE *rl_instream;
0592 extern FILE *rl_outstream;
0593 
0594 /* If non-zero, Readline gives values of LINES and COLUMNS from the environment
0595    greater precedence than values fetched from the kernel when computing the
0596    screen dimensions. */
0597 extern int rl_prefer_env_winsize;
0598 
0599 /* If non-zero, then this is the address of a function to call just
0600    before readline_internal () prints the first prompt. */
0601 extern rl_hook_func_t *rl_startup_hook;
0602 
0603 /* If non-zero, this is the address of a function to call just before
0604    readline_internal_setup () returns and readline_internal starts
0605    reading input characters. */
0606 extern rl_hook_func_t *rl_pre_input_hook;
0607       
0608 /* The address of a function to call periodically while Readline is
0609    awaiting character input, or NULL, for no event handling. */
0610 extern rl_hook_func_t *rl_event_hook;
0611 
0612 /* The address of a function to call if a read is interrupted by a signal. */
0613 extern rl_hook_func_t *rl_signal_event_hook;
0614 
0615 extern rl_hook_func_t *rl_timeout_event_hook;
0616 
0617 /* The address of a function to call if Readline needs to know whether or not
0618    there is data available from the current input source. */
0619 extern rl_hook_func_t *rl_input_available_hook;
0620 
0621 /* The address of the function to call to fetch a character from the current
0622    Readline input stream */
0623 extern rl_getc_func_t *rl_getc_function;
0624 
0625 extern rl_voidfunc_t *rl_redisplay_function;
0626 
0627 extern rl_vintfunc_t *rl_prep_term_function;
0628 extern rl_voidfunc_t *rl_deprep_term_function;
0629 
0630 /* Dispatch variables. */
0631 extern Keymap rl_executing_keymap;
0632 extern Keymap rl_binding_keymap;
0633 
0634 extern int rl_executing_key;
0635 extern char *rl_executing_keyseq;
0636 extern int rl_key_sequence_length;
0637 
0638 /* Display variables. */
0639 /* If non-zero, readline will erase the entire line, including any prompt,
0640    if the only thing typed on an otherwise-blank line is something bound to
0641    rl_newline. */
0642 extern int rl_erase_empty_line;
0643 
0644 /* If non-zero, the application has already printed the prompt (rl_prompt)
0645    before calling readline, so readline should not output it the first time
0646    redisplay is done. */
0647 extern int rl_already_prompted;
0648 
0649 /* A non-zero value means to read only this many characters rather than
0650    up to a character bound to accept-line. */
0651 extern int rl_num_chars_to_read;
0652 
0653 /* The text of a currently-executing keyboard macro. */
0654 extern char *rl_executing_macro;
0655 
0656 /* Variables to control readline signal handling. */
0657 /* If non-zero, readline will install its own signal handlers for
0658    SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
0659 extern int rl_catch_signals;
0660 
0661 /* If non-zero, readline will install a signal handler for SIGWINCH
0662    that also attempts to call any calling application's SIGWINCH signal
0663    handler.  Note that the terminal is not cleaned up before the
0664    application's signal handler is called; use rl_cleanup_after_signal()
0665    to do that. */
0666 extern int rl_catch_sigwinch;
0667 
0668 /* If non-zero, the readline SIGWINCH handler will modify LINES and
0669    COLUMNS in the environment. */
0670 extern int rl_change_environment;
0671 
0672 /* Completion variables. */
0673 /* Pointer to the generator function for completion_matches ().
0674    NULL means to use rl_filename_completion_function (), the default
0675    filename completer. */
0676 extern rl_compentry_func_t *rl_completion_entry_function;
0677 
0678 /* Optional generator for menu completion.  Default is
0679    rl_completion_entry_function (rl_filename_completion_function). */
0680 extern rl_compentry_func_t *rl_menu_completion_entry_function;
0681 
0682 /* If rl_ignore_some_completions_function is non-NULL it is the address
0683    of a function to call after all of the possible matches have been
0684    generated, but before the actual completion is done to the input line.
0685    The function is called with one argument; a NULL terminated array
0686    of (char *).  If your function removes any of the elements, they
0687    must be free()'ed. */
0688 extern rl_compignore_func_t *rl_ignore_some_completions_function;
0689 
0690 /* Pointer to alternative function to create matches.
0691    Function is called with TEXT, START, and END.
0692    START and END are indices in RL_LINE_BUFFER saying what the boundaries
0693    of TEXT are.
0694    If this function exists and returns NULL then call the value of
0695    rl_completion_entry_function to try to match, otherwise use the
0696    array of strings returned. */
0697 extern rl_completion_func_t *rl_attempted_completion_function;
0698 
0699 /* The basic list of characters that signal a break between words for the
0700    completer routine.  The initial contents of this variable is what
0701    breaks words in the shell, i.e. "n\"\\'`@$>". */
0702 extern const char *rl_basic_word_break_characters;
0703 
0704 /* The list of characters that signal a break between words for
0705    rl_complete_internal.  The default list is the contents of
0706    rl_basic_word_break_characters.  */
0707 extern const char *rl_completer_word_break_characters;
0708 
0709 /* Hook function to allow an application to set the completion word
0710    break characters before readline breaks up the line.  Allows
0711    position-dependent word break characters. */
0712 extern rl_cpvfunc_t *rl_completion_word_break_hook;
0713 
0714 /* List of characters which can be used to quote a substring of the line.
0715    Completion occurs on the entire substring, and within the substring   
0716    rl_completer_word_break_characters are treated as any other character,
0717    unless they also appear within this list. */
0718 extern const char *rl_completer_quote_characters;
0719 
0720 /* List of quote characters which cause a word break. */
0721 extern const char *rl_basic_quote_characters;
0722 
0723 /* List of characters that need to be quoted in filenames by the completer. */
0724 extern const char *rl_filename_quote_characters;
0725 
0726 /* List of characters that are word break characters, but should be left
0727    in TEXT when it is passed to the completion function.  The shell uses
0728    this to help determine what kind of completing to do. */
0729 extern const char *rl_special_prefixes;
0730 
0731 /* If non-zero, then this is the address of a function to call when
0732    completing on a directory name.  The function is called with
0733    the address of a string (the current directory name) as an arg.  It
0734    changes what is displayed when the possible completions are printed
0735    or inserted.  The directory completion hook should perform
0736    any necessary dequoting.  This function should return 1 if it modifies
0737    the directory name pointer passed as an argument.  If the directory
0738    completion hook returns 0, it should not modify the directory name
0739    pointer passed as an argument. */
0740 extern rl_icppfunc_t *rl_directory_completion_hook;
0741 
0742 /* If non-zero, this is the address of a function to call when completing
0743    a directory name.  This function takes the address of the directory name
0744    to be modified as an argument.  Unlike rl_directory_completion_hook, it
0745    only modifies the directory name used in opendir(2), not what is displayed
0746    when the possible completions are printed or inserted.  If set, it takes
0747    precedence over rl_directory_completion_hook.  The directory rewrite
0748    hook should perform any necessary dequoting.  This function has the same
0749    return value properties as the directory_completion_hook.
0750 
0751    I'm not happy with how this works yet, so it's undocumented.  I'm trying
0752    it in bash to see how well it goes. */
0753 extern rl_icppfunc_t *rl_directory_rewrite_hook;
0754 
0755 /* If non-zero, this is the address of a function for the completer to call
0756    before deciding which character to append to a completed name.  It should
0757    modify the directory name passed as an argument if appropriate, and return
0758    non-zero if it modifies the name.  This should not worry about dequoting
0759    the filename; that has already happened by the time it gets here. */
0760 extern rl_icppfunc_t *rl_filename_stat_hook;
0761 
0762 /* If non-zero, this is the address of a function to call when reading
0763    directory entries from the filesystem for completion and comparing
0764    them to the partial word to be completed.  The function should
0765    either return its first argument (if no conversion takes place) or
0766    newly-allocated memory.  This can, for instance, convert filenames
0767    between character sets for comparison against what's typed at the
0768    keyboard.  The returned value is what is added to the list of
0769    matches.  The second argument is the length of the filename to be
0770    converted. */
0771 extern rl_dequote_func_t *rl_filename_rewrite_hook;
0772 
0773 /* Backwards compatibility with previous versions of readline. */
0774 #define rl_symbolic_link_hook rl_directory_completion_hook
0775 
0776 /* If non-zero, then this is the address of a function to call when
0777    completing a word would normally display the list of possible matches.
0778    This function is called instead of actually doing the display.
0779    It takes three arguments: (char **matches, int num_matches, int max_length)
0780    where MATCHES is the array of strings that matched, NUM_MATCHES is the
0781    number of strings in that array, and MAX_LENGTH is the length of the
0782    longest string in that array. */
0783 extern rl_compdisp_func_t *rl_completion_display_matches_hook;
0784 
0785 /* Non-zero means that the results of the matches are to be treated
0786    as filenames.  This is ALWAYS zero on entry, and can only be changed
0787    within a completion entry finder function. */
0788 extern int rl_filename_completion_desired;
0789 
0790 /* Non-zero means that the results of the matches are to be quoted using
0791    double quotes (or an application-specific quoting mechanism) if the
0792    filename contains any characters in rl_word_break_chars.  This is
0793    ALWAYS non-zero on entry, and can only be changed within a completion
0794    entry finder function. */
0795 extern int rl_filename_quoting_desired;
0796 
0797 /* Set to a function to quote a filename in an application-specific fashion.
0798    Called with the text to quote, the type of match found (single or multiple)
0799    and a pointer to the quoting character to be used, which the function can
0800    reset if desired. */
0801 extern rl_quote_func_t *rl_filename_quoting_function;
0802 
0803 /* Function to call to remove quoting characters from a filename.  Called
0804    before completion is attempted, so the embedded quotes do not interfere
0805    with matching names in the file system. */
0806 extern rl_dequote_func_t *rl_filename_dequoting_function;
0807 
0808 /* Function to call to decide whether or not a word break character is
0809    quoted.  If a character is quoted, it does not break words for the
0810    completer. */
0811 extern rl_linebuf_func_t *rl_char_is_quoted_p;
0812 
0813 /* Non-zero means to suppress normal filename completion after the
0814    user-specified completion function has been called. */
0815 extern int rl_attempted_completion_over;
0816 
0817 /* Set to a character describing the type of completion being attempted by
0818    rl_complete_internal; available for use by application completion
0819    functions. */
0820 extern int rl_completion_type;
0821 
0822 /* Set to the last key used to invoke one of the completion functions */
0823 extern int rl_completion_invoking_key;
0824 
0825 /* Up to this many items will be displayed in response to a
0826    possible-completions call.  After that, we ask the user if she
0827    is sure she wants to see them all.  The default value is 100. */
0828 extern int rl_completion_query_items;
0829 
0830 /* Character appended to completed words when at the end of the line.  The
0831    default is a space.  Nothing is added if this is '\0'. */
0832 extern int rl_completion_append_character;
0833 
0834 /* If set to non-zero by an application completion function,
0835    rl_completion_append_character will not be appended. */
0836 extern int rl_completion_suppress_append;
0837 
0838 /* Set to any quote character readline thinks it finds before any application
0839    completion function is called. */
0840 extern int rl_completion_quote_character;
0841 
0842 /* Set to a non-zero value if readline found quoting anywhere in the word to
0843    be completed; set before any application completion function is called. */
0844 extern int rl_completion_found_quote;
0845 
0846 /* If non-zero, the completion functions don't append any closing quote.
0847    This is set to 0 by rl_complete_internal and may be changed by an
0848    application-specific completion function. */
0849 extern int rl_completion_suppress_quote;
0850 
0851 /* If non-zero, readline will sort the completion matches.  On by default. */
0852 extern int rl_sort_completion_matches;
0853 
0854 /* If non-zero, a slash will be appended to completed filenames that are
0855    symbolic links to directory names, subject to the value of the
0856    mark-directories variable (which is user-settable).  This exists so
0857    that application completion functions can override the user's preference
0858    (set via the mark-symlinked-directories variable) if appropriate.
0859    It's set to the value of _rl_complete_mark_symlink_dirs in
0860    rl_complete_internal before any application-specific completion
0861    function is called, so without that function doing anything, the user's
0862    preferences are honored. */
0863 extern int rl_completion_mark_symlink_dirs;
0864 
0865 /* If non-zero, then disallow duplicates in the matches. */
0866 extern int rl_ignore_completion_duplicates;
0867 
0868 /* If this is non-zero, completion is (temporarily) inhibited, and the
0869    completion character will be inserted as any other. */
0870 extern int rl_inhibit_completion;
0871 
0872 /* Applications can set this to non-zero to have readline's signal handlers
0873    installed during the entire duration of reading a complete line, as in
0874    readline-6.2.  This should be used with care, because it can result in
0875    readline receiving signals and not handling them until it's called again
0876    via rl_callback_read_char, thereby stealing them from the application.
0877    By default, signal handlers are only active while readline is active. */   
0878 extern int rl_persistent_signal_handlers;
0879 
0880 /* Input error; can be returned by (*rl_getc_function) if readline is reading
0881    a top-level command (RL_ISSTATE (RL_STATE_READCMD)). */
0882 #define READERR         (-2)
0883 
0884 /* Definitions available for use by readline clients. */
0885 #define RL_PROMPT_START_IGNORE  '\001'
0886 #define RL_PROMPT_END_IGNORE    '\002'
0887 
0888 /* Possible values for do_replace argument to rl_filename_quoting_function,
0889    called by rl_complete_internal. */
0890 #define NO_MATCH        0
0891 #define SINGLE_MATCH    1
0892 #define MULT_MATCH      2
0893 
0894 /* Possible state values for rl_readline_state */
0895 #define RL_STATE_NONE       0x000000        /* no state; before first call */
0896 
0897 #define RL_STATE_INITIALIZING   0x0000001   /* initializing */
0898 #define RL_STATE_INITIALIZED    0x0000002   /* initialization done */
0899 #define RL_STATE_TERMPREPPED    0x0000004   /* terminal is prepped */
0900 #define RL_STATE_READCMD    0x0000008   /* reading a command key */
0901 #define RL_STATE_METANEXT   0x0000010   /* reading input after ESC */
0902 #define RL_STATE_DISPATCHING    0x0000020   /* dispatching to a command */
0903 #define RL_STATE_MOREINPUT  0x0000040   /* reading more input in a command function */
0904 #define RL_STATE_ISEARCH    0x0000080   /* doing incremental search */
0905 #define RL_STATE_NSEARCH    0x0000100   /* doing non-inc search */
0906 #define RL_STATE_SEARCH     0x0000200   /* doing a history search */
0907 #define RL_STATE_NUMERICARG 0x0000400   /* reading numeric argument */
0908 #define RL_STATE_MACROINPUT 0x0000800   /* getting input from a macro */
0909 #define RL_STATE_MACRODEF   0x0001000   /* defining keyboard macro */
0910 #define RL_STATE_OVERWRITE  0x0002000   /* overwrite mode */
0911 #define RL_STATE_COMPLETING 0x0004000   /* doing completion */
0912 #define RL_STATE_SIGHANDLER 0x0008000   /* in readline sighandler */
0913 #define RL_STATE_UNDOING    0x0010000   /* doing an undo */
0914 #define RL_STATE_INPUTPENDING   0x0020000   /* rl_execute_next called */
0915 #define RL_STATE_TTYCSAVED  0x0040000   /* tty special chars saved */
0916 #define RL_STATE_CALLBACK   0x0080000   /* using the callback interface */
0917 #define RL_STATE_VIMOTION   0x0100000   /* reading vi motion arg */
0918 #define RL_STATE_MULTIKEY   0x0200000   /* reading multiple-key command */
0919 #define RL_STATE_VICMDONCE  0x0400000   /* entered vi command mode at least once */
0920 #define RL_STATE_CHARSEARCH 0x0800000   /* vi mode char search */
0921 #define RL_STATE_REDISPLAYING   0x1000000   /* updating terminal display */
0922 
0923 #define RL_STATE_DONE       0x2000000   /* done; accepted line */
0924 #define RL_STATE_TIMEOUT    0x4000000   /* done; timed out */
0925 #define RL_STATE_EOF        0x8000000   /* done; got eof on read */
0926 
0927 #define RL_SETSTATE(x)      (rl_readline_state |= (x))
0928 #define RL_UNSETSTATE(x)    (rl_readline_state &= ~(x))
0929 #define RL_ISSTATE(x)       (rl_readline_state & (x))
0930 
0931 struct readline_state {
0932   /* line state */
0933   int point;
0934   int end;
0935   int mark;
0936   int buflen;
0937   char *buffer;
0938   UNDO_LIST *ul;
0939   char *prompt;
0940 
0941   /* global state */
0942   int rlstate;
0943   int done;
0944   Keymap kmap;
0945 
0946   /* input state */
0947   rl_command_func_t *lastfunc;
0948   int insmode;
0949   int edmode;
0950   char *kseq;
0951   int kseqlen;
0952 
0953   int pendingin;
0954   FILE *inf;
0955   FILE *outf;
0956   char *macro;
0957 
0958   /* signal state */
0959   int catchsigs;
0960   int catchsigwinch;
0961 
0962   /* search state */
0963 
0964   /* completion state */
0965   rl_compentry_func_t *entryfunc;
0966   rl_compentry_func_t *menuentryfunc;
0967   rl_compignore_func_t *ignorefunc;
0968   rl_completion_func_t *attemptfunc;
0969   const char *wordbreakchars;
0970 
0971   /* options state */
0972 
0973   /* hook state */
0974   
0975   /* reserved for future expansion, so the struct size doesn't change */
0976   char reserved[64];
0977 };
0978 
0979 extern int rl_save_state (struct readline_state *);
0980 extern int rl_restore_state (struct readline_state *);
0981 
0982 #ifdef __cplusplus
0983 }
0984 #endif
0985 
0986 #endif /* _READLINE_H_ */