Thread: xterm End key
View Single Post
  #2   (View Single Post)  
Old 24th August 2008
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 1,027
Default

This won't be a perfect answer to your question, but maybe it can get you started. In this kind of problem, the first thing I would do is go into the xterm shell and type
Code:
# cat > /dev/null
Then hit the key you're interested in, in this case End (you can also try Keypad-End), and see what you get. To break out of the cat use Ctrl-D.

For most keys this will show you what you're getting in the xterm when you hit the key. In my case with End I see:
Code:
^[[4~
(This is just how I've set the key up, you may see something different.) The first ^[ really indicates Escape, it's a sequence of Escape [ 4 ~ .

Then you have to get your editor to use this. Never used le, but for emacs I put in my ~/.emacs file:
Code:
(global-set-key "\e[4~" 'move-to-window-end)    ; for xterm
Here "move-to-window-end" is the function I want on that key (it's a function I defined elsewhere).

The other question is where does the ^[[4~ come from? You can set this up in your ~/.Xresources file. Mine includes the following:
Code:
*VT100.Translations: #override \
              !<Key>BackSpace:    string(0x7F) \n\
              !<Key>KP_Begin:     string(0x1b) string("[G") \n\
              !<Key>Home:         string(0x1b) string("[1~") \n\
              !<Key>KP_Home:      string(0x1b) string("[1~") \n\
              <Key>Insert:        string(0x1b) string("[2~") \n\
              !<Key>KP_Insert:    string(0x1b) string("[2~") \n\
              <Key>Delete:        string(0x1b) string("[3~") \n\
              !<Key>KP_Delete:    string(0x1b) string("[3~") \n\
              !<Key>End:          string(0x1b) string("[4~") \n\
              !<Key>KP_End:       string(0x1b) string("[4~") \n\
              c<Key>Home:         string(0x1b) string("[35~") \n\
              c<Key>KP_Home:      string(0x1b) string("[35~") \n\
  etc. etc.
You shouldn't copy this verbatim, it's just an example, but you can see where the ^[[4~ comes from. In the .Xresources file "string(0x1b)" represents Escape character.

Hope this helps a bit.

Last edited by IdOp; 24th August 2008 at 04:59 PM. Reason: glitches
Reply With Quote