# -*- coding: utf-8 -*-

"""
examples.advanced_colors
~~~~~~~~~~~~~~~~~~~~~~~~

Use familiar API of the `termcolor.colored` function to apply any
color, highlight, attribute or their mix to your yaspin spinner.
"""

import time

from yaspin import yaspin
from yaspin.spinners import Spinners
from yaspin.termcolor import colored


def test_highlights():
    test_items = [
        ("On gray color", lambda frame: colored(frame, on_color="on_grey")),
        ("On red color", lambda frame: colored(frame, on_color="on_red")),
        ("On green color", lambda frame: colored(frame, on_color="on_green")),
        (
            "On yellow color",
            lambda frame: colored(frame, on_color="on_yellow"),
        ),
        ("On blue color", lambda frame: colored(frame, on_color="on_blue")),
        (
            "On magenta color",
            lambda frame: colored(frame, on_color="on_magenta"),
        ),
        ("On cyan color", lambda frame: colored(frame, on_color="on_cyan")),
        ("On white color", lambda frame: colored(frame, on_color="on_white")),
    ]
    for text, color_func in test_items:
        with yaspin(Spinners.bouncingBall, text=text, color=color_func):
            time.sleep(2)


def test_attributes():
    test_items = [
        (
            "Bold gray color",
            lambda frame: colored(frame, "grey", attrs=["bold"]),
        ),
        (
            "Dark red color",
            lambda frame: colored(frame, "red", attrs=["dark"]),
        ),
        (
            "Underline green color",
            lambda frame: colored(frame, "green", attrs=["underline"]),
        ),
        (
            "Blink yellow color",
            lambda frame: colored(frame, "yellow", attrs=["blink"]),
        ),
        (
            "Reversed blue color",
            lambda frame: colored(frame, "blue", attrs=["reverse"]),
        ),
        (
            "Concealed magenta color",
            lambda frame: colored(frame, "magenta", attrs=["concealed"]),
        ),
        (
            "Bold underline reverse cyan color",
            lambda frame: colored(
                frame, "cyan", attrs=["bold", "underline", "reverse"]
            ),
        ),
        (
            "Dark blink concealed white color",
            lambda frame: colored(
                frame, "white", attrs=["dark", "blink", "concealed"]
            ),
        ),
    ]
    for text, color_func in test_items:
        with yaspin(Spinners.bouncingBar, text=text, color=color_func):
            time.sleep(2)


def test_mixing():
    test_items = [
        (
            "Underline red on grey color",
            lambda frame: colored(
                frame, "red", "on_grey", attrs=["underline"]
            ),
        ),
        (
            "Reversed green on red color",
            lambda frame: colored(frame, "green", "on_red", attrs=["reverse"]),
        ),
    ]
    for text, color_func in test_items:
        with yaspin(Spinners.pong, text=text, color=color_func):
            time.sleep(2)


def main():
    test_highlights()
    test_attributes()
    test_mixing()


if __name__ == "__main__":
    main()

@@ -252,953 +252,295 @@
 pin%0A
-from yaspin.spinners import Spinners%0Afrom yaspin.termcolor import colored%0A%0A%0Adef test_highlights():%0A    test_items = %5B%0A        (%22On gray color%22, lambda frame: colored(frame, on_color=%22on_grey%22)),%0A        (%22On red color%22, lambda frame: colored(frame, on_color=%22on_red%22)),%0A        (%22On green color%22, lambda frame: colored(frame, on_color=%22on_green%22)),%0A        (%0A            %22On yellow color%22,%0A            lambda frame: colored(frame, on_color=%22on_yellow%22),%0A        ),%0A        (%22On blue color%22, lambda frame: colored(frame, on_color=%22on_blue%22)),%0A        (%0A            %22On magenta color%22,%0A            lambda frame: colored(frame, on_color=%22on_magenta%22),%0A        ),%0A        (%22On cyan color%22, lambda frame: colored(frame, on_color=%22on_cyan%22)),%0A        (%22On
+%0A%0Adef white_shark():%0A    # Set with attributes%0A    with yaspin().white.bold.shark.on_blue as sp:%0A        sp.text = %22White bold shark in a blue sea %F0%9F%A6%88%22%0A        time.sleep(5)%0A%0A%0Adef ping_pong():%0A    # Set
  w
-h
 it
-e color%22, lambda frame: colored(frame, on_color=%22on_white%22)),%0A    %5D%0A    for text, color_func in test_items:%0A        with yaspin(Spinners.bouncingBall, text=text, color=color_func):%0A  
+h attributes%0A    with yaspin(text=%22%F0%9F%8F%93%22).yellow.bold.underline.pong.on_blue:%0A
         
   ti
