parent
ee00958ea1
commit
ec2d1ab3ea
26
method.py
26
method.py
|
@ -713,8 +713,11 @@ class WrapLine(Method):
|
|||
if lines is None:
|
||||
return
|
||||
#w.buffer.delete_line(cursor.y)
|
||||
w.buffer.delete(Point(0, cursor.y), Point(len(w.buffer.lines[cursor.y]), cursor.y))
|
||||
w.buffer.insert_lines(Point(0, cursor.y), lines)
|
||||
p1 = Point(0, cursor.y)
|
||||
p2 = Point(len(w.buffer.lines[cursor.y]), cursor.y)
|
||||
w.buffer.delete(p1, p2)
|
||||
p3 = Point(0, cursor.y)
|
||||
w.buffer.insert_lines(p3, lines)
|
||||
w.goto(Point(x, y))
|
||||
class WrapParagraph(WrapLine):
|
||||
limit = 80
|
||||
|
@ -738,7 +741,9 @@ class WrapParagraph(WrapLine):
|
|||
if self.empty_re.match(line):
|
||||
break
|
||||
y2 += 1
|
||||
lines.append(line.strip())
|
||||
s = line.strip()
|
||||
if s:
|
||||
lines.append(s)
|
||||
|
||||
x, y = c.xy()
|
||||
longline = ' '.join(lines)
|
||||
|
@ -746,8 +751,16 @@ class WrapParagraph(WrapLine):
|
|||
if lines is None:
|
||||
return
|
||||
|
||||
w.buffer.delete(Point(x1, y1), Point(x2, y2))
|
||||
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
|
||||
|
@ -767,6 +780,11 @@ class WrapParagraph2(Method):
|
|||
DeleteRightWhitespace().execute(w)
|
||||
w.goto(old_cursor)
|
||||
self.wrapper().execute(w)
|
||||
new_cursor = w.logical_cursor()
|
||||
if new_cursor.y >= len(w.buffer.lines):
|
||||
while new_cursor.y >= len(w.buffer.lines):
|
||||
w.buffer.insert_string(Point(len(w.buffer.lines[-1]), len(w.buffer.lines) - 1), "\n")
|
||||
w.goto(Point(0, new_cursor.y))
|
||||
|
||||
class JustifyRight(Method):
|
||||
'''Justify text with the previous line right from the cursor by whitespace'''
|
||||
|
|
|
@ -55,5 +55,18 @@ class Scheme(mode.Fundamental):
|
|||
self.add_bindings('close-paren', (')',))
|
||||
self.add_bindings('close-brace', ('}',))
|
||||
self.add_bindings('close-bracket', (']',))
|
||||
self.add_action_and_bindings(SchemeCheckSyntax(), ('C-c s',))
|
||||
|
||||
class SchemeCheckSyntax(method.Method):
|
||||
'''Check the syntax of a scheme file'''
|
||||
def _execute(self, w, **vargs):
|
||||
app = w.application
|
||||
cmd = "guile -s %r" % (w.buffer.path)
|
||||
(status, output) = commands.getstatusoutput(cmd)
|
||||
if status == 0:
|
||||
app.set_error("Syntax OK")
|
||||
app.data_buffer("*Scheme-Check-Syntax*", output, switch_to=False)
|
||||
else:
|
||||
app.data_buffer("*Scheme-Check-Syntax*", output)
|
||||
|
||||
install = Scheme.install
|
||||
|
|
|
@ -49,7 +49,7 @@ class Text(mode.Fundamental):
|
|||
def __init__(self, w):
|
||||
mode.Fundamental.__init__(self, w)
|
||||
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.WrapParagraph(), ('M-q',))
|
||||
|
||||
class TextInsertSpace(method.Method):
|
||||
|
|
|
@ -16,6 +16,7 @@ class Text2(mode.text.Text):
|
|||
modename = 'Text2'
|
||||
grammar = Text2Grammar
|
||||
extensions = ['.txt']
|
||||
extensions = []
|
||||
colors = {
|
||||
'email': ('cyan', 'default'),
|
||||
'url': ('green', 'default'),
|
||||
|
|
Loading…
Reference in New Issue