Anzahl der Zeilen der Console herausfinden
-
Wie finde ich die anzahl der Zeilen der Console heraus?
-
Mit man: termios. Aber genau wie, weiß ich selber nicht.
-
ioctl(TIOCGWINSZ)
-
int y = 0, x = 0; char *tty = NULL; int fd = 0; struct winsize win; // Determine lines and cols if (!(tty = ttyname(0))) printf_error(FATAL, "ttyname: %s", strerror(errno)); if ((fd = open(tty, O_RDWR)) == -1) printf_error(FATAL, "open: %s", strerror(errno)); if ((ret = ioctl(fd, TIOCGWINSZ, &win)) == -1) print_error(FATAL, "ioctl: %s", strerror(errno)); y = win.ws_row; x = win.ws_col; close(fd);
-
Danke, funktioniert wunderbar