{"thread":{"id":"12728","subject":"gitk: synchronize highlighting in file view for 'f'&'b' commands","startedAt":"2008-03-17T20:00:55Z","lastAt":"2008-05-02T18:45:37Z","messageCount":3,"participants":["Eric Raible","Paul Mackerras"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"72317","messageId":"279b37b20803171300v748b5d23rcc5c0e534429d1be@mail.gmail.com","threadId":"12728","inReplyTo":null,"subject":"gitk: synchronize highlighting in file view for 'f'&'b' commands","fromName":"Eric Raible","fromEmail":"raible@gmail.com","sentAt":"2008-03-17T20:00:55Z","receivedAt":"2008-03-17T20:00:55Z","isPatch":false,"sender":{"key":"raible@gmail.com","avatar":null},"body":"Previously, 'b', backspace, and delete all did the same thing.\nThis changes 'b' to perform the inverse of 'f'.  And both of\nthem now highlight the filename of the currently diff.\n\nThis makes it easier to review and navigate the diffs associated\nwith a particular commit using only f, b, and space because the\nfilename of the currently display diff will be dynamically\nhighlighted.\n\nSigned-off-by: Eric Raible <raible@gmail.com>\n---\n gitk-git/gitk |   24 ++++++++++++++++++++----\n 1 files changed, 20 insertions(+), 4 deletions(-)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex 84ab02e..51ba3ff 100644\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -1016,7 +1016,7 @@ proc makewindow {} {\n     bindkey k \"selnextline 1\"\n     bindkey j \"goback\"\n     bindkey l \"goforw\"\n-    bindkey b \"$ctext yview scroll -1 pages\"\n+    bindkey b prevfile\n     bindkey d \"$ctext yview scroll 18 units\"\n     bindkey u \"$ctext yview scroll -18 units\"\n     bindkey / {dofind 1 1}\n@@ -5478,18 +5478,34 @@ proc changediffdisp {} {\n     $ctext tag conf d1 -elide [lindex $diffelide 1]\n }\n\n+proc highlightfile {loc} {\n+    global ctext\n+    $ctext yview $loc\n+\n+    global cmitmode ctext cflist cflist_top\n+    if {$cmitmode eq \"tree\"} return\n+\n+    $cflist tag remove highlight $cflist_top.0 \"$cflist_top.0 lineend\"\n+\n+    set file [regsub -- \"-* (.*?) -*\" [$ctext get $loc \"$loc lineend\"] \"\\\\1\"]\n+    set cline [$cflist search -regexp [subst {^$file$}] 0.0]\n+\n+    $cflist tag add highlight $cline \"$cline lineend\"\n+    $cflist see $cline\n+    set cflist_top [lindex [split $cline .] 0]\n+}\n+\n proc prevfile {} {\n     global difffilestart ctext\n     set prev [lindex $difffilestart 0]\n     set here [$ctext index @0,0]\n     foreach loc $difffilestart {\n        if {[$ctext compare $loc >= $here]} {\n-           $ctext yview $prev\n+           highlightfile $prev\n            return\n        }\n        set prev $loc\n     }\n-    $ctext yview $prev\n }\n\n proc nextfile {} {\n@@ -5497,7 +5513,7 @@ proc nextfile {} {\n     set here [$ctext index @0,0]\n     foreach loc $difffilestart {\n        if {[$ctext compare $loc > $here]} {\n-           $ctext yview $loc\n+           highlightfile $loc\n            return\n        }\n     }\n--\n1.5.4.2.1161.g1a6f0\n"},{"id":"75829","messageId":"18459.3557.603906.871664@cargo.ozlabs.ibm.com","threadId":"12728","inReplyTo":"279b37b20803171300v748b5d23rcc5c0e534429d1be@mail.gmail.com","subject":"Re: gitk: synchronize highlighting in file view for 'f'&'b' commands","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2008-05-02T12:49:41Z","receivedAt":"2008-05-02T12:49:41Z","isPatch":false,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Eric Raible writes:\n\n> Previously, 'b', backspace, and delete all did the same thing.\n> This changes 'b' to perform the inverse of 'f'.  And both of\n> them now highlight the filename of the currently diff.\n\nOK, but...\n\n> +    set file [regsub -- \"-* (.*?) -*\" [$ctext get $loc \"$loc lineend\"] \"\\\\1\"]\n> +    set cline [$cflist search -regexp [subst {^$file$}] 0.0]\n\nThis seems to be working out the index of the line we want to\nhighlight in the file list, but both the callers of highlightfile can\nsupply that info much more easily by incrementing a count as they go\nthrough $difffilestart, as far as I can tell.\n\nPaul.\n"},{"id":"75863","messageId":"481B6151.7040707@nextest.com","threadId":"12728","inReplyTo":"18459.3557.603906.871664@cargo.ozlabs.ibm.com","subject":"Re: gitk: synchronize highlighting in file view for 'f'&'b' commands","fromName":"Eric Raible","fromEmail":"raible@nextest.com","sentAt":"2008-05-02T18:45:37Z","receivedAt":"2008-05-02T18:45:37Z","isPatch":false,"sender":{"key":"raible@nextest.com","avatar":null},"body":"Paul Mackerras wrote:\n> Eric Raible writes:\n> \n>> Previously, 'b', backspace, and delete all did the same thing.\n>> This changes 'b' to perform the inverse of 'f'.  And both of\n>> them now highlight the filename of the currently diff.\n> \n> OK, but...\n> \n>> +    set file [regsub -- \"-* (.*?) -*\" [$ctext get $loc \"$loc lineend\"] \"\\\\1\"]\n>> +    set cline [$cflist search -regexp [subst {^$file$}] 0.0]\n> \n> This seems to be working out the index of the line we want to\n> highlight in the file list, but both the callers of highlightfile can\n> supply that info much more easily by incrementing a count as they go\n> through $difffilestart, as far as I can tell.\n> \n> Paul.\n> \n\nThat very well might be, but I:\n\n1) wanted to make the smallest possible change\n2) didn't peruse the code closely enough to see how to do that\n\nI unfortunately don't have the time to pursue this just now.\nAny chance you could take the idea and fly with it?\n\nThanks - Eric\n"}]}