File Compare Functionality

For discussions about the source code and how to get involved in the development of muCommander.

File Compare Functionality

Postby Walküre » Mon Feb 09, 2009 9:59 pm

Hi,
i know that i can define a Custom Command in muCommander with special tokens:
$f for the file's full path,
$n for its name,
$p for its parent directory
$j for the JVM's startup directory.
Is there the possibility to use a token (for example $f1) for the selected file on the left side and another token (for example $f2) for the selected file on the right side of MC?. With the use of $f1 and $f2 i can start for example an external tool (opendiff, ...) to compare the two selected files $f1 and $f2.

Thank you, Ronny
Walküre
 
Posts: 16
Joined: Fri Jan 05, 2007 9:36 pm

Re: File Compare Functionality

Postby Nicolas » Thu May 28, 2009 10:01 pm

Hey Ronny,

Good idea, I'll try and implement this as soon as I can find an hour or so.
Thanks for the suggestion!

Nicolas
User avatar
Nicolas
 
Posts: 804
Joined: Mon Oct 02, 2006 10:36 pm
Location: France

Re: File Compare Functionality

Postby Walküre » Thu Sep 17, 2009 9:43 pm

Hi,
or maybe so we can solve this; but it is quick and dirty becaude "opendiff" is hardcoded :o)

in "action_keymap.xml"
<!-- Action : Compare the content of both selected files. -->
<!-- Default : control F -->
<action class="com.mucommander.ui.action.CompareFileAction" keystroke="control F"/>

in "CompareFileAction.java"
package com.mucommander.ui.action;

import com.mucommander.ui.main.MainFrame;
import com.mucommander.file.util.FileSet;
import java.util.Hashtable;

