branch : pmacs2
This commit is contained in:
moculus 2008-03-20 15:04:04 +00:00
parent bfdfedfa09
commit 8b403b9455
1 changed files with 16 additions and 0 deletions

View File

@ -627,6 +627,22 @@ class WrapParagraph(Method):
w.insert_lines(p1, newlines)
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):
'''Justify text with the previous line right from the cursor by whitespace'''
def _execute(self, w, **vargs):