mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
File manager: refactoring of MSG_RESIZE handling.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
6e4ea30fc3
commit
97bc63d7ac
@ -204,12 +204,14 @@ check_split (panels_layout_t * layout)
|
||||
}
|
||||
else
|
||||
{
|
||||
int md_cols = CONST_WIDGET (midnight_dlg)->cols;
|
||||
|
||||
if (layout->vertical_equal)
|
||||
layout->left_panel_size = COLS / 2;
|
||||
layout->left_panel_size = md_cols / 2;
|
||||
else if (layout->left_panel_size < MINWIDTH)
|
||||
layout->left_panel_size = MINWIDTH;
|
||||
else if (layout->left_panel_size > COLS - MINWIDTH)
|
||||
layout->left_panel_size = COLS - MINWIDTH;
|
||||
else if (layout->left_panel_size > md_cols - MINWIDTH)
|
||||
layout->left_panel_size = md_cols - MINWIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,7 +242,7 @@ update_split (const WDialog * h)
|
||||
if (panels_layout.horizontal_split)
|
||||
tty_printf ("%03d", height - panels_layout.top_panel_size);
|
||||
else
|
||||
tty_printf ("%03d", COLS - panels_layout.left_panel_size);
|
||||
tty_printf ("%03d", CONST_WIDGET (midnight_dlg)->cols - panels_layout.left_panel_size);
|
||||
|
||||
widget_move (h, 6, 12);
|
||||
tty_print_char ('=');
|
||||
@ -331,6 +333,7 @@ layout_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *
|
||||
|
||||
case MSG_POST_KEY:
|
||||
{
|
||||
const Widget *mw = CONST_WIDGET (midnight_dlg);
|
||||
int _menubar_visible, _command_prompt, _keybar_visible, _message_visible;
|
||||
|
||||
_menubar_visible = check_options[1].widget->state;
|
||||
@ -345,8 +348,8 @@ layout_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *
|
||||
if (_output_lines < 0)
|
||||
_output_lines = 0;
|
||||
height =
|
||||
LINES - _keybar_visible - _command_prompt - _menubar_visible - _output_lines -
|
||||
_message_visible;
|
||||
mw->lines - _keybar_visible - _command_prompt - _menubar_visible -
|
||||
_output_lines - _message_visible;
|
||||
minimum = MINHEIGHT * (1 + panels_layout.horizontal_split);
|
||||
if (height < minimum)
|
||||
{
|
||||
@ -356,8 +359,8 @@ layout_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *
|
||||
}
|
||||
else
|
||||
height =
|
||||
LINES - _keybar_visible - _command_prompt - _menubar_visible - _output_lines -
|
||||
_message_visible;
|
||||
mw->lines - _keybar_visible - _command_prompt - _menubar_visible -
|
||||
_output_lines - _message_visible;
|
||||
|
||||
if (old_output_lines != _output_lines)
|
||||
{
|
||||
@ -388,7 +391,7 @@ layout_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *
|
||||
{
|
||||
eq = panels_layout.vertical_equal;
|
||||
if (eq)
|
||||
panels_layout.left_panel_size = COLS / 2;
|
||||
panels_layout.left_panel_size = CONST_WIDGET (midnight_dlg)->cols / 2;
|
||||
}
|
||||
|
||||
widget_disable (WIDGET (bleft_widget), eq);
|
||||
@ -672,7 +675,8 @@ layout_box (void)
|
||||
void
|
||||
panel_update_cols (Widget * widget, panel_display_t frame_size)
|
||||
{
|
||||
int cols, origin;
|
||||
const Widget *mw = CONST_WIDGET (midnight_dlg);
|
||||
int cols, x;
|
||||
|
||||
/* don't touch panel if it is not in dialog yet */
|
||||
/* if panel is not in dialog it is not in widgets list
|
||||
@ -682,28 +686,28 @@ panel_update_cols (Widget * widget, panel_display_t frame_size)
|
||||
|
||||
if (panels_layout.horizontal_split)
|
||||
{
|
||||
widget->cols = COLS;
|
||||
widget->cols = mw->cols;
|
||||
return;
|
||||
}
|
||||
|
||||
if (frame_size == frame_full)
|
||||
{
|
||||
cols = COLS;
|
||||
origin = 0;
|
||||
cols = mw->cols;
|
||||
x = mw->x;
|
||||
}
|
||||
else if (widget == get_panel_widget (0))
|
||||
{
|
||||
cols = panels_layout.left_panel_size;
|
||||
origin = 0;
|
||||
x = mw->x;
|
||||
}
|
||||
else
|
||||
{
|
||||
cols = COLS - panels_layout.left_panel_size;
|
||||
origin = panels_layout.left_panel_size;
|
||||
cols = mw->cols - panels_layout.left_panel_size;
|
||||
x = mw->x + panels_layout.left_panel_size;
|
||||
}
|
||||
|
||||
widget->cols = cols;
|
||||
widget->x = origin;
|
||||
widget->x = x;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -737,11 +741,12 @@ setup_panels (void)
|
||||
* +--------+------------------------------------------------------+
|
||||
*/
|
||||
|
||||
const Widget *mw = CONST_WIDGET (midnight_dlg);
|
||||
int start_y;
|
||||
|
||||
/* iniitial height of panels */
|
||||
height =
|
||||
LINES - menubar_visible - mc_global.message_visible - (command_prompt ? 1 : 0) -
|
||||
mw->lines - menubar_visible - mc_global.message_visible - (command_prompt ? 1 : 0) -
|
||||
mc_global.keybar_visible;
|
||||
|
||||
if (mc_global.tty.console_flag != '\0')
|
||||
@ -760,11 +765,11 @@ setup_panels (void)
|
||||
}
|
||||
}
|
||||
|
||||
widget_set_size (WIDGET (the_menubar), 0, 0, 1, COLS);
|
||||
widget_set_size (WIDGET (the_menubar), mw->y, mw->x, 1, mw->cols);
|
||||
menubar_set_visible (the_menubar, menubar_visible);
|
||||
|
||||
check_split (&panels_layout);
|
||||
start_y = menubar_visible;
|
||||
start_y = mw->y + menubar_visible;
|
||||
|
||||
/* update columns first... */
|
||||
panel_do_cols (0);
|
||||
@ -773,30 +778,34 @@ setup_panels (void)
|
||||
/* ...then rows and origin */
|
||||
if (panels_layout.horizontal_split)
|
||||
{
|
||||
widget_set_size (panels[0].widget, start_y, 0, panels_layout.top_panel_size,
|
||||
panels[0].widget->cols);
|
||||
widget_set_size (panels[1].widget, start_y + panels_layout.top_panel_size, 0,
|
||||
height - panels_layout.top_panel_size, panels[1].widget->cols);
|
||||
widget_set_size (panels[0].widget, start_y, panels[0].widget->x,
|
||||
panels_layout.top_panel_size, panels[0].widget->cols);
|
||||
widget_set_size (panels[1].widget, start_y + panels_layout.top_panel_size,
|
||||
panels[1].widget->x, height - panels_layout.top_panel_size,
|
||||
panels[1].widget->cols);
|
||||
}
|
||||
else
|
||||
{
|
||||
widget_set_size (panels[0].widget, start_y, 0, height, panels[0].widget->cols);
|
||||
widget_set_size (panels[0].widget, start_y, panels[0].widget->x, height,
|
||||
panels[0].widget->cols);
|
||||
widget_set_size (panels[1].widget, start_y, panels[1].widget->x, height,
|
||||
panels[1].widget->cols);
|
||||
}
|
||||
|
||||
if (mc_global.message_visible)
|
||||
widget_set_size (WIDGET (the_hint), height + start_y, 0, 1, COLS);
|
||||
widget_set_size (WIDGET (the_hint), height + start_y, mw->x, 1, mw->cols);
|
||||
else
|
||||
/* make invisible */
|
||||
widget_set_size (WIDGET (the_hint), 0, 0, 0, 0);
|
||||
|
||||
/* Output window */
|
||||
if (mc_global.tty.console_flag != '\0' && output_lines)
|
||||
{
|
||||
output_start_y = LINES - (command_prompt ? 1 : 0) - mc_global.keybar_visible - output_lines;
|
||||
output_start_y =
|
||||
mw->lines - (command_prompt ? 1 : 0) - mc_global.keybar_visible - output_lines;
|
||||
show_console_contents (output_start_y,
|
||||
LINES - output_lines - mc_global.keybar_visible - 1,
|
||||
LINES - mc_global.keybar_visible - 1);
|
||||
mw->lines - output_lines - mc_global.keybar_visible - 1,
|
||||
mw->lines - mc_global.keybar_visible - 1);
|
||||
}
|
||||
|
||||
if (command_prompt)
|
||||
@ -808,11 +817,12 @@ setup_panels (void)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* make invisible */
|
||||
widget_set_size (WIDGET (cmdline), 0, 0, 0, 0);
|
||||
widget_set_size (WIDGET (the_prompt), LINES, COLS, 0, 0);
|
||||
widget_set_size (WIDGET (the_prompt), mw->lines, mw->cols, 0, 0);
|
||||
}
|
||||
|
||||
widget_set_size (WIDGET (the_bar), LINES - 1, 0, mc_global.keybar_visible, COLS);
|
||||
widget_set_size (WIDGET (the_bar), mw->lines - 1, mw->x, mc_global.keybar_visible, mw->cols);
|
||||
buttonbar_set_visible (the_bar, mc_global.keybar_visible);
|
||||
|
||||
update_xterm_title_path ();
|
||||
@ -876,6 +886,7 @@ panels_split_less (void)
|
||||
void
|
||||
setup_cmdline (void)
|
||||
{
|
||||
const Widget *mw = CONST_WIDGET (midnight_dlg);
|
||||
int prompt_width;
|
||||
int y;
|
||||
char *tmp_prompt = (char *) mc_prompt;
|
||||
@ -891,11 +902,11 @@ setup_cmdline (void)
|
||||
prompt_width = str_term_width1 (tmp_prompt);
|
||||
|
||||
/* Check for prompts too big */
|
||||
if (COLS > 8 && prompt_width > COLS - 8)
|
||||
if (mw->cols > 8 && prompt_width > mw->cols - 8)
|
||||
{
|
||||
int prompt_len;
|
||||
|
||||
prompt_width = COLS - 8;
|
||||
prompt_width = mw->cols - 8;
|
||||
prompt_len = str_offset_to_pos (tmp_prompt, prompt_width);
|
||||
tmp_prompt[prompt_len] = '\0';
|
||||
}
|
||||
@ -909,11 +920,11 @@ setup_cmdline (void)
|
||||
}
|
||||
#endif
|
||||
|
||||
y = LINES - 1 - mc_global.keybar_visible;
|
||||
y = mw->lines - 1 - mc_global.keybar_visible;
|
||||
|
||||
widget_set_size (WIDGET (the_prompt), y, 0, 1, prompt_width);
|
||||
widget_set_size (WIDGET (the_prompt), y, mw->x, 1, prompt_width);
|
||||
label_set_text (the_prompt, mc_prompt);
|
||||
widget_set_size (WIDGET (cmdline), y, prompt_width, 1, COLS - prompt_width);
|
||||
widget_set_size (WIDGET (cmdline), y, mw->x + prompt_width, 1, mw->cols - prompt_width);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -942,7 +953,7 @@ set_hintbar (const char *str)
|
||||
void
|
||||
rotate_dash (gboolean show)
|
||||
{
|
||||
Widget *w = WIDGET (midnight_dlg);
|
||||
const Widget *w = CONST_WIDGET (midnight_dlg);
|
||||
|
||||
if (!nice_rotating_dash || (ok_to_refresh <= 0))
|
||||
return;
|
||||
@ -1034,14 +1045,16 @@ create_panel (int num, panel_view_mode_t type)
|
||||
|
||||
if (old_type == view_listing && panel->frame_size == frame_full && type != view_listing)
|
||||
{
|
||||
int md_cols = CONST_WIDGET (midnight_dlg)->cols;
|
||||
|
||||
if (panels_layout.horizontal_split)
|
||||
{
|
||||
cols = COLS;
|
||||
cols = md_cols;
|
||||
x = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cols = COLS - panels_layout.left_panel_size;
|
||||
cols = md_cols - panels_layout.left_panel_size;
|
||||
if (num == 1)
|
||||
x = panels_layout.left_panel_size;
|
||||
}
|
||||
|
@ -1508,9 +1508,7 @@ midnight_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void
|
||||
return MSG_HANDLED;
|
||||
|
||||
case MSG_RESIZE:
|
||||
/* dlg_set_size() is surplus for this case */
|
||||
w->lines = LINES;
|
||||
w->cols = COLS;
|
||||
widget_adjust_position (w->pos_flags, &w->y, &w->x, &w->lines, &w->cols);
|
||||
setup_panels ();
|
||||
menubar_arrange (the_menubar);
|
||||
return MSG_HANDLED;
|
||||
|
Loading…
Reference in New Issue
Block a user