From 3f01d10bb249f7ef1c5f79be7900fe997e432589 Mon Sep 17 00:00:00 2001 From: moculus Date: Mon, 30 Jul 2007 15:19:17 +0000 Subject: [PATCH] fixed annoying split window issue --HG-- branch : pmacs2 --- window2.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/window2.py b/window2.py index f086339..6652f28 100644 --- a/window2.py +++ b/window2.py @@ -160,6 +160,7 @@ class Window(object): (x, y) = self.logical_cursor().xy() l = len(newlines) assert l > 0, repr(newlines) + visible = self.point_is_visible(p) if l > 1: if y > p.y: self.cursor = Point(x, y + l - 1) @@ -167,6 +168,10 @@ class Window(object): self.cursor = Point(len(newlines[-1]) + x - p.x, y + l - 1) elif y == p.y and x >= p.x: self.cursor = Point(x + len(newlines[0]), y) + + if not visible and l > 1 and self.first.y > p.y: + self.first = Point(self.first.x, self.first.y + l - 1) + self.redraw() self.mode.region_added(p, newlines) self.assure_visible_cursor() @@ -175,14 +180,25 @@ class Window(object): def region_removed(self, p1, p2): cursor = self.logical_cursor() (x, y) = cursor.xy() + visible = self.point_is_visible(p2) + + xdelta = p2.x - p1.x + ydelta = p2.y - p1.y + if cursor < p1: pass elif cursor < p2: self.cursor = p1 elif cursor.y == p2.y: - self.cursor = Point(self.cursor.x - p2.x + p1.x, p1.y) + #self.cursor = Point(self.cursor.x - p2.x + p1.x, p1.y) + self.cursor = Point(self.cursor.x - xdelta, p1.y) else: - self.cursor = Point(self.cursor.x, self.cursor.y - p2.y + p1.y) + #self.cursor = Point(self.cursor.x, self.cursor.y - p2.y + p1.y) + self.cursor = Point(self.cursor.x, self.cursor.y - ydelta) + + if not visible and ydelta and self.first.y > p2.y: + self.first = Point(self.first.x, self.first.y - ydelta) + self.redraw() self.mode.region_removed(p1, p2) self.assure_visible_cursor()