loopstring 0.0.1__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.
loopstring/__init__.py
ADDED
|
File without changes
|
loopstring/loopstring.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
class FG:
|
|
2
|
+
"""Foreground text colors"""
|
|
3
|
+
BLACK = "\033[30m"
|
|
4
|
+
RED = "\033[31m"
|
|
5
|
+
GREEN = "\033[32m"
|
|
6
|
+
YELLOW = "\033[33m"
|
|
7
|
+
BLUE = "\033[34m"
|
|
8
|
+
MAGENTA = "\033[35m"
|
|
9
|
+
CYAN = "\033[36m"
|
|
10
|
+
WHITE = "\033[37m"
|
|
11
|
+
RESET = "\033[39m"
|
|
12
|
+
|
|
13
|
+
class BG:
|
|
14
|
+
"""Background colors"""
|
|
15
|
+
BLACK = "\033[40m"
|
|
16
|
+
RED = "\033[41m"
|
|
17
|
+
GREEN = "\033[42m"
|
|
18
|
+
YELLOW = "\033[43m"
|
|
19
|
+
BLUE = "\033[44m"
|
|
20
|
+
MAGENTA = "\033[45m"
|
|
21
|
+
CYAN = "\033[46m"
|
|
22
|
+
WHITE = "\033[47m"
|
|
23
|
+
RESET = "\033[49m"
|
|
24
|
+
|
|
25
|
+
class FORMAT:
|
|
26
|
+
"""Formatting tags"""
|
|
27
|
+
BOLD = '\033[1m' # Bold
|
|
28
|
+
DIM = '\033[2m' # Dim
|
|
29
|
+
ITALIC = '\033[3m' # Italic
|
|
30
|
+
UNDERLINE = '\033[4m' # Underline
|
|
31
|
+
REVERSE = '\033[7m' # Reverse video
|
|
32
|
+
STRIKETHROUGH = '\033[9m' # Strikethrough
|
|
33
|
+
|
|
34
|
+
class BOXES:
|
|
35
|
+
@staticmethod
|
|
36
|
+
def draw_box(text: str, style: str = 'light') -> str:
|
|
37
|
+
"""Wraps text inside a customizable Unicode box.
|
|
38
|
+
|
|
39
|
+
Supported styles: 'light', 'heavy', 'double', 'rounded', 'dashed'
|
|
40
|
+
"""
|
|
41
|
+
# Define unicode box-drawing character maps
|
|
42
|
+
glyphs = {
|
|
43
|
+
'light': {'h': '─', 'v': '│', 'tl': '┌', 'tr': '┐', 'bl': '└', 'br': '┘'},
|
|
44
|
+
'heavy': {'h': '━', 'v': '┃', 'tl': '┏', 'tr': '┓', 'bl': '┗', 'br': '┛'},
|
|
45
|
+
'double': {'h': '═', 'v': '║', 'tl': '╔', 'tr': '╗', 'bl': '╚', 'br': '╝'},
|
|
46
|
+
'rounded': {'h': '─', 'v': '│', 'tl': '╭', 'tr': '╮', 'bl': '╰', 'br': '╯'},
|
|
47
|
+
# Using a triple-dash pattern for the dashed style
|
|
48
|
+
'dashed': {'h': '┄', 'v': '┆', 'tl': '┌', 'tr': '┐', 'bl': '└', 'br': '┘'}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# Fallback to light style if an invalid style is passed
|
|
52
|
+
g = glyphs.get(style.lower(), glyphs['light'])
|
|
53
|
+
|
|
54
|
+
# Split text into lines and find the longest line to set box width
|
|
55
|
+
lines = text.split('\n')
|
|
56
|
+
max_width = max(len(line) for line in lines) if lines else 0
|
|
57
|
+
|
|
58
|
+
# Construct the box layers
|
|
59
|
+
box = []
|
|
60
|
+
box.append(f"{g['tl']}{g['h'] * (max_width + 2)}{g['tr']}")
|
|
61
|
+
|
|
62
|
+
for line in lines:
|
|
63
|
+
box.append(f"{g['v']} {line.ljust(max_width)} {g['v']}")
|
|
64
|
+
|
|
65
|
+
box.append(f"{g['bl']}{g['h'] * (max_width + 2)}{g['br']}")
|
|
66
|
+
|
|
67
|
+
return '\n'.join(box)
|
|
68
|
+
|
|
69
|
+
class SYMBOLS:
|
|
70
|
+
"""Cool symbols!"""
|
|
71
|
+
HEXAGON = '⬢' # Bold
|
|
72
|
+
PENTAGON = '⬟' # Dim
|
|
73
|
+
STAR = '⭑' # Italic
|
|
74
|
+
DOWNLOAD = '⤓' # Underline
|
|
75
|
+
REVERSE = '\033[7m' # Reverse video
|
|
76
|
+
STRIKETHROUGH = '\033[9m' # Strikethrough
|
|
77
|
+
LIGHTSHADE = '░'
|
|
78
|
+
MEDIUMSHADE = '▒'
|
|
79
|
+
DARKSHADE = '▓'
|
|
80
|
+
FULLSHADE = '█'
|
|
81
|
+
PHONE = '☎'
|
|
82
|
+
PENTAGONARROW = '⭔'
|
|
83
|
+
ENTERKEY = '⏎'
|
|
84
|
+
CHECKMARK = '✓'
|
|
85
|
+
SPACEBAR = '␣'
|
|
86
|
+
THINSQUARE = '⌷'
|
|
87
|
+
SLOPE = '⌳'
|
|
88
|
+
FILLEDRIGHTTRIANGLE = '▶'
|
|
89
|
+
RIGHTTRIANGLE = '▷'
|
|
90
|
+
ASTROIDSTAR = '✦'
|
|
91
|
+
|
|
92
|
+
print(BOXES.draw_box("lol", "heavy"))
|
|
93
|
+
print(FORMAT.BOLD + "text")
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: loopstring
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A terminal string layout, coloring, and box-drawing utility.
|
|
5
|
+
Requires-Python: >=3.7
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
|
|
8
|
+
# LoopString
|
|
9
|
+
|
|
10
|
+
A lightweight, powerful Python utility for terminal text formatting, custom box-drawing, and terminal UI layouts.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- **Custom Box UI:** Wrap single or multi-line text blocks in `light`, `heavy`, `double`, `rounded`, or `dashed` geometric borders.
|
|
15
|
+
- **Clean Namespaces:** Organized using clean object structures (`FG`, `BG`, `FORMAT`, `BOXES`) to ensure autocomplete works perfectly in your IDE.
|
|
16
|
+
- **Styling Combinations:** Easily concatenate colors and text styles without syntax errors or formatting collisions.
|
|
17
|
+
- **Pre-built Symbols:** Enjoy stress-free symbol concatenation without having to copy-paste.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
Once published, you can install the package directly from PyPI using pip:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install loopstring
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage Examples
|
|
28
|
+
|
|
29
|
+
### 1. Drawing a Custom Box
|
|
30
|
+
```python
|
|
31
|
+
from loopstring import BOXES
|
|
32
|
+
|
|
33
|
+
# Draw a clean rounded box around your text
|
|
34
|
+
print(BOXES.rounded("System Online"))
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 2. Styling Terminal Text
|
|
38
|
+
```python
|
|
39
|
+
from loopstring import FG, BG, FORMAT
|
|
40
|
+
|
|
41
|
+
# Apply vibrant styles safely without tuples
|
|
42
|
+
print(f"{FG.GREEN}{FORMAT.BOLD}Success!{FORMAT.RESET} Everything loaded correctly.")
|
|
43
|
+
print(f"{BG.BLUE}{FG.WHITE} Notice {FORMAT.RESET} Check system updates.")
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
loopstring/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
loopstring/loopstring.py,sha256=s7K4vNJyVRLNyTB_b1H1waUrFFjRWTb1ppG7Dht_riw,2944
|
|
3
|
+
loopstring-0.0.1.dist-info/METADATA,sha256=3CFjOr4wvoxBR-NabeBHCT0JnZtdQjPd2D-A6uCBGDw,1508
|
|
4
|
+
loopstring-0.0.1.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
5
|
+
loopstring-0.0.1.dist-info/top_level.txt,sha256=2ydcZBVjxIoTy9e7zFiQFH3LMMAGVBh6iPbdCfKdtqo,11
|
|
6
|
+
loopstring-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
loopstring
|