From 7cdc9feea1d8fcd016a842155c30308e4a0cae3d Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 6 Mar 2001 12:05:45 +0000 Subject: [PATCH] * autoload.c (cygwin_premain0): Add missing parameter. * binmode.c (cygwin_premain0): Ditto. * textmode.c (cygwin_premain0): Ditto. Patch contributed by Jason Tiller : * auto_load.cc: Add "GetKeyboardLayout" entry in the list of Win32 User32.DLL exports to provide. * fhandler.h (class fhandler_console): Add meta_mask private member to remember which keystroke modifiers should generate META. * fhandler_console.cc (fhandler_console::read): Modify code that tests a keystroke for a META-escaped key to use the 'meta_mask' variable. (fhandler_console::fhandler_console): Add definition for variable "meta_mask" used to determine if a keystroke should be preceded by META in the client console stream. Set meta_mask based on whether or not user's keyboard language is English - non-English keyboards pass AltGr (right ) unmolested, whereas English keyboards now interpret left- and right- as META. --- winsup/cygwin/ChangeLog | 24 ++++++++++++++++++++++++ winsup/cygwin/autoload.cc | 1 + winsup/cygwin/automode.c | 2 +- winsup/cygwin/binmode.c | 4 +++- winsup/cygwin/fhandler.h | 3 +++ winsup/cygwin/fhandler_console.cc | 16 +++++++++++++++- winsup/cygwin/textmode.c | 4 +++- 7 files changed, 50 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 72647b30f..47901fcea 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,27 @@ +Tue Mar 6 13:02:00 2001 Jason Tiller + + * autoload.c (cygwin_premain0): Add missing parameter. + * binmode.c (cygwin_premain0): Ditto. + * textmode.c (cygwin_premain0): Ditto. + +Tue Mar 6 12:04:00 2001 Jason Tiller + + * auto_load.cc: Add "GetKeyboardLayout" entry in the list of + Win32 User32.DLL exports to provide. + * fhandler.h (class fhandler_console): Add meta_mask private + member to remember which keystroke modifiers should generate + META. + * fhandler_console.cc (fhandler_console::read): Modify code that + tests a keystroke for a META-escaped key to use the 'meta_mask' + variable. + (fhandler_console::fhandler_console): Add definition for + variable "meta_mask" used to determine if a keystroke should be + preceded by META in the client console stream. Set meta_mask + based on whether or not user's keyboard language is English - + non-English keyboards pass AltGr (right ) unmolested, + whereas English keyboards now interpret left- and right- + as META. + Mon Mar 5 20:15:00 2001 Corinna Vinschen * include/a.out.h: Add copyright hint. diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc index bd035e397..a22d72d38 100644 --- a/winsup/cygwin/autoload.cc +++ b/winsup/cygwin/autoload.cc @@ -306,6 +306,7 @@ LoadDLLfunc (DefWindowProcA, 16, user32) LoadDLLfunc (DispatchMessageA, 4, user32) LoadDLLfunc (FindWindowA, 8, user32) LoadDLLfunc (GetClipboardData, 4, user32) +LoadDLLfunc (GetKeyboardLayout, 4, user32) LoadDLLfunc (GetMessageA, 16, user32) LoadDLLfunc (GetProcessWindowStation, 0, user32) LoadDLLfunc (GetThreadDesktop, 4, user32) diff --git a/winsup/cygwin/automode.c b/winsup/cygwin/automode.c index e02b0b9de..f7cddfeec 100644 --- a/winsup/cygwin/automode.c +++ b/winsup/cygwin/automode.c @@ -14,7 +14,7 @@ details. */ extern int _fmode; void -cygwin_premain0 (int argc, char **argv) +cygwin_premain0 (int argc, char **argv, struct per_process *myself) { static struct __cygwin_perfile pf[] = { diff --git a/winsup/cygwin/binmode.c b/winsup/cygwin/binmode.c index 2eb02df23..50efff46f 100644 --- a/winsup/cygwin/binmode.c +++ b/winsup/cygwin/binmode.c @@ -8,11 +8,13 @@ This software is a copyrighted work licensed under the terms of the Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ +#include #include +#include extern int _fmode; void -cygwin_premain0 (int argc, char **argv) +cygwin_premain0 (int argc, char **argv, struct per_process *myself) { _fmode &= ~_O_TEXT; _fmode |= _O_BINARY; diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 3196f2114..c4f931d63 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -608,6 +608,9 @@ private: WORD default_color, underline_color, dim_color; + /* Used to determine if an input keystroke should be modified with META. */ + int meta_mask; + /* Output state */ int state_; int args_[MAXARGS]; diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 6e8c76c1c..ca73ab651 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -250,7 +250,8 @@ fhandler_console::read (void *pv, size_t buflen) converting a CTRL-U. */ if ((unsigned char)ich > 0x7f && current_codepage == ansi_cp) OemToCharBuff (tmp + 1, tmp + 1, 1); - if (!(input_rec.Event.KeyEvent.dwControlKeyState & LEFT_ALT_PRESSED)) + /* Determine if the keystroke is modified by META. */ + if (!(input_rec.Event.KeyEvent.dwControlKeyState & meta_mask)) toadd = tmp + 1; else { @@ -790,6 +791,19 @@ fhandler_console::fhandler_console (const char *name) : dwLastButtonState = 0; nModifiers = 0; use_mouse = raw_win32_keyboard_mode = FALSE; + /* Set the mask that determines if an input keystroke is modified by + META. We set this based on the keyboard layout language loaded + for the current thread. The left key always generates + META, but the right key only generates META if we are using + an English keyboard because many "international" keyboards + replace common shell symbols ('[', '{', etc.) with accented + language-specific characters (umlaut, accent grave, etc.). On + these keyboards right (called AltGr) is used to produce the + shell symbols and should not be interpreted as META. */ + meta_mask = LEFT_ALT_PRESSED; + if (PRIMARYLANGID (LOWORD (GetKeyboardLayout (0))) == LANG_ENGLISH) + meta_mask |= RIGHT_ALT_PRESSED; + set_need_fork_fixup (); } diff --git a/winsup/cygwin/textmode.c b/winsup/cygwin/textmode.c index 92648ca04..6d52d50f8 100644 --- a/winsup/cygwin/textmode.c +++ b/winsup/cygwin/textmode.c @@ -8,11 +8,13 @@ This software is a copyrighted work licensed under the terms of the Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ +#include #include +#include extern int _fmode; void -cygwin_premain0 (int argc, char **argv) +cygwin_premain0 (int argc, char **argv, struct per_process *myself) { _fmode &= ~_O_BINARY; _fmode |= _O_TEXT;