ttyterminfotermcap

Why is terminfo[kcuu1] = '\EOA'?


From what I can tell reading terminfo(5), kcuu1 should be the sequence that the terminal sends when the up arrow is pressed. I have never, ever seen that be anything other than ^[[A (speaking now about cat, messed up terminal settings, etc). So, given that the terminals I've used (rxvt, gnome-terminal, iTerm) all default to TERM=xterm, why isn't kcuu1 \E[A?

I see that cuu1 is \E[A, but (from the man page, again), that's the string that I should send to the terminal to move the cursor, not a string the terminal sends to me.

BTW this is with OS X.


Solution

  • Arrow and other special keys (terminfo refers to them as "keypad") send different codes depending on whether the terminal is in "application mode" or not. An application that wants to make use of the various k* keys is supposed to output smkx first (and rmkx at the end to restore the old behavior).

    You can try Ctrl+V Up in vi (or a similar terminal application) to see that Up does indeed send \EOA there.

    See these links for more details: