Revert movement of @chapter and @node tags from separate files to
[deliverable/binutils-gdb.git] / readline / readline.c
index 8ff6e98929fd8337ec9c31d374582a385698af8d..6bd25f7d93926c760c92c90aee95c6025b8a3e71 100644 (file)
@@ -64,7 +64,7 @@
 #include "history.h"
 
 #ifndef RL_LIBRARY_VERSION
-#  define RL_LIBRARY_VERSION "2.2-bash"
+#  define RL_LIBRARY_VERSION "4.0"
 #endif
 
 /* Evaluates its arguments multiple times. */
@@ -83,7 +83,6 @@ extern void _rl_output_character_function ();
 #else
 extern int _rl_output_character_function ();
 #endif
-extern void _rl_get_screen_size ();
 
 extern int _rl_enable_meta;
 extern int _rl_term_autowrap;
@@ -100,7 +99,6 @@ extern int alphabetic ();
 
 /* Functions imported from bind.c. */
 extern void _rl_bind_if_unbound ();
-extern int rl_set_keymap_from_edit_mode ();
 
 /* Functions imported from input.c. */
 extern int _rl_any_typein ();
@@ -118,9 +116,7 @@ extern void _rl_move_vert ();
 extern void _rl_update_final ();
 extern void _rl_clear_to_eol ();
 extern void _rl_clear_screen ();
-
-extern void _rl_save_prompt ();
-extern void _rl_restore_prompt ();
+extern void _rl_erase_entire_line ();
 
 extern void _rl_erase_at_end_of_line ();
 extern void _rl_move_cursor_relative ();
@@ -167,14 +163,16 @@ static void readline_initialize_everything ();
 static void start_using_history ();
 static void bind_arrow_keys ();
 
-#if !defined (__GO32__)
+#if !defined (__GO32__) || defined (HAVE_TERMIOS_H)
 static void readline_default_bindings ();
 #endif /* !__GO32__ */
 
 #if defined (__GO32__)
 #  include <go32.h>
 #  include <pc.h>
-#  undef HANDLE_SIGNALS
+#  if !defined (__DJGPP__)
+#    undef HANDLE_SIGNALS
+#  endif /* !__DJGPP__ */
 #endif /* __GO32__ */
 
 extern char *xmalloc (), *xrealloc ();
@@ -253,9 +251,14 @@ int rl_visible_prompt_length = 0;
 int rl_key_sequence_length = 0;
 
 /* If non-zero, then this is the address of a function to call just
-   before readline_internal () prints the first prompt. */
+   before readline_internal_setup () prints the first prompt. */
 Function *rl_startup_hook = (Function *)NULL;
 
+/* If non-zero, this is the address of a function to call just before
+   readline_internal_setup () returns and readline_internal starts
+   reading input characters. */
+Function *rl_pre_input_hook = (Function *)NULL;
+
 /* What we use internally.  You should always refer to RL_LINE_BUFFER. */
 static char *the_line;
 
@@ -286,6 +289,9 @@ char *_rl_comment_begin;
 /* Keymap holding the function currently being executed. */
 Keymap rl_executing_keymap;
 
+/* Non-zero means to erase entire line, including prompt, on empty input lines. */
+int rl_erase_empty_line = 0;
+
 /* Line buffer and maintenence. */
 char *rl_line_buffer = (char *)NULL;
 int rl_line_buffer_len = 0;
@@ -388,6 +394,9 @@ readline_internal_setup ()
        rl_vi_insertion_mode (1, 0);
 #endif /* VI_MODE */
     }
+
+  if (rl_pre_input_hook)
+    (*rl_pre_input_hook) ();
 }
 
 STATIC_CALLBACK char *
