#include #include int main(void) { if (GetConsoleTask()) { BPTR fh = Open("CONSOLE:", MODE_OLDFILE); if (fh) { int dimsok = 0, width, height; int posok = 0, curx, cury; char report[25 + 1]; SetMode(fh, 1); // RAW mode if (Write(fh, "\x9b""0 q", 4) == 4) { LONG actual = Read(fh, report, sizeof(report) - 1); if (actual >= 0) { report[actual] = '\0'; if (sscanf(report, "\x9b""1;1;%d;%d r", &height, &width) == 2) { dimsok = 1; } } } if (Write(fh, "\x9b""6n", 3) == 3) { LONG actual = Read(fh, report, sizeof(report) - 1); if (actual >= 0) { report[actual] = '\0'; if (sscanf(report, "\x9b""%d;%dR", &cury, &curx) == 2) { curx--; /* position starts at 1,1 */ cury--; posok = 1; } } } SetMode(fh, 0); // Normal mode Close(fh); if (dimsok) { Printf("console dimensions: %ld x %ld\n", width, height); } if (posok) { Printf("cursor position: %ld, %ld\n", curx, cury); } } } return 0; }