@@ -386,6 +386,7 @@ proc makewindow {} {
386
386
global rowctxmenu mergemax wrapcomment
387
387
global highlight_files gdttype
388
388
global searchstring sstring
389
+ global bgcolor fgcolor bglist fglist diffcolors
389
390
390
391
menu .bar
391
392
.bar add cascade -label " File" -menu .bar.file
@@ -446,18 +447,19 @@ proc makewindow {} {
446
447
.ctop add .ctop.top
447
448
set canv .ctop.top.clist.canv
448
449
canvas $canv -height $geometry(canvh) -width $geometry(canv1) \
449
- -bg white -bd 0 \
450
+ -background $bgcolor -bd 0 \
450
451
-yscrollincr $linespc -yscrollcommand " scrollcanv $cscroll "
451
452
.ctop.top.clist add $canv
452
453
set canv2 .ctop.top.clist.canv2
453
454
canvas $canv2 -height $geometry(canvh) -width $geometry(canv2) \
454
- -bg white -bd 0 -yscrollincr $linespc
455
+ -background $bgcolor -bd 0 -yscrollincr $linespc
455
456
.ctop.top.clist add $canv2
456
457
set canv3 .ctop.top.clist.canv3
457
458
canvas $canv3 -height $geometry(canvh) -width $geometry(canv3) \
458
- -bg white -bd 0 -yscrollincr $linespc
459
+ -background $bgcolor -bd 0 -yscrollincr $linespc
459
460
.ctop.top.clist add $canv3
460
461
bind .ctop.top.clist <Configure> {resizeclistpanes %W %w}
462
+ lappend bglist $canv $canv2 $canv3
461
463
462
464
set sha1entry .ctop.top.bar.sha1
463
465
set entries $sha1entry
@@ -563,19 +565,22 @@ proc makewindow {} {
563
565
trace add variable searchstring write incrsearch
564
566
pack $sstring -side left -expand 1 -fill x
565
567
set ctext .ctop.cdet.left.ctext
566
- text $ctext -bg white -state disabled -font $textfont \
568
+ text $ctext -background $bgcolor -foreground $fgcolor \
569
+ -state disabled -font $textfont \
567
570
-width $geometry(ctextw) -height $geometry(ctexth) \
568
571
-yscrollcommand scrolltext -wrap none
569
572
scrollbar .ctop.cdet.left.sb -command " $ctext yview"
570
573
pack .ctop.cdet.left.sb -side right -fill y
571
574
pack $ctext -side left -fill both -expand 1
572
575
.ctop.cdet add .ctop.cdet.left
576
+ lappend bglist $ctext
577
+ lappend fglist $ctext
573
578
574
579
$ctext tag conf comment -wrap $wrapcomment
575
580
$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 "
581
+ $ctext tag conf hunksep -fore [ lindex $diffcolors 2]
582
+ $ctext tag conf d0 -fore [ lindex $diffcolors 0]
583
+ $ctext tag conf d1 -fore [ lindex $diffcolors 1]
579
584
$ctext tag conf m0 -fore red
580
585
$ctext tag conf m1 -fore blue
581
586
$ctext tag conf m2 -fore green
@@ -608,11 +613,15 @@ proc makewindow {} {
608
613
pack .ctop.cdet.right.mode -side top -fill x
609
614
set cflist .ctop.cdet.right.cfiles
610
615
set indent [font measure $mainfont " nn" ]
611
- text $cflist -width $geometry(cflistw) -background white -font $mainfont \
616
+ text $cflist -width $geometry(cflistw) \
617
+ -background $bgcolor -foreground $fgcolor \
618
+ -font $mainfont \
612
619
-tabs [list $indent [expr {2 * $indent }]] \
613
620
-yscrollcommand " .ctop.cdet.right.sb set" \
614
621
-cursor [. cget -cursor] \
615
622
-spacing1 1 -spacing3 1
623
+ lappend bglist $cflist
624
+ lappend fglist $cflist
616
625
scrollbar .ctop.cdet.right.sb -command " $cflist yview"
617
626
pack .ctop.cdet.right.sb -side right -fill y
618
627
pack $cflist -side left -fill both -expand 1
@@ -747,6 +756,7 @@ proc savestuff {w} {
747
756
global maxwidth showneartags
748
757
global viewname viewfiles viewargs viewperm nextviewnum
749
758
global cmitmode wrapcomment
759
+ global colors bgcolor fgcolor diffcolors
750
760
751
761
if {$stuffsaved } return
752
762
if {![winfo viewable .]} return
@@ -761,6 +771,10 @@ proc savestuff {w} {
761
771
puts $f [list set cmitmode $cmitmode ]
762
772
puts $f [list set wrapcomment $wrapcomment ]
763
773
puts $f [list set showneartags $showneartags ]
774
+ puts $f [list set bgcolor $bgcolor ]
775
+ puts $f [list set fgcolor $fgcolor ]
776
+ puts $f [list set colors $colors ]
777
+ puts $f [list set diffcolors $diffcolors ]
764
778
puts $f " set geometry(width) [ winfo width .ctop] "
765
779
puts $f " set geometry(height) [ winfo height .ctop] "
766
780
puts $f " set geometry(canv1) [ expr {[winfo width $canv ] -2}]"
@@ -2870,19 +2884,19 @@ proc drawlines {id} {
2870
2884
}
2871
2885
2872
2886
proc drawcmittext {id row col rmx} {
2873
- global linespc canv canv2 canv3 canvy0
2887
+ global linespc canv canv2 canv3 canvy0 fgcolor
2874
2888
global commitlisted commitinfo rowidlist
2875
2889
global rowtextx idpos idtags idheads idotherrefs
2876
2890
global linehtag linentag linedtag
2877
- global mainfont canvxmax boldrows boldnamerows
2891
+ global mainfont canvxmax boldrows boldnamerows fgcolor
2878
2892
2879
2893
set ofill [expr {[lindex $commitlisted $row ]? " blue" : " white" }]
2880
2894
set x [xc $row $col ]
2881
2895
set y [yc $row ]
2882
2896
set orad [expr {$linespc / 3}]
2883
2897
set t [$canv create oval [expr {$x - $orad }] [expr {$y - $orad }] \
2884
2898
[expr {$x + $orad - 1}] [expr {$y + $orad - 1}] \
2885
- -fill $ofill -outline black -width 1]
2899
+ -fill $ofill -outline $fgcolor -width 1 -tags circle ]
2886
2900
$canv raise $t
2887
2901
$canv bind $t <1> {selcanvline {} %x %y}
2888
2902
set xt [xc $row [llength [lindex $rowidlist $row ]]]
@@ -2910,13 +2924,13 @@ proc drawcmittext {id row col rmx} {
2910
2924
lappend nfont bold
2911
2925
}
2912
2926
}
2913
- set linehtag($row ) [$canv create text $xt $y -anchor w \
2914
- -text $headline -font $font ]
2927
+ set linehtag($row ) [$canv create text $xt $y -anchor w -fill $fgcolor \
2928
+ -text $headline -font $font -tags text ]
2915
2929
$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 ]
2930
+ set linentag($row ) [$canv2 create text 3 $y -anchor w -fill $fgcolor \
2931
+ -text $name -font $nfont -tags text ]
2932
+ set linedtag($row ) [$canv3 create text 3 $y -anchor w -fill $fgcolor \
2933
+ -text $date -font $mainfont -tags text ]
2920
2934
set xr [expr {$xt + [font measure $mainfont $headline ]}]
2921
2935
if {$xr > $canvxmax } {
2922
2936
set canvxmax $xr
@@ -3138,7 +3152,7 @@ proc bindline {t id} {
3138
3152
proc drawtags {id x xt y1} {
3139
3153
global idtags idheads idotherrefs
3140
3154
global linespc lthickness
3141
- global canv mainfont commitrow rowtextx curview
3155
+ global canv mainfont commitrow rowtextx curview fgcolor
3142
3156
3143
3157
set marks {}
3144
3158
set ntags 0
@@ -3201,8 +3215,8 @@ proc drawtags {id x xt y1} {
3201
3215
-width 0 -fill " #ffddaa" -tags tag.$id
3202
3216
}
3203
3217
}
3204
- set t [$canv create text $xl $y1 -anchor w -text $tag \
3205
- -font $mainfont -tags tag.$id ]
3218
+ set t [$canv create text $xl $y1 -anchor w -text $tag -fill $fgcolor \
3219
+ -font $mainfont -tags [ list tag.$id text] ]
3206
3220
if {$ntags >= 0} {
3207
3221
$canv bind $t <1> [list showtag $tag 1]
3208
3222
}
@@ -3223,10 +3237,11 @@ proc xcoord {i level ln} {
3223
3237
}
3224
3238
3225
3239
proc show_status {msg} {
3226
- global canv mainfont
3240
+ global canv mainfont fgcolor
3227
3241
3228
3242
clear_display
3229
- $canv create text 3 3 -anchor nw -text $msg -font $mainfont -tags textitems
3243
+ $canv create text 3 3 -anchor nw -text $msg -font $mainfont \
3244
+ -tags text -fill $fgcolor
3230
3245
}
3231
3246
3232
3247
proc finishcommits {} {
@@ -4574,7 +4589,8 @@ proc linehover {} {
4574
4589
set t [$canv create rectangle $x0 $y0 $x1 $y1 \
4575
4590
-fill \# ffff80 -outline black -width 1 -tags hover]
4576
4591
$canv raise $t
4577
- set t [$canv create text $x $y -anchor nw -text $text -tags hover -font $mainfont ]
4592
+ set t [$canv create text $x $y -anchor nw -text $text -tags hover \
4593
+ -font $mainfont ]
4578
4594
$canv raise $t
4579
4595
}
4580
4596
@@ -5242,6 +5258,7 @@ proc doquit {} {
5242
5258
proc doprefs {} {
5243
5259
global maxwidth maxgraphpct diffopts
5244
5260
global oldprefs prefstop showneartags
5261
+ global bgcolor fgcolor ctext diffcolors
5245
5262
5246
5263
set top .gitkprefs
5247
5264
set prefstop $top
@@ -5265,6 +5282,7 @@ proc doprefs {} {
5265
5282
-font optionfont
5266
5283
spinbox $top .maxpct -from 1 -to 100 -width 4 -textvariable maxgraphpct
5267
5284
grid x $top .maxpctl $top .maxpct -sticky w
5285
+
5268
5286
label $top .ddisp -text " Diff display options"
5269
5287
grid $top .ddisp - -sticky w -pady 10
5270
5288
label $top .diffoptl -text " Options for diff program" \
@@ -5276,6 +5294,34 @@ proc doprefs {} {
5276
5294
checkbutton $top .ntag.b -variable showneartags
5277
5295
pack $top .ntag.b $top .ntag.l -side left
5278
5296
grid x $top .ntag -sticky w
5297
+
5298
+ label $top .cdisp -text " Colors: press to choose"
5299
+ grid $top .cdisp - -sticky w -pady 10
5300
+ label $top .bg -padx 40 -relief sunk -background $bgcolor
5301
+ button $top .bgbut -text " Background" -font optionfont \
5302
+ -command [list choosecolor bgcolor 0 $top .bg background setbg]
5303
+ grid x $top .bgbut $top .bg -sticky w
5304
+ label $top .fg -padx 40 -relief sunk -background $fgcolor
5305
+ button $top .fgbut -text " Foreground" -font optionfont \
5306
+ -command [list choosecolor fgcolor 0 $top .fg foreground setfg]
5307
+ grid x $top .fgbut $top .fg -sticky w
5308
+ label $top .diffold -padx 40 -relief sunk -background [lindex $diffcolors 0]
5309
+ button $top .diffoldbut -text " Diff: old lines" -font optionfont \
5310
+ -command [list choosecolor diffcolors 0 $top .diffold " diff old lines" \
5311
+ [list $ctext tag conf d0 -foreground]]
5312
+ grid x $top .diffoldbut $top .diffold -sticky w
5313
+ label $top .diffnew -padx 40 -relief sunk -background [lindex $diffcolors 1]
5314
+ button $top .diffnewbut -text " Diff: new lines" -font optionfont \
5315
+ -command [list choosecolor diffcolors 1 $top .diffnew " diff new lines" \
5316
+ [list $ctext tag conf d1 -foreground]]
5317
+ grid x $top .diffnewbut $top .diffnew -sticky w
5318
+ label $top .hunksep -padx 40 -relief sunk -background [lindex $diffcolors 2]
5319
+ button $top .hunksepbut -text " Diff: hunk header" -font optionfont \
5320
+ -command [list choosecolor diffcolors 2 $top .hunksep \
5321
+ " diff hunk header" \
5322
+ [list $ctext tag conf hunksep -foreground]]
5323
+ grid x $top .hunksepbut $top .hunksep -sticky w
5324
+
5279
5325
frame $top .buts
5280
5326
button $top .buts.ok -text " OK" -command prefsok
5281
5327
button $top .buts.can -text " Cancel" -command prefscan
@@ -5285,6 +5331,35 @@ proc doprefs {} {
5285
5331
grid $top .buts - - -pady 10 -sticky ew
5286
5332
}
5287
5333
5334
+ proc choosecolor {v vi w x cmd} {
5335
+ global $v
5336
+
5337
+ set c [tk_chooseColor -initialcolor [lindex [set $v ] $vi ] \
5338
+ -title " Gitk: choose color for $x " ]
5339
+ if {$c eq {}} return
5340
+ $w conf -background $c
5341
+ lset $v $vi $c
5342
+ eval $cmd $c
5343
+ }
5344
+
5345
+ proc setbg {c} {
5346
+ global bglist
5347
+
5348
+ foreach w $bglist {
5349
+ $w conf -background $c
5350
+ }
5351
+ }
5352
+
5353
+ proc setfg {c} {
5354
+ global fglist canv
5355
+
5356
+ foreach w $fglist {
5357
+ $w conf -foreground $c
5358
+ }
5359
+ allcanvs itemconf text -fill $c
5360
+ $canv itemconf circle -outline $c
5361
+ }
5362
+
5288
5363
proc prefscan {} {
5289
5364
global maxwidth maxgraphpct diffopts
5290
5365
global oldprefs prefstop showneartags
@@ -5620,6 +5695,9 @@ set wrapcomment "none"
5620
5695
set showneartags 1
5621
5696
5622
5697
set colors {green red blue magenta darkgrey brown orange}
5698
+ set bgcolor white
5699
+ set fgcolor black
5700
+ set diffcolors {red " #00a000" blue}
5623
5701
5624
5702
catch {source ~/.gitk}
5625
5703
0 commit comments