# [ANNOUNCE] mtkdiff-20050514 (integrated w/ gitk)

2 messages from 2005-05-14 to 2005-05-14. Participants: Tejun Heo, Paul Mackerras.
Thread: https://gitlist.dev/t/610

## Tejun Heo, 2005-05-14 02:58

Subject: [ANNOUNCE] mtkdiff-20050514 (integrated w/ gitk)
Message-ID: <20050514025815.GA5845@htj.dyndns.org>
URL: https://gitlist.dev/e/20050514025815.GA5845%40htj.dyndns.org

```
 Hello, guys.

 This is mtkdiff-20050514.  I've modified gitk to invoke gitkdiff on
double click and right click.  If you double click on a commit mtkdiff
will show the commit.  If you right click on a commit while another
one is selected, mtkdiff will show the difference between the two
commits (as in bk revtool).  Also, I've modified gitk & gitkdiff to
show commit SHA1 in the info text when a commit is selected.

 The tarball can be found at

 http://home-tj.org/mtkdiff/files/mtkdiff-20050514.tar.gz

 Patch of the gitk changes follow.  (gitk-0.9 vs. the modified version)

 Thanks.

--- gitk-0.9	2005-05-14 11:57:02.000000000 +0900
+++ gitk	2005-05-14 11:57:04.000000000 +0900
@@ -175,6 +175,8 @@ proc makewindow {} {
     pack .ctop -side top -fill both -expand 1
 
     bindall <1> {selcanvline %x %y}
+    bindall <Double-1> {canvdclick %x %y}
+    bindall <3> {canvrclick %x %y}
     bindall <B1-Motion> {selcanvline %x %y}
     bindall <ButtonRelease-4> "allcanvs yview scroll -5 u"
     bindall <ButtonRelease-5> "allcanvs yview scroll 5 u"
@@ -473,7 +475,7 @@ proc drawgraph {start} {
     }
 }
 
-proc selcanvline {x y} {
+proc coordtoline {x, y} {
     global canv canvy0 ctext linespc selectedline
     global lineid linehtag linentag linedtag
     set ymax [lindex [$canv cget -scrollregion] 3]
@@ -483,8 +485,38 @@ proc selcanvline {x y} {
     if {$l < 0} {
 	set l 0
     }
-    if {[info exists selectedline] && $selectedline == $l} return
-    selectline $l
+    if {[info exists selectedline] && $selectedline == $l} {
+	return -1
+    }
+    return $l
+}
+
+proc selcanvline {x y} {
+    set l [coordtoline $x, $y]
+    if {$l >= 0} {
+	selectline $l
+    }
+}
+
+proc canvdclick {x y} {
+    global lineid selectedline
+    selcanvline $x $y
+    if {[info exists selectedline]} {
+	exec gitkdiff -r $lineid($selectedline) &
+    }
+}
+
+proc canvrclick {x y} {
+    global selectedline lineid
+
+    if {[info exists selectedline]} {
+	set l [coordtoline $x, $y]
+	if {$selectedline != $l} {
+	    exec gitkdiff -r $lineid($selectedline) -r $lineid($l) &
+	}
+    } else {
+	selcanvline $x $y
+    }
 }
 
 proc selectline {l} {
@@ -521,6 +553,7 @@ proc selectline {l} {
     $ctext conf -state normal
     $ctext delete 0.0 end
     set info $commitinfo($id)
+    $ctext insert end "Commit: $id\n"
     $ctext insert end "Author: [lindex $info 1]  [lindex $info 2]\n"
     $ctext insert end "Committer: [lindex $info 3]  [lindex $info 4]\n"
     $ctext insert end "\n"

```

## Paul Mackerras, 2005-05-14 06:50

Subject: Re: [ANNOUNCE] mtkdiff-20050514 (integrated w/ gitk)
Message-ID: <17029.40860.516486.308420@cargo.ozlabs.ibm.com>
URL: https://gitlist.dev/e/17029.40860.516486.308420%40cargo.ozlabs.ibm.com
In-Reply-To: <20050514025815.GA5845@htj.dyndns.org>

```
Tejun Heo writes:

>  This is mtkdiff-20050514.  I've modified gitk to invoke gitkdiff on
> double click and right click.  If you double click on a commit mtkdiff
> will show the commit.  If you right click on a commit while another
> one is selected, mtkdiff will show the difference between the two
> commits (as in bk revtool).  Also, I've modified gitk & gitkdiff to
> show commit SHA1 in the info text when a commit is selected.

Cute.  I was thinking along the same lines, but intending to use
dirdiff to display the differences.  I'll make the diff viewer
user-configurable, I think.  Also, I'm planning to put a bar with the
sha1 and a search facility in the next version of gitk.

Paul.

```
