home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / editors / 2081 < prev    next >
Encoding:
Text File  |  1992-08-27  |  6.3 KB  |  134 lines

  1. Newsgroups: comp.editors
  2. Path: sparky!uunet!sun-barr!cs.utexas.edu!torn!cunews!nrcnet0!bnrgate!scrumpy!lewis
  3. From: lewis@bnrmtl.bnr.ca (Pierre LEWis)
  4. Subject: Xterms and key mappings (was Re: mined -- problems, problems ...
  5. Message-ID: <1992Aug27.125346.28209@bnrmtl.bnr.ca>
  6. Reply-To: lew@bnr.ca (Pierre LEWis)
  7. Organization: Bell-Northern Research Montreal, Canada
  8. References: <1992Aug26.143939.23188@infko.uucp> <1992Aug27.001638.9471@chpc.utexas.edu>
  9. Date: Thu, 27 Aug 92 12:53:46 GMT
  10. Lines: 122
  11.  
  12. In article <1992Aug27.001638.9471@chpc.utexas.edu> aswx266@chpc.utexas.edu
  13. (Michael Lemke) writes:
  14.  
  15. > xterms are sick.  You need the following junk in your .Xdefaults to make
  16. > xterm send application keypad codes.  Real standard terminals, i.e.,
  17. > ANSI, can be switched from normal keypad mode to application keypad
  18. > mode with an escape sequence.  When will we ever get a working terminal
  19. > emulation for X windows?  Ok, here's the nonsense:
  20.  
  21. I agree it's messy and not very user-friendly as one poster pointed out, but
  22. it's not xterm's fault, rather that of the X server than handles the
  23. keyboard.  On our Suns, I have to do something like Michael described.  But
  24. on our NCD terminals (with a keypad that matches that of a real VT100), it
  25. works perfectly well.  Here are my notes on the topic, it might help others
  26. with key mapping problems.
  27.  
  28. ===== snip === snip === snip === snip === snip === snip === snip === snip =====
  29.  
  30. (from the man page of xxx, a vt100-based utility I wrote)
  31.  
  32. XTERM SETUP
  33.      This is a short summary of what needs to be done to use xxx under
  34.      xterm (a very good vt100 emulation).  It's a bit short, I know, and
  35.      it's my understanding.  There are two issues.  The first issue is
  36.      fonts.  You should select a font which supports ISO Latin 1 chars
  37.      (name ends with -iso8859-1), so as to see the special chars.
  38.  
  39.      The second issue is the keypad.  This can be defined thru X key
  40.      mappings, which, in X11, is a two-step process.  The first step
  41.      takes scancodes and maps these to keysyms (xmodmap).  Changes
  42.      here will apply to all X applications.  The second step is thru
  43.      .xresources for xterm where you can specify what to do when
  44.      keysym is pressed.  Changes here apply only to xterms and can be
  45.      turned on only when needed.  This second approach is the simpler
  46.      (although messier).
  47.  
  48.      The first approach involves xmodmap.  Refer to man page.  Here's
  49.      a complete example of .xinitrc (for HP 700):
  50.         xmodmap -e 'keycode 29 = KP_F1'
  51.         xmodmap -e 'keycode 25 = KP_F2'
  52.         xmodmap -e 'keycode 27 = KP_F3'
  53.         xmodmap -e 'keycode 31 = KP_F4'
  54.         xmodmap -e 'keycode 21 = KP_7'
  55.         xmodmap -e 'keycode 17 = KP_8'
  56.         xmodmap -e 'keycode 19 = KP_9'
  57.         xmodmap -e 'keycode 23 = KP_Subtract'
  58.         xmodmap -e 'keycode 16 = KP_4'
  59.         xmodmap -e 'keycode 18 = KP_5'
  60.         xmodmap -e 'keycode 20 = KP_6'
  61.         xmodmap -e 'keycode 22 = KP_Separator'
  62.         xmodmap -e 'keycode 24 = KP_1'
  63.         xmodmap -e 'keycode 26 = KP_2'
  64.         xmodmap -e 'keycode 28 = KP_3'
  65.         xmodmap -e 'keycode 46 = KP_Enter'
  66.         xmodmap -e 'keycode 30 = KP_0'
  67.         xmodmap -e 'keycode 44 = KP_Decimal'
  68.         xmodmap -e 'keycode 111 = Delete'
  69.      This sets up the 18 keypad keys and (last line) maps the "Delete
  70.      char" key to Delete.
  71.      On Apollo DN3500, I used something like
  72.         xmodmap -e 'keycode 192 = KP_1 KP_F2'
  73.         xmodmap -e 'keycode 193 = KP_2 KP_F3'
  74.         xmodmap -e 'keycode 194 = KP_Separator KP_9'
  75.      etc., which maps various keys (non-shifted and shifted) to various
  76.      keypad keys of a vt100 (a subset -- the Apollo keyboard was
  77.      lousy).  To find out what the keycodes are on your keyboard, use
  78.      xev.  To find out current mappings, try xmodmap -pm -pk.  Other
  79.      changes may be needed, for example to disable a modifier key, e.g.
  80.      on Sparc I need
  81.         xmodmap -e 'clear Mod5'
  82.      so I can use the NumLock key for something else.
  83.  
  84.      In the second approach using xterm resources, the trick is to
  85.      generate the appropriate sequence that would be generated by the
  86.      vt100 keypad (it assumes vt100 keypad is in either numeric or
  87.      application mode and that this does not change -- xxx uses latter).
  88.      See the xterm and X man pages.  The resources look like this:
  89.         *VT100.Translations: #override \
  90.            Ctrl<Key>F1:  string(0x1b) string("[Q") \n\
  91.                <Key>F1:  string(0x1b) string("[q") \n\
  92.            Meta<Key>F2:  string(0x1b) string("[R") \n\
  93.         (...)
  94.      You choose what keys you will want to use to emulate the vt100
  95.      keypad and you build up you mapping.
  96.  
  97.      Here's a commented template you could use to build up your own
  98.      (comments (to be removed!) indicate vt100 key)
  99.      mappings:                                       REMOVE COMMENTS!
  100.         <Key>  :  string(0x1b) string("[P") \n\      pf1
  101.         <Key>  :  string(0x1b) string("[Q") \n\      pf2
  102.         <Key>  :  string(0x1b) string("[R") \n\      pf3
  103.         <Key>  :  string(0x1b) string("[S") \n\      pf4
  104.         <Key>  :  string(0x1b) string("[w") \n\      7
  105.         <Key>  :  string(0x1b) string("[x") \n\      8
  106.         <Key>  :  string(0x1b) string("[y") \n\      9
  107.         <Key>  :  string(0x1b) string("[m") \n\      -
  108.         <Key>  :  string(0x1b) string("[t") \n\      4
  109.         <Key>  :  string(0x1b) string("[u") \n\      5
  110.         <Key>  :  string(0x1b) string("[v") \n\      6
  111.         <Key>  :  string(0x1b) string("[l") \n\      ,
  112.         <Key>  :  string(0x1b) string("[q") \n\      1
  113.         <Key>  :  string(0x1b) string("[r") \n\      2
  114.         <Key>  :  string(0x1b) string("[s") \n\      3
  115.         <Key>  :  string(0x1b) string("[M") \n\      enter
  116.         <Key>  :  string(0x1b) string("[p") \n\      0
  117.         <Key>  :  string(0x1b) string("[n") \n       .
  118.      (note: last line has no \ to indicate continuation).
  119.  
  120.      Above mappings can be tested under the Bourne shell; they will
  121.      appear, for example, as ^[[n for the last mapping above.  Trying
  122.      out xxx on a real vt100 before this step can also help.
  123.  
  124.      NCD terminals fully emulate a vt100 keypad, that is they provide
  125.      the KP_ keys mentioned in the first approach.  No further setup is
  126.      required.
  127.  
  128. Enjoy
  129. -- 
  130. Pierre LEWIS    +1 514 765-8207      ESN 852-8207
  131. Internet: lew@bnr.ca                 Corwan: lewis@bnrmtl
  132.  
  133. Implementing standards is like walking on water -- both work best when frozen.
  134.