public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: "Shannon Barber via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Sixt <j6t@kdbg.org>, Shannon Barber <sgbarber@gmail.com>,
	Shannon Barber <sbarber@dataspeedinc.com>
Subject: [PATCH] gitk: use config settings for head/tag colors
Date: Tue, 13 Jan 2026 06:28:41 +0000	[thread overview]
Message-ID: <pull.2030.git.1768285721660.gitgitgadget@gmail.com> (raw)

From: Shannon Barber <sbarber@dataspeedinc.com>

The drawtags procedure currently uses headfgcolor for all label text,
 ignoring the tagfgcolor setting.

The call to create the outline polygon for (non-tag) heads currently
 has the color for headoutlinecolor hardcoded to black.

This patch maintains the variables for the non-tag refs so that heads
 are colored differently from non-head (non-tag) refs.

The outline and fill colors for the non-head refs remain hardcoded to
 the prior values, black & #ddddff.

Signed-off-by: Shannon Barber <sgbarber@gmail.com>
---
    gitk: use headoutlinecolor, headbgcolor, and tagfgcolor config settings
    to change the color of the tags and head outlines and fill
    
    This patch makes the config settings, headoutlinecolor and tagfgcolor,
    work. These are existing config settings but not used in the code.
    
    (I noticed that tagfgcolor was not working while making an extension for
    vscode that exports its color theme to gitk.) (Upon review of the code I
    found that headoutlinecolor was also not used and investigated and fixed
    it.)
    
    This simple patch has them affect the target UI elements while drawing
    refs and their outlined boxes. Tags are drawn in their own code branch
    then heads and non-heads are drawn in another one. Because both head and
    non-head refs are drawn in the same loop the colors used to draw (and
    fill) toggle between the head colors and (still hard-coded) non-head ref
    colors.
    
    Image showing it working, reviewing the patch that made it work.
    gitk-colors
    [https://github.com/user-attachments/assets/0eea207d-0891-41c8-8c6d-1464a96a1c76]

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2030%2FMagmaiKH%2Fsbarber%2Fuse_color_config_variables-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2030/MagmaiKH/sbarber/use_color_config_variables-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2030

 gitk-git/gitk | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 7f62c8041d..0415abd873 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -6831,16 +6831,18 @@ proc drawtags {id x xt y1} {
         } else {
             # draw a head or other ref
             if {[incr nheads -1] >= 0} {
-                set col $headbgcolor
+                set refoutlinecol $headoutlinecolor
+                set reffillcol $headbgcolor
                 if {$tag eq $mainhead} {
                     set font mainfontbold
                 }
             } else {
-                set col "#ddddff"
+                set refoutlinecol black
+                set reffillcol "#ddddff"
             }
             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 $refoutlinecol -fill $reffillcol -tags tag.$id
             if {[regexp {^(remotes/.*/|remotes/)} $tag match remoteprefix]} {
                 set rwid [font measure mainfont $remoteprefix]
                 set xi [expr {$x + 1}]
@@ -6850,7 +6852,8 @@ proc drawtags {id x xt y1} {
                         -width 0 -fill $remotebgcolor -tags tag.$id
             }
         }
-        set t [$canv create text $xl $y1 -anchor w -text $tag -fill $headfgcolor \
+        set textfgcolor [expr {$ntags >= 0 ? $tagfgcolor : $headfgcolor}]
+        set t [$canv create text $xl $y1 -anchor w -text $tag -fill $textfgcolor \
                    -font $font -tags [list tag.$id text]]
         if {$ntags >= 0} {
             $canv bind $t <1> $tagclick

base-commit: d529f3a197364881746f558e5652f0236131eb86
-- 
gitgitgadget

             reply	other threads:[~2026-01-13  6:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-13  6:28 Shannon Barber via GitGitGadget [this message]
2026-01-14 18:11 ` [PATCH] gitk: use config settings for head/tag colors Johannes Sixt
     [not found]   ` <SJ1SPRMB0003BF77E3500DF7C96E3042D18CA@SJ1SPRMB0003.namprd20.prod.outlook.com>
2026-01-20 16:02     ` Johannes Sixt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.2030.git.1768285721660.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=sbarber@dataspeedinc.com \
    --cc=sgbarber@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox