delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/03/06/07:10:43

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Date: Tue, 6 Mar 2001 13:09:31 +0100
From: Corinna Vinschen <cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Patch submission for AltGr handling
Message-ID: <20010306130931.C7734@cygbert.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <20010305194419 DOT R1398 AT cygbert DOT vinschen DOT de> <Pine DOT WNT DOT 4 DOT 32 DOT 0103051757300 DOT -350215 AT tiller2 DOT ventritex DOT com>
Mime-Version: 1.0
User-Agent: Mutt/1.2.5i
In-Reply-To: <Pine.WNT.4.32.0103051757300.-350215@tiller2.ventritex.com>; from jdtiller@best.com on Mon, Mar 05, 2001 at 06:18:35PM -0800

Thanks for the patch. I've applied it with just a few minor
layout changes. The ChangeLog entries should begin with a
tab and the comments where all plain C comments elsewhere, so
I changed your comments to plain C comments as well.

Corinna

On Mon, Mar 05, 2001 at 06:18:35PM -0800, Jason Tiller wrote:
> Hi, Again, Corinna! :)
> 
> On Mon, 5 Mar 2001, Corinna Vinschen wrote:
> 
> > Could you please resubmit a patch which doesn't introduce another
> > CYGWIN option but instead uses automatic recognition of the current
> > keyboard setting? For example the expression
> 
> > if (PRIMARYLANGID (LOWORD (GetKeyboardLayout (0)) == LANG_ENGLISH)
> >
> > should work.
> 
> It does indeed.  I've provided the patch and changelog info at the
> bottom of this message.  I did rudimentary testing to show that AltGr
> is interpreted as META on a US English keyboard; I then set my default
> keyboard to German (Standard) and verified that the
> GetKeyboardLayout() call worked appropriately and that AltGr was *not*
> interpreted as META.  So far, so good!
> 
> I hope that others with access to international keyboards will find
> that this patch does not interfere with their needs.  Thanks again for
> the help.
> 
> ---Jason Tiller
> jtiller AT sjm DOT com
> Sonos
> 
> Here are the diffs (fhandler.h, fhandler_console.cc and autoload.cc):
> 
> --- fhandler.h-orig	Mon Jan 29 18:36:10 2001
> +++ fhandler.h	Mon Mar  5 15:42:24 2001
> @@ -615,6 +615,10 @@ private:
>    int input_tcsetattr (int a, const struct termios *t);
>    void set_cursor_maybe ();
> 
> +  // Used to determine if an input keystroke should be modified with
> +  // META.
> +  int meta_mask;
> +
>  public:
> 
>    fhandler_console (const char *name);
> 
> 
> --- fhandler_console.cc-orig	Mon Jan 29 18:36:12 2001
> +++ fhandler_console.cc	Mon Mar  5 17:47:30 2001
> @@ -220,10 +220,11 @@ fhandler_console::read (void *pv, size_t
>  		 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
> -		{
> +                { // Yup.
>  		  tmp[0] = '\033';
>  		  tmp[1] = cyg_tolower (tmp[1]);
>  		  toadd = tmp;
> @@ -720,6 +721,20 @@ fhandler_console::fhandler_console (cons
>  {
>    set_cb (sizeof *this);
>    state_ = normal;
> +
> +  // 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 <ALT> key always generates
> +  // META, but the right <ALT> 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 <ALT> (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 ();
>  }
> 
> 
> 
> --- autoload.cc-orig	Mon Mar  5 16:59:44 2001
> +++ autoload.cc	Mon Mar  5 17:01:00 2001
> @@ -255,6 +255,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)
> 
> 
> Here are the ChangeLog entries:
> 
>      * 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 <ALT>) unmolested,
>        whereas English keyboards now interpret left- and right-<ALT>
>        as META.
> 
> 
> That's it.  Once again, thanks for considering this patch.
> 
> ---Jason Tiller
> jtiller AT sjm DOT com
> Sonos
> 
> 
> --
> Want to unsubscribe from this list?
> Check out: http://cygwin.com/ml/#unsubscribe-simple

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin AT cygwin DOT com
Red Hat, Inc.

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019