Re: gitk hyperlinks (was Re: Display of merges in gitk)

2005-08-06 Thread Linus Torvalds


On Sat, 6 Aug 2005, Paul Mackerras wrote:
 Linus Torvalds writes:
  
   - clickable SHA1's in commit messages would be really really cool if 
 something like that is even possible with tcl/tk.
 
 Done, and it was even pretty easy.  It took only about a dozen lines.

Looks good also. I assume the mouse can't change when it hovers? 

 Good idea.  Also done. :)  It's on master.kernel.org now in my gitk.git
 directory.  Hopefully Junio will pull it into git soon.  The current
 version also squishes the graph horizontally if it gets too wide
 (i.e. more than half the width of the top-left pane).

Yeah, that looks weird when the lines start turning soft ans squiggly.

Linus
-
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: gitk hyperlinks (was Re: Display of merges in gitk)

2005-08-06 Thread jepler
On Sat, Aug 06, 2005 at 09:20:16AM -0700, Linus Torvalds wrote:
 Looks good also. I assume the mouse can't change when it hovers? 

In gitk?  This is be possible.  My patch[1] does it.  The way it's done stinks a
little bit, though.  Enter and Leave are bound on a tag common to all the
hyperlinks, and change the -cursor of the whole widget---either to hand2 or
the empty string.

+$ctext tag bind Commit Enter { %W configure -cursor hand2 }
+$ctext tag bind Commit Leave { %W configure -cursor {} }

My patch also underlines links, as requested in a different message in this 
thread.

+$ctext tag configure Commit -underline yes -foreground blue

Jeff
[1] http://www.gelato.unsw.edu.au/archives/git/0508/7253.html


pgpTyavkb8S8o.pgp
Description: PGP signature


Re: gitk hyperlinks (was Re: Display of merges in gitk)

2005-08-06 Thread Kay Sievers
On Sat, Aug 06, 2005 at 08:44:10AM -0700, Linus Torvalds wrote:
 
 
 On Sat, 6 Aug 2005, Kay Sievers wrote:
  
  Damn cool? No problem. :)

  http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=403fe5ae57c831968c3dbbaba291ae825a1c5aaa
 
 Goodie. Although when I looked at it first, it wasn't obvious - the link
 is same font, same color as the rest. Maybe make them stand out a _bit_
 more?

It's blue now, to invite you to click on it. :)

Kay
-
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: gitk hyperlinks (was Re: Display of merges in gitk)

2005-08-05 Thread jepler
On Fri, Aug 05, 2005 at 07:37:41AM -0700, Linus Torvalds wrote:
 For 2.6.13 we've been reverting some stuff lately, to make sure we get a 
 stable release. That's fine, and when I revert something I try to mention 
 the commit ID of the thing I revert in the message. Apparently others do 
 too, as indicated by a patch I just got from Petr Vandovec. So we've got 
 for example:
[snipped]

The following code worked for me on a toy commit.  I'm not sure the regular
expression in linkcommits is right if the SHA1 is followed by a colon or a 
comma,
as I noticed it was in your examples.  If it doesn, then removing the [[::]]
and [[::]] will probably fix it.

Things that look like SHA1s are highlighted even if they don't actually exist.

There is probably a more right place to do the '$ctext tag bind Commit' 
commands
but I didn't find it right away.

diff --git a/gitk b/gitk
--- a/gitk
+++ b/gitk
@@ -1753,6 +1753,11 @@ proc selectline {l} {
 $ctext conf -state disabled
 set commentend [$ctext index end - 1c]
 
+linkcommits $ctext 0.0 $commentend
+$ctext tag configure Commit -underline yes -foreground blue
+$ctext tag bind Commit Enter { %W configure -cursor hand2 }
+$ctext tag bind Commit Leave { %W configure -cursor {} }
+$ctext tag bind Commit Button-1ButtonRelease-1 { linkclick %W %x %y }
 $cflist delete 0 end
 $cflist insert end Comments
 if {$nparents($id) == 1} {
@@ -1762,6 +1767,30 @@ proc selectline {l} {
 }
 }
 
+proc linkclick {w x y} {
+set index [$w index @$x,$y]
+set tags [$w tag names $index]
+foreach c $tags {
+if {![string match {C_*} $c]} { continue; }
+global sha1string
+set sha1string [string range $c 2 end]
+gotocommit
+}
+}
+
+proc linkcommits {w start end} {
+while {1} {
+set pos [$w search -regexp {[[::]][0-9a-fA-F]{40}[[::]]} $start $end]
+if {$pos == {}} {break}
+
+set commit [$w get $pos $pos+40c]
+
+$w tag add Commit $pos $pos+40c
+$w tag add C_$commit $pos $pos+40c
+set start [$w index $pos+40c]
+}
+}
+
 proc selnextline {dir} {
 global selectedline
 if {![info exists selectedline]} return



pgppDwXRz0T1l.pgp
Description: PGP signature