news, docs, black

This commit is contained in:
Anthony Scopatz 2019-03-07 14:56:56 -08:00
parent d8cb53ae2f
commit 33e57f4317
4 changed files with 58 additions and 5 deletions

View file

@ -1495,11 +1495,26 @@ or ``{BOLD_BLUE}``. Colors have the form shown below:
and ``BACKGROUND_#123456`` can both be used.
* ``bg#HEX`` or ``BG#HEX`` are shortcuts for setting a background hex color.
Thus you can set ``bg#0012ab`` or the uppercase version.
* ``BOLD_`` is a prefix qualifier that may be used with any foreground color.
* ``BOLD_`` is a prefix modifier that increases the intesnity of the font.
It may be used with any foreground color.
For example, ``BOLD_RED`` and ``BOLD_#112233`` are OK!
* ``FAINT_`` is a prefix modifier that decreases the intesnity of the font.
For example, ``FAINT_YELLOW``.
* ``ITALIC_`` is a prefix modifier that switches to an italic font.
For example, ``ITALIC_BLUE``.
* ``UNDERLINE_`` is a prefix qualifier that also may be used with any
foreground color. For example, ``UNDERLINE_GREEN``.
* Or any other combination of qualifiers, such as
* ``SLOWBLINK_`` is a prefix modifier makes the text blink, slowly.
For example, ``SLOWBLINK_PURPLE``.
* ``FASTBLINK_`` is a prefix modifier makes the text blink, quickly.
For example, ``FASTBLINK_CYAN``.
* ``INVERT_`` is a prefix modifier swaps the foreground and background colors.
For example, ``INVERT_WHITE``.
* ``CONCEAL_`` is a prefix modifier which hides the text. This may not be
widely supported. For example, ``CONCEAL_BLACK``.
* ``STRIKETHROUGH_`` is a prefix modifier which draws a line through the text.
For example, ``STRIKETHROUGH_RED``.
* Or any other combination of modifiers, such as
``BOLD_UNDERLINE_INTENSE_BLACK``, which is the most metal color you
can use!

38
news/bad-colors.rst Normal file
View file

@ -0,0 +1,38 @@
**Added:**
* Support for more ANSI escape sequece modifers allowed in color names.
The current modifiers now allowed are: BOLD, FAINT, ITALIC, UNDERLINE,
SLOWBLINK, FASTBLINK, INVERT, CONCEAL, and STRIKETHROUGH.
* New ``ansi_tools.ansi_color_name_to_escape_code()`` function for
converting a color name to an ANSI escape code.
* ``color_tools.RE_XONSH_COLOR`` is a regular expression for matching
xonsh color names.
* ``color_tools.iscolor()`` is a simple function for testing whether a
string is a valid color name or not.
* The ``tools.all_permutations()`` function yeilds all possible permutations
of an iterable, including removals.
**Changed:**
* ANSI color styles may now defined simply by their plain and intense colors.
* ``SET_FOREGROUND_3INTS_`` renamed to ``SET_FOREGROUND_FAINT_``,
``SET_BACKGROUND_3INTS_`` renamed to ``SET_BACKGROUND_FAINT_``,
``SET_FOREGROUND_SHORT_`` renamed to ``SET_FOREGROUND_SLOWBLINK_``, and
``SET_BACKGROUND_SHORT_`` renamed to ``SET_BACKGROUND_SLOWBLINK_``.
**Deprecated:**
* <news item>
**Removed:**
* ``ansi_tools.ANSI_REVERSE_COLOR_NAME_TRANSLATIONS`` removed, as it is
no longer needed.
**Fixed:**
* Fixed issues where ``$LS_COLORS`` could not convert valid ANSI colors.
**Security:**
* <news item>

View file

@ -322,7 +322,7 @@ def ansi_color_escape_code_to_name(escape_code, style, reversed_style=None):
# check if we have pre- & post-fixes to apply to the last, non-background element
prefixes += n
if prefixes.endswith("_"):
for i in range(-1, -len(norm_names)-1, -1):
for i in range(-1, -len(norm_names) - 1, -1):
if "BACKGROUND_" not in norm_names[i]:
norm_names[i] = prefixes + norm_names[i]
break

View file

@ -50,7 +50,7 @@ def RE_XONSH_COLOR():
# colors
r"(?P<color>BLACK|RED|GREEN|YELLOW|BLUE|PURPLE|CYAN|WHITE|INTENSE_BLACK|"
r"INTENSE_RED|INTENSE_GREEN|INTENSE_YELLOW|INTENSE_BLUE|INTENSE_PURPLE|"
r"INTENSE_CYAN|INTENSE_WHITE|#" + hex + "{3}|#" + hex +"{6})"
r"INTENSE_CYAN|INTENSE_WHITE|#" + hex + "{3}|#" + hex + "{6})"
)
bghex = (
"bg#" + hex + "{3}|"
@ -298,7 +298,7 @@ def CLUT():
("220", "ffd700"),
("221", "ffd75f"),
("222", "ffd787"),
("223", "ffd7aff"),
("223", "ffd7af"),
("224", "ffd7d7"),
("225", "ffd7ff"),
("226", "ffff00"),