2 * Copyright notice from original mutt:
3 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
5 * This file is part of mutt-ng, see http://www.muttng.org/.
6 * It's licensed under the GNU General Public License,
7 * please see the file GPL in the top level source directory.
10 #include <lib-lib/lib-lib.h>
12 #if defined(USE_SLANG_CURSES) || defined(HAVE_RESIZETERM)
15 #ifdef HAVE_SYS_IOCTL_H
16 # include <sys/ioctl.h>
17 #elif defined(HAVE_IOCTL_H)
21 #include <lib-ui/curses.h>
24 /* this routine should be called after receiving SIGWINCH */
25 void mutt_resize_screen (void)
31 #ifdef HAVE_RESIZETERM
32 int SLtt_Screen_Rows, SLtt_Screen_Cols;
35 SLtt_Screen_Rows = -1;
36 SLtt_Screen_Cols = -1;
37 if ((fd = open ("/dev/tty", O_RDONLY)) != -1) {
38 if (ioctl (fd, TIOCGWINSZ, &w) != -1) {
39 SLtt_Screen_Rows = w.ws_row;
40 SLtt_Screen_Cols = w.ws_col;
44 if (SLtt_Screen_Rows <= 0) {
45 if ((cp = getenv ("LINES")) != NULL) {
46 SLtt_Screen_Rows = atoi (cp);
49 SLtt_Screen_Rows = 24;
51 if (SLtt_Screen_Cols <= 0) {
52 if ((cp = getenv ("COLUMNS")) != NULL)
53 SLtt_Screen_Cols = atoi (cp);
55 SLtt_Screen_Cols = 80;
57 #ifdef USE_SLANG_CURSES
61 stdscr = newwin (0, 0, 0, 0);
62 keypad (stdscr, TRUE);
64 resizeterm (SLtt_Screen_Rows, SLtt_Screen_Cols);
68 #endif /* defined(USE_SLANG_CURSES) || defined(HAVE_RESIZETERM) */