File: __init__.py

package info (click to toggle)
python-tcolorpy 0.1.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 468 kB
  • sloc: python: 624; makefile: 53; sh: 6
file content (36 lines) | stat: -rw-r--r-- 913 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import platform

from .__version__ import __author__, __copyright__, __email__, __license__, __version__
from ._const import AnsiBGColor, AnsiFGColor, AnsiStyle
from ._truecolor import Color, RGBTuple, tcolor


__all__ = (
    "__author__",
    "__email__",
    "__license__",
    "__version__",
    "__copyright__",
    "AnsiBGColor",
    "AnsiFGColor",
    "AnsiStyle",
    "Color",
    "RGBTuple",
    "tcolor",
)


if platform.system() == "Windows":
    from ctypes import windll  # type: ignore

    # https://docs.microsoft.com/en-us/windows/console/getstdhandle
    STD_OUTPUT_HANDLE = -11

    # https://docs.microsoft.com/en-us/windows/console/setconsolemode
    ENABLE_PROCESSED_OUTPUT = 1
    ENABLE_VIRTUAL_TERMINAL_PROCESSING = 4

    windll.kernel32.SetConsoleMode(
        windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE),
        ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING,
    )