Advertisement
Guest User

80x24 changer

a guest
May 22nd, 2011
1,587
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. //by Wiesław Herr <herself at makhleb.net>, distributed under the MIT license
  2. //this program changes the terminal size to 80x24 regardless of the actual window size
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. #ifdef __linux
  7. #include <pty.h>
  8. #else //*bsd
  9. #include <sys/ttycom.h>
  10. #endif
  11.  
  12. int main(int argc, const char *argv[])
  13. {
  14.     struct winsize ws;
  15.     int ret;
  16.  
  17.     ret = ioctl(0, TIOCGWINSZ, &ws);
  18.     if(ret < 0){
  19.         perror("ioctl");
  20.         return 1;
  21.     }
  22.     printf("Current window size: %dx%d\n", ws.ws_col, ws.ws_row);
  23.  
  24.     ws.ws_col=80;
  25.     ws.ws_row=24;
  26.     ws.ws_xpixel=0;
  27.     ws.ws_ypixel=0;
  28.  
  29.     ioctl(0, TIOCSWINSZ, &ws);
  30.     if(ret < 0){
  31.         perror("ioctl");
  32.         return 1;
  33.     }
  34.     printf("Window size reset!\n");
  35.  
  36.     ioctl(0, TIOCGWINSZ, &ws);
  37.     if(ret < 0){
  38.         perror("ioctl");
  39.         return 1;
  40.     }
  41.     printf("Current window size: %dx%d\n", ws.ws_col, ws.ws_row);
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement