Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com Date: Sun, 9 Jul 2000 23:00:34 -0400 From: Chris Faylor To: cygwin-developers AT sourceware DOT cygnus DOT com Subject: Re: CTRL-U broken by OemToCharBuff? Message-ID: <20000709230034.A28472@cygnus.com> Reply-To: cygwin-developers AT sourceware DOT cygnus DOT com Mail-Followup-To: cygwin-developers AT sourceware DOT cygnus DOT com References: <20000709215323 DOT A19246 AT cygnus DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <20000709215323.A19246@cygnus.com>; from cgf on Sun, Jul 09, 2000 at 09:53:23PM -0400 On Sun, Jul 09, 2000 at 09:53:23PM -0400, cgf wrote: >The new OemToCharBuff call translates a CTRL-U to 0xa7 for some reason. >Kazuhiro, can you explain this? It causes me problems when I try >to use CTRL-U to wipe out a line of text. > >If I have something set up wrong, I assume I won't be the only one so >we're going to have to rectify this. The patch below seems to perform the same function as Kazuhiro's original, at the expense of slightly more code. For some reason, WideCharToMultiByte does not screw up CTRL-U. I'm not entirely certain why we're converting to ansi, though? Why not just use the OEM code page and avoid this conversion? cgf Index: fhandler_console.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/fhandler_console.cc,v retrieving revision 1.9 diff -u -p -r1.9 fhandler_console.cc --- fhandler_console.cc 2000/07/04 02:26:20 1.9 +++ fhandler_console.cc 2000/07/10 02:55:51 @@ -128,6 +128,7 @@ fhandler_console::read (void *pv, size_t HANDLE w4[2]; DWORD nwait; + char tmp[17]; w4[0] = h; if (iscygthread ()) @@ -155,11 +156,12 @@ fhandler_console::read (void *pv, size_t __seterrno (); return -1; } + DWORD nread; INPUT_RECORD input_rec; const char *toadd; - if (!ReadConsoleInput (h, &input_rec, 1, &nread)) + if (!ReadConsoleInputW (h, &input_rec, 1, &nread)) { syscall_printf ("ReadConsoleInput failed, %E"); __seterrno (); @@ -167,6 +169,7 @@ fhandler_console::read (void *pv, size_t } #define ich (input_rec.Event.KeyEvent.uChar.AsciiChar) +#define wch (input_rec.Event.KeyEvent.uChar.UnicodeChar) /* check if we're just disposing of this one */ @@ -179,7 +182,7 @@ fhandler_console::read (void *pv, size_t !input_rec.Event.KeyEvent.bKeyDown) continue; - if (ich == 0 || + if (wch == 0 || /* arrow/function keys */ (input_rec.Event.KeyEvent.dwControlKeyState & ENHANCED_KEY)) { @@ -188,18 +191,18 @@ fhandler_console::read (void *pv, size_t continue; nread = strlen (toadd); } - else if (!(input_rec.Event.KeyEvent.dwControlKeyState & LEFT_ALT_PRESSED)) - { - OemToCharBuff (&ich, &ich, 1); - toadd = &ich; - } else { - static char tmp[2]; - tmp[0] = '\033'; - tmp[1] = tolower (ich); - toadd = tmp; - nread = 2; + nread = WideCharToMultiByte (CP_ACP, 0, &wch, 1, tmp + 1, sizeof (tmp) - 1, NULL, NULL); + if (!(input_rec.Event.KeyEvent.dwControlKeyState & LEFT_ALT_PRESSED)) + toadd = tmp + 1; + else + { + tmp[0] = '\033'; + tmp[1] = tolower (tmp[1]); + toadd = tmp; + nread++; + } } if (line_edit (toadd, nread))