Int: implement fmtc() with right justification

This commit is contained in:
The MMGen Project 2025-11-24 12:48:48 +00:00
commit eec4de2a01
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2

View file

@ -263,6 +263,7 @@ class Int(int, Hilite, InitErrors):
min_val = None
max_val = None
max_digits = None
trunc_ok = False
color = 'red'
def __new__(cls, n, *, base=10):
@ -282,10 +283,10 @@ class Int(int, Hilite, InitErrors):
@classmethod
def fmtc(cls, s, width, /, *, color=False):
return super().fmtc(str(s), width, color=color)
return cls.colorize(s.rjust(width), color=color)
def fmt(self, width, /, *, color=False):
return super().fmtc(str(self), width, color=color)
return self.fmtc(str(self), width, color=color)
def hl(self, **kwargs):
return super().colorize(str(self), **kwargs)