This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Query about right <ALT> (AltGr) code


Hello, All, :)

[I've been trying to figure out why the right <alt> key (AltGr)
doesn't generate META in bash.  My previous missive noted that the
Cygwin changelog for one of the later B* releases specifically
indicated that AltGr was changed to not be trapped by Cygwin so that
it could be used for special character entry by non-US keyboards.]

In looking through the Cygwin source (for 1.1.8-1), it looks like the
the relevant code is here:

>>>>>>>>>>

cygwin-1.1.8-1/winsup/cygwin/fhandler_console.cc:

...

int
fhandler_console::read (void *pv, size_t buflen)
{
...
      switch (input_rec.EventType)
        {
        case KEY_EVENT:
          if (!input_rec.Event.KeyEvent.bKeyDown)
            continue;

#define ich (input_rec.Event.KeyEvent.uChar.AsciiChar)
#define wch (input_rec.Event.KeyEvent.uChar.UnicodeChar)

          if (wch == 0 ||
              /* arrow/function keys */
              (input_rec.Event.KeyEvent.dwControlKeyState & ENHANCED_KEY))
            {
              toadd = get_nonascii_key (input_rec, tmp);
              if (!toadd)
                continue;
              nread = strlen (toadd);
            }
          else
            {
              tmp[1] = ich;
              /* Need this check since US code page seems to have a bug when
                 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))
                toadd = tmp + 1;
              else
                {
                  tmp[0] = '\033';
                  tmp[1] = cyg_tolower (tmp[1]);
                  toadd = tmp;
                  nread++;
                }
            }

<<<<<<<<<<

I don't pretend to understand most of this, but it looks to me that
when the left <alt> key is held down during a keystroke entry, the
console handler stuffs a \033 in the keyboard buffer, which is
equivalent to <ESC> (ASCII 27) and is interpreted by bash as META.
Fine.  That makes sense.

I'm attempting to rebuild the cygwin1.dll in preparation for modifying
the above code to support RIGHT_ALT_PRESSED, but I've run into a
problem.  After a 'configure' and then a 'make', make dies with:

make[2]: Entering directory `/cygwin-1.1.8-1/i586-pc-cygwin/winsup/cygwin'
make[2]: *** No rule to make target `all'.  Stop.
make[2]: Leaving directory `/cygwin-1.1.8-1/i586-pc-cygwin/winsup/cygwin'
make[1]: *** [cygwin] Error 2
make[1]: Leaving directory `/cygwin-1.1.8-1/i586-pc-cygwin/winsup'
make: *** [all-target-winsup] Error 2

(It died after probably 20 minutes of churning on a PII-400 on
Win95b).

I searched the FAQ but didn't find any entries relating to building
Cygwin itself, and searching the archives is worse than hopeless
because the searcher won't let you specify strings surrounded in
double-quotes so you get back massive numbers of hits.  Anyone want to
guess on how many hits you get when cygwin1.dll is part of the search
string? ;>

Can anyone quickly guide me towards resolving this make issue?

Also, while I don't have the skill to do it, it would be awfully handy
to provide a Cygwin run-time option via the CYGWIN environment
variable that allowed the user to choose how AltGr should operate.
The default could be as it is today (AltGr unaffected), and a
"altgrmeta" would force left and right <alt> to be the same.  Just an
idea...

As always, thanks for your help. :)

---Jason Tiller
jdtiller@best.com
http://www.sonos.org/


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]