public class CompareFileAction extends MuAction {

public CompareFileAction(MainFrame mainFrame, Hashtable properties) {
super(mainFrame, properties);
}

public void performAction() {
FileSet files1 = mainFrame.getLeftPanel().getFileTable().getSelectedFiles();
FileSet files2 = mainFrame.getRightPanel().getFileTable().getSelectedFiles();

if( (files1.size() == 1) &&
(files2.size() == 1) &&
(files1.fileAt(0).isDirectory() == false) &&
(files2.fileAt(0).isDirectory() == false)) {

String[] tokens = new String[3];
tokens[0] = "opendiff";
tokens[1] = files1.fileAt(0).getAbsolutePath();
tokens[2] = files2.fileAt(0).getAbsolutePath();

try {
ProcessBuilder pb = new ProcessBuilder(tokens);
pb.redirectErrorStream(true);
pb.start();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}

Best Regards.
Ronny
Walküre
 
Posts: 16
Joined: Fri Jan 05, 2007 9:36 pm

Re: File Compare Functionality

Postby Walküre » Sun Sep 20, 2009 5:59 pm

ok, it was a very old Code Version. :cry:
Better:

package com.mucommander.ui.action.impl;

import com.mucommander.ui.action.AbstractActionDescriptor;
import com.mucommander.ui.action.ActionCategories;
import com.mucommander.ui.action.ActionCategory;
import com.mucommander.ui.action.ActionFactory;
import com.mucommander.ui.action.MuAction;
import com.mucommander.ui.main.MainFrame;
import com.mucommander.file.util.FileSet;
import java.awt.event.KeyEvent;
import java.util.Hashtable;
import javax.swing.KeyStroke;

public class CompareFileAction extends MuAction {

private static final long serialVersionUID = 1L;

public CompareFileAction(MainFrame mainFrame, Hashtable properties) {
super(mainFrame, properties);
}

public void performAction() {
FileSet files1 = mainFrame.getLeftPanel().getFileTable().getSelectedFiles();
FileSet files2 = mainFrame.getRightPanel().getFileTable().getSelectedFiles();

if( (files1.size() == 1) &&
(files2.size() == 1) &&
(files1.fileAt(0).isDirectory() == false) &&
(files2.fileAt(0).isDirectory() == false)) {

String[] tokens = new String[3];
tokens[0] = "opendiff";
tokens[1] = files1.fileAt(0).getAbsolutePath();
tokens[2] = files2.fileAt(0).getAbsolutePath();

try {
ProcessBuilder pb = new ProcessBuilder(tokens);
pb.redirectErrorStream(true);
pb.start();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

public static class Factory implements ActionFactory {
public MuAction createAction(MainFrame mainFrame, Hashtable properties) {
return new CompareFileAction(mainFrame, properties);
}
}

public static class Descriptor extends AbstractActionDescriptor {
public static final String ACTION_ID = "CompareFile";

public String getId() { return ACTION_ID; }
public ActionCategory getCategory() { return ActionCategories.VIEW; }
public KeyStroke getDefaultAltKeyStroke() { return null; }
public KeyStroke getDefaultKeyStroke() {
return KeyStroke.getKeyStroke(KeyEvent.VK_F7, KeyEvent.ALT_DOWN_MASK);
}
}
}

and in ActionManager.java add:

registerAction(new CompareFileAction.Descriptor(), new CompareFileAction.Factory());

im so sorry about my old stuff
Ronny
Walküre
 
Posts: 16
Joined: Fri Jan 05, 2007 9:36 pm

Re: File Compare Functionality

Postby Kasper » Wed Mar 10, 2010 9:51 am

This would indeed be a huge improvement on muCommander, not being able to do a quick/easy file diff is an ongoing annoyance to me and something I still miss a lot from Total Commander. I really hope someone will be able to implement this idea.

Regards, Kasper
Kasper
 
Posts: 2
Joined: Thu May 29, 2008 12:22 pm

Re: File Compare Functionality

Postby PGabor » Thu Apr 08, 2010 7:56 pm

Hi!

I've just implemented a similar funcionality in my little muCommander fork, called mugCommander (pagavcs.googlecode.com), but it's Ubuntu only, as I only made .deb package and it calls the "meld" program for comparing.

And a little more about the mugCommander:

why fork?
because it caused me problem to start the muCommander in Eclipse in debug mode, so I started to make small fixes in the source code, adding new features, rewriting code, introducing generics where not used, formatting code as I like etc...

what's the difference?
- file search: name, content, case sensitive/insensitive, inside archives, character encodings, results are shown like a contents of an archive file
- file compare (using "meld" program)
- native edit (shift+f4, invokes "gedit")
- fixes in text editor/viewer: remember size, faster scrolling with mousewheel, copy-cut-paste context menu
- make default quick keys more similar to total commander: ctrl+r=refresh; alt+f5=pack; alt+f9=unpack; f9=run; ctrl+h=show/hide hidden files
- easy to use extension support: Context menu, Drive popup menu, File emblem, Main menu bar, Service
- currently two (and half) extensions are available: PagaVCS (+OpenTerminal packaged into it currently), Bonjour
- test classes are in separate srctst directory, and not compiled into the distributed jar

Feel free to backmerge any of my changes to muCommander.

Regards, Gábor
PGabor
 
Posts: 1
Joined: Thu Apr 08, 2010 7:37 pm

Re: File Compare Functionality

Postby Nicolas » Fri Apr 09, 2010 10:52 am

Hey there,

Just a quick message to acknowledge your post.

Maxence is dealing with code submissions, patches and the like, and he's currently unavailable (on holidays, the lucky sod). I'll make sure he gives your post and your port the attention they deserve when he gets back.

Cheers,
Nicolas
User avatar
Nicolas
 
Posts: 804
Joined: Mon Oct 02, 2006 10:36 pm
Location: France

Re: File Compare Functionality

Postby Walküre » Fri May 07, 2010 8:46 am

Hi Maxence,

is there any new info about the File Compare Function or about the branch?
Walküre
 
Posts: 16
Joined: Fri Jan 05, 2007 9:36 pm

Re: File Compare Functionality

Postby mUser » Wed Aug 18, 2010 9:42 pm

Are we there yet? 8)
It would be nice to have this functionality merged in mucommander.
mUser
 
Posts: 1
Joined: Wed Aug 18, 2010 9:29 pm


Return to Developer's corner

Who is online

Users browsing this forum: No registered users and 1 guest

cron