* [PATCH] gitk: improve dark background support
@ 2010-11-04 0:35 David Fries
2010-11-08 13:14 ` Matthijs Kooijman
0 siblings, 1 reply; 3+ messages in thread
From: David Fries @ 2010-11-04 0:35 UTC (permalink / raw
To: git
Replace most uses of black with $fgcolor as items such as a black
outline on the tag or tag lines with a black background doesn't show
up. Use $fgcolor instead to make it contrast with the background.
Use diffcolor 2 for link as blue on a black background might as well
look like dark blue on black and is very difficult to read. The
"Diff: hunk header" keeps the colors more consistent and both default
to blue.
If the foreground color is dark use light tags, branches, and
remote fill colors. If it is light use darker versions so the
text is readable.
Signed-off-by: David Fries <David@Fries.net>
---
gitk-git/gitk | 40 ++++++++++++++++++++++++++++++++--------
1 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 1b0e09a..ca9244f 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -6233,6 +6233,7 @@ proc drawtags {id x xt y1} {
global idtags idheads idotherrefs mainhead
global linespc lthickness
global canv rowtextx curview fgcolor bgcolor ctxbut
+ global tagcolor branchcolor remotecolor
set marks {}
set ntags 0
@@ -6270,7 +6271,7 @@ proc drawtags {id x xt y1} {
set xt [expr {$xt + $delta + $wid + $lthickness + $linespc}]
}
set t [$canv create line $x $y1 [lindex $xvals end] $y1 \
- -width $lthickness -fill black -tags tag.$id]
+ -width $lthickness -fill $fgcolor -tags tag.$id]
$canv lower $t
foreach tag $marks x $xvals wid $wvals {
set xl [expr {$x + $delta}]
@@ -6280,13 +6281,13 @@ proc drawtags {id x xt y1} {
# draw a tag
set t [$canv create polygon $x [expr {$yt + $delta}] $xl $yt \
$xr $yt $xr $yb $xl $yb $x [expr {$yb - $delta}] \
- -width 1 -outline black -fill yellow -tags tag.$id]
+ -width 1 -outline $fgcolor -fill $tagcolor -tags tag.$id]
$canv bind $t <1> [list showtag $tag 1]
set rowtextx([rowofcommit $id]) [expr {$xr + $linespc}]
} 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
}
@@ -6295,14 +6296,14 @@ proc drawtags {id x xt y1} {
}
set xl [expr {$xl - $delta/2}]
$canv create polygon $x $yt $xr $yt $xr $yb $x $yb \
- -width 1 -outline black -fill $col -tags tag.$id
+ -width 1 -outline $fgcolor -fill $col -tags tag.$id
if {[regexp {^(remotes/.*/|remotes/)} $tag match remoteprefix]} {
set rwid [font measure mainfont $remoteprefix]
set xi [expr {$x + 1}]
set yti [expr {$yt + 1}]
set xri [expr {$x + $rwid}]
$canv create polygon $xi $yti $xri $yti $xri $yb $xi $yb \
- -width 0 -fill "#ffddaa" -tags tag.$id
+ -width 0 -fill $remotecolor -tags tag.$id
}
}
set t [$canv create text $xl $y1 -anchor w -text $tag -fill $fgcolor \
@@ -6673,7 +6674,7 @@ proc appendwithlinks {text tags} {
}
proc setlink {id lk} {
- global curview ctext pendinglinks
+ global curview ctext pendinglinks diffcolors
set known 0
if {[string length $id] < 40} {
@@ -6687,7 +6688,7 @@ proc setlink {id lk} {
set known [commitinview $id $curview]
}
if {$known} {
- $ctext tag conf $lk -foreground blue -underline 1
+ $ctext tag conf $lk -foreground [lindex $diffcolors 2] -underline 1
$ctext tag bind $lk <1> [list selbyid $id]
$ctext tag bind $lk <Enter> {linkcursor %W 1}
$ctext tag bind $lk <Leave> {linkcursor %W -1}
@@ -8215,6 +8216,7 @@ proc linehover {} {
global hoverx hovery hoverid hovertimer
global canv linespc lthickness
global commitinfo
+ global fgcolor
set text [lindex $commitinfo($hoverid) 0]
set ymax [lindex [$canv cget -scrollregion] 3]
@@ -8227,7 +8229,7 @@ proc linehover {} {
set x1 [expr {$x + [font measure mainfont $text] + 2 * $lthickness}]
set y1 [expr {$y + $linespc + 2 * $lthickness}]
set t [$canv create rectangle $x0 $y0 $x1 $y1 \
- -fill \#ffff80 -outline black -width 1 -tags hover]
+ -fill \#ffff80 -outline $fgcolor -width 1 -tags hover]
$canv raise $t
set t [$canv create text $x $y -anchor nw -text $text -tags hover \
-font mainfont]
@@ -10877,6 +10879,23 @@ proc setbg {c} {
}
}
+proc setfill {c} {
+ global tagcolor branchcolor remotecolor
+
+ set fg [winfo rgb . $c]
+ if {[lindex $fg 0] + 1.5 * [lindex $fg 1] + 0.5 * [lindex $fg 2] > 100000} {
+ # dark fill to read a light foreground font
+ set tagcolor yellow4
+ set branchcolor green4
+ set remotecolor "#806F55"
+ } else {
+ # light fill to read a dark foreground font
+ set tagcolor yellow
+ set branchcolor green
+ set remotecolor "#ffddaa"
+ }
+}
+
proc setfg {c} {
global fglist canv
@@ -10886,6 +10905,8 @@ proc setfg {c} {
allcanvs itemconf text -fill $c
$canv itemconf circle -outline $c
$canv itemconf markid -outline $c
+
+ setfill $c
}
proc prefscan {} {
@@ -11381,11 +11402,13 @@ if {[tk windowingsystem] eq "win32"} {
set uicolor SystemButtonFace
set bgcolor SystemWindow
set fgcolor SystemButtonText
+ setfill $fgcolor
set selectbgcolor SystemHighlight
} else {
set uicolor grey85
set bgcolor white
set fgcolor black
+ setfill $fgcolor
set selectbgcolor gray85
}
set diffcolors {red "#00a000" blue}
@@ -11422,6 +11445,7 @@ namespace import ::msgcat::mc
::msgcat::mcload $gitk_msgsdir
catch {source ~/.gitk}
+setfill $fgcolor
parsefont mainfont $mainfont
eval font create mainfont [fontflags mainfont]
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] gitk: improve dark background support
2010-11-04 0:35 [PATCH] gitk: improve dark background support David Fries
@ 2010-11-08 13:14 ` Matthijs Kooijman
2010-11-11 4:59 ` David Fries
0 siblings, 1 reply; 3+ messages in thread
From: Matthijs Kooijman @ 2010-11-08 13:14 UTC (permalink / raw
To: David Fries; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 1076 bytes --]
Hi David,
I've been using gitk with a gray-on-black color-scheme for a while now,
so I've given your patch a test drive. It seems to work as expected and
indeed makes gitk a bit more pleasant to use with a dark color scheme.
I've reviewed the code a bit and it looks ok as well (though I'm hardly
familiar with git internals, and not at all in this area).
I did encounter one minor issue, though: If you change the foreground
color, the current view is not updated until you restart or switch views
(or otherwise trigger a redraw, I guess). A quick look at the code shows
that the "setfg" function contains some code that updates all canvases
and all contexts in $fglist with the new fg color. I guess that
something similar should be done for these tag colors to get them
updated right away (though perhaps that should be a second patch)?
A final note: There are still some other problems with working with
grey-on-black color scheme. In case your interested in working on those,
I've listed them at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=568470
Gr.
Matthijs
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gitk: improve dark background support
2010-11-08 13:14 ` Matthijs Kooijman
@ 2010-11-11 4:59 ` David Fries
0 siblings, 0 replies; 3+ messages in thread
From: David Fries @ 2010-11-11 4:59 UTC (permalink / raw
To: git; +Cc: Matthijs Kooijman
On Mon, Nov 08, 2010 at 02:14:12PM +0100, Matthijs Kooijman wrote:
> Hi David,
>
> I've been using gitk with a gray-on-black color-scheme for a while now,
> so I've given your patch a test drive. It seems to work as expected and
> indeed makes gitk a bit more pleasant to use with a dark color scheme.
>
> I've reviewed the code a bit and it looks ok as well (though I'm hardly
> familiar with git internals, and not at all in this area).
>
> I did encounter one minor issue, though: If you change the foreground
> color, the current view is not updated until you restart or switch views
> (or otherwise trigger a redraw, I guess). A quick look at the code shows
> that the "setfg" function contains some code that updates all canvases
> and all contexts in $fglist with the new fg color. I guess that
> something similar should be done for these tag colors to get them
> updated right away (though perhaps that should be a second patch)?
After much work and document searching I now know more about tk/tcl
than ever before and have figured out how to make the colors
dynamically update when the preferences change. Have a look if you
will, and if it looks good I'll post it to the maintainer for
inclusion. I'm also posting a new patch series to the list.
branch gitk_colors
git://gitorious.org/~dfries/git/dfriess-git-mainline.git
and the more disorganized work in progress branch is gitk_colors_PreSquash
> A final note: There are still some other problems with working with
> grey-on-black color scheme. In case your interested in working on those,
> I've listed them at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=568470
Anything left in that list worth going over? In terms of the .gitk
config colors what are you using and what isn't working?
my relevant .gitk config file settings,
set mainfont {Helvetica 8}
set textfont {Courier 8}
set uifont {Helvetica 9 bold}
set uicolor grey85
set bgcolor black
set fgcolor white
set colors {green red blue magenta darkgrey brown orange}
set diffcolors {red green cyan}
set markbgcolor #404060
set selectbgcolor gray50
--
David Fries <david@fries.net>
http://fries.net/~david/ (PGP encryption key available)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-11-11 4:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-04 0:35 [PATCH] gitk: improve dark background support David Fries
2010-11-08 13:14 ` Matthijs Kooijman
2010-11-11 4:59 ` David Fries
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).