1 /* Handle window size changes and information. */
3 /* Copyright (C) 2005 Free Software Foundation, Inc.
5 This file is part of GNU Bash, the Bourne Again SHell.
7 Bash is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License along
18 with Bash; see the file COPYING. If not, write to the Free Software
19 Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
25 #include "bashtypes.h"
27 #if defined (HAVE_UNISTD_H)
31 #include <sys/ioctl.h>
33 #if !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
34 /* For struct winsize on SCO */
35 /* sys/ptem.h has winsize but needs mblk_t from sys/stream.h */
36 # if defined (HAVE_SYS_PTEM_H) && defined (TIOCGWINSZ) && defined (SIGWINCH)
37 # if defined (HAVE_SYS_STREAM_H)
38 # include <sys/stream.h>
40 # include <sys/ptem.h>
41 # endif /* HAVE_SYS_PTEM_H && TIOCGWINSZ && SIGWINCH */
42 #endif /* !STRUCT_WINSIZE_IN_SYS_IOCTL */
46 /* Return the fd from which we are actually getting input. */
47 #define input_tty() (shell_tty != -1) ? shell_tty : fileno (stderr)
55 #if defined (READLINE)
56 extern void rl_set_screen_size __P((int, int));
60 get_new_window_size (from_sig, rp, cp)
64 #if defined (TIOCGWINSZ)
69 if (tty >= 0 && (ioctl (tty, TIOCGWINSZ, &win) == 0) &&
70 win.ws_row > 0 && win.ws_col > 0)
72 sh_set_lines_and_columns (win.ws_row, win.ws_col);
73 #if defined (READLINE)
74 rl_set_screen_size (win.ws_row, win.ws_col);