I'm writing a terminal program on the Kindle Paperwhite 2. I compile using tcc. I use linux. I want to implement functions such as gotoxy(x,y)
and the Mouse.
To move the cursor, I need to send control codes. I found I use printf like this:
printf("\033[%d;%dH",y,x);
The problem is how to receive control codes sent back to me from the terminal. I'm reading this document
I wrote the following code:
printf("\033[?9h");//this turns on the mouse in the terminal
while (1)
{
printf("\n");
sleep(1);
}
Using scanf or getch() doesn't capture anything.
Now every time I click, I see a code on the screen (like "^[[M 9.").
It's as if the code doesn't get printed unless a newline is printer.
I need to be able to capture the last two characters as decimals which i think is the xy of the screen.
Can someone help?
Thanks