Skip to content

Commit 252c52d

Browse files
fleutotpaulusmack
authored andcommitted
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 <[email protected]> [[email protected]: Reworded commit message to be clearer, changed filesepfgcolor to black] Signed-off-by: Paul Mackerras <[email protected]>
1 parent a8b38d9 commit 252c52d

File tree

1 file changed

+110
-39
lines changed

1 file changed

+110
-39
lines changed

gitk

Lines changed: 110 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,6 +2026,9 @@ proc makewindow {} {
20262026
global highlight_files gdttype
20272027
global searchstring sstring
20282028
global bgcolor fgcolor bglist fglist diffcolors selectbgcolor
2029+
global uifgcolor uifgdisabledcolor
2030+
global filesepbgcolor filesepfgcolor
2031+
global mergecolors foundbgcolor currentsearchhitbgcolor
20292032
global headctxmenu progresscanv progressitem progresscoords statusw
20302033
global fprogitem fprogcoord lastprogupdate progupdatepending
20312034
global rprogitem rprogcoord rownumsel numcommits
@@ -2177,10 +2180,10 @@ proc makewindow {} {
21772180
0x00, 0x38, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x00, 0x38, 0x00, 0x1c,
21782181
0x00, 0x0e, 0x00, 0x07, 0x80, 0x03, 0xc0, 0x01};
21792182
}
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
21842187

