From 125e4cb86ba976f3f04759b0baa912a99a67ccfd Mon Sep 17 00:00:00 2001 From: Ilia Maslakov Date: Fri, 8 Apr 2011 10:04:04 +0000 Subject: [PATCH] Ticket #2534 (mark files by shift-left/shift-right) added actions for mark files in the panel by shift-left/shift-right Signed-off-by: Andrew Borodin Signed-off-by: Ilia Maslakov --- misc/mc.keymap.default | 2 ++ misc/mc.keymap.emacs | 2 ++ src/filemanager/panel.c | 62 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/misc/mc.keymap.default b/misc/mc.keymap.default index dcb5d2e45..95368d513 100644 --- a/misc/mc.keymap.default +++ b/misc/mc.keymap.default @@ -77,6 +77,8 @@ Search = ctrl-s; alt-s Mark = insert; ctrl-t MarkUp = shift-up MarkDown = shift-down +MarkLeft = +MarkRight = Down = down; ctrl-n Up = up; ctrl-p Left = left diff --git a/misc/mc.keymap.emacs b/misc/mc.keymap.emacs index 9bbafaf53..5100dbe7e 100644 --- a/misc/mc.keymap.emacs +++ b/misc/mc.keymap.emacs @@ -78,6 +78,8 @@ Search = ctrl-s; alt-s Mark = insert; ctrl-t MarkUp = shift-up MarkDown = shift-down +MarkLeft = +MarkRight = Down = down; ctrl-n Up = up; ctrl-p Left = left diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c index 2794580fa..c85d9d37a 100644 --- a/src/filemanager/panel.c +++ b/src/filemanager/panel.c @@ -350,7 +350,7 @@ static char *panel_history_show_list_sign = NULL; static WPanel *mouse_mark_panel = NULL; static int mouse_marking = 0; - +static int state_mark = 0; /*** file scope functions ************************************************************************/ /* --------------------------------------------------------------------------------------------- */ @@ -2059,6 +2059,44 @@ mark_file_down (WPanel * panel) do_mark_file (panel, MARK_FORCE_DOWN); } +/* --------------------------------------------------------------------------------------------- */ + +static void +mark_file_right (WPanel * panel) +{ + int lines = llines (panel); + + if (state_mark < 0) + state_mark = selection (panel)->f.marked ? 0 : 1; + + lines = min (lines, panel->count - panel->selected - 1); + for (; lines != 0; lines--) + { + do_file_mark (panel, panel->selected, state_mark); + move_down (panel); + } + do_file_mark (panel, panel->selected, state_mark); +} + +/* --------------------------------------------------------------------------------------------- */ + +static void +mark_file_left (WPanel * panel) +{ + int lines = llines (panel); + + if (state_mark < 0) + state_mark = selection (panel)->f.marked ? 0 : 1; + + lines = min (lines, panel->selected + 1); + for (; lines != 0; lines--) + { + do_file_mark (panel, panel->selected, state_mark); + move_up (panel); + } + do_file_mark (panel, panel->selected, state_mark); +} + /* --------------------------------------------------------------------------------------------- */ /** Incremental search of a file name in the panel. * @param panel instance of WPanel structure @@ -2744,6 +2782,21 @@ panel_execute_cmd (WPanel * panel, unsigned long command) if (command != CK_Search) stop_search (panel); + + switch (command) + { + case CK_Up: + case CK_Down: + case CK_Left: + case CK_Right: + case CK_Bottom: + case CK_Top: + case CK_PageDown: + case CK_PageUp: + /* reset state of marks flag*/ + state_mark = -1; + break; + } switch (command) { case CK_PanelOtherCd: @@ -2818,6 +2871,12 @@ panel_execute_cmd (WPanel * panel, unsigned long command) case CK_MarkDown: mark_file_down (panel); break; + case CK_MarkLeft: + mark_file_left (panel); + break; + case CK_MarkRight: + mark_file_right (panel); + break; case CK_CdParentSmart: res = force_maybe_cd (); break; @@ -2951,6 +3010,7 @@ panel_callback (Widget * w, widget_msg_t msg, int parm) return MSG_HANDLED; case WIDGET_FOCUS: + state_mark = -1; current_panel = panel; panel->active = 1; if (mc_chdir (panel->cwd) != 0)