def print_color(self, string, end="\n", **kwargs): """Prints a color string using prompt-toolkit color management.""" if isinstance(string, str): tokens = partial_color_tokenize(string) else: # assume this is a list of (Token, str) tuples and just print tokens = string tokens = PygmentsTokens(tokens) env = XSH.env style_overrides_env = env.get("XONSH_STYLE_OVERRIDES", {}) if HAS_PYGMENTS: self.styler.style_name = env.get("XONSH_COLOR_STYLE") self.styler.override(style_overrides_env) proxy_style = _style_from_pygments_cls( pyghooks.xonsh_style_proxy(self.styler)) else: proxy_style = merge_styles([ _style_from_pygments_dict(DEFAULT_STYLE_DICT), _style_from_pygments_dict(style_overrides_env), ]) ptk_print( tokens, style=proxy_style, end=end, include_default_pygments_style=False, **kwargs, )
def print_color(self, string, end='\n', **kwargs): """Prints a color string using prompt-toolkit color management.""" if isinstance(string, str): tokens = partial_color_tokenize(string) else: # assume this is a list of (Token, str) tuples and just print tokens = string tokens = PygmentsTokens(tokens) if HAS_PYGMENTS: env = builtins.__xonsh_env__ self.styler.style_name = env.get('XONSH_COLOR_STYLE') proxy_style = style_from_pygments_cls(pyghooks.xonsh_style_proxy(self.styler)) else: proxy_style = style_from_pygments_dict(DEFAULT_STYLE_DICT) ptk_print(tokens, style=proxy_style, end=end, include_default_pygments_style=False)
def print_color(self, string, end="\n", **kwargs): """Prints a color string using prompt-toolkit color management.""" if isinstance(string, str): tokens = partial_color_tokenize(string) else: # assume this is a list of (Token, str) tuples and just print tokens = string tokens = PygmentsTokens(tokens) if HAS_PYGMENTS: env = builtins.__xonsh__.env self.styler.style_name = env.get("XONSH_COLOR_STYLE") proxy_style = style_from_pygments_cls( pyghooks.xonsh_style_proxy(self.styler) ) else: proxy_style = style_from_pygments_dict(DEFAULT_STYLE_DICT) ptk_print( tokens, style=proxy_style, end=end, include_default_pygments_style=False )