Browse Source

Ticket #1531: old method of reverse selection of files.

Now Gray-* shortcut inverts selection of directories as well as files.
This is very confusing feature especially when user is going to delete
files.

Added new variable 'reverse_files_only' allows use the old behavior
of reverse selection.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Andrew Borodin 15 years ago
parent
commit
96e032b473
5 changed files with 29 additions and 5 deletions
  1. 7 0
      doc/man/mc.1.in
  2. 8 1
      doc/man/ru/mc.1.in
  3. 12 4
      src/cmd.c
  4. 1 0
      src/setup.c
  5. 1 0
      src/setup.h

+ 7 - 0
doc/man/mc.1.in

@@ -3177,6 +3177,13 @@ don't need to quote those characters in the middle of the command line.
 On the other hand, you cannot use them to change selection when the
 command line is not empty.
 .TP
+.I reverse_files_only
+Allow revert selection of files only. This variable is on by default.
+If on, the reverse selection is applied to files only, not to directories.
+The selection of directories is untouched. If off, the reverse
+selection is applied to files as well to directories: all unselected
+items become selected, and vice versa.
+.TP
 .I panel_scroll_pages
 If set (the default), panel will scroll by half the display when the
 cursor reaches the end or the beginning of the panel, otherwise it

+ 8 - 1
doc/man/ru/mc.1.in

@@ -3551,7 +3551,7 @@ router). Эта опция работает только в том случае,
 .PP
 .I only_leading_plus_minus
 .IP
-устанавливает специальный режим обработки символов '+', '-', '*' в
+Устанавливает специальный режим обработки символов '+', '-', '*' в
 командной строке. Эти символы используются для выбора, отмены выбора и
 инвертирования выбора, но выполняют такую функцию только если командная
 строка пуста. В середине командной строки эти символы уже не вызывают
@@ -3559,6 +3559,13 @@ router). Эта опция работает только в том случае,
 использовать эти символы для таких операций, если командная строка не
 пуста.
 .PP
+.I reverse_files_only
+.IP
+Если опция установлена (по умолчанию она установлена), инвертирование
+выбора применяется только к файлам, но не к каталогам. Выбор каталогов
+не изменяется. Если не установлена, производится инвертирование как файлов,
+так и каталогов. Все невыбранные объекты становятся выбранными и наоборот.
+.PP
 .I panel_scroll_pages
 .IP
 Если опция установлена (по умолчанию она установлена), то когда курсор

+ 12 - 4
src/cmd.c

@@ -53,6 +53,8 @@
 
 #include "../src/search/search.h"
 
+#include "../src/mcconfig/mcconfig.h"
+
 #include "cmd.h"		/* Our definitions */
 #include "fileopctx.h"
 #include "file.h"		/* file operation routines */
@@ -73,8 +75,7 @@
 #include "layout.h"		/* get_current_type() */
 #include "ext.h"		/* regex_command() */
 #include "boxes.h"		/* cd_dialog() */
-#include "setup.h"		/* save_setup() */
-#include "../src/mcconfig/mcconfig.h"
+#include "setup.h"
 #include "execute.h"		/* toggle_panels() */
 #include "history.h"
 #include "strutil.h"
@@ -97,6 +98,9 @@ int use_internal_edit = 1;
 /* Automatically fills name with current selected item name on mkdir */
 int auto_fill_mkdir_name = 1;
 
+/* if set, only selection of files is inverted */
+int reverse_files_only = 1;
+
 /* selection flags */
 typedef enum {
     SELECT_FILES_ONLY = 1 << 0,
@@ -494,9 +498,13 @@ void
 reverse_selection_cmd (void)
 {
     int i;
+    file_entry *file;
 
-    for (i = 0; i < current_panel->count; i++)
-	do_file_mark (current_panel, i, !current_panel->dir.list [i].f.marked);
+    for (i = 0; i < current_panel->count; i++) {
+	file = &current_panel->dir.list [i];
+	if ((reverse_files_only == 0) || !S_ISDIR (file->st.st_mode))
+	    do_file_mark (current_panel, i, !file->f.marked);
+    }
 }
 
 static void

+ 1 - 0
src/setup.c

@@ -236,6 +236,7 @@ static const struct {
     { "horizontal_split",   &horizontal_split },
     { "mcview_remember_file_position", &mcview_remember_file_position },
     { "auto_fill_mkdir_name", &auto_fill_mkdir_name },
+    { "reverse_files_only", &reverse_files_only },
     { 0, 0 }
 };
 

+ 1 - 0
src/setup.h

@@ -32,6 +32,7 @@ extern int startup_right_mode;
 extern int verbose;
 
 extern int mouse_close_dialog;
+extern int reverse_files_only;
 
 #define PROFILE_NAME     ".mc/ini"
 #define HOTLIST_FILENAME ".mc/hotlist"