diff options
author | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-01-14 13:47:35 +0200 |
---|---|---|
committer | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-01-14 13:47:35 +0200 |
commit | e56c2153add98361ea7909789b195d3a702f85bb (patch) | |
tree | fd7d9691a4b62f44b2c60f5cf62f006a9476124f /tui/ansi.py | |
parent | 822d89c50a70277186f5c845e4341236548c16b7 (diff) |
Moving things around and adding fouth flag option for bot suggestions.
Diffstat (limited to 'tui/ansi.py')
-rw-r--r-- | tui/ansi.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tui/ansi.py b/tui/ansi.py new file mode 100644 index 0000000..c25ff6c --- /dev/null +++ b/tui/ansi.py @@ -0,0 +1,46 @@ +""" ansi.py - ansi ohjauskomentoja. värit jne """ + +class Ansi: + """ Ansi - Luokallinen staattisia metodeja ansi komennoille """ + + BLACK = 0 + RED = 1 + GREEN = 2 + YELLOW = 3 + BLUE = 4 + MAGENTA = 5 + CYAN = 6 + WHITE = 7 + GRAY = 8 + BRIGHT_RED = 9 + BRIGHT_GREEN = 0xA + BRIGHT_YELLOW = 0xB + BRIGHT_BLUE = 0xC + BRIGHT_MAGENTA = 0xD + BRIGHT_CYAN = 0xE + BRIGHT_WHITE = 0xF + + @staticmethod + def color(color): + """ asettaa tekstin värin """ + if color in range(16): + print(end=f"\033[{'1;' if color//8 else ''}3{color%8}m") + + + @staticmethod + def bg(color): + """ asettaa tekstin taustan värin""" + if color in range(8): + print(end=f"\033[4{color}m") + + + @staticmethod + def cup(lines): + """ liikuttaa kursoria ylöspäin""" + print(end=f"\033[{lines}F") + + + @staticmethod + def reset(): + """ resetoi tekstin värin ja muut attribuutit perusarvoille """ + print(end="\033[0m") |