从终端读取屏幕字符 [英] Read screen character from terminal

查看:36
本文介绍了从终端读取屏幕字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我研究,terminfo/termcapioctl 不允许在终端的 (x,y) 位置查询字符屏幕.这是相当出乎意料的,因为:

As far I researched, terminfo/termcap and ioctl don't allow to query character at (x,y) position on terminal's screen. This is rather unexpected, because:

  • 可以阅读例如终端的屏幕尺寸(例如 tput cotput li)、
  • 可以从终端读取输入

——两者表示与终端的通信是双向的.真的没有办法在给定位置查询字符,比如 *inch*, *in_wch* 诅咒函数(仅适用于诅咒窗口)?

– the two mean that communication with terminal is bidirectional. Is there really no way to query a character at given position, like with *inch*, *in_wch* curses functions (which work only for curses windows)?

推荐答案

这是意料之中的(不是意料之外的"):

That's expected (not "unexpected"):

  • tput 给出来自终端数据库(固定)和操作系统(可变)的组合,但不询问终端.
  • 从终端读取是通过来自设备的输入流(终端的设计目的).

一些(不是全部)终端支持转义序列,询问终端光标在哪里.resize 程序使用它来获取屏幕尺寸.但请记住,正如手册页中所述,已知它依赖于终端:

Some (not all) terminals support an escape sequence which asks the terminal where the cursor is. The resize program uses that to obtain the screensize. But keep in mind that it is known to be terminal-dependent, as mentioned in the manual page:

-s [行列]
此选项表示 Sun 控制台转义序列将用于代替 VT100 风格的 xterm 转义码.

-s [rows columns]
This option indicates that Sun console escape sequences will be used instead of the VT100-style xterm escape codes.

很少有终端支持转义序列,它只会从屏幕上读取字符.不是每个人都喜欢可以读取他们屏幕的程序的概念—也许在他们不知情的情况下.

Very few terminals support an escape sequence which will simply read characters from the screen. Not everyone likes the notion of a program that can read their screen — perhaps without their knowledge.

这篇关于从终端读取屏幕字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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