For example, in a program I want to get current cursor position on terminal (tput u7
or \E[6n
on xterm):
CSI P s n
P s = 6 → Report Cursor Position (CPR) [row;column] as CSI r ; c R
I write this sequence to standard output in my program. After that I read the reply from terminal on standard input. (tty is in raw mode during this)
The question is: what if a user happens to input an escape sequence (by pressing some key) or a digit or anything right at the moment after request was sent but before reply was sent or in the midst of the reply? How was this feature supposed to work? Is this mechanism flawed, or I'm missing something?