home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / HOWTO / MINI / BACKSPAC < prev    next >
Encoding:
Internet Message Format  |  1995-04-20  |  7.1 KB

  1. Date: Fri, 11 Nov 1994 16:41:22 -0500
  2. From: S. Lee <sl14@crux5.cit.cornell.edu>
  3. To: comp-os-linux-announce@uunet.uu.net
  4. Newgroups: comp.os.linux.announce, comp.os.linux.help, comp.os.linux.misc
  5. Subject: Backspace Mini-HOWTO
  6.  
  7. The Linux BackSpace Mini-HOWTO
  8. by Stephen Lee
  9. $Id: Backspace-Mini-HOWTO,v 1.0 1994/11/11 21:37:05 slee Rel $
  10.  
  11. ===============
  12. 0. Introduction
  13. ===============
  14.  
  15. This Mini-HOWTO document describes setting up the keyboard to handle the
  16. <BackSpace> and <Delete> keys properly.  It has been annoying to me that
  17. those keys had not work consistently across different programs, so I took
  18. one afternoon and tried to fix all that.  Here I document my experience so
  19. others would not need to go through the same tedious cycle I did.
  20.  
  21. I'm using Slackware 2.0.0, so pathnames to files might be different from
  22. yours if you are using a different distribution.
  23.  
  24. ==============
  25. 1. Terminology
  26. ==============
  27.  
  28. <BackSpace> 
  29.     The key on the keyboard marked "Backspace" or "<--" (not to
  30.     confused with the left arrow on the cursor pad or keypad).
  31.  
  32. <Delete>
  33.     The key on the cursor pad marked "Delete", or the key marked "Del"
  34.     on the numeric keypad when NumLock is off.
  35.  
  36. BS
  37.     ASCII character 0x08, or control-h.
  38.  
  39. DEL
  40.     ASCII character 0x7F.
  41.  
  42. ^D
  43.     ASCII character 0x04, or control-d.
  44.  
  45. [BackSpace]
  46.     A X11 keysym.
  47.  
  48. [Delete]
  49.     Another X11 keysym.
  50.  
  51. ===============
  52. 2. Basic Issues
  53. ===============
  54.  
  55. I assume you came from the DOS world like I did, and is used to the
  56. mapping of function that <BackSpace> deletes character to the left of the
  57. cursor and <Delete> deletes character on top of the cursor.
  58.  
  59. The most intuitive mapping is <BackSpace> -> BS and <Delete> -> DEL.  This
  60. is fine unless you want to use EMACS.  EMACS map control-h to its help
  61. function, which, under ASCII, is unfortunately BS.  So each time you want
  62. to erase a character backwards, you invoke the help system.  (Hint: to
  63. remove the question if you're not that far, press <control-g>.  if you have
  64. pressed other keys, you might need to press <ctrl-x> then <1> to remove
  65. the help screen.)  By the way, DEL under EMACS deletes BACKWARDS, like
  66. what you'd expect for BS.
  67.  
  68. One choice is to remap the keys under EMACS.  Unfortunately you'll lose the
  69. "<control-h> = help" mapping, and you'll have to do that to every EMACS you
  70. want to access, which is a pain.
  71.  
  72. So, I decided to map <BackSpace> -> DEL and <Delete> -> ^D.  This would work
  73. for both EMACS and csh, and a EMACS across a telnet or rlogin connection.
  74. Now you can use the <Delete> key for editing the command line also!  (Before
  75. it does the same thing as <BackSpace>.)
  76.  
  77. =============================================
  78. 3. How to do it under text mode (non-X setup)
  79. =============================================
  80.  
  81. You need to have the "loadkeys" program from the kbd package.  I believe
  82. you should have it if you're running Slackware.
  83.  
  84. Another file you want is /usr/lib/kbd/keytables/*.map.  Choose one that is
  85. closest to your setup (it would be /usr/src/linux/drivers/char/defkeymap.map
  86. if you have the kernel source).
  87.  
  88. The keycodes are 14 <BackSpace>, 83 <Keypad Del> , 111 <Cursor pad Delete>.
  89. If you have slackware you should already have the following:
  90.  
  91.     keycode  14 = Delete           Delete          
  92.             alt     keycode  14 = Meta_Delete     
  93.  
  94.     keycode  83 = KP_Period       
  95.             altgr   control keycode  83 = Boot            
  96.             control alt     keycode  83 = Boot            
  97.  
  98.     keycode 111 = Remove          
  99.             altgr   control keycode 111 = Boot            
  100.             control alt     keycode 111 = Boot            
  101.  
  102.     string Remove = "\033[3~"
  103.  
  104. All you need to do is to replace the last line with
  105.  
  106.     string Remove = "\004"
  107.  
  108. and now you have both mapping under text mode after you run loadkeys:
  109.  
  110.     Nekomi% loadkeys whatever.map
  111.     ^^^^^^^
  112.     Shell prompt
  113.  
  114. Note that this command changes the mapping for ALL Virtual Consoles.  You
  115. might want to put this in your /etc/rc.d/rc.local so that it is run every
  116. time you reboot.
  117.  
  118. You'll need to make sure that Linux know which key your <BackSpace> is, so
  119. do the following on your shell prompt:
  120.  
  121.     Nekomi% stty erase '^?'
  122.                             ^^
  123.                             can be "^" then "?", or 
  124.                             type <control-v><BackSpace>
  125.  
  126. You might want to put it in your ~/.login or ~/.profile.
  127.  
  128. =======================================
  129. 4. How to do it under XFree86 (General)
  130. =======================================
  131.  
  132. I'm using XFree86 2.1, but the procedure should be the same for other
  133. versions.
  134.  
  135. You need xmodmap which should be included with your XFree86.
  136.  
  137. We want to map <BackSpace> -> [BackSpace] and <Delete> -> [Delete] here.
  138. So put the following in your .xinitrc:
  139.  
  140.     xmodmap -e "keycode 22 = BackSpace"
  141.     xmodmap -e "keycode 107 = Delete"
  142.  
  143. Alternatively, you might generate a map file from your whatever.map using
  144. /usr/lib/kbd/keytables/mk_modmap:
  145.  
  146.     mk_modmap whatever.map > whatever.xmap
  147.  
  148. I think you need to remove all the "compose" command in the output, then
  149. you can use
  150.  
  151.     xmodmap whatever.xmap
  152.  
  153. to load the keymap.  Note that <BackSpace> would be mapped to [Delete]
  154. this way (if you use the same whatever.map for text mode), so be sure to
  155. edit whatever.xmap for keycode 22 and 107.
  156.  
  157. ===========================
  158. 4.1 Setting up GNU EMACS 19
  159. ===========================
  160.  
  161. GNU EMACS 19 has some X support built in.  To make [Delete] work the way
  162. you expect, put this in your ~/.emacs file:
  163.  
  164.     (cond (window-system
  165.            (define-key function-key-map [delete] "\C-d")
  166.         ))
  167.  
  168. while you are at it, you can map more keys like [F1] etc.  I think most
  169. of the keypad is already set up so you can use <Home> <End> <PgUp> <PgDn>
  170. etc. already.
  171.  
  172. Now you can use both <BackSpace> and <Delete>, and <control-h> will bring
  173. up the help.
  174.  
  175. You can find out want keycode and keysym a key sends using "xev" from
  176. your shell under X.
  177.  
  178. ====================
  179. 4.2 Setting up xterm
  180. ====================
  181.  
  182. "xterm" and "color_xterm" has their own mappings different from the text
  183. mode settings.  To change them, put this in your ~/.Xdefaults:
  184.  
  185.     .XTerm.VT100.Translations: #override <Key>BackSpace: string(0x7F)\n\
  186.             <Key>Delete:    string(0x04)\n\
  187.             <Key>Home:      string(0x1b) string("[1~")\n\
  188.             <Key>End:       string(0x1b) string("[4~")
  189.  
  190. Remember to restart your xterm and use the "stty erase '^?'" command.
  191.  
  192. This maps [BackSpace] -> DEL and [Delete] -> ^D, just like in text mode
  193. so it works for non-X EMACS (try "emacs -nw") or across telnet/rlogin.
  194.  
  195. It works for most xterm-derived terminals as well, like color_xterm or
  196. kterm.
  197.  
  198. This also changes the mapping for [Home] and [End] so they send different
  199. codes.  So I can use them in "less" :)
  200.  
  201. (Hint: look up the man page for lesskey(1) for setting up cursor pad keys
  202. for "less".  I think they are already set up under Slackware)
  203.  
  204. ==============
  205. 5. Misc. stuff
  206. ==============
  207.  
  208. - I don't know how to change the mapping under "rxvt".
  209.  
  210. - when you telnet/rlogin to a remote UNIX machine, make sure it knows
  211.   your setting by issuing "stty erase '^?'".
  212.  
  213. - although csh/tcsh treats BS and DEL the same way, other programs don't.
  214.   So your mapping might seem to work under csh/tcsh but you get wierd
  215.   stuff like ^? under some programs.  Solution: remember the "stty"
  216.   command above.
  217.  
  218.  
  219.  
  220.