[meld] filediff: After undo/redo, scroll the newly-placed cursor onscreen
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] filediff: After undo/redo, scroll the newly-placed cursor onscreen
- Date: Sat, 2 Apr 2016 21:45:00 +0000 (UTC)
commit 0b9de7f066ceffcd9bb55481d913b03daf154875
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Apr 3 07:40:22 2016 +1000
filediff: After undo/redo, scroll the newly-placed cursor onscreen
Because a single undo/redo action can affect multiple buffers (e.g.,
merge-all actions) we make sure we scroll the cursors for all
affected buffers onscreen.
meld/filediff.py | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index d19fc3b..357fb8d 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -860,13 +860,24 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
self.emit('close', 0)
return response
+ def _scroll_to_actions(self, actions):
+ """Scroll all views affected by *actions* to the current cursor"""
+
+ affected_buffers = set(a.buffer for a in actions)
+ for buf in affected_buffers:
+ buf_index = self.textbuffer.index(buf)
+ view = self.textview[buf_index]
+ view.scroll_mark_onscreen(buf.get_insert())
+
def on_undo_activate(self):
if self.undosequence.can_undo():
- self.undosequence.undo()
+ actions = self.undosequence.undo()
+ self._scroll_to_actions(actions)
def on_redo_activate(self):
if self.undosequence.can_redo():
- self.undosequence.redo()
+ actions = self.undosequence.redo()
+ self._scroll_to_actions(actions)
def on_text_insert_text(self, buf, it, text, textlen):
text = text_type(text, 'utf8')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]