1
1

Fixup update of command line after window resize.

The bug only occurs with subshell enabled.

When resizing the window while in the viewer, the subshell resizes
itself and hence prints its prompt again. This is captured and processed
by mc.

src/filemanager/layout.c:setup_panels() is executed and recalculates
properties of the panel, but for some reason this time mc_prompt does
contain all the invisible characters, they are not stripped off, hence
size calculation goes wrong.

Thanks Egmont Koblinger for the detailed description of the problem and
the idea of fix.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
Andrew Borodin 2011-11-30 13:28:05 +03:00
родитель d99feea391
Коммит 86c8378d66
6 изменённых файлов: 65 добавлений и 29 удалений

Просмотреть файл

@ -385,7 +385,7 @@ toggle_panels (void)
#ifdef HAVE_SUBSHELL_SUPPORT
if (mc_global.tty.use_subshell)
{
load_prompt (0, NULL);
do_load_prompt ();
if (new_dir)
do_possible_cd (new_dir);
if (mc_global.tty.console_flag != '\0' && output_lines)

Просмотреть файл

@ -263,7 +263,7 @@ enter (WInput * lc_cmdline)
}
if (mc_global.tty.use_subshell)
load_prompt (0, NULL);
do_load_prompt ();
#endif
}
return MSG_HANDLED;

Просмотреть файл

@ -52,6 +52,10 @@
#include "src/viewer/mcviewer.h" /* The view widget */
#include "src/setup.h"
#include "src/background.h"
#ifdef HAVE_SUBSHELL_SUPPORT
#include "src/main.h" /* do_load_prompt() */
#include "src/subshell.h"
#endif
#include "command.h"
#include "midnight.h"
@ -642,7 +646,6 @@ void
setup_panels (void)
{
int start_y;
int promptl; /* the prompt len */
if (mc_global.tty.console_flag != '\0')
{
@ -688,16 +691,14 @@ setup_panels (void)
panel_do_cols (0);
panel_do_cols (1);
promptl = str_term_width1 (mc_prompt);
widget_set_size (&the_menubar->widget, 0, 0, 1, COLS);
if (command_prompt)
{
widget_set_size (&cmdline->widget, LINES - 1 - mc_global.keybar_visible, promptl, 1,
COLS - promptl);
input_set_origin (cmdline, promptl, COLS - promptl);
widget_set_size (&the_prompt->widget, LINES - 1 - mc_global.keybar_visible, 0, 1, promptl);
#ifdef HAVE_SUBSHELL_SUPPORT
if (!mc_global.tty.use_subshell || !do_load_prompt ())
#endif
setup_cmdline ();
}
else
{
@ -717,6 +718,7 @@ setup_panels (void)
LINES - output_lines - mc_global.keybar_visible - 1,
LINES - mc_global.keybar_visible - 1);
}
if (mc_global.message_visible)
widget_set_size (&the_hint->widget, height + start_y, 0, 1, COLS);
else
@ -727,6 +729,40 @@ setup_panels (void)
/* --------------------------------------------------------------------------------------------- */
void
setup_cmdline (void)
{
int prompt_len;
int y;
char *tmp_prompt = NULL;
#ifdef HAVE_SUBSHELL_SUPPORT
if (mc_global.tty.use_subshell)
tmp_prompt = strip_ctrl_codes (subshell_prompt);
if (tmp_prompt == NULL)
#endif
tmp_prompt = (char *) mc_prompt;
prompt_len = str_term_width1 (tmp_prompt);
/* Check for prompts too big */
if (COLS > 8 && prompt_len > COLS - 8)
{
prompt_len = COLS - 8;
tmp_prompt[prompt_len] = '\0';
}
mc_prompt = tmp_prompt;
y = LINES - 1 - mc_global.keybar_visible;
widget_set_size ((Widget *) the_prompt, y, 0, 1, prompt_len);
label_set_text (the_prompt, mc_prompt);
widget_set_size ((Widget *) cmdline, y, prompt_len, 1, COLS - prompt_len);
input_set_origin ((WInput *) cmdline, prompt_len, COLS - prompt_len);
}
/* --------------------------------------------------------------------------------------------- */
void
use_dash (gboolean flag)
{

Просмотреть файл

@ -36,6 +36,7 @@ void layout_change (void);
void layout_box (void);
void setup_panels (void);
void destroy_panels (void);
void setup_cmdline (void);
void set_display_type (int num, panel_view_mode_t type);
void panel_update_cols (Widget * widget, panel_display_t frame_size);
void swap_panels (void);

Просмотреть файл

@ -290,33 +290,18 @@ do_cd (const char *new_dir, enum cd_enum exact)
/* --------------------------------------------------------------------------------------------- */
#ifdef HAVE_SUBSHELL_SUPPORT
int
load_prompt (int fd, void *unused)
gboolean
do_load_prompt (void)
{
(void) fd;
(void) unused;
gboolean ret = FALSE;
if (!read_subshell_prompt ())
return 0;
return ret;
/* Don't actually change the prompt if it's invisible */
if (((Dlg_head *) top_dlg->data == midnight_dlg) && command_prompt)
{
char *tmp_prompt;
int prompt_len;
tmp_prompt = strip_ctrl_codes (subshell_prompt);
prompt_len = str_term_width1 (tmp_prompt);
/* Check for prompts too big */
if (COLS > 8 && prompt_len > COLS - 8)
{
prompt_len = COLS - 8;
tmp_prompt[prompt_len] = '\0';
}
mc_prompt = tmp_prompt;
label_set_text (the_prompt, mc_prompt);
input_set_origin ((WInput *) cmdline, prompt_len, COLS - prompt_len);
setup_cmdline ();
/* since the prompt has changed, and we are called from one of the
* tty_get_event channels, the prompt updating does not take place
@ -324,8 +309,21 @@ load_prompt (int fd, void *unused)
*/
update_cursor (midnight_dlg);
mc_refresh ();
ret = TRUE;
}
update_subshell_prompt = TRUE;
return ret;
}
/* --------------------------------------------------------------------------------------------- */
int
load_prompt (int fd, void *unused)
{
(void) fd;
(void) unused;
do_load_prompt ();
return 0;
}
#endif /* HAVE_SUBSHELL_SUPPORT */

Просмотреть файл

@ -85,6 +85,7 @@ extern GArray *macros_list;
/*** declarations of public functions ************************************************************/
#ifdef HAVE_SUBSHELL_SUPPORT
gboolean do_load_prompt (void);
int load_prompt (int fd, void *unused);
#endif