diff options
author | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-02-17 09:41:48 +0200 |
---|---|---|
committer | Aineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi> | 2024-02-17 09:41:48 +0200 |
commit | e785dbd4f726c5716f21071ed25dc35ac87c0c74 (patch) | |
tree | 781373b78380a1ffd1ea8c5dc8ceb2bd313631e9 /src/miinaharava/tui/ansi.py | |
parent | 4eff4a32cfa594cc2a3df3885de92d407edc6675 (diff) |
Dev tools and directory structure rework.
Diffstat (limited to 'src/miinaharava/tui/ansi.py')
-rw-r--r-- | src/miinaharava/tui/ansi.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/miinaharava/tui/ansi.py b/src/miinaharava/tui/ansi.py new file mode 100644 index 0000000..c25ff6c --- /dev/null +++ b/src/miinaharava/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") |