Skip to content

Commit 60378c0

Browse files
mark987paulusmack
authored andcommitted
[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 <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 696cf49 commit 60378c0

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

gitk

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ proc makewindow {} {
402402
global rowctxmenu mergemax wrapcomment
403403
global highlight_files gdttype
404404
global searchstring sstring
405-
global bgcolor fgcolor bglist fglist diffcolors
405+
global bgcolor fgcolor bglist fglist diffcolors selectbgcolor
406406
global headctxmenu
407407

408408
menu .bar
@@ -457,15 +457,18 @@ proc makewindow {} {
457457
set cscroll .tf.histframe.csb
458458
set canv .tf.histframe.pwclist.canv
459459
canvas $canv \
460+
-selectbackground $selectbgcolor \
460461
-background $bgcolor -bd 0 \
461462
-yscrollincr $linespc -yscrollcommand "scrollcanv $cscroll"
462463
.tf.histframe.pwclist add $canv
463464
set canv2 .tf.histframe.pwclist.canv2
464465
canvas $canv2 \
466+
-selectbackground $selectbgcolor \
465467
-background $bgcolor -bd 0 -yscrollincr $linespc
466468
.tf.histframe.pwclist add $canv2
467469
set canv3 .tf.histframe.pwclist.canv3
468470
canvas $canv3 \
471+
-selectbackground $selectbgcolor \
469472
-background $bgcolor -bd 0 -yscrollincr $linespc
470473
.tf.histframe.pwclist add $canv3
471474
eval .tf.histframe.pwclist sash place 0 $geometry(pwsash0)
@@ -666,6 +669,7 @@ proc makewindow {} {
666669
set cflist .bright.cfiles
667670
set indent [font measure $mainfont "nn"]
668671
text $cflist \
672+
-selectbackground $selectbgcolor \
669673
-background $bgcolor -foreground $fgcolor \
670674
-font $mainfont \
671675
-tabs [list $indent [expr {2 * $indent}]] \
@@ -825,7 +829,7 @@ proc savestuff {w} {
825829
global maxwidth showneartags
826830
global viewname viewfiles viewargs viewperm nextviewnum
827831
global cmitmode wrapcomment
828-
global colors bgcolor fgcolor diffcolors
832+
global colors bgcolor fgcolor diffcolors selectbgcolor
829833

830834
if {$stuffsaved} return
831835
if {![winfo viewable .]} return
@@ -844,6 +848,7 @@ proc savestuff {w} {
844848
puts $f [list set fgcolor $fgcolor]
845849
puts $f [list set colors $colors]
846850
puts $f [list set diffcolors $diffcolors]
851+
puts $f [list set selectbgcolor $selectbgcolor]
847852

848853
puts $f "set geometry(main) [wm geometry .]"
849854
puts $f "set geometry(topwidth) [winfo width .tf]"
@@ -5845,7 +5850,7 @@ proc doquit {} {
58455850
proc doprefs {} {
58465851
global maxwidth maxgraphpct diffopts
58475852
global oldprefs prefstop showneartags
5848-
global bgcolor fgcolor ctext diffcolors
5853+
global bgcolor fgcolor ctext diffcolors selectbgcolor
58495854
global uifont
58505855

58515856
set top .gitkprefs
@@ -5912,6 +5917,10 @@ proc doprefs {} {
59125917
"diff hunk header" \
59135918
[list $ctext tag conf hunksep -foreground]]
59145919
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
59155924

59165925
frame $top.buts
59175926
button $top.buts.ok -text "OK" -command prefsok -default active
@@ -5936,6 +5945,16 @@ proc choosecolor {v vi w x cmd} {
59365945
eval $cmd $c
59375946
}
59385947

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+
59395958
proc setbg {c} {
59405959
global bglist
59415960

@@ -6292,6 +6311,7 @@ set colors {green red blue magenta darkgrey brown orange}
62926311
set bgcolor white
62936312
set fgcolor black
62946313
set diffcolors {red "#00a000" blue}
6314+
set selectbgcolor gray85
62956315

62966316
catch {source ~/.gitk}
62976317

0 commit comments

Comments
 (0)