<<< Date Index >>>     <<< Thread Index >>>

Re: Binding to CTRL + arrowkeys



On 2007-10-14, Felix 'buebo' Kakrow <spam@xxxxxxxx> wrote:
> Hello,
> Am 13.10.07 19:12 schrieb Gary Johnson <garyjohn@xxxxxxxxxxxxxxx>:
> > To see what mutt receives when you type a key or key combination, 
> > execute this in mutt:
> > 
> >    :exec what-key
> 
> This does only seem to work when I set $LANG to something that is not UTF-8,
> per default $LANG is de_DE.UTF-8 on my System (Ubuntu 7.10) and I'd rather
> not change it.
> 
> Is there any other way of obtaining the key codes? I tried 'showkey' as
> well but that refused to work under x.org.

One way is to use a text editor such as vim.  Using vim, enter 
insert mode and type Ctrl-V followed by the key whose key code you 
wish to find.  For example, on the following lines I typed 
<Ctrl-V><Up><Return><Ctrl-V><Ctrl-Up><Return>:

^[OA
^[[A

The first character in each line was Escape, displayed in vim as ^[, 
so I replaces the actual Escape character with a carat (^) followed 
by a left bracket ([) so that you could see it.

What that means is that the PuTTY terminal I am currently using 
sends <Escape>OA for the up arrow and <Escape>[A for Ctrl-up-arrow.  
So if the terminal you are using does the same thing, you could 
create macros like this:

   macro pager \eOA     do-up-command
   macro pager \e[A     do-ctrl-up-command

I think that if mutt already recognizes \eOA as <Up> you must use 
<Up> and not \eOA, but I'm not sure about that.

> What I don't get is that I can bind comands to the arrow-keys (like <down>
> for <next-unread> for example) and control works in other combinations (like
> ^F for forgetting the pgp passphrase), so what is different about control +
> arrow-key?

^F is a standard representation for, or a standard mechanism for 
generating, an ASCII character whose value is 0x06.  There is also a 
standard interface for handling keys that are not part of the ASCII 
character set.  This is described in the terminfo man page.  
Terminals often send these keys as the Escape character followed by 
a sequence of other characters, as in the up-arrow example above.  
Terminal libraries such as ncurses use the terminfo database to 
translate between the escape sequences sent by a particular terminal 
for a particular key and the terminfo code for that key.  There is a 
terminfo definition for the up-arrow but not for ctrl-up-arrow.

Not all terminals send unique escape sequences for all keys.  Your 
terminal may not send a unique sequences for up-arrow and 
ctrl-up-arrow.  I don't know much about the differences between 
terminals and the escape codes they use.

Regards,
Gary