better mutt/wrapping support

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-03-01 17:10:07 +00:00
parent e87e02e711
commit ea98b0a812
2 changed files with 10 additions and 7 deletions

View File

@ -787,8 +787,6 @@ class WrapParagraph(WrapLine):
w.goto(Point(x, y)) w.goto(Point(x, y))
class WrapParagraph2(Method): class WrapParagraph2(Method):
limit = 80 limit = 80
wrapper = WrapLine
spacer = InsertSpace
empty_re = regex.whitespace empty_re = regex.whitespace
prefix_re = None prefix_re = None
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
@ -855,11 +853,16 @@ class WrapParagraph2(Method):
# translate our cursor according to the line breaks we just did. # translate our cursor according to the line breaks we just did.
(x, y) = oldc.xy() (x, y) = oldc.xy()
k = 0 k = 0
while x > len(newlines[k]): while k < len(newlines) and x > len(newlines[k]):
x = x - len(newlines[k]) - 1 x = x - len(newlines[k]) - 1
y += 1 y += 1
k += 1 k += 1
#raise Exception, (x, y)
# if our cursor is on a new line (past all the newlines) then we should
# be inserting another line so that we preserve the spacing of the
# document.
if k == len(newlines):
newlines.append('')
# kill the old paragraph region, insert the new, and goto the new cursor # kill the old paragraph region, insert the new, and goto the new cursor
w.kill(p1, Point(len(w.buffer.lines[i-1]), i-1)) w.kill(p1, Point(len(w.buffer.lines[i-1]), i-1))

View File

@ -43,10 +43,10 @@ class Mutt(mode.Fundamental):
class MuttWrapLine(method.WrapLine): class MuttWrapLine(method.WrapLine):
limit = 72 limit = 72
#class MuttWrapParagraph(method.WrapParagraph):
class MuttWrapParagraph(method.WrapParagraph2): class MuttWrapParagraph(method.WrapParagraph2):
wrapper = MuttWrapLine wrapper = MuttWrapLine
empty_re = re.compile('^[ >\n]*$') limit = 72
empty_re = re.compile('^(?: *>.*| *)$')
class MuttInsertSpace(mode.text.TextInsertSpace): class MuttInsertSpace(mode.text.TextInsertSpace):
limit = 72 limit = 72