@@ -339,6 +339,30 @@ proc makewindow {} {
339
339
entry $sha1entry -width 40 -font $textfont -textvariable sha1string
340
340
trace add variable sha1string write sha1change
341
341
pack $sha1entry -side left -pady 2
342
+
343
+ image create bitmap bm-left -data {
344
+ # define left_width 16
345
+ # define left_height 16
346
+ static unsigned char left_bits[] = {
347
+ 0x00, 0x00, 0xc0, 0x01, 0xe0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1c, 0x00,
348
+ 0x0e, 0x00, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x0e, 0x00, 0x1c, 0x00,
349
+ 0x38, 0x00, 0x70, 0x00, 0xe0, 0x00, 0xc0, 0x01};
350
+ }
351
+ image create bitmap bm-right -data {
352
+ # define right_width 16
353
+ # define right_height 16
354
+ static unsigned char right_bits[] = {
355
+ 0x00, 0x00, 0xc0, 0x01, 0x80, 0x03, 0x00, 0x07, 0x00, 0x0e, 0x00, 0x1c,
356
+ 0x00, 0x38, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x00, 0x38, 0x00, 0x1c,
357
+ 0x00, 0x0e, 0x00, 0x07, 0x80, 0x03, 0xc0, 0x01};
358
+ }
359
+ button .ctop.top.bar.leftbut -image bm-left -command goback \
360
+ -state disabled -width 26
361
+ pack .ctop.top.bar.leftbut -side left -fill y
362
+ button .ctop.top.bar.rightbut -image bm-right -command goforw \
363
+ -state disabled -width 26
364
+ pack .ctop.top.bar.rightbut -side left -fill y
365
+
342
366
button .ctop.top.bar.findbut -text " Find" -command dofind
343
367
pack .ctop.top.bar.findbut -side left
344
368
set findstring {}
@@ -1175,7 +1199,7 @@ proc drawrest {level startix} {
1175
1199
# puts "overall $drawmsecs ms for $numcommits commits"
1176
1200
if {$redisplaying } {
1177
1201
if {$stopped == 0 && [info exists selectedline]} {
1178
- selectline $selectedline
1202
+ selectline $selectedline 0
1179
1203
}
1180
1204
if {$stopped == 1} {
1181
1205
set stopped 0
@@ -1274,7 +1298,7 @@ proc dofind {} {
1274
1298
1275
1299
proc findselectline {l} {
1276
1300
global findloc commentend ctext
1277
- selectline $l
1301
+ selectline $l 1
1278
1302
if {$findloc == " All fields" || $findloc == " Comments" } {
1279
1303
# highlight the matches in the comments
1280
1304
set f [$ctext get 1.0 $commentend ]
@@ -1665,15 +1689,17 @@ proc selcanvline {w x y} {
1665
1689
if {![info exists rowtextx($l )] || $x < $rowtextx($l) } return
1666
1690
}
1667
1691
unmarkmatches
1668
- selectline $l
1692
+ selectline $l 1
1669
1693
}
1670
1694
1671
- proc selectline {l} {
1695
+ proc selectline {l isnew } {
1672
1696
global canv canv2 canv3 ctext commitinfo selectedline
1673
1697
global lineid linehtag linentag linedtag
1674
1698
global canvy0 linespc parents nparents
1675
1699
global cflist currentid sha1entry
1676
- global commentend idtags
1700
+ global commentend idtags idline
1701
+ global history historyindex
1702
+
1677
1703
$canv delete hover
1678
1704
if {![info exists lineid($l )] || ![info exists linehtag($l )]} return
1679
1705
$canv delete secsel
@@ -1722,6 +1748,22 @@ proc selectline {l} {
1722
1748
}
1723
1749
allcanvs yview moveto [expr $newtop * 1.0 / $ymax ]
1724
1750
}
1751
+
1752
+ if {$isnew && (![info exists selectedline] || $selectedline != $l )} {
1753
+ if {$historyindex < [llength $history ]} {
1754
+ set history [lreplace $history $historyindex end $l ]
1755
+ } else {
1756
+ lappend history $l
1757
+ }
1758
+ incr historyindex
1759
+ if {$historyindex > 1} {
1760
+ .ctop.top.bar.leftbut conf -state normal
1761
+ } else {
1762
+ .ctop.top.bar.leftbut conf -state disabled
1763
+ }
1764
+ .ctop.top.bar.rightbut conf -state disabled
1765
+ }
1766
+
1725
1767
set selectedline $l
1726
1768
1727
1769
set id $lineid($l)
@@ -1746,8 +1788,25 @@ proc selectline {l} {
1746
1788
$ctext insert end " \n "
1747
1789
}
1748
1790
$ctext insert end " \n "
1749
- $ctext insert end [lindex $info 5]
1791
+ set commentstart [$ctext index " end - 1c" ]
1792
+ set comment [lindex $info 5]
1793
+ $ctext insert end $comment
1750
1794
$ctext insert end " \n "
1795
+
1796
+ # make anything that looks like a SHA1 ID be a clickable link
1797
+ set links [regexp -indices -all -inline {[0-9a-f]{40}} $comment ]
1798
+ set i 0
1799
+ foreach l $links {
1800
+ set s [lindex $l 0]
1801
+ set e [lindex $l 1]
1802
+ set linkid [string range $comment $s $e ]
1803
+ if {![info exists idline($linkid )]} continue
1804
+ incr e
1805
+ $ctext tag conf link$i -foreground blue -underline 1
1806
+ $ctext tag add link$i " $commentstart + $s c" " $commentstart + $e c"
1807
+ $ctext tag bind link$i <1> [list selectline $idline($linkid) 1]
1808
+ }
1809
+
1751
1810
$ctext tag delete Comments
1752
1811
$ctext tag remove found 1.0 end
1753
1812
$ctext conf -state disabled
@@ -1767,7 +1826,34 @@ proc selnextline {dir} {
1767
1826
if {![info exists selectedline]} return
1768
1827
set l [expr $selectedline + $dir ]
1769
1828
unmarkmatches
1770
- selectline $l
1829
+ selectline $l 1
1830
+ }
1831
+
1832
+ proc goback {} {
1833
+ global history historyindex
1834
+
1835
+ if {$historyindex > 1} {
1836
+ incr historyindex -1
1837
+ selectline [lindex $history [expr {$historyindex - 1}]] 0
1838
+ .ctop.top.bar.rightbut conf -state normal
1839
+ }
1840
+ if {$historyindex <= 1} {
1841
+ .ctop.top.bar.leftbut conf -state disabled
1842
+ }
1843
+ }
1844
+
1845
+ proc goforw {} {
1846
+ global history historyindex
1847
+
1848
+ if {$historyindex < [llength $history ]} {
1849
+ set l [lindex $history $historyindex ]
1850
+ incr historyindex
1851
+ selectline $l 0
1852
+ .ctop.top.bar.leftbut conf -state normal
1853
+ }
1854
+ if {$historyindex >= [llength $history ]} {
1855
+ .ctop.top.bar.rightbut conf -state disabled
1856
+ }
1771
1857
}
1772
1858
1773
1859
proc mergediff {id} {
@@ -2590,7 +2676,7 @@ proc gotocommit {} {
2590
2676
}
2591
2677
}
2592
2678
if {[info exists idline($id )]} {
2593
- selectline $idline($id)
2679
+ selectline $idline($id) 1
2594
2680
return
2595
2681
}
2596
2682
if {[regexp {^[0-9a-fA-F]{4,}$} $sha1string ]} {
@@ -2702,7 +2788,7 @@ proc lineclick {x y id} {
2702
2788
proc selbyid {id} {
2703
2789
global idline
2704
2790
if {[info exists idline($id )]} {
2705
- selectline $idline($id)
2791
+ selectline $idline($id) 1
2706
2792
}
2707
2793
}
2708
2794
@@ -2906,7 +2992,7 @@ proc domktag {} {
2906
2992
set xt [eval drawtags $id $idpos($id) ]
2907
2993
$canv coords $linehtag($idline($id) ) $xt [lindex $idpos($id) 2]
2908
2994
if {[info exists selectedline] && $selectedline == $idline($id) } {
2909
- selectline $selectedline
2995
+ selectline $selectedline 0
2910
2996
}
2911
2997
}
2912
2998
@@ -3016,6 +3102,9 @@ foreach arg $argv {
3016
3102
}
3017
3103
}
3018
3104
3105
+ set history {}
3106
+ set historyindex 0
3107
+
3019
3108
set stopped 0
3020
3109
set redisplaying 0
3021
3110
set stuffsaved 0
0 commit comments