def Render(self, target, foreground=None, background=None):
"""Decorate the string with the ansii escapes for the color."""
if (not self.terminal_capable or
foreground not in self.COLOR_MAP or
background not in self.COLOR_MAP):
return utils.SmartUnicode(target)
escape_seq = ""
if background:
escape_seq += self.tparm(
["setab", "setb"], self.COLOR_MAP[background])
if foreground:
escape_seq += self.tparm(
["setaf", "setf"], self.COLOR_MAP[foreground])
return (escape_seq + utils.SmartUnicode(target) +
self.tparm(["sgr0"]))
评论列表
文章目录