{"thread":{"id":"35413","subject":"[PATCH] gitk: make pointer selection visible in highlighted lines","startedAt":"2013-11-27T18:06:01Z","lastAt":"2013-12-11T23:36:40Z","messageCount":8,"participants":["Max Kirillov","Thomas Rast","Eric Sunshine","Paul Mackerras","Stefan Haller"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"231199","messageId":"20131127180601.GA31211@wheezy.local","threadId":"35413","inReplyTo":null,"subject":"[PATCH] gitk: make pointer selection visible in highlighted lines","fromName":"Max Kirillov","fromEmail":"max@max630.net","sentAt":"2013-11-27T18:06:01Z","receivedAt":"2013-11-27T18:06:01Z","isPatch":true,"sender":{"key":"max@max630.net","avatar":"https://avatars.githubusercontent.com/u/381560?v=4"},"body":"Custom tags have higher priority than sel, and when they define\ntheir own background, it makes selection invisible. Especially\ninconvenient for filesep (to select filenames), but may aslo affect\nother tags.\n\nSigned-off-by: Max Kirillov <max@max630.net>\n---\n gitk-git/gitk | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex 5cd00d8..9f350ab 100755\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -2385,6 +2385,7 @@ proc makewindow {} {\n     $ctext tag conf found -back $foundbgcolor\n     $ctext tag conf currentsearchhit -back $currentsearchhitbgcolor\n     $ctext tag conf wwrap -wrap word\n+    $ctext tag raise sel\n \n     .pwbottom add .bleft\n     if {!$use_ttk} {\n-- \n1.8.4.2.1566.g3c1a064\n"},{"id":"231206","messageId":"871u21hczm.fsf@thomasrast.ch","threadId":"35413","inReplyTo":"20131127180601.GA31211@wheezy.local","subject":"Re: [PATCH] gitk: make pointer selection visible in highlighted lines","fromName":"Thomas Rast","fromEmail":"tr@thomasrast.ch","sentAt":"2013-11-27T19:16:13Z","receivedAt":"2013-11-27T19:16:13Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Max Kirillov <max@max630.net> writes:\n\n> Custom tags have higher priority than sel, and when they define\n> their own background, it makes selection invisible. Especially\n> inconvenient for filesep (to select filenames), but may aslo affect\n> other tags.\n>\n> Signed-off-by: Max Kirillov <max@max630.net>\n\nNice.\n\nTested-by: Thomas Rast <tr@thomasrast.ch>\n\n> ---\n>  gitk-git/gitk | 1 +\n>  1 file changed, 1 insertion(+)\n>\n> diff --git a/gitk-git/gitk b/gitk-git/gitk\n> index 5cd00d8..9f350ab 100755\n> --- a/gitk-git/gitk\n> +++ b/gitk-git/gitk\n> @@ -2385,6 +2385,7 @@ proc makewindow {} {\n>      $ctext tag conf found -back $foundbgcolor\n>      $ctext tag conf currentsearchhit -back $currentsearchhitbgcolor\n>      $ctext tag conf wwrap -wrap word\n> +    $ctext tag raise sel\n>  \n>      .pwbottom add .bleft\n>      if {!$use_ttk} {\n\n-- \nThomas Rast\ntr@thomasrast.ch\n"},{"id":"231210","messageId":"CAPig+cTKofBCdgwJkpyPsAHjhi4-GqPwU2CuOAPsf_qr8isJ9w@mail.gmail.com","threadId":"35413","inReplyTo":"20131127180601.GA31211@wheezy.local","subject":"Re: [PATCH] gitk: make pointer selection visible in highlighted lines","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-11-27T20:29:53Z","receivedAt":"2013-11-27T20:29:53Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Nov 27, 2013 at 1:06 PM, Max Kirillov <max@max630.net> wrote:\n> Custom tags have higher priority than sel, and when they define\n> their own background, it makes selection invisible. Especially\n> inconvenient for filesep (to select filenames), but may also affect\n\ns/aslo/also/\n\n> other tags.\n>\n> Signed-off-by: Max Kirillov <max@max630.net>\n"},{"id":"231263","messageId":"20131128212018.GA24615@wheezy.local","threadId":"35413","inReplyTo":"20131127180601.GA31211@wheezy.local","subject":"[PATCH v2] gitk: make pointer selection visible in highlighted lines","fromName":"Max Kirillov","fromEmail":"max@max630.net","sentAt":"2013-11-28T21:20:18Z","receivedAt":"2013-11-28T21:20:18Z","isPatch":true,"sender":{"key":"max@max630.net","avatar":"https://avatars.githubusercontent.com/u/381560?v=4"},"body":"Custom tags have higher priority than `sel`, and when they define their\nown background, it makes selection invisible. Especially inconvenient\nfor `filesep` (to select filenames), but also affects other tags.\nUse `tag raise` to fix `sel`'s priority.\n\nAlso change `omark` tag handling, so that it is created once, together\nwith others, and then only removed from text rather than deleted. Then\nit will not get larger priority than the `sel` tag.\n\nSigned-off-by: Max Kirillov <max@max630.net>\n---\n\nFixed the typo in the comment and selection of text in marked line\n\n gitk | 8 +++++---\n 1 file changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 1dd5137..491a1fa 100755\n--- a/gitk\n+++ b/gitk\n@@ -2029,6 +2029,7 @@ proc makewindow {} {\n     global headctxmenu progresscanv progressitem progresscoords statusw\n     global fprogitem fprogcoord lastprogupdate progupdatepending\n     global rprogitem rprogcoord rownumsel numcommits\n+    global markbgcolor\n     global have_tk85 use_ttk NS\n     global git_version\n     global worddiff\n@@ -2376,6 +2377,8 @@ proc makewindow {} {\n     $ctext tag conf found -back yellow\n     $ctext tag conf currentsearchhit -back orange\n     $ctext tag conf wwrap -wrap word\n+    $ctext tag conf omark -background $markbgcolor\n+    $ctext tag raise sel\n \n     .pwbottom add .bleft\n     if {!$use_ttk} {\n@@ -7439,11 +7442,10 @@ proc getblobline {bf id} {\n }\n \n proc mark_ctext_line {lnum} {\n-    global ctext markbgcolor\n+    global ctext\n \n-    $ctext tag delete omark\n+    $ctext tag remove omark 1.0 end\n     $ctext tag add omark $lnum.0 \"$lnum.0 + 1 line\"\n-    $ctext tag conf omark -background $markbgcolor\n     $ctext see $lnum.0\n }\n \n-- \n1.8.4.2.1566.g3c1a064\n"},{"id":"231338","messageId":"20131201224132.GB12576@iris.ozlabs.ibm.com","threadId":"35413","inReplyTo":"20131128212018.GA24615@wheezy.local","subject":"Re: [PATCH v2] gitk: make pointer selection visible in highlighted lines","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2013-12-01T22:41:32Z","receivedAt":"2013-12-01T22:41:32Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"On Thu, Nov 28, 2013 at 11:20:18PM +0200, Max Kirillov wrote:\n> Custom tags have higher priority than `sel`, and when they define their\n> own background, it makes selection invisible. Especially inconvenient\n> for `filesep` (to select filenames), but also affects other tags.\n> Use `tag raise` to fix `sel`'s priority.\n> \n> Also change `omark` tag handling, so that it is created once, together\n> with others, and then only removed from text rather than deleted. Then\n> it will not get larger priority than the `sel` tag.\n\nThis conflicts with the recent change to highlight the current search\nhit in orange (c46149, \"gitk: Highlight current search hit in\norange\").  With the selection being the highest-priority tag, the\ncurrent search hit gets shown in grey instead.  I think I prefer the\norange.  I agree though that if the user explicitly selects part of\nthe text using the mouse, the selection highlight should be the\nhighest priority in that case.  Maybe the solution is to not select\nthe search hit automatically?\n\nPaul.\n"},{"id":"231358","messageId":"1ld8zlh.1h4guajnkaralM%lists@haller-berlin.de","threadId":"35413","inReplyTo":"20131201224132.GB12576@iris.ozlabs.ibm.com","subject":"Re: [PATCH v2] gitk: make pointer selection visible in highlighted lines","fromName":"Stefan Haller","fromEmail":"lists@haller-berlin.de","sentAt":"2013-12-02T10:04:09Z","receivedAt":"2013-12-02T10:04:09Z","isPatch":true,"sender":{"key":"lists@haller-berlin.de","avatar":null},"body":"Paul Mackerras <paulus@samba.org> wrote:\n\n> On Thu, Nov 28, 2013 at 11:20:18PM +0200, Max Kirillov wrote:\n> > Custom tags have higher priority than `sel`, and when they define their\n> > own background, it makes selection invisible. Especially inconvenient\n> > for `filesep` (to select filenames), but also affects other tags.\n> > Use `tag raise` to fix `sel`'s priority.\n> > \n> > Also change `omark` tag handling, so that it is created once, together\n> > with others, and then only removed from text rather than deleted. Then\n> > it will not get larger priority than the `sel` tag.\n> \n> This conflicts with the recent change to highlight the current search\n> hit in orange (c46149, \"gitk: Highlight current search hit in\n> orange\").  With the selection being the highest-priority tag, the\n> current search hit gets shown in grey instead.  I think I prefer the\n> orange.  I agree though that if the user explicitly selects part of\n> the text using the mouse, the selection highlight should be the\n> highest priority in that case.  Maybe the solution is to not select\n> the search hit automatically?\n\nI don't think that not selecting the search hint is an option: the\nselection is used to keep track of where to search next.\n\nCan't we just raise the currentsearchhit tag above the sel tag?\n\n\n-- \nStefan Haller\nBerlin, Germany\nhttp://www.haller-berlin.de/\n"},{"id":"231406","messageId":"20131203003434.GA18541@wheezy.local","threadId":"35413","inReplyTo":"1ld8zlh.1h4guajnkaralM%lists@haller-berlin.de","subject":"Re: [PATCH v2] gitk: make pointer selection visible in highlighted lines","fromName":"Max Kirillov","fromEmail":"max@max630.net","sentAt":"2013-12-03T00:35:10Z","receivedAt":"2013-12-03T00:35:10Z","isPatch":true,"sender":{"key":"max@max630.net","avatar":"https://avatars.githubusercontent.com/u/381560?v=4"},"body":"On Mon, Dec 02, 2013 at 11:04:09AM +0100, Stefan Haller wrote:\n> I don't think that not selecting the search hint is an\n> option: the selection is used to keep track of where to\n> search next.\n\nTo mark the next found position, should a 0-length selection\nbe enough? I will try to experiment with it.\n\n> Can't we just raise the currentsearchhit tag above the sel\n> tag?\n\nThis also seems to help, as far as I understod\ncurrentsearchhit is always removed as interactive selection\nstarts, so it should not hide manual selection.\n\n-- \nMax\n"},{"id":"231935","messageId":"20131211233640.GA4985@wheezy.local","threadId":"35413","inReplyTo":"1ld8zlh.1h4guajnkaralM%lists@haller-berlin.de","subject":"[RFC] HACK: use anchor mark instead of sel tag","fromName":"Max Kirillov","fromEmail":"max@max630.net","sentAt":"2013-12-11T23:36:40Z","receivedAt":"2013-12-11T23:36:40Z","isPatch":false,"sender":{"key":"max@max630.net","avatar":"https://avatars.githubusercontent.com/u/381560?v=4"},"body":"---\n\nI hacked somehow around this. It seems that just usilg the\nanchor mark should be enough to implement almost the same\nbehavior. The hard part is that I don't know which feature\nis intentional and which is just random consequence of using\nsel for search highlight.\n\nOne thing which seems to me important and not possible to\nimplement without using another mask or tag is to return\ncurrentsearchhit back when user removes characters from the\nend of search string, and it starts to match previous\nplaces.\n\nThis is not intended as patch for merging, just proof of\nconcept.\n\n gitk-git/gitk | 32 ++++++++++++++++++--------------\n 1 file changed, 18 insertions(+), 14 deletions(-)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex cf25472..c8b223f 100755\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -8320,24 +8320,29 @@ proc settabs {{firstab {}}} {\n proc incrsearch {name ix op} {\n     global ctext searchstring searchdirn\n \n-    if {[catch {$ctext index anchor}]} {\n+    if {[catch {set prev_anchor [$ctext index anchor]}]} {\n \t# no anchor set, use start of selection, or of visible area\n \tset sel [$ctext tag ranges sel]\n \tif {$sel ne {}} {\n-\t    $ctext mark set anchor [lindex $sel 0]\n+\t    set start [lindex $sel 0]\n \t} elseif {$searchdirn eq \"-forwards\"} {\n-\t    $ctext mark set anchor @0,0\n+\t    set start @0,0\n+\t} else {\n+\t    set start @0,[winfo height $ctext]\n+\t}\n+    } else {\n+\tif {$searchdirn eq \"-forwards\"} {\n+\t    set start $prev_anchor\n \t} else {\n-\t    $ctext mark set anchor @0,[winfo height $ctext]\n+\t    set start \"$prev_anchor + [string length $searchstring] c\"\n \t}\n     }\n     if {$searchstring ne {}} {\n-\tset here [$ctext search -count mlen $searchdirn -- $searchstring anchor]\n+\tset here [$ctext search -count mlen $searchdirn -- $searchstring $start]\n \tif {$here ne {}} {\n \t    $ctext see $here\n \t    set mend \"$here + $mlen c\"\n-\t    $ctext tag remove sel 1.0 end\n-\t    $ctext tag add sel $here $mend\n+\t    $ctext mark set anchor $here\n \t    suppress_highlighting_file_for_current_scrollpos\n \t    highlightfile_for_scrollpos $here\n \t}\n@@ -8355,7 +8360,7 @@ proc dosearch {} {\n \tset sel [$ctext tag ranges sel]\n \tif {$sel ne {}} {\n \t    set start \"[lindex $sel 0] + 1c\"\n-\t} elseif {[catch {set start [$ctext index anchor]}]} {\n+\t} elseif {[catch {set start \"[$ctext index anchor] + 1c\"}]} {\n \t    set start \"@0,0\"\n \t}\n \tset match [$ctext search -count mlen -- $searchstring $start]\n@@ -8368,8 +8373,7 @@ proc dosearch {} {\n \tsuppress_highlighting_file_for_current_scrollpos\n \thighlightfile_for_scrollpos $match\n \tset mend \"$match + $mlen c\"\n-\t$ctext tag add sel $match $mend\n-\t$ctext mark unset anchor\n+\t$ctext mark set anchor $match\n \trehighlight_search_results\n     }\n }\n@@ -8397,8 +8401,7 @@ proc dosearchback {} {\n \tsuppress_highlighting_file_for_current_scrollpos\n \thighlightfile_for_scrollpos $match\n \tset mend \"$match + $ml c\"\n-\t$ctext tag add sel $match $mend\n-\t$ctext mark unset anchor\n+        $ctext mark set anchor $match\n \trehighlight_search_results\n     }\n }\n@@ -8418,14 +8421,15 @@ proc searchmark {first last} {\n     global ctext searchstring\n     puts [list $first $last]\n \n-    set sel [$ctext tag ranges sel]\n+    #TODO: catch no anchor\n+    set anchor [$ctext index anchor]\n \n     set mend $first.0\n     while {1} {\n \tset match [$ctext search -count mlen -- $searchstring $mend $last.end]\n \tif {$match eq {}} break\n \tset mend \"$match + $mlen c\"\n-\tif {$sel ne {} && [$ctext compare $match == [lindex $sel 0]]} {\n+\tif {$anchor eq $match} {\n \t    $ctext tag add currentsearchhit $match $mend\n \t} else {\n \t    $ctext tag add found $match $mend\n-- \n1.8.4.2.1566.g3c1a064\n"}]}