diff options
| author | Quentin Carbonneaux | 2012-03-11 23:10:35 +0100 |
|---|---|---|
| committer | Quentin Carbonneaux | 2012-03-11 23:10:35 +0100 |
| commit | 61e93595f832ccc9a46428eaf398d776e482dfd2 (patch) | |
| tree | f113057541f242c1c829f3601146e0491d459f29 | |
| parent | c5b6ac6afa188bd107bdbfb96500182447368b05 (diff) | |
Use ioctl to retreive screen's size in tresize.
The curses (ncurses) library does not automatically get the new size of
the terminal, thus, we must rely on an ioctl to retreive it and inform
ncurses with a resizeterm call.
| -rw-r--r-- | irc.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -16,6 +16,7 @@ #include <sys/types.h> #include <sys/socket.h> #include <sys/select.h> +#include <sys/ioctl.h> #include <netinet/in.h> #include <netinet/tcp.h> #include <netdb.h> @@ -347,13 +348,17 @@ tinit(void) static void tresize(void) { + struct winsize ws; + winchg=0; - getmaxyx(stdscr, scr.y, scr.x); - if (scr.y<3 || scr.x<10) panic("Screen too small."); + ioctl(0, TIOCGWINSZ, &ws); + resizeterm(scr.y=ws.ws_row, scr.x=ws.ws_col); + if (scr.y<3 || scr.x<10) + panic("Screen too small."); wresize(scr.mw, scr.y-2, scr.x); wresize(scr.iw, 1, scr.x); wresize(scr.sw, 1, scr.x); - mvwin(scr.iw, scr.y-1, 1); + mvwin(scr.iw, scr.y-1, 0); tredraw(); } |
