- if(tcgetattr(ttyfd, &term) == -1) {
- perror("failed to get terminal attr");
- return -1;
- }
- saved_term = term;
- term.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
- term.c_oflag &= ~OPOST;
- term.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
- term.c_cflag = (term.c_cflag & ~(CSIZE | PARENB)) | CS8;
-
- if(tcsetattr(ttyfd, TCSAFLUSH, &term) == -1) {
- perror("failed to change terminal attributes");
- return -1;
- }
-
- ioctl(1, TIOCGWINSZ, &winsz);
- term_width = winsz.ws_col;
- term_height = winsz.ws_row;
-
- signal(SIGWINCH, sighandler);
-
- write(ttyfd, "\033[2J", 4);
-