git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Eric Raible" <raible@gmail.com>
To: paulus@samba.org
Cc: git@vger.kernel.org
Subject: gitk: synchronize highlighting in file view for 'f'&'b' commands
Date: Mon, 17 Mar 2008 13:00:55 -0700	[thread overview]
Message-ID: <279b37b20803171300v748b5d23rcc5c0e534429d1be@mail.gmail.com> (raw)

Previously, 'b', backspace, and delete all did the same thing.
This changes 'b' to perform the inverse of 'f'.  And both of
them now highlight the filename of the currently diff.

This makes it easier to review and navigate the diffs associated
with a particular commit using only f, b, and space because the
filename of the currently display diff will be dynamically
highlighted.

Signed-off-by: Eric Raible <raible@gmail.com>
---
 gitk-git/gitk |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 84ab02e..51ba3ff 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -1016,7 +1016,7 @@ proc makewindow {} {
     bindkey k "selnextline 1"
     bindkey j "goback"
     bindkey l "goforw"
-    bindkey b "$ctext yview scroll -1 pages"
+    bindkey b prevfile
     bindkey d "$ctext yview scroll 18 units"
     bindkey u "$ctext yview scroll -18 units"
     bindkey / {dofind 1 1}
@@ -5478,18 +5478,34 @@ proc changediffdisp {} {
     $ctext tag conf d1 -elide [lindex $diffelide 1]
 }

+proc highlightfile {loc} {
+    global ctext
+    $ctext yview $loc
+
+    global cmitmode ctext cflist cflist_top
+    if {$cmitmode eq "tree"} return
+
+    $cflist tag remove highlight $cflist_top.0 "$cflist_top.0 lineend"
+
+    set file [regsub -- "-* (.*?) -*" [$ctext get $loc "$loc lineend"] "\\1"]
+    set cline [$cflist search -regexp [subst {^$file$}] 0.0]
+
+    $cflist tag add highlight $cline "$cline lineend"
+    $cflist see $cline
+    set cflist_top [lindex [split $cline .] 0]
+}
+
 proc prevfile {} {
     global difffilestart ctext
     set prev [lindex $difffilestart 0]
     set here [$ctext index @0,0]
     foreach loc $difffilestart {
        if {[$ctext compare $loc >= $here]} {
-           $ctext yview $prev
+           highlightfile $prev
            return
        }
        set prev $loc
     }
-    $ctext yview $prev
 }

 proc nextfile {} {
@@ -5497,7 +5513,7 @@ proc nextfile {} {
     set here [$ctext index @0,0]
     foreach loc $difffilestart {
        if {[$ctext compare $loc > $here]} {
-           $ctext yview $loc
+           highlightfile $loc
            return
        }
     }
--
1.5.4.2.1161.g1a6f0

             reply	other threads:[~2008-03-17 20:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-17 20:00 Eric Raible [this message]
2008-05-02 12:49 ` gitk: synchronize highlighting in file view for 'f'&'b' commands Paul Mackerras
2008-05-02 18:45   ` Eric Raible

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=279b37b20803171300v748b5d23rcc5c0e534429d1be@mail.gmail.com \
    --to=raible@gmail.com \
    --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).