diff --git a/lib/tty/tty-ncurses.c b/lib/tty/tty-ncurses.c index 7481a3e00..1b88e7ae1 100644 --- a/lib/tty/tty-ncurses.c +++ b/lib/tty/tty-ncurses.c @@ -34,6 +34,10 @@ #include #include #include +#ifdef HAVE_SYS_IOCTL_H +#include +#endif +#include #include "lib/global.h" #include "lib/strutil.h" /* str_term_form */ @@ -224,6 +228,36 @@ tty_shutdown (void) /* --------------------------------------------------------------------------------------------- */ +void +tty_change_screen_size (void) +{ +#if defined(TIOCGWINSZ) && NCURSES_VERSION_MAJOR >= 4 + struct winsize winsz; + + winsz.ws_col = winsz.ws_row = 0; + +#ifndef NCURSES_VERSION + tty_noraw_mode (); + tty_reset_screen (); +#endif + + /* Ioctl on the STDIN_FILENO */ + ioctl (fileno (stdout), TIOCGWINSZ, &winsz); + if (winsz.ws_col != 0 && winsz.ws_row != 0) + { +#if defined(NCURSES_VERSION) && defined(HAVE_RESIZETERM) + resizeterm (winsz.ws_row, winsz.ws_col); + clearok (stdscr, TRUE); /* sigwinch's should use a semaphore! */ +#else + COLS = winsz.ws_col; + LINES = winsz.ws_row; +#endif + } +#endif /* defined(TIOCGWINSZ) || NCURSES_VERSION_MAJOR >= 4 */ +} + +/* --------------------------------------------------------------------------------------------- */ + void tty_reset_prog_mode (void) { diff --git a/lib/tty/tty-slang.c b/lib/tty/tty-slang.c index 6b7fd32f7..3554bc507 100644 --- a/lib/tty/tty-slang.c +++ b/lib/tty/tty-slang.c @@ -34,10 +34,13 @@ #include #include #include -#include #include /* size_t */ #include #include +#ifdef HAVE_SYS_IOCTL_H +#include +#endif +#include #include "lib/global.h" #include "lib/strutil.h" /* str_term_form */ @@ -153,7 +156,6 @@ sigwinch_handler (int dummy) { (void) dummy; - tty_change_screen_size (); mc_global.tty.winch_flag = TRUE; } @@ -372,6 +374,19 @@ tty_shutdown (void) } } +/* --------------------------------------------------------------------------------------------- */ + +void +tty_change_screen_size (void) +{ + SLtt_get_screen_size (); + SLsmg_reinit_smg (); + + do_enter_ca_mode (); + tty_keypad (TRUE); + tty_nodelay (FALSE); +} + /* --------------------------------------------------------------------------------------------- */ /* Done each time we come back from done mode */ diff --git a/lib/tty/tty.c b/lib/tty/tty.c index 68317e75e..54756f9f9 100644 --- a/lib/tty/tty.c +++ b/lib/tty/tty.c @@ -252,38 +252,6 @@ tty_resize (int fd) /* --------------------------------------------------------------------------------------------- */ -void -tty_change_screen_size (void) -{ -#if defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 -#if defined TIOCGWINSZ - struct winsize winsz; - - winsz.ws_col = winsz.ws_row = 0; - /* Ioctl on the STDIN_FILENO */ - ioctl (0, TIOCGWINSZ, &winsz); - if (winsz.ws_col && winsz.ws_row) - { -#if defined(NCURSES_VERSION) && defined(HAVE_RESIZETERM) - resizeterm (winsz.ws_row, winsz.ws_col); - clearok (stdscr, TRUE); /* sigwinch's should use a semaphore! */ -#else - COLS = winsz.ws_col; - LINES = winsz.ws_row; -#endif -#ifdef HAVE_SUBSHELL_SUPPORT - if (!mc_global.tty.use_subshell) - return; - - tty_resize (mc_global.tty.subshell_pty); -#endif - } -#endif /* TIOCGWINSZ */ -#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */ -} - -/* --------------------------------------------------------------------------------------------- */ - void tty_init_xterm_support (gboolean is_xterm) { diff --git a/lib/widget/dialog-switch.c b/lib/widget/dialog-switch.c index 7d851a71c..d8c6d7707 100644 --- a/lib/widget/dialog-switch.c +++ b/lib/widget/dialog-switch.c @@ -32,16 +32,8 @@ #include -/* If TIOCGWINSZ supported, make it available here, because window resizing code - * depends on it... */ -#ifdef HAVE_SYS_IOCTL_H -#include -#endif -#include - #include "lib/global.h" #include "lib/tty/tty.h" /* LINES, COLS */ -#include "lib/tty/win.h" /* do_enter_ca_mode() */ #include "lib/tty/color.h" /* tty_set_normal_attrs() */ #include "lib/widget.h" #include "lib/event.h" @@ -121,7 +113,6 @@ dialog_switch_goto (GList * dlg) /* --------------------------------------------------------------------------------------------- */ -#if defined TIOCGWINSZ static void dlg_resize_cb (void *data, void *user_data) { @@ -133,7 +124,6 @@ dlg_resize_cb (void *data, void *user_data) else d->winch_pending = TRUE; } -#endif /* --------------------------------------------------------------------------------------------- */ /*** public functions ****************************************************************************/ @@ -374,25 +364,12 @@ void dialog_change_screen_size (void) { mc_global.tty.winch_flag = FALSE; -#if defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 -#if defined TIOCGWINSZ -#ifndef NCURSES_VERSION - tty_noraw_mode (); - tty_reset_screen (); -#endif tty_change_screen_size (); -#ifdef HAVE_SLANG - /* XSI Curses spec states that portable applications shall not invoke - * initscr() more than once. This kludge could be done within the scope - * of the specification by using endwin followed by a refresh (in fact, - * more than one curses implementation does this); it is guaranteed to work - * only with slang. - */ - SLsmg_init_smg (); - do_enter_ca_mode (); - tty_keypad (TRUE); - tty_nodelay (FALSE); + +#ifdef HAVE_SUBSHELL_SUPPORT + if (mc_global.tty.use_subshell) + tty_resize (mc_global.tty.subshell_pty); #endif /* Inform all suspending dialogs */ @@ -402,9 +379,6 @@ dialog_change_screen_size (void) /* Now, force the redraw */ repaint_screen (); - -#endif /* TIOCGWINSZ */ -#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */ } /* --------------------------------------------------------------------------------------------- */