[PATCH] gitk: Make selection highlight color configurable
Cygwin's tk by default uses a very dark selection background color that makes the currently selected text almost unreadable. On linux, the default selection background is a light gray which is very usable. This makes the default a light gray everywhere but allows the user to configure the color as well. Signed-off-by: Mark Levedahl <mdl123@verizon.net> Signed-off-by: Paul Mackerras <paulus@samba.org>
Mark Levedahl committed
May 20, 2007 at 12:12 UTC
60378c0c0996522600dc31864dc60f5ca7d84529
1 file changed
+23
-3
gitk
+23
-3
@@ -402,7 +402,7 @@ proc makewindow {} {
402
global rowctxmenu mergemax wrapcomment
403
global highlight_files gdttype
404
global searchstring sstring
405
- global bgcolor fgcolor bglist fglist diffcolors
405
+ global bgcolor fgcolor bglist fglist diffcolors selectbgcolor
406
global headctxmenu
407
408
menu .bar
@@ -457,15 +457,18 @@ proc makewindow {} {
457
set cscroll .tf.histframe.csb
458
set canv .tf.histframe.pwclist.canv
459
canvas $canv \
460
+ -selectbackground $selectbgcolor \
461
-background $bgcolor -bd 0 \
462
-yscrollincr $linespc -yscrollcommand "scrollcanv $cscroll"
463
.tf.histframe.pwclist add $canv
464
set canv2 .tf.histframe.pwclist.canv2
465
canvas $canv2 \
466
+ -selectbackground $selectbgcolor \
467
-background $bgcolor -bd 0 -yscrollincr $linespc
468
.tf.histframe.pwclist add $canv2
469
set canv3 .tf.histframe.pwclist.canv3
470
canvas $canv3 \
471
+ -selectbackground $selectbgcolor \
472
-background $bgcolor -bd 0 -yscrollincr $linespc
473
.tf.histframe.pwclist add $canv3
474
eval .tf.histframe.pwclist sash place 0 $geometry(pwsash0)
@@ -666,6 +669,7 @@ proc makewindow {} {
669
set cflist .bright.cfiles
670
set indent [font measure $mainfont "nn"]
671
text $cflist \
672
+ -selectbackground $selectbgcolor \
673
-background $bgcolor -foreground $fgcolor \
674
-font $mainfont \
675
-tabs [list $indent [expr {2 * $indent}]] \
@@ -825,7 +829,7 @@ proc savestuff {w} {
829
global maxwidth showneartags
830
global viewname viewfiles viewargs viewperm nextviewnum
831
global cmitmode wrapcomment
828
- global colors bgcolor fgcolor diffcolors
832
+ global colors bgcolor fgcolor diffcolors selectbgcolor
833
834
if {$stuffsaved} return
835
if {![winfo viewable .]} return
@@ -844,6 +848,7 @@ proc savestuff {w} {
848
puts $f [list set fgcolor $fgcolor]
849
puts $f [list set colors $colors]
850
puts $f [list set diffcolors $diffcolors]
851
+ puts $f [list set selectbgcolor $selectbgcolor]
852
853
puts $f "set geometry(main) [wm geometry .]"
854
puts $f "set geometry(topwidth) [winfo width .tf]"
@@ -5845,7 +5850,7 @@ proc doquit {} {
5850
proc doprefs {} {
5851
global maxwidth maxgraphpct diffopts
5852
global oldprefs prefstop showneartags
5848
- global bgcolor fgcolor ctext diffcolors
5853
+ global bgcolor fgcolor ctext diffcolors selectbgcolor
5854
global uifont
5855
5856
set top .gitkprefs
@@ -5912,6 +5917,10 @@ proc doprefs {} {
5917
"diff hunk header" \
5918
[list $ctext tag conf hunksep -foreground]]
5919
grid x $top.hunksepbut $top.hunksep -sticky w
5920
+ label $top.selbgsep -padx 40 -relief sunk -background $selectbgcolor
5921
+ button $top.selbgbut -text "Select bg" -font optionfont \
5922
+ -command [list choosecolor selectbgcolor 0 $top.bg background setselbg]
5923
+ grid x $top.selbgbut $top.selbgsep -sticky w
5924
5925
frame $top.buts
5926
button $top.buts.ok -text "OK" -command prefsok -default active
@@ -5936,6 +5945,16 @@ proc choosecolor {v vi w x cmd} {
5945
eval $cmd $c
5946
}
5947
5948
+proc setselbg {c} {
5949
+ global bglist cflist
5950
+ foreach w $bglist {
5951
+ $w configure -selectbackground $c
5952
+ }
5953
+ $cflist tag configure highlight \
5954
+ -background [$cflist cget -selectbackground]
5955
+ allcanvs itemconf secsel -fill $c
5956
+}
5957
+
5958
proc setbg {c} {
5959
global bglist
5960
@@ -6292,6 +6311,7 @@ set colors {green red blue magenta darkgrey brown orange}
6311
set bgcolor white
6312
set fgcolor black
6313
set diffcolors {red "#00a000" blue}
6314
+set selectbgcolor gray85
6315
6316
catch {source ~/.gitk}
6317