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

gitk: Basic support for highlighting one view within another

With this, one view can be used as a highlight for another, so that the commits that are in the highlight view are displayed in bold. This required some fairly major changes to how the list of ids, parents, children, and id to row mapping were stored for each view. We can now be reading in several views at once; for all except the current view, we just update the displayorder and the lists of parents and children for the view. This also creates a little bit of infrastructure for handling the watch cursor. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed May 2, 2006 at 11:15 UTC da7c24dd9c75d014780179f8eb843968919e4c46
1 file changed +343 -221
gitk
+343 -221
@@ -16,75 +16,82 @@ proc gitdir {} {
16 }
17 }
18
19 -proc start_rev_list {} {
19 +proc start_rev_list {view} {
20 global startmsecs nextupdate ncmupdate
21 global commfd leftover tclencoding datemode
22 - global revtreeargs curview viewfiles
22 + global revtreeargs viewfiles commitidx
23
24 set startmsecs [clock clicks -milliseconds]
25 set nextupdate [expr {$startmsecs + 100}]
26 set ncmupdate 1
27 - initlayout
27 + set commitidx($view) 0
28 set args $revtreeargs
29 - if {$viewfiles($curview) ne {}} {
30 - set args [concat $args "--" $viewfiles($curview)]
29 + if {$viewfiles($view) ne {}} {
30 + set args [concat $args "--" $viewfiles($view)]
31 }
32 set order "--topo-order"
33 if {$datemode} {
34 set order "--date-order"
35 }
36 if {[catch {
37 - set commfd [open [concat | git-rev-list --header $order \
38 - --parents --boundary --default HEAD $args] r]
37 + set fd [open [concat | git-rev-list --header $order \
38 + --parents --boundary --default HEAD $args] r]
39 } err]} {
40 puts stderr "Error executing git-rev-list: $err"
41 exit 1
42 }
43 - set leftover {}
44 - fconfigure $commfd -blocking 0 -translation lf
43 + set commfd($view) $fd
44 + set leftover($view) {}
45 + fconfigure $fd -blocking 0 -translation lf
46 if {$tclencoding != {}} {
46 - fconfigure $commfd -encoding $tclencoding
47 + fconfigure $fd -encoding $tclencoding
48 }
48 - fileevent $commfd readable [list getcommitlines $commfd]
49 - . config -cursor watch
50 - settextcursor watch
49 + fileevent $fd readable [list getcommitlines $fd $view]
50 + nowbusy $view
51 }
52
53 proc stop_rev_list {} {
54 - global commfd
54 + global commfd curview
55
56 - if {![info exists commfd]} return
56 + if {![info exists commfd($curview)]} return
57 + set fd $commfd($curview)
58 catch {
58 - set pid [pid $commfd]
59 + set pid [pid $fd]
60 exec kill $pid
61 }
61 - catch {close $commfd}
62 - unset commfd
62 + catch {close $fd}
63 + unset commfd($curview)
64 }
65
66 proc getcommits {} {
66 - global phase canv mainfont
67 + global phase canv mainfont curview
68
69 set phase getcommits
69 - start_rev_list
70 + initlayout
71 + start_rev_list $curview
72 $canv delete all
73 $canv create text 3 3 -anchor nw -text "Reading commits..." \
74 -font $mainfont -tags textitems
75 }
76
75 -proc getcommitlines {commfd} {
77 +proc getcommitlines {fd view} {
78 global commitlisted nextupdate
77 - global leftover
79 + global leftover commfd
80 global displayorder commitidx commitrow commitdata
79 - global parentlist childlist children
81 + global parentlist childlist children curview hlview
82 + global vparentlist vchildlist vdisporder vcmitlisted
83
81 - set stuff [read $commfd]
84 + set stuff [read $fd]
85 if {$stuff == {}} {
83 - if {![eof $commfd]} return
86 + if {![eof $fd]} return
87 + unset commfd($view)
88 # set it blocking so we wait for the process to terminate
85 - fconfigure $commfd -blocking 1
86 - if {![catch {close $commfd} err]} {
87 - after idle finishcommits
89 + fconfigure $fd -blocking 1
90 + if {![catch {close $fd} err]} {
91 + notbusy $view
92 + if {$view == $curview} {
93 + after idle finishcommits
94 + }
95 return
96 }
97 if {[string range $err 0 4] == "usage"} {
@@ -103,13 +110,13 @@ proc getcommitlines {commfd} {
110 while 1 {
111 set i [string first "\0" $stuff $start]
112 if {$i < 0} {
106 - append leftover [string range $stuff $start end]
113 + append leftover($view) [string range $stuff $start end]
114 break
115 }
116 if {$start == 0} {
110 - set cmit $leftover
117 + set cmit $leftover($view)
118 append cmit [string range $stuff 0 [expr {$i - 1}]]
112 - set leftover {}
119 + set leftover($view) {}
120 } else {
121 set cmit [string range $stuff $start [expr {$i - 1}]]
122 }
@@ -145,40 +152,49 @@ proc getcommitlines {commfd} {
152 set i 0
153 foreach p $olds {
154 if {$i == 0 || [lsearch -exact $olds $p] >= $i} {
148 - lappend children($p) $id
155 + lappend children($view,$p) $id
156 }
157 incr i
158 }
159 } else {
160 set olds {}
161 }
155 - lappend parentlist $olds
156 - if {[info exists children($id)]} {
157 - lappend childlist $children($id)
158 - unset children($id)
159 - } else {
160 - lappend childlist {}
162 + if {![info exists children($view,$id)]} {
163 + set children($view,$id) {}
164 }
165 set commitdata($id) [string range $cmit [expr {$j + 1}] end]
163 - set commitrow($id) $commitidx
164 - incr commitidx
165 - lappend displayorder $id
166 - lappend commitlisted $listed
166 + set commitrow($view,$id) $commitidx($view)
167 + incr commitidx($view)
168 + if {$view == $curview} {
169 + lappend parentlist $olds
170 + lappend childlist $children($view,$id)
171 + lappend displayorder $id
172 + lappend commitlisted $listed
173 + } else {
174 + lappend vparentlist($view) $olds
175 + lappend vchildlist($view) $children($view,$id)
176 + lappend vdisporder($view) $id
177 + lappend vcmitlisted($view) $listed
178 + }
179 set gotsome 1
180 }
181 if {$gotsome} {
170 - layoutmore
182 + if {$view == $curview} {
183 + layoutmore
184 + } elseif {[info exists hlview] && $view == $hlview} {
185 + highlightmore
186 + }
187 }
188 if {[clock clicks -milliseconds] >= $nextupdate} {
173 - doupdate 1
189 + doupdate
190 }
191 }
192
177 -proc doupdate {reading} {
193 +proc doupdate {} {
194 global commfd nextupdate numcommits ncmupdate
195
180 - if {$reading} {
181 - fileevent $commfd readable {}
196 + foreach v [array names commfd] {
197 + fileevent $commfd($v) readable {}
198 }
199 update
200 set nextupdate [expr {[clock clicks -milliseconds] + 100}]
@@ -189,8 +205,9 @@ proc doupdate {reading} {
205 } else {
206 set ncmupdate [expr {$numcommits + 100}]
207 }
192 - if {$reading} {
193 - fileevent $commfd readable [list getcommitlines $commfd]
208 + foreach v [array names commfd] {
209 + set fd $commfd($v)
210 + fileevent $fd readable [list getcommitlines $fd $v]
211 }
212 }
213
@@ -200,13 +217,18 @@ proc readcommit {id} {
217 }
218
219 proc updatecommits {} {
203 - global viewdata curview revtreeargs phase
220 + global viewdata curview revtreeargs phase displayorder
221 + global children commitrow
222
223 if {$phase ne {}} {
224 stop_rev_list
225 set phase {}
226 }
227 set n $curview
228 + foreach id $displayorder {
229 + catch {unset children($n,$id)}
230 + catch {unset commitrow($n,$id)}
231 + }
232 set curview -1
233 catch {unset viewdata($n)}
234 readrefs
@@ -363,14 +385,23 @@ proc makewindow {} {
385 .bar add cascade -label "Edit" -menu .bar.edit
386 .bar.edit add command -label "Preferences" -command doprefs
387 .bar.edit configure -font $uifont
388 +
389 menu .bar.view -font $uifont
390 + menu .bar.view.hl -font $uifont -tearoff 0
391 .bar add cascade -label "View" -menu .bar.view
368 - .bar.view add command -label "New view..." -command newview
369 - .bar.view add command -label "Edit view..." -command editview
392 + .bar.view add command -label "New view..." -command {newview 0}
393 + .bar.view add command -label "Edit view..." -command editview \
394 + -state disabled
395 .bar.view add command -label "Delete view" -command delview -state disabled
396 + .bar.view add cascade -label "Highlight" -menu .bar.view.hl
397 .bar.view add separator
398 .bar.view add radiobutton -label "All files" -command {showview 0} \
399 -variable selectedview -value 0
400 + .bar.view.hl add command -label "New view..." -command {newview 1}
401 + .bar.view.hl add command -label "Remove" -command delhighlight \
402 + -state disabled
403 + .bar.view.hl add separator
404 +
405 menu .bar.help
406 .bar add cascade -label "Help" -menu .bar.help
407 .bar.help add command -label "About gitk" -command about
@@ -1154,9 +1185,10 @@ proc highlight_flist {ll} {
1185
1186 # Code to implement multiple views
1187
1157 -proc newview {} {
1158 - global nextviewnum newviewname newviewperm uifont
1188 +proc newview {ishighlight} {
1189 + global nextviewnum newviewname newviewperm uifont newishighlight
1190
1191 + set newishighlight $ishighlight
1192 set top .gitkview
1193 if {[winfo exists $top]} {
1194 raise $top
@@ -1215,19 +1247,23 @@ proc vieweditor {top n title} {
1247 focus $top.t
1248 }
1249
1218 -proc viewmenuitem {n} {
1219 - set nmenu [.bar.view index end]
1220 - set targetcmd [list showview $n]
1221 - for {set i 6} {$i <= $nmenu} {incr i} {
1222 - if {[.bar.view entrycget $i -command] eq $targetcmd} {
1223 - return $i
1250 +proc doviewmenu {m first cmd op args} {
1251 + set nmenu [$m index end]
1252 + for {set i $first} {$i <= $nmenu} {incr i} {
1253 + if {[$m entrycget $i -command] eq $cmd} {
1254 + eval $m $op $i $args
1255 + break
1256 }
1257 }
1226 - return {}
1258 +}
1259 +
1260 +proc allviewmenus {n op args} {
1261 + doviewmenu .bar.view 6 [list showview $n] $op $args
1262 + doviewmenu .bar.view.hl 3 [list addhighlight $n] $op $args
1263 }
1264
1265 proc newviewok {top n} {
1230 - global nextviewnum newviewperm newviewname
1266 + global nextviewnum newviewperm newviewname newishighlight
1267 global viewname viewfiles viewperm selectedview curview
1268
1269 set files {}
@@ -1243,18 +1279,18 @@ proc newviewok {top n} {
1279 set viewname($n) $newviewname($n)
1280 set viewperm($n) $newviewperm($n)
1281 set viewfiles($n) $files
1246 - .bar.view add radiobutton -label $viewname($n) \
1247 - -command [list showview $n] -variable selectedview -value $n
1248 - after idle showview $n
1282 + addviewmenu $n
1283 + if {!$newishighlight} {
1284 + after idle showview $n
1285 + } else {
1286 + after idle addhighlight $n
1287 + }
1288 } else {
1289 # editing an existing view
1290 set viewperm($n) $newviewperm($n)
1291 if {$newviewname($n) ne $viewname($n)} {
1292 set viewname($n) $newviewname($n)
1254 - set i [viewmenuitem $n]
1255 - if {$i ne {}} {
1256 - .bar.view entryconf $i -label $viewname($n)
1257 - }
1293 + allviewmenus $n entryconf -label $viewname($n)
1294 }
1295 if {$files ne $viewfiles($n)} {
1296 set viewfiles($n) $files
@@ -1270,15 +1306,21 @@ proc delview {} {
1306 global curview viewdata viewperm
1307
1308 if {$curview == 0} return
1273 - set i [viewmenuitem $curview]
1274 - if {$i ne {}} {
1275 - .bar.view delete $i
1276 - }
1309 + allviewmenus $curview delete
1310 set viewdata($curview) {}
1311 set viewperm($curview) 0
1312 showview 0
1313 }
1314
1315 +proc addviewmenu {n} {
1316 + global viewname
1317 +
1318 + .bar.view add radiobutton -label $viewname($n) \
1319 + -command [list showview $n] -variable selectedview -value $n
1320 + .bar.view.hl add radiobutton -label $viewname($n) \
1321 + -command [list addhighlight $n] -variable selectedhlview -value $n
1322 +}
1323 +
1324 proc flatten {var} {
1325 global $var
1326
@@ -1301,14 +1343,15 @@ proc unflatten {var l} {
1343 proc showview {n} {
1344 global curview viewdata viewfiles
1345 global displayorder parentlist childlist rowidlist rowoffsets
1304 - global colormap rowtextx commitrow
1346 + global colormap rowtextx commitrow nextcolor canvxmax
1347 global numcommits rowrangelist commitlisted idrowranges
1348 global selectedline currentid canv canvy0
1349 global matchinglines treediffs
1350 global pending_select phase
1309 - global commitidx rowlaidout rowoptim linesegends leftover
1351 + global commitidx rowlaidout rowoptim linesegends
1352 global commfd nextupdate
1311 - global selectedview
1353 + global selectedview hlview selectedhlview
1354 + global vparentlist vchildlist vdisporder vcmitlisted
1355
1356 if {$n == $curview} return
1357 set selid {}
@@ -1329,20 +1372,19 @@ proc showview {n} {
1372 normalline
1373 stopfindproc
1374 if {$curview >= 0} {
1375 + set vparentlist($curview) $parentlist
1376 + set vchildlist($curview) $childlist
1377 + set vdisporder($curview) $displayorder
1378 + set vcmitlisted($curview) $commitlisted
1379 if {$phase ne {}} {
1380 set viewdata($curview) \
1334 - [list $phase $displayorder $parentlist $childlist $rowidlist \
1335 - $rowoffsets $rowrangelist $commitlisted \
1336 - [flatten children] [flatten idrowranges] \
1337 - [flatten idinlist] \
1338 - $commitidx $rowlaidout $rowoptim $numcommits \
1339 - $linesegends $leftover $commfd]
1340 - fileevent $commfd readable {}
1381 + [list $phase $rowidlist $rowoffsets $rowrangelist \
1382 + [flatten idrowranges] [flatten idinlist] \
1383 + $rowlaidout $rowoptim $numcommits $linesegends]
1384 } elseif {![info exists viewdata($curview)]
1385 || [lindex $viewdata($curview) 0] ne {}} {
1386 set viewdata($curview) \
1344 - [list {} $displayorder $parentlist $childlist $rowidlist \
1345 - $rowoffsets $rowrangelist $commitlisted]
1387 + [list {} $rowidlist $rowoffsets $rowrangelist]
1388 }
1389 }
1390 catch {unset matchinglines}
@@ -1351,8 +1393,11 @@ proc showview {n} {
1393
1394 set curview $n
1395 set selectedview $n
1396 + set selectedhlview -1
1397 + .bar.view entryconf 1 -state [expr {$n == 0? "disabled": "normal"}]
1398 .bar.view entryconf 2 -state [expr {$n == 0? "disabled": "normal"}]
1355 - .bar.view entryconf 3 -state [expr {$n == 0? "disabled": "normal"}]
1399 + catch {unset hlview}
1400 + .bar.view.hl entryconf 1 -state disabled
1401
1402 if {![info exists viewdata($n)]} {
1403 set pending_select $selid
@@ -1362,46 +1407,36 @@ proc showview {n} {
1407
1408 set v $viewdata($n)
1409 set phase [lindex $v 0]
1365 - set displayorder [lindex $v 1]
1366 - set parentlist [lindex $v 2]
1367 - set childlist [lindex $v 3]
1368 - set rowidlist [lindex $v 4]
1369 - set rowoffsets [lindex $v 5]
1370 - set rowrangelist [lindex $v 6]
1371 - set commitlisted [lindex $v 7]
1410 + set displayorder $vdisporder($n)
1411 + set parentlist $vparentlist($n)
1412 + set childlist $vchildlist($n)
1413 + set commitlisted $vcmitlisted($n)
1414 + set rowidlist [lindex $v 1]
1415 + set rowoffsets [lindex $v 2]
1416 + set rowrangelist [lindex $v 3]
1417 if {$phase eq {}} {
1418 set numcommits [llength $displayorder]
1419 catch {unset idrowranges}
1375 - catch {unset children}
1420 } else {
1377 - unflatten children [lindex $v 8]
1378 - unflatten idrowranges [lindex $v 9]
1379 - unflatten idinlist [lindex $v 10]
1380 - set commitidx [lindex $v 11]
1381 - set rowlaidout [lindex $v 12]
1382 - set rowoptim [lindex $v 13]
1383 - set numcommits [lindex $v 14]
1384 - set linesegends [lindex $v 15]
1385 - set leftover [lindex $v 16]
1386 - set commfd [lindex $v 17]
1387 - fileevent $commfd readable [list getcommitlines $commfd]
1388 - set nextupdate [expr {[clock clicks -milliseconds] + 100}]
1421 + unflatten idrowranges [lindex $v 4]
1422 + unflatten idinlist [lindex $v 5]
1423 + set rowlaidout [lindex $v 6]
1424 + set rowoptim [lindex $v 7]
1425 + set numcommits [lindex $v 8]
1426 + set linesegends [lindex $v 9]
1427 }
1428
1429 catch {unset colormap}
1430 catch {unset rowtextx}
1393 - catch {unset commitrow}
1431 + set nextcolor 0
1432 + set canvxmax [$canv cget -width]
1433 set curview $n
1434 set row 0
1396 - foreach id $displayorder {
1397 - set commitrow($id) $row
1398 - incr row
1399 - }
1435 setcanvscroll
1436 set yf 0
1437 set row 0
1403 - if {$selid ne {} && [info exists commitrow($selid)]} {
1404 - set row $commitrow($selid)
1438 + if {$selid ne {} && [info exists commitrow($n,$selid)]} {
1439 + set row $commitrow($n,$selid)
1440 # try to get the selected row in the same position on the screen
1441 set ymax [lindex [$canv cget -scrollregion] 3]
1442 set ytop [expr {[yc $row] - $yscreen}]
@@ -1413,21 +1448,98 @@ proc showview {n} {
1448 allcanvs yview moveto $yf
1449 drawvisible
1450 selectline $row 0
1416 - if {$phase eq {}} {
1417 - global maincursor textcursor
1418 - . config -cursor $maincursor
1419 - settextcursor $textcursor
1420 - } else {
1421 - . config -cursor watch
1422 - settextcursor watch
1451 + if {$phase ne {}} {
1452 if {$phase eq "getcommits"} {
1453 global mainfont
1454 $canv create text 3 3 -anchor nw -text "Reading commits..." \
1455 -font $mainfont -tags textitems
1456 }
1457 + if {[info exists commfd($n)]} {
1458 + layoutmore
1459 + } else {
1460 + finishcommits
1461 + }
1462 }
1463 }
1464
1465 +proc addhighlight {n} {
1466 + global hlview curview viewdata highlighted highlightedrows
1467 + global selectedhlview
1468 +
1469 + if {[info exists hlview]} {
1470 + delhighlight
1471 + }
1472 + set hlview $n
1473 + set selectedhlview $n
1474 + .bar.view.hl entryconf 1 -state normal
1475 + set highlighted($n) 0
1476 + set highlightedrows {}
1477 + if {$n != $curview && ![info exists viewdata($n)]} {
1478 + set viewdata($n) [list getcommits {{}} {{}} {} {} {} 0 0 0 {}]
1479 + set vparentlist($n) {}
1480 + set vchildlist($n) {}
1481 + set vdisporder($n) {}
1482 + set vcmitlisted($n) {}
1483 + start_rev_list $n
1484 + } else {
1485 + highlightmore
1486 + }
1487 +}
1488 +
1489 +proc delhighlight {} {
1490 + global hlview highlightedrows canv linehtag mainfont
1491 + global selectedhlview selectedline
1492 +
1493 + if {![info exists hlview]} return
1494 + unset hlview
1495 + set selectedhlview {}
1496 + .bar.view.hl entryconf 1 -state disabled
1497 + foreach l $highlightedrows {
1498 + $canv itemconf $linehtag($l) -font $mainfont
1499 + if {$l == $selectedline} {
1500 + $canv delete secsel
1501 + set t [eval $canv create rect [$canv bbox $linehtag($l)] \
1502 + -outline {{}} -tags secsel \
1503 + -fill [$canv cget -selectbackground]]
1504 + $canv lower $t
1505 + }
1506 + }
1507 +}
1508 +
1509 +proc highlightmore {} {
1510 + global hlview highlighted commitidx highlightedrows linehtag mainfont
1511 + global displayorder vdisporder curview canv commitrow selectedline
1512 +
1513 + set font [concat $mainfont bold]
1514 + set max $commitidx($hlview)
1515 + if {$hlview == $curview} {
1516 + set disp $displayorder
1517 + } else {
1518 + set disp $vdisporder($hlview)
1519 + }
1520 + for {set i $highlighted($hlview)} {$i < $max} {incr i} {
1521 + set id [lindex $disp $i]
1522 + if {[info exists commitrow($curview,$id)]} {
1523 + set row $commitrow($curview,$id)
1524 + if {[info exists linehtag($row)]} {
1525 + $canv itemconf $linehtag($row) -font $font
1526 + lappend highlightedrows $row
1527 + if {$row == $selectedline} {
1528 + $canv delete secsel
1529 + set t [eval $canv create rect \
1530 + [$canv bbox $linehtag($row)] \
1531 + -outline {{}} -tags secsel \
1532 + -fill [$canv cget -selectbackground]]
1533 + $canv lower $t
1534 + }
1535 + }
1536 + }
1537 + }
1538 + set highlighted($hlview) $max
1539 +}
1540 +
1541 +# Graph layout functions
1542 +
1543 proc shortids {ids} {
1544 set res {}
1545 foreach id $ids {
@@ -1463,19 +1575,19 @@ proc ntimes {n o} {
1575 }
1576
1577 proc usedinrange {id l1 l2} {
1466 - global children commitrow childlist
1578 + global children commitrow childlist curview
1579
1468 - if {[info exists commitrow($id)]} {
1469 - set r $commitrow($id)
1580 + if {[info exists commitrow($curview,$id)]} {
1581 + set r $commitrow($curview,$id)
1582 if {$l1 <= $r && $r <= $l2} {
1583 return [expr {$r - $l1 + 1}]
1584 }
1585 set kids [lindex $childlist $r]
1586 } else {
1475 - set kids $children($id)
1587 + set kids $children($curview,$id)
1588 }
1589 foreach c $kids {
1478 - set r $commitrow($c)
1590 + set r $commitrow($curview,$c)
1591 if {$l1 <= $r && $r <= $l2} {
1592 return [expr {$r - $l1 + 1}]
1593 }
@@ -1546,20 +1658,18 @@ proc initlayout {} {
1658 global rowidlist rowoffsets displayorder commitlisted
1659 global rowlaidout rowoptim
1660 global idinlist rowchk rowrangelist idrowranges
1549 - global commitidx numcommits canvxmax canv
1661 + global numcommits canvxmax canv
1662 global nextcolor
1663 global parentlist childlist children
1552 - global colormap rowtextx commitrow
1664 + global colormap rowtextx
1665 global linesegends
1666
1555 - set commitidx 0
1667 set numcommits 0
1668 set displayorder {}
1669 set commitlisted {}
1670 set parentlist {}
1671 set childlist {}
1672 set rowrangelist {}
1562 - catch {unset children}
1673 set nextcolor 0
1674 set rowidlist {{}}
1675 set rowoffsets {{}}
@@ -1570,7 +1680,6 @@ proc initlayout {} {
1680 set canvxmax [$canv cget -width]
1681 catch {unset colormap}
1682 catch {unset rowtextx}
1573 - catch {unset commitrow}
1683 catch {unset idrowranges}
1684 set linesegends {}
1685 }
@@ -1605,10 +1714,10 @@ proc visiblerows {} {
1714
1715 proc layoutmore {} {
1716 global rowlaidout rowoptim commitidx numcommits optim_delay
1608 - global uparrowlen
1717 + global uparrowlen curview
1718
1719 set row $rowlaidout
1611 - set rowlaidout [layoutrows $row $commitidx 0]
1720 + set rowlaidout [layoutrows $row $commitidx($curview) 0]
1721 set orow [expr {$rowlaidout - $uparrowlen - 1}]
1722 if {$orow > $rowoptim} {
1723 optimize_rows $rowoptim 0 $orow
@@ -1622,7 +1731,7 @@ proc layoutmore {} {
1731
1732 proc showstuff {canshow} {
1733 global numcommits commitrow pending_select selectedline
1625 - global linesegends idrowranges idrangedrawn
1734 + global linesegends idrowranges idrangedrawn curview
1735
1736 if {$numcommits == 0} {
1737 global phase
@@ -1657,9 +1766,9 @@ proc showstuff {canshow} {
1766 incr row
1767 }
1768 if {[info exists pending_select] &&
1660 - [info exists commitrow($pending_select)] &&
1661 - $commitrow($pending_select) < $numcommits} {
1662 - selectline $commitrow($pending_select) 1
1769 + [info exists commitrow($curview,$pending_select)] &&
1770 + $commitrow($curview,$pending_select) < $numcommits} {
1771 + selectline $commitrow($curview,$pending_select) 1
1772 }
1773 if {![info exists selectedline] && ![info exists pending_select]} {
1774 selectline 0 1
@@ -1671,7 +1780,7 @@ proc layoutrows {row endrow last} {
1780 global uparrowlen downarrowlen maxwidth mingaplen
1781 global childlist parentlist
1782 global idrowranges linesegends
1674 - global commitidx
1783 + global commitidx curview
1784 global idinlist rowchk rowrangelist
1785
1786 set idlist [lindex $rowidlist $row]
@@ -1691,7 +1800,8 @@ proc layoutrows {row endrow last} {
1800 set nev [expr {[llength $idlist] + [llength $newolds]
1801 + [llength $oldolds] - $maxwidth + 1}]
1802 if {$nev > 0} {
1694 - if {!$last && $row + $uparrowlen + $mingaplen >= $commitidx} break
1803 + if {!$last &&
1804 + $row + $uparrowlen + $mingaplen >= $commitidx($curview)} break
1805 for {set x [llength $idlist]} {[incr x -1] >= 0} {} {
1806 set i [lindex $idlist $x]
1807 if {![info exists rowchk($i)] || $row >= $rowchk($i)} {
@@ -1780,30 +1890,28 @@ proc layoutrows {row endrow last} {
1890 proc addextraid {id row} {
1891 global displayorder commitrow commitinfo
1892 global commitidx commitlisted
1783 - global parentlist childlist children
1893 + global parentlist childlist children curview
1894
1785 - incr commitidx
1895 + incr commitidx($curview)
1896 lappend displayorder $id
1897 lappend commitlisted 0
1898 lappend parentlist {}
1789 - set commitrow($id) $row
1899 + set commitrow($curview,$id) $row
1900 readcommit $id
1901 if {![info exists commitinfo($id)]} {
1902 set commitinfo($id) {"No commit information available"}
1903 }
1794 - if {[info exists children($id)]} {
1795 - lappend childlist $children($id)
1796 - unset children($id)
1797 - } else {
1798 - lappend childlist {}
1904 + if {![info exists children($curview,$id)]} {
1905 + set children($curview,$id) {}
1906 }
1907 + lappend childlist $children($curview,$id)
1908 }
1909
1910 proc layouttail {} {
1803 - global rowidlist rowoffsets idinlist commitidx
1911 + global rowidlist rowoffsets idinlist commitidx curview
1912 global idrowranges rowrangelist
1913
1806 - set row $commitidx
1914 + set row $commitidx($curview)
1915 set idlist [lindex $rowidlist $row]
1916 while {$idlist ne {}} {
1917 set col [expr {[llength $idlist] - 1}]
@@ -1978,12 +2086,13 @@ proc linewidth {id} {
2086 }
2087
2088 proc rowranges {id} {
1981 - global phase idrowranges commitrow rowlaidout rowrangelist
2089 + global phase idrowranges commitrow rowlaidout rowrangelist curview
2090
2091 set ranges {}
2092 if {$phase eq {} ||
1985 - ([info exists commitrow($id)] && $commitrow($id) < $rowlaidout)} {
1986 - set ranges [lindex $rowrangelist $commitrow($id)]
2093 + ([info exists commitrow($curview,$id)]
2094 + && $commitrow($curview,$id) < $rowlaidout)} {
2095 + set ranges [lindex $rowrangelist $commitrow($curview,$id)]
2096 } elseif {[info exists idrowranges($id)]} {
2097 set ranges $idrowranges($id)
2098 }
@@ -1994,11 +2103,12 @@ proc drawlineseg {id i} {
2103 global rowoffsets rowidlist
2104 global displayorder
2105 global canv colormap linespc
1997 - global numcommits commitrow
2106 + global numcommits commitrow curview
2107
2108 set ranges [rowranges $id]
2109 set downarrow 1
2001 - if {[info exists commitrow($id)] && $commitrow($id) < $numcommits} {
2110 + if {[info exists commitrow($curview,$id)]
2111 + && $commitrow($curview,$id) < $numcommits} {
2112 set downarrow [expr {$i < [llength $ranges] / 2 - 1}]
2113 } else {
2114 set downarrow 1
@@ -2122,7 +2232,7 @@ proc drawparentlinks {id row col olds} {
2232 proc drawlines {id} {
2233 global colormap canv
2234 global idrangedrawn
2125 - global childlist iddrawn commitrow rowidlist
2235 + global children iddrawn commitrow rowidlist curview
2236
2237 $canv delete lines.$id
2238 set nr [expr {[llength [rowranges $id]] / 2}]
@@ -2131,9 +2241,9 @@ proc drawlines {id} {
2241 drawlineseg $id $i
2242 }
2243 }
2134 - foreach child [lindex $childlist $commitrow($id)] {
2244 + foreach child $children($curview,$id) {
2245 if {[info exists iddrawn($child)]} {
2136 - set row $commitrow($child)
2246 + set row $commitrow($curview,$child)
2247 set col [lsearch -exact [lindex $rowidlist $row] $child]
2248 if {$col >= 0} {
2249 drawparentlinks $child $row $col [list $id]
@@ -2147,7 +2257,8 @@ proc drawcmittext {id row col rmx} {
2257 global commitlisted commitinfo rowidlist
2258 global rowtextx idpos idtags idheads idotherrefs
2259 global linehtag linentag linedtag
2150 - global mainfont namefont canvxmax
2260 + global mainfont canvxmax
2261 + global hlview commitrow highlightedrows
2262
2263 set ofill [expr {[lindex $commitlisted $row]? "blue": "white"}]
2264 set x [xc $row $col]
@@ -2172,11 +2283,16 @@ proc drawcmittext {id row col rmx} {
2283 set name [lindex $commitinfo($id) 1]
2284 set date [lindex $commitinfo($id) 2]
2285 set date [formatdate $date]
2286 + set font $mainfont
2287 + if {[info exists hlview] && [info exists commitrow($hlview,$id)]} {
2288 + lappend font bold
2289 + lappend highlightedrows $row
2290 + }
2291 set linehtag($row) [$canv create text $xt $y -anchor w \
2176 - -text $headline -font $mainfont ]
2292 + -text $headline -font $font]
2293 $canv bind $linehtag($row) <Button-3> "rowmenu %X %Y $id"
2294 set linentag($row) [$canv2 create text 3 $y -anchor w \
2179 - -text $name -font $namefont]
2295 + -text $name -font $mainfont]
2296 set linedtag($row) [$canv3 create text 3 $y -anchor w \
2297 -text $date -font $mainfont]
2298 set xr [expr {$xt + [font measure $mainfont $headline]}]
@@ -2307,21 +2423,19 @@ proc findcrossings {id} {
2423
2424 proc assigncolor {id} {
2425 global colormap colors nextcolor
2310 - global commitrow parentlist children childlist
2426 + global commitrow parentlist children children curview
2427
2428 if {[info exists colormap($id)]} return
2429 set ncolors [llength $colors]
2314 - if {[info exists commitrow($id)]} {
2315 - set kids [lindex $childlist $commitrow($id)]
2316 - } elseif {[info exists children($id)]} {
2317 - set kids $children($id)
2430 + if {[info exists children($curview,$id)]} {
2431 + set kids $children($curview,$id)
2432 } else {
2433 set kids {}
2434 }
2435 if {[llength $kids] == 1} {
2436 set child [lindex $kids 0]
2437 if {[info exists colormap($child)]
2324 - && [llength [lindex $parentlist $commitrow($child)]] == 1} {
2438 + && [llength [lindex $parentlist $commitrow($curview,$child)]] == 1} {
2439 set colormap($id) $colormap($child)
2440 return
2441 }
@@ -2349,7 +2463,7 @@ proc assigncolor {id} {
2463 && [lsearch -exact $badcolors $colormap($child)] < 0} {
2464 lappend badcolors $colormap($child)
2465 }
2352 - foreach p [lindex $parentlist $commitrow($child)] {
2466 + foreach p [lindex $parentlist $commitrow($curview,$child)] {
2467 if {[info exists colormap($p)]
2468 && [lsearch -exact $badcolors $colormap($p)] < 0} {
2469 lappend badcolors $colormap($p)
@@ -2382,7 +2496,7 @@ proc bindline {t id} {
2496 proc drawtags {id x xt y1} {
2497 global idtags idheads idotherrefs
2498 global linespc lthickness
2385 - global canv mainfont commitrow rowtextx
2499 + global canv mainfont commitrow rowtextx curview
2500
2501 set marks {}
2502 set ntags 0
@@ -2425,7 +2539,7 @@ proc drawtags {id x xt y1} {
2539 $xr $yt $xr $yb $xl $yb $x [expr {$yb - $delta}] \
2540 -width 1 -outline black -fill yellow -tags tag.$id]
2541 $canv bind $t <1> [list showtag $tag 1]
2428 - set rowtextx($commitrow($id)) [expr {$xr + $linespc}]
2542 + set rowtextx($commitrow($curview,$id)) [expr {$xr + $linespc}]
2543 } else {
2544 # draw a head or other ref
2545 if {[incr nheads -1] >= 0} {
@@ -2467,21 +2581,17 @@ proc xcoord {i level ln} {
2581 }
2582
2583 proc finishcommits {} {
2470 - global commitidx phase
2584 + global commitidx phase curview
2585 global canv mainfont ctext maincursor textcursor
2586 global findinprogress pending_select
2587
2474 - if {$commitidx > 0} {
2588 + if {$commitidx($curview) > 0} {
2589 drawrest
2590 } else {
2591 $canv delete all
2592 $canv create text 3 3 -anchor nw -text "No commits selected" \
2593 -font $mainfont -tags textitems
2594 }
2481 - if {![info exists findinprogress]} {
2482 - . config -cursor $maincursor
2483 - settextcursor $textcursor
2484 - }
2595 set phase {}
2596 catch {unset pending_select}
2597 }
@@ -2497,18 +2607,38 @@ proc settextcursor {c} {
2607 set curtextcursor $c
2608 }
2609
2610 +proc nowbusy {what} {
2611 + global isbusy
2612 +
2613 + if {[array names isbusy] eq {}} {
2614 + . config -cursor watch
2615 + settextcursor watch
2616 + }
2617 + set isbusy($what) 1
2618 +}
2619 +
2620 +proc notbusy {what} {
2621 + global isbusy maincursor textcursor
2622 +
2623 + catch {unset isbusy($what)}
2624 + if {[array names isbusy] eq {}} {
2625 + . config -cursor $maincursor
2626 + settextcursor $textcursor
2627 + }
2628 +}
2629 +
2630 proc drawrest {} {
2631 global numcommits
2632 global startmsecs
2633 global canvy0 numcommits linespc
2504 - global rowlaidout commitidx
2634 + global rowlaidout commitidx curview
2635 global pending_select
2636
2637 set row $rowlaidout
2508 - layoutrows $rowlaidout $commitidx 1
2638 + layoutrows $rowlaidout $commitidx($curview) 1
2639 layouttail
2510 - optimize_rows $row 0 $commitidx
2511 - showstuff $commitidx
2640 + optimize_rows $row 0 $commitidx($curview)
2641 + showstuff $commitidx($curview)
2642 if {[info exists pending_select]} {
2643 selectline 0 1
2644 }
@@ -2540,7 +2670,7 @@ proc findmatches {f} {
2670 proc dofind {} {
2671 global findtype findloc findstring markedmatches commitinfo
2672 global numcommits displayorder linehtag linentag linedtag
2543 - global mainfont namefont canv canv2 canv3 selectedline
2673 + global mainfont canv canv2 canv3 selectedline
2674 global matchinglines foundstring foundstrlen matchstring
2675 global commitdata
2676
@@ -2601,7 +2731,7 @@ proc dofind {} {
2731 markmatches $canv $l $f $linehtag($l) $matches $mainfont
2732 } elseif {$ty == "Author"} {
2733 drawcmitrow $l
2604 - markmatches $canv2 $l $f $linentag($l) $matches $namefont
2734 + markmatches $canv2 $l $f $linentag($l) $matches $mainfont
2735 } elseif {$ty == "Date"} {
2736 drawcmitrow $l
2737 markmatches $canv3 $l $f $linedtag($l) $matches $mainfont
@@ -2699,13 +2829,8 @@ proc stopfindproc {{done 0}} {
2829 catch {close $findprocfile}
2830 unset findprocpid
2831 }
2702 - if {[info exists findinprogress]} {
2703 - unset findinprogress
2704 - if {$phase eq {}} {
2705 - . config -cursor $maincursor
2706 - settextcursor $textcursor
2707 - }
2708 - }
2832 + catch {unset findinprogress}
2833 + notbusy find
2834 }
2835
2836 proc findpatches {} {
@@ -2745,14 +2870,13 @@ proc findpatches {} {
2870 fconfigure $f -blocking 0
2871 fileevent $f readable readfindproc
2872 set finddidsel 0
2748 - . config -cursor watch
2749 - settextcursor watch
2873 + nowbusy find
2874 set findinprogress 1
2875 }
2876
2877 proc readfindproc {} {
2878 global findprocfile finddidsel
2755 - global commitrow matchinglines findinsertpos
2879 + global commitrow matchinglines findinsertpos curview
2880
2881 set n [gets $findprocfile line]
2882 if {$n < 0} {
@@ -2769,11 +2893,11 @@ proc readfindproc {} {
2893 stopfindproc
2894 return
2895 }
2772 - if {![info exists commitrow($id)]} {
2896 + if {![info exists commitrow($curview,$id)]} {
2897 puts stderr "spurious id: $id"
2898 return
2899 }
2776 - set l $commitrow($id)
2900 + set l $commitrow($curview,$id)
2901 insertmatch $l $id
2902 }
2903
@@ -2847,8 +2971,7 @@ proc findfiles {} {
2971 set finddidsel 0
2972 set findinsertpos end
2973 set id [lindex $displayorder $l]
2850 - . config -cursor watch
2851 - settextcursor watch
2974 + nowbusy find
2975 set findinprogress 1
2976 findcont
2977 update
@@ -3018,7 +3141,7 @@ proc commit_descriptor {p} {
3141 # append some text to the ctext widget, and make any SHA1 ID
3142 # that we know about be a clickable link.
3143 proc appendwithlinks {text} {
3021 - global ctext commitrow linknum
3144 + global ctext commitrow linknum curview
3145
3146 set start [$ctext index "end - 1c"]
3147 $ctext insert end $text
@@ -3028,11 +3151,12 @@ proc appendwithlinks {text} {
3151 set s [lindex $l 0]
3152 set e [lindex $l 1]
3153 set linkid [string range $text $s $e]
3031 - if {![info exists commitrow($linkid)]} continue
3154 + if {![info exists commitrow($curview,$linkid)]} continue
3155 incr e
3156 $ctext tag add link "$start + $s c" "$start + $e c"
3157 $ctext tag add link$linknum "$start + $s c" "$start + $e c"
3035 - $ctext tag bind link$linknum <1> [list selectline $commitrow($linkid) 1]
3158 + $ctext tag bind link$linknum <1> \
3159 + [list selectline $commitrow($curview,$linkid) 1]
3160 incr linknum
3161 }
3162 $ctext tag conf link -foreground blue -underline 1
@@ -3686,11 +3810,10 @@ proc redisplay {} {
3810 }
3811
3812 proc incrfont {inc} {
3689 - global mainfont namefont textfont ctext canv phase
3813 + global mainfont textfont ctext canv phase
3814 global stopped entries
3815 unmarkmatches
3816 set mainfont [lreplace $mainfont 1 1 [expr {[lindex $mainfont 1] + $inc}]]
3693 - set namefont [lreplace $namefont 1 1 [expr {[lindex $namefont 1] + $inc}]]
3817 set textfont [lreplace $textfont 1 1 [expr {[lindex $textfont 1] + $inc}]]
3818 setcoords
3819 $ctext conf -font $textfont
@@ -3729,7 +3852,7 @@ proc sha1change {n1 n2 op} {
3852
3853 proc gotocommit {} {
3854 global sha1string currentid commitrow tagids headids
3732 - global displayorder numcommits
3855 + global displayorder numcommits curview
3856
3857 if {$sha1string == {}
3858 || ([info exists currentid] && $sha1string == $currentid)} return
@@ -3755,8 +3878,8 @@ proc gotocommit {} {
3878 }
3879 }
3880 }
3758 - if {[info exists commitrow($id)]} {
3759 - selectline $commitrow($id) 1
3881 + if {[info exists commitrow($curview,$id)]} {
3882 + selectline $commitrow($curview,$id) 1
3883 return
3884 }
3885 if {[regexp {^[0-9a-fA-F]{4,}$} $sha1string]} {
@@ -3864,7 +3987,7 @@ proc arrowjump {id n y} {
3987 }
3988
3989 proc lineclick {x y id isnew} {
3867 - global ctext commitinfo childlist commitrow canv thickerline
3990 + global ctext commitinfo children canv thickerline curview
3991
3992 if {![info exists commitinfo($id)] && ![getcommit $id]} return
3993 unmarkmatches
@@ -3903,7 +4026,7 @@ proc lineclick {x y id isnew} {
4026 $ctext insert end "\tAuthor:\t[lindex $info 1]\n"
4027 set date [formatdate [lindex $info 2]]
4028 $ctext insert end "\tDate:\t$date\n"
3906 - set kids [lindex $childlist $commitrow($id)]
4029 + set kids $children($curview,$id)
4030 if {$kids ne {}} {
4031 $ctext insert end "\nChildren:"
4032 set i 0
@@ -3934,9 +4057,9 @@ proc normalline {} {
4057 }
4058
4059 proc selbyid {id} {
3937 - global commitrow
3938 - if {[info exists commitrow($id)]} {
3939 - selectline $commitrow($id) 1
4060 + global commitrow curview
4061 + if {[info exists commitrow($curview,$id)]} {
4062 + selectline $commitrow($curview,$id) 1
4063 }
4064 }
4065
@@ -3949,9 +4072,10 @@ proc mstime {} {
4072 }
4073
4074 proc rowmenu {x y id} {
3952 - global rowctxmenu commitrow selectedline rowmenuid
4075 + global rowctxmenu commitrow selectedline rowmenuid curview
4076
3954 - if {![info exists selectedline] || $commitrow($id) eq $selectedline} {
4077 + if {![info exists selectedline]
4078 + || $commitrow($curview,$id) eq $selectedline} {
4079 set state disabled
4080 } else {
4081 set state normal
@@ -4151,14 +4275,15 @@ proc domktag {} {
4275 }
4276
4277 proc redrawtags {id} {
4154 - global canv linehtag commitrow idpos selectedline
4278 + global canv linehtag commitrow idpos selectedline curview
4279
4156 - if {![info exists commitrow($id)]} return
4157 - drawcmitrow $commitrow($id)
4280 + if {![info exists commitrow($curview,$id)]} return
4281 + drawcmitrow $commitrow($curview,$id)
4282 $canv delete tag.$id
4283 set xt [eval drawtags $id $idpos($id)]
4160 - $canv coords $linehtag($commitrow($id)) $xt [lindex $idpos($id) 2]
4161 - if {[info exists selectedline] && $selectedline == $commitrow($id)} {
4284 + $canv coords $linehtag($commitrow($curview,$id)) $xt [lindex $idpos($id) 2]
4285 + if {[info exists selectedline]
4286 + && $selectedline == $commitrow($curview,$id)} {
4287 selectline $selectedline 0
4288 }
4289 }
@@ -4674,8 +4799,6 @@ set colors {green red blue magenta darkgrey brown orange}
4799
4800 catch {source ~/.gitk}
4801
4677 -set namefont $mainfont
4678 -
4802 font create optionfont -family sans-serif -size -12
4803
4804 set revtreeargs {}
@@ -4704,6 +4827,7 @@ set optim_delay 16
4827 set nextviewnum 1
4828 set curview 0
4829 set selectedview 0
4830 +set selectedhlview {}
4831 set viewfiles(0) {}
4832 set viewperm(0) 0
4833
@@ -4733,10 +4857,9 @@ if {$cmdline_files ne {}} {
4857 set viewname(1) "Command line"
4858 set viewfiles(1) $cmdline_files
4859 set viewperm(1) 0
4736 - .bar.view add radiobutton -label $viewname(1) -command {showview 1} \
4737 - -variable selectedview -value 1
4860 + addviewmenu 1
4861 + .bar.view entryconf 1 -state normal
4862 .bar.view entryconf 2 -state normal
4739 - .bar.view entryconf 3 -state normal
4863 }
4864
4865 if {[info exists permviews]} {
@@ -4746,8 +4869,7 @@ if {[info exists permviews]} {
4869 set viewname($n) [lindex $v 0]
4870 set viewfiles($n) [lindex $v 1]
4871 set viewperm($n) 1
4749 - .bar.view add radiobutton -label $viewname($n) \
4750 - -command [list showview $n] -variable selectedview -value $n
4872 + addviewmenu $n
4873 }
4874 }
4875 getcommits