parent
bfdfedfa09
commit
8b403b9455
|
@ -627,6 +627,22 @@ class WrapParagraph(Method):
|
||||||
w.insert_lines(p1, newlines)
|
w.insert_lines(p1, newlines)
|
||||||
w.goto(Point(x, y))
|
w.goto(Point(x, y))
|
||||||
|
|
||||||
|
class CountWords(Method):
|
||||||
|
'''Count the number of words in the document'''
|
||||||
|
def _execute(self, w, **vargs):
|
||||||
|
wcount = 0
|
||||||
|
pcount = 0
|
||||||
|
inp = False
|
||||||
|
for line in w.buffer.lines:
|
||||||
|
c = len(line.split())
|
||||||
|
if c and not inp:
|
||||||
|
inp = True
|
||||||
|
pcount += 1
|
||||||
|
elif not c and inp:
|
||||||
|
inp = False
|
||||||
|
wcount += c
|
||||||
|
w.set_error("%d words (%d paragraphs) found in the document" % (wcount, pcount))
|
||||||
|
|
||||||
class JustifyRight(Method):
|
class JustifyRight(Method):
|
||||||
'''Justify text with the previous line right from the cursor by whitespace'''
|
'''Justify text with the previous line right from the cursor by whitespace'''
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
|
|
Loading…
Reference in New Issue