@@ -405,7 +414,7 @@ readline_internal_teardown (eof)
     {
       temp = savestring (the_line);
       rl_revert_line (1, 0);
-      entry = replace_history_entry (where_history (), the_line, (HIST_ENTRY *)NULL);
+      entry = replace_history_entry (where_history (), the_line, (histdata_t)NULL);
       _rl_free_history_entry (entry);
 
       strcpy (the_line, temp);
@@ -488,6 +497,12 @@ readline_internal_charloop ()
       if (rl_done == 0)
        (*rl_redisplay_function) ();
 
+      /* If the application writer has told us to erase the entire line if
+         the only character typed was something bound to rl_newline, do so. */
+      if (rl_erase_empty_line && rl_done && rl_last_func == rl_newline &&
+         rl_point == 0 && rl_end == 0)
+       _rl_erase_entire_line ();
+
 #if defined (READLINE_CALLBACKS)
       return 0;
 #else
@@ -501,7 +516,7 @@ readline_internal_charloop ()
 static int
 readline_internal_charloop ()
 {
-  int eof;
+  int eof = 1;
 
   while (rl_done == 0)
     eof = readline_internal_char ();
@@ -732,10 +747,10 @@ readline_initialize_everything ()
   /* Initialize the terminal interface. */
   _rl_init_terminal_io ((char *)NULL);
 
-#if !defined (__GO32__)
+#if !defined (__GO32__) || defined (HAVE_TERMIOS_H)
   /* Bind tty characters to readline functions. */
   readline_default_bindings ();
-#endif /* !__GO32__ */
+#endif /* !__GO32__ || HAVE_TERMIOS_H */
 
   /* Initialize the function names. */
   rl_initialize_funmap ();
@@ -837,11 +852,19 @@ rl_digit_loop ()
 {
   int key, c, sawminus, sawdigits;
 
-  _rl_save_prompt ();
+  rl_save_prompt ();
 
   sawminus = sawdigits = 0;
   while (1)
     {
+      if (rl_numeric_arg > 1000000)
+       {
+         sawdigits = rl_explicit_arg = rl_numeric_arg = 0;
+         ding ();
+         rl_restore_prompt ();
+         rl_clear_message ();
+         return 1;
+       }
       rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
       key = c = rl_read_key ();
 
@@ -858,7 +881,7 @@ rl_digit_loop ()
          else
            {
              key = rl_read_key ();
-             _rl_restore_prompt ();
+             rl_restore_prompt ();
              rl_clear_message ();
              return (_rl_dispatch (key, _rl_keymap));
            }
@@ -881,7 +904,7 @@ rl_digit_loop ()
          /* Make M-- command equivalent to M--1 command. */
          if (sawminus && rl_numeric_arg == 1 && rl_explicit_arg == 0)
            rl_explicit_arg = 1;
-         _rl_restore_prompt ();
+         rl_restore_prompt ();
          rl_clear_message ();
          return (_rl_dispatch (key, _rl_keymap));
        }
@@ -1231,7 +1254,8 @@ rl_backward_word (count, key)
 
 /* Clear the current line.  Numeric argument to C-l does this. */
 int
-rl_refresh_line ()
+rl_refresh_line (ignore1, ignore2)
+     int ignore1, ignore2;
 {
   int curr_line, nleft;
 
@@ -1250,7 +1274,7 @@ rl_refresh_line ()
   _rl_move_vert (curr_line);
   _rl_move_cursor_relative (0, the_line);   /* XXX is this right */
 
-#if defined (__GO32__)
+#if defined (__GO32__) && !defined (__DJGPP__)
   {
     int row, col, width, row_start;
 
@@ -1259,9 +1283,9 @@ rl_refresh_line ()
     row_start = ScreenPrimary + (row * width);
     memset (row_start + col, 0, (width - col) * 2);
   }
-#else /* !__GO32__ */
+#else /* !__GO32__ || __DJGPP__ */
   _rl_clear_to_eol (0);                /* arg of 0 means to not use spaces */
-#endif /* !__GO32__ */
+#endif /* !__GO32__ || __DJGPP__ */
 
   rl_forced_update_display ();
   rl_display_fixed = 1;
@@ -1278,7 +1302,7 @@ rl_clear_screen (count, key)
 {
   if (rl_explicit_arg)
     {
-      rl_refresh_line ();
+      rl_refresh_line (count, key);
       return 0;
     }
 
@@ -1428,6 +1452,11 @@ rl_newline (count, key)
     }
 #endif /* VI_MODE */
 
+  /* If we've been asked to erase empty lines, suppress the final update,
+     since _rl_update_final calls crlf(). */
+  if (rl_erase_empty_line && rl_point == 0 && rl_end == 0)
+    return 0;
+
   if (readline_echoing_p)
     _rl_update_final ();
   return 0;
@@ -1507,9 +1536,22 @@ rl_delete (count, key)
     }
   else
     return (rl_delete_text (rl_point, rl_point + 1));
-  
 }
 
+/* Delete the character under the cursor, unless the insertion
+   point is at the end of the line, in which case the character
+   behind the cursor is deleted.  COUNT is obeyed and may be used
+   to delete forward or backward that many characters. */      
+int
+rl_rubout_or_delete (count, key)
+     int count, key;
+{
+  if (rl_end != 0 && rl_point == rl_end)
+    return (rl_rubout (count, key));
+  else
+    return (rl_delete (count, key));
+}  
+
 /* Delete all spaces and tabs around point. */
 int
 rl_delete_horizontal_space (count, ignore)
@@ -1533,6 +1575,19 @@ rl_delete_horizontal_space (count, ignore)
   return 0;
 }
 
+/* Like the tcsh editing function delete-char-or-list.  The eof character
+   is caught before this is invoked, so this really does the same thing as
+   delete-char-or-list-or-eof, as long as it's bound to the eof character. */
+int
+rl_delete_or_show_completions (count, key)
+     int count, key;
+{
+  if (rl_end != 0 && rl_point == rl_end)
+    return (rl_possible_completions (count, key));
+  else
+    return (rl_delete (count, key));
+}
+
 #ifndef RL_COMMENT_BEGIN_DEFAULT
 #define RL_COMMENT_BEGIN_DEFAULT "#"
 #endif
@@ -1859,7 +1914,7 @@ maybe_replace_line ()
   /* If the current line has changed, save the changes. */
   if (temp && ((UNDO_LIST *)(temp->data) != rl_undo_list))
     {
-      temp = replace_history_entry (where_history (), the_line, rl_undo_list);
+      temp = replace_history_entry (where_history (), the_line, (histdata_t)rl_undo_list);
       free (temp->line);
       free (temp);
     }
This page took 0.026581 seconds and 4 git commands to generate.