Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void get_cursor_position(int *col, int *rows)
- {
- int a = 0;
- int i = 0;
- char buf[4]
- write(1, "\033[6n", 4); // string asking for the cursor position
- read(1, buf, 4);
- while (buf[i])
- {
- if (buf[i] >= 48 && buf[i] <= 57)
- {
- if (a == 0)
- *rows = atoi(&buf[i]) - 1;
- else
- *col = atoi(&(buf[i]) - 1;
- a++;
- }
- i++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement