From f6c4ae2f31a348dd3c7cc7955719524033aa8fb4 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 14 Aug 2019 11:39:08 +0300 Subject: [PATCH] (setup_panels): refactoring: optimization ..,and change order of widget origin/size calculation. Signed-off-by: Andrew Borodin --- src/filemanager/layout.c | 73 +++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 24 deletions(-) diff --git a/src/filemanager/layout.c b/src/filemanager/layout.c index a4c9d09da..63e5dd17e 100644 --- a/src/filemanager/layout.c +++ b/src/filemanager/layout.c @@ -711,17 +711,47 @@ panel_update_cols (Widget * widget, panel_display_t frame_size) void setup_panels (void) { + /* File manager screen layout: + * + * +---------------------------------------------------------------+ + * | Menu bar | + * +-------------------------------+-------------------------------+ + * | | | + * | | | + * | | | + * | | | + * | Left panel | Right panel | + * | | | + * | | | + * | | | + * | | | + * +-------------------------------+-------------------------------+ + * | Hint (message) bar | + * +---------------------------------------------------------------+ + * | | + * | Console content | + * | | + * +--------+------------------------------------------------------+ + * | Prompt | Command line | + * | Key (button) bar | + * +--------+------------------------------------------------------+ + */ + int start_y; + /* iniitial height of panels */ + height = + LINES - menubar_visible - mc_global.message_visible - (command_prompt ? 1 : 0) - + mc_global.keybar_visible; + if (mc_global.tty.console_flag != '\0') { int minimum; if (output_lines < 0) output_lines = 0; - height = - LINES - mc_global.keybar_visible - (command_prompt ? 1 : 0) - menubar_visible - - output_lines - mc_global.message_visible; + else + height -= output_lines; minimum = MINHEIGHT * (1 + panels_layout.horizontal_split); if (height < minimum) { @@ -729,12 +759,9 @@ setup_panels (void) height = minimum; } } - else - { - height = - LINES - menubar_visible - (command_prompt ? 1 : 0) - mc_global.keybar_visible - - mc_global.message_visible; - } + + widget_set_size (WIDGET (the_menubar), 0, 0, 1, COLS); + menubar_set_visible (the_menubar, menubar_visible); check_split (&panels_layout); start_y = menubar_visible; @@ -758,7 +785,19 @@ setup_panels (void) panels[1].widget->cols); } - widget_set_size (WIDGET (the_menubar), 0, 0, 1, COLS); + if (mc_global.message_visible) + widget_set_size (WIDGET (the_hint), height + start_y, 0, 1, COLS); + else + 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; + show_console_contents (output_start_y, + LINES - output_lines - mc_global.keybar_visible - 1, + LINES - mc_global.keybar_visible - 1); + } if (command_prompt) { @@ -776,20 +815,6 @@ setup_panels (void) widget_set_size (WIDGET (the_bar), LINES - 1, 0, mc_global.keybar_visible, COLS); buttonbar_set_visible (the_bar, mc_global.keybar_visible); - /* 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; - show_console_contents (output_start_y, - LINES - output_lines - mc_global.keybar_visible - 1, - LINES - mc_global.keybar_visible - 1); - } - - if (mc_global.message_visible) - widget_set_size (WIDGET (the_hint), height + start_y, 0, 1, COLS); - else - widget_set_size (WIDGET (the_hint), 0, 0, 0, 0); - update_xterm_title_path (); }