termstr: Make center method match str's center.

- Fixes wiggling titles in fill3 borders.
This commit is contained in:
Andrew Hamilton 2022-04-18 00:23:23 +10:00
parent 0d6dbacd7d
commit 4f4b7c80f3
5 changed files with 5 additions and 7 deletions

View file

@ -349,9 +349,7 @@ class TermStr(collections.UserString):
return self.__class__(fillchar * (width - len(self.data))) + self
def center(self, width, fillchar=" "):
left_width = (width - len(self.data)) // 2
if left_width < 1:
return self
left_width = round((width - len(self.data)) / 2)
return (self.__class__(fillchar * left_width) + self +
self.__class__(fillchar * (width - left_width - len(self.data))))