CTRL-"+|-|*" selection



5) this patch for select/unselect/reverse selections. using CTRL-"+", 
CTRL-"-" keys select/unselect all files and dirs (mask "*").
CTRL-"*" reverse selection including dirs.

-- 
C U L8er!
Max Schedriviy                  mailto:max tavrida net
diff -Naur mc/src/cmd.c mc-new/src/cmd.c
--- mc/src/cmd.c	Wed Jun 27 16:29:14 2001
+++ mc-new/src/cmd.c	Mon Jul  2 16:00:52 2001
@@ -511,14 +511,38 @@
 }
 #endif /* HAVE_X */
 
-void select_cmd_panel (WPanel *panel)
+/* reverse selection including directories - mAX */
+void reverse_selection_dir_cmd_panel (WPanel *panel)
+{
+    file_entry *file;
+    int i;
+
+    for (i = 0; i < panel->count; i++){
+	file = &panel->dir.list [i];
+	do_file_mark (panel, i, !file->f.marked);
+    }
+    paint_panel (panel);
+}
+
+#ifndef HAVE_X
+void reverse_selection_dir_cmd (void)
+{
+    reverse_selection_dir_cmd_panel (cpanel);
+}
+#endif /* HAVE_X */
+
+void select_cmd_panel (WPanel *panel, int force)
 {
     char *reg_exp, *reg_exp_t;
     int i;
     int c;
     int dirflag = 0;
 
-    reg_exp = input_dialog (_(" Select "), "", easy_patterns ? "*" : ".");
+    if (!force)	/* if force, don't show unselect dialog and reg_exp="*" - mAX */
+	reg_exp = input_dialog (_(" Select "), "", easy_patterns ? "*" : ".");
+    else
+	reg_exp = g_strdup("*");
+
     if (!reg_exp)
 	return;
     
@@ -537,12 +561,14 @@
     for (i = 0; i < panel->count; i++){
         if (!strcmp (panel->dir.list [i].fname, ".."))
             continue;
-	if (S_ISDIR (panel->dir.list [i].buf.st_mode)){
-	    if (!dirflag)
-                continue;
-        } else {
-            if (dirflag)
-                continue;
+	if (!force) {	/* if force, select directories too - mAX */
+	    if (S_ISDIR (panel->dir.list [i].buf.st_mode)){
+		if (!dirflag)
+		continue;
+	    } else {
+        	if (dirflag)
+		    continue;
+	    }
 	}
 	c = regexp_match (reg_exp_t, panel->dir.list [i].fname, match_file);
 	if (c == -1){
@@ -561,18 +587,28 @@
 #ifndef HAVE_X
 void select_cmd (void)
 {
-	select_cmd_panel (cpanel);
+	select_cmd_panel (cpanel, 0);	/* 0 - show select dialog - mAX */
+}
+
+void select_force_cmd (void)
+{
+	select_cmd_panel (cpanel, 1);	/* 1 - don't show select dialog - mAX */
 }
 #endif /* !HAVE_X */
 
-void unselect_cmd_panel (WPanel *panel)
+/* changed my mAX */
+void unselect_cmd_panel (WPanel *panel, int force)
 {
     char *reg_exp, *reg_exp_t;
     int i;
     int c;
     int dirflag = 0;
 
-    reg_exp = input_dialog (_(" Unselect "),"", easy_patterns ? "*" : ".");
+    if (!force)	/* if force, don't show unselect dialog and reg_exp="*" - mAX */
+	reg_exp = input_dialog (_(" Unselect "),"", easy_patterns ? "*" : ".");
+    else
+	reg_exp = g_strdup("*");
+
     if (!reg_exp)
 	return;
     
@@ -590,13 +626,15 @@
     for (i = 0; i < panel->count; i++){
         if (!strcmp (panel->dir.list [i].fname, "..")) 
             continue;
-	if (S_ISDIR (panel->dir.list [i].buf.st_mode)){
-	    if (!dirflag)
-	        continue;
-        } else {
-            if (dirflag)
-                continue;
-        }
+	if (!force) {	/* if force, unselect dirs too - mAX */
+	    if (S_ISDIR (panel->dir.list [i].buf.st_mode)){
+		if (!dirflag)
+	    	    continue;
+    	    } else {
+        	if (dirflag)
+            	    continue;
+    	    }
+	}
 	c = regexp_match (reg_exp_t, panel->dir.list [i].fname, match_file);
 	if (c == -1){
 	    message (1, MSG_ERROR, _("  Malformed regular expression  "));
@@ -614,9 +652,14 @@
 #ifndef HAVE_X
 void unselect_cmd (void)
 {
-	unselect_cmd_panel (cpanel);
+	unselect_cmd_panel (cpanel, 0);	/* 0 - show unselect dialog - mAX */
 }
 
+void unselect_force_cmd (void)
+{
+	unselect_cmd_panel (cpanel, 1); /* 1 - don't show unselect dialog - mAX */
+}
+
 /* Check if the file exists */
 /* If not copy the default */
 static int check_for_default(char *default_file, char *file)
diff -Naur mc/src/cmd.h mc-new/src/cmd.h
--- mc/src/cmd.h	Wed Aug 23 17:42:00 2000
+++ mc-new/src/cmd.h	Mon Jul  2 15:52:20 2001
@@ -48,11 +48,15 @@
 void edit_symlink_cmd (void);
 void other_symlink_cmd (void);
 void reverse_selection_cmd_panel (WPanel *);
-void unselect_cmd_panel (WPanel *);
-void select_cmd_panel (WPanel *);
+void reverse_selection_dir_cmd_panel (WPanel *); /* added by mAX */
+void unselect_cmd_panel (WPanel *, int force);	/* changed by mAX */
+void select_cmd_panel (WPanel *, int force);	/* changed by mAX */
 void reverse_selection_cmd (void);
+void reverse_selection_dir_cmd (void);	/* added by mAX - reverse selections including directories */
 void unselect_cmd (void);
+void unselect_force_cmd (void);	/* added by mAX - don't show unselect dialog */
 void select_cmd (void);
+void select_force_cmd (void);	/* added by mAX - don't show select dialog */
 void swap_cmd (void);
 void view_other_cmd (void);
 void mkdir_panel_cmd (void);
diff -Naur mc/src/main.c mc-new/src/main.c
--- mc/src/main.c	Wed Jun 27 16:29:16 2001
+++ mc-new/src/main.c	Mon Jul  2 15:36:56 2001
@@ -2019,17 +2019,26 @@
 	    if(!only_leading_plus_minus) {
 		/* Special treatement, since the input line will eat them */
 		if (id == '+' ) {
-		    select_cmd ();
+		    if (!ctrl_pressed())	/* see below - mAX */
+			select_cmd ();
+		    else
+			select_force_cmd ();
 		    return MSG_HANDLED;
 		}
 
 		if (check_key_backslash (id) || id == '-'){
-		    unselect_cmd ();
+		    if (!ctrl_pressed())	/* see below - mAX */
+			unselect_cmd ();
+		    else
+			unselect_force_cmd ();
 		    return MSG_HANDLED;
 		}
 
 		if (id == '*') {
-		    reverse_selection_cmd ();
+		    if (!ctrl_pressed())	/* see below - mAX */
+			reverse_selection_cmd ();
+		    else
+			reverse_selection_dir_cmd ();
 		    return MSG_HANDLED;
 		}
 	    } else if (command_prompt && !strlen (input_w (cmdline)->buffer)) {
@@ -2038,17 +2047,26 @@
 		 */
 		
 		if (id == '+') {
-		    select_cmd ();
+		    if (!ctrl_pressed())	/* '+' - show select dialog - mAX */
+			select_cmd ();
+		    else
+			select_force_cmd ();	/* CTRL+'+' - don't show select dialog - mAX */
 		    return MSG_HANDLED;
 		}
 		
 		if (check_key_backslash (id) || id == '-') {
-		    unselect_cmd ();
+		    if (!ctrl_pressed())	/* '-' - show unselect dialog - mAX */
+			unselect_cmd ();
+		    else			/* CTRL+'-' - don't show unselect dialog - mAX */
+			unselect_force_cmd ();
 		    return MSG_HANDLED;
 		}
 		
 		if (id == '*') {
-		    reverse_selection_cmd ();
+		    if (!ctrl_pressed())	/* '*' - invert files only (not dirs) - mAX */
+			reverse_selection_cmd ();
+		    else			/* CTRL+'*' - invert all - mAX */
+			reverse_selection_dir_cmd ();
 		    return MSG_HANDLED;
 		}
 	    }   


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]