nicer linewrap algo for the small printer

workspace
Brendan Howell 4 years ago
parent b8c9b11f0c
commit e0ae6b729c

@ -94,9 +94,9 @@ class LogPrinter(logging.Handler):
out_ep=self.printer["outep"]) out_ep=self.printer["outep"])
msg = self.format(record) msg = self.format(record)
#text = textwrap.fill(msg, width=self.printer["textwidth"]) #text = textwrap.fill(msg, width=self.printer["textwidth"])
spliter_regex = r'.{1,' + str(self.printer["textwidth"]) + '}(?:\s+|$)' splitter_regex = r'.{1,' + str(self.printer["textwidth"]) + '}(?:\s+|$)'
out_text = "\r\n".join(line.strip() for line in out_text = "\r\n".join(line.strip() for line in
re.findall(spliter_regex, msg)) re.findall(splitter_regex, msg))
out_text += "\r\n" * 4 out_text += "\r\n" * 4
prn.text(out_text) prn.text(out_text)
prn.cut() prn.cut()
@ -446,7 +446,7 @@ class Bureau(object):
""" """
prn = self._get_small_printer() prn = self._get_small_printer()
spliter_regex = r'.{1,' + str(self.smprint["textwidth"]) + '}(?:\s+|$)' splitter_regex = r'.{1,' + str(self.smprint["textwidth"]) + '}(?:\s+|$)'
out_text = "\r\n".join(line.strip() for line in out_text = "\r\n".join(line.strip() for line in
re.findall(splitter_regex, text)) re.findall(splitter_regex, text))

Loading…
Cancel
Save