I'm trying to retrieve the coordinates of cursor in a VT100 terminal using the following code:
void getCursor(int* x, int* y) {
printf("33[6n");
scanf("33[%d;%dR", x, y);
}
I'm using the following ANSI escape sequence:
Device Status Report - ESC[6n
Reports the cursor position to the
application as (as though typed at the keyboard) ESC[n;mR, where n is
the row and m is the column.
The code compiles and the ANSI sequence is sent, but, upon receiving it, the terminal prints the ^[[x;yR
string to the stdout
instead of stdin
making it imposible for me to retrieve it from the program:
Clearly, the string is designated for the program, though, so I must be doing something incorrectly. Does anybody know what it is?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…