问题
在终端仿真器中,是否有可能在莫苏事件发生时运行命令?
我试过什么
我想我已经走到一半了--使用echo -e "\e[?1003h" (详细信息见here )并在终端上挥动鼠标会产生一种与发生的鼠标事件相关的打印大量字符的理想效果。(注:echo -e "\e[?1003l"关闭此功能)
echo -e "\e[?1003h"
# move mouse over terminal window, in the character input line, NOT to stdout:
> CF*CC+C@,C;.C:/C8/C8/C8/C8/C9/C9/C9/C90C90C80C81C81C81C81C81C90C:/C;/C;.C<.C<.
# After deleting that, I enter:
> echo -e "\e[?1003l"
# mouse move, all is quiet我还尝试将其连接到输出到文件中。这是为了看看我是否可以查看文件并根据该文件运行一个命令。其内容如下:
> echo -e "\e[?1003h" >> file.txt
# elevator music whilst I move the mouse about
> echo -e "\e[?1003l"
# move mouse a bit, nothing
> cat file.txt
# nothing but blank lines, fair enough. But, mouse moves and in the terminal input is printed...
> CF*CC+C@,C;.C:/C8/C8/C8/C8/C9/C9/C9/C90C90C8 ...
# Delete that output, and then I type:
> echo -e "\e[?1003l"
# mouse moves, no output我想要什么
我怎样才能捕获这个输出,这样它就会转到stdout,或者到一个文件,这样我就可以使用更改的输出来触发运行命令了?如果这是不可能的,那么在终端模拟器中使用事件坐标进行鼠标单击时,还有其他方法来捕获吗?
发布于 2018-08-18 18:09:17
不是输出,而是输入。
在bash中有多种读取输入的方法。这里有一个能读到一切直到停止的东西:
echo -e "\e[?1003h"
echo "Press enter and then ctrl-d to stop reading"
cat > myfile使用Enter和Ctrl+D完成并正确退出时,您可以检查myfile以查看所有鼠标事件。
在从终端读取和解码转义序列之前,适当的鼠标应用程序将禁用本地回波和终端缓冲。
https://stackoverflow.com/questions/51909557
复制相似问题