Local copy/rename



4) this is simple patch to allow copy/rename files in current directory with 
F15/F16 keys.
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
@@ -361,6 +361,16 @@
     }
 }
 
+/* local copy file (don't include path to filename) - mAX */
+void local_copy_cmd (void)
+{
+    save_cwds_stat ();
+    if (panel_operate (cpanel, OP_LCOPY, NULL, TRUE)){
+	update_panels (UP_OPTIMIZE, UP_KEEPSEL);
+	repaint_screen ();
+    }
+}
+
 void ren_cmd (void)
 {
     save_cwds_stat ();
@@ -370,6 +380,16 @@
     }
 }
 
+/* rename file (don't include path to filename) - mAX */
+void local_ren_cmd (void)
+{
+    save_cwds_stat ();
+    if (panel_operate (cpanel, OP_RENAME, NULL, TRUE)){
+	update_panels (UP_OPTIMIZE, UP_KEEPSEL);
+	repaint_screen ();
+    }
+}
+
 void copymove_cmd_with_default (int copy, char *thedefault)
 {
     save_cwds_stat ();
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
@@ -22,7 +22,9 @@
 void edit_cmd (WPanel *panel);
 void edit_cmd_new (WPanel *panel);
 void copy_cmd (void);
+void local_copy_cmd (void);	/* copy file to local dir */
 void ren_cmd (void);
+void local_ren_cmd (void);	/* rename file - mAX */
 void free_vfs_now (void);
 void reselect_vfs (void);
 void copymove_cmd_with_default (int copy, char *thedefault);
diff -Naur mc/src/file.c mc-new/src/file.c
--- mc/src/file.c	Wed Jun  6 19:32:31 2001
+++ mc-new/src/file.c	Mon Jul  2 15:47:53 2001
@@ -150,9 +150,12 @@
  */
 struct link *dest_dirs = 0;
 
-char *op_names [3] = {
+/* changed by mAX (LocalCopy and Rename added) */
+char *op_names [5] = {
 	N_(" Copy "),
+	N_(" LocalCopy "),
 	N_(" Move "),
+	N_(" Rename "),
 	N_(" Delete ")
 };
 
@@ -1677,7 +1680,13 @@
  * (I don't use spaces around the words, because someday they could be
  * dropped, when widgets get smarter)
  */
-static char *op_names1 [] = { N_("1Copy"), N_("1Move"), N_("1Delete") };
+ 
+/*
+    changed by mAX 
+    added operations - local copy and rename (F15 and F16 keys)
+*/
+static char *op_names1 [] = { N_("1Copy"), N_("1LCopy"), N_("1Move"),
+			      N_("1Rename"), N_("1Delete") };
 #define	FMD_XLEN 64
 
 int fmd_xlen = FMD_XLEN;
@@ -1900,7 +1909,13 @@
 	    else
 		dest_dir = panel->cwd;
 
-	    dest = file_mask_dialog (ctx, operation, cmd_buf, dest_dir, only_one, &do_bg);
+	    if(operation==OP_LCOPY || operation==OP_RENAME){	/* changed by mAX */
+		dest = file_mask_dialog (ctx, operation, cmd_buf, source, only_one, &do_bg);
+	    } else {
+		char* dest_full = concat_dir_and_file (dest_dir, source);
+		dest = file_mask_dialog (ctx, operation, cmd_buf, dest_full, only_one, &do_bg);
+		g_free(dest_full);
+	    }
 	    if (!dest){
 		g_free (ctx->rx.buffer);
 		file_op_context_destroy (ctx);
@@ -1968,7 +1983,8 @@
 	/* We now have ETA in all cases */
 
 	/* One file: FIXME mc_chdir will take user out of any vfs */
-	if (operation != OP_COPY && get_current_type () == view_tree)
+	/* changed by mAX */
+	if (operation != OP_COPY && operation != OP_LCOPY && get_current_type () == view_tree)
 	    mc_chdir (PATH_SEP_STR);
 
 	/* The source and src_stat variables have been initialized before */
@@ -1994,6 +2010,7 @@
 
 	        switch (operation) {
 	        case OP_COPY:
+	        case OP_LCOPY:	/* added by mAX */
 		    /*
 		     * we use file_mask_op_follow_links only with OP_COPY,
 		     */
@@ -2007,6 +2024,7 @@
 		    break;
 
 	        case OP_MOVE:
+	        case OP_RENAME:	/* added by mAX */
 		    if (S_ISDIR (src_stat.st_mode))
 		        value = move_dir_dir (ctx, source_with_path, dest, &count, &bytes);
 		    else
@@ -2038,7 +2056,8 @@
 	}
 
 	/* Initialize variables for progress bars */
-	if (operation != OP_MOVE && verbose && file_op_compute_totals) {
+	/* changed by mAX */
+	if (operation != OP_MOVE && operation != OP_RENAME && verbose && file_op_compute_totals) {
 	    panel_compute_totals (panel, &ctx->progress_count, &ctx->progress_bytes);
 	    ctx->progress_totals_computed = 1;
 	} else {
@@ -2078,6 +2097,7 @@
 
 		    switch (operation){
 		    case OP_COPY:
+		    case OP_LCOPY:	/* added by mAX */
 		       /*
 			* we use file_mask_op_follow_links only with OP_COPY,
 		        */
@@ -2092,6 +2112,7 @@
 		    	break;
 
 		    case OP_MOVE:
+		    case OP_RENAME:	/* added by mAX */
 		    	if (S_ISDIR (src_stat.st_mode))
 			    value = move_dir_dir (ctx, source_with_path, temp, &count, &bytes);
 		    	else
diff -Naur mc/src/filegui.c mc-new/src/filegui.c
--- mc/src/filegui.c	Tue Jun  5 19:41:44 2001
+++ mc-new/src/filegui.c	Mon Jul  2 15:45:19 2001
@@ -912,7 +912,7 @@
     Quick_input.ylen  = FMDY;
     Quick_input.i18n  = 1;
 
-    if (operation == OP_COPY) {
+    if (operation == OP_COPY || operation == OP_LCOPY) {	/* changed by mAX */
 	Quick_input.class = "quick_file_mask_copy";
 	Quick_input.widgets = fmd_widgets;
     } else { /* operation == OP_MOVE */
@@ -930,12 +930,12 @@
     if ((val = quick_dialog_skip (&Quick_input, SKIP)) == B_CANCEL)
 	return 0;
 
-    if (ctx->follow_links && operation != OP_MOVE)
+    if (ctx->follow_links && operation != OP_MOVE && operation != OP_RENAME)	/* changed by mAX */
 	ctx->stat_func = mc_stat;
     else
 	ctx->stat_func = mc_lstat;
 
-    if (ctx->op_preserve || operation == OP_MOVE) {
+    if (ctx->op_preserve || operation == OP_MOVE || operation == OP_RENAME) {	/* changed by mAX */
 	ctx->preserve = 1;
 	ctx->umask_kill = 0777777;
 	ctx->preserve_uidgid = (geteuid () == 0) ? 1 : 0;
diff -Naur mc/src/fileopctx.h mc-new/src/fileopctx.h
--- mc/src/fileopctx.h	Fri Feb 26 02:27:29 1999
+++ mc-new/src/fileopctx.h	Mon Jul  2 15:44:45 2001
@@ -107,11 +107,13 @@
 
 typedef enum {
 	OP_COPY,
+	OP_LCOPY,	/* local copy - mAX */
 	OP_MOVE,
+	OP_RENAME,	/* rename - mAX */
 	OP_DELETE
 } FileOperation;
 
-extern char *op_names [3];
+extern char *op_names [5];
 
 typedef enum {
 	FILE_CONT,
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
@@ -1778,6 +1778,8 @@
 }
 
 static const key_map default_map [] = {
+    { KEY_F(15),  local_copy_cmd },	/* F15 - copy file to local dir - mAX */
+    { KEY_F(16),  local_ren_cmd },	/* F16 - rename file - mAX */
 #ifndef HAVE_GNOME
     { KEY_F(19),  menu_last_selected_cmd },
     { KEY_F(20),  (key_callback) quiet_quit_cmd },


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