termstr: Let termstr's style be given with optional arguments

This commit is contained in:
Andrew Hamilton 2022-10-19 14:03:21 +10:00
parent 6deb413090
commit b82dbc3d71
2 changed files with 4 additions and 1 deletions

View file

@ -211,7 +211,7 @@ def join(seperator, parts):
class TermStr(collections.UserString):
def __init__(self, data, style=CharStyle()):
def __init__(self, data, style=CharStyle(), **kwargs):
if isinstance(style, tuple):
self.data = data
self.style = style
@ -220,6 +220,8 @@ class TermStr(collections.UserString):
self.data, self.style = data.data, data.style
except AttributeError:
self.data = _pad_wide_chars(data).expandtabs()
if kwargs != {}:
style = CharStyle(**kwargs)
self.style = (style,) * len(self.data)
@classmethod