[meld: 1/7] [Issue #78]: Scrolling in central takes screen position in to account
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld: 1/7] [Issue #78]: Scrolling in central takes screen position in to account
- Date: Sun, 3 Nov 2019 00:56:41 +0000 (UTC)
commit 08b4e90e5315b3a9306990fabf4cd1ab548942a6
Author: heikkiket <heikki ketoharju iki fi>
Date: Mon Dec 17 22:04:10 2018 +0000
[Issue #78]: Scrolling in central takes screen position in to account
If scrolling with mouse and currently highlighted change is outside
of the screen, seek next and previous changes outside of screen.
If changes are at the first or last quarter of the textfield,
treat them as they would be outside of screen.
(cherry picked from commit d76eb0e01cbbfc0f1cb1a377e0d532d4d08aec9f)
meld/filediff.py | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 51 insertions(+), 3 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index b178c302..044788b1 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -599,11 +599,59 @@ class FileDiff(Gtk.VBox, MeldDoc):
@Template.Callback()
def on_linkmap_scroll_event(self, linkmap, event):
- self.next_diff(event.direction)
+ self.next_diff(event.direction, use_viewport=True)
- def next_diff(self, direction, centered=False):
+ def next_diff(self, direction, centered=False, use_viewport=False):
+ # use_viewport: seek next and previous diffes based on where
+ # the user is currently scrolling at.
target = (self.cursor.next if direction == Gdk.ScrollDirection.DOWN
- else self.cursor.prev)
+ else self.cursor.prev)
+
+ if use_viewport:
+
+ if target is None:
+ return
+
+ pane = self.cursor.pane
+ text_area = self.textview[pane].get_visible_rect()
+
+ chunk = self.linediffer.get_chunk(target, pane)
+ if not chunk:
+ return
+
+
+ #Count the down top and bottom 25% of the window
+ topedge = text_area.y
+ bottomedge = text_area.y+text_area.height
+
+ topline = self.textview[pane].get_line_at_y(
+ topedge).target_iter.get_line()
+ bottomline = self.textview[pane].get_line_at_y(
+ bottomedge).target_iter.get_line()
+
+ topquarter = self.textview[pane].get_line_at_y(
+ topedge + text_area.height / 4).target_iter.get_line()
+ bottomquarter = self.textview[pane].get_line_at_y(
+ bottomedge - text_area.height / 4).target_iter.get_line()
+
+ while chunk[1] < topquarter and direction == Gdk.ScrollDirection.DOWN:
+ target += 1
+ if(target > self.linediffer.diff_count()):
+ return
+
+ chunk = self.linediffer.get_chunk(target, pane)
+ if not chunk:
+ return
+
+ while chunk[1] > bottomquarter and direction == Gdk.ScrollDirection.UP:
+ target -= 1
+ if target < 0:
+ return
+
+ chunk = self.linediffer.get_chunk(target, pane)
+ if not chunk:
+ return
+
self.go_to_chunk(target, centered=centered)
@Template.Callback()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]