Re: Alt key not recognized as Meta in xterm

2010-01-03 Thread Gary Carvell
Thanks Andy, your explanation was extremely helpful. For the longest
time it was unclear whether the Alt key issue was related to
LANG/LC_*, readline / .inputrc, xterm, X resources, or something else
entirely. ASCII is much simpler :-) At any rate, things are good now.

FWIW, on my Linux box running Slackware64 and twm, I changed LANG from
the default en_US to to en_US.UTF-8. This caused the same issue as on
Cygwin, and the same .Xdefaults entry fixed it.

Gary

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Alt key not recognized as Meta in xterm

2010-01-01 Thread Thomas Dickey

On Fri, 1 Jan 2010, Andy Koppe wrote:


2010/1/1 Thomas Dickey:

Is Cygwin also specifying a meta key?

(some people equate meta==alt, though they're not necessarily the same)


I don't know whether there's ever been an official policy decision on
that, but I think the general assumption among Cygwin users is that
Alt==Meta, since of course PC keyboards don't have a Meta key yet lots
of programs expect one.

I realise that in X it is possible to map a different key to Meta, but
the altIsNotMeta setting is off by default in Cygwin's xterm. Also,
the Cygwin console, rxvt, and mintty (via PuTTY) assume that Alt is
Meta (and they all encode it as Escape by default).


iirc, Cygwin console (unless something's changed in 1.7) and rxvt don't 
actually do the meta function as described in the terminfo manpage, e.g.,


   If  the  terminal has a ``meta key'' which acts as a shift key, setting
   the 8th bit of any character transmitted, this fact  can  be  indicated
   with  km.   Otherwise,  software will assume that the 8th bit is parity
   and it will usually be cleared.  If strings exist to turn  this  ``meta
   mode'' on and off, they can be given as smm and rmm.

Rather, they're assuming that meta is a way to put an escape character in 
front of other keys.  That's reflected in readline's manpage:


   An emacs-style notation is used to denote keystrokes.  Control keys are
   denoted  by C-key, e.g., C-n means Control-N.  Similarly, meta keys are
   denoted by M-key, so M-x means Meta-X.  (On keyboards  without  a  meta
   key,  M-x means ESC x, i.e., press the Escape key then the x key.  This
   makes ESC the meta prefix.  The combination M-C-x means  ESC-Control-x,
   or  press the Escape key then hold the Control key while pressing the x
   key.)

however (same manpage)

   convert-meta (On)
  If  set  to On, readline will convert characters with the eighth
  bit set to an ASCII key sequence by stripping the eighth bit and
  prefixing  it  with an escape character (in effect, using escape
  as the meta prefix).

...

   input-meta (Off)
  If set to On, readline will enable eight-bit input (that is,  it
  will  not  clear  the  eighth  bit  in the characters it reads),
  regardless of what the terminal claims it can support.  The name
  meta-flag is a synonym for this variable.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Alt key not recognized as Meta in xterm

2010-01-01 Thread Andy Koppe
2010/1/1 Thomas Dickey:
> Is Cygwin also specifying a meta key?
>
> (some people equate meta==alt, though they're not necessarily the same)

I don't know whether there's ever been an official policy decision on
that, but I think the general assumption among Cygwin users is that
Alt==Meta, since of course PC keyboards don't have a Meta key yet lots
of programs expect one.

I realise that in X it is possible to map a different key to Meta, but
the altIsNotMeta setting is off by default in Cygwin's xterm. Also,
the Cygwin console, rxvt, and mintty (via PuTTY) assume that Alt is
Meta (and they all encode it as Escape by default).

Andy

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Alt key not recognized as Meta in xterm

2010-01-01 Thread Thomas Dickey

On Fri, 1 Jan 2010, Andy Koppe wrote:


2010/1/1 Thomas Dickey:

On Fri, 1 Jan 2010, Andy Koppe wrote:


   XTerm*vt100.metaSendsEscape: true


Actually that's not a hack, but the correct solution. I think this
needs to be part of the default config in /etc/X11/app-defaults/XTerm.


However, the reason that it's not is because there's no standard for
the meta key assignment.


Understood. I didn't mean it should be the default for Xterm in
general, but it should be for Cygwin's version, due to UTF-8 being the
default charset.


Is Cygwin also specifying a meta key?

(some people equate meta==alt, though they're not necessarily the same)

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Alt key not recognized as Meta in xterm

2010-01-01 Thread Andy Koppe
2010/1/1 Thomas Dickey:
> On Fri, 1 Jan 2010, Andy Koppe wrote:
>
>>>XTerm*vt100.metaSendsEscape: true
>>
>> Actually that's not a hack, but the correct solution. I think this
>> needs to be part of the default config in /etc/X11/app-defaults/XTerm.
>
> However, the reason that it's not is because there's no standard for
> the meta key assignment.

Understood. I didn't mean it should be the default for Xterm in
general, but it should be for Cygwin's version, due to UTF-8 being the
default charset.

Andy

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Alt key not recognized as Meta in xterm

2010-01-01 Thread Thomas Dickey

On Fri, 1 Jan 2010, Andy Koppe wrote:


   XTerm*vt100.metaSendsEscape: true


Actually that's not a hack, but the correct solution. I think this
needs to be part of the default config in /etc/X11/app-defaults/XTerm.


However, the reason that it's not is because there's no standard for
the meta key assignment.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/

Re: Alt key not recognized as Meta in xterm

2010-01-01 Thread Andy Koppe
2009/12/30 Gary Carvell:

X issues including xterm ones should go to the cygwin-xfree list. I'm
sending this to both lists, but please respond on cygwin-xfree only.

> With the upgrade to Cygwin 1.7, I found that the Alt key is no longer
> recognized as a Meta key in xterm. This means the Alt based command
> line editing keys such as Alt-F/B for forward- and backward-word must
> be entered with the Esc key instead. I assume this is related to the
> internationalization changes in 1.7.
>
> I liked the old behavior better, but had some trouble changing it
> back. So here's my little hack for this in case anyone else finds it
> useful. In your home directory, create a file .Xdefaults containing
> this line:
>
>    XTerm*vt100.metaSendsEscape: true

Actually that's not a hack, but the correct solution. I think this
needs to be part of the default config in /etc/X11/app-defaults/XTerm.

When that option is not enabled, 'meta' is sent by setting the highest
bit of the metafied character, e.g. 'f' (0x66) turns into 0xE6. That's
fine if you're using ASCII only, but obviously it'll conflict with any
character encodings beyond ASCII, e.g.in ISO-8859-1 and others, 0xE6
is æ (the ae ligature).

And in UTF-8, which of course is the Cygwin default now, a 0xE6 byte
would be an incomplete sequence. That's why xterm applies the meta bit
before doing the UTF-8 encoding, so Alt-f is sent as \xC3\xA6, which
is the UTF-8 encoding for U+00E6 (again: æ) . But bash doesn't
recognise that as Alt-f.

> I'd be glad to hear any background information on the key mapping
> change, or better ways to restore the old behavior.

If you don't need anything beyond ASCII, you could go back to a
singlebyte charset, e.g. by setting 'LANG=en_US.ISO-8859-1'.
Otherwise, the escape prefix is the way to go.

Andy

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/