Skip to content

Commit 113ce12

Browse files
stefandtwpaulusmack
authored andcommitted
gitk: add diff lines background colors
Not using colored background for added and removed lines is a missed opportunity to make diff lines easier to grasp visually. Use a subtle red/green background by default. Make the font slightly darker to improve contrast. Signed-off-by: Stefan Dotterweich <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent e272a77 commit 113ce12

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

gitk

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,7 +2072,7 @@ proc makewindow {} {
20722072
global rowctxmenu fakerowmenu mergemax wrapcomment
20732073
global highlight_files gdttype
20742074
global searchstring sstring
2075-
global bgcolor fgcolor bglist fglist diffcolors selectbgcolor
2075+
global bgcolor fgcolor bglist fglist diffcolors diffbgcolors selectbgcolor
20762076
global uifgcolor uifgdisabledcolor
20772077
global filesepbgcolor filesepfgcolor
20782078
global mergecolors foundbgcolor currentsearchhitbgcolor
@@ -2433,7 +2433,9 @@ proc makewindow {} {
24332433
$ctext tag conf filesep -font textfontbold -fore $filesepfgcolor -back $filesepbgcolor
24342434
$ctext tag conf hunksep -fore [lindex $diffcolors 2]
24352435
$ctext tag conf d0 -fore [lindex $diffcolors 0]
2436+
$ctext tag conf d0 -back [lindex $diffbgcolors 0]
24362437
$ctext tag conf dresult -fore [lindex $diffcolors 1]
2438+
$ctext tag conf dresult -back [lindex $diffbgcolors 1]
24372439
$ctext tag conf m0 -fore [lindex $mergecolors 0]
24382440
$ctext tag conf m1 -fore [lindex $mergecolors 1]
24392441
$ctext tag conf m2 -fore [lindex $mergecolors 2]
@@ -11606,6 +11608,7 @@ proc prefspage_general {notebook} {
1160611608

1160711609
proc prefspage_colors {notebook} {
1160811610
global NS uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
11611+
global diffbgcolors
1160911612

1161011613
set page [create_prefs_page $notebook.colors]
1161111614

@@ -11628,11 +11631,23 @@ proc prefspage_colors {notebook} {
1162811631
-command [list choosecolor diffcolors 0 $page.diffold [mc "diff old lines"] \
1162911632
[list $ctext tag conf d0 -foreground]]
1163011633
grid x $page.diffoldbut $page.diffold -sticky w
11634+
label $page.diffoldbg -padx 40 -relief sunk -background [lindex $diffbgcolors 0]
11635+
${NS}::button $page.diffoldbgbut -text [mc "Diff: old lines bg"] \
11636+
-command [list choosecolor diffbgcolors 0 $page.diffoldbg \
11637+
[mc "diff old lines bg"] \
11638+
[list $ctext tag conf d0 -background]]
11639+
grid x $page.diffoldbgbut $page.diffoldbg -sticky w
1163111640
label $page.diffnew -padx 40 -relief sunk -background [lindex $diffcolors 1]
1163211641
${NS}::button $page.diffnewbut -text [mc "Diff: new lines"] \
1163311642
-command [list choosecolor diffcolors 1 $page.diffnew [mc "diff new lines"] \
1163411643
[list $ctext tag conf dresult -foreground]]
1163511644
grid x $page.diffnewbut $page.diffnew -sticky w
11645+
label $page.diffnewbg -padx 40 -relief sunk -background [lindex $diffbgcolors 1]
11646+
${NS}::button $page.diffnewbgbut -text [mc "Diff: new lines bg"] \
11647+
-command [list choosecolor diffbgcolors 1 $page.diffnewbg \
11648+
[mc "diff new lines bg"] \
11649+
[list $ctext tag conf dresult -background]]
11650+
grid x $page.diffnewbgbut $page.diffnewbg -sticky w
1163611651
label $page.hunksep -padx 40 -relief sunk -background [lindex $diffcolors 2]
1163711652
${NS}::button $page.hunksepbut -text [mc "Diff: hunk header"] \
1163811653
-command [list choosecolor diffcolors 2 $page.hunksep \
@@ -12376,7 +12391,8 @@ if {[tk windowingsystem] eq "win32"} {
1237612391
set web_browser "xdg-open"
1237712392
}
1237812393
}
12379-
set diffcolors {red "#00a000" blue}
12394+
set diffcolors {"#c30000" "#009800" blue}
12395+
set diffbgcolors {"#fff3f3" "#f0fff0"}
1238012396
set diffcontext 3
1238112397
set mergecolors {red blue "#00ff00" purple brown "#009090" magenta "#808000" "#009000" "#ff0080" cyan "#b07070" "#70b0f0" "#70f0b0" "#f0b070" "#ff70b0"}
1238212398
set ignorespace 0
@@ -12447,7 +12463,7 @@ set config_variables {
1244712463
remotebgcolor tagbgcolor tagfgcolor tagoutlinecolor reflinecolor
1244812464
filesepbgcolor filesepfgcolor linehoverbgcolor linehoverfgcolor
1244912465
linehoveroutlinecolor mainheadcirclecolor workingfilescirclecolor
12450-
indexcirclecolor circlecolors linkfgcolor circleoutlinecolor
12466+
indexcirclecolor circlecolors linkfgcolor circleoutlinecolor diffbgcolors
1245112467
web_browser
1245212468
}
1245312469
foreach var $config_variables {

0 commit comments

Comments
 (0)