trgb 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of trgb might be problematic. Click here for more details.
- tcx/__init__.py +8 -0
- tcx/colors.py +45 -0
- tcx/colors256.py +19 -0
- tcx/main.py +22 -0
- tcx/rgb.py +21 -0
- tcx/styles.py +15 -0
- trgb-0.1.0.dist-info/METADATA +67 -0
- trgb-0.1.0.dist-info/RECORD +10 -0
- trgb-0.1.0.dist-info/WHEEL +5 -0
- trgb-0.1.0.dist-info/top_level.txt +1 -0
tcx/__init__.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from .colors import red, green, yellow, black, blue, magenta, cyan, white, gray, bright_blue, bright_cyan, bright_green, bright_magenta, bright_red, bright_white, bright_yellow, bg_black, bg_blue, bg_cyan, bg_gray, bg_green, bg_magenta, bg_red, bg_white, bg_yellow, bright_bg_magenta, bright_bg_blue, bright_bg_cyan, bright_bg_green, bright_bg_red, bright_bg_white, bright_bg_yellow
|
|
2
|
+
from .styles import bold, dim, italic, underline, blink, blink_fast, reverse, hidden,strikethrough
|
|
3
|
+
from .colors256 import custom_color, custom_bg
|
|
4
|
+
from .rgb import rgb, bg_rgb
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
'red','green', 'yellow', 'black', 'blue', 'magenta', 'cyan', 'white', 'gray', 'bright_blue', 'bright_cyan', 'bright_green', 'bright_magenta', 'bright_red', 'bright_white', 'bright_yellow', 'bg_black', 'bg_blue', 'bg_cyan', 'bg_gray', 'bg_green', 'bg_magenta', 'bg_red', 'bg_white', 'bg_yellow', 'bright_bg_magenta', 'bright_bg_blue', 'bright_bg_cyan', 'bright_bg_green', 'bright_bg_red', 'bright_bg_white', 'bright_bg_yellow', 'bold', 'dim', 'italic', 'underline', 'blink', 'blink_fast', 'reverse', 'hidden', 'strikethrough', 'custom_color', 'custom_bg', 'rgb', 'bg_rgb'
|
|
8
|
+
]
|
tcx/colors.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from main import SW
|
|
2
|
+
|
|
3
|
+
class Colors(SW):
|
|
4
|
+
def __init__(self, *code: str):
|
|
5
|
+
super().__init__(*code)
|
|
6
|
+
|
|
7
|
+
red = Colors('31')
|
|
8
|
+
green = Colors('32')
|
|
9
|
+
yellow = Colors('33')
|
|
10
|
+
blue = Colors('34')
|
|
11
|
+
magenta = Colors('35')
|
|
12
|
+
cyan = Colors('36')
|
|
13
|
+
white = Colors('37')
|
|
14
|
+
black = Colors('30')
|
|
15
|
+
gray = Colors('90')
|
|
16
|
+
|
|
17
|
+
bright_red = Colors('91')
|
|
18
|
+
bright_green = Colors('92')
|
|
19
|
+
bright_yellow = Colors('93')
|
|
20
|
+
bright_blue = Colors('94')
|
|
21
|
+
bright_magenta = Colors('95')
|
|
22
|
+
bright_cyan = Colors('96')
|
|
23
|
+
bright_white = Colors('97')
|
|
24
|
+
|
|
25
|
+
class BgColors(SW):
|
|
26
|
+
def __init__(self, *code: str):
|
|
27
|
+
super().__init__(*code)
|
|
28
|
+
|
|
29
|
+
bg_red = BgColors('41')
|
|
30
|
+
bg_black = BgColors('40')
|
|
31
|
+
bg_green = BgColors('42')
|
|
32
|
+
bg_yellow = BgColors('43')
|
|
33
|
+
bg_blue = BgColors('44')
|
|
34
|
+
bg_magenta = BgColors('45')
|
|
35
|
+
bg_cyan = BgColors('46')
|
|
36
|
+
bg_white = BgColors('47')
|
|
37
|
+
bg_gray = BgColors('100')
|
|
38
|
+
|
|
39
|
+
bright_bg_red = BgColors('101')
|
|
40
|
+
bright_bg_green = BgColors('102')
|
|
41
|
+
bright_bg_yellow = BgColors('103')
|
|
42
|
+
bright_bg_blue = BgColors('104')
|
|
43
|
+
bright_bg_magenta = BgColors('105')
|
|
44
|
+
bright_bg_cyan = BgColors('106')
|
|
45
|
+
bright_bg_white = BgColors('107')
|
tcx/colors256.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from main import SW
|
|
2
|
+
|
|
3
|
+
class Colors256(SW):
|
|
4
|
+
def __init__(self, color):
|
|
5
|
+
if not 0 <= color <= 255:
|
|
6
|
+
raise ValueError("Color mode must be range 0 ... 256")
|
|
7
|
+
super().__init__(f"38;5;{color}")
|
|
8
|
+
|
|
9
|
+
def custom_color(color: int):
|
|
10
|
+
return Colors256(color)
|
|
11
|
+
|
|
12
|
+
class BgColors256(SW):
|
|
13
|
+
def __init__(self, color):
|
|
14
|
+
if not 0 <= color <= 255:
|
|
15
|
+
raise ValueError("Color mode must be range 0 ... 256")
|
|
16
|
+
super().__init__(f"48;5;{color}")
|
|
17
|
+
|
|
18
|
+
def custom_bg(color: int):
|
|
19
|
+
return BgColors256(color)
|
tcx/main.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class SW:
|
|
2
|
+
RESET = "\033[0m"
|
|
3
|
+
|
|
4
|
+
def __init__(self, *code: str):
|
|
5
|
+
self.code = tuple(code)
|
|
6
|
+
|
|
7
|
+
def __add__(self, other):
|
|
8
|
+
if hasattr(other, "code"):
|
|
9
|
+
return SW(*(self.code + other.code))
|
|
10
|
+
return NotImplemented
|
|
11
|
+
|
|
12
|
+
def __radd__(self, other):
|
|
13
|
+
if hasattr(other, "code"):
|
|
14
|
+
return SW(*(other.code + self.code))
|
|
15
|
+
return NotImplemented
|
|
16
|
+
|
|
17
|
+
def __call__(self, *args, sep='', reset=True):
|
|
18
|
+
text = sep.join(map(str, args))
|
|
19
|
+
codes = ";".join(self.code)
|
|
20
|
+
prefix = f"\033[{codes}m"
|
|
21
|
+
suf = self.RESET if reset else ''
|
|
22
|
+
return f"{prefix}{text}{suf}"
|
tcx/rgb.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from main import SW
|
|
2
|
+
|
|
3
|
+
class RGBColors(SW):
|
|
4
|
+
def __init__(self, r: int, g: int, b: int):
|
|
5
|
+
for c in (r, g, b):
|
|
6
|
+
if not 0 <= c <= 255:
|
|
7
|
+
raise ValueError("Values can must be in range 0 ... 255")
|
|
8
|
+
super().__init__(f"38;2;{r};{g};{b}")
|
|
9
|
+
|
|
10
|
+
def rgb(r: int, g: int, b: int):
|
|
11
|
+
return RGBColors(r, g, b)
|
|
12
|
+
|
|
13
|
+
class BgRGBColors(SW):
|
|
14
|
+
def __init__(self, r: int, g: int, b: int):
|
|
15
|
+
for c in (r, g, b):
|
|
16
|
+
if not 0 <= c <= 255:
|
|
17
|
+
raise ValueError("Values can must be in range 0 ... 255")
|
|
18
|
+
super().__init__(f"48;2;{r};{g};{b}")
|
|
19
|
+
|
|
20
|
+
def bg_rgb(r: int, g: int, b: int):
|
|
21
|
+
return BgRGBColors(r, g, b)
|
tcx/styles.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from main import SW
|
|
2
|
+
|
|
3
|
+
class Styles(SW):
|
|
4
|
+
def __init__(self, *code: str):
|
|
5
|
+
super().__init__(*code)
|
|
6
|
+
|
|
7
|
+
bold = Styles('1')
|
|
8
|
+
dim = Styles('2')
|
|
9
|
+
italic = Styles('3')
|
|
10
|
+
underline = Styles('4')
|
|
11
|
+
blink = Styles('5')
|
|
12
|
+
blink_fast = Styles('6')
|
|
13
|
+
reverse = Styles('7')
|
|
14
|
+
hidden = Styles('8')
|
|
15
|
+
strikethrough = Styles('9')
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: trgb
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Library for Python with colors, styles, support rgb and 256 colors for terminal
|
|
5
|
+
Author: 13
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: ansi,terminal,colors,rgb
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# TerminalRGB - trgb
|
|
16
|
+
|
|
17
|
+
A library for styling text in a terminal using ANSI-codes for Python
|
|
18
|
+
|
|
19
|
+
-------------------------
|
|
20
|
+
|
|
21
|
+
Functional:
|
|
22
|
+
|
|
23
|
+
Colors, Styles, RGB and 256 palette
|
|
24
|
+
|
|
25
|
+
import:
|
|
26
|
+
|
|
27
|
+
'''bash
|
|
28
|
+
|
|
29
|
+
pip install tcx
|
|
30
|
+
|
|
31
|
+
'''py
|
|
32
|
+
|
|
33
|
+
from tcx import red, blue, bold, rgb ...
|
|
34
|
+
|
|
35
|
+
using:
|
|
36
|
+
|
|
37
|
+
'''py
|
|
38
|
+
|
|
39
|
+
print(red("Print red text"))
|
|
40
|
+
|
|
41
|
+
--------------------------- or
|
|
42
|
+
|
|
43
|
+
style = red("Print red text")
|
|
44
|
+
print(red)
|
|
45
|
+
|
|
46
|
+
the ability to stack styles:
|
|
47
|
+
|
|
48
|
+
## WARNING: the interpreter may consider your action to be an error - use type ignore
|
|
49
|
+
|
|
50
|
+
'''py
|
|
51
|
+
|
|
52
|
+
print(bold + rgb(1,1,1)("Hello World!"))
|
|
53
|
+
|
|
54
|
+
--------------------------- or
|
|
55
|
+
|
|
56
|
+
style = bold + rgb(4, 239, 8)
|
|
57
|
+
print(style("Hello World!"))
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
you can stack as many styles as you want:
|
|
61
|
+
|
|
62
|
+
'''py
|
|
63
|
+
|
|
64
|
+
style = bg_rgb(1,1,1) + rgb(2,2,2) + italic
|
|
65
|
+
print(style("text"))
|
|
66
|
+
|
|
67
|
+
# I wish you a pleasant experience. Good luck!
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
tcx/__init__.py,sha256=lzWzcP6sTr9Su9UUU7ueg7lVFu75eNInD1Gk5EN9yT0,1154
|
|
2
|
+
tcx/colors.py,sha256=wJG3_PK5pqLjd0VG5W1sDg0Tkq9y043xP3bViKdqdk4,1101
|
|
3
|
+
tcx/colors256.py,sha256=7z3WV4XTw5IxtvEzkTf8yzAppRPBZimpAR4wkTv5vX8,549
|
|
4
|
+
tcx/main.py,sha256=oOrmec_QVdooTFy3nYe3hdNKd195PpKM4tUYDdGlIl0,666
|
|
5
|
+
tcx/rgb.py,sha256=Ce36uEV19kbIjUok-AReWUp8crTu3W75aKJHsLj2Gyk,678
|
|
6
|
+
tcx/styles.py,sha256=-nGOVCZcQDafYNaksh-dvblsXgEzeg1Ba6Ko5e-QOAg,366
|
|
7
|
+
trgb-0.1.0.dist-info/METADATA,sha256=-oy9cNgoxc2qqDTU6WTSR__MEN_XZ4T6gOUWVfm6oM8,1361
|
|
8
|
+
trgb-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
9
|
+
trgb-0.1.0.dist-info/top_level.txt,sha256=voDxH_zsGvbjBArDULVT3nO3k5zdj3jueSFaYp0SF6c,4
|
|
10
|
+
trgb-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
tcx
|