Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* PATCH: Use getche on Win32
@ 2005-05-09 20:42 Mark Mitchell
  2005-05-10  6:01 ` Eli Zaretskii
  0 siblings, 1 reply; 23+ messages in thread
From: Mark Mitchell @ 2005-05-09 20:42 UTC (permalink / raw)
  To: bug-readline; +Cc: gdb-patches


[This is the penultimate GDB-on-MinGW patch.]

Windows console semantics are different from UNIX.  If we just use
"read" to read what the user's typing, we end up blocking until a
newline is available, and even then there are some oddities.  The
easiest thing seems to be to use the special "getche" (short for "get
character with echo") routine which does the right thing.

Reviews?

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2005-05-09  Mark Mitchell  <mark@codesourcery.com>

	* readline/input.c (rl_getc): Use getche to read console input on
	Windows.

Index: input.c
===================================================================
RCS file: /cvs/src/src/readline/input.c,v
retrieving revision 1.5
retrieving revision 1.5.60.1
diff -c -5 -p -r1.5 -r1.5.60.1
*** input.c	8 Dec 2002 22:31:37 -0000	1.5
--- input.c	5 Apr 2005 17:53:04 -0000	1.5.60.1
*************** rl_getc (stream)
*** 422,431 ****
--- 422,438 ----
    int result;
    unsigned char c;
  
    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 getche ();
+ #endif
        result = read (fileno (stream), &c, sizeof (unsigned char));
  
        if (result == sizeof (unsigned char))
  	return (c);
  


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2005-05-13 13:43 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-09 20:42 PATCH: Use getche on Win32 Mark Mitchell
2005-05-10  6:01 ` Eli Zaretskii
2005-05-10 11:45   ` Mark Mitchell
2005-05-10 20:05     ` Eli Zaretskii
2005-05-10 20:26       ` Mark Mitchell
2005-05-10 20:31         ` Eli Zaretskii
2005-05-10 20:49           ` Daniel Jacobowitz
2005-05-10 21:41             ` Christopher Faylor
2005-05-11  6:55               ` Christopher Faylor
2005-05-11  7:13                 ` Eli Zaretskii
2005-05-11  7:17                   ` Mark Mitchell
2005-05-11  7:21                 ` MinGW build instructions (was: PATCH: Use getche on Win32) Eli Zaretskii
2005-05-11  7:29                   ` MinGW build instructions Mark Mitchell
2005-05-11  7:53                     ` Eli Zaretskii
2005-05-11 18:45                     ` Christopher Faylor
2005-05-11 19:05                       ` Eli Zaretskii
2005-05-11 19:58                         ` Christopher Faylor
2005-05-11 23:16                           ` Eli Zaretskii
2005-05-11  6:56             ` PATCH: Use getche on Win32 Mark Mitchell
2005-05-11 13:42               ` Eli Zaretskii
2005-05-13 11:42                 ` Mark Mitchell
2005-05-13 15:18                   ` Eli Zaretskii
2005-05-11  7:07             ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox