Skip to content

Commit

Permalink
Add light shades and dark grey
Browse files Browse the repository at this point in the history
Co-authored-by: Hendrik Buschmeier <hbuschme@uni-bielefeld.de>
  • Loading branch information
hugovk and hbuschme committed Nov 2, 2022
1 parent f1c08c3 commit d703626
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
16 changes: 16 additions & 0 deletions src/termcolor/__main__.py
Expand Up @@ -15,6 +15,14 @@
cprint("Magenta color", "magenta")
cprint("Cyan color", "cyan")
cprint("White color", "white")
cprint("Light grey color", "light_grey")
cprint("Dark grey color", "dark_grey")
cprint("Light red color", "light_red")
cprint("Light green color", "light_green")
cprint("Light yellow color", "light_yellow")
cprint("Light blue color", "light_blue")
cprint("Light magenta color", "light_magenta")
cprint("Light cyan color", "light_cyan")
print("-" * 78)

print("Test highlights:")
Expand All @@ -26,6 +34,14 @@
cprint("On magenta color", on_color="on_magenta")
cprint("On cyan color", on_color="on_cyan")
cprint("On white color", color="black", on_color="on_white")
cprint("On light grey color", on_color="on_light_grey")
cprint("On dark grey color", on_color="on_dark_grey")
cprint("On light red color", on_color="on_light_red")
cprint("On light green color", on_color="on_light_green")
cprint("On light yellow color", on_color="on_light_yellow")
cprint("On light blue color", on_color="on_light_blue")
cprint("On light magenta color", on_color="on_light_magenta")
cprint("On light cyan color", on_color="on_light_cyan")
print("-" * 78)

print("Test attributes:")
Expand Down
28 changes: 24 additions & 4 deletions src/termcolor/termcolor.py
Expand Up @@ -61,7 +61,15 @@ def __getattr__(name: str) -> list[str]:
"on_blue": 44,
"on_magenta": 45,
"on_cyan": 46,
"on_white": 47,
"on_light_grey": 47,
"on_dark_grey": 100,
"on_light_red": 101,
"on_light_green": 102,
"on_light_yellow": 103,
"on_light_blue": 104,
"on_light_magenta": 105,
"on_light_cyan": 106,
"on_white": 107,
}

COLORS = {
Expand All @@ -73,7 +81,15 @@ def __getattr__(name: str) -> list[str]:
"blue": 34,
"magenta": 35,
"cyan": 36,
"white": 37,
"light_grey": 37,
"dark_grey": 90,
"light_red": 91,
"light_green": 92,
"light_yellow": 93,
"light_blue": 94,
"light_magenta": 95,
"light_cyan": 96,
"white": 97,
}


Expand Down Expand Up @@ -104,10 +120,14 @@ def colored(
"""Colorize text.
Available text colors:
black, red, green, yellow, blue, magenta, cyan, white.
black, red, green, yellow, blue, magenta, cyan, white,
light_grey, dark_grey, light_red, light_green, light_yellow, light_blue,
light_magenta, light_cyan.
Available text highlights:
on_black, 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,
on_light_grey, on_dark_grey, on_light_red, on_light_green, on_light_yellow,
on_light_blue, on_light_magenta, on_light_cyan.
Available attributes:
bold, dark, underline, blink, reverse, concealed.
Expand Down
12 changes: 10 additions & 2 deletions tests/test_termcolor.py
Expand Up @@ -56,14 +56,18 @@ def assert_cprint(
@pytest.mark.parametrize(
"color, expected",
[
("black", "\x1b[30mtext\x1b[0m"),
("grey", "\x1b[30mtext\x1b[0m"),
("red", "\x1b[31mtext\x1b[0m"),
("green", "\x1b[32mtext\x1b[0m"),
("yellow", "\x1b[33mtext\x1b[0m"),
("blue", "\x1b[34mtext\x1b[0m"),
("magenta", "\x1b[35mtext\x1b[0m"),
("cyan", "\x1b[36mtext\x1b[0m"),
("white", "\x1b[37mtext\x1b[0m"),
("white", "\x1b[97mtext\x1b[0m"),
("light_grey", "\x1b[37mtext\x1b[0m"),
("dark_grey", "\x1b[90mtext\x1b[0m"),
("light_blue", "\x1b[94mtext\x1b[0m"),
],
)
def test_color(
Expand All @@ -83,14 +87,18 @@ def test_color(
@pytest.mark.parametrize(
"on_color, expected",
[
("on_black", "\x1b[40mtext\x1b[0m"),
("on_grey", "\x1b[40mtext\x1b[0m"),
("on_red", "\x1b[41mtext\x1b[0m"),
("on_green", "\x1b[42mtext\x1b[0m"),
("on_yellow", "\x1b[43mtext\x1b[0m"),
("on_blue", "\x1b[44mtext\x1b[0m"),
("on_magenta", "\x1b[45mtext\x1b[0m"),
("on_cyan", "\x1b[46mtext\x1b[0m"),
("on_white", "\x1b[47mtext\x1b[0m"),
("on_white", "\x1b[107mtext\x1b[0m"),
("on_light_grey", "\x1b[47mtext\x1b[0m"),
("on_dark_grey", "\x1b[100mtext\x1b[0m"),
("on_light_blue", "\x1b[104mtext\x1b[0m"),
],
)
def test_on_color(
Expand Down

0 comments on commit d703626

Please sign in to comment.