@@ -312,7 +312,7 @@ proc getcommit {id} {
312
312
313
313
proc readrefs {} {
314
314
global tagids idtags headids idheads tagcontents
315
- global otherrefids idotherrefs
315
+ global otherrefids idotherrefs mainhead
316
316
317
317
foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
318
318
catch {unset $v }
@@ -358,6 +358,13 @@ proc readrefs {} {
358
358
}
359
359
}
360
360
close $refd
361
+ set mainhead {}
362
+ catch {
363
+ set thehead [exec git symbolic-ref HEAD]
364
+ if {[string match " refs/heads/*" $thehead ]} {
365
+ set mainhead [string range $thehead 11 end]
366
+ }
367
+ }
361
368
}
362
369
363
370
proc show_error {w top msg} {
@@ -386,6 +393,7 @@ proc makewindow {} {
386
393
global rowctxmenu mergemax wrapcomment
387
394
global highlight_files gdttype
388
395
global searchstring sstring
396
+ global bgcolor fgcolor bglist fglist diffcolors
389
397
390
398
menu .bar
391
399
.bar add cascade -label " File" -menu .bar.file
@@ -446,18 +454,19 @@ proc makewindow {} {
446
454
.ctop add .ctop.top
447
455
set canv .ctop.top.clist.canv
448
456
canvas $canv -height $geometry(canvh) -width $geometry(canv1) \
449
- -bg white -bd 0 \
457
+ -background $bgcolor -bd 0 \
450
458
-yscrollincr $linespc -yscrollcommand " scrollcanv $cscroll "
451
459
.ctop.top.clist add $canv
452
460
set canv2 .ctop.top.clist.canv2
453
461
canvas $canv2 -height $geometry(canvh) -width $geometry(canv2) \
454
- -bg white -bd 0 -yscrollincr $linespc
462
+ -background $bgcolor -bd 0 -yscrollincr $linespc
455
463
.ctop.top.clist add $canv2
456
464
set canv3 .ctop.top.clist.canv3
457
465
canvas $canv3 -height $geometry(canvh) -width $geometry(canv3) \
458
- -bg white -bd 0 -yscrollincr $linespc
466
+ -background $bgcolor -bd 0 -yscrollincr $linespc
459
467
.ctop.top.clist add $canv3
460
468
bind .ctop.top.clist <Configure> {resizeclistpanes %W %w}
469
+ lappend bglist $canv $canv2 $canv3
461
470
462
471
set sha1entry .ctop.top.bar.sha1
463
472
set entries $sha1entry
@@ -563,19 +572,22 @@ proc makewindow {} {
563
572
trace add variable searchstring write incrsearch
564
573
pack $sstring -side left -expand 1 -fill x
565
574
set ctext .ctop.cdet.left.ctext
566
- text $ctext -bg white -state disabled -font $textfont \
575
+ text $ctext -background $bgcolor -foreground $fgcolor \
576
+ -state disabled -font $textfont \
567
577
-width $geometry(ctextw) -height $geometry(ctexth) \
568
578
-yscrollcommand scrolltext -wrap none
569
579
scrollbar .ctop.cdet.left.sb -command " $ctext yview"
570
580
pack .ctop.cdet.left.sb -side right -fill y
571
581
pack $ctext -side left -fill both -expand 1
572
582
.ctop.cdet add .ctop.cdet.left
583
+ lappend bglist $ctext
584
+ lappend fglist $ctext
573
585
574
586
$ctext tag conf comment -wrap $wrapcomment
575
587
$ctext tag conf filesep -font [concat $textfont bold] -back " #aaaaaa"
576
- $ctext tag conf hunksep -fore blue
577
- $ctext tag conf d0 -fore red
578
- $ctext tag conf d1 -fore " #00a000 "
588
+ $ctext tag conf hunksep -fore [ lindex $diffcolors 2]
589
+ $ctext tag conf d0 -fore [ lindex $diffcolors 0]
590
+ $ctext tag conf d1 -fore [ lindex $diffcolors 1]
579
591
$ctext tag conf m0 -fore red
580
592
$ctext tag conf m1 -fore blue
581
593
$ctext tag conf m2 -fore green
@@ -608,11 +620,15 @@ proc makewindow {} {
608
620
pack .ctop.cdet.right.mode -side top -fill x
609
621
set cflist .ctop.cdet.right.cfiles
610
622
set indent [font measure $mainfont " nn" ]
611
- text $cflist -width $geometry(cflistw) -background white -font $mainfont \
623
+ text $cflist -width $geometry(cflistw) \
624
+ -background $bgcolor -foreground $fgcolor \
625
+ -font $mainfont \
612
626
-tabs [list $indent [expr {2 * $indent }]] \
613
627
-yscrollcommand " .ctop.cdet.right.sb set" \
614
628
-cursor [. cget -cursor] \
615
629
-spacing1 1 -spacing3 1
630
+ lappend bglist $cflist
631
+ lappend fglist $cflist
616
632
scrollbar .ctop.cdet.right.sb -command " $cflist yview"
617
633
pack .ctop.cdet.right.sb -side right -fill y
618
634
pack $cflist -side left -fill both -expand 1
@@ -747,6 +763,7 @@ proc savestuff {w} {
747
763
global maxwidth showneartags
748
764
global viewname viewfiles viewargs viewperm nextviewnum
749
765
global cmitmode wrapcomment
766
+ global colors bgcolor fgcolor diffcolors
750
767
751
768
if {$stuffsaved } return
752
769
if {![winfo viewable .]} return
@@ -761,6 +778,10 @@ proc savestuff {w} {
761
778
puts $f [list set cmitmode $cmitmode ]
762
779
puts $f [list set wrapcomment $wrapcomment ]
763
780
puts $f [list set showneartags $showneartags ]
781
+ puts $f [list set bgcolor $bgcolor ]
782
+ puts $f [list set fgcolor $fgcolor ]
783
+ puts $f [list set colors $colors ]
784
+ puts $f [list set diffcolors $diffcolors ]
764
785
puts $f " set geometry(width) [ winfo width .ctop] "
765
786
puts $f " set geometry(height) [ winfo height .ctop] "
766
787
puts $f " set geometry(canv1) [ expr {[winfo width $canv ] -2}]"
@@ -2870,19 +2891,19 @@ proc drawlines {id} {
2870
2891
}
2871
2892
2872
2893
proc drawcmittext {id row col rmx} {
2873
- global linespc canv canv2 canv3 canvy0
2894
+ global linespc canv canv2 canv3 canvy0 fgcolor
2874
2895
global commitlisted commitinfo rowidlist
2875
2896
global rowtextx idpos idtags idheads idotherrefs
2876
2897
global linehtag linentag linedtag
2877
- global mainfont canvxmax boldrows boldnamerows
2898
+ global mainfont canvxmax boldrows boldnamerows fgcolor
2878
2899
2879
2900
set ofill [expr {[lindex $commitlisted $row ]? " blue" : " white" }]
2880
2901
set x [xc $row $col ]
2881
2902
set y [yc $row ]
2882
2903
set orad [expr {$linespc / 3}]
2883
2904
set t [$canv create oval [expr {$x - $orad }] [expr {$y - $orad }] \
2884
2905
[expr {$x + $orad - 1}] [expr {$y + $orad - 1}] \
2885
- -fill $ofill -outline black -width 1]
2906
+ -fill $ofill -outline $fgcolor -width 1 -tags circle ]
2886
2907
$canv raise $t
2887
2908
$canv bind $t <1> {selcanvline {} %x %y}
2888
2909
set xt [xc $row [llength [lindex $rowidlist $row ]]]
@@ -2910,13 +2931,13 @@ proc drawcmittext {id row col rmx} {
2910
2931
lappend nfont bold
2911
2932
}
2912
2933
}
2913
- set linehtag($row ) [$canv create text $xt $y -anchor w \
2914
- -text $headline -font $font ]
2934
+ set linehtag($row ) [$canv create text $xt $y -anchor w -fill $fgcolor \
2935
+ -text $headline -font $font -tags text ]
2915
2936
$canv bind $linehtag($row) <Button-3> " rowmenu %X %Y $id "
2916
- set linentag($row ) [$canv2 create text 3 $y -anchor w \
2917
- -text $name -font $nfont ]
2918
- set linedtag($row ) [$canv3 create text 3 $y -anchor w \
2919
- -text $date -font $mainfont ]
2937
+ set linentag($row ) [$canv2 create text 3 $y -anchor w -fill $fgcolor \
2938
+ -text $name -font $nfont -tags text ]
2939
+ set linedtag($row ) [$canv3 create text 3 $y -anchor w -fill $fgcolor \
2940
+ -text $date -font $mainfont -tags text ]
2920
2941
set xr [expr {$xt + [font measure $mainfont $headline ]}]
2921
2942
if {$xr > $canvxmax } {
2922
2943
set canvxmax $xr
@@ -3136,9 +3157,9 @@ proc bindline {t id} {
3136
3157
}
3137
3158
3138
3159
proc drawtags {id x xt y1} {
3139
- global idtags idheads idotherrefs
3160
+ global idtags idheads idotherrefs mainhead
3140
3161
global linespc lthickness
3141
- global canv mainfont commitrow rowtextx curview
3162
+ global canv mainfont commitrow rowtextx curview fgcolor bgcolor
3142
3163
3143
3164
set marks {}
3144
3165
set ntags 0
@@ -3163,8 +3184,14 @@ proc drawtags {id x xt y1} {
3163
3184
set yb [expr {$yt + $linespc - 1}]
3164
3185
set xvals {}
3165
3186
set wvals {}
3187
+ set i -1
3166
3188
foreach tag $marks {
3167
- set wid [font measure $mainfont $tag ]
3189
+ incr i
3190
+ if {$i >= $ntags && $i < $ntags + $nheads && $tag eq $mainhead } {
3191
+ set wid [font measure [concat $mainfont bold] $tag ]
3192
+ } else {
3193
+ set wid [font measure $mainfont $tag ]
3194
+ }
3168
3195
lappend xvals $xt
3169
3196
lappend wvals $wid
3170
3197
set xt [expr {$xt + $delta + $wid + $lthickness + $linespc }]
@@ -3175,6 +3202,7 @@ proc drawtags {id x xt y1} {
3175
3202
foreach tag $marks x $xvals wid $wvals {
3176
3203
set xl [expr {$x + $delta }]
3177
3204
set xr [expr {$x + $delta + $wid + $lthickness }]
3205
+ set font $mainfont
3178
3206
if {[incr ntags -1] >= 0} {
3179
3207
# draw a tag
3180
3208
set t [$canv create polygon $x [expr {$yt + $delta }] $xl $yt \
@@ -3186,6 +3214,9 @@ proc drawtags {id x xt y1} {
3186
3214
# draw a head or other ref
3187
3215
if {[incr nheads -1] >= 0} {
3188
3216
set col green
3217
+ if {$tag eq $mainhead } {
3218
+ lappend font bold
3219
+ }
3189
3220
} else {
3190
3221
set col " #ddddff"
3191
3222
}
@@ -3201,8 +3232,8 @@ proc drawtags {id x xt y1} {
3201
3232
-width 0 -fill " #ffddaa" -tags tag.$id
3202
3233
}
3203
3234
}
3204
- set t [$canv create text $xl $y1 -anchor w -text $tag \
3205
- -font $mainfont -tags tag.$id ]
3235
+ set t [$canv create text $xl $y1 -anchor w -text $tag -fill $fgcolor \
3236
+ -font $font -tags [ list tag.$id text] ]
3206
3237
if {$ntags >= 0} {
3207
3238
$canv bind $t <1> [list showtag $tag 1]
3208
3239
}
@@ -3223,10 +3254,11 @@ proc xcoord {i level ln} {
3223
3254
}
3224
3255
3225
3256
proc show_status {msg} {
3226
- global canv mainfont
3257
+ global canv mainfont fgcolor
3227
3258
3228
3259
clear_display
3229
- $canv create text 3 3 -anchor nw -text $msg -font $mainfont -tags textitems
3260
+ $canv create text 3 3 -anchor nw -text $msg -font $mainfont \
3261
+ -tags text -fill $fgcolor
3230
3262
}
3231
3263
3232
3264
proc finishcommits {} {
@@ -4574,7 +4606,8 @@ proc linehover {} {
4574
4606
set t [$canv create rectangle $x0 $y0 $x1 $y1 \
4575
4607
-fill \# ffff80 -outline black -width 1 -tags hover]
4576
4608
$canv raise $t
4577
- set t [$canv create text $x $y -anchor nw -text $text -tags hover -font $mainfont ]
4609
+ set t [$canv create text $x $y -anchor nw -text $text -tags hover \
4610
+ -font $mainfont ]
4578
4611
$canv raise $t
4579
4612
}
4580
4613
@@ -5242,6 +5275,7 @@ proc doquit {} {
5242
5275
proc doprefs {} {
5243
5276
global maxwidth maxgraphpct diffopts
5244
5277
global oldprefs prefstop showneartags
5278
+ global bgcolor fgcolor ctext diffcolors
5245
5279
5246
5280
set top .gitkprefs
5247
5281
set prefstop $top
@@ -5265,6 +5299,7 @@ proc doprefs {} {
5265
5299
-font optionfont
5266
5300
spinbox $top .maxpct -from 1 -to 100 -width 4 -textvariable maxgraphpct
5267
5301
grid x $top .maxpctl $top .maxpct -sticky w
5302
+
5268
5303
label $top .ddisp -text " Diff display options"
5269
5304
grid $top .ddisp - -sticky w -pady 10
5270
5305
label $top .diffoptl -text " Options for diff program" \
@@ -5276,6 +5311,34 @@ proc doprefs {} {
5276
5311
checkbutton $top .ntag.b -variable showneartags
5277
5312
pack $top .ntag.b $top .ntag.l -side left
5278
5313
grid x $top .ntag -sticky w
5314
+
5315
+ label $top .cdisp -text " Colors: press to choose"
5316
+ grid $top .cdisp - -sticky w -pady 10
5317
+ label $top .bg -padx 40 -relief sunk -background $bgcolor
5318
+ button $top .bgbut -text " Background" -font optionfont \
5319
+ -command [list choosecolor bgcolor 0 $top .bg background setbg]
5320
+ grid x $top .bgbut $top .bg -sticky w
5321
+ label $top .fg -padx 40 -relief sunk -background $fgcolor
5322
+ button $top .fgbut -text " Foreground" -font optionfont \
5323
+ -command [list choosecolor fgcolor 0 $top .fg foreground setfg]
5324
+ grid x $top .fgbut $top .fg -sticky w
5325
+ label $top .diffold -padx 40 -relief sunk -background [lindex $diffcolors 0]
5326
+ button $top .diffoldbut -text " Diff: old lines" -font optionfont \
5327
+ -command [list choosecolor diffcolors 0 $top .diffold " diff old lines" \
5328
+ [list $ctext tag conf d0 -foreground]]
5329
+ grid x $top .diffoldbut $top .diffold -sticky w
5330
+ label $top .diffnew -padx 40 -relief sunk -background [lindex $diffcolors 1]
5331
+ button $top .diffnewbut -text " Diff: new lines" -font optionfont \
5332
+ -command [list choosecolor diffcolors 1 $top .diffnew " diff new lines" \
5333
+ [list $ctext tag conf d1 -foreground]]
5334
+ grid x $top .diffnewbut $top .diffnew -sticky w
5335
+ label $top .hunksep -padx 40 -relief sunk -background [lindex $diffcolors 2]
5336
+ button $top .hunksepbut -text " Diff: hunk header" -font optionfont \
5337
+ -command [list choosecolor diffcolors 2 $top .hunksep \
5338
+ " diff hunk header" \
5339
+ [list $ctext tag conf hunksep -foreground]]
5340
+ grid x $top .hunksepbut $top .hunksep -sticky w
5341
+
5279
5342
frame $top .buts
5280
5343
button $top .buts.ok -text " OK" -command prefsok
5281
5344
button $top .buts.can -text " Cancel" -command prefscan
@@ -5285,6 +5348,35 @@ proc doprefs {} {
5285
5348
grid $top .buts - - -pady 10 -sticky ew
5286
5349
}
5287
5350
5351
+ proc choosecolor {v vi w x cmd} {
5352
+ global $v
5353
+
5354
+ set c [tk_chooseColor -initialcolor [lindex [set $v ] $vi ] \
5355
+ -title " Gitk: choose color for $x " ]
5356
+ if {$c eq {}} return
5357
+ $w conf -background $c
5358
+ lset $v $vi $c
5359
+ eval $cmd $c
5360
+ }
5361
+
5362
+ proc setbg {c} {
5363
+ global bglist
5364
+
5365
+ foreach w $bglist {
5366
+ $w conf -background $c
5367
+ }
5368
+ }
5369
+
5370
+ proc setfg {c} {
5371
+ global fglist canv
5372
+
5373
+ foreach w $fglist {
5374
+ $w conf -foreground $c
5375
+ }
5376
+ allcanvs itemconf text -fill $c
5377
+ $canv itemconf circle -outline $c
5378
+ }
5379
+
5288
5380
proc prefscan {} {
5289
5381
global maxwidth maxgraphpct diffopts
5290
5382
global oldprefs prefstop showneartags
@@ -5620,6 +5712,9 @@ set wrapcomment "none"
5620
5712
set showneartags 1
5621
5713
5622
5714
set colors {green red blue magenta darkgrey brown orange}
5715
+ set bgcolor white
5716
+ set fgcolor black
5717
+ set diffcolors {red " #00a000" blue}
5623
5718
5624
5719
catch {source ~/.gitk}
5625
5720
0 commit comments