问题描述
我的目标是建立一个终端,使命令行界面程序的行为与键盘输入预期的一样(该程序最初是为Windows用xharbour编写的,但现在我想将其移植到linux).我选择xterm是因为它更简单,因此无需禁用默认终端键组合.
My goal is to set up a terminal in which a command-line interface program would behave as expected for the keyboard inputs (the program is written in xharbour originally for Windows but now I would like to port it to linux).I have chosen xterm to start with as it is simpler, no need for disabling default terminal key combinations.
对于腻子,大多数字符都能很好地工作,对于那些不使用腻子的字符,我可以使用autohotkey,一个ahk脚本来完成.例如,对于Ctrl + F1:^F1::SendInput ^[O5P
With putty most of the characters work out well and for those that don't I use autohotkey, an ahk script and that does the job. For example, for Ctrl+F1:^F1::SendInput ^[O5P
我尝试并修改,重新编译terminfo,对其进行更改并更改了键盘类型,但无法获得在终端中按Ctrl + F1的^ [O5P响应.如果您知道进行此更改的任何方式,请告诉我...我已经阅读了数百页本应执行的操作,但是所有这些更改均未产生任何效果或没有达到预期的效果.
I tried and modified, recompiled the terminfo, changed it and changed the keyboard types but could not achieve to get a ^[O5P response for pressing Ctrl+F1 in terminal.If you know any way of doing this change, please tell me... I have read trough hundreds of pages that supposedly do this but all those changes did not made any effect or not the expected effect.
因此,我离开尝试修改终端设置以实现Ctrl + F1达到^ [O5P目标,并尝试了一些与autohotkey类似的命令和程序:
So I left trying to modify the terminal settings to achieve my Ctrl+F1 to ^[O5P goal and tried some commands and programs that would do something similar to autohotkey:
-
xmodmap
,但是对于组合键不起作用 -
xdotool
激活xyz类型^ [O5P,这将返回各个字符的字符代码 -
xmacro
,它不会将击键发送到其他窗口 -
ironahk
,尝试运行example.ahk时我一开始就出现错误,并且在其简易手册中找不到我想要的命令. -
bind '\e[1;5P":"\e[O5P"'
,这里的第一个键码是我现在输入ctrl + f1时得到的,而在我希望通过此组合得到的键码之后.没有效果. -
xbindkeys
+xvkbd
都没有帮助.
xmodmap
, but for key combinations it's not workingxdotool
windowactivate xyz type ^[O5P, this returns the char codes of individual charactersxmacro
, it doesn't send keystrokes to other windowironahk
, I get an error right at the start with trying to run the example.ahk and couldn't find the commands that I wished for in its light manual.bind '\e[1;5P":"\e[O5P"'
, here the first keycode is what I currently get when typing ctrl+f1 and after the one that I wish to get by this combination. No effect.xbindkeys
+xvkbd
, didn't helped either.
如果您已经知道,请帮助我,设法以某种方式实现了这一目标(更改为组合键返回的键码).
Please help me if you already know, managed somehow to achieve this (change the key code returned for a key combination).
我使用最新的CentOS和Ubuntu进行测试.
I use the latest CentOS and Ubuntu for testing.
推荐答案
可以通过修改翻译表将xterm配置为在按下某些键时发送自定义字符串.转换表是由xrdb
命令管理的X资源数据库的一部分.
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.
在xterm 此处.可以将其复制到$HOME/.Xdefaults
或$HOME/.Xresources
中,并在下次登录时加载.要立即将其加载到当前会话中,请按xrdb -merge $HOME/.Xresources
键.这不会影响任何已经在运行的xterm. (您也许可以使用editres
更改正在运行的xterm的转换表,但这比其应有的麻烦还要多.)
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.)
要为xterm的单个实例提供自定义转换表,请使用-xrm
选项,如
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")'
这篇关于更改xterm为组合键生成的转义序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!