Merge branch '2521_panel_size_after_split_change'
* 2521_panel_size_after_split_change: Ticket #2521: fixup of panel size after layout change.
Этот коммит содержится в:
Коммит
7c0a526916
@ -53,7 +53,7 @@
|
|||||||
#include "src/setup.h"
|
#include "src/setup.h"
|
||||||
#include "src/background.h"
|
#include "src/background.h"
|
||||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||||
#include "src/main.h" /* do_load_prompt() */
|
#include "src/main.h" /* do_load_prompt() */
|
||||||
#include "src/subshell.h"
|
#include "src/subshell.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -65,21 +65,24 @@
|
|||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
#include "info.h" /* The Info widget */
|
#include "info.h" /* The Info widget */
|
||||||
|
|
||||||
|
|
||||||
/*** global variables ****************************************************************************/
|
/*** global variables ****************************************************************************/
|
||||||
|
|
||||||
|
panels_layout_t panels_layout = {
|
||||||
|
/* Set if the panels are split horizontally */
|
||||||
|
.horizontal_split = 0,
|
||||||
|
|
||||||
|
/* vertical split */
|
||||||
|
.vertical_equal = 1,
|
||||||
|
.left_panel_size = 0,
|
||||||
|
|
||||||
|
/* horizontal split */
|
||||||
|
.horizontal_equal = 1,
|
||||||
|
.top_panel_size = 0
|
||||||
|
};
|
||||||
|
|
||||||
/* Controls the display of the rotating dash on the verbose mode */
|
/* Controls the display of the rotating dash on the verbose mode */
|
||||||
int nice_rotating_dash = 1;
|
int nice_rotating_dash = 1;
|
||||||
|
|
||||||
/* Set if the panels are split horizontally */
|
|
||||||
int horizontal_split = 0;
|
|
||||||
|
|
||||||
/* Set if the split is the same */
|
|
||||||
int equal_split = 1;
|
|
||||||
|
|
||||||
/* First panel size if the panel are not split equally */
|
|
||||||
int first_panel_size = 0;
|
|
||||||
|
|
||||||
/* The number of output lines shown (if available) */
|
/* The number of output lines shown (if available) */
|
||||||
int output_lines = 0;
|
int output_lines = 0;
|
||||||
|
|
||||||
@ -139,14 +142,12 @@ static struct
|
|||||||
|
|
||||||
/* These variables are used to avoid updating the information unless */
|
/* These variables are used to avoid updating the information unless */
|
||||||
/* we need it */
|
/* we need it */
|
||||||
static int old_first_panel_size;
|
static panels_layout_t old_layout;
|
||||||
static int old_horizontal_split;
|
|
||||||
static int old_output_lines;
|
static int old_output_lines;
|
||||||
|
|
||||||
/* Internal variables */
|
/* Internal variables */
|
||||||
static int _horizontal_split;
|
panels_layout_t _panels_layout;
|
||||||
static int _equal_split;
|
static int equal_split;
|
||||||
static int _first_panel_size;
|
|
||||||
static int _menubar_visible;
|
static int _menubar_visible;
|
||||||
static int _output_lines;
|
static int _output_lines;
|
||||||
static gboolean _command_prompt;
|
static gboolean _command_prompt;
|
||||||
@ -196,30 +197,27 @@ max (int a, int b)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static inline void
|
static void
|
||||||
_check_split (void)
|
check_split (panels_layout_t * layout)
|
||||||
{
|
{
|
||||||
if (_horizontal_split)
|
if (layout->horizontal_split)
|
||||||
{
|
{
|
||||||
if (_equal_split)
|
if (layout->horizontal_equal)
|
||||||
_first_panel_size = height / 2;
|
layout->top_panel_size = height / 2;
|
||||||
else if (_first_panel_size < MINHEIGHT)
|
else if (layout->top_panel_size < MINHEIGHT)
|
||||||
_first_panel_size = MINHEIGHT;
|
layout->top_panel_size = MINHEIGHT;
|
||||||
else if (_first_panel_size > height - MINHEIGHT)
|
else if (layout->top_panel_size > height - MINHEIGHT)
|
||||||
_first_panel_size = height - MINHEIGHT;
|
layout->top_panel_size = height - MINHEIGHT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_equal_split)
|
if (layout->vertical_equal)
|
||||||
_first_panel_size = COLS / 2;
|
layout->left_panel_size = COLS / 2;
|
||||||
else if (_first_panel_size < MINWIDTH)
|
else if (layout->left_panel_size < MINWIDTH)
|
||||||
_first_panel_size = MINWIDTH;
|
layout->left_panel_size = MINWIDTH;
|
||||||
else if (_first_panel_size > COLS - MINWIDTH)
|
else if (layout->left_panel_size > COLS - MINWIDTH)
|
||||||
_first_panel_size = COLS - MINWIDTH;
|
layout->left_panel_size = COLS - MINWIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
old_first_panel_size = _first_panel_size;
|
|
||||||
old_horizontal_split = _horizontal_split;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -228,19 +226,29 @@ static void
|
|||||||
update_split (const Dlg_head * h)
|
update_split (const Dlg_head * h)
|
||||||
{
|
{
|
||||||
/* Check split has to be done before testing if it changed, since
|
/* Check split has to be done before testing if it changed, since
|
||||||
it can change due to calling _check_split() as well */
|
it can change due to calling check_split() as well */
|
||||||
_check_split ();
|
check_split (&_panels_layout);
|
||||||
|
old_layout = _panels_layout;
|
||||||
|
|
||||||
|
if (_panels_layout.horizontal_split)
|
||||||
|
check_options[6].widget->state = _panels_layout.horizontal_equal ? 1 : 0;
|
||||||
|
else
|
||||||
|
check_options[6].widget->state = _panels_layout.vertical_equal ? 1 : 0;
|
||||||
|
send_message ((Widget *) check_options[6].widget, WIDGET_DRAW, 0);
|
||||||
|
|
||||||
tty_setcolor (check_options[6].widget->state & C_BOOL ? DISABLED_COLOR : COLOR_NORMAL);
|
tty_setcolor (check_options[6].widget->state & C_BOOL ? DISABLED_COLOR : COLOR_NORMAL);
|
||||||
|
|
||||||
dlg_move (h, 6, 5);
|
dlg_move (h, 6, 5);
|
||||||
tty_printf ("%03d", _first_panel_size);
|
if (_panels_layout.horizontal_split)
|
||||||
|
tty_printf ("%03d", _panels_layout.top_panel_size);
|
||||||
|
else
|
||||||
|
tty_printf ("%03d", _panels_layout.left_panel_size);
|
||||||
|
|
||||||
dlg_move (h, 6, 17);
|
dlg_move (h, 6, 17);
|
||||||
if (_horizontal_split)
|
if (_panels_layout.horizontal_split)
|
||||||
tty_printf ("%03d", height - _first_panel_size);
|
tty_printf ("%03d", height - _panels_layout.top_panel_size);
|
||||||
else
|
else
|
||||||
tty_printf ("%03d", COLS - _first_panel_size);
|
tty_printf ("%03d", COLS - _panels_layout.left_panel_size);
|
||||||
|
|
||||||
dlg_move (h, 6, 12);
|
dlg_move (h, 6, 12);
|
||||||
tty_print_char ('=');
|
tty_print_char ('=');
|
||||||
@ -254,9 +262,19 @@ b_left_right_cback (WButton * button, int action)
|
|||||||
(void) action;
|
(void) action;
|
||||||
|
|
||||||
if (button == bleft_widget)
|
if (button == bleft_widget)
|
||||||
_first_panel_size++;
|
{
|
||||||
|
if (_panels_layout.horizontal_split)
|
||||||
|
_panels_layout.top_panel_size++;
|
||||||
|
else
|
||||||
|
_panels_layout.left_panel_size++;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
_first_panel_size--;
|
{
|
||||||
|
if (_panels_layout.horizontal_split)
|
||||||
|
_panels_layout.top_panel_size--;
|
||||||
|
else
|
||||||
|
_panels_layout.left_panel_size--;
|
||||||
|
}
|
||||||
|
|
||||||
update_split (button->widget.owner);
|
update_split (button->widget.owner);
|
||||||
return 0;
|
return 0;
|
||||||
@ -296,12 +314,14 @@ layout_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *d
|
|||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
case DLG_DRAW:
|
case DLG_DRAW:
|
||||||
/*When repainting the whole dialog (e.g. with C-l) we have to
|
/* When repainting the whole dialog (e.g. with C-l) we have to
|
||||||
update everything */
|
update everything */
|
||||||
common_dialog_repaint (h);
|
common_dialog_repaint (h);
|
||||||
|
|
||||||
old_first_panel_size = -1;
|
old_layout.horizontal_split = -1;
|
||||||
old_horizontal_split = -1;
|
old_layout.left_panel_size = -1;
|
||||||
|
old_layout.top_panel_size = -1;
|
||||||
|
|
||||||
old_output_lines = -1;
|
old_output_lines = -1;
|
||||||
|
|
||||||
update_split (h);
|
update_split (h);
|
||||||
@ -328,11 +348,12 @@ layout_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *d
|
|||||||
if (mc_global.tty.console_flag != '\0')
|
if (mc_global.tty.console_flag != '\0')
|
||||||
{
|
{
|
||||||
int minimum;
|
int minimum;
|
||||||
|
|
||||||
if (_output_lines < 0)
|
if (_output_lines < 0)
|
||||||
_output_lines = 0;
|
_output_lines = 0;
|
||||||
height = LINES - _keybar_visible - (_command_prompt ? 1 : 0) -
|
height = LINES - _keybar_visible - (_command_prompt ? 1 : 0) -
|
||||||
_menubar_visible - _output_lines - _message_visible;
|
_menubar_visible - _output_lines - _message_visible;
|
||||||
minimum = MINHEIGHT * (1 + _horizontal_split);
|
minimum = MINHEIGHT * (1 + _panels_layout.horizontal_split);
|
||||||
if (height < minimum)
|
if (height < minimum)
|
||||||
{
|
{
|
||||||
_output_lines -= minimum - height;
|
_output_lines -= minimum - height;
|
||||||
@ -355,15 +376,19 @@ layout_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *d
|
|||||||
case DLG_ACTION:
|
case DLG_ACTION:
|
||||||
if (sender == (Widget *) radio_widget)
|
if (sender == (Widget *) radio_widget)
|
||||||
{
|
{
|
||||||
if (_horizontal_split != radio_widget->sel)
|
if (_panels_layout.horizontal_split != radio_widget->sel)
|
||||||
{
|
{
|
||||||
_horizontal_split = radio_widget->sel;
|
_panels_layout.horizontal_split = radio_widget->sel;
|
||||||
if (_equal_split)
|
|
||||||
|
if (_panels_layout.horizontal_split)
|
||||||
{
|
{
|
||||||
if (_horizontal_split)
|
if (_panels_layout.horizontal_equal)
|
||||||
_first_panel_size = height / 2;
|
_panels_layout.top_panel_size = height / 2;
|
||||||
else
|
}
|
||||||
_first_panel_size = COLS / 2;
|
else
|
||||||
|
{
|
||||||
|
if (_panels_layout.vertical_equal)
|
||||||
|
_panels_layout.left_panel_size = COLS / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,11 +399,22 @@ layout_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *d
|
|||||||
|
|
||||||
if (sender == (Widget *) check_options[6].widget)
|
if (sender == (Widget *) check_options[6].widget)
|
||||||
{
|
{
|
||||||
_equal_split = check_options[6].widget->state & C_BOOL;
|
int eq;
|
||||||
|
|
||||||
widget_disable (bleft_widget->widget, _equal_split);
|
if (_panels_layout.horizontal_split)
|
||||||
|
{
|
||||||
|
_panels_layout.horizontal_equal = check_options[6].widget->state & C_BOOL;
|
||||||
|
eq = _panels_layout.horizontal_equal;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_panels_layout.vertical_equal = check_options[6].widget->state & C_BOOL;
|
||||||
|
eq = _panels_layout.vertical_equal;
|
||||||
|
}
|
||||||
|
|
||||||
|
widget_disable (bleft_widget->widget, eq);
|
||||||
send_message ((Widget *) bleft_widget, WIDGET_DRAW, 0);
|
send_message ((Widget *) bleft_widget, WIDGET_DRAW, 0);
|
||||||
widget_disable (bright_widget->widget, _equal_split);
|
widget_disable (bright_widget->widget, eq);
|
||||||
send_message ((Widget *) bright_widget, WIDGET_DRAW, 0);
|
send_message ((Widget *) bright_widget, WIDGET_DRAW, 0);
|
||||||
|
|
||||||
update_split (h);
|
update_split (h);
|
||||||
@ -418,17 +454,19 @@ init_layout (void)
|
|||||||
output_lines_label = _("Output lines:");
|
output_lines_label = _("Output lines:");
|
||||||
|
|
||||||
/* save old params */
|
/* save old params */
|
||||||
_equal_split = equal_split;
|
_panels_layout = panels_layout;
|
||||||
_menubar_visible = menubar_visible;
|
_menubar_visible = menubar_visible;
|
||||||
_command_prompt = command_prompt;
|
_command_prompt = command_prompt;
|
||||||
_keybar_visible = mc_global.keybar_visible;
|
_keybar_visible = mc_global.keybar_visible;
|
||||||
_message_visible = mc_global.message_visible;
|
_message_visible = mc_global.message_visible;
|
||||||
_xterm_title = xterm_title;
|
_xterm_title = xterm_title;
|
||||||
_free_space = free_space;
|
_free_space = free_space;
|
||||||
old_first_panel_size = -1;
|
|
||||||
old_horizontal_split = -1;
|
old_layout.horizontal_split = -1;
|
||||||
|
old_layout.left_panel_size = -1;
|
||||||
|
old_layout.top_panel_size = -1;
|
||||||
|
|
||||||
old_output_lines = -1;
|
old_output_lines = -1;
|
||||||
_first_panel_size = first_panel_size;
|
|
||||||
_output_lines = output_lines;
|
_output_lines = output_lines;
|
||||||
|
|
||||||
#ifdef ENABLE_NLS
|
#ifdef ENABLE_NLS
|
||||||
@ -519,21 +557,23 @@ init_layout (void)
|
|||||||
add_widget (layout_dlg, w);
|
add_widget (layout_dlg, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
equal_split = panels_layout.horizontal_split ?
|
||||||
|
panels_layout.horizontal_equal : panels_layout.vertical_equal;
|
||||||
|
|
||||||
/* "Panel split" groupbox */
|
/* "Panel split" groupbox */
|
||||||
bright_widget = button_new (6, 14, B_2RIGHT, NARROW_BUTTON, "&>", b_left_right_cback);
|
bright_widget = button_new (6, 14, B_2RIGHT, NARROW_BUTTON, "&>", b_left_right_cback);
|
||||||
widget_disable (bright_widget->widget, _equal_split);
|
widget_disable (bright_widget->widget, equal_split);
|
||||||
add_widget (layout_dlg, bright_widget);
|
add_widget (layout_dlg, bright_widget);
|
||||||
|
|
||||||
bleft_widget = button_new (6, 8, B_2LEFT, NARROW_BUTTON, "&<", b_left_right_cback);
|
bleft_widget = button_new (6, 8, B_2LEFT, NARROW_BUTTON, "&<", b_left_right_cback);
|
||||||
widget_disable (bleft_widget->widget, _equal_split);
|
widget_disable (bleft_widget->widget, equal_split);
|
||||||
add_widget (layout_dlg, bleft_widget);
|
add_widget (layout_dlg, bleft_widget);
|
||||||
|
|
||||||
check_options[6].widget = check_new (5, 5, XTRACT (6));
|
check_options[6].widget = check_new (5, 5, XTRACT (6));
|
||||||
add_widget (layout_dlg, check_options[6].widget);
|
add_widget (layout_dlg, check_options[6].widget);
|
||||||
|
|
||||||
radio_widget = radio_new (3, 5, 2, s_split_direction);
|
radio_widget = radio_new (3, 5, 2, s_split_direction);
|
||||||
radio_widget->sel = horizontal_split;
|
radio_widget->sel = panels_layout.horizontal_split;
|
||||||
add_widget (layout_dlg, radio_widget);
|
add_widget (layout_dlg, radio_widget);
|
||||||
|
|
||||||
add_widget (layout_dlg, groupbox_new (2, 3, 6, l1, title1));
|
add_widget (layout_dlg, groupbox_new (2, 3, 6, l1, title1));
|
||||||
@ -545,31 +585,6 @@ init_layout (void)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
|
||||||
check_split (void)
|
|
||||||
{
|
|
||||||
if (horizontal_split)
|
|
||||||
{
|
|
||||||
if (equal_split)
|
|
||||||
first_panel_size = height / 2;
|
|
||||||
else if (first_panel_size < MINHEIGHT)
|
|
||||||
first_panel_size = MINHEIGHT;
|
|
||||||
else if (first_panel_size > height - MINHEIGHT)
|
|
||||||
first_panel_size = height - MINHEIGHT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (equal_split)
|
|
||||||
first_panel_size = COLS / 2;
|
|
||||||
else if (first_panel_size < MINWIDTH)
|
|
||||||
first_panel_size = MINWIDTH;
|
|
||||||
else if (first_panel_size > COLS - MINWIDTH)
|
|
||||||
first_panel_size = COLS - MINWIDTH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
panel_do_cols (int idx)
|
panel_do_cols (int idx)
|
||||||
{
|
{
|
||||||
@ -626,11 +641,22 @@ layout_box (void)
|
|||||||
if (run_dlg (layout_dlg) == B_ENTER)
|
if (run_dlg (layout_dlg) == B_ENTER)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < (size_t) LAYOUT_OPTIONS_COUNT; i++)
|
for (i = 0; i < (size_t) LAYOUT_OPTIONS_COUNT; i++)
|
||||||
if (check_options[i].widget != NULL)
|
if (check_options[i].widget != NULL)
|
||||||
*check_options[i].variable = check_options[i].widget->state & C_BOOL;
|
*check_options[i].variable = check_options[i].widget->state & C_BOOL;
|
||||||
horizontal_split = radio_widget->sel;
|
|
||||||
first_panel_size = _first_panel_size;
|
panels_layout.horizontal_split = radio_widget->sel;
|
||||||
|
if (panels_layout.horizontal_split)
|
||||||
|
{
|
||||||
|
panels_layout.horizontal_equal = *check_options[6].variable;
|
||||||
|
panels_layout.top_panel_size = _panels_layout.top_panel_size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
panels_layout.vertical_equal = *check_options[6].variable;
|
||||||
|
panels_layout.left_panel_size = _panels_layout.left_panel_size;
|
||||||
|
}
|
||||||
output_lines = _output_lines;
|
output_lines = _output_lines;
|
||||||
layout_do_change = TRUE;
|
layout_do_change = TRUE;
|
||||||
}
|
}
|
||||||
@ -650,12 +676,13 @@ setup_panels (void)
|
|||||||
if (mc_global.tty.console_flag != '\0')
|
if (mc_global.tty.console_flag != '\0')
|
||||||
{
|
{
|
||||||
int minimum;
|
int minimum;
|
||||||
|
|
||||||
if (output_lines < 0)
|
if (output_lines < 0)
|
||||||
output_lines = 0;
|
output_lines = 0;
|
||||||
height =
|
height =
|
||||||
LINES - mc_global.keybar_visible - (command_prompt ? 1 : 0) - menubar_visible -
|
LINES - mc_global.keybar_visible - (command_prompt ? 1 : 0) - menubar_visible -
|
||||||
output_lines - mc_global.message_visible;
|
output_lines - mc_global.message_visible;
|
||||||
minimum = MINHEIGHT * (1 + horizontal_split);
|
minimum = MINHEIGHT * (1 + panels_layout.horizontal_split);
|
||||||
if (height < minimum)
|
if (height < minimum)
|
||||||
{
|
{
|
||||||
output_lines -= minimum - height;
|
output_lines -= minimum - height;
|
||||||
@ -668,26 +695,23 @@ setup_panels (void)
|
|||||||
LINES - menubar_visible - (command_prompt ? 1 : 0) - mc_global.keybar_visible -
|
LINES - menubar_visible - (command_prompt ? 1 : 0) - mc_global.keybar_visible -
|
||||||
mc_global.message_visible;
|
mc_global.message_visible;
|
||||||
}
|
}
|
||||||
check_split ();
|
|
||||||
|
check_split (&panels_layout);
|
||||||
start_y = menubar_visible;
|
start_y = menubar_visible;
|
||||||
|
|
||||||
/* The column computing is defered until panel_do_cols */
|
/* The column computing is defered until panel_do_cols */
|
||||||
if (horizontal_split)
|
if (panels_layout.horizontal_split)
|
||||||
{
|
{
|
||||||
widget_set_size (panels[0].widget, start_y, 0, first_panel_size, 0);
|
widget_set_size (panels[0].widget, start_y, 0, panels_layout.top_panel_size, 0);
|
||||||
|
widget_set_size (panels[1].widget, start_y + panels_layout.top_panel_size, 0,
|
||||||
widget_set_size (panels[1].widget, start_y + first_panel_size, 0,
|
height - panels_layout.top_panel_size, 0);
|
||||||
height - first_panel_size, 0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int first_x = first_panel_size;
|
|
||||||
|
|
||||||
widget_set_size (panels[0].widget, start_y, 0, height, 0);
|
widget_set_size (panels[0].widget, start_y, 0, height, 0);
|
||||||
|
widget_set_size (panels[1].widget, start_y, panels_layout.left_panel_size, height, 0);
|
||||||
widget_set_size (panels[1].widget, start_y, first_x, height, 0);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
panel_do_cols (0);
|
panel_do_cols (0);
|
||||||
panel_do_cols (1);
|
panel_do_cols (1);
|
||||||
|
|
||||||
@ -872,9 +896,17 @@ set_display_type (int num, panel_view_mode_t type)
|
|||||||
|
|
||||||
if (old_type == view_listing && panel->frame_size == frame_full && type != view_listing)
|
if (old_type == view_listing && panel->frame_size == frame_full && type != view_listing)
|
||||||
{
|
{
|
||||||
cols = COLS - first_panel_size;
|
if (panels_layout.horizontal_split)
|
||||||
if (num == 1)
|
{
|
||||||
x = first_panel_size;
|
cols = COLS;
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cols = COLS - panels_layout.left_panel_size;
|
||||||
|
if (num == 1)
|
||||||
|
x = panels_layout.left_panel_size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -883,6 +915,7 @@ set_display_type (int num, panel_view_mode_t type)
|
|||||||
if (old_widget == NULL && type != view_listing)
|
if (old_widget == NULL && type != view_listing)
|
||||||
{
|
{
|
||||||
char panel_dir[MC_MAXPATHLEN];
|
char panel_dir[MC_MAXPATHLEN];
|
||||||
|
|
||||||
mc_get_current_wd (panel_dir, sizeof (panel_dir));
|
mc_get_current_wd (panel_dir, sizeof (panel_dir));
|
||||||
panels[num].last_saved_dir = g_strdup (panel_dir);
|
panels[num].last_saved_dir = g_strdup (panel_dir);
|
||||||
}
|
}
|
||||||
|
@ -25,20 +25,31 @@ typedef enum
|
|||||||
|
|
||||||
struct WPanel;
|
struct WPanel;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int horizontal_split;
|
||||||
|
|
||||||
|
/* vertical split */
|
||||||
|
int vertical_equal;
|
||||||
|
int left_panel_size;
|
||||||
|
|
||||||
|
/* horizontal split */
|
||||||
|
int horizontal_equal;
|
||||||
|
int top_panel_size;
|
||||||
|
} panels_layout_t;
|
||||||
|
|
||||||
/*** global variables defined in .c file *********************************************************/
|
/*** global variables defined in .c file *********************************************************/
|
||||||
|
|
||||||
extern int equal_split;
|
|
||||||
extern int first_panel_size;
|
|
||||||
extern int output_lines;
|
extern int output_lines;
|
||||||
extern gboolean command_prompt;
|
extern gboolean command_prompt;
|
||||||
extern int menubar_visible;
|
extern int menubar_visible;
|
||||||
extern int output_start_y;
|
extern int output_start_y;
|
||||||
extern gboolean xterm_title;
|
extern gboolean xterm_title;
|
||||||
extern int free_space;
|
extern int free_space;
|
||||||
|
|
||||||
extern int horizontal_split;
|
|
||||||
extern int nice_rotating_dash;
|
extern int nice_rotating_dash;
|
||||||
|
|
||||||
|
extern panels_layout_t panels_layout;
|
||||||
|
|
||||||
/*** declarations of public functions ************************************************************/
|
/*** declarations of public functions ************************************************************/
|
||||||
|
|
||||||
void layout_change (void);
|
void layout_change (void);
|
||||||
|
@ -462,7 +462,7 @@ midnight_get_title (const Dlg_head * h, size_t len)
|
|||||||
static void
|
static void
|
||||||
toggle_panels_split (void)
|
toggle_panels_split (void)
|
||||||
{
|
{
|
||||||
horizontal_split = !horizontal_split;
|
panels_layout.horizontal_split = !panels_layout.horizontal_split;
|
||||||
layout_change ();
|
layout_change ();
|
||||||
do_refresh ();
|
do_refresh ();
|
||||||
}
|
}
|
||||||
@ -1534,8 +1534,8 @@ midnight_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void
|
|||||||
void
|
void
|
||||||
update_menu (void)
|
update_menu (void)
|
||||||
{
|
{
|
||||||
menu_set_name (left_menu, horizontal_split ? _("&Above") : _("&Left"));
|
menu_set_name (left_menu, panels_layout.horizontal_split ? _("&Above") : _("&Left"));
|
||||||
menu_set_name (right_menu, horizontal_split ? _("&Below") : _("&Right"));
|
menu_set_name (right_menu, panels_layout.horizontal_split ? _("&Below") : _("&Right"));
|
||||||
menubar_arrange (the_menubar);
|
menubar_arrange (the_menubar);
|
||||||
menubar_set_visible (the_menubar, menubar_visible);
|
menubar_set_visible (the_menubar, menubar_visible);
|
||||||
}
|
}
|
||||||
|
@ -3882,7 +3882,7 @@ panel_update_cols (Widget * widget, panel_display_t frame_size)
|
|||||||
if (widget->owner == NULL)
|
if (widget->owner == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (horizontal_split)
|
if (panels_layout.horizontal_split)
|
||||||
{
|
{
|
||||||
widget->cols = COLS;
|
widget->cols = COLS;
|
||||||
return;
|
return;
|
||||||
@ -3895,13 +3895,13 @@ panel_update_cols (Widget * widget, panel_display_t frame_size)
|
|||||||
}
|
}
|
||||||
else if (widget == get_panel_widget (0))
|
else if (widget == get_panel_widget (0))
|
||||||
{
|
{
|
||||||
cols = first_panel_size;
|
cols = panels_layout.left_panel_size;
|
||||||
origin = 0;
|
origin = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cols = COLS - first_panel_size;
|
cols = COLS - panels_layout.left_panel_size;
|
||||||
origin = first_panel_size;
|
origin = panels_layout.left_panel_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
widget->cols = cols;
|
widget->cols = cols;
|
||||||
|
32
src/setup.c
32
src/setup.c
@ -217,8 +217,6 @@ static const struct
|
|||||||
const char *opt_name;
|
const char *opt_name;
|
||||||
int *opt_addr;
|
int *opt_addr;
|
||||||
} layout [] = {
|
} layout [] = {
|
||||||
{ "equal_split", &equal_split },
|
|
||||||
{ "first_panel_size", &first_panel_size },
|
|
||||||
{ "message_visible", &mc_global.message_visible },
|
{ "message_visible", &mc_global.message_visible },
|
||||||
{ "keybar_visible", &mc_global.keybar_visible },
|
{ "keybar_visible", &mc_global.keybar_visible },
|
||||||
{ "xterm_title", &xterm_title },
|
{ "xterm_title", &xterm_title },
|
||||||
@ -226,6 +224,11 @@ static const struct
|
|||||||
{ "command_prompt", &command_prompt },
|
{ "command_prompt", &command_prompt },
|
||||||
{ "menubar_visible", &menubar_visible },
|
{ "menubar_visible", &menubar_visible },
|
||||||
{ "free_space", &free_space },
|
{ "free_space", &free_space },
|
||||||
|
{ "horizontal_split", &panels_layout.horizontal_split },
|
||||||
|
{ "vertical_equal", &panels_layout.vertical_equal },
|
||||||
|
{ "left_panel_size", &panels_layout.left_panel_size },
|
||||||
|
{ "horizontal_equal", &panels_layout.horizontal_equal },
|
||||||
|
{ "top_panel_size", &panels_layout.top_panel_size },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -317,7 +320,6 @@ static const struct
|
|||||||
{ "editor_group_undo", &option_group_undo },
|
{ "editor_group_undo", &option_group_undo },
|
||||||
#endif /* USE_INTERNAL_EDIT */
|
#endif /* USE_INTERNAL_EDIT */
|
||||||
{ "nice_rotating_dash", &nice_rotating_dash },
|
{ "nice_rotating_dash", &nice_rotating_dash },
|
||||||
{ "horizontal_split", &horizontal_split },
|
|
||||||
{ "mcview_remember_file_position", &mcview_remember_file_position },
|
{ "mcview_remember_file_position", &mcview_remember_file_position },
|
||||||
{ "auto_fill_mkdir_name", &auto_fill_mkdir_name },
|
{ "auto_fill_mkdir_name", &auto_fill_mkdir_name },
|
||||||
{ "copymove_persistent_attr", &setup_copymove_persistent_attr },
|
{ "copymove_persistent_attr", &setup_copymove_persistent_attr },
|
||||||
@ -534,10 +536,34 @@ static void
|
|||||||
load_layout (void)
|
load_layout (void)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
int equal_split;
|
||||||
|
int first_panel_size;
|
||||||
|
|
||||||
|
/* legacy options */
|
||||||
|
panels_layout.horizontal_split = mc_config_get_int (mc_main_config, CONFIG_APP_SECTION,
|
||||||
|
"horizontal_split", 0);
|
||||||
|
equal_split = mc_config_get_int (mc_main_config, "Layout", "equal_split", 1);
|
||||||
|
first_panel_size = mc_config_get_int (mc_main_config, "Layout", "first_panel_size", 1);
|
||||||
|
if (panels_layout.horizontal_split)
|
||||||
|
{
|
||||||
|
panels_layout.horizontal_equal = equal_split;
|
||||||
|
panels_layout.left_panel_size = first_panel_size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
panels_layout.vertical_equal = equal_split;
|
||||||
|
panels_layout.top_panel_size = first_panel_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* actual options override legacy ones */
|
||||||
for (i = 0; layout[i].opt_name != NULL; i++)
|
for (i = 0; layout[i].opt_name != NULL; i++)
|
||||||
*layout[i].opt_addr = mc_config_get_int (mc_main_config, "Layout",
|
*layout[i].opt_addr = mc_config_get_int (mc_main_config, "Layout",
|
||||||
layout[i].opt_name, *layout[i].opt_addr);
|
layout[i].opt_name, *layout[i].opt_addr);
|
||||||
|
|
||||||
|
/* remove legacy options */
|
||||||
|
mc_config_del_key (mc_main_config, CONFIG_APP_SECTION, "horizontal_split");
|
||||||
|
mc_config_del_key (mc_main_config, "Layout", "equal_split");
|
||||||
|
mc_config_del_key (mc_main_config, "Layout", "first_panel_size");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user