- if (select(rt->pty + 1, &rfds, NULL, NULL, &tv) > 0) {
- if (madtty_process(rt))
- break;
+ if ((fd = open("/dev/tty", O_RDONLY)) != -1) {
+ if (ioctl(fd, TIOCGWINSZ, &w) != -1) {
+ rows = w.ws_row;
+ cols = w.ws_col;
+ }
+ close(fd);
+ }
+ if (rows <= 0) {
+ rows = atoi(getenv("LINES") ?: "24");
+ }
+ if (cols <= 0) {
+ cols = atoi(getenv("COLUMNS") ?: "80");
+ }
+
+ resizeterm(rows, cols);
+ madtty_resize(rt, rows - 2, cols - 2);
+ wresize(term_win, rows - 2, cols - 2);
+ sigwinch = 0;
+ erase();