终端的轻量级事件包装器 [英] Lightweight event wrapper for the terminal

查看:76
本文介绍了终端的轻量级事件包装器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我相信这是ncurses库的领域.我尽力避免不得不摔倒和弄脏它.

I believe this is the realm of the ncurses library. I'm trying to avoid having to get down and dirty with it though.

我正在寻找一个程序,该程序可以配置为在执行终端鼠标报告转换为按键时运行命令.

I'm looking for a program that I can configure to run a command while performing terminal mouse reporting translation to keypresses.

这是与不那么传呼机一起使用的.

This is for use with pagers like less.

例如,Terminal.app的MouseTerm SIMBL插件正是这样做的.

For example the MouseTerm SIMBL plugin for Terminal.app does exactly this.

但是iTerm2没有.我想要.

But iTerm2 does not. And I want it.

我认为答案可能与直接重新映射代码一样简单.

I think the answer may be as simple as directly remapping the codes.

似乎有转义码可以将终端切换为鼠标监听模式,而鼠标单击转义码实际上似乎包含字符坐标.我可以在Vim中使用Ctrl + V来查看它们,因为我已经告诉vim打开鼠标.

It looks like there are escape codes to switch the terminal into and out of mouse-listening mode, and mouse click escape codes actually seem to include the character coordinates. I can look at them with Ctrl+V inside of Vim because I have told vim to turn on the mouse.

它看起来像这样:

Note ^[ denotes escape (you can type escape by typing ctrl+[)

left click: ^[[M !!
right click: ^[[M"!!
middle click: ^[[M!!!
scroll up: ^[[M`!!
scroll down: ^[[Ma!!

根据文档,这确实与鼠标滚轮代码比鼠标滚轮代码多64个匹配(我喜欢此页面).

So that does match up with the mouse wheel button codes being 64 more than the mouse button ones according to documentation (I like this page).

现在,我已经掌握了需要将什么代码映射到我只需要了解如何获取可以过滤输入的图层的知识.

Now that I'm armed with the knowledge of what codes I need to map to what I just need to find out how to get a layer that lets me filter the input.

这显然使我顿悟.我只需要一个简单的非行缓冲程序即可侦听鼠标转义码并将其替换为键码.当然,Perl Term::ReadKey可以让我设置原始模式并完成几乎琐碎的任务.

This has apparently led me to an epiphany. I simply need a simple non-line-buffering program that listens for mouse escape codes and replaces them with key codes. Surely Perl Term::ReadKey will let me set raw mode and do this nearly trivial task.

推荐答案

这东西很难.我一直在通过配置Tmux来处理事情.

This stuff is difficult. I've been making do by configuring Tmux to handle things.

这篇关于终端的轻量级事件包装器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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