branch : pmacs2
This commit is contained in:
moculus 2008-03-06 01:35:06 +00:00
parent 47a35eb0c7
commit 740fbb85e9
3 changed files with 7 additions and 17 deletions

View File

@ -853,17 +853,11 @@ 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 k < len(newlines) and x > len(newlines[k]): while k < len(newlines) - 1 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
# 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))
w.insert_lines(p1, newlines) w.insert_lines(p1, newlines)

View File

@ -40,16 +40,11 @@ class Mutt(mode.Fundamental):
self.add_action_and_bindings(MuttWrapParagraph(), ('M-q',)) self.add_action_and_bindings(MuttWrapParagraph(), ('M-q',))
self.add_action_and_bindings(MuttInsertSpace(), ('SPACE',)) self.add_action_and_bindings(MuttInsertSpace(), ('SPACE',))
class MuttWrapLine(method.WrapLine):
limit = 72
class MuttWrapParagraph(method.WrapParagraph2): class MuttWrapParagraph(method.WrapParagraph2):
wrapper = MuttWrapLine
limit = 72 limit = 72
empty_re = re.compile('^(?: *>.*| *)$') empty_re = re.compile('^(?: *>.*| *)$')
class MuttInsertSpace(mode.text.TextInsertSpace): class MuttInsertSpace(mode.text.TextInsertSpace):
limit = 72
wrapper = MuttWrapParagraph wrapper = MuttWrapParagraph
install = Mutt.install install = Mutt.install

View File

@ -52,16 +52,17 @@ class Text(mode.Fundamental):
self.add_action_and_bindings(TextInsertSpace(), ('SPACE',)) self.add_action_and_bindings(TextInsertSpace(), ('SPACE',))
self.add_action_and_bindings(method.WrapParagraph2(), ('M-q',)) self.add_action_and_bindings(method.WrapParagraph2(), ('M-q',))
class TextWrapParagraph(method.WrapParagraph2):
pass
class TextInsertSpace(method.Method): class TextInsertSpace(method.Method):
limit = 80 wrapper = TextWrapParagraph
#wrapper = method.WrapParagraph
wrapper = method.WrapParagraph2
def execute(self, w, **vargs): def execute(self, w, **vargs):
w.insert_string_at_cursor(' ')
cursor = w.logical_cursor() cursor = w.logical_cursor()
i = cursor.y i = cursor.y
if len(w.buffer.lines[i]) > self.limit: if len(w.buffer.lines[i]) > self.wrapper.limit:
self.wrapper().execute(w) self.wrapper().execute(w)
w.insert_string_at_cursor(' ')
class LearnWord(method.Method): class LearnWord(method.Method):
def execute(self, w, **vargs): def execute(self, w, **vargs):