Skip to content

Commit

Permalink
Grey is really black, so add as black
Browse files Browse the repository at this point in the history
Let's keep grey as a deprecated value, and can keep it around
indefinitely, no pressing need to remove it.

Co-authored-by: Hendrik Buschmeier <hbuschme@uni-bielefeld.de>
  • Loading branch information
hugovk and hbuschme committed Nov 2, 2022
1 parent 0f80be5 commit f1c08c3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/termcolor/__main__.py
Expand Up @@ -7,7 +7,7 @@
if __name__ == "__main__":
print(f"Current terminal type: {os.getenv('TERM')}")
print("Test basic colors:")
cprint("Grey color", "grey")
cprint("Black color", "black")
cprint("Red color", "red")
cprint("Green color", "green")
cprint("Yellow color", "yellow")
Expand All @@ -18,18 +18,18 @@
print("-" * 78)

print("Test highlights:")
cprint("On grey color", on_color="on_grey")
cprint("On black color", on_color="on_black")
cprint("On red color", on_color="on_red")
cprint("On green color", on_color="on_green")
cprint("On yellow color", on_color="on_yellow")
cprint("On blue color", on_color="on_blue")
cprint("On magenta color", on_color="on_magenta")
cprint("On cyan color", on_color="on_cyan")
cprint("On white color", color="grey", on_color="on_white")
cprint("On white color", color="black", on_color="on_white")
print("-" * 78)

print("Test attributes:")
cprint("Bold grey color", "grey", attrs=["bold"])
cprint("Bold black color", "black", attrs=["bold"])
cprint("Dark red color", "red", attrs=["dark"])
cprint("Underline green color", "green", attrs=["underline"])
cprint("Blink yellow color", "yellow", attrs=["blink"])
Expand All @@ -48,5 +48,5 @@
print("-" * 78)

print("Test mixing:")
cprint("Underline red on grey color", "red", "on_grey", ["underline"])
cprint("Underline red on black color", "red", "on_black", ["underline"])
cprint("Reversed green on red color", "green", "on_red", ["reverse"])
12 changes: 7 additions & 5 deletions src/termcolor/termcolor.py
Expand Up @@ -53,7 +53,8 @@ def __getattr__(name: str) -> list[str]:


HIGHLIGHTS = {
"on_grey": 40,
"on_black": 40,
"on_grey": 40, # Actually black but kept for backwards compatibility
"on_red": 41,
"on_green": 42,
"on_yellow": 43,
Expand All @@ -64,7 +65,8 @@ def __getattr__(name: str) -> list[str]:
}

COLORS = {
"grey": 30,
"black": 30,
"grey": 30, # Actually black but kept for backwards compatibility
"red": 31,
"green": 32,
"yellow": 33,
Expand Down Expand Up @@ -102,16 +104,16 @@ def colored(
"""Colorize text.
Available text colors:
grey, red, green, yellow, blue, magenta, cyan, white.
black, red, green, yellow, blue, magenta, cyan, white.
Available text highlights:
on_grey, on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white.
on_black, on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white.
Available attributes:
bold, dark, underline, blink, reverse, concealed.
Example:
colored('Hello, World!', 'red', 'on_grey', ['bold', 'blink'])
colored('Hello, World!', 'red', 'on_black', ['bold', 'blink'])
colored('Hello, World!', 'green')
"""
if not _can_do_colour():
Expand Down

0 comments on commit f1c08c3

Please sign in to comment.