Imported from ../bash-3.1.tar.gz.
[platform/upstream/bash.git] / lib / readline / readline.h
index d608c7a..fade6d4 100644 (file)
@@ -1,6 +1,6 @@
 /* Readline.h -- the names of functions callable from within readline. */
 
-/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library, a library for
    reading lines of text with interactive input and history editing.
@@ -29,18 +29,20 @@ extern "C" {
 
 #if defined (READLINE_LIBRARY)
 #  include "rlstdc.h"
+#  include "rltypedefs.h"
 #  include "keymaps.h"
 #  include "tilde.h"
 #else
 #  include <readline/rlstdc.h>
+#  include <readline/rltypedefs.h>
 #  include <readline/keymaps.h>
 #  include <readline/tilde.h>
 #endif
 
 /* Hex-encoded Readline version number. */
-#define RL_READLINE_VERSION    0x0402          /* Readline 4.2 */
-#define RL_VERSION_MAJOR       4
-#define RL_VERSION_MINOR       2
+#define RL_READLINE_VERSION    0x0501          /* Readline 5.1 */
+#define RL_VERSION_MAJOR       5
+#define RL_VERSION_MINOR       1
 
 /* Readline data structures. */
 
@@ -82,7 +84,11 @@ extern int rl_digit_argument PARAMS((int, int));
 extern int rl_universal_argument PARAMS((int, int));
 
 /* Bindable commands for moving the cursor. */
+extern int rl_forward_byte PARAMS((int, int));
+extern int rl_forward_char PARAMS((int, int));
 extern int rl_forward PARAMS((int, int));
+extern int rl_backward_byte PARAMS((int, int));
+extern int rl_backward_char PARAMS((int, int));
 extern int rl_backward PARAMS((int, int));
 extern int rl_beg_of_line PARAMS((int, int));
 extern int rl_end_of_line PARAMS((int, int));
@@ -132,6 +138,9 @@ extern int rl_exchange_point_and_mark PARAMS((int, int));
 extern int rl_vi_editing_mode PARAMS((int, int));
 extern int rl_emacs_editing_mode PARAMS((int, int));
 
+/* Bindable commands to change the insert mode (insert or overwrite) */
+extern int rl_overwrite_mode PARAMS((int, int));
+
 /* Bindable commands for managing key bindings. */
 extern int rl_re_read_init_file PARAMS((int, int));
 extern int rl_dump_functions PARAMS((int, int));
@@ -151,6 +160,7 @@ extern int rl_kill_line PARAMS((int, int));
 extern int rl_backward_kill_line PARAMS((int, int));
 extern int rl_kill_full_line PARAMS((int, int));
 extern int rl_unix_word_rubout PARAMS((int, int));
+extern int rl_unix_filename_rubout PARAMS((int, int));
 extern int rl_unix_line_discard PARAMS((int, int));
 extern int rl_copy_region_to_kill PARAMS((int, int));
 extern int rl_kill_region PARAMS((int, int));
@@ -231,6 +241,7 @@ extern int rl_vi_column PARAMS((int, int));
 extern int rl_vi_delete_to PARAMS((int, int));
 extern int rl_vi_change_to PARAMS((int, int));
 extern int rl_vi_yank_to PARAMS((int, int));
+extern int rl_vi_rubout PARAMS((int, int));
 extern int rl_vi_delete PARAMS((int, int));
 extern int rl_vi_back_to_indent PARAMS((int, int));
 extern int rl_vi_first_print PARAMS((int, int));
@@ -249,6 +260,8 @@ extern int rl_vi_check PARAMS((void));
 extern int rl_vi_domove PARAMS((int, int *));
 extern int rl_vi_bracktype PARAMS((int));
 
+extern void rl_vi_start_inserting PARAMS((int, int, int));
+
 /* VI-mode pseudo-bindable commands, used as utility functions. */
 extern int rl_vi_fWord PARAMS((int, int));
 extern int rl_vi_bWord PARAMS((int, int));
@@ -281,12 +294,22 @@ extern int rl_bind_key PARAMS((int, rl_command_func_t *));
 extern int rl_bind_key_in_map PARAMS((int, rl_command_func_t *, Keymap));
 extern int rl_unbind_key PARAMS((int));
 extern int rl_unbind_key_in_map PARAMS((int, Keymap));
+extern int rl_bind_key_if_unbound PARAMS((int, rl_command_func_t *));
+extern int rl_bind_key_if_unbound_in_map PARAMS((int, rl_command_func_t *, Keymap));
 extern int rl_unbind_function_in_map PARAMS((rl_command_func_t *, Keymap));
 extern int rl_unbind_command_in_map PARAMS((const char *, Keymap));
-extern int rl_set_key PARAMS((const char *, rl_command_func_t *, Keymap));
+extern int rl_bind_keyseq PARAMS((const char *, rl_command_func_t *));
+extern int rl_bind_keyseq_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
+extern int rl_bind_keyseq_if_unbound PARAMS((const char *, rl_command_func_t *));
+extern int rl_bind_keyseq_if_unbound_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
 extern int rl_generic_bind PARAMS((int, const char *, char *, Keymap));
+
+extern char *rl_variable_value PARAMS((const char *));
 extern int rl_variable_bind PARAMS((const char *, const char *));
 
+/* Backwards compatibility, use rl_bind_keyseq_in_map instead. */
+extern int rl_set_key PARAMS((const char *, rl_command_func_t *, Keymap));
+
 /* Backwards compatibility, use rl_generic_bind instead. */
 extern int rl_macro_bind PARAMS((const char *, const char *, Keymap));
 
@@ -349,7 +372,7 @@ extern int rl_clear_message PARAMS((void));
 extern int rl_reset_line_state PARAMS((void));
 extern int rl_crlf PARAMS((void));
 
-#if (defined (__STDC__) || defined (__cplusplus)) && defined (USE_VARARGS) && defined (PREFER_STDARG)
+#if defined (USE_VARARGS) && defined (PREFER_STDARG)
 extern int rl_message (const char *, ...)  __attribute__((__format__ (printf, 1, 2)));
 #else
 extern int rl_message ();
@@ -365,6 +388,7 @@ extern void rl_save_prompt PARAMS((void));
 extern void rl_restore_prompt PARAMS((void));
 
 /* Modifying text. */
+extern void rl_replace_line PARAMS((const char *, int));
 extern int rl_insert_text PARAMS((const char *));
 extern int rl_delete_text PARAMS((int, int));
 extern int rl_kill_text PARAMS((int, int));
@@ -374,11 +398,13 @@ extern char *rl_copy_text PARAMS((int, int));
 extern void rl_prep_terminal PARAMS((int));
 extern void rl_deprep_terminal PARAMS((void));
 extern void rl_tty_set_default_bindings PARAMS((Keymap));
+extern void rl_tty_unset_default_bindings PARAMS((Keymap));
 
 extern int rl_reset_terminal PARAMS((const char *));
 extern void rl_resize_terminal PARAMS((void));
 extern void rl_set_screen_size PARAMS((int, int));
 extern void rl_get_screen_size PARAMS((int *, int *));
+extern void rl_reset_screen_size PARAMS((void));
 
 extern char *rl_get_termcap PARAMS((const char *));
 
@@ -417,6 +443,8 @@ extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *)
 extern char *rl_username_completion_function PARAMS((const char *, int));
 extern char *rl_filename_completion_function PARAMS((const char *, int));
 
