readline.h revision 124575
121308Sache/* Readline.h -- the names of functions callable from within readline. */
221308Sache
321308Sache/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
421308Sache
521308Sache   This file is part of the GNU Readline Library, a library for
621308Sache   reading lines of text with interactive input and history editing.
721308Sache
821308Sache   The GNU Readline Library is free software; you can redistribute it
921308Sache   and/or modify it under the terms of the GNU General Public License
1058314Sache   as published by the Free Software Foundation; either version 2, or
1121308Sache   (at your option) any later version.
1221308Sache
1321308Sache   The GNU Readline Library is distributed in the hope that it will be
1421308Sache   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
1521308Sache   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1621308Sache   GNU General Public License for more details.
1721308Sache
1821308Sache   The GNU General Public License is often shipped with GNU software, and
1921308Sache   is generally kept in a file called COPYING or LICENSE.  If you do not
2021308Sache   have a copy of the license, write to the Free Software Foundation,
2158314Sache   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
22123279Sobrien
23119614Sache/* $FreeBSD: head/contrib/libreadline/readline.h 124575 2004-01-15 19:37:45Z obrien $ */
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. */
44119614Sache#define RL_READLINE_VERSION	0x0403		/* Readline 4.3 */
45119614Sache#define RL_VERSION_MAJOR	4
46119614Sache#define RL_VERSION_MINOR	3
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));
164119614Sacheextern int rl_unix_line_discard PARAMS((int, int));
165119614Sacheextern int rl_copy_region_to_kill PARAMS((int, int));
166119614Sacheextern int rl_kill_region PARAMS((int, int));
167119614Sacheextern int rl_copy_forward_word PARAMS((int, int));
168119614Sacheextern int rl_copy_backward_word PARAMS((int, int));
169119614Sacheextern int rl_yank PARAMS((int, int));
170119614Sacheextern int rl_yank_pop PARAMS((int, int));
171119614Sacheextern int rl_yank_nth_arg PARAMS((int, int));
172119614Sacheextern int rl_yank_last_arg PARAMS((int, int));
17375409Sache/* Not available unless __CYGWIN__ is defined. */
17475409Sache#ifdef __CYGWIN__
175119614Sacheextern int rl_paste_from_clipboard PARAMS((int, int));
17635493Sache#endif
17735493Sache
17847563Sache/* Bindable commands for incremental searching. */
179119614Sacheextern int rl_reverse_search_history PARAMS((int, int));
180119614Sacheextern int rl_forward_search_history PARAMS((int, int));
18121308Sache
18247563Sache/* Bindable keyboard macro commands. */
183119614Sacheextern int rl_start_kbd_macro PARAMS((int, int));
184119614Sacheextern int rl_end_kbd_macro PARAMS((int, int));
185119614Sacheextern int rl_call_last_kbd_macro PARAMS((int, int));
18621308Sache
18747563Sache/* Bindable undo commands. */
188119614Sacheextern int rl_revert_line PARAMS((int, int));
189119614Sacheextern int rl_undo_command PARAMS((int, int));
19047563Sache
19147563Sache/* Bindable tilde expansion commands. */
192119614Sacheextern int rl_tilde_expand PARAMS((int, int));
19347563Sache
19447563Sache/* Bindable terminal control commands. */
195119614Sacheextern int rl_restart_output PARAMS((int, int));
196119614Sacheextern int rl_stop_output PARAMS((int, int));
19747563Sache
19847563Sache/* Miscellaneous bindable commands. */
199119614Sacheextern int rl_abort PARAMS((int, int));
200119614Sacheextern int rl_tty_status PARAMS((int, int));
20147563Sache
20247563Sache/* Bindable commands for incremental and non-incremental history searching. */
203119614Sacheextern int rl_history_search_forward PARAMS((int, int));
204119614Sacheextern int rl_history_search_backward PARAMS((int, int));
205119614Sacheextern int rl_noninc_forward_search PARAMS((int, int));
206119614Sacheextern int rl_noninc_reverse_search PARAMS((int, int));
207119614Sacheextern int rl_noninc_forward_search_again PARAMS((int, int));
208119614Sacheextern int rl_noninc_reverse_search_again PARAMS((int, int));
20947563Sache
21058314Sache/* Bindable command used when inserting a matching close character. */
211119614Sacheextern int rl_insert_close PARAMS((int, int));
21247563Sache
21347563Sache/* Not available unless READLINE_CALLBACKS is defined. */
214119614Sacheextern void rl_callback_handler_install PARAMS((const char *, rl_vcpfunc_t *));
215119614Sacheextern void rl_callback_read_char PARAMS((void));
216119614Sacheextern void rl_callback_handler_remove PARAMS((void));
21747563Sache
21821308Sache/* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */
21947563Sache/* VI-mode bindable commands. */
220119614Sacheextern int rl_vi_redo PARAMS((int, int));
221119614Sacheextern int rl_vi_undo PARAMS((int, int));
222119614Sacheextern int rl_vi_yank_arg PARAMS((int, int));
223119614Sacheextern int rl_vi_fetch_history PARAMS((int, int));
224119614Sacheextern int rl_vi_search_again PARAMS((int, int));
225119614Sacheextern int rl_vi_search PARAMS((int, int));
226119614Sacheextern int rl_vi_complete PARAMS((int, int));
227119614Sacheextern int rl_vi_tilde_expand PARAMS((int, int));
228119614Sacheextern int rl_vi_prev_word PARAMS((int, int));
229119614Sacheextern int rl_vi_next_word PARAMS((int, int));
230119614Sacheextern int rl_vi_end_word PARAMS((int, int));
231119614Sacheextern int rl_vi_insert_beg PARAMS((int, int));
232119614Sacheextern int rl_vi_append_mode PARAMS((int, int));
233119614Sacheextern int rl_vi_append_eol PARAMS((int, int));
234119614Sacheextern int rl_vi_eof_maybe PARAMS((int, int));
235119614Sacheextern int rl_vi_insertion_mode PARAMS((int, int));
236119614Sacheextern int rl_vi_movement_mode PARAMS((int, int));
237119614Sacheextern int rl_vi_arg_digit PARAMS((int, int));
238119614Sacheextern int rl_vi_change_case PARAMS((int, int));
239119614Sacheextern int rl_vi_put PARAMS((int, int));
240119614Sacheextern int rl_vi_column PARAMS((int, int));
241119614Sacheextern int rl_vi_delete_to PARAMS((int, int));
242119614Sacheextern int rl_vi_change_to PARAMS((int, int));
243119614Sacheextern int rl_vi_yank_to PARAMS((int, int));
244119614Sacheextern int rl_vi_delete PARAMS((int, int));
245119614Sacheextern int rl_vi_back_to_indent PARAMS((int, int));
246119614Sacheextern int rl_vi_first_print PARAMS((int, int));
247119614Sacheextern int rl_vi_char_search PARAMS((int, int));
248119614Sacheextern int rl_vi_match PARAMS((int, int));
249119614Sacheextern int rl_vi_change_char PARAMS((int, int));
250119614Sacheextern int rl_vi_subst PARAMS((int, int));
251119614Sacheextern int rl_vi_overstrike PARAMS((int, int));
252119614Sacheextern int rl_vi_overstrike_delete PARAMS((int, int));
253119614Sacheextern int rl_vi_replace PARAMS((int, int));
254119614Sacheextern int rl_vi_set_mark PARAMS((int, int));
255119614Sacheextern int rl_vi_goto_mark PARAMS((int, int));
25621308Sache
25747563Sache/* VI-mode utility functions. */
258119614Sacheextern int rl_vi_check PARAMS((void));
259119614Sacheextern int rl_vi_domove PARAMS((int, int *));
260119614Sacheextern int rl_vi_bracktype PARAMS((int));
26121308Sache
26247563Sache/* VI-mode pseudo-bindable commands, used as utility functions. */
263119614Sacheextern int rl_vi_fWord PARAMS((int, int));
264119614Sacheextern int rl_vi_bWord PARAMS((int, int));
265119614Sacheextern int rl_vi_eWord PARAMS((int, int));
266119614Sacheextern int rl_vi_fword PARAMS((int, int));
267119614Sacheextern int rl_vi_bword PARAMS((int, int));
268119614Sacheextern int rl_vi_eword PARAMS((int, int));
26921308Sache
27021308Sache/* **************************************************************** */
27121308Sache/*								    */
27221308Sache/*			Well Published Functions		    */
27321308Sache/*								    */
27421308Sache/* **************************************************************** */
27521308Sache
27621308Sache/* Readline functions. */
27721308Sache/* Read a line of input.  Prompt with PROMPT.  A NULL PROMPT means none. */
278119614Sacheextern char *readline PARAMS((const char *));
27921308Sache
280119614Sacheextern int rl_set_prompt PARAMS((const char *));
281119614Sacheextern int rl_expand_prompt PARAMS((char *));
28275409Sache
283119614Sacheextern int rl_initialize PARAMS((void));
28421308Sache
28575409Sache/* Undocumented; unused by readline */
286119614Sacheextern int rl_discard_argument PARAMS((void));
28721308Sache
28847563Sache/* Utility functions to bind keys to readline commands. */
289119614Sacheextern int rl_add_defun PARAMS((const char *, rl_command_func_t *, int));
290119614Sacheextern int rl_bind_key PARAMS((int, rl_command_func_t *));
291119614Sacheextern int rl_bind_key_in_map PARAMS((int, rl_command_func_t *, Keymap));
292119614Sacheextern int rl_unbind_key PARAMS((int));
293119614Sacheextern int rl_unbind_key_in_map PARAMS((int, Keymap));
294119614Sacheextern int rl_unbind_function_in_map PARAMS((rl_command_func_t *, Keymap));
295119614Sacheextern int rl_unbind_command_in_map PARAMS((const char *, Keymap));
296119614Sacheextern int rl_set_key PARAMS((const char *, rl_command_func_t *, Keymap));
297119614Sacheextern int rl_generic_bind PARAMS((int, const char *, char *, Keymap));
298119614Sacheextern int rl_variable_bind PARAMS((const char *, const char *));
29947563Sache
30021308Sache/* Backwards compatibility, use rl_generic_bind instead. */
301119614Sacheextern int rl_macro_bind PARAMS((const char *, const char *, Keymap));
30221308Sache
30347563Sache/* Undocumented in the texinfo manual; not really useful to programs. */
304119614Sacheextern int rl_translate_keyseq PARAMS((const char *, char *, int *));
305119614Sacheextern char *rl_untranslate_keyseq PARAMS((int));
30621308Sache
307119614Sacheextern rl_command_func_t *rl_named_function PARAMS((const char *));
308119614Sacheextern rl_command_func_t *rl_function_of_keyseq PARAMS((const char *, Keymap, int *));
30921308Sache
310119614Sacheextern void rl_list_funmap_names PARAMS((void));
311119614Sacheextern char **rl_invoking_keyseqs_in_map PARAMS((rl_command_func_t *, Keymap));
312119614Sacheextern char **rl_invoking_keyseqs PARAMS((rl_command_func_t *));
31347563Sache
314119614Sacheextern void rl_function_dumper PARAMS((int));
315119614Sacheextern void rl_macro_dumper PARAMS((int));
316119614Sacheextern void rl_variable_dumper PARAMS((int));
31721308Sache
318119614Sacheextern int rl_read_init_file PARAMS((const char *));
319119614Sacheextern int rl_parse_and_bind PARAMS((char *));
32021308Sache
32147563Sache/* Functions for manipulating keymaps. */
322119614Sacheextern Keymap rl_make_bare_keymap PARAMS((void));
323119614Sacheextern Keymap rl_copy_keymap PARAMS((Keymap));
324119614Sacheextern Keymap rl_make_keymap PARAMS((void));
325119614Sacheextern void rl_discard_keymap PARAMS((Keymap));
326119614Sache
327119614Sacheextern Keymap rl_get_keymap_by_name PARAMS((const char *));
328119614Sacheextern char *rl_get_keymap_name PARAMS((Keymap));
329119614Sacheextern void rl_set_keymap PARAMS((Keymap));
330119614Sacheextern Keymap rl_get_keymap PARAMS((void));
33175409Sache/* Undocumented; used internally only. */
332119614Sacheextern void rl_set_keymap_from_edit_mode PARAMS((void));
333119614Sacheextern char *rl_get_keymap_name_from_edit_mode PARAMS((void));
33447563Sache
33547563Sache/* Functions for manipulating the funmap, which maps command names to functions. */
336119614Sacheextern int rl_add_funmap_entry PARAMS((const char *, rl_command_func_t *));
337119614Sacheextern const char **rl_funmap_names PARAMS((void));
33875409Sache/* Undocumented, only used internally -- there is only one funmap, and this
33975409Sache   function may be called only once. */
340119614Sacheextern void rl_initialize_funmap PARAMS((void));
34147563Sache
34247563Sache/* Utility functions for managing keyboard macros. */
343119614Sacheextern void rl_push_macro_input PARAMS((char *));
34447563Sache
34547563Sache/* Functions for undoing, from undo.c */
346119614Sacheextern void rl_add_undo PARAMS((enum undo_code, int, int, char *));
347119614Sacheextern void rl_free_undo_list PARAMS((void));
348119614Sacheextern int rl_do_undo PARAMS((void));
349119614Sacheextern int rl_begin_undo_group PARAMS((void));
350119614Sacheextern int rl_end_undo_group PARAMS((void));
351119614Sacheextern int rl_modifying PARAMS((int, int));
35247563Sache
35321308Sache/* Functions for redisplay. */
354119614Sacheextern void rl_redisplay PARAMS((void));
355119614Sacheextern int rl_on_new_line PARAMS((void));
356119614Sacheextern int rl_on_new_line_with_prompt PARAMS((void));
357119614Sacheextern int rl_forced_update_display PARAMS((void));
358119614Sacheextern int rl_clear_message PARAMS((void));
359119614Sacheextern int rl_reset_line_state PARAMS((void));
360119614Sacheextern int rl_crlf PARAMS((void));
36121308Sache
36258314Sache#if (defined (__STDC__) || defined (__cplusplus)) && defined (USE_VARARGS) && defined (PREFER_STDARG)
363119614Sacheextern int rl_message (const char *, ...)  __attribute__((__format__ (printf, 1, 2)));
36421308Sache#else
36521308Sacheextern int rl_message ();
36621308Sache#endif
36721308Sache
368119614Sacheextern int rl_show_char PARAMS((int));
36975409Sache
37021308Sache/* Undocumented in texinfo manual. */
371119614Sacheextern int rl_character_len PARAMS((int, int));
37221308Sache
37347563Sache/* Save and restore internal prompt redisplay information. */
374119614Sacheextern void rl_save_prompt PARAMS((void));
375119614Sacheextern void rl_restore_prompt PARAMS((void));
37647563Sache
37721308Sache/* Modifying text. */
378119614Sacheextern void rl_replace_line PARAMS((const char *, int));
379119614Sacheextern int rl_insert_text PARAMS((const char *));
380119614Sacheextern int rl_delete_text PARAMS((int, int));
381119614Sacheextern int rl_kill_text PARAMS((int, int));
382119614Sacheextern char *rl_copy_text PARAMS((int, int));
38321308Sache
38447563Sache/* Terminal and tty mode management. */
385119614Sacheextern void rl_prep_terminal PARAMS((int));
386119614Sacheextern void rl_deprep_terminal PARAMS((void));
387119614Sacheextern void rl_tty_set_default_bindings PARAMS((Keymap));
38821308Sache
389119614Sacheextern int rl_reset_terminal PARAMS((const char *));
390119614Sacheextern void rl_resize_terminal PARAMS((void));
391119614Sacheextern void rl_set_screen_size PARAMS((int, int));
392119614Sacheextern void rl_get_screen_size PARAMS((int *, int *));
39321308Sache
394119614Sacheextern char *rl_get_termcap PARAMS((const char *));
395119614Sache
39647563Sache/* Functions for character input. */
397119614Sacheextern int rl_stuff_char PARAMS((int));
398119614Sacheextern int rl_execute_next PARAMS((int));
399119614Sacheextern int rl_clear_pending_input PARAMS((void));
400119614Sacheextern int rl_read_key PARAMS((void));
401119614Sacheextern int rl_getc PARAMS((FILE *));
402119614Sacheextern int rl_set_keyboard_input_timeout PARAMS((int));
40347563Sache
40475409Sache/* `Public' utility functions . */
405119614Sacheextern void rl_extend_line_buffer PARAMS((int));
406119614Sacheextern int rl_ding PARAMS((void));
407119614Sacheextern int rl_alphabetic PARAMS((int));
40875409Sache
40947563Sache/* Readline signal handling, from signals.c */
410119614Sacheextern int rl_set_signals PARAMS((void));
411119614Sacheextern int rl_clear_signals PARAMS((void));
412119614Sacheextern void rl_cleanup_after_signal PARAMS((void));
413119614Sacheextern void rl_reset_after_signal PARAMS((void));
414119614Sacheextern void rl_free_line_state PARAMS((void));
41547563Sache
416119614Sacheextern int rl_set_paren_blink_timeout PARAMS((int));
41721308Sache
41875409Sache/* Undocumented. */
419119614Sacheextern int rl_maybe_save_line PARAMS((void));
420119614Sacheextern int rl_maybe_unsave_line PARAMS((void));
421119614Sacheextern int rl_maybe_replace_line PARAMS((void));
42247563Sache
42321308Sache/* Completion functions. */
424119614Sacheextern int rl_complete_internal PARAMS((int));
425119614Sacheextern void rl_display_match_list PARAMS((char **, int, int));
42621308Sache
427119614Sacheextern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *));
428119614Sacheextern char *rl_username_completion_function PARAMS((const char *, int));
429119614Sacheextern char *rl_filename_completion_function PARAMS((const char *, int));
43021308Sache
431119614Sacheextern int rl_completion_mode PARAMS((rl_command_func_t *));
432119614Sache
433124575Sobrien#if !defined(RL_NO_COMPAT)
43475409Sache/* Backwards compatibility (compat.c).  These will go away sometime. */
435119614Sacheextern void free_undo_list PARAMS((void));
436119614Sacheextern int maybe_save_line PARAMS((void));
437119614Sacheextern int maybe_unsave_line PARAMS((void));
438119614Sacheextern int maybe_replace_line PARAMS((void));
43975409Sache
440119614Sacheextern int ding PARAMS((void));
441119614Sacheextern int alphabetic PARAMS((int));
442119614Sacheextern int crlf PARAMS((void));
44375409Sache
444119614Sacheextern char **completion_matches PARAMS((char *, rl_compentry_func_t *));
445119614Sacheextern char *username_completion_function PARAMS((const char *, int));
446119614Sacheextern char *filename_completion_function PARAMS((const char *, int));
447119614Sache#endif
44875409Sache
44921308Sache/* **************************************************************** */
45021308Sache/*								    */
45121308Sache/*			Well Published Variables		    */
45221308Sache/*								    */
45321308Sache/* **************************************************************** */
45421308Sache
45521308Sache/* The version of this incarnation of the readline library. */
456119614Sacheextern const char *rl_library_version;		/* e.g., "4.2" */
457119614Sacheextern int rl_readline_version;			/* e.g., 0x0402 */
45821308Sache
45958314Sache/* True if this is real GNU readline. */
46058314Sacheextern int rl_gnu_readline_p;
46158314Sache
46275409Sache/* Flags word encapsulating the current readline state. */
46375409Sacheextern int rl_readline_state;
46475409Sache
46575409Sache/* Says which editing mode readline is currently using.  1 means emacs mode;
46675409Sache   0 means vi mode. */
46775409Sacheextern int rl_editing_mode;
46875409Sache
469119614Sache/* Insert or overwrite mode for emacs mode.  1 means insert mode; 0 means
470119614Sache   overwrite mode.  Reset to insert mode on each input line. */
471119614Sacheextern int rl_insert_mode;
472119614Sache
47321308Sache/* The name of the calling program.  You should initialize this to
47421308Sache   whatever was in argv[0].  It is used when parsing conditionals. */
47575409Sacheextern const char *rl_readline_name;
47621308Sache
47726500Sache/* The prompt readline uses.  This is set from the argument to
47826500Sache   readline (), and should not be assigned to directly. */
47926500Sacheextern char *rl_prompt;
48026500Sache
48121308Sache/* The line buffer that is in use. */
48221308Sacheextern char *rl_line_buffer;
48321308Sache
48421308Sache/* The location of point, and end. */
48575409Sacheextern int rl_point;
48675409Sacheextern int rl_end;
48721308Sache
48847563Sache/* The mark, or saved cursor position. */
48921308Sacheextern int rl_mark;
49021308Sache
49147563Sache/* Flag to indicate that readline has finished with the current input
49247563Sache   line and should return it. */
49321308Sacheextern int rl_done;
49421308Sache
49547563Sache/* If set to a character value, that will be the next keystroke read. */
49621308Sacheextern int rl_pending_input;
49721308Sache
49826500Sache/* Non-zero if we called this function from _rl_dispatch().  It's present
49926500Sache   so functions can find out whether they were called from a key binding
50026500Sache   or directly from an application. */
50130974Sacheextern int rl_dispatching;
50226500Sache
50375409Sache/* Non-zero if the user typed a numeric argument before executing the
50475409Sache   current function. */
50575409Sacheextern int rl_explicit_arg;
50675409Sache
50775409Sache/* The current value of the numeric argument specified by the user. */
50875409Sacheextern int rl_numeric_arg;
50975409Sache
51075409Sache/* The address of the last command function Readline executed. */
51175409Sacheextern rl_command_func_t *rl_last_func;
51275409Sache
51321308Sache/* The name of the terminal to use. */
51475409Sacheextern const char *rl_terminal_name;
51521308Sache
51621308Sache/* The input and output streams. */
51775409Sacheextern FILE *rl_instream;
51875409Sacheextern FILE *rl_outstream;
51921308Sache
52021308Sache/* If non-zero, then this is the address of a function to call just
52121308Sache   before readline_internal () prints the first prompt. */
52275409Sacheextern rl_hook_func_t *rl_startup_hook;
52321308Sache
52447563Sache/* If non-zero, this is the address of a function to call just before
52547563Sache   readline_internal_setup () returns and readline_internal starts
52647563Sache   reading input characters. */
52775409Sacheextern rl_hook_func_t *rl_pre_input_hook;
52847563Sache
52921308Sache/* The address of a function to call periodically while Readline is
53021308Sache   awaiting character input, or NULL, for no event handling. */
53175409Sacheextern rl_hook_func_t *rl_event_hook;
53221308Sache
53375409Sache/* The address of the function to call to fetch a character from the current
53475409Sache   Readline input stream */
53575409Sacheextern rl_getc_func_t *rl_getc_function;
53621308Sache
53775409Sacheextern rl_voidfunc_t *rl_redisplay_function;
53875409Sache
53975409Sacheextern rl_vintfunc_t *rl_prep_term_function;
54075409Sacheextern rl_voidfunc_t *rl_deprep_term_function;
54175409Sache
54221308Sache/* Dispatch variables. */
54321308Sacheextern Keymap rl_executing_keymap;
54421308Sacheextern Keymap rl_binding_keymap;
54521308Sache
54647563Sache/* Display variables. */
54747563Sache/* If non-zero, readline will erase the entire line, including any prompt,
54847563Sache   if the only thing typed on an otherwise-blank line is something bound to
54947563Sache   rl_newline. */
55047563Sacheextern int rl_erase_empty_line;
55147563Sache
55258314Sache/* If non-zero, the application has already printed the prompt (rl_prompt)
55358314Sache   before calling readline, so readline should not output it the first time
55458314Sache   redisplay is done. */
55558314Sacheextern int rl_already_prompted;
55658314Sache
55758314Sache/* A non-zero value means to read only this many characters rather than
55858314Sache   up to a character bound to accept-line. */
55958314Sacheextern int rl_num_chars_to_read;
56058314Sache
56175409Sache/* The text of a currently-executing keyboard macro. */
56275409Sacheextern char *rl_executing_macro;
56375409Sache
56447563Sache/* Variables to control readline signal handling. */
56547563Sache/* If non-zero, readline will install its own signal handlers for
56647563Sache   SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
56747563Sacheextern int rl_catch_signals;
56847563Sache
56947563Sache/* If non-zero, readline will install a signal handler for SIGWINCH
57047563Sache   that also attempts to call any calling application's SIGWINCH signal
57147563Sache   handler.  Note that the terminal is not cleaned up before the
57247563Sache   application's signal handler is called; use rl_cleanup_after_signal()
57347563Sache   to do that. */
57447563Sacheextern int rl_catch_sigwinch;
57547563Sache
57621308Sache/* Completion variables. */
57721308Sache/* Pointer to the generator function for completion_matches ().
578119614Sache   NULL means to use rl_filename_completion_function (), the default
579119614Sache   filename completer. */
58075409Sacheextern rl_compentry_func_t *rl_completion_entry_function;
58121308Sache
58221308Sache/* If rl_ignore_some_completions_function is non-NULL it is the address
58321308Sache   of a function to call after all of the possible matches have been
58421308Sache   generated, but before the actual completion is done to the input line.
58521308Sache   The function is called with one argument; a NULL terminated array
58621308Sache   of (char *).  If your function removes any of the elements, they
58721308Sache   must be free()'ed. */
58875409Sacheextern rl_compignore_func_t *rl_ignore_some_completions_function;
58921308Sache
59021308Sache/* Pointer to alternative function to create matches.
59121308Sache   Function is called with TEXT, START, and END.
59221308Sache   START and END are indices in RL_LINE_BUFFER saying what the boundaries
59321308Sache   of TEXT are.
59421308Sache   If this function exists and returns NULL then call the value of
59521308Sache   rl_completion_entry_function to try to match, otherwise use the
59621308Sache   array of strings returned. */
59775409Sacheextern rl_completion_func_t *rl_attempted_completion_function;
59821308Sache
59921308Sache/* The basic list of characters that signal a break between words for the
60021308Sache   completer routine.  The initial contents of this variable is what
60121308Sache   breaks words in the shell, i.e. "n\"\\'`@$>". */
60275409Sacheextern const char *rl_basic_word_break_characters;
60321308Sache
60421308Sache/* The list of characters that signal a break between words for
60521308Sache   rl_complete_internal.  The default list is the contents of
60621308Sache   rl_basic_word_break_characters.  */
60775409Sacheextern const char *rl_completer_word_break_characters;
60821308Sache
60921308Sache/* List of characters which can be used to quote a substring of the line.
61021308Sache   Completion occurs on the entire substring, and within the substring
61121308Sache   rl_completer_word_break_characters are treated as any other character,
61221308Sache   unless they also appear within this list. */
61375409Sacheextern const char *rl_completer_quote_characters;
61421308Sache
61521308Sache/* List of quote characters which cause a word break. */
61675409Sacheextern const char *rl_basic_quote_characters;
61721308Sache
61821308Sache/* List of characters that need to be quoted in filenames by the completer. */
61975409Sacheextern const char *rl_filename_quote_characters;
62021308Sache
62121308Sache/* List of characters that are word break characters, but should be left
62221308Sache   in TEXT when it is passed to the completion function.  The shell uses
62321308Sache   this to help determine what kind of completing to do. */
62475409Sacheextern const char *rl_special_prefixes;
62521308Sache
62621308Sache/* If non-zero, then this is the address of a function to call when
62721308Sache   completing on a directory name.  The function is called with
62875409Sache   the address of a string (the current directory name) as an arg.  It
62975409Sache   changes what is displayed when the possible completions are printed
63075409Sache   or inserted. */
63175409Sacheextern rl_icppfunc_t *rl_directory_completion_hook;
63221308Sache
63375409Sache/* If non-zero, this is the address of a function to call when completing
63475409Sache   a directory name.  This function takes the address of the directory name
63575409Sache   to be modified as an argument.  Unlike rl_directory_completion_hook, it
63675409Sache   only modifies the directory name used in opendir(2), not what is displayed
63775409Sache   when the possible completions are printed or inserted.  It is called
63875409Sache   before rl_directory_completion_hook.  I'm not happy with how this works
63975409Sache   yet, so it's undocumented. */
64075409Sacheextern rl_icppfunc_t *rl_directory_rewrite_hook;
64175409Sache
64221308Sache/* Backwards compatibility with previous versions of readline. */
64321308Sache#define rl_symbolic_link_hook rl_directory_completion_hook
64421308Sache
64547563Sache/* If non-zero, then this is the address of a function to call when
64647563Sache   completing a word would normally display the list of possible matches.
64747563Sache   This function is called instead of actually doing the display.
64847563Sache   It takes three arguments: (char **matches, int num_matches, int max_length)
64947563Sache   where MATCHES is the array of strings that matched, NUM_MATCHES is the
65047563Sache   number of strings in that array, and MAX_LENGTH is the length of the
65147563Sache   longest string in that array. */
65275409Sacheextern rl_compdisp_func_t *rl_completion_display_matches_hook;
65347563Sache
65421308Sache/* Non-zero means that the results of the matches are to be treated
65521308Sache   as filenames.  This is ALWAYS zero on entry, and can only be changed
65621308Sache   within a completion entry finder function. */
65721308Sacheextern int rl_filename_completion_desired;
65821308Sache
65921308Sache/* Non-zero means that the results of the matches are to be quoted using
66021308Sache   double quotes (or an application-specific quoting mechanism) if the
66121308Sache   filename contains any characters in rl_word_break_chars.  This is
66221308Sache   ALWAYS non-zero on entry, and can only be changed within a completion
66321308Sache   entry finder function. */
66421308Sacheextern int rl_filename_quoting_desired;
66521308Sache
66621308Sache/* Set to a function to quote a filename in an application-specific fashion.
66721308Sache   Called with the text to quote, the type of match found (single or multiple)
66821308Sache   and a pointer to the quoting character to be used, which the function can
66921308Sache   reset if desired. */
67075409Sacheextern rl_quote_func_t *rl_filename_quoting_function;
67121308Sache
67221308Sache/* Function to call to remove quoting characters from a filename.  Called
67321308Sache   before completion is attempted, so the embedded quotes do not interfere
67421308Sache   with matching names in the file system. */
67575409Sacheextern rl_dequote_func_t *rl_filename_dequoting_function;
67621308Sache
67721308Sache/* Function to call to decide whether or not a word break character is
67821308Sache   quoted.  If a character is quoted, it does not break words for the
67921308Sache   completer. */
68075409Sacheextern rl_linebuf_func_t *rl_char_is_quoted_p;
68121308Sache
68221308Sache/* Non-zero means to suppress normal filename completion after the
68321308Sache   user-specified completion function has been called. */
68421308Sacheextern int rl_attempted_completion_over;
68521308Sache
68621308Sache/* Set to a character describing the type of completion being attempted by
68721308Sache   rl_complete_internal; available for use by application completion
68821308Sache   functions. */
68921308Sacheextern int rl_completion_type;
69021308Sache
69121308Sache/* Character appended to completed words when at the end of the line.  The
69221308Sache   default is a space.  Nothing is added if this is '\0'. */
69321308Sacheextern int rl_completion_append_character;
69421308Sache
695119614Sache/* If set to non-zero by an application completion function,
696119614Sache   rl_completion_append_character will not be appended. */
697119614Sacheextern int rl_completion_suppress_append;
698119614Sache
69926500Sache/* Up to this many items will be displayed in response to a
70026500Sache   possible-completions call.  After that, we ask the user if she
70126500Sache   is sure she wants to see them all.  The default value is 100. */
70226500Sacheextern int rl_completion_query_items;
70326500Sache
704119614Sache/* If non-zero, a slash will be appended to completed filenames that are
705119614Sache   symbolic links to directory names, subject to the value of the
706119614Sache   mark-directories variable (which is user-settable).  This exists so
707119614Sache   that application completion functions can override the user's preference
708119614Sache   (set via the mark-symlinked-directories variable) if appropriate.
709119614Sache   It's set to the value of _rl_complete_mark_symlink_dirs in
710119614Sache   rl_complete_internal before any application-specific completion
711119614Sache   function is called, so without that function doing anything, the user's
712119614Sache   preferences are honored. */
713119614Sacheextern int rl_completion_mark_symlink_dirs;
714119614Sache
71526500Sache/* If non-zero, then disallow duplicates in the matches. */
71626500Sacheextern int rl_ignore_completion_duplicates;
71726500Sache
71821308Sache/* If this is non-zero, completion is (temporarily) inhibited, and the
71921308Sache   completion character will be inserted as any other. */
72021308Sacheextern int rl_inhibit_completion;
721119614Sache
72221308Sache/* Definitions available for use by readline clients. */
72321308Sache#define RL_PROMPT_START_IGNORE	'\001'
72421308Sache#define RL_PROMPT_END_IGNORE	'\002'
72521308Sache
72621308Sache/* Possible values for do_replace argument to rl_filename_quoting_function,
72721308Sache   called by rl_complete_internal. */
72821308Sache#define NO_MATCH        0
72921308Sache#define SINGLE_MATCH    1
73021308Sache#define MULT_MATCH      2
73121308Sache
73275409Sache/* Possible state values for rl_readline_state */
73375409Sache#define RL_STATE_NONE		0x00000		/* no state; before first call */
73475409Sache
73575409Sache#define RL_STATE_INITIALIZING	0x00001		/* initializing */
73675409Sache#define RL_STATE_INITIALIZED	0x00002		/* initialization done */
73775409Sache#define RL_STATE_TERMPREPPED	0x00004		/* terminal is prepped */
73875409Sache#define RL_STATE_READCMD	0x00008		/* reading a command key */
73975409Sache#define RL_STATE_METANEXT	0x00010		/* reading input after ESC */
74075409Sache#define RL_STATE_DISPATCHING	0x00020		/* dispatching to a command */
74175409Sache#define RL_STATE_MOREINPUT	0x00040		/* reading more input in a command function */
74275409Sache#define RL_STATE_ISEARCH	0x00080		/* doing incremental search */
74375409Sache#define RL_STATE_NSEARCH	0x00100		/* doing non-inc search */
74475409Sache#define RL_STATE_SEARCH		0x00200		/* doing a history search */
74575409Sache#define RL_STATE_NUMERICARG	0x00400		/* reading numeric argument */
74675409Sache#define RL_STATE_MACROINPUT	0x00800		/* getting input from a macro */
74775409Sache#define RL_STATE_MACRODEF	0x01000		/* defining keyboard macro */
74875409Sache#define RL_STATE_OVERWRITE	0x02000		/* overwrite mode */
74975409Sache#define RL_STATE_COMPLETING	0x04000		/* doing completion */
75075409Sache#define RL_STATE_SIGHANDLER	0x08000		/* in readline sighandler */
75175409Sache#define RL_STATE_UNDOING	0x10000		/* doing an undo */
75275409Sache#define RL_STATE_INPUTPENDING	0x20000		/* rl_execute_next called */
75375409Sache
75475409Sache#define RL_STATE_DONE		0x80000		/* done; accepted line */
75575409Sache
75675409Sache#define RL_SETSTATE(x)		(rl_readline_state |= (x))
75775409Sache#define RL_UNSETSTATE(x)	(rl_readline_state &= ~(x))
75875409Sache#define RL_ISSTATE(x)		(rl_readline_state & (x))
75975409Sache
760119614Sachestruct readline_state {
761119614Sache  /* line state */
762119614Sache  int point;
763119614Sache  int end;
764119614Sache  int mark;
765119614Sache  char *buffer;
766119614Sache  int buflen;
767119614Sache  UNDO_LIST *ul;
768119614Sache  char *prompt;
769119614Sache
770119614Sache  /* global state */
771119614Sache  int rlstate;
772119614Sache  int done;
773119614Sache  Keymap kmap;
774119614Sache
775119614Sache  /* input state */
776119614Sache  rl_command_func_t *lastfunc;
777119614Sache  int insmode;
778119614Sache  int edmode;
779119614Sache  int kseqlen;
780119614Sache  FILE *inf;
781119614Sache  FILE *outf;
782119614Sache  int pendingin;
783119614Sache  char *macro;
784119614Sache
785119614Sache  /* signal state */
786119614Sache  int catchsigs;
787119614Sache  int catchsigwinch;
788119614Sache
789119614Sache  /* reserved for future expansion, so the struct size doesn't change */
790119614Sache  char reserved[64];
791119614Sache};
792119614Sache
793119614Sacheextern int rl_save_state PARAMS((struct readline_state *));
794119614Sacheextern int rl_restore_state PARAMS((struct readline_state *));
795119614Sache
796124575Sobrien#if !defined(RL_NO_COMPAT)
79721308Sache#if !defined (savestring)
79821334Sache#define savestring rl_savestring
79975409Sacheextern char *savestring __P((char *));  /* XXX backwards compatibility */
80021308Sache#endif
801124575Sobrien#endif
80221308Sache
80347563Sache#ifdef __cplusplus
80447563Sache}
80547563Sache#endif
80647563Sache
80721308Sache#endif /* _READLINE_H_ */
808