From 938e1db9631a89c2de526e1de21a55b1469da03d Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 19 Jun 2019 10:34:42 +0100 Subject: add `margin` arg to ParsedLine.truncate so commands/outs.py doesn't do it manually and cause potential issues with multi-byte chars --- src/IRCLine.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/IRCLine.py b/src/IRCLine.py index f713eecd..5aae1f53 100644 --- a/src/IRCLine.py +++ b/src/IRCLine.py @@ -111,13 +111,13 @@ class ParsedLine(object): else: return line - def _line_max(self, hostmask: str) -> int: - return LINE_MAX-len((":%s " % hostmask).encode("utf8")) - def truncate(self, hostmask: str) -> typing.Tuple[str, str]: + def _line_max(self, hostmask: str, margin: int) -> int: + return LINE_MAX-len((":%s " % hostmask).encode("utf8"))-margin + def truncate(self, hostmask: str, margin: int=0) -> typing.Tuple[str, str]: valid_bytes = b"" valid_index = -1 - line_max = self._line_max(hostmask) + line_max = self._line_max(hostmask, margin) tags_formatted, line_formatted = self._format() for i, char in enumerate(line_formatted): -- cgit v1.3.1-10-gc9f91