def run(self):
# print ('running:'+str(time.time()))
Pref.running = True
if self.syntax and self.syntax in Pref.strip:
for item in Pref.strip[self.syntax]:
for k in range(len(self.content)):
self.content[k] = re.sub(item, '', self.content[k])
self.content_line = re.sub(item, '', self.content_line)
self.word_count = sum([self.count(region) for region in self.content])
if Pref.enable_count_chars:
if Pref.char_ignore_whitespace:
self.char_count = sum([len(''.join(region.split())) for region in self.content])
else:
self.char_count = sum([len(region) for region in self.content])
if Pref.enable_line_word_count:
self.word_count_line = self.count(self.content_line)
if Pref.enable_line_char_count:
if Pref.char_ignore_whitespace:
self.chars_in_line = len(''.join(self.content_line.split()))
else:
self.chars_in_line = len(self.content_line)
if not self.on_selection:
vs = self.view.settings()
ws = vs.get('WordCount', wsd)
ws['count'] = self.word_count
vs.set('WordCount', ws)
sublime.set_timeout(lambda:self.on_done(), 0)
评论列表
文章目录