Page 1 of 2

XY + WinMerge

Posted: 07 May 2008 13:52
by Walrez
Not very elegant, but.... this one lets you select two of your open tabs, and opens WinMerge (a file synchronization program) with both directories loaded for comparison:
You need to adapt the location of WinMerge in your system.

"WinMerge:WinMerge"
#343;
set $first, <curpath>;
#343;
set $second, <curpath>;
set $cmd, """D:\Software\WinMergePortable\WinMergePortable.exe"" /e /r /f ""*.frm *.cls"" """;
addstr $cmd, $first, """ """, $second , """";
open $cmd;

Posted: 07 May 2008 14:01
by jacky
Well, I don't use WinMerge, but I actually like the idea of using the Tab list that way, that's a nice idea :)

Posted: 07 May 2008 14:19
by graham
I don't have winmerge but the approach is what I think could offer a sensible and elegant solution to the DP user need for file comparisons.

Taking this concept further ...

Rather than a complete integration of DP within existing code of XY this approach offers many possibilities for external programs to solve a special DP need. This is why I once remarked that for those wanting DP all that was required was a definition of the 'user needs'. It could be that these needs can be solved by calling (script?) an external written program or module to satisfy a particular need. It will not satisfy the die hard DP user who wants it all but there are DP programs out there that do this so why complicate XY tab principles for a few special needs. I urge Don to explore this approach as a very feasible solution to satisfy most DP wishes (90%) and the remaining 10% will have to revert to a DP only program.

Posted: 07 May 2008 16:51
by Walrez
jacky wrote:Well, I don't use WinMerge, but I actually like the idea of using the Tab list that way, that's a nice idea :)
Here's a variation: This one sends the current tab and the next one. Of course, these scripts are useful for whatever external programs that can accept more than one file/path for whatever reason.

"WinMerge2:WinMerge2"
set $first, <curpath>;
seltab +;
set $second, <curpath>;
seltab -;
set $cmd, """D:\Software\WinMerge\WinMerge.exe"" /e /r /f ""*.*"" """;
addstr $cmd, $first, """ """, $second , """";
open $cmd;

Posted: 07 May 2008 19:00
by eurytos
here is my 'open with' UDC that I have setup using winmerge.

"C:\Program Files\WinMerge\WinMergeU.exe" "<items>" "<clipboard>"


It will work comparing files or folders. I used the clipboard so I would not be required to be in the same tab to do comparisons but that causes an issue if comparing large directories. Overall it works well for me though.


I should probably improve it by using some scripting. maybe I will do that now.

Posted: 07 May 2008 19:30
by admin
eurytos wrote:here is my 'open with' UDC that I have setup using winmerge.

"C:\Program Files\WinMerge\WinMergeU.exe" "<items>" "<clipboard>"


It will work comparing files or folders. I used the clipboard so I would not be required to be in the same tab to do comparisons but that causes an issue if comparing large directories. Overall it works well for me though.


I should probably improve it by using some scripting. maybe I will do that now.
Why "<items>"? (= all selected items) More suitable would be <curitem> (= the one selected and focused item).

Posted: 07 May 2008 21:30
by eurytos
admin wrote:
eurytos wrote:here is my 'open with' UDC that I have setup using winmerge.

"C:\Program Files\WinMerge\WinMergeU.exe" "<items>" "<clipboard>"


It will work comparing files or folders. I used the clipboard so I would not be required to be in the same tab to do comparisons but that causes an issue if comparing large directories. Overall it works well for me though.


I should probably improve it by using some scripting. maybe I will do that now.
Why "<items>"? (= all selected items) More suitable would be <curitem> (= the one selected and focused item).
Using "<items>" gives me the ability to also select two items/folders in the same tab without needing to copy one to the clipboard. I don't think that would work if I used <curitem>

Posted: 07 May 2008 21:33
by admin
eurytos wrote:
admin wrote:
eurytos wrote:here is my 'open with' UDC that I have setup using winmerge.

"C:\Program Files\WinMerge\WinMergeU.exe" "<items>" "<clipboard>"


It will work comparing files or folders. I used the clipboard so I would not be required to be in the same tab to do comparisons but that causes an issue if comparing large directories. Overall it works well for me though.


I should probably improve it by using some scripting. maybe I will do that now.
Why "<items>"? (= all selected items) More suitable would be <curitem> (= the one selected and focused item).
Using "<items>" gives me the ability to also select two items/folders in the same tab without needing to copy one to the clipboard. I don't think that would work if I used <curitem>
Ah, I see! And what if you select two items and there's something on the clipboard? How does winmerge handle this?

Posted: 07 May 2008 21:39
by eurytos
admin wrote:
eurytos wrote:
admin wrote:
eurytos wrote:here is my 'open with' UDC that I have setup using winmerge.

