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-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:
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))
_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);
#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)
#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
}
#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)
release_sigint ();
}
+#endif /* !NO_TTY_DRIVER */
\f
/* **************************************************************** */
/* */
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)
#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)
#endif /* !TIOCSTOP */
return 0;
+#endif /* !__MINGW32__ */
}
/* **************************************************************** */
rltty_set_default_bindings (kmap)
Keymap kmap;
{
+#if !defined (NO_TTY_DRIVER)
TIOTYPE ttybuff;
int tty = fileno (rl_instream);
# endif /* VWERASE && TERMIOS_TTY_DRIVER */
}
#endif /* !NEW_TTY_DRIVER */
+#endif
}
/* New public way to set the system default editing chars to their readline
#if defined (HANDLE_SIGNALS)
-#if defined (NEW_TTY_DRIVER)
+#if defined (NEW_TTY_DRIVER) || defined (NO_TTY_DRIVER)
int
_rl_disable_tty_signals ()
{