diff options
author | Timo Sirainen <cras@irssi.org> | 2002-03-14 23:46:48 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-03-14 23:46:48 +0000 |
commit | 6a89217d6a413c4f69c1396f711908fc746083e6 (patch) | |
tree | 36e57dda16152ad259539bbfae4d2a06a7851532 /src/fe-text/term.c | |
parent | 85a1b122cdec3edab5dda3cb015613f5ff793a9b (diff) | |
download | irssi-6a89217d6a413c4f69c1396f711908fc746083e6.zip |
Get the terminal size at startup with ioctl() and use it. Fixes at least
NetBSD.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2616 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-text/term.c')
-rw-r--r-- | src/fe-text/term.c | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/src/fe-text/term.c b/src/fe-text/term.c index a50fc8a3..94d81cfd 100644 --- a/src/fe-text/term.c +++ b/src/fe-text/term.c @@ -47,12 +47,31 @@ int term_type; static int force_colors; static int resize_dirty; -/* Resize the terminal if needed */ -void term_resize_dirty(void) +int term_get_size(int *width, int *height) { #ifdef TIOCGWINSZ struct winsize ws; + + /* Get new window size */ + if (ioctl(0, TIOCGWINSZ, &ws) < 0) + return FALSE; + + *width = ws.ws_col; + *height = ws.ws_row; + + if (*width < MIN_SCREEN_WIDTH) + *width = MIN_SCREEN_WIDTH; + if (*height < 1) + *height = 1; + return TRUE; +#else + return FALSE; #endif +} + +/* Resize the terminal if needed */ +void term_resize_dirty(void) +{ int width, height; if (!resize_dirty) @@ -60,27 +79,14 @@ void term_resize_dirty(void) resize_dirty = FALSE; -#ifdef TIOCGWINSZ - /* Get new window size */ - if (ioctl(0, TIOCGWINSZ, &ws) < 0) - return; + if (!term_get_size(&width, &height)) + width = height = -1; - if (ws.ws_row == term_height && ws.ws_col == term_width) { - /* Same size, abort. */ - return; + if (height != term_height || width != term_width) { + term_resize(width, height); + mainwindows_resize(term_width, term_height); + term_resize_final(width, height); } - - if (ws.ws_col < MIN_SCREEN_WIDTH) - ws.ws_col = MIN_SCREEN_WIDTH; - - width = ws.ws_col; - height = ws.ws_row; -#else - width = height = -1; -#endif - term_resize(width, height); - mainwindows_resize(term_width, term_height); - term_resize_final(width, height); } #ifdef SIGWINCH |