为什么terminfo [kcuu1] ='\ EOA'? [英] Why is terminfo[kcuu1] = '\EOA'?

查看:164
本文介绍了为什么terminfo [kcuu1] ='\ EOA'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,阅读terminfo(5)时,kcuu1应该是终端在按下向上箭头时发送的序列.我从未见过除^[[A以外的任何内容(现在谈论cat,弄乱终端设置等).因此,考虑到我使用的终端(rxvt,gnome-terminal,iTerm)全部默认为TERM = xterm,为什么kcuu1 \E[A不是?

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?

我看到cuu1 \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.

顺便说一下,这是在OS X上.

BTW this is with OS X.

推荐答案

箭头和其他特殊键(terminfo将其称为键盘")根据终端是否处于应用程序模式"而发送不同的代码.想要利用各种k*键的应用程序应该首先输出smkx(最后输出rmkx以恢复旧的行为).

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).

您可以在vi(或类似的终端应用程序)中尝试 Ctrl + V Up 来查看 Up 确实发送了\EOA在那里.

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:

  • Terminfo smkx and Application Cursor Keys vs Application keypad
  • http://invisible-island.net/xterm/xterm.faq.html#xterm_arrows

这篇关于为什么terminfo [kcuu1] ='\ EOA'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