Change the escape sequence generated by xterm for key combinations

天大地大妈咪最大 提交于 2019-12-06 16:19:59

xterm can be configured to send custom strings when certain keys are pressed by modifying its translation table. The translation table is part of the X resource database managed by the xrdb command.

There's a good example of a customized translation table for xterm here. It can be copied into your $HOME/.Xdefaults or $HOME/.Xresources and it will be loaded the next time you log in. To load it into your current session immediately, xrdb -merge $HOME/.Xresources. This won't affect any xterms that are already running. (You might be able to change the translation table of a running xterm with editres, but that's more trouble than it's worth.)

To provide a custom translation table for a single instance of xterm, use the -xrm option, as in

xterm -xrm 'XTerm.VT100.translations: #override Ctrl<Key>Left: string(0x1b) string("b") \n Ctrl<Key>Right: string(0x1b) string("f")'

Not directly answering the question, but ESC O 5 P is a quite-wrong thing for a terminal to be sending.

In brief: ESC O, otherwise called SS3 short for Single Shift 3, is a sequence that modifies the next character sent, putting it in the G3 graphical area instead of the standard one. This would modify the 5 and send the P directly. This isn't and has never been a good idea.

The correct thing to send for Ctrl-F1 would be CSI 1;5 P, a form of CSI P (being the F1 key) with the second parameter set to 5 (being the modifier bitmask).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!