help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to make <shift> work with <control> in xterm?


From: Pascal Bourguignon
Subject: Re: How to make <shift> work with <control> in xterm?
Date: Sat, 14 Oct 2006 08:00:39 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

id.brep@gmail.com writes:

> In the emacs manual, it's said:
>
>    On ASCII terminals, there are only 32 possible control characters.
> These are the control variants of letters and `@[]\^_'.  In addition,
> the shift key is meaningless with control characters: `C-a' and `C-A'
> are the same character, and Emacs cannot distinguish them.
>
> I use xterm, I think it's graphical terminal, is it possibleto make
> <shit>
> work with <control> in xterm?

Not AFAIK.

The question is that there is no line protocol to encode shit+control+key.

There is the ASCII code, with 33 control codes and 95 character codes.

Unshifted, we get characters between 32 and 47, and between 96 and 127.
The shift key is used to get the characters between 48 and 95.
The control key is used to get the control codes between 0 and 31.

So we only need 32 keys in addition to shift and control to generate
all the ASCII codes.

  0 NUL    1 SOH    2 STX    3 ETX    4 EOT    5 ENQ    6 ACK    7 BEL  
  8 BS     9 TAB   10 LF    11 VT    12 FF    13 CR    14 SO    15 SI   
 16 DLE   17 DC1   18 DC2   19 DC3   20 DC4   21 NAK   22 SYN   23 ETB  
 24 CAN   25 EM    26 SUB   27 ESC   28 FS    29 GS    30 RS    31 US   
 32 SP    33  !   34  "   35  #   36  $   37  %   38  &   39  '  
 40  (   41  )   42  *   43  +   44  ,   45  -   46  .   47  /  
 48  0   49  1   50  2   51  3   52  4   53  5   54  6   55  7  
 56  8   57  9   58  :   59  ;   60  <   61  =   62  >   63  ?  
 64  @   65  A   66  B   67  C   68  D   69  E   70  F   71  G  
 72  H   73  I   74  J   75  K   76  L   77  M   78  N   79  O  
 80  P   81  Q   82  R   83  S   84  T   85  U   86  V   87  W  
 88  X   89  Y   90  Z   91  [   92  \   93  ]   94  ^   95  _  
 96  `   97  a   98  b   99  c  100  d  101  e  102  f  103  g  
104  h  105  i  106  j  107  k  108  l  109  m  110  n  111  o  
112  p  113  q  114  r  115  s  116  t  117  u  118  v  119  w  
120  x  121  y  122  z  123  {  124  |  125  }  126  ~  127 DEL  


For Meta, we have the choice to use the old protocol, prefixing the
key with escape (ESC, code 27), or the new one, setting the high bit
on the 7-bit ASCII code.  But this doesn't work well with iso-8859-1
keyboards, so we still often map Meta to ESC...

Apart from Meta sent as ESC, there's no protocol to encode the other
modifiers.  We just send normal ASCII codes.  On the other side, emacs
takes the ASCII codes and guess that some modifier keys were pressed
along with some character key.  But of course, since there are not 64
control code, it can only man C-x, not C-S-x (C-X).


What could be done, is to define a protocol to encode and transmit all
the X keysyms thru a serial line, and patch xterm to use it.

Or we could design a ad-hoc encoding scheme where:

Escape  =   1
Control =   2
Meta    =   4
Alt     =   8
Shift   =  16
super   =  32
Hyper   =  64

And a key choard would be encoded as

CAN(24) c(99) <modifiers> <character>

with <modifiers> being the sum of the codes of the modifier keys that
are pressed, and  <character> being the ASCII code of the graphic
character.

So when you'd type C-M-S-x, xterm would send: 24 99 22 120

This would be interpreted by emacs as: C-x c C-v x
and it could be bound to a distinct command from a keymap for C-x c.

Or we could patch emacs to decode the protocol and translate the two
bytes following a C-x c into the corresponding key events.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"You can tell the Lisp programmers.  They have pockets full of punch
 cards with close parentheses on them." --> http://tinyurl.com/8ubpf


reply via email to

[Prev in Thread] Current Thread [Next in Thread]