From: Stefan Haller <stefan@haller-berlin.de>
To: Paul Mackerras <paulus@samba.org>
Cc: git@vger.kernel.org
Subject: [PATCH v2] gitk: Synchronize highlighting in file view when scrolling diff
Date: Wed, 19 Sep 2012 11:57:21 +0200 [thread overview]
Message-ID: <1348048641-5765-1-git-send-email-stefan@haller-berlin.de> (raw)
In-Reply-To: <5058BC35.6050007@arcor.de>
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 <stefan@haller-berlin.de>
---
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
next prev parent reply other threads:[~2012-09-19 9:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-18 5:57 [PATCH] gitk: Synchronize highlighting in file view when scrolling diff Stefan Haller
2012-09-18 18:23 ` Peter Oberndorfer
2012-09-19 9:57 ` Stefan Haller [this message]
2012-09-18 23:46 ` Paul Mackerras
2012-09-19 14:28 ` Marc Branchaud
2012-09-19 18:17 ` [PATCH v3] " Stefan Haller
2012-09-23 6:58 ` Paul Mackerras
2012-09-24 5:51 ` Stefan Haller
2012-10-26 22:03 ` [PATCH] gitk: Do not select file list entries during diff loading Peter Oberndorfer
2012-10-29 8:56 ` Stefan Haller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1348048641-5765-1-git-send-email-stefan@haller-berlin.de \
--to=stefan@haller-berlin.de \
--cc=git@vger.kernel.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).