Use ioctl to retreive screen's size in tresize. - irc - Unnamed repository; edi… | |
git clone git://vernunftzentrum.de/irc.git | |
Log | |
Files | |
Refs | |
README | |
--- | |
commit 61e93595f832ccc9a46428eaf398d776e482dfd2 | |
parent c5b6ac6afa188bd107bdbfb96500182447368b05 | |
Author: Quentin Carbonneaux <[email protected]> | |
Date: Sun, 11 Mar 2012 23:10:35 +0100 | |
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. | |
Diffstat: | |
irc.c | 11 ++++++++--- | |
1 file changed, 8 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/irc.c b/irc.c | |
@@ -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(); | |
} | |