21852188
${NS}::button .tf.bar.leftbut -command goback -state disabled -width 26
21862189
if {$use_ttk} {
@@ -2349,32 +2352,32 @@ proc makewindow {} {
23492352
lappend fglist $ctext
23502353

23512354
$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
23532356
$ctext tag conf hunksep -fore [lindex $diffcolors 2]
23542357
$ctext tag conf d0 -fore [lindex $diffcolors 0]
23552358
$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]
23722375
$ctext tag conf mmax -fore darkgrey
23732376
set mergemax 16
23742377
$ctext tag conf mresult -font textfontbold
23752378
$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
23782381
$ctext tag conf wwrap -wrap word
23792382

23802383
.pwbottom add .bleft
@@ -2721,6 +2724,14 @@ proc savestuff {w} {
27212724
global viewname viewfiles viewargs viewargscmd viewperm nextviewnum
27222725
global cmitmode wrapcomment datetimeformat limitdiffs
27232726
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
27242735
global autoselect autosellen extdifftool perfile_attrs markbgcolor use_ttk
27252736
global hideremotes want_ttk maxrefs
27262737

@@ -2753,13 +2764,37 @@ proc savestuff {w} {
27532764
puts $f [list set want_ttk $want_ttk]
27542765
puts $f [list set bgcolor $bgcolor]
27552766
puts $f [list set fgcolor $fgcolor]
2767+
puts $f [list set uifgcolor $uifgcolor]
2768+
puts $f [list set uifgdisabledcolor $uifgdisabledcolor]
27562769
puts $f [list set colors $colors]
27572770
puts $f [list set diffcolors $diffcolors]
2771+
puts $f [list set mergecolors $mergecolors]
27582772
puts $f [list set markbgcolor $markbgcolor]
27592773
puts $f [list set diffcontext $diffcontext]
27602774
puts $f [list set selectbgcolor $selectbgcolor]
2775+
puts $f [list set foundbgcolor $foundbgcolor]
2776+
puts $f [list set currentsearchhitbgcolor $currentsearchhitbgcolor]
27612777
puts $f [list set extdifftool $extdifftool]
27622778
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]
27632798

27642799
puts $f "set geometry(main) [wm geometry .]"
27652800
puts $f "set geometry(state) [wm state .]"
@@ -5925,15 +5960,17 @@ proc drawcmittext {id row col} {
59255960
global linehtag linentag linedtag selectedline
59265961
global canvxmax boldids boldnameids fgcolor markedid
59275962
global mainheadid nullid nullid2 circleitem circlecolors ctxbut
5963+
global mainheadcirclecolor workingfilescirclecolor indexcirclecolor
5964+
global circleoutlinecolor
59285965

59295966
# listed is 0 for boundary, 1 for normal, 2 for negative, 3 for left, 4 for right
59305967
set listed $cmitlisted($curview,$id)
59315968
if {$id eq $nullid} {
5932-
set ofill red
5969+
set ofill $workingfilescirclecolor
59335970
} elseif {$id eq $nullid2} {
5934-
set ofill green
5971+
set ofill $indexcirclecolor
59355972
} elseif {$id eq $mainheadid} {
5936-
set ofill yellow
5973+
set ofill $mainheadcirclecolor
59375974
} else {
59385975
set ofill [lindex $circlecolors $listed]
59395976
}
@@ -5943,21 +5980,21 @@ proc drawcmittext {id row col} {
59435980
if {$listed <= 2} {
59445981
set t [$canv create oval [expr {$x - $orad}] [expr {$y - $orad}] \
59455982
[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]
59475984
} elseif {$listed == 3} {
59485985
# triangle pointing left for left-side commits
59495986
set t [$canv create polygon \
59505987
[expr {$x - $orad}] $y \
59515988
[expr {$x + $orad - 1}] [expr {$y - $orad}] \
59525989
[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]
59545991
} else {
59555992
# triangle pointing right for right-side commits
59565993
set t [$canv create polygon \
59575994
[expr {$x + $orad - 1}] $y \
59585995
[expr {$x - $orad}] [expr {$y - $orad}] \
59595996
[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]
59615998
}
59625999
set circleitem($row) $t
59636000
$canv raise $t
@@ -6345,6 +6382,9 @@ proc drawtags {id x xt y1} {
63456382
global idtags idheads idotherrefs mainhead
63466383
global linespc lthickness
63476384
global canv rowtextx curview fgcolor bgcolor ctxbut
6385+
global headbgcolor headfgcolor headoutlinecolor remotebgcolor
6386+
global tagbgcolor tagfgcolor tagoutlinecolor
6387+
global reflinecolor
63486388

63496389
set marks {}
63506390
set ntags 0
@@ -6382,7 +6422,7 @@ proc drawtags {id x xt y1} {
63826422
set xt [expr {$xt + $delta + $wid + $lthickness + $linespc}]
63836423
}
63846424
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]
63866426
$canv lower $t
63876427
foreach tag $marks x $xvals wid $wvals {
63886428
set tag_quoted [string map {% %%} $tag]
@@ -6393,13 +6433,14 @@ proc drawtags {id x xt y1} {
63936433
# draw a tag
63946434
set t [$canv create polygon $x [expr {$yt + $delta}] $xl $yt \
63956435
$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]
63976438
$canv bind $t <1> [list showtag $tag_quoted 1]
63986439
set rowtextx([rowofcommit $id]) [expr {$xr + $linespc}]
63996440
} else {
64006441
# draw a head or other ref
64016442
if {[incr nheads -1] >= 0} {
6402-
set col green
6443+
set col $headbgcolor
64036444
if {$tag eq $mainhead} {
64046445
set font mainfontbold
64056446
}
@@ -6415,10 +6456,10 @@ proc drawtags {id x xt y1} {
64156456
set yti [expr {$yt + 1}]
64166457
set xri [expr {$x + $rwid}]
64176458
$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
64196460
}
64206461
}
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 \
64226463
-font $font -tags [list tag.$id text]]
64236464
if {$ntags >= 0} {
64246465
$canv bind $t <1> [list showtag $tag_quoted 1]
@@ -6799,6 +6840,7 @@ proc appendwithlinks {text tags} {
67996840

68006841
proc setlink {id lk} {
68016842
global curview ctext pendinglinks
6843+
global linkfgcolor
68026844

68036845
if {[string range $id 0 1] eq "-g"} {
68046846
set id [string range $id 2 end]
@@ -6816,7 +6858,7 @@ proc setlink {id lk} {
68166858
set known [commitinview $id $curview]
68176859
}
68186860
if {$known} {
6819-
$ctext tag conf $lk -foreground blue -underline 1
6861+
$ctext tag conf $lk -foreground $linkfgcolor -underline 1
68206862
$ctext tag bind $lk <1> [list selbyid $id]
68216863
$ctext tag bind $lk <Enter> {linkcursor %W 1}
68226864
$ctext tag bind $lk <Leave> {linkcursor %W -1}
@@ -8459,6 +8501,8 @@ proc lineleave {id} {
84598501
proc linehover {} {
84608502
global hoverx hovery hoverid hovertimer
84618503
global canv linespc lthickness
8504+
global linehoverbgcolor linehoverfgcolor linehoveroutlinecolor
8505+
84628506
global commitinfo
84638507

84648508
set text [lindex $commitinfo($hoverid) 0]
@@ -8472,10 +8516,11 @@ proc linehover {} {
84728516
set x1 [expr {$x + [font measure mainfont $text] + 2 * $lthickness}]
84738517
set y1 [expr {$y + $linespc + 2 * $lthickness}]
84748518
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]
84768521
$canv raise $t
84778522
set t [$canv create text $x $y -anchor nw -text $text -tags hover \
8478-
-font mainfont]
8523+
-font mainfont -fill $linehoverfgcolor]
84798524
$canv raise $t
84808525
}
84818526

@@ -9039,12 +9084,13 @@ proc domktag {} {
90399084
proc redrawtags {id} {
90409085
global canv linehtag idpos currentid curview cmitlisted markedid
90419086
global canvxmax iddrawn circleitem mainheadid circlecolors
9087+
global mainheadcirclecolor
90429088

90439089
if {![commitinview $id $curview]} return
90449090
if {![info exists iddrawn($id)]} return
90459091
set row [rowofcommit $id]
90469092
if {$id eq $mainheadid} {
9047-
set ofill yellow
9093+
set ofill $mainheadcirclecolor
90489094
} else {
90499095
set ofill [lindex $circlecolors $cmitlisted($curview,$id)]
90509096
}
@@ -11728,22 +11774,47 @@ if {[tk windowingsystem] eq "aqua"} {
1172811774
set colors {green red blue magenta darkgrey brown orange}
1172911775
if {[tk windowingsystem] eq "win32"} {
1173011776
set uicolor SystemButtonFace
11777+
set uifgcolor SystemButtonText
11778+
set uifgdisabledcolor SystemDisabledText
1173111779
set bgcolor SystemWindow
11732-
set fgcolor SystemButtonText
11780+
set fgcolor SystemWindowText
1173311781
set selectbgcolor SystemHighlight
1173411782
} else {
1173511783
set uicolor grey85
11784+
set uifgcolor black
11785+
set uifgdisabledcolor "#999"
1173611786
set bgcolor white
1173711787
set fgcolor black
1173811788
set selectbgcolor gray85
1173911789
}
1174011790
set diffcolors {red "#00a000" blue}
1174111791
set diffcontext 3
11792+
set mergecolors {red blue green purple brown "#009090" magenta "#808000" "#009000" "#ff0080" cyan "#b07070" "#70b0f0" "#70f0b0" "#f0b070" "#ff70b0"}
1174211793
set ignorespace 0
1174311794
set worddiff ""
1174411795
set markbgcolor "#e0e0ff"
1174511796

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
1174611813
set circlecolors {white blue gray blue blue}
11814+
set linkfgcolor blue
11815+
set circleoutlinecolor $fgcolor
11816+
set foundbgcolor yellow
11817+
set currentsearchhitbgcolor orange
1174711818

1174811819
# button for popping up context menus
1174911820
if {[tk windowingsystem] eq "aqua"} {

0 commit comments

Comments
 (0)