git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 05/13] gitk: fill in `wvals` as the tags are first processed

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Dec 19, 2016, 16:45 UTC
Message-ID
<d7b6999f7e3ba271c6932925cd26ea2884df3014.1482164633.git.mhagger@alum.mit.edu>
In-Reply-To
<cover.1482164633.git.mhagger@alum.mit.edu>

It's no longer, and a little bit more direct, to fill in `wvals` at the same time as we determine the tag's type.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
 gitk | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/gitk b/gitk
index d2e3803..fb2f653 100755
--- a/gitk
+++ b/gitk
@@ -6561,6 +6561,7 @@ proc drawtags {id x xt y1} {
 
     set marks {}
     set types {}
+    set wvals {}
     set maxtags 3
     set maxtagpct 25
     set maxwidth [expr {[graph_pane_width] * $maxtagpct / 100}]
@@ -6575,14 +6576,17 @@ proc drawtags {id x xt y1} {
 	    # show just a single "n tags..." tag
 	    lappend types tags
 	    if {$ntags == 1} {
-		lappend marks "tag..."
+		set text "tag..."
 	    } else {
-		lappend marks [format "%d tags..." $ntags]
+		set text [format "%d tags..." $ntags]
 	    }
+	    lappend marks $text
+	    lappend wvals [font measure mainfont $text]
 	} else {
 	    foreach tag $tags {
 		lappend types tag
 		lappend marks $tag
+		lappend wvals [font measure mainfont $tag]
 	    }
 	}
     }
@@ -6590,8 +6594,10 @@ proc drawtags {id x xt y1} {
 	foreach head $idheads($id) {
 	    if {$head eq $mainhead} {
 		lappend types mainhead
+		lappend wvals [font measure mainfontbold $head]
 	    } else {
 		lappend types head
+		lappend wvals [font measure mainfont $head]
 	    }
 	    lappend marks $head
 	}
@@ -6600,6 +6606,7 @@ proc drawtags {id x xt y1} {
 	foreach other $idotherrefs($id) {
 	    lappend types other
 	    lappend marks $other
+	    lappend wvals [font measure mainfont $other]
 	}
     }
     if {$marks eq {}} {
@@ -6609,15 +6616,8 @@ proc drawtags {id x xt y1} {
     set yt [expr {$y1 - 0.5 * $linespc}]
     set yb [expr {$yt + $linespc - 1}]
     set xvals {}
-    set wvals {}
-    foreach tag $marks type $types {
-	if {$type eq "mainhead"} {
-	    set wid [font measure mainfontbold $tag]
-	} else {
-	    set wid [font measure mainfont $tag]
-	}
+    foreach wid $wvals {
 	lappend xvals $xt
-	lappend wvals $wid
 	set xt [expr {$xt + $wid + $extra}]
     }
     set t [$canv create line $x $y1 [lindex $xvals end] $y1 \
-- 
2.9.3
Previous: Michael HaggertyNext: Michael Haggerty
Message 9 of 24 in “gitk: tweak rendering of remote-tracking references”
  1. 00/13 gitk: tweak rendering of remote-tracking referencesMichael Haggerty, Dec 19, 2016
  2. 01/13 gitk: when processing tag labels, don't use `marks` as scratch spaceMichael Haggerty, Dec 19, 2016
  3. 02/13 gitk: keep track of tag types in a separate `types` arrayMichael Haggerty, Dec 19, 2016
  4. 12/13 gitk: add a configuration setting `remoterefbgcolor`Michael Haggerty, Dec 19, 2016
  5. 07/13 gitk: extract a method `remotereftext`Michael Haggerty, Dec 19, 2016
  6. 06/13 gitk: simplify regexpMichael Haggerty, Dec 19, 2016
  7. 04/13 gitk: use a type "mainhead" to indicate the main HEAD branchMichael Haggerty, Dec 19, 2016
  8. 08/13 gitk: only change the color of the "remote" part of remote refsMichael Haggerty, Dec 19, 2016
  9. 05/13 gitk: fill in `wvals` as the tags are first processedMichael Haggerty, Dec 19, 2016
  10. 09/13 gitk: shorten labels displayed for modern remote-tracking refsMichael Haggerty, Dec 19, 2016
  11. 10/13 gitk: use type "remote" for remote-tracking referencesMichael Haggerty, Dec 19, 2016
  12. 11/13 gitk: introduce a constant otherrefbgcolorMichael Haggerty, Dec 19, 2016
  13. 13/13 gitk: change the default colors for remote-tracking referencesMichael Haggerty, Dec 19, 2016
  14. 03/13 gitk: use a type "tags" to indicate abbreviated tagsMichael Haggerty, Dec 19, 2016
  15. Philip OakleyDec 19, 2016
  16. Michael HaggertyDec 20, 2016
  17. Marc BranchaudDec 20, 2016
  18. Paul MackerrasDec 20, 2016
  19. Marc BranchaudDec 20, 2016
  20. Michael HaggertyDec 21, 2016
  21. Marc BranchaudDec 21, 2016
  22. Michael HaggertyDec 22, 2016
  23. Marc BranchaudJan 9, 2017
  24. Marc BranchaudFeb 6, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.