@@ -527,34 +527,32 @@
 n_blue:%0A        
-  
 time.sleep(2)%0A%0A%0A
@@ -542,33 +542,33 @@
  time.sleep(
-2
+5
 )%0A%0A%0Adef 
 test_attribu
@@ -559,1884 +559,331 @@
 def 
-test_attributes():%0A    test_items = %5B%0A        (%0A            %22Bold gray color%22,%0A            lambda frame: colored(frame, %22grey%22, attrs=%5B%22bold%22%5D),%0A        ),%0A        (%0A            %22Dark red color%22,%0A            lambda frame: colored(frame, %22red%22, attrs=%5B%22dark%22%5D),%0A        ),%0A        (%0A            %22Underline green color%22,%0A            lambda frame: colored(frame, %22green%22, attrs=%5B%22underline%22%5D),%0A        ),%0A        (%0A            %22Blink yellow color%22,%0A            lambda frame: colored(frame, %22yellow%22, attrs=%5B%22blink%22%5D),%0A        ),%0A        (%0A            %22Reversed blue color%22,%0A            lambda frame: colored(frame, %22blue%22, attrs=%5B%22reverse%22%5D),%0A        ),%0A        (%0A            %22Concealed magenta color%22,%0A            lambda frame: colored(frame, %22magenta%22, attrs=%5B%22concealed%22%5D),%0A        ),%0A        (%0A            %22Bold underline reverse cyan color%22,%0A            lambda frame: colored(%0A                frame, %22cyan%22, attrs=%5B%22bold%22, %22underline%22, %22reverse%22%5D%0A            ),%0A        ),%0A        (%0A            %22Dark blink concealed white color%22,%0A            lambda frame: colored(%0A                frame, %22white%22, attrs=%5B%22dark%22, %22blink%22, %22concealed%22%5D%0A            ),%0A        ),%0A    %5D%0A    for text, color_func in test_items:%0A        with yaspin(Spinners.bouncingBar, text=text, color=color_func):%0A            time.sleep(2)%0A%0A%0Adef test_mixing():%0A    test_items = %5B%0A        (%0A            %22Underline red on grey color%22,%0A            lambda frame: colored(%0A                frame, %22red%22, %22on_grey%22, attrs=%5B%22underline%22%5D%0A            ),%0A        ),%0A        (%0A            %22Reversed green on red color%22,%0A            lambda frame: colored(frame, %22green%22, %22on_red%22, attrs=%5B%22reverse%22%5D),%0A        ),%0A    %5D%0A    for text, color_func in test_items:%0A        with yaspin(Spinners.pong, text=text, color=color_func):%0A            time.sleep(2)%0A%0A%0Adef main():%0A    test_highlights()%0A    test_attributes()%0A    test_mixing
+ball():%0A    # Set with arguments%0A    with yaspin(%0A        color=%22white%22,%0A        on_color=%22on_magenta%22,%0A        attrs=%5B%22dark%22, %22blink%22, %22concealed%22%5D,%0A    ).bouncingBall as sp:%0A        sp.text = %22Dark blink concealed white ball on magenta color%22%0A        time.sleep(5)%0A%0A%0Adef main():%0A    white_shark()%0A    ping_pong()%0A    ball
 ()%0A%0A

Update examples/advanced_colors.py