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