[gedit] Scroll full snippet in view if possible



commit 6901f736e9a4fe1a8609d902be74c948b7e24013
Author: Jesse van den Kieboom <jesse icecrew nl>
Date:   Sun Nov 15 18:06:11 2009 +0100

    Scroll full snippet in view if possible

 plugins/snippets/snippets/Document.py |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/plugins/snippets/snippets/Document.py b/plugins/snippets/snippets/Document.py
index 424367f..53f08bb 100644
--- a/plugins/snippets/snippets/Document.py
+++ b/plugins/snippets/snippets/Document.py
@@ -553,6 +553,19 @@ class Document:
                 else:
                         self.goto_placeholder(self.active_placeholder, sn.placeholders[keys[0]])
 
+                if sn in self.active_snippets:
+                        # Check if we can get end_iter in view without moving the
+                        # current cursor position out of view
+                        cur = buf.get_iter_at_mark(buf.get_insert())
+                        last = sn.end_iter()
+
+                        curloc = self.view.get_iter_location(cur)
+                        lastloc = self.view.get_iter_location(last)
+
+                        if (lastloc.y + lastloc.height) - curloc.y <= \
+                           self.view.get_visible_rect().height:
+                                self.view.scroll_mark_onscreen(sn.end_mark)
+
                 buf.end_user_action()
                 self.view.grab_focus()
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]