Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //by Wiesław Herr <herself at makhleb.net>, distributed under the MIT license
- //this program changes the terminal size to 80x24 regardless of the actual window size
- #include <stdio.h>
- #include <stdlib.h>
- #ifdef __linux
- #include <pty.h>
- #else //*bsd
- #include <sys/ttycom.h>
- #endif
- int main(int argc, const char *argv[])
- {
- struct winsize ws;
- int ret;
- ret = ioctl(0, TIOCGWINSZ, &ws);
- if(ret < 0){
- perror("ioctl");
- return 1;
- }
- printf("Current window size: %dx%d\n", ws.ws_col, ws.ws_row);
- ws.ws_col=80;
- ws.ws_row=24;
- ws.ws_xpixel=0;
- ws.ws_ypixel=0;
- ioctl(0, TIOCSWINSZ, &ws);
- if(ret < 0){
- perror("ioctl");
- return 1;
- }
- printf("Window size reset!\n");
- ioctl(0, TIOCGWINSZ, &ws);
- if(ret < 0){
- perror("ioctl");
- return 1;
- }
- printf("Current window size: %dx%d\n", ws.ws_col, ws.ws_row);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement