Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想检测运行我的 CLI 程序的窗口何时变为活动/不活动。
具体来说,我的程序定期从服务器接收数据并将它们显示在终端窗口上。每当收到新数据时,我都会更改窗口的标题以通知用户。我想做的是在他看到这些新数据后重置窗口的名称。
我正在使用 python,但我想如果你有一个通用的解决方案,我可以继续。
某些终端,例如xterm让您将这些信息作为焦点事件获取。如果启用 DEC 模式 1004
xterm
CSI ? 1004 h
然后您将获得焦点/焦点事件发送为
CSI I # focus in CSI O # focus out