parent
7543e3f19e
commit
dcf393d135
|
@ -742,50 +742,7 @@ class WrapLine(Method):
|
||||||
p3 = Point(0, cursor.y)
|
p3 = Point(0, cursor.y)
|
||||||
w.buffer.insert_lines(p3, lines)
|
w.buffer.insert_lines(p3, lines)
|
||||||
w.goto(Point(x, y))
|
w.goto(Point(x, y))
|
||||||
class WrapParagraph(WrapLine):
|
class WrapParagraph(Method):
|
||||||
limit = 80
|
|
||||||
empty_re = regex.whitespace
|
|
||||||
prefix_re = regex.leading_whitespace
|
|
||||||
def _execute(self, w, **vargs):
|
|
||||||
c = w.logical_cursor()
|
|
||||||
y2 = y1 = c.y
|
|
||||||
x2 = x1 = 0
|
|
||||||
line = w.buffer.lines[y1]
|
|
||||||
if self.empty_re.match(line):
|
|
||||||
return
|
|
||||||
|
|
||||||
m = self.prefix_re.match(line)
|
|
||||||
prefix = m.group(0)
|
|
||||||
lines = [line.strip()]
|
|
||||||
y2 += 1
|
|
||||||
|
|
||||||
while y2 + 1 < len(w.buffer.lines):
|
|
||||||
line = w.buffer.lines[y2 + 1]
|
|
||||||
if self.empty_re.match(line):
|
|
||||||
break
|
|
||||||
y2 += 1
|
|
||||||
s = line.strip()
|
|
||||||
if s:
|
|
||||||
lines.append(s)
|
|
||||||
|
|
||||||
x, y = c.xy()
|
|
||||||
longline = ' '.join(lines)
|
|
||||||
lines, x, y = self._wrap_line(longline, x, y)
|
|
||||||
if lines is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
p1 = Point(x1, y1)
|
|
||||||
if y2 == len(w.buffer.lines):
|
|
||||||
y2 -= 1
|
|
||||||
x2 = len(w.buffer.lines[y2])
|
|
||||||
p2 = Point(x2, y2)
|
|
||||||
w.buffer.delete(p1, p2)
|
|
||||||
w.buffer.insert_lines(Point(0, c.y), lines)
|
|
||||||
while y >= len(w.buffer.lines):
|
|
||||||
x = 0
|
|
||||||
w.buffer.insert_string(Point(len(w.buffer.lines[-1], len(w.buffer.lines) - 1)), '\n')
|
|
||||||
w.goto(Point(x, y))
|
|
||||||
class WrapParagraph2(Method):
|
|
||||||
limit = 80
|
limit = 80
|
||||||
valid_re = re.compile('^( *)([^ ].*)$')
|
valid_re = re.compile('^( *)([^ ].*)$')
|
||||||
empty_re = regex.whitespace
|
empty_re = regex.whitespace
|
||||||
|
|
|
@ -40,7 +40,7 @@ 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 MuttWrapParagraph(method.WrapParagraph2):
|
class MuttWrapParagraph(method.WrapParagraph):
|
||||||
limit = 72
|
limit = 72
|
||||||
empty_re = re.compile('^(?: *>.*| *)$')
|
empty_re = re.compile('^(?: *>.*| *)$')
|
||||||
|
|
||||||
|
|
|
@ -610,7 +610,6 @@ class PerlHashCleanup2(Method):
|
||||||
def _parse_assign(self, w, **vargs):
|
def _parse_assign(self, w, **vargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#class PerlWrapParagraph(WrapParagraph):
|
|
||||||
class PerlWrapParagraph(Method):
|
class PerlWrapParagraph(Method):
|
||||||
'''Wrap Comments and POD'''
|
'''Wrap Comments and POD'''
|
||||||
# enumerations for line types
|
# enumerations for line types
|
||||||
|
|
|
@ -87,4 +87,3 @@ class RstInsertSpace(TextInsertSpace):
|
||||||
limit = 75
|
limit = 75
|
||||||
class RstWrapParagraph(method.WrapParagraph):
|
class RstWrapParagraph(method.WrapParagraph):
|
||||||
limit = 75
|
limit = 75
|
||||||
#spacer = RstInsertSpace
|
|
||||||
|
|
|
@ -50,9 +50,9 @@ class Text(mode.Fundamental):
|
||||||
mode.Fundamental.__init__(self, w)
|
mode.Fundamental.__init__(self, w)
|
||||||
self.add_action_and_bindings(LearnWord(), ('C-c l',))
|
self.add_action_and_bindings(LearnWord(), ('C-c l',))
|
||||||
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(TextWrapParagraph(), ('M-q',))
|
||||||
|
|
||||||
class TextWrapParagraph(method.WrapParagraph2):
|
class TextWrapParagraph(method.WrapParagraph):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class TextInsertSpace(method.Method):
|
class TextInsertSpace(method.Method):
|
||||||
|
|
Loading…
Reference in New Issue