mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 10:04:32 +03:00
Moved mc_refresh() to lib/widget
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
5f8a5e4290
commit
aad40e52fb
@ -48,7 +48,7 @@
|
|||||||
#include "key.h"
|
#include "key.h"
|
||||||
#include "win.h" /* xterm_flag */
|
#include "win.h" /* xterm_flag */
|
||||||
|
|
||||||
#include "src/filemanager/layout.h" /* mc_refresh() */
|
#include "lib/widget.h" /* mc_refresh() */
|
||||||
|
|
||||||
#ifdef HAVE_TEXTMODE_X11_SUPPORT
|
#ifdef HAVE_TEXTMODE_X11_SUPPORT
|
||||||
#include "x11conn.h"
|
#include "x11conn.h"
|
||||||
|
@ -34,12 +34,16 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_IOCTL_H
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "lib/global.h"
|
#include "lib/global.h"
|
||||||
#include "lib/strutil.h"
|
#include "lib/strutil.h"
|
||||||
|
|
||||||
#include "tty.h"
|
#include "tty.h"
|
||||||
#include "tty-internal.h"
|
#include "tty-internal.h"
|
||||||
|
#include "win.h"
|
||||||
|
|
||||||
/*** global variables ****************************************************************************/
|
/*** global variables ****************************************************************************/
|
||||||
|
|
||||||
@ -204,3 +208,54 @@ mc_tty_normalize_from_utf8 (const char *str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/** Resize given terminal using TIOCSWINSZ, return ioctl() result */
|
||||||
|
int
|
||||||
|
tty_resize (int fd)
|
||||||
|
{
|
||||||
|
#if defined TIOCSWINSZ
|
||||||
|
struct winsize tty_size;
|
||||||
|
|
||||||
|
tty_size.ws_row = LINES;
|
||||||
|
tty_size.ws_col = COLS;
|
||||||
|
tty_size.ws_xpixel = tty_size.ws_ypixel = 0;
|
||||||
|
|
||||||
|
return ioctl (fd, TIOCSWINSZ, &tty_size);
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void
|
||||||
|
tty_low_level_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 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
@ -130,8 +130,11 @@ extern void tty_draw_vline (int y, int x, int ch, int len);
|
|||||||
extern void tty_draw_box (int y, int x, int rows, int cols, gboolean single);
|
extern void tty_draw_box (int y, int x, int rows, int cols, gboolean single);
|
||||||
extern void tty_fill_region (int y, int x, int rows, int cols, unsigned char ch);
|
extern void tty_fill_region (int y, int x, int rows, int cols, unsigned char ch);
|
||||||
|
|
||||||
|
extern int tty_resize (int fd);
|
||||||
extern void tty_refresh (void);
|
extern void tty_refresh (void);
|
||||||
extern void tty_setup_sigwinch (void (*handler) (int));
|
extern void tty_setup_sigwinch (void (*handler) (int));
|
||||||
|
extern void tty_low_level_change_screen_size (void);
|
||||||
|
|
||||||
|
|
||||||
extern int mc_tty_normalize_lines_char (const char *);
|
extern int mc_tty_normalize_lines_char (const char *);
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include "lib/global.h"
|
#include "lib/global.h"
|
||||||
#include "lib/tty/tty.h" /* LINES, COLS */
|
#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/tty/color.h" /* tty_set_normal_attrs() */
|
||||||
#include "lib/widget.h"
|
#include "lib/widget.h"
|
||||||
#include "lib/event.h"
|
#include "lib/event.h"
|
||||||
@ -91,6 +92,17 @@ dialog_switch_goto (GList * dlg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static void
|
||||||
|
dlg_resize_cb (void *data, void *user_data)
|
||||||
|
{
|
||||||
|
Dlg_head *d = data;
|
||||||
|
|
||||||
|
(void) user_data;
|
||||||
|
d->callback (d, NULL, DLG_RESIZE, 0, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/*** public functions ****************************************************************************/
|
/*** public functions ****************************************************************************/
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -298,3 +310,42 @@ repaint_screen (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
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_low_level_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);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Inform all suspending dialogs */
|
||||||
|
dialog_switch_got_winch ();
|
||||||
|
/* Inform all running dialogs */
|
||||||
|
g_list_foreach (top_dlg, (GFunc) dlg_resize_cb, NULL);
|
||||||
|
|
||||||
|
/* Now, force the redraw */
|
||||||
|
repaint_screen ();
|
||||||
|
|
||||||
|
#endif /* TIOCGWINSZ */
|
||||||
|
#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
@ -31,6 +31,7 @@ void dialog_switch_shutdown (void);
|
|||||||
/* Clear screen */
|
/* Clear screen */
|
||||||
void clr_scr (void);
|
void clr_scr (void);
|
||||||
void repaint_screen (void);
|
void repaint_screen (void);
|
||||||
|
void dialog_change_screen_size (void);
|
||||||
|
|
||||||
/*** inline functions ****************************************************************************/
|
/*** inline functions ****************************************************************************/
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ frontend_run_dlg (Dlg_head * h)
|
|||||||
while (h->state == DLG_ACTIVE)
|
while (h->state == DLG_ACTIVE)
|
||||||
{
|
{
|
||||||
if (mc_global.tty.winch_flag)
|
if (mc_global.tty.winch_flag)
|
||||||
change_screen_size ();
|
dialog_change_screen_size ();
|
||||||
|
|
||||||
if (is_idle ())
|
if (is_idle ())
|
||||||
{
|
{
|
||||||
|
@ -459,3 +459,22 @@ input_expand_dialog (const char *header, const char *text,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void
|
||||||
|
mc_refresh (void)
|
||||||
|
{
|
||||||
|
#ifdef WITH_BACKGROUND
|
||||||
|
if (mc_global.we_are_background)
|
||||||
|
return;
|
||||||
|
#endif /* WITH_BACKGROUND */
|
||||||
|
if (mc_global.tty.winch_flag == FALSE)
|
||||||
|
tty_refresh ();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* if winch was caugth, we should do not only redraw screen, but
|
||||||
|
reposition/resize all */
|
||||||
|
dialog_change_screen_size ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
@ -47,6 +47,9 @@ struct Dlg_head *create_message (int flags, const char *title,
|
|||||||
void message (int flags, const char *title, const char *text, ...)
|
void message (int flags, const char *title, const char *text, ...)
|
||||||
__attribute__ ((format (__printf__, 3, 4)));
|
__attribute__ ((format (__printf__, 3, 4)));
|
||||||
|
|
||||||
|
/* Clear screen */
|
||||||
|
void mc_refresh (void);
|
||||||
|
|
||||||
/*** inline functions ****************************************************************************/
|
/*** inline functions ****************************************************************************/
|
||||||
|
|
||||||
#endif /* MC__WTOOLS_H */
|
#endif /* MC__WTOOLS_H */
|
||||||
|
@ -58,7 +58,6 @@
|
|||||||
#include "src/consaver/cons.saver.h"
|
#include "src/consaver/cons.saver.h"
|
||||||
#include "src/viewer/mcviewer.h" /* The view widget */
|
#include "src/viewer/mcviewer.h" /* The view widget */
|
||||||
#include "src/setup.h"
|
#include "src/setup.h"
|
||||||
#include "src/subshell.h" /* For resize_subshell() */
|
|
||||||
#include "src/background.h"
|
#include "src/background.h"
|
||||||
|
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
@ -597,46 +596,6 @@ restore_into_right_dir_panel (int idx, Widget * from_widget)
|
|||||||
return new_widget;
|
return new_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
low_level_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
|
|
||||||
resize_subshell ();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif /* TIOCGWINSZ */
|
|
||||||
#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
static void
|
|
||||||
dlg_resize_cb (void *data, void *user_data)
|
|
||||||
{
|
|
||||||
Dlg_head *d = data;
|
|
||||||
|
|
||||||
(void) user_data;
|
|
||||||
d->callback (d, NULL, DLG_RESIZE, 0, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/*** public functions ****************************************************************************/
|
/*** public functions ****************************************************************************/
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -688,25 +647,6 @@ layout_box (void)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
|
||||||
mc_refresh (void)
|
|
||||||
{
|
|
||||||
#ifdef WITH_BACKGROUND
|
|
||||||
if (mc_global.we_are_background)
|
|
||||||
return;
|
|
||||||
#endif /* WITH_BACKGROUND */
|
|
||||||
if (mc_global.tty.winch_flag == FALSE)
|
|
||||||
tty_refresh ();
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* if winch was caugth, we should do not only redraw screen, but
|
|
||||||
reposition/resize all */
|
|
||||||
change_screen_size ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
setup_panels (void)
|
setup_panels (void)
|
||||||
{
|
{
|
||||||
@ -801,50 +741,11 @@ sigwinch_handler (int dummy)
|
|||||||
{
|
{
|
||||||
(void) dummy;
|
(void) dummy;
|
||||||
#if !(defined(USE_NCURSES) || defined(USE_NCURSESW)) /* don't do malloc in a signal handler */
|
#if !(defined(USE_NCURSES) || defined(USE_NCURSESW)) /* don't do malloc in a signal handler */
|
||||||
low_level_change_screen_size ();
|
tty_low_level_change_screen_size ();
|
||||||
#endif
|
#endif
|
||||||
mc_global.tty.winch_flag = TRUE;
|
mc_global.tty.winch_flag = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
void
|
|
||||||
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
|
|
||||||
low_level_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);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Inform all suspending dialogs */
|
|
||||||
dialog_switch_got_winch ();
|
|
||||||
/* Inform all running dialogs */
|
|
||||||
g_list_foreach (top_dlg, (GFunc) dlg_resize_cb, NULL);
|
|
||||||
|
|
||||||
/* Now, force the redraw */
|
|
||||||
repaint_screen ();
|
|
||||||
#endif /* TIOCGWINSZ */
|
|
||||||
#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -37,7 +37,6 @@ void layout_box (void);
|
|||||||
void setup_panels (void);
|
void setup_panels (void);
|
||||||
void destroy_panels (void);
|
void destroy_panels (void);
|
||||||
void sigwinch_handler (int dummy);
|
void sigwinch_handler (int dummy);
|
||||||
void change_screen_size (void);
|
|
||||||
void set_display_type (int num, panel_view_mode_t type);
|
void set_display_type (int num, panel_view_mode_t type);
|
||||||
void panel_update_cols (Widget * widget, panel_display_t frame_size);
|
void panel_update_cols (Widget * widget, panel_display_t frame_size);
|
||||||
void swap_panels (void);
|
void swap_panels (void);
|
||||||
@ -61,9 +60,6 @@ void set_hintbar (const char *str);
|
|||||||
void use_dash (gboolean flag); /* Disable/Enable rotate_dash routines */
|
void use_dash (gboolean flag); /* Disable/Enable rotate_dash routines */
|
||||||
void rotate_dash (void);
|
void rotate_dash (void);
|
||||||
|
|
||||||
/* Clear screen */
|
|
||||||
void mc_refresh (void);
|
|
||||||
|
|
||||||
/*** inline functions ****************************************************************************/
|
/*** inline functions ****************************************************************************/
|
||||||
|
|
||||||
#endif /* MC__LAYOUT_H */
|
#endif /* MC__LAYOUT_H */
|
||||||
|
@ -180,7 +180,6 @@ static gboolean feed_subshell (int how, int fail_on_error);
|
|||||||
static void synchronize (void);
|
static void synchronize (void);
|
||||||
static int pty_open_master (char *pty_name);
|
static int pty_open_master (char *pty_name);
|
||||||
static int pty_open_slave (const char *pty_name);
|
static int pty_open_slave (const char *pty_name);
|
||||||
static int resize_tty (int fd);
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
/**
|
/**
|
||||||
@ -250,7 +249,7 @@ init_subshell_child (const char *pty_name)
|
|||||||
|
|
||||||
/* Set the pty's size (80x25 by default on Linux) according to the */
|
/* Set the pty's size (80x25 by default on Linux) according to the */
|
||||||
/* size of the real terminal as calculated by ncurses, if possible */
|
/* size of the real terminal as calculated by ncurses, if possible */
|
||||||
resize_tty (subshell_pty_slave);
|
tty_resize (subshell_pty_slave);
|
||||||
|
|
||||||
/* Set up the subshell's environment and init file name */
|
/* Set up the subshell's environment and init file name */
|
||||||
|
|
||||||
@ -1046,37 +1045,6 @@ do_update_prompt (void)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/** Resize given terminal using TIOCSWINSZ, return ioctl() result */
|
|
||||||
static int
|
|
||||||
resize_tty (int fd)
|
|
||||||
{
|
|
||||||
#if defined TIOCSWINSZ
|
|
||||||
struct winsize tty_size;
|
|
||||||
|
|
||||||
tty_size.ws_row = LINES;
|
|
||||||
tty_size.ws_col = COLS;
|
|
||||||
tty_size.ws_xpixel = tty_size.ws_ypixel = 0;
|
|
||||||
|
|
||||||
return ioctl (fd, TIOCSWINSZ, &tty_size);
|
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
/** Resize mc_global.tty.subshell_pty */
|
|
||||||
|
|
||||||
void
|
|
||||||
resize_subshell (void)
|
|
||||||
{
|
|
||||||
if (!mc_global.tty.use_subshell)
|
|
||||||
return;
|
|
||||||
|
|
||||||
resize_tty (mc_global.tty.subshell_pty);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
int
|
int
|
||||||
exit_subshell (void)
|
exit_subshell (void)
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,6 @@ void init_subshell (void);
|
|||||||
int invoke_subshell (const char *command, int how, char **new_dir);
|
int invoke_subshell (const char *command, int how, char **new_dir);
|
||||||
int read_subshell_prompt (void);
|
int read_subshell_prompt (void);
|
||||||
void do_update_prompt (void);
|
void do_update_prompt (void);
|
||||||
void resize_subshell (void);
|
|
||||||
int exit_subshell (void);
|
int exit_subshell (void);
|
||||||
void do_subshell_chdir (const char *directory, gboolean update_prompt, gboolean reset_prompt);
|
void do_subshell_chdir (const char *directory, gboolean update_prompt, gboolean reset_prompt);
|
||||||
void subshell_get_console_attributes (void);
|
void subshell_get_console_attributes (void);
|
||||||
|
Loading…
Reference in New Issue
Block a user