+extern int rl_completion_mode PARAMS((rl_command_func_t *));
+
 #if 0
 /* Backwards compatibility (compat.c).  These will go away sometime. */
 extern void free_undo_list PARAMS((void));
@@ -453,6 +481,10 @@ extern int rl_readline_state;
    0 means vi mode. */
 extern int rl_editing_mode;
 
+/* Insert or overwrite mode for emacs mode.  1 means insert mode; 0 means
+   overwrite mode.  Reset to insert mode on each input line. */
+extern int rl_insert_mode;
+
 /* The name of the calling program.  You should initialize this to
    whatever was in argv[0].  It is used when parsing conditionals. */
 extern const char *rl_readline_name;
@@ -500,6 +532,11 @@ extern const char *rl_terminal_name;
 extern FILE *rl_instream;
 extern FILE *rl_outstream;
 
+/* If non-zero, Readline gives values of LINES and COLUMNS from the environment
+   greater precedence than values fetched from the kernel when computing the
+   screen dimensions. */
+extern int rl_prefer_env_winsize;
+
 /* If non-zero, then this is the address of a function to call just
    before readline_internal () prints the first prompt. */
 extern rl_hook_func_t *rl_startup_hook;
@@ -587,7 +624,12 @@ extern const char *rl_basic_word_break_characters;
 /* The list of characters that signal a break between words for
    rl_complete_internal.  The default list is the contents of
    rl_basic_word_break_characters.  */
