@matheusbsbs / matheus-bagliano / commits / d8d2df08f6
Fork 0

gitk: Make downward-pointing arrows end in vertical line segment

It seems Tk 8.4 can't draw arrows on diagonal line segments. This adds code to the optimizer to make the last bit of a line go vertically before being terminated with an arrow pointing downwards, so that it will be drawn correctly by Tk 8.4. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Mar 18, 2006 at 20:42 UTC d8d2df08f6c5f804878bf9faf0820db87dbd68f5
1 file changed +21 -8
gitk
+21 -8
@@ -952,8 +952,9 @@ proc layoutrows {row endrow last} {
952 set offs [lreplace $offs $x $x]
953 set offs [incrange $offs $x 1]
954 set idinlist($i) 0
955 - lappend linesegends($row) $i
956 - lappend idrowranges($i) [expr {$row-1}]
955 + set rm1 [expr {$row - 1}]
956 + lappend linesegends($rm1) $i
957 + lappend idrowranges($i) $rm1
958 if {[incr nev -1] <= 0} break
959 continue
960 }
@@ -982,7 +983,6 @@ proc layoutrows {row endrow last} {
983 unset idinlist($id)
984 }
985 if {[info exists idrowranges($id)]} {
985 - lappend linesegends($row) $id
986 lappend idrowranges($id) $row
987 }
988 incr row
@@ -1038,7 +1038,7 @@ proc addextraid {id row} {
1038
1039 proc layouttail {} {
1040 global rowidlist rowoffsets idinlist commitidx
1041 - global idrowranges linesegends
1041 + global idrowranges
1042
1043 set row $commitidx
1044 set idlist [lindex $rowidlist $row]
@@ -1047,7 +1047,6 @@ proc layouttail {} {
1047 set id [lindex $idlist $col]
1048 addextraid $id $row
1049 unset idinlist($id)
1050 - lappend linesegends($row) $id
1050 lappend idrowranges($id) $row
1051 incr row
1052 set offs [ntimes $col 0]
@@ -1061,7 +1060,6 @@ proc layouttail {} {
1060 lset rowidlist $row [list $id]
1061 lset rowoffsets $row 0
1062 makeuparrow $id 0 $row 0
1064 - lappend linesegends($row) $id
1063 lappend idrowranges($id) $row
1064 incr row
1065 lappend rowidlist {}
@@ -1079,12 +1077,23 @@ proc insert_pad {row col npad} {
1077 }
1078
1079 proc optimize_rows {row col endrow} {
1082 - global rowidlist rowoffsets idrowranges
1080 + global rowidlist rowoffsets idrowranges linesegends displayorder
1081
1082 for {} {$row < $endrow} {incr row} {
1083 set idlist [lindex $rowidlist $row]
1084 set offs [lindex $rowoffsets $row]
1085 set haspad 0
1086 + set downarrowcols {}
1087 + if {[info exists linesegends($row)]} {
1088 + set downarrowcols $linesegends($row)
1089 + if {$col > 0} {
1090 + while {$downarrowcols ne {}} {
1091 + set i [lsearch -exact $idlist [lindex $downarrowcols 0]]
1092 + if {$i < 0 || $i >= $col} break
1093 + set downarrowcols [lrange $downarrowcols 1 end]
1094 + }
1095 + }
1096 + }
1097 for {} {$col < [llength $offs]} {incr col} {
1098 if {[lindex $idlist $col] eq {}} {
1099 set haspad 1
@@ -1102,6 +1111,10 @@ proc optimize_rows {row col endrow} {
1111 $y0 > [lindex $idrowranges($id) 0]} {
1112 set isarrow 1
1113 }
1114 + } elseif {$downarrowcols ne {} &&
1115 + [lindex $idlist $col] eq [lindex $downarrowcols 0]} {
1116 + set downarrowcols [lrange $downarrowcols 1 end]
1117 + set isarrow 1
1118 }
1119 if {$z < -1 || ($z < 0 && $isarrow)} {
1120 set npad [expr {-1 - $z + $isarrow}]
@@ -1660,7 +1673,7 @@ proc drawrest {} {
1673 showstuff $commitidx
1674
1675 set drawmsecs [expr {[clock clicks -milliseconds] - $startmsecs}]
1663 - puts "overall $drawmsecs ms for $numcommits commits"
1676 + #puts "overall $drawmsecs ms for $numcommits commits"
1677 }
1678
1679 proc findmatches {f} {