gitk: Move hard-coded colors to .gitk
The Preferences dialog gives control of the colors of some elements of the gitk user interface, but many are hard-coded in the gitk script. In order to allow these to be customized through the gitk config file, these other colors are stored in variables which can be set in the config file, thus providing a way for color schemes to be stored and shared. For win32, this makes the default foreground color that of window text rather than button text. Signed-off-by: Gauthier Östervall <gauthier@ostervall.se> [paulus@samba.org: Reworded commit message to be clearer, changed filesepfgcolor to black] Signed-off-by: Paul Mackerras <paulus@samba.org>
Gauthier Östervall committed
Mar 27, 2013 at 14:40 UTC
252c52df9d8d34692cb98a001491dd448e705901
1 file changed
+110
-39
gitk
+110
-39
@@ -2026,6 +2026,9 @@ proc makewindow {} {
2026
global highlight_files gdttype
2027
global searchstring sstring
2028
global bgcolor fgcolor bglist fglist diffcolors selectbgcolor
2029
+ global uifgcolor uifgdisabledcolor
2030
+ global filesepbgcolor filesepfgcolor
2031
+ global mergecolors foundbgcolor currentsearchhitbgcolor
2032
global headctxmenu progresscanv progressitem progresscoords statusw
2033
global fprogitem fprogcoord lastprogupdate progupdatepending
2034
global rprogitem rprogcoord rownumsel numcommits
@@ -2177,10 +2180,10 @@ proc makewindow {} {
2180
0x00, 0x38, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x00, 0x38, 0x00, 0x1c,
2181
0x00, 0x0e, 0x00, 0x07, 0x80, 0x03, 0xc0, 0x01};
2182
}
2180
- image create bitmap bm-left -data $bm_left_data
2181
- image create bitmap bm-left-gray -data $bm_left_data -foreground "#999"
2182
- image create bitmap bm-right -data $bm_right_data
2183
- image create bitmap bm-right-gray -data $bm_right_data -foreground "#999"
2183
+ image create bitmap bm-left -data $bm_left_data -foreground $uifgcolor
2184
+ image create bitmap bm-left-gray -data $bm_left_data -foreground $uifgdisabledcolor
2185
+ image create bitmap bm-right -data $bm_right_data -foreground $uifgcolor
2186
+ image create bitmap bm-right-gray -data $bm_right_data -foreground $uifgdisabledcolor
2187
2188
${NS}::button .tf.bar.leftbut -command goback -state disabled -width 26
2189
if {$use_ttk} {
@@ -2349,32 +2352,32 @@ proc makewindow {} {
2352
lappend fglist $ctext
2353
2354
$ctext tag conf comment -wrap $wrapcomment
2352
- $ctext tag conf filesep -font textfontbold -back "#aaaaaa"
2355
+ $ctext tag conf filesep -font textfontbold -fore $filesepfgcolor -back $filesepbgcolor
2356
$ctext tag conf hunksep -fore [lindex $diffcolors 2]
2357
$ctext tag conf d0 -fore [lindex $diffcolors 0]
2358
$ctext tag conf dresult -fore [lindex $diffcolors 1]
2356
- $ctext tag conf m0 -fore red
2357
- $ctext tag conf m1 -fore blue
2358
- $ctext tag conf m2 -fore green
2359
- $ctext tag conf m3 -fore purple
2360
- $ctext tag conf m4 -fore brown
2361
- $ctext tag conf m5 -fore "#009090"
2362
- $ctext tag conf m6 -fore magenta
2363
- $ctext tag conf m7 -fore "#808000"
2364
- $ctext tag conf m8 -fore "#009000"
2365
- $ctext tag conf m9 -fore "#ff0080"
2366
- $ctext tag conf m10 -fore cyan
2367
- $ctext tag conf m11 -fore "#b07070"
2368
- $ctext tag conf m12 -fore "#70b0f0"
2369
- $ctext tag conf m13 -fore "#70f0b0"
2370
- $ctext tag conf m14 -fore "#f0b070"
2371
- $ctext tag conf m15 -fore "#ff70b0"
2359
+ $ctext tag conf m0 -fore [lindex $mergecolors 0]
2360
+ $ctext tag conf m1 -fore [lindex $mergecolors 1]
2361
+ $ctext tag conf m2 -fore [lindex $mergecolors 2]
2362
+ $ctext tag conf m3 -fore [lindex $mergecolors 3]
2363
+ $ctext tag conf m4 -fore [lindex $mergecolors 4]
2364
+ $ctext tag conf m5 -fore [lindex $mergecolors 5]
2365
+ $ctext tag conf m6 -fore [lindex $mergecolors 6]
2366
+ $ctext tag conf m7 -fore [lindex $mergecolors 7]
2367
+ $ctext tag conf m8 -fore [lindex $mergecolors 8]
2368
+ $ctext tag conf m9 -fore [lindex $mergecolors 9]
2369
+ $ctext tag conf m10 -fore [lindex $mergecolors 10]
2370
+ $ctext tag conf m11 -fore [lindex $mergecolors 11]
2371
+ $ctext tag conf m12 -fore [lindex $mergecolors 12]
2372
+ $ctext tag conf m13 -fore [lindex $mergecolors 13]
2373
+ $ctext tag conf m14 -fore [lindex $mergecolors 14]
2374
+ $ctext tag conf m15 -fore [lindex $mergecolors 15]
2375
$ctext tag conf mmax -fore darkgrey
2376
set mergemax 16
2377
$ctext tag conf mresult -font textfontbold
2378
$ctext tag conf msep -font textfontbold
2376
- $ctext tag conf found -back yellow
2377
- $ctext tag conf currentsearchhit -back orange
2379
+ $ctext tag conf found -back $foundbgcolor
2380
+ $ctext tag conf currentsearchhit -back $currentsearchhitbgcolor
2381
$ctext tag conf wwrap -wrap word
2382
2383
.pwbottom add .bleft
@@ -2721,6 +2724,14 @@ proc savestuff {w} {
2724
global viewname viewfiles viewargs viewargscmd viewperm nextviewnum
2725
global cmitmode wrapcomment datetimeformat limitdiffs
2726
global colors uicolor bgcolor fgcolor diffcolors diffcontext selectbgcolor
2727
+ global uifgcolor uifgdisabledcolor
2728
+ global headbgcolor headfgcolor headoutlinecolor remotebgcolor
2729
+ global tagbgcolor tagfgcolor tagoutlinecolor
2730
+ global reflinecolor filesepbgcolor filesepfgcolor
2731
+ global mergecolors foundbgcolor currentsearchhitbgcolor
2732
+ global linehoverbgcolor linehoverfgcolor linehoveroutlinecolor circlecolors
2733
+ global mainheadcirclecolor workingfilescirclecolor indexcirclecolor
2734
+ global linkfgcolor circleoutlinecolor
2735
global autoselect autosellen extdifftool perfile_attrs markbgcolor use_ttk
2736
global hideremotes want_ttk maxrefs
2737
@@ -2753,13 +2764,37 @@ proc savestuff {w} {
2764
puts $f [list set want_ttk $want_ttk]
2765
puts $f [list set bgcolor $bgcolor]
2766
puts $f [list set fgcolor $fgcolor]
2767
+ puts $f [list set uifgcolor $uifgcolor]
2768
+ puts $f [list set uifgdisabledcolor $uifgdisabledcolor]
2769
puts $f [list set colors $colors]
2770
puts $f [list set diffcolors $diffcolors]
2771
+ puts $f [list set mergecolors $mergecolors]
2772
puts $f [list set markbgcolor $markbgcolor]
2773
puts $f [list set diffcontext $diffcontext]
2774
puts $f [list set selectbgcolor $selectbgcolor]
2775
+ puts $f [list set foundbgcolor $foundbgcolor]
2776
+ puts $f [list set currentsearchhitbgcolor $currentsearchhitbgcolor]
2777
puts $f [list set extdifftool $extdifftool]
2778
puts $f [list set perfile_attrs $perfile_attrs]
2779
+ puts $f [list set headbgcolor $headbgcolor]
2780
+ puts $f [list set headfgcolor $headfgcolor]
2781
+ puts $f [list set headoutlinecolor $headoutlinecolor]
2782
+ puts $f [list set remotebgcolor $remotebgcolor]
2783
+ puts $f [list set tagbgcolor $tagbgcolor]
2784
+ puts $f [list set tagfgcolor $tagfgcolor]
2785
+ puts $f [list set tagoutlinecolor $tagoutlinecolor]
2786
+ puts $f [list set reflinecolor $reflinecolor]
2787
+ puts $f [list set filesepbgcolor $filesepbgcolor]
2788
+ puts $f [list set filesepfgcolor $filesepfgcolor]
2789
+ puts $f [list set linehoverbgcolor $linehoverbgcolor]
2790
+ puts $f [list set linehoverfgcolor $linehoverfgcolor]
2791
+ puts $f [list set linehoveroutlinecolor $linehoveroutlinecolor]
2792
+ puts $f [list set mainheadcirclecolor $mainheadcirclecolor]
2793
+ puts $f [list set workingfilescirclecolor $workingfilescirclecolor]
2794
+ puts $f [list set indexcirclecolor $indexcirclecolor]
2795
+ puts $f [list set circlecolors $circlecolors]
2796
+ puts $f [list set linkfgcolor $linkfgcolor]
2797
+ puts $f [list set circleoutlinecolor $circleoutlinecolor]
2798
2799
puts $f "set geometry(main) [wm geometry .]"
2800
puts $f "set geometry(state) [wm state .]"
@@ -5925,15 +5960,17 @@ proc drawcmittext {id row col} {
5960
global linehtag linentag linedtag selectedline
5961
global canvxmax boldids boldnameids fgcolor markedid
5962
global mainheadid nullid nullid2 circleitem circlecolors ctxbut
5963
+ global mainheadcirclecolor workingfilescirclecolor indexcirclecolor
5964
+ global circleoutlinecolor
5965
5966
# listed is 0 for boundary, 1 for normal, 2 for negative, 3 for left, 4 for right
5967
set listed $cmitlisted($curview,$id)
5968
if {$id eq $nullid} {
5932
- set ofill red
5969
+ set ofill $workingfilescirclecolor
5970
} elseif {$id eq $nullid2} {
5934
- set ofill green
5971
+ set ofill $indexcirclecolor
5972
} elseif {$id eq $mainheadid} {
5936
- set ofill yellow
5973
+ set ofill $mainheadcirclecolor
5974
} else {
5975
set ofill [lindex $circlecolors $listed]
5976
}
@@ -5943,21 +5980,21 @@ proc drawcmittext {id row col} {
5980
if {$listed <= 2} {
5981
set t [$canv create oval [expr {$x - $orad}] [expr {$y - $orad}] \
5982
[expr {$x + $orad - 1}] [expr {$y + $orad - 1}] \
5946
- -fill $ofill -outline $fgcolor -width 1 -tags circle]
5983
+ -fill $ofill -outline $circleoutlinecolor -width 1 -tags circle]
5984
} elseif {$listed == 3} {
5985
# triangle pointing left for left-side commits
5986
set t [$canv create polygon \
5987
[expr {$x - $orad}] $y \
5988
[expr {$x + $orad - 1}] [expr {$y - $orad}] \
5989
[expr {$x + $orad - 1}] [expr {$y + $orad - 1}] \
5953
- -fill $ofill -outline $fgcolor -width 1 -tags circle]
5990
+ -fill $ofill -outline $circleoutlinecolor -width 1 -tags circle]
5991
} else {
5992
# triangle pointing right for right-side commits
5993
set t [$canv create polygon \
5994
[expr {$x + $orad - 1}] $y \
5995
[expr {$x - $orad}] [expr {$y - $orad}] \
5996
[expr {$x - $orad}] [expr {$y + $orad - 1}] \
5960
- -fill $ofill -outline $fgcolor -width 1 -tags circle]
5997
+ -fill $ofill -outline $circleoutlinecolor -width 1 -tags circle]
5998
}
5999
set circleitem($row) $t
6000
$canv raise $t
@@ -6345,6 +6382,9 @@ proc drawtags {id x xt y1} {
6382
global idtags idheads idotherrefs mainhead
6383
global linespc lthickness
6384
global canv rowtextx curview fgcolor bgcolor ctxbut
6385
+ global headbgcolor headfgcolor headoutlinecolor remotebgcolor
6386
+ global tagbgcolor tagfgcolor tagoutlinecolor
6387
+ global reflinecolor
6388
6389
set marks {}
6390
set ntags 0
@@ -6382,7 +6422,7 @@ proc drawtags {id x xt y1} {
6422
set xt [expr {$xt + $delta + $wid + $lthickness + $linespc}]
6423
}
6424
set t [$canv create line $x $y1 [lindex $xvals end] $y1 \
6385
- -width $lthickness -fill black -tags tag.$id]
6425
+ -width $lthickness -fill $reflinecolor -tags tag.$id]
6426
$canv lower $t
6427
foreach tag $marks x $xvals wid $wvals {
6428
set tag_quoted [string map {% %%} $tag]
@@ -6393,13 +6433,14 @@ proc drawtags {id x xt y1} {
6433
# draw a tag
6434
set t [$canv create polygon $x [expr {$yt + $delta}] $xl $yt \
6435
$xr $yt $xr $yb $xl $yb $x [expr {$yb - $delta}] \
6396
- -width 1 -outline black -fill yellow -tags tag.$id]
6436
+ -width 1 -outline $tagoutlinecolor -fill $tagbgcolor \
6437
+ -tags tag.$id]
6438
$canv bind $t <1> [list showtag $tag_quoted 1]
6439
set rowtextx([rowofcommit $id]) [expr {$xr + $linespc}]
6440
} else {
6441
# draw a head or other ref
6442
if {[incr nheads -1] >= 0} {
6402
- set col green
6443
+ set col $headbgcolor
6444
if {$tag eq $mainhead} {
6445
set font mainfontbold
6446
}
@@ -6415,10 +6456,10 @@ proc drawtags {id x xt y1} {
6456
set yti [expr {$yt + 1}]
6457
set xri [expr {$x + $rwid}]
6458
$canv create polygon $xi $yti $xri $yti $xri $yb $xi $yb \
6418
- -width 0 -fill "#ffddaa" -tags tag.$id
6459
+ -width 0 -fill $remotebgcolor -tags tag.$id
6460
}
6461
}
6421
- set t [$canv create text $xl $y1 -anchor w -text $tag -fill $fgcolor \
6462
+ set t [$canv create text $xl $y1 -anchor w -text $tag -fill $headfgcolor \
6463
-font $font -tags [list tag.$id text]]
6464
if {$ntags >= 0} {
6465
$canv bind $t <1> [list showtag $tag_quoted 1]
@@ -6799,6 +6840,7 @@ proc appendwithlinks {text tags} {
6840
6841
proc setlink {id lk} {
6842
global curview ctext pendinglinks
6843
+ global linkfgcolor
6844
6845
if {[string range $id 0 1] eq "-g"} {
6846
set id [string range $id 2 end]
@@ -6816,7 +6858,7 @@ proc setlink {id lk} {
6858
set known [commitinview $id $curview]
6859
}
6860
if {$known} {
6819
- $ctext tag conf $lk -foreground blue -underline 1
6861
+ $ctext tag conf $lk -foreground $linkfgcolor -underline 1
6862
$ctext tag bind $lk <1> [list selbyid $id]
6863
$ctext tag bind $lk <Enter> {linkcursor %W 1}
6864
$ctext tag bind $lk <Leave> {linkcursor %W -1}
@@ -8459,6 +8501,8 @@ proc lineleave {id} {
8501
proc linehover {} {
8502
global hoverx hovery hoverid hovertimer
8503
global canv linespc lthickness
8504
+ global linehoverbgcolor linehoverfgcolor linehoveroutlinecolor
8505
+
8506
global commitinfo
8507
8508
set text [lindex $commitinfo($hoverid) 0]
@@ -8472,10 +8516,11 @@ proc linehover {} {
8516
set x1 [expr {$x + [font measure mainfont $text] + 2 * $lthickness}]
8517
set y1 [expr {$y + $linespc + 2 * $lthickness}]
8518
set t [$canv create rectangle $x0 $y0 $x1 $y1 \
8475
- -fill \#ffff80 -outline black -width 1 -tags hover]
8519
+ -fill $linehoverbgcolor -outline $linehoveroutlinecolor \
8520
+ -width 1 -tags hover]
8521
$canv raise $t
8522
set t [$canv create text $x $y -anchor nw -text $text -tags hover \
8478
- -font mainfont]
8523
+ -font mainfont -fill $linehoverfgcolor]
8524
$canv raise $t
8525
}
8526
@@ -9039,12 +9084,13 @@ proc domktag {} {
9084
proc redrawtags {id} {
9085
global canv linehtag idpos currentid curview cmitlisted markedid
9086
global canvxmax iddrawn circleitem mainheadid circlecolors
9087
+ global mainheadcirclecolor
9088
9089
if {![commitinview $id $curview]} return
9090
if {![info exists iddrawn($id)]} return
9091
set row [rowofcommit $id]
9092
if {$id eq $mainheadid} {
9047
- set ofill yellow
9093
+ set ofill $mainheadcirclecolor
9094
} else {
9095
set ofill [lindex $circlecolors $cmitlisted($curview,$id)]
9096
}
@@ -11728,22 +11774,47 @@ if {[tk windowingsystem] eq "aqua"} {
11774
set colors {green red blue magenta darkgrey brown orange}
11775
if {[tk windowingsystem] eq "win32"} {
11776
set uicolor SystemButtonFace
11777
+ set uifgcolor SystemButtonText
11778
+ set uifgdisabledcolor SystemDisabledText
11779
set bgcolor SystemWindow
11732
- set fgcolor SystemButtonText
11780
+ set fgcolor SystemWindowText
11781
set selectbgcolor SystemHighlight
11782
} else {
11783
set uicolor grey85
11784
+ set uifgcolor black
11785
+ set uifgdisabledcolor "#999"
11786
set bgcolor white
11787
set fgcolor black
11788
set selectbgcolor gray85
11789
}
11790
set diffcolors {red "#00a000" blue}
11791
set diffcontext 3
11792
+set mergecolors {red blue green purple brown "#009090" magenta "#808000" "#009000" "#ff0080" cyan "#b07070" "#70b0f0" "#70f0b0" "#f0b070" "#ff70b0"}
11793
set ignorespace 0
11794
set worddiff ""
11795
set markbgcolor "#e0e0ff"
11796
11797
+set headbgcolor green
11798
+set headfgcolor black
11799
+set headoutlinecolor black
11800
+set remotebgcolor #ffddaa
11801
+set tagbgcolor yellow
11802
+set tagfgcolor black
11803
+set tagoutlinecolor black
11804
+set reflinecolor black
11805
+set filesepbgcolor #aaaaaa
11806
+set filesepfgcolor black
11807
+set linehoverbgcolor #ffff80
11808
+set linehoverfgcolor black
11809
+set linehoveroutlinecolor black
11810
+set mainheadcirclecolor yellow
11811
+set workingfilescirclecolor red
11812
+set indexcirclecolor green
11813
set circlecolors {white blue gray blue blue}
11814
+set linkfgcolor blue
11815
+set circleoutlinecolor $fgcolor
11816
+set foundbgcolor yellow
11817
+set currentsearchhitbgcolor orange
11818
11819
# button for popping up context menus
11820
if {[tk windowingsystem] eq "aqua"} {