[meld] filediff: Refactor next_diff
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] filediff: Refactor next_diff
- Date: Mon, 30 Dec 2013 21:22:34 +0000 (UTC)
commit f2efad2055814b970a779a844fdd6329236dbfb9
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Dec 21 06:50:42 2013 +1000
filediff: Refactor next_diff
meld/filediff.py | 32 ++++++++++++++------------------
1 files changed, 14 insertions(+), 18 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index a56c399..b80a940 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -1904,33 +1904,29 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.recompute_label()
def next_diff(self, direction, centered=False):
+ target = (self.cursor.next if direction == Gdk.ScrollDirection.DOWN
+ else self.cursor.prev)
+ if target is None:
+ return
+
pane = self._get_focused_pane()
if pane == -1:
if len(self.textview) > 1:
pane = 1
else:
pane = 0
- buf = self.textbuffer[pane]
-
- if direction == Gdk.ScrollDirection.DOWN:
- target = self.cursor.next
- else: # direction == Gdk.ScrollDirection.UP
- target = self.cursor.prev
- if target is None:
+ chunk = self.linediffer.get_chunk(target, pane)
+ if not chunk:
return
- c = self.linediffer.get_chunk(target, pane)
- if c:
- # Warp the cursor to the first line of next chunk
- if self.cursor.line != c[1]:
- buf.place_cursor(buf.get_iter_at_line(c[1]))
- if centered:
- self.textview[pane].scroll_to_mark(
- buf.get_insert(), 0.0, True, 0.5, 0.5)
- else:
- self.textview[pane].scroll_to_mark(
- buf.get_insert(), 0.2, True, 0.5, 0.5)
+ # Warp the cursor to the first line of next chunk
+ buf = self.textbuffer[pane]
+ if self.cursor.line != chunk[1]:
+ buf.place_cursor(buf.get_iter_at_line(chunk[1]))
+ tolerance = 0.0 if centered else 0.2
+ self.textview[pane].scroll_to_mark(
+ buf.get_insert(), tolerance, True, 0.5, 0.5)
def copy_chunk(self, src, dst, chunk, copy_up):
b0, b1 = self.textbuffer[src], self.textbuffer[dst]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]