Read screen character from terminal

前端 未结 1 1452
北恋
北恋 2021-01-21 02:36

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 un

相关标签:
1条回答
  • 2021-01-21 02:51

    That's expected (not "unexpected"):

    • tput gives values from a combination of the terminal database (fixed) and the operating system (changeable), but does not ask the terminal.
    • reading from the terminal is by an input stream from the device (what terminals are designed to do).

    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 [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.

    0 讨论(0)
提交回复
热议问题