-extern const char *rl_completer_word_break_characters;
+extern /*const*/ char *rl_completer_word_break_characters;
+
+/* Hook function to allow an application to set the completion word
+   break characters before readline breaks up the line.  Allows
+   position-dependent word break characters. */
+extern rl_cpvfunc_t *rl_completion_word_break_hook;
 
 /* List of characters which can be used to quote a substring of the line.
    Completion occurs on the entire substring, and within the substring   
@@ -671,22 +713,50 @@ extern int rl_attempted_completion_over;
    functions. */
 extern int rl_completion_type;
 
-/* Character appended to completed words when at the end of the line.  The
-   default is a space.  Nothing is added if this is '\0'. */
-extern int rl_completion_append_character;
-
 /* Up to this many items will be displayed in response to a
    possible-completions call.  After that, we ask the user if she
    is sure she wants to see them all.  The default value is 100. */
 extern int rl_completion_query_items;
 
+/* Character appended to completed words when at the end of the line.  The
+   default is a space.  Nothing is added if this is '\0'. */
+extern int rl_completion_append_character;
+
+/* If set to non-zero by an application completion function,
+   rl_completion_append_character will not be appended. */
+extern int rl_completion_suppress_append;
+
+/* Set to any quote character readline thinks it finds before any application
+   completion function is called. */
+extern int rl_completion_quote_character;
+
+/* Set to a non-zero value if readline found quoting anywhere in the word to
+   be completed; set before any application completion function is called. */
+extern int rl_completion_found_quote;
+
+/* If non-zero, the completion functions don't append any closing quote.
+   This is set to 0 by rl_complete_internal and may be changed by an
+   application-specific completion function. */
+extern int rl_completion_suppress_quote;
+
+/* If non-zero, a slash will be appended to completed filenames that are
+   symbolic links to directory names, subject to the value of the
+   mark-directories variable (which is user-settable).  This exists so
+   that application completion functions can override the user's preference
+   (set via the mark-symlinked-directories variable) if appropriate.
+   It's set to the value of _rl_complete_mark_symlink_dirs in
+   rl_complete_internal before any application-specific completion
+   function is called, so without that function doing anything, the user's
+   preferences are honored. */
+extern int rl_completion_mark_symlink_dirs;
+
 /* If non-zero, then disallow duplicates in the matches. */
 extern int rl_ignore_completion_duplicates;
 
 /* If this is non-zero, completion is (temporarily) inhibited, and the
    completion character will be inserted as any other. */
 extern int rl_inhibit_completion;
-   
+
 /* Definitions available for use by readline clients. */
 #define RL_PROMPT_START_IGNORE '\001'
 #define RL_PROMPT_END_IGNORE   '\002'
@@ -698,33 +768,80 @@ extern int rl_inhibit_completion;
 #define MULT_MATCH      2
 
 /* Possible state values for rl_readline_state */
