@@ -480,7 +480,7 @@ proc click {w} {
480
480
481
481
proc savestuff {w} {
482
482
global canv canv2 canv3 ctext cflist mainfont textfont
483
- global stuffsaved findmergefiles gaudydiff
483
+ global stuffsaved findmergefiles gaudydiff maxgraphpct
484
484
485
485
if {$stuffsaved } return
486
486
if {![winfo viewable .]} return
@@ -490,6 +490,7 @@ proc savestuff {w} {
490
490
puts $f [list set textfont $textfont ]
491
491
puts $f [list set findmergefiles $findmergefiles ]
492
492
puts $f [list set gaudydiff $gaudydiff ]
493
+ puts $f [list set maxgraphpct $maxgraphpct ]
493
494
puts $f " set geometry(width) [ winfo width .ctop] "
494
495
puts $f " set geometry(height) [ winfo height .ctop] "
495
496
puts $f " set geometry(canv1) [ expr [winfo width $canv ] -2]"
@@ -694,7 +695,7 @@ proc bindline {t id} {
694
695
695
696
proc drawcommitline {level} {
696
697
global parents children nparents nchildren todo
697
- global canv canv2 canv3 mainfont namefont canvx0 canvy linespc
698
+ global canv canv2 canv3 mainfont namefont canvy linespc
698
699
global lineid linehtag linentag linedtag commitinfo
699
700
global colormap numcommits currentparents dupparents
700
701
global oldlevel oldnlines oldtodo
@@ -728,7 +729,7 @@ proc drawcommitline {level} {
728
729
}
729
730
}
730
731
}
731
- set x [expr $canvx0 + $level * $linespc ]
732
+ set x [xcoord $level $level $lineno ]
732
733
set y1 $canvy
733
734
set canvy [expr $canvy + $linespc ]
734
735
allcanvs conf -scrollregion \
@@ -756,7 +757,7 @@ proc drawcommitline {level} {
756
757
-fill $ofill -outline black -width 1]
757
758
$canv raise $t
758
759
$canv bind $t <1> {selcanvline {} %x %y}
759
- set xt [expr $canvx0 + [llength $todo ] * $linespc ]
760
+ set xt [xcoord [llength $todo ] $level $lineno ]
760
761
if {[llength $currentparents ] > 2} {
761
762
set xt [expr {$xt + ([llength $currentparents ] - 2) * $linespc }]
762
763
}
@@ -832,8 +833,8 @@ proc drawtags {id x xt y1} {
832
833
proc updatetodo {level noshortcut} {
833
834
global currentparents ncleft todo
834
835
global mainline oldlevel oldtodo oldnlines
835
- global canvx0 canvy linespc mainline
836
- global commitinfo
836
+ global canvy linespc mainline
837
+ global commitinfo lineno xspc1
837
838
838
839
set oldlevel $level
839
840
set oldtodo $todo
@@ -842,10 +843,11 @@ proc updatetodo {level noshortcut} {
842
843
set p [lindex $currentparents 0]
843
844
if {$ncleft($p) == 1 && [lsearch -exact $todo $p ] < 0} {
844
845
set ncleft($p ) 0
845
- set x [expr $canvx0 + $level * $linespc ]
846
+ set x [xcoord $level $level $lineno ]
846
847
set y [expr $canvy - $linespc ]
847
848
set mainline($p ) [list $x $y ]
848
849
set todo [lreplace $todo $level $level $p ]
850
+ set xspc1([expr {$lineno + 1}]) $xspc1($lineno)
849
851
return 0
850
852
}
851
853
}
@@ -891,28 +893,54 @@ proc notecrossings {id lo hi corner} {
891
893
}
892
894
}
893
895
894
- proc drawslants {} {
895
- global canv mainline sidelines canvx0 canvy linespc
896
- global oldlevel oldtodo todo currentparents dupparents
897
- global lthickness linespc canvy colormap
896
+ proc xcoord {i level ln} {
897
+ global canvx0 xspc1 xspc2
898
+
899
+ set x [expr {$canvx0 + $i * $xspc1($ln) }]
900
+ if {$i > 0 && $i == $level } {
901
+ set x [expr {$x + 0.5 * ($xspc2 - $xspc1($ln) )}]
902
+ } elseif {$i > $level } {
903
+ set x [expr {$x + $xspc2 - $xspc1($ln) }]
904
+ }
905
+ return $x
906
+ }
898
907
908
+ proc drawslants {level} {
909
+ global canv mainline sidelines canvx0 canvy xspc1 xspc2 lthickness
910
+ global oldlevel oldtodo todo currentparents dupparents
911
+ global lthickness linespc canvy colormap lineno geometry
912
+ global maxgraphpct
913
+
914
+ # decide on the line spacing for the next line
915
+ set lj [expr {$lineno + 1}]
916
+ set maxw [expr {$maxgraphpct * $geometry(canv1) / 100}]
917
+ set n [llength $todo ]
918
+ if {$n <= 1 || $canvx0 + $n * $xspc2 <= $maxw } {
919
+ set xspc1($lj ) $xspc2
920
+ } else {
921
+ set xspc1($lj ) [expr {($maxw - $canvx0 - $xspc2 ) / ($n - 1)}]
922
+ if {$xspc1($lj) < $lthickness } {
923
+ set xspc1($lj ) $lthickness
924
+ }
925
+ }
926
+
899
927
set y1 [expr $canvy - $linespc ]
900
928
set y2 $canvy
901
929
set i -1
902
930
foreach id $oldtodo {
903
931
incr i
904
932
if {$id == {}} continue
905
- set xi [expr { $canvx0 + $i * $linespc } ]
933
+ set xi [xcoord $i $oldlevel $lineno ]
906
934
if {$i == $oldlevel } {
907
935
foreach p $currentparents {
908
936
set j [lsearch -exact $todo $p ]
909
937
set coords [list $xi $y1 ]
910
- set xj [expr { $canvx0 + $j * $linespc } ]
911
- if {$j < $i - 1 } {
912
- lappend coords [expr $xj + $linespc ] $y1
938
+ set xj [xcoord $j $level $lj ]
939
+ if {$xj < $xi - $linespc } {
940
+ lappend coords [expr { $xj + $linespc } ] $y1
913
941
notecrossings $p $j $i [expr {$j + 1}]
914
- } elseif {$j > $i + 1 } {
915
- lappend coords [expr $xj - $linespc ] $y1
942
+ } elseif {$xj > $xi + $linespc } {
943
+ lappend coords [expr { $xj - $linespc } ] $y1
916
944
notecrossings $p $i $j [expr {$j - 1}]
917
945
}
918
946
if {[lsearch -exact $dupparents $p ] >= 0} {
@@ -924,28 +952,48 @@ proc drawslants {} {
924
952
}
925
953
} else {
926
954
# normal case, no parent duplicated
955
+ set yb $y2
956
+ set dx [expr {abs($xi - $xj )}]
957
+ if {0 && $dx < $linespc } {
958
+ set yb [expr {$y1 + $dx }]
959
+ }
927
960
if {![info exists mainline($p )]} {
928
- if {$i != $j } {
929
- lappend coords $xj $y2
961
+ if {$xi != $xj } {
962
+ lappend coords $xj $yb
930
963
}
931
964
set mainline($p ) $coords
932
965
} else {
933
- lappend coords $xj $y2
966
+ lappend coords $xj $yb
967
+ if {$yb < $y2 } {
968
+ lappend coords $xj $y2
969
+ }
934
970
lappend sidelines($p ) [list $coords 1]
935
971
}
936
972
}
937
973
}
938
- } elseif {[lindex $todo $i ] != $id } {
939
- set j [lsearch -exact $todo $id ]
940
- set xj [expr {$canvx0 + $j * $linespc }]
941
- lappend mainline($id ) $xi $y1 $xj $y2
974
+ } else {
975
+ set j $i
976
+ if {[lindex $todo $i ] != $id } {
977
+ set j [lsearch -exact $todo $id ]
978
+ }
979
+ if {$j != $i || $xspc1($lineno) != $xspc1($lj)
980
+ || ($oldlevel <= $i && $i <= $level )
981
+ || ($level <= $i && $i <= $oldlevel )} {
982
+ set xj [xcoord $j $level $lj ]
983
+ set dx [expr {abs($xi - $xj )}]
984
+ set yb $y2
985
+ if {0 && $dx < $linespc } {
986
+ set yb [expr {$y1 + $dx }]
987
+ }
988
+ lappend mainline($id ) $xi $y1 $xj $yb
989
+ }
942
990
}
943
991
}
944
992
}
945
993
946
994
proc decidenext {{noread 0}} {
947
995
global parents children nchildren ncleft todo
948
- global canv canv2 canv3 mainfont namefont canvx0 canvy linespc
996
+ global canv canv2 canv3 mainfont namefont canvy linespc
949
997
global datemode cdate
950
998
global commitinfo
951
999
global currentparents oldlevel oldnlines oldtodo
@@ -1036,7 +1084,7 @@ proc drawcommit {id} {
1036
1084
return
1037
1085
}
1038
1086
while 1 {
1039
- drawslants
1087
+ drawslants $level
1040
1088
drawcommitline $level
1041
1089
if {[updatetodo $level $datemode ]} {
1042
1090
set level [decidenext 1]
@@ -1065,8 +1113,8 @@ proc finishcommits {} {
1065
1113
-font $mainfont -tags textitems
1066
1114
set phase {}
1067
1115
} else {
1068
- drawslants
1069
1116
set level [decidenext]
1117
+ drawslants $level
1070
1118
drawrest $level [llength $startcommits ]
1071
1119
}
1072
1120
. config -cursor $maincursor
@@ -1114,7 +1162,7 @@ proc drawrest {level startix} {
1114
1162
if {$hard } {
1115
1163
set level [decidenext]
1116
1164
if {$level < 0} break
1117
- drawslants
1165
+ drawslants $level
1118
1166
}
1119
1167
if {[clock clicks -milliseconds] >= $nextupdate } {
1120
1168
update
@@ -2451,10 +2499,14 @@ proc listboxsel {} {
2451
2499
2452
2500
proc setcoords {} {
2453
2501
global linespc charspc canvx0 canvy0 mainfont
2502
+ global xspc1 xspc2
2503
+
2454
2504
set linespc [font metrics $mainfont -linespace]
2455
2505
set charspc [font measure $mainfont " m" ]
2456
2506
set canvy0 [expr 3 + 0.5 * $linespc ]
2457
2507
set canvx0 [expr 3 + 0.5 * $linespc ]
2508
+ set xspc1(0) $linespc
2509
+ set xspc2 $linespc
2458
2510
}
2459
2511
2460
2512
proc redisplay {} {
@@ -2941,6 +2993,7 @@ set mainfont {Helvetica 9}
2941
2993
set textfont {Courier 9}
2942
2994
set findmergefiles 0
2943
2995
set gaudydiff 0
2996
+ set maxgraphpct 50
2944
2997
2945
2998
set colors {green red blue magenta darkgrey brown orange}
2946
2999
0 commit comments