]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* input.c (rl_getc): Use getch to read console input on
authorMark Mitchell <mark@codesourcery.com>
Mon, 25 Jul 2005 15:09:31 +0000 (15:09 +0000)
committerMark Mitchell <mark@codesourcery.com>
Mon, 25 Jul 2005 15:09:31 +0000 (15:09 +0000)
Windows.
* readline.c (bind_arrow_keys_internal): Translate
Windows keysequences into POSIX key sequences.
* rldefs.h (NO_TTY_DRIVER): Define on MinGW.
* rltty.c: Conditionalize on NO_TTY_DRIVER throughout.

readline/ChangeLog.gdb
readline/input.c
readline/readline.c
readline/rldefs.h
readline/rltty.c

index 62fa1b66139773d5912f6359be9e9ba31e825651..cdf268648a1884b6da668763317b907a19657c67 100644 (file)
@@ -1,3 +1,12 @@
+2005-07-25  Mark Mitchell <mark@codesourcery.com>
+
+       * input.c (rl_getc): Use getch to read console input on
+       Windows.
+       * readline.c (bind_arrow_keys_internal): Translate
+       Windows keysequences into POSIX key sequences.
+       * rldefs.h (NO_TTY_DRIVER): Define on MinGW.
+       * rltty.c: Conditionalize on NO_TTY_DRIVER throughout.
+       
 2005-07-03  Mark Kettenis <kettenis@gnu.org>
 
        From Martin Simmons:
index 841f05d1af9ccf55a7cae4cc59beee899c6f0e3a..9120dfa8a8dc90b0b8a5c4c16b1988eb4fe8c51f 100644 (file)
@@ -424,6 +424,13 @@ rl_getc (stream)
 
   while (1)
     {
+#ifdef __MINGW32__
+      /* On Windows, use a special routine to read a single  character
+        from the console.  (Otherwise, no characters are available
+        until the user hits the return key.)  */
+      if (isatty (fileno (stream)))
+       return getch ();
+#endif
       result = read (fileno (stream), &c, sizeof (unsigned char));
 
       if (result == sizeof (unsigned char))
index aed0235bf3f1dc745bc533793e497a6c03250c06..07fb58fd210d2f973c0bcbc1cf9f6e11af8d5bf9 100644 (file)
@@ -868,6 +868,22 @@ bind_arrow_keys_internal (map)
    _rl_bind_if_unbound ("\033[0D", rl_get_next_history);
 #endif
 
+#ifdef __MINGW32__
+   /* Under Windows, when an extend key (like an arrow key) is
+      pressed, getch() will return 340 (octal) followed by a code for
+      the extended key.  We use macros to transform those into the
+      normal ANSI terminal sequences for these keys.  */
+
+   /* Up arrow.  */
+   rl_macro_bind ("\340H", "\033[A", map);
+   /* Left arrow.  */
+   rl_macro_bind ("\340K", "\033[D", map);
+   /* Right arrow.  */
+   rl_macro_bind ("\340M", "\033[C", map);
+   /* Down arrow.  */
+   rl_macro_bind ("\340P", "\033[B", map);
+#endif
+
   _rl_bind_if_unbound ("\033[A", rl_get_previous_history);
   _rl_bind_if_unbound ("\033[B", rl_get_next_history);
   _rl_bind_if_unbound ("\033[C", rl_forward_char);
index 4a28bd1e49c2d14571a8b599ed17c70be7e649bb..b80db8cffede5caabab4be7f70fd9cf4035552c8 100644 (file)
@@ -32,7 +32,9 @@
 
 #include "rlstdc.h"
 
-#if defined (_POSIX_VERSION) && !defined (TERMIOS_MISSING)
+#if defined (__MINGW32__)
+#  define NO_TTY_DRIVER
+#elif defined (_POSIX_VERSION) && !defined (TERMIOS_MISSING)
 #  define TERMIOS_TTY_DRIVER
 #else
 #  if defined (HAVE_TERMIO_H)
index ad179043472c1e51881c2e71f6b53b51b4cc8791..2ccb9d1a56621800a9f0309c5260509858fcbd2e 100644 (file)
@@ -152,7 +152,9 @@ set_winsize (tty)
 #endif /* TIOCGWINSZ */
 }
 
-#if defined (NEW_TTY_DRIVER)
+#if defined (NO_TTY_DRIVER)
+/* Nothing */
+#elif defined (NEW_TTY_DRIVER)
 
 /* Values for the `flags' field of a struct bsdtty.  This tells which
    elements of the struct bsdtty have been fetched from the system and
@@ -632,6 +634,22 @@ prepare_terminal_settings (meta_flag, oldtio, tiop)
 }
 #endif  /* NEW_TTY_DRIVER */
 
+/* Put the terminal in CBREAK mode so that we can detect key
+   presses. */
+#if defined (NO_TTY_DRIVER)
+void
+rl_prep_terminal (meta_flag)
+     int meta_flag;
+{
+  readline_echoing_p = 1;
+}
+
+void
+rl_deprep_terminal ()
+{
+}
+
+#else /* ! NO_TTY_DRIVER */
 /* Put the terminal in CBREAK mode so that we can detect key presses. */
 void
 rl_prep_terminal (meta_flag)
@@ -706,6 +724,7 @@ rl_deprep_terminal ()
 
   release_sigint ();
 }
+#endif /* !NO_TTY_DRIVER */
 \f
 /* **************************************************************** */
 /*                                                                 */
@@ -717,6 +736,10 @@ int
 rl_restart_output (count, key)
      int count, key;
 {
+#if defined (__MINGW32__)
+  return 0;
+#else /* !__MING32__ */
+
   int fildes = fileno (rl_outstream);
 #if defined (TIOCSTART)
 #if defined (apollo)
@@ -744,12 +767,17 @@ rl_restart_output (count, key)
 #endif /* !TIOCSTART */
 
   return 0;
+#endif /* !__MINGW32__ */
 }
 
 int
 rl_stop_output (count, key)
      int count, key;
 {
+#if defined (__MINGW32__)
+  return 0;
+#else
+
   int fildes = fileno (rl_instream);
 
 #if defined (TIOCSTOP)
@@ -772,6 +800,7 @@ rl_stop_output (count, key)
 #endif /* !TIOCSTOP */
 
   return 0;
+#endif /* !__MINGW32__ */
 }
 
 /* **************************************************************** */
@@ -786,6 +815,7 @@ void
 rltty_set_default_bindings (kmap)
      Keymap kmap;
 {
+#if !defined (NO_TTY_DRIVER)
   TIOTYPE ttybuff;
   int tty = fileno (rl_instream);
 
@@ -844,6 +874,7 @@ rltty_set_default_bindings (kmap)
 #  endif /* VWERASE && TERMIOS_TTY_DRIVER */
     }
 #endif /* !NEW_TTY_DRIVER */
+#endif
 }
 
 /* New public way to set the system default editing chars to their readline
@@ -857,7 +888,7 @@ rl_tty_set_default_bindings (kmap)
 
 #if defined (HANDLE_SIGNALS)
 
-#if defined (NEW_TTY_DRIVER)
+#if defined (NEW_TTY_DRIVER) || defined (NO_TTY_DRIVER)
 int
 _rl_disable_tty_signals ()
 {