"C:\Program Files\WinMerge\WinMergeU.exe" "<items>" "<clipboard>"


It will work comparing files or folders. I used the clipboard so I would not be required to be in the same tab to do comparisons but that causes an issue if comparing large directories. Overall it works well for me though.


I should probably improve it by using some scripting. maybe I will do that now.
Why "<items>"? (= all selected items) More suitable would be <curitem> (= the one selected and focused item).
Using "<items>" gives me the ability to also select two items/folders in the same tab without needing to copy one to the clipboard. I don't think that would work if I used <curitem>
Ah, I see! And what if you select two items and there's something on the clipboard? How does winmerge handle this?
It takes the first two items and then ignores the clipboard (or at least don't give me a visible error). The functionality wouldn't work the same if I swapped <clipboard> and <items>, then it would take the clipboard and 1 item.

Re: XY + WinMerge

Posted: 05 Apr 2012 12:13
by leinad
Just for the record, to compare two selected files in the active pane, here is a one-liner:

Code: Select all

::run """C:\Programme\WinMerge\WinMergeU.exe"" /e /r ""<get SelectedItemsPathNames """""" """""">""";
and to compare two files which are in a different pane

Code: Select all

::run """C:\Programme\WinMerge\WinMergeU.exe"" /e /r ""<get item 1>"" ""<get item 2>""";

Re: XY + WinMerge

Posted: 11 Apr 2012 17:14
by admin
leinad wrote:Just for the record, to compare two selected files in the active pane, here is a one-liner:

Code: Select all

::run """C:\Programme\WinMerge\WinMergeU.exe"" /e /r ""<get SelectedItemsPathNames """""" """""">""";
This looks so frightening that I think about adding something like SelectedItemsPathNamesAsQuotedItemsList... :)

Re: XY + WinMerge

Posted: 11 Apr 2012 17:18
by highend
SelectedItemsPathNamesAsQuotedItemsList...
Don't steal me my usual
formatlist()

^^

Re: XY + WinMerge

Posted: 18 Jan 2015 10:32
by Enternal
Just an "update" to the code here. Well too bad it's not a one-liner but at least you can now select either files from the same pane or a single file from each pane to compare. And it does it smartly too so if you selected 2 files in the current pane, it will compare those. If you select only 1 file, it will look for another selected item in the other pane and compare the 2. If you selected more than 2 files on the same pane, it will throw you an error. If you selected 1 but more than 1 file on the other pane (total more than 2), it will also throw an error.

Code: Select all

"WinMerge"
  $Executable = "C:\Users\Owner\Programs\Other\WinMerge\WinMergePortable.exe";
  End ("<selitems>"==""),"Nothing Is Selected!";
  If Get("CountSelected") == 1 {
      $Count1 = Get("CountSelected", "1"); $Count2 = Get("CountSelected", "2");
      If ($Count1 > 1 || $Count2 > 1) {Msg "No More Than 2 Items can Be Selected!"; End(1);}
      Else {$SelectedItems = "<get item 1>|<get item 2>";} }
  ElseIf Get("CountSelected") > 2 {Msg "No More Than 2 Items can Be Selected!"; End(1);}
  Else {$SelectedItems = Get("SelectedItemsPathNames","|");}
  $File1 = GetToken("$SelectedItems",1,"|"); $File2 = GetToken("$SelectedItems",2,"|");
  Run """$Executable"" /e /r ""$File1"" ""$File2"""; }

"BeyondCompare"
  $Executable = "C:\Users\Owner\Programs\Other\Beyond Compare\BCompare.exe";
  End ("<selitems>"==""),"Nothing Is Selected!";
  If Get("CountSelected") == 1 {
      $Count1 = Get("CountSelected", "1"); $Count2 = Get("CountSelected", "2");
      If ($Count1 > 1 || $Count2 > 1) {Msg "No More Than 2 Items can Be Selected!"; End(1);}
      Else {$SelectedItems = "<get item 1>|<get item 2>";} }
  ElseIf Get("CountSelected") > 2 {Msg "No More Than 2 Items can Be Selected!"; End(1);}
  Else {$SelectedItems = Get("SelectedItemsPathNames","|");}
  $File1 = GetToken("$SelectedItems",1,"|"); $File2 = GetToken("$SelectedItems",2,"|");
  Run """$Executable"" /e /r ""$File1"" ""$File2"""; }

Re: XY + WinMerge

Posted: 18 Jan 2015 14:03
by Stef123
Whoa, thanks a lot. :tup:
This is much more versatile than my own clunky solution. And I learned some valuable scripting stuff as well. This deserves a permanent place in the scripts overview, imo. :beer:

Re: XY + WinMerge

Posted: 18 Jan 2015 17:02
by klownboy
Thanks Enternal, I just DL'ed WinMerge to give this a try.