From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Haller Subject: [PATCH v2] gitk: Synchronize highlighting in file view when scrolling diff Date: Wed, 19 Sep 2012 11:57:21 +0200 Message-ID: <1348048641-5765-1-git-send-email-stefan@haller-berlin.de> References: <5058BC35.6050007@arcor.de> Cc: git@vger.kernel.org To: Paul Mackerras X-From: git-owner@vger.kernel.org Wed Sep 19 11:58:08 2012 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TEH2g-0003VC-6F for gcvg-git-2@plane.gmane.org; Wed, 19 Sep 2012 11:58:02 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756031Ab2ISJ5u (ORCPT ); Wed, 19 Sep 2012 05:57:50 -0400 Received: from server90.greatnet.de ([83.133.96.186]:50964 "EHLO server90.greatnet.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755049Ab2ISJ5q (ORCPT ); Wed, 19 Sep 2012 05:57:46 -0400 Received: from macbook-stk.office.ableton.com (nat1.ableton.net [217.110.199.117]) by server90.greatnet.de (Postfix) with ESMTPA id 0EA872C4078; Wed, 19 Sep 2012 11:57:44 +0200 (CEST) X-Mailer: git-send-email 1.7.12.517.g4c1112f In-Reply-To: <5058BC35.6050007@arcor.de> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Whenever the diff pane scrolls, highlight the corresponding file in the file list on the right. For a large commit with many files and long per-file diffs, this makes it easier to keep track of what you're looking at. This allows simplifying the prevfile and nextfile functions, because all they have to do is scroll the diff pane. Signed-off-by: Stefan Haller --- The only change from v1 is the addition of the "$difffilestart eq {}" condition, this should fix the flickering problem reported by Peter. I didn't do anything about the search problem yet, will look into this next. (Personally though, I think this is acceptable the way it is.) gitk | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/gitk b/gitk index d93bd99..8095806 100755 --- a/gitk +++ b/gitk @@ -7947,10 +7947,9 @@ proc changediffdisp {} { $ctext tag conf dresult -elide [lindex $diffelide 1] } -proc highlightfile {loc cline} { - global ctext cflist cflist_top +proc highlightfile {cline} { + global cflist cflist_top - $ctext yview $loc $cflist tag remove highlight $cflist_top.0 "$cflist_top.0 lineend" $cflist tag add highlight $cline.0 "$cline.0 lineend" $cflist see $cline.0 @@ -7962,17 +7961,15 @@ proc prevfile {} { if {$cmitmode eq "tree"} return set prev 0.0 - set prevline 1 set here [$ctext index @0,0] foreach loc $difffilestart { if {[$ctext compare $loc >= $here]} { - highlightfile $prev $prevline + $ctext yview $prev return } set prev $loc - incr prevline } - highlightfile $prev $prevline + $ctext yview $prev } proc nextfile {} { @@ -7980,11 +7977,9 @@ proc nextfile {} { if {$cmitmode eq "tree"} return set here [$ctext index @0,0] - set line 1 foreach loc $difffilestart { - incr line if {[$ctext compare $loc > $here]} { - highlightfile $loc $line + $ctext yview $loc return } } @@ -8138,7 +8133,17 @@ proc searchmarkvisible {doall} { } proc scrolltext {f0 f1} { - global searchstring + global searchstring cmitmode + global ctext cflist cflist_top difffilestart + + if {$cmitmode ne "tree" && [info exists difffilestart]} { + set top [lindex [split [$ctext index @0,0] .] 0] + if {$difffilestart eq {} || $top < [lindex $difffilestart 0]} { + highlightfile 0 + } else { + highlightfile [expr {[bsearch $difffilestart $top] + 2}] + } + } .bleft.bottom.sb set $f0 $f1 if {$searchstring ne {}} { -- 1.7.12.517.g4c1112f