mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
color
This commit is contained in:
parent
86d3f9427e
commit
729f55238e
2 changed files with 27 additions and 1 deletions
23
news/printx_color.rst
Normal file
23
news/printx_color.rst
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
**Added:**
|
||||||
|
|
||||||
|
* builtins: Added color to printx e.g. ``printx('Good', color='GREEN')``.
|
||||||
|
|
||||||
|
**Changed:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Deprecated:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Removed:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Fixed:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Security:**
|
||||||
|
|
||||||
|
* <news item>
|
|
@ -2018,11 +2018,14 @@ def format_color(string, **kwargs):
|
||||||
return ansi_partial_color_format(string, style=style)
|
return ansi_partial_color_format(string, style=style)
|
||||||
|
|
||||||
|
|
||||||
def print_color(string, **kwargs):
|
def print_color(string, color=None, **kwargs):
|
||||||
"""Prints a string that may contain colors. This dispatched to the shell
|
"""Prints a string that may contain colors. This dispatched to the shell
|
||||||
method of the same name. Colors will be formatted if they have not already
|
method of the same name. Colors will be formatted if they have not already
|
||||||
been.
|
been.
|
||||||
"""
|
"""
|
||||||
|
if color:
|
||||||
|
string = f'{{{color}}}{string}{{RESET}}'
|
||||||
|
|
||||||
if hasattr(xsh.shell, "shell"):
|
if hasattr(xsh.shell, "shell"):
|
||||||
xsh.shell.shell.print_color(string, **kwargs)
|
xsh.shell.shell.print_color(string, **kwargs)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue