From 049463f729bb444365cfc9ef2b21f2c99fcdac09 Mon Sep 17 00:00:00 2001
From: Kai Willadsen <kai.willadsen@gmail.com>
Date: Mon, 28 Sep 2009 06:10:37 +1000
Subject: [PATCH] Highlight current chunk

---
 meld/filediff.py |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/meld/filediff.py b/meld/filediff.py
index a2bc5b7..45a4c9d 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -253,6 +253,10 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
             self.cursor.chunk, self.cursor.prev, self.cursor.next = chunk, prev, next
         self.cursor.pane, self.cursor.pos = pane, pos
         self.cursor.line, self.cursor.offset = line, offset
+        for t in self.textview[:self.num_panes]:
+            t.queue_draw()
+        for lm in self.linkmap[:self.num_panes - 1]:
+            lm.queue_draw()
 
     def on_textview_focus_in_event(self, view, event):
         self.textview_focussed = view
@@ -769,7 +773,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
         context.clip()
         context.set_line_width(1.0)
 
-        def draw_change(change): # draw background and thin lines
+        def draw_change(change, current=False): # draw background and thin lines
             ypos0 = self._line_to_pixel(pane, change[1]) - visible.y
             context.set_source_rgb(*self.line_colors[change[0]])
             context.move_to(-0.5, ypos0 - 0.5)
@@ -783,11 +787,15 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
                 context.set_source_rgb(*self.fill_colors[change[0]])
                 context.rectangle(0, ypos0, width, ypos1 - ypos0 - 1)
                 context.fill()
+                if current:
+                    context.set_source_rgba(1.0, 1.0, 1.0, 0.25)
+                    context.rectangle(0, ypos0, width, ypos1 - ypos0 - 1)
+                    context.fill()
 
-        for change in self.linediffer.single_changes(pane):
+        for i, change in enumerate(self.linediffer.single_changes(pane)):
             if change[2] < start_line: continue
             if change[1] > end_line: break
-            draw_change(change)
+            draw_change(change, i == self.cursor.chunk)
 
         if textview.is_focus():
             ypos, height = self._line_to_pixel_plus_height(pane, self.cursor.line)
@@ -1193,7 +1201,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
             context.paint()
             context.identity_matrix()
 
-        for c in self.linediffer.pair_changes(which, which + 1):
+        for i, c in enumerate(self.linediffer.pair_changes(which, which + 1)):
             assert c[0] != "equal"
             if c[2] < visible[1] and c[4] < visible[3]: # find first visible chunk
                 continue
@@ -1217,6 +1225,10 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
             context.set_source_rgb(*self.fill_colors[c[0]])
             context.fill_preserve()
 
+            if i == self.cursor.chunk:
+                context.set_source_rgba(1.0, 1.0, 1.0, 0.25)
+                context.fill_preserve()
+
             context.set_source_rgb(*self.line_colors[c[0]])
             context.stroke()
 
-- 
1.6.0.6