-#define RL_STATE_NONE          0x00000         /* no state; before first call */
-
-#define RL_STATE_INITIALIZING  0x00001         /* initializing */
-#define RL_STATE_INITIALIZED   0x00002         /* initialization done */
-#define RL_STATE_TERMPREPPED   0x00004         /* terminal is prepped */
-#define RL_STATE_READCMD       0x00008         /* reading a command key */
-#define RL_STATE_METANEXT      0x00010         /* reading input after ESC */
-#define RL_STATE_DISPATCHING   0x00020         /* dispatching to a command */
-#define RL_STATE_MOREINPUT     0x00040         /* reading more input in a command function */
-#define RL_STATE_ISEARCH       0x00080         /* doing incremental search */
-#define RL_STATE_NSEARCH       0x00100         /* doing non-inc search */
-#define RL_STATE_SEARCH                0x00200         /* doing a history search */
-#define RL_STATE_NUMERICARG    0x00400         /* reading numeric argument */
-#define RL_STATE_MACROINPUT    0x00800         /* getting input from a macro */
-#define RL_STATE_MACRODEF      0x01000         /* defining keyboard macro */
-#define RL_STATE_OVERWRITE     0x02000         /* overwrite mode */
-#define RL_STATE_COMPLETING    0x04000         /* doing completion */
-#define RL_STATE_SIGHANDLER    0x08000         /* in readline sighandler */
-#define RL_STATE_UNDOING       0x10000         /* doing an undo */
-#define RL_STATE_INPUTPENDING  0x20000         /* rl_execute_next called */
-
-#define RL_STATE_DONE          0x80000         /* done; accepted line */
+#define RL_STATE_NONE          0x000000                /* no state; before first call */
+
+#define RL_STATE_INITIALIZING  0x000001        /* initializing */
+#define RL_STATE_INITIALIZED   0x000002        /* initialization done */
+#define RL_STATE_TERMPREPPED   0x000004        /* terminal is prepped */
+#define RL_STATE_READCMD       0x000008        /* reading a command key */
+#define RL_STATE_METANEXT      0x000010        /* reading input after ESC */
+#define RL_STATE_DISPATCHING   0x000020        /* dispatching to a command */
+#define RL_STATE_MOREINPUT     0x000040        /* reading more input in a command function */
+#define RL_STATE_ISEARCH       0x000080        /* doing incremental search */
+#define RL_STATE_NSEARCH       0x000100        /* doing non-inc search */
+#define RL_STATE_SEARCH                0x000200        /* doing a history search */
+#define RL_STATE_NUMERICARG    0x000400        /* reading numeric argument */
+#define RL_STATE_MACROINPUT    0x000800        /* getting input from a macro */
+#define RL_STATE_MACRODEF      0x001000        /* defining keyboard macro */
+#define RL_STATE_OVERWRITE     0x002000        /* overwrite mode */
+#define RL_STATE_COMPLETING    0x004000        /* doing completion */
+#define RL_STATE_SIGHANDLER    0x008000        /* in readline sighandler */
+#define RL_STATE_UNDOING       0x010000        /* doing an undo */
+#define RL_STATE_INPUTPENDING  0x020000        /* rl_execute_next called */
+#define RL_STATE_TTYCSAVED     0x040000        /* tty special chars saved */
+#define RL_STATE_CALLBACK      0x080000        /* using the callback interface */
+#define RL_STATE_VIMOTION      0x100000        /* reading vi motion arg */
+#define RL_STATE_MULTIKEY      0x200000        /* reading multiple-key command */
+#define RL_STATE_VICMDONCE     0x400000        /* entered vi command mode at least once */
+
+#define RL_STATE_DONE          0x800000        /* done; accepted line */
 
 #define RL_SETSTATE(x)         (rl_readline_state |= (x))
 #define RL_UNSETSTATE(x)       (rl_readline_state &= ~(x))
 #define RL_ISSTATE(x)          (rl_readline_state & (x))
 
+struct readline_state {
+  /* line state */
+  int point;
+  int end;
+  int mark;
+  char *buffer;
+  int buflen;
+  UNDO_LIST *ul;
+  char *prompt;
+
+  /* global state */
+  int rlstate;
+  int done;
+  Keymap kmap;
+
+  /* input state */
+  rl_command_func_t *lastfunc;
+  int insmode;
+  int edmode;
+  int kseqlen;
+  FILE *inf;
+  FILE *outf;
+  int pendingin;
+  char *macro;
+
+  /* signal state */
+  int catchsigs;
+  int catchsigwinch;
+
+  /* search state */
+
+  /* completion state */
+
+  /* options state */
+
+  /* reserved for future expansion, so the struct size doesn't change */
+  char reserved[64];
+};
+
+extern int rl_save_state PARAMS((struct readline_state *));
+extern int rl_restore_state PARAMS((struct readline_state *));
+
 #ifdef __cplusplus
 }
 #endif