From 5e688eec946566baa0361cfe0b3b72018027d13f Mon Sep 17 00:00:00 2001 From: Ilia Maslakov Date: Mon, 6 Feb 2012 19:14:22 +0400 Subject: [PATCH] Ticket #2465 (dynamically resize panels) added new panel's action to dynamically resize panels: SplitEqual - make equal size of panels SplitMore - enlarge left/up panel SplitLess - enlarge right/down panel changed misc/mc.keymap.default, misc/mc.keymap.emacs Signed-off-by: Ilia Maslakov --- lib/keybind.c | 6 ++--- lib/keybind.h | 6 ++--- misc/mc.keymap.default | 3 +++ misc/mc.keymap.emacs | 3 +++ src/filemanager/layout.c | 53 ++++++++++++++++++++++++++++++++++++++ src/filemanager/layout.h | 4 ++- src/filemanager/midnight.c | 9 +++++++ 7 files changed, 77 insertions(+), 7 deletions(-) diff --git a/lib/keybind.c b/lib/keybind.c index ca55c1fe8..19d84b0c2 100644 --- a/lib/keybind.c +++ b/lib/keybind.c @@ -194,6 +194,9 @@ static name_keymap_t command_names[] = { {"HotListAdd", CK_HotListAdd}, {"ShowHidden", CK_ShowHidden}, {"SplitVertHoriz", CK_SplitVertHoriz}, + {"SplitEqual", CK_SplitEqual}, + {"SplitMore", CK_SplitMore}, + {"SplitLess", CK_SplitLess}, {"PutCurrentPath", CK_PutCurrentPath}, {"PutOtherPath", CK_PutOtherPath}, {"PutCurrentTagged", CK_PutCurrentTagged}, @@ -324,9 +327,6 @@ static name_keymap_t command_names[] = { /* diff viewer */ {"ShowSymbols", CK_ShowSymbols}, {"SplitFull", CK_SplitFull}, - {"SplitEqual", CK_SplitEqual}, - {"SplitMore", CK_SplitMore}, - {"SplitLess", CK_SplitLess}, {"Tab2", CK_Tab2}, {"Tab3", CK_Tab3}, {"Tab4", CK_Tab4}, diff --git a/lib/keybind.h b/lib/keybind.h index 7e16110eb..a9f2b5c70 100644 --- a/lib/keybind.h +++ b/lib/keybind.h @@ -164,6 +164,9 @@ enum CK_Tree, CK_Undelete, CK_SplitVertHoriz, + CK_SplitEqual, + CK_SplitMore, + CK_SplitLess, CK_CompareFiles, CK_OptionsPanel, CK_LinkSymbolicRelative, @@ -304,9 +307,6 @@ enum /* diff viewer */ CK_ShowSymbols = 700, CK_SplitFull, - CK_SplitEqual, - CK_SplitMore, - CK_SplitLess, CK_Tab2, CK_Tab3, CK_Tab4, diff --git a/misc/mc.keymap.default b/misc/mc.keymap.default index 0611ec4e4..14ab458fd 100644 --- a/misc/mc.keymap.default +++ b/misc/mc.keymap.default @@ -26,6 +26,9 @@ PanelListingSwitch = alt-t PanelListingChange = ShowHidden = alt-dot SplitVertHoriz = alt-comma +SplitEqual = alt-equal +SplitMore = alt-shift-right +SplitLess = alt-shift-left Shell = ctrl-o PutCurrentPath = alt-a PutOtherPath = alt-shift-a diff --git a/misc/mc.keymap.emacs b/misc/mc.keymap.emacs index add0e2dc8..9a3266d1e 100644 --- a/misc/mc.keymap.emacs +++ b/misc/mc.keymap.emacs @@ -26,6 +26,9 @@ PanelListingSwitch = alt-t PanelListingChange = ShowHidden = alt-dot SplitVertHoriz = alt-comma +SplitEqual = alt-equal +SplitMore = alt-shift-right +SplitLess = alt-shift-left Shell = ctrl-o PutCurrentPath = alt-a PutOtherPath = alt-shift-a diff --git a/src/filemanager/layout.c b/src/filemanager/layout.c index bb126a093..f49f046a4 100644 --- a/src/filemanager/layout.c +++ b/src/filemanager/layout.c @@ -753,6 +753,59 @@ setup_panels (void) /* --------------------------------------------------------------------------------------------- */ +void +panels_split_equal (void) +{ + if (panels_layout.horizontal_split) + panels_layout.horizontal_equal = TRUE; + else + panels_layout.vertical_equal = TRUE; + + layout_change (); + do_refresh (); +} + +/* --------------------------------------------------------------------------------------------- */ + +void +panels_split_more (void) +{ + if (panels_layout.horizontal_split) + { + panels_layout.horizontal_equal = FALSE; + panels_layout.top_panel_size++; + } + else + { + panels_layout.vertical_equal = FALSE; + panels_layout.left_panel_size++; + } + + layout_change (); +} + +/* --------------------------------------------------------------------------------------------- */ + +void +panels_split_less (void) +{ + if (panels_layout.horizontal_split) + { + panels_layout.horizontal_equal = FALSE; + panels_layout.top_panel_size--; + } + else + { + panels_layout.vertical_equal = FALSE; + panels_layout.left_panel_size--; + } + + layout_change (); +} + +/* --------------------------------------------------------------------------------------------- */ + + void setup_cmdline (void) { diff --git a/src/filemanager/layout.h b/src/filemanager/layout.h index 3467b3dcd..80e0c80ae 100644 --- a/src/filemanager/layout.h +++ b/src/filemanager/layout.h @@ -51,10 +51,12 @@ extern int nice_rotating_dash; extern panels_layout_t panels_layout; /*** declarations of public functions ************************************************************/ - void layout_change (void); void layout_box (void); void setup_panels (void); +void panels_split_equal (void); +void panels_split_more (void); +void panels_split_less (void); void destroy_panels (void); void setup_cmdline (void); void set_display_type (int num, panel_view_mode_t type); diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c index 3734e73af..165454397 100644 --- a/src/filemanager/midnight.c +++ b/src/filemanager/midnight.c @@ -1294,6 +1294,15 @@ midnight_execute_cmd (Widget * sender, unsigned long command) case CK_SplitVertHoriz: toggle_panels_split (); break; + case CK_SplitEqual: + panels_split_equal (); + break; + case CK_SplitMore: + panels_split_more (); + break; + case CK_SplitLess: + panels_split_less (); + break; case CK_PanelTree: panel_tree_cmd (); break;