Skip to content

Commit 94a2eed

Browse files
committed
Change cursor to a hand cursor when over a SHA1 ID link.
This is based on suggestions by Jeff Epler and Linus Torvalds, but extended so that we do the switching between the watch cursor and the normal cursor correctly as well. Also fixed a bug pointed out by Junio Hamano - I wasn't incrementing the link number (duh!).
1 parent d698206 commit 94a2eed

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

gitk

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ proc getcommits {rargs} {
5454
$canv create text 3 3 -anchor nw -text "Reading commits..." \
5555
-font $mainfont -tags textitems
5656
. config -cursor watch
57-
$ctext config -cursor watch
57+
settextcursor watch
5858
}
5959

6060
proc getcommitlines {commfd} {
@@ -277,7 +277,7 @@ proc makewindow {} {
277277
global canv canv2 canv3 linespc charspc ctext cflist textfont
278278
global findtype findtypemenu findloc findstring fstring geometry
279279
global entries sha1entry sha1string sha1but
280-
global maincursor textcursor
280+
global maincursor textcursor curtextcursor
281281
global rowctxmenu gaudydiff mergemax
282282

283283
menu .bar
@@ -465,6 +465,7 @@ proc makewindow {} {
465465

466466
set maincursor [. cget -cursor]
467467
set textcursor [$ctext cget -cursor]
468+
set curtextcursor $textcursor
468469

469470
set rowctxmenu .rowctxmenu
470471
menu $rowctxmenu -tearoff 0
@@ -1142,7 +1143,18 @@ proc finishcommits {} {
11421143
drawrest $level [llength $startcommits]
11431144
}
11441145
. config -cursor $maincursor
1145-
$ctext config -cursor $textcursor
1146+
settextcursor $textcursor
1147+
}
1148+
1149+
# Don't change the text pane cursor if it is currently the hand cursor,
1150+
# showing that we are over a sha1 ID link.
1151+
proc settextcursor {c} {
1152+
global ctext curtextcursor
1153+
1154+
if {[$ctext cget -cursor] == $curtextcursor} {
1155+
$ctext config -cursor $c
1156+
}
1157+
set curtextcursor $c
11461158
}
11471159

11481160
proc drawgraph {} {
@@ -1377,7 +1389,7 @@ proc stopfindproc {{done 0}} {
13771389
unset findinprogress
13781390
if {$phase != "incrdraw"} {
13791391
. config -cursor $maincursor
1380-
$ctext config -cursor $textcursor
1392+
settextcursor $textcursor
13811393
}
13821394
}
13831395
}
@@ -1420,7 +1432,7 @@ proc findpatches {} {
14201432
fileevent $f readable readfindproc
14211433
set finddidsel 0
14221434
. config -cursor watch
1423-
$ctext config -cursor watch
1435+
settextcursor watch
14241436
set findinprogress 1
14251437
}
14261438

@@ -1525,7 +1537,7 @@ proc findfiles {} {
15251537
set id $lineid($l)
15261538
set p [lindex $parents($id) 0]
15271539
. config -cursor watch
1528-
$ctext config -cursor watch
1540+
settextcursor watch
15291541
set findinprogress 1
15301542
findcont [list $id $p]
15311543
update
@@ -1802,10 +1814,14 @@ proc selectline {l isnew} {
18021814
set linkid [string range $comment $s $e]
18031815
if {![info exists idline($linkid)]} continue
18041816
incr e
1805-
$ctext tag conf link$i -foreground blue -underline 1
1817+
$ctext tag add link "$commentstart + $s c" "$commentstart + $e c"
18061818
$ctext tag add link$i "$commentstart + $s c" "$commentstart + $e c"
18071819
$ctext tag bind link$i <1> [list selectline $idline($linkid) 1]
1820+
incr i
18081821
}
1822+
$ctext tag conf link -foreground blue -underline 1
1823+
$ctext tag bind link <Enter> { %W configure -cursor hand2 }
1824+
$ctext tag bind link <Leave> { %W configure -cursor $curtextcursor }
18091825

18101826
$ctext tag delete Comments
18111827
$ctext tag remove found 1.0 end

0 commit comments

Comments
 (0)