fixed annoying split window issue

--HG--
branch : pmacs2
This commit is contained in:
moculus 2007-07-30 15:19:17 +00:00
parent fd05e219b8
commit 3f01d10bb2
1 changed files with 18 additions and 2 deletions

View File

@ -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()