{"thread":{"id":"52783","subject":"[PATCH] gitk: add diff lines background colors","startedAt":"2020-02-11T21:25:26Z","lastAt":"2020-04-09T17:48:19Z","messageCount":4,"participants":["Stefan Dotterweich","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"391580","messageId":"20200211212448.9288-1-stefandotterweich@gmx.de","threadId":"52783","inReplyTo":null,"subject":"[PATCH] gitk: add diff lines background colors","fromName":"Stefan Dotterweich","fromEmail":"stefandotterweich@gmx.de","sentAt":"2020-02-11T21:24:48Z","receivedAt":"2020-02-11T21:25:26Z","isPatch":true,"sender":{"key":"stefandotterweich@gmx.de","avatar":"https://avatars.githubusercontent.com/u/1097029?v=4"},"body":"Not using colored background for added and removed lines is a missed\nopportunity to make diff lines easier to grasp visually.\n\nUse a subtle red/green background by default. Make the font slightly darker\nto improve contrast.\n\nSigned-off-by: Stefan Dotterweich <stefandotterweich@gmx.de>\n---\nThe variable diffcolors seems like a fitting place for the two new colors.\nHowever, adding them to that list causes problems if diffcolors saved in\n.gitk then contains three instead of five colors. This could be solved by\nmodifying the variable after loading .gitk. I'm not sure if that would be\nthe preferred approach or where to implement a special case like that. To\navoid the problem, I introduced a new variable diffbgcolors.\n\n gitk | 22 +++++++++++++++++++---\n 1 file changed, 19 insertions(+), 3 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex da84e22..66c237a 100755\n--- a/gitk\n+++ b/gitk\n@@ -2073,7 +2073,7 @@ proc makewindow {} {\n     global rowctxmenu fakerowmenu mergemax wrapcomment\n     global highlight_files gdttype\n     global searchstring sstring\n-    global bgcolor fgcolor bglist fglist diffcolors selectbgcolor\n+    global bgcolor fgcolor bglist fglist diffcolors diffbgcolors selectbgcolor\n     global uifgcolor uifgdisabledcolor\n     global filesepbgcolor filesepfgcolor\n     global mergecolors foundbgcolor currentsearchhitbgcolor\n@@ -2434,7 +2434,9 @@ proc makewindow {} {\n     $ctext tag conf filesep -font textfontbold -fore $filesepfgcolor -back $filesepbgcolor\n     $ctext tag conf hunksep -fore [lindex $diffcolors 2]\n     $ctext tag conf d0 -fore [lindex $diffcolors 0]\n+    $ctext tag conf d0 -back [lindex $diffbgcolors 0]\n     $ctext tag conf dresult -fore [lindex $diffcolors 1]\n+    $ctext tag conf dresult -back [lindex $diffbgcolors 1]\n     $ctext tag conf m0 -fore [lindex $mergecolors 0]\n     $ctext tag conf m1 -fore [lindex $mergecolors 1]\n     $ctext tag conf m2 -fore [lindex $mergecolors 2]\n@@ -11607,6 +11609,7 @@ proc prefspage_general {notebook} {\n\n proc prefspage_colors {notebook} {\n     global NS uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor\n+    global diffbgcolors\n\n     set page [create_prefs_page $notebook.colors]\n\n@@ -11629,11 +11632,23 @@ proc prefspage_colors {notebook} {\n \t-command [list choosecolor diffcolors 0 $page.diffold [mc \"diff old lines\"] \\\n \t\t      [list $ctext tag conf d0 -foreground]]\n     grid x $page.diffoldbut $page.diffold -sticky w\n+    label $page.diffoldbg -padx 40 -relief sunk -background [lindex $diffbgcolors 0]\n+    ${NS}::button $page.diffoldbgbut -text [mc \"Diff: old lines bg\"] \\\n+\t-command [list choosecolor diffbgcolors 0 $page.diffoldbg \\\n+\t\t      [mc \"diff old lines bg\"] \\\n+\t\t      [list $ctext tag conf d0 -background]]\n+    grid x $page.diffoldbgbut $page.diffoldbg -sticky w\n     label $page.diffnew -padx 40 -relief sunk -background [lindex $diffcolors 1]\n     ${NS}::button $page.diffnewbut -text [mc \"Diff: new lines\"] \\\n \t-command [list choosecolor diffcolors 1 $page.diffnew [mc \"diff new lines\"] \\\n \t\t      [list $ctext tag conf dresult -foreground]]\n     grid x $page.diffnewbut $page.diffnew -sticky w\n+    label $page.diffnewbg -padx 40 -relief sunk -background [lindex $diffbgcolors 1]\n+    ${NS}::button $page.diffnewbgbut -text [mc \"Diff: new lines bg\"] \\\n+\t-command [list choosecolor diffbgcolors 1 $page.diffnewbg \\\n+\t\t      [mc \"diff new lines bg\"] \\\n+\t\t      [list $ctext tag conf dresult -background]]\n+    grid x $page.diffnewbgbut $page.diffnewbg -sticky w\n     label $page.hunksep -padx 40 -relief sunk -background [lindex $diffcolors 2]\n     ${NS}::button $page.hunksepbut -text [mc \"Diff: hunk header\"] \\\n \t-command [list choosecolor diffcolors 2 $page.hunksep \\\n@@ -12377,7 +12392,8 @@ if {[tk windowingsystem] eq \"win32\"} {\n \tset web_browser \"xdg-open\"\n     }\n }\n-set diffcolors {red \"#00a000\" blue}\n+set diffcolors {\"#c30000\" \"#009800\" blue}\n+set diffbgcolors {\"#fff3f3\" \"#f0fff0\"}\n set diffcontext 3\n set mergecolors {red blue \"#00ff00\" purple brown \"#009090\" magenta \"#808000\" \"#009000\" \"#ff0080\" cyan \"#b07070\" \"#70b0f0\" \"#70f0b0\" \"#f0b070\" \"#ff70b0\"}\n set ignorespace 0\n@@ -12448,7 +12464,7 @@ set config_variables {\n     remotebgcolor tagbgcolor tagfgcolor tagoutlinecolor reflinecolor\n     filesepbgcolor filesepfgcolor linehoverbgcolor linehoverfgcolor\n     linehoveroutlinecolor mainheadcirclecolor workingfilescirclecolor\n-    indexcirclecolor circlecolors linkfgcolor circleoutlinecolor\n+    indexcirclecolor circlecolors linkfgcolor circleoutlinecolor diffbgcolors\n     web_browser\n }\n foreach var $config_variables {\n--\n2.24.1\n\n"},{"id":"394974","messageId":"8b5b8d89-59c2-7349-25c1-2529db13fa6e@kdbg.org","threadId":"52783","inReplyTo":"20200211212448.9288-1-stefandotterweich@gmx.de","subject":"Re: [PATCH] gitk: add diff lines background colors","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2020-04-07T16:42:52Z","receivedAt":"2020-04-07T16:42:57Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 11.02.20 um 22:24 schrieb Stefan Dotterweich:\n> Not using colored background for added and removed lines is a missed\n> opportunity to make diff lines easier to grasp visually.\n> \n> Use a subtle red/green background by default. Make the font slightly darker\n> to improve contrast.\n\nI've been using gitk with this patch for a while, and I find the new\nappearance *very* pleasing! It gives gitk a fresh, modern look.\n\nThere is one major gripe, though: the new background color overrides the\nselection background and makes the selection invisible. This is a\nshowstopper.\n\nNote that the search result highlight does not become invisible.\n\n-- Hannes\n\n> \n> Signed-off-by: Stefan Dotterweich <stefandotterweich@gmx.de>\n> ---\n> The variable diffcolors seems like a fitting place for the two new colors.\n> However, adding them to that list causes problems if diffcolors saved in\n> .gitk then contains three instead of five colors. This could be solved by\n> modifying the variable after loading .gitk. I'm not sure if that would be\n> the preferred approach or where to implement a special case like that. To\n> avoid the problem, I introduced a new variable diffbgcolors.\n> \n>  gitk | 22 +++++++++++++++++++---\n>  1 file changed, 19 insertions(+), 3 deletions(-)\n> \n> diff --git a/gitk b/gitk\n> index da84e22..66c237a 100755\n> --- a/gitk\n> +++ b/gitk\n> @@ -2073,7 +2073,7 @@ proc makewindow {} {\n>      global rowctxmenu fakerowmenu mergemax wrapcomment\n>      global highlight_files gdttype\n>      global searchstring sstring\n> -    global bgcolor fgcolor bglist fglist diffcolors selectbgcolor\n> +    global bgcolor fgcolor bglist fglist diffcolors diffbgcolors selectbgcolor\n>      global uifgcolor uifgdisabledcolor\n>      global filesepbgcolor filesepfgcolor\n>      global mergecolors foundbgcolor currentsearchhitbgcolor\n> @@ -2434,7 +2434,9 @@ proc makewindow {} {\n>      $ctext tag conf filesep -font textfontbold -fore $filesepfgcolor -back $filesepbgcolor\n>      $ctext tag conf hunksep -fore [lindex $diffcolors 2]\n>      $ctext tag conf d0 -fore [lindex $diffcolors 0]\n> +    $ctext tag conf d0 -back [lindex $diffbgcolors 0]\n>      $ctext tag conf dresult -fore [lindex $diffcolors 1]\n> +    $ctext tag conf dresult -back [lindex $diffbgcolors 1]\n>      $ctext tag conf m0 -fore [lindex $mergecolors 0]\n>      $ctext tag conf m1 -fore [lindex $mergecolors 1]\n>      $ctext tag conf m2 -fore [lindex $mergecolors 2]\n> @@ -11607,6 +11609,7 @@ proc prefspage_general {notebook} {\n> \n>  proc prefspage_colors {notebook} {\n>      global NS uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor\n> +    global diffbgcolors\n> \n>      set page [create_prefs_page $notebook.colors]\n> \n> @@ -11629,11 +11632,23 @@ proc prefspage_colors {notebook} {\n>  \t-command [list choosecolor diffcolors 0 $page.diffold [mc \"diff old lines\"] \\\n>  \t\t      [list $ctext tag conf d0 -foreground]]\n>      grid x $page.diffoldbut $page.diffold -sticky w\n> +    label $page.diffoldbg -padx 40 -relief sunk -background [lindex $diffbgcolors 0]\n> +    ${NS}::button $page.diffoldbgbut -text [mc \"Diff: old lines bg\"] \\\n> +\t-command [list choosecolor diffbgcolors 0 $page.diffoldbg \\\n> +\t\t      [mc \"diff old lines bg\"] \\\n> +\t\t      [list $ctext tag conf d0 -background]]\n> +    grid x $page.diffoldbgbut $page.diffoldbg -sticky w\n>      label $page.diffnew -padx 40 -relief sunk -background [lindex $diffcolors 1]\n>      ${NS}::button $page.diffnewbut -text [mc \"Diff: new lines\"] \\\n>  \t-command [list choosecolor diffcolors 1 $page.diffnew [mc \"diff new lines\"] \\\n>  \t\t      [list $ctext tag conf dresult -foreground]]\n>      grid x $page.diffnewbut $page.diffnew -sticky w\n> +    label $page.diffnewbg -padx 40 -relief sunk -background [lindex $diffbgcolors 1]\n> +    ${NS}::button $page.diffnewbgbut -text [mc \"Diff: new lines bg\"] \\\n> +\t-command [list choosecolor diffbgcolors 1 $page.diffnewbg \\\n> +\t\t      [mc \"diff new lines bg\"] \\\n> +\t\t      [list $ctext tag conf dresult -background]]\n> +    grid x $page.diffnewbgbut $page.diffnewbg -sticky w\n>      label $page.hunksep -padx 40 -relief sunk -background [lindex $diffcolors 2]\n>      ${NS}::button $page.hunksepbut -text [mc \"Diff: hunk header\"] \\\n>  \t-command [list choosecolor diffcolors 2 $page.hunksep \\\n> @@ -12377,7 +12392,8 @@ if {[tk windowingsystem] eq \"win32\"} {\n>  \tset web_browser \"xdg-open\"\n>      }\n>  }\n> -set diffcolors {red \"#00a000\" blue}\n> +set diffcolors {\"#c30000\" \"#009800\" blue}\n> +set diffbgcolors {\"#fff3f3\" \"#f0fff0\"}\n>  set diffcontext 3\n>  set mergecolors {red blue \"#00ff00\" purple brown \"#009090\" magenta \"#808000\" \"#009000\" \"#ff0080\" cyan \"#b07070\" \"#70b0f0\" \"#70f0b0\" \"#f0b070\" \"#ff70b0\"}\n>  set ignorespace 0\n> @@ -12448,7 +12464,7 @@ set config_variables {\n>      remotebgcolor tagbgcolor tagfgcolor tagoutlinecolor reflinecolor\n>      filesepbgcolor filesepfgcolor linehoverbgcolor linehoverfgcolor\n>      linehoveroutlinecolor mainheadcirclecolor workingfilescirclecolor\n> -    indexcirclecolor circlecolors linkfgcolor circleoutlinecolor\n> +    indexcirclecolor circlecolors linkfgcolor circleoutlinecolor diffbgcolors\n>      web_browser\n>  }\n>  foreach var $config_variables {\n> --\n> 2.24.1\n> \n> \n\n"},{"id":"395080","messageId":"2ecfbb59-3a65-9db0-4ff7-e649ab6dfb6e@kdbg.org","threadId":"52783","inReplyTo":"8b5b8d89-59c2-7349-25c1-2529db13fa6e@kdbg.org","subject":"[PATCH] gitk: Un-hide selection in added and removed text and search results","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2020-04-08T18:36:25Z","receivedAt":"2020-04-08T18:36:30Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"The recently introduced background for the tags that highlight\nadded and removed text takes precedence over the background color\nof the selection. But selected text is more important than the\nhighlighted text. Make the highlighting tags the lowest priority.\n\nThe same argument holds for the highlight of search results. But\nsearch results are a bit more important. Therefore, make them\nalso low-priority, but just above the added-and-removed tags.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\nAm 07.04.20 um 18:42 schrieb Johannes Sixt:\n> There is one major gripe, though: the new background color overrides the\n> selection background and makes the selection invisible. This is a\n> showstopper.\n\nHere is a fix for that on top of Stefan's patch. The patch text works\nwithout Stefan's patch (and would un-hide the selection in search\nresults), but the commit message would have to be adjusted.\n\n-- Hannes\n\n gitk | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/gitk b/gitk\nindex 4129c0ba95..d4dd9aca64 100755\n--- a/gitk\n+++ b/gitk\n@@ -2468,6 +2468,11 @@ proc makewindow {} {\n     $ctext tag conf currentsearchhit -back $currentsearchhitbgcolor\n     $ctext tag conf wwrap -wrap word -lmargin2 1c\n     $ctext tag conf bold -font textfontbold\n+    # set these to the lowest priority:\n+    $ctext tag lower currentsearchhit\n+    $ctext tag lower found\n+    $ctext tag lower dresult\n+    $ctext tag lower d0\n \n     .pwbottom add .bleft\n     if {!$use_ttk} {\n-- \n2.26.0.207.gdeb9c6cae9\n"},{"id":"395133","messageId":"dc614e0d-fe7b-2aed-545b-e4322e35ab12@kdbg.org","threadId":"52783","inReplyTo":"2ecfbb59-3a65-9db0-4ff7-e649ab6dfb6e@kdbg.org","subject":"[PATCH v2] gitk: Un-hide selection in areas with non-default background color","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2020-04-09T17:48:12Z","receivedAt":"2020-04-09T17:48:19Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"The recently introduced background for the tags that highlight\nadded and removed text takes precedence over the background color\nof the selection. But selected text is more important than the\nhighlighted text. Make the highlighting tags the lowest priority.\n\nThe same argument holds for the file separator and the highlight\nof search results. Therefore, make them also low-priority. But\nsearch results are a bit more important; therefore, keep them\nabove the other tags.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\nHere is an update for my earlier patch as I found that the file\nseparator also overrides the selection. This fixes it.\n\n1:  7c4c862 ! 1:  3a0e64c gitk: Un-hide selection in added and removed text and search results\n    @@ Metadata\n     Author: Johannes Sixt <j6t@kdbg.org>\n     \n      ## Commit message ##\n    -    gitk: Un-hide selection in added and removed text and search results\n    +    gitk: Un-hide selection in areas with non-default background color\n     \n         The recently introduced background for the tags that highlight\n         added and removed text takes precedence over the background color\n         of the selection. But selected text is more important than the\n         highlighted text. Make the highlighting tags the lowest priority.\n     \n    -    The same argument holds for the highlight of search results. But\n    -    search results are a bit more important. Therefore, make them\n    -    also low-priority, but just above the added-and-removed tags.\n    +    The same argument holds for the file separator and the highlight\n    +    of search results. Therefore, make them also low-priority. But\n    +    search results are a bit more important; therefore, keep them\n    +    above the other tags.\n     \n         Signed-off-by: Johannes Sixt <j6t@kdbg.org>\n     \n    @@ gitk: proc makewindow {} {\n     +    # set these to the lowest priority:\n     +    $ctext tag lower currentsearchhit\n     +    $ctext tag lower found\n    ++    $ctext tag lower filesep\n     +    $ctext tag lower dresult\n     +    $ctext tag lower d0\n      \n gitk | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/gitk b/gitk\nindex 4129c0b..9ac6e5b 100755\n--- a/gitk\n+++ b/gitk\n@@ -2468,6 +2468,12 @@ proc makewindow {} {\n     $ctext tag conf currentsearchhit -back $currentsearchhitbgcolor\n     $ctext tag conf wwrap -wrap word -lmargin2 1c\n     $ctext tag conf bold -font textfontbold\n+    # set these to the lowest priority:\n+    $ctext tag lower currentsearchhit\n+    $ctext tag lower found\n+    $ctext tag lower filesep\n+    $ctext tag lower dresult\n+    $ctext tag lower d0\n \n     .pwbottom add .bleft\n     if {!$use_ttk} {\n-- \n2.26.0.207.gdeb9c6cae9\n\n"}]}