如何获得的MouseMove和鼠标点击在bash? [英] how to get MouseMove and MouseClick in bash?

查看:376
本文介绍了如何获得的MouseMove和鼠标点击在bash?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何让bash脚本编程的鼠标点击和mousemove事件对我自己简单的操作系统事件。

I'm wondering how to get the MouseClick and MouseMove events in bash scripting for my own simple OS events.

请告诉我怎么去的事件。

Please tell me how to get that events.

推荐答案

在xterm终端仿真器定义了一些控制序列做鼠标跟踪,您可以了解更多关于他们在一节的鼠标跟踪 ctlseqs 的xterm的分布。如果您已经安装的xterm,你可能必须在 /usr/share/doc/xterm/ctlseqs.txt.gz 复制或类似的路径。

The xterm terminal emulator defines some control sequences to do mouse tracking, you can learn more about them in the section Mouse Tracking in the document ctlseqs for the xterm distribution. If you have xterm installed, you'll probably have a copy at /usr/share/doc/xterm/ctlseqs.txt.gz or a similar path.

在X Window系统上运行大多数终端仿真程序(例如:的Konsole,GNOME终端,ETERM,...)至少了解一些这些控制序列。如果您想直接在Linux上的虚拟终端之一使用它们,你可能需要运行 GPM(8)

Most terminal emulators running on the X Window System (e.g: Konsole, gnome-terminal, eterm, ...) understand at least some of these control sequences. If you want to use them directly on one of Linux's virtual terminals, you'll probably have to run gpm(8).

有启用和禁用鼠标移动报告的几个控制序列:

There are several control sequences for enabling and disabling mouse movement reporting:


  • 9 - > X10鼠标报告,与X10的xterm的兼容性,按钮preSS报告

  • 1000 - > X11鼠标报告,按钮preSS和发布的报告

  • 1001 - >亮点的报告,报告鼠标的亮点有用

  • 1002 - >按钮运动的报告,报告运动当按钮是pressed

  • 1003 - >所有运动的报告,报告所有动作

控制序列是 CSI?数H 启用和 CSI?数l 禁用。 CSI要么是 ESC [或字符 0x9b 。所以,你可以按如下方式使用它们:

The control sequence is CSI ? number h for enabling and CSI ? number l for disabling. CSI is either ESC [ or character 0x9b. So, you could use them as follows:

echo -e "\e[?1000h"

然后,你会得到一串字符按钮preSS,请参阅 ctlseqs console_ codeS(4)了解详情。然后,您可以禁用鼠标跟踪与

Then, you'll get a bunch of characters on button press, see ctlseqs or console_codes(4) for details. Then, you can disable mouse tracking with:

echo -e "\e[?1000l"

不幸的是,previous鼠标报告模式只能手柄坐标到223(255 - 32),或在某些情况下,95(127 - 32)。因此,有一些新的交换机,以更改鼠标坐标报告的格式为:

Unfortunately, the previous mouse reporting modes can only handle coordinates up to 223 (255 - 32), or in some situations 95 (127 - 32). So there are some new switches to change the format in which mouse coordinates are reported:


  • 1006 - >报告早在十进制值(xterm中,许多其他终端仿真器,但不urxvt)

  • 1015 - >报告早在十进制值(urxvt,xterm中,其他的终端模拟器,一些应用发现它的复杂解析)

  • 1005 - >报表重新连接codeD为UTF-8(xterm中,urxvt,以多种方式打破)

有关申请一个很好的策略是使鼠标的报告,然后(可选要求urxvt 1015模式,然后)要求SGR 1006模式。申请应同时处理新的和传统的鼠标报告的反应,继续在终端仿真器工作而无需为新模式的支持。

A good strategy for an application would be to enable mouse reporting, then (optionally request urxvt 1015 mode and then) request SGR 1006 mode. The application should handle both the new and legacy mouse reporting responses, to continue working on terminal emulators without support for the new modes.

在上新的报告模式的详细信息:

More information on the new reporting modes at:

  • midnight-commander ticket #2956
  • tmux ticket #26
  • midnight-commander ticket #2662

这篇关于如何获得的MouseMove和鼠标点击在bash?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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