gitk: Add user-configurable branch bg color
PATCH 1/1 gitk: Add user-configurable branch bg color
In some cases, the default branch background color (green) isn't an optimal choice, thus it can be difficult to read.
This provides a way for the user to customize the color used to fill the rectangle around the branch name, by choosing another one from the "Preferences" dialog.
The default behavior of using "green" as the default color is maintained.
--- gitk | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
gitk +16 -4
@@ -2720,7 +2720,7 @@ proc savestuff {w} { global maxwidth showneartags showlocalchanges global viewname viewfiles viewargs viewargscmd viewperm nextviewnum global cmitmode wrapcomment datetimeformat limitdiffs - global colors uicolor bgcolor fgcolor diffcolors diffcontext selectbgcolor + global colors uicolor bgcolor fgcolor diffcolors diffcontext selectbgcolor branchcolor global autoselect autosellen extdifftool perfile_attrs markbgcolor use_ttk global hideremotes want_ttk maxrefs
@@ -2760,6 +2760,7 @@ proc savestuff {w} { puts $f [list set selectbgcolor $selectbgcolor] puts $f [list set extdifftool $extdifftool] puts $f [list set perfile_attrs $perfile_attrs] + puts $f [list set branchcolor $branchcolor] puts $f "set geometry(main) [wm geometry .]" puts $f "set geometry(state) [wm state .]"
@@ -6344,7 +6345,7 @@ proc bindline {t id} { proc drawtags {id x xt y1} { global idtags idheads idotherrefs mainhead global linespc lthickness - global canv rowtextx curview fgcolor bgcolor ctxbut + global canv rowtextx curview fgcolor bgcolor ctxbut branchcolor set marks {} set ntags 0
@@ -6399,7 +6400,7 @@ proc drawtags {id x xt y1} { } else { # draw a head or other ref if {[incr nheads -1] >= 0} { - set col green + set col $branchcolor if {$tag eq $mainhead} { set font mainfontbold }
@@ -11033,7 +11034,7 @@ proc prefspage_general {notebook} { } proc prefspage_colors {notebook} { - global NS uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor + global NS uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor branchcolor set page [create_prefs_page $notebook.colors]
@@ -11077,6 +11078,12 @@ proc prefspage_colors {notebook} { ${NS}::button $page.selbgbut -text [mc "Select bg"] \ -command [list choosecolor selectbgcolor {} $page.selbgsep [mc "background"] setselbg] grid x $page.selbgbut $page.selbgsep -sticky w + label $page.selbranchcolsep -padx 40 -relief sunk -background $branchcolor + ${NS}::button $page.selbranchcolbut -text [mc "Select branch bg"] \ + -command [list choosecolor branchcolor {} $page.selbranchcolsep \ + [mc "branch background"] \ + setbranchcolor] + grid x $page.selbranchcolbut $page.selbranchcolsep -sticky w return $page }
@@ -11221,6 +11228,10 @@ proc setfg {c} { $canv itemconf markid -outline $c } +proc setbranchcolor {c} { + reloadcommits +} + proc prefscan {} { global oldprefs prefstop
@@ -11742,6 +11753,7 @@ set diffcontext 3 set ignorespace 0 set worddiff "" set markbgcolor "#e0e0ff" +set branchcolor green set circlecolors {white blue gray blue blue}
Signature · 1 line
1.8.2
A message that is not in the archive (sent off-list or not yet received): CAJDDKr5XqX3dKLEiOAo7VeaofN37Q8aAN=GyMVf5-bGiiv9FDw@mail.gmail.com
Quoted 8 lines · David Aguilar
Quoted 3 lines
In some cases, the default branch background color (green) isn't an optimal choice, thus it can be difficult to read.
I'm just curious -- is it "difficult to read" because gitk does not specify a foreground color, thus causing it to pickup a system default (which can vary), or is it for a different reason?
If this is the reason then I wonder whether gitk should explicitly set a foreground color. Apologies if it already works that way -- I just wanted to better understand the motivation behind this patch.
Yes, having gitk to specify a foreground color instead would probably solve it too: i can remember the branch rectangles were a lot more readable in the past, but this could probably be due to me using a dark system theme at the time.
For example, in my case it would look a lot more readable if the text was "white on green" instead of "black on green", that could be even hardcoded as it was with the "green" color, but the reason behind the choice to let the user customize it is that i think it is better to honour the user system colors giving the means to adjust it to match his actual system configuration, rather than overriding it.
Regards,
Manuel