From 718fdc8accbff57fe4944d4016ee31f5a2c21fdf Mon Sep 17 00:00:00 2001 From: Ilia Maslakov Date: Mon, 10 May 2010 18:34:17 +0000 Subject: [PATCH] Ticket #2021 (MarkFileDown/MarkFileUp) Added a new panel action 'PanelMarkFileDown'/'PanelMarkFileUp' for mark files and move cursor to the down or up after mark. Signed-off-by: Ilia Maslakov --- misc/mc.keymap.default | 2 ++ misc/mc.keymap.emacs | 2 ++ src/cmddef.h | 40 +++++++++++++++++++++------------------- src/keybind.c | 2 ++ src/screen.c | 40 ++++++++++++++++++++++++++++++++++------ 5 files changed, 61 insertions(+), 25 deletions(-) diff --git a/misc/mc.keymap.default b/misc/mc.keymap.default index 0869d41f1..274c52c70 100644 --- a/misc/mc.keymap.default +++ b/misc/mc.keymap.default @@ -260,6 +260,8 @@ CmdDiffView = ctrl-y [panel] PanelStartSearch = ctrl-s; alt-s PanelMarkFile = insert; ctrl-t +PanelMarkFileUp = shift-up +PanelMarkFileDown = shift-down PanelMoveDown = down; ctrl-n PanelMoveUp = up; ctrl-p PanelMoveLeft = left diff --git a/misc/mc.keymap.emacs b/misc/mc.keymap.emacs index 2a7cb4ed3..22bc72259 100644 --- a/misc/mc.keymap.emacs +++ b/misc/mc.keymap.emacs @@ -264,6 +264,8 @@ CmdDiffView = ctrl-y [panel] PanelStartSearch = ctrl-s; alt-s PanelMarkFile = insert; ctrl-t +PanelMarkFileUp = shift-up +PanelMarkFileDown = shift-down PanelMoveDown = down; ctrl-n PanelMoveUp = up; ctrl-p PanelMoveLeft = left diff --git a/src/cmddef.h b/src/cmddef.h index 67abf24c3..95f5545ae 100644 --- a/src/cmddef.h +++ b/src/cmddef.h @@ -399,25 +399,27 @@ #define CK_PanelGotoMiddleFile 8018 #define CK_PanelGotoTopFile 8019 #define CK_PanelMarkFile 8020 -#define CK_PanelMoveDown 8021 -#define CK_PanelMoveEnd 8022 -#define CK_PanelMoveHome 8023 -#define CK_PanelMoveUp 8024 -#define CK_PanelMoveLeft 8025 -#define CK_PanelMoveRight 8026 -#define CK_PanelNextPage 8027 -#define CK_PanelPrevPage 8028 -#define CK_PanelSetPanelEncoding 8029 -#define CK_PanelStartSearch 8030 -#define CK_PanelSyncOtherPanel 8031 -#define CK_PanelToggleSortOrderNext 8032 -#define CK_PanelToggleSortOrderPrev 8033 -#define CK_PanelSelectSortOrder 8034 -#define CK_PanelReverseSort 8035 -#define CK_PanelSortOrderByName 8036 -#define CK_PanelSortOrderByExt 8037 -#define CK_PanelSortOrderBySize 8038 -#define CK_PanelSortOrderByMTime 8039 +#define CK_PanelMarkFileUp 8021 +#define CK_PanelMarkFileDown 8022 +#define CK_PanelMoveDown 8023 +#define CK_PanelMoveEnd 8024 +#define CK_PanelMoveHome 8025 +#define CK_PanelMoveUp 8026 +#define CK_PanelMoveLeft 8027 +#define CK_PanelMoveRight 8028 +#define CK_PanelNextPage 8029 +#define CK_PanelPrevPage 8030 +#define CK_PanelSetPanelEncoding 8031 +#define CK_PanelStartSearch 8032 +#define CK_PanelSyncOtherPanel 8033 +#define CK_PanelToggleSortOrderNext 8034 +#define CK_PanelToggleSortOrderPrev 8035 +#define CK_PanelSelectSortOrder 8036 +#define CK_PanelReverseSort 8037 +#define CK_PanelSortOrderByName 8038 +#define CK_PanelSortOrderByExt 8039 +#define CK_PanelSortOrderBySize 8040 +#define CK_PanelSortOrderByMTime 8041 /* diff viewer */ #define CK_DiffDisplaySymbols 9001 diff --git a/src/keybind.c b/src/keybind.c index c9a32fd6b..0e74bc864 100644 --- a/src/keybind.c +++ b/src/keybind.c @@ -424,6 +424,8 @@ static name_keymap_t command_names[] = { { "PanelGotoMiddleFile", CK_PanelGotoMiddleFile }, { "PanelGotoTopFile", CK_PanelGotoTopFile }, { "PanelMarkFile", CK_PanelMarkFile }, + { "PanelMarkFileDown", CK_PanelMarkFileDown }, + { "PanelMarkFileUp", CK_PanelMarkFileUp }, { "PanelMoveUp", CK_PanelMoveUp }, { "PanelMoveDown", CK_PanelMoveDown }, { "PanelMoveLeft", CK_PanelMoveLeft }, diff --git a/src/screen.c b/src/screen.c index 8237b5e6f..746d9eeab 100644 --- a/src/screen.c +++ b/src/screen.c @@ -73,6 +73,14 @@ #define MARKED_SELECTED 3 #define STATUS 5 +typedef enum +{ + MARK_DONT_MOVE = 0, + MARK_DOWN = 1, + MARK_FORCE_DOWN = 2, + MARK_FORCE_UP = 3 +} mark_act_t; + /* * This describes a format item. The parse_display_format routine parses * the user specified format and creates a linked list of format_e structures. @@ -2346,17 +2354,31 @@ do_file_mark (WPanel * panel, int idx, int mark) } static void -do_mark_file (WPanel * panel, int do_move) +do_mark_file (WPanel * panel, mark_act_t do_move) { do_file_mark (panel, panel->selected, selection (panel)->f.marked ? 0 : 1); - if (mark_moves_down && do_move) + if ((mark_moves_down && do_move == MARK_DOWN) || do_move == MARK_FORCE_DOWN) move_down (panel); + else if (do_move == MARK_FORCE_UP) + move_up (panel); } static void mark_file (WPanel * panel) { - do_mark_file (panel, 1); + do_mark_file (panel, MARK_DOWN); +} + +static void +mark_file_up (WPanel * panel) +{ + do_mark_file (panel, MARK_FORCE_UP); +} + +static void +mark_file_down (WPanel * panel) +{ + do_mark_file (panel, MARK_FORCE_DOWN); } /* Incremental search of a file name in the panel */ @@ -2936,6 +2958,12 @@ panel_execute_cmd (WPanel * panel, unsigned long command) case CK_PanelMarkFile: mark_file (panel); break; + case CK_PanelMarkFileUp: + mark_file_up (panel); + break; + case CK_PanelMarkFileDown: + mark_file_down (panel); + break; case CK_PanelMoveUp: move_up (panel); break; @@ -3131,7 +3159,7 @@ static int mouse_marking = 0; static void mouse_toggle_mark (WPanel * panel) { - do_mark_file (panel, 0); + do_mark_file (panel, MARK_DONT_MOVE); mouse_marking = selection (panel)->f.marked; } @@ -3139,9 +3167,9 @@ static void mouse_set_mark (WPanel * panel) { if (mouse_marking && !(selection (panel)->f.marked)) - do_mark_file (panel, 0); + do_mark_file (panel, MARK_DONT_MOVE); else if (!mouse_marking && (selection (panel)->f.marked)) - do_mark_file (panel, 0); + do_mark_file (panel, MARK_DONT_MOVE); } static int