nicer linewrap algo for the small printer

workspace
Brendan Howell 4 years ago
parent a6b74ad065
commit b0fea04653

@ -96,7 +96,7 @@ class LogPrinter(logging.Handler):
#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+|$)' spliter_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, text)) re.findall(spliter_regex, msg))
out_text += "\r\n" * 4 out_text += "\r\n" * 4
prn.text(out_text) prn.text(out_text)
prn.cut() prn.cut()

Loading…
Cancel
Save