loopstring 0.0.5__tar.gz → 0.2.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: loopstring
3
- Version: 0.0.5
3
+ Version: 0.2.0
4
4
  Summary: Terminal utilities
5
5
  Requires-Python: >=3.7
6
6
  Description-Content-Type: text/markdown
@@ -0,0 +1,285 @@
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
+
12
+ class BG:
13
+ """Background colors"""
14
+ BLACK = "\033[40m"
15
+ RED = "\033[41m"
16
+ GREEN = "\033[42m"
17
+ YELLOW = "\033[43m"
18
+ BLUE = "\033[44m"
19
+ MAGENTA = "\033[45m"
20
+ CYAN = "\033[46m"
21
+ WHITE = "\033[47m"
22
+ RESET = "\033[49m"
23
+
24
+ class FORMAT:
25
+ """Formatting tags"""
26
+ BOLD = '\033[1m' # Bold
27
+ DIM = '\033[2m' # Dim
28
+ ITALIC = '\033[3m' # Italic
29
+ UNDERLINE = '\033[4m' # Underline
30
+ REVERSE = '\033[7m' # Reverse video
31
+ STRIKETHROUGH = '\033[9m' # Strikethrough
32
+ RESET = "\033[39m"
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
+ # ... keep all your existing draw_box code exactly the same ...
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
+ 'dashed': {'h': '┄', 'v': '┆', 'tl': '┌', 'tr': '┐', 'bl': '└', 'br': '┘'}
48
+ }
49
+ g = glyphs.get(style.lower(), glyphs['light'])
50
+ lines = text.split('\n')
51
+ max_width = max(len(line) for line in lines) if lines else 0
52
+ box = []
53
+ box.append(f"{g['tl']}{g['h'] * (max_width + 2)}{g['tr']}")
54
+ for line in lines:
55
+ box.append(f"{g['v']} {line.ljust(max_width)} {g['v']}")
56
+ box.append(f"{g['bl']}{g['h'] * (max_width + 2)}{g['br']}")
57
+ return '\n'.join(box)
58
+
59
+ @staticmethod
60
+ def rounded(text: str) -> str:
61
+ """Shortcut to draw a rounded box."""
62
+ return BOXES.draw_box(text, style='rounded')
63
+
64
+ @staticmethod
65
+ def heavy(text: str) -> str:
66
+ """Shortcut to draw a heavy box."""
67
+ return BOXES.draw_box(text, style='heavy')
68
+
69
+ @staticmethod
70
+ def double(text: str) -> str:
71
+ """Shortcut to draw a double box."""
72
+ return BOXES.draw_box(text, style='double')
73
+
74
+ @staticmethod
75
+ def dashed(text: str) -> str:
76
+ """Shortcut to draw a dashed box."""
77
+ return BOXES.draw_box(text, style='dashed')
78
+
79
+
80
+ class SYMBOLS:
81
+ """Cool symbols for layouts, dashboards, and loading bars!"""
82
+ # Original Symbols
83
+ HEXAGON = '⬢'
84
+ PENTAGON = '⬟'
85
+ STAR = '⭑'
86
+ DOWNLOAD = '⤓'
87
+ LIGHTSHADE = '░'
88
+ MEDIUMSHADE = '▒'
89
+ DARKSHADE = '▓'
90
+ FULLSHADE = '█'
91
+ PHONE = '☎'
92
+ PENTAGONARROW = '⭔'
93
+ ENTERKEY = '⏎'
94
+ CHECKMARK = '✓'
95
+ SPACEBAR = '␣'
96
+ THINSQUARE = '⌷'
97
+ SLOPE = '⌳'
98
+ FILLEDRIGHTTRIANGLE = '▶'
99
+ RIGHTTRIANGLE = '▷'
100
+ ASTROIDSTAR = '✦'
101
+
102
+ MONITOR = '🖵' # U+1F5B5 - Physical monitor screen layout
103
+ CLEAR_SCREEN = '⎚' # U+239A - Classic wipe/clear screen icon
104
+ PROMPT = '❯' # U+276F - Modern CLI input hook
105
+ NETWORK = '🛜︎' # U+1F6DC - Wi-Fi/Network status indicator
106
+
107
+ FILL_1_8 = '▏' # U+258F - Left 1/8 block fill
108
+ FILL_1_4 = '▎' # U+258E - Left 1/4 block fill
109
+ FILL_HALF = '▌' # U+258C - Left half block fill
110
+ FILL_3_4 = '▊' # U+258A - Left 3/4 block fill
111
+
112
+ FOLDER_CLOSED = '🗀' # U+1F5C0 - Closed directory item
113
+ FOLDER_OPEN = '🗁' # U+1F5C1 - Expanded directory folder
114
+ DOCUMENT = '🖹' # U+1F5B9 - Log/Text file symbol
115
+ TRASH = '🗑︎' # U+1F5D1 - Delete/Erase storage indicator
116
+
117
+ LOOP_INFINITY = '∞' # U+221E - Infinity track loop
118
+ LOOP_SINGLE = '➰︎' # U+27B0 - Light curly loop curl
119
+ LOOP_DOUBLE = '➿︎' # U+27BF - Double curly loop hook
120
+ LOOP_REFRESH = '⥁' # U+2941 - Circular reload sequence
121
+
122
+ SCALES = '⚖'
123
+
124
+ class DIVIDERS:
125
+ @staticmethod
126
+ def draw_divider(text, style="box"):
127
+ if style == "box":
128
+ return(f"▌[{text}]▐")
129
+ elif style == "server":
130
+ return(f"╽ {text} ╿")
131
+ elif style == "pixel":
132
+ return(f"▀▄ {text} ▄▀")
133
+ elif style == "shade":
134
+ return(f"░▒▓█ {text} █▓▒░")
135
+ elif style == "angle_bracket":
136
+ return(f"❬ {text} ❭")
137
+ elif style == "boxed":
138
+ return(f"┍[ {text} ]┑")
139
+ elif style == "bullet":
140
+ return(f"⁌ {text} ⁍")
141
+ elif style == "dotted_line":
142
+ return(f"⁞ {text} ⁞")
143
+ elif style == "mini_triangle":
144
+ return(f"◂ {text} ▸")
145
+ elif style == "science":
146
+ return(f"⚗⚛ {text} ⚛⚗")
147
+
148
+ class MULTI_INPUT_MATRICES:
149
+ @staticmethod
150
+ def draw_matrix(text1, text2, text3, matrixType="square"):
151
+ """
152
+ Draws matrices with three text parameters.
153
+ Available in 3 styles:
154
+ - Square
155
+ - Rounded
156
+ - Curly
157
+ """
158
+ # Combine inputs to find the maximum string length efficiently
159
+ texts = [text1, text2, text3]
160
+ biggestLength = max(len(t) for t in texts)
161
+
162
+ # Dynamically pad each text string to match the longest one
163
+ padded_texts = [t.ljust(biggestLength) for t in texts]
164
+
165
+ if matrixType == "square":
166
+ # Brackets now dynamically scale based on the largest input width
167
+ topBracket = "⎡ " + padded_texts[0] + " ⎤"
168
+ middleBracket = "⎢ " + padded_texts[1] + " ⎥"
169
+ bottomBracket = "⎣ " + padded_texts[2] + " ⎦"
170
+ elif matrixType == "rounded":
171
+ topBracket = "⎧ " + padded_texts[0] + " ⎫"
172
+ middleBracket = "⎪ " + padded_texts[1] + " ⎪"
173
+ bottomBracket = "⎩ " + padded_texts[2] + " ⎭"
174
+ elif matrixType == "curly":
175
+ topBracket = "⎧ " + padded_texts[0] + " ⎫"
176
+ middleBracket = "⎨ " + padded_texts[1] + " ⎬"
177
+ bottomBracket = "⎩ " + padded_texts[2] + " ⎭"
178
+
179
+ return topBracket + "\n" + middleBracket + "\n" + bottomBracket + "\n"
180
+
181
+ class MATRICES:
182
+ @staticmethod
183
+ def draw_matrix(text, matrixType="square"):
184
+ """
185
+ Draws matrices with one text parameter.
186
+ Available in 3 styles:
187
+ - Square
188
+ - Rounded
189
+ - Curly
190
+ """
191
+ textLength = 0
192
+ textLength = len(text)
193
+ if matrixType == "square":
194
+ topBracket = "⎡" + ((" " * textLength) + " ") + "⎤"
195
+ middleBracket = "⎢" + (" " + text + " ") + "⎥"
196
+ bottomBracket = "⎣" + ((" " * textLength) + " ") + "⎦"
197
+ elif matrixType == "rounded":
198
+ topBracket = "⎧" + ((" " * textLength) + " ") + "⎫"
199
+ middleBracket = "⎪" + (" " + text + " ") + "⎪"
200
+ bottomBracket = "⎩" + ((" " * textLength) + " ") + "⎭"
201
+ elif matrixType == "curly":
202
+ topBracket = "⎧" + ((" " * textLength) + " ") + "⎫"
203
+ middleBracket = "⎨" + (" " + text + " ") + "⎬"
204
+ bottomBracket = "⎩" + ((" " * textLength) + " ") + "⎭"
205
+
206
+ return((topBracket + "\n") + (middleBracket + "\n") + (bottomBracket + "\n"))
207
+
208
+
209
+ class WRITEDOWN:
210
+ def format_writedown(writedown_text):
211
+ """
212
+ Parses standard Writedown (a Markdown modification) syntax string formatting loops and translates
213
+ them directly into terminal screen Colorama escape styles.
214
+ """
215
+ lines = writedown_text.split(r"\n") # Splits text lines accurately
216
+
217
+
218
+
219
+ for line in lines:
220
+ processed_line = line.strip()
221
+
222
+ # 1. Parse # Headers -> Bright Cyan Bold
223
+ if processed_line.startswith("# "):
224
+ processed_line = "\033[36m" + "\033[1m" + "▶ " + processed_line[2:].upper()
225
+ # 2. Parse ## and ### Headers -> Bright White Bold
226
+ elif processed_line.startswith("## "):
227
+ processed_line = "\033[36m" + "\033[1m" + "▷ " + processed_line[3:]
228
+ elif processed_line.startswith("### "):
229
+ processed_line = "\033[37m" + "‣ " + processed_line[4:]
230
+ # 3. Parse * Bullet points -> Green Bullet Indent
231
+ elif processed_line.startswith("* "):
232
+ processed_line = " " + "\033[32m" + "• " + "\033[37m" + processed_line[2:]
233
+ elif processed_line.startswith("- "):
234
+ processed_line = " " + "\033[32m" + "- " + "\033[37m" + processed_line[2:]
235
+ elif processed_line.startswith("> "):
236
+ processed_line = " " + "\033[33m" + "‣ " + "\033[37m" + processed_line[2:]
237
+ elif processed_line.startswith("1. "):
238
+ processed_line = " " + "\033[31m" + "1. " + "\033[37m" + processed_line[3:]
239
+ elif processed_line.startswith("2. "):
240
+ processed_line = " " + "\033[31m" + "2. " + "\033[37m" + processed_line[3:]
241
+ elif processed_line.startswith("3. "):
242
+ processed_line = " " + "\033[31m" + "3. " + "\033[37m" + processed_line[3:]
243
+ elif processed_line.startswith("4. "):
244
+ processed_line = " " + "\033[31m" + "4. " + "\033[37m" + processed_line[3:]
245
+ elif processed_line.startswith("5. "):
246
+ processed_line = " " + "\033[31m" + "5. " + "\033[37m" + processed_line[3:]
247
+ elif processed_line.startswith("6. "):
248
+ processed_line = " " + "\033[31m" + "6. " + "\033[37m" + processed_line[3:]
249
+ elif processed_line.startswith("7. "):
250
+ processed_line = " " + "\033[31m" + "7. " + "\033[37m" + processed_line[3:]
251
+ elif processed_line.startswith("8. "):
252
+ processed_line = " " + "\033[31m" + "8. " + "\033[37m" + processed_line[3:]
253
+ elif processed_line.startswith("9. "):
254
+ processed_line = " " + "\033[31m" + "9. " + "\033[37m" + processed_line[3:]
255
+ elif processed_line.startswith("10. "):
256
+ processed_line = " " + "\033[31m" + "10. " + "\033[37m" + processed_line[4:]
257
+
258
+ # 4. Parse Inline **Bold** markers using colorama replacements
259
+ while "**" in processed_line:
260
+ processed_line = processed_line.replace("**", "\033[33m" + "\033[1m", 1).replace("**", "\033[0m" + "\033[37m", 1)
261
+
262
+ # 5. Parse Inline *Italic* markers (we can use Underline style for italics in terminal layouts)
263
+ while "*" in processed_line:
264
+ processed_line = processed_line.replace("*", "\033[4m", 1).replace("*", "\033[24m", 1)
265
+
266
+ # 6. Parse Inline `Code` markers -> Magenta text style
267
+ while "`" in processed_line:
268
+ processed_line = processed_line.replace("`", "\033[35m", 1).replace("`", "\033[37m", 1)
269
+
270
+ while "=Y=" in processed_line:
271
+ processed_line = processed_line.replace("=Y=", "\033[43m", 1).replace("=Y=", "\033[0m", 1)
272
+
273
+ while "=R=" in processed_line:
274
+ processed_line = processed_line.replace("=R=", "\033[41m", 1).replace("=R=", "\033[0m", 1)
275
+
276
+ while "=G=" in processed_line:
277
+ processed_line = processed_line.replace("=G=", "\033[42m", 1).replace("=G=", "\033[0m", 1)
278
+
279
+ while "=C=" in processed_line:
280
+ processed_line = processed_line.replace("=C=", "\033[46m", 1).replace("=C=", "\033[0m", 1)
281
+
282
+ while "=B=" in processed_line:
283
+ processed_line = processed_line.replace("=B=", "\033[44m", 1).replace("=B=", "\033[0m", 1)
284
+
285
+ return("\033[0m" + processed_line + "\033[0m")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: loopstring
3
- Version: 0.0.5
3
+ Version: 0.2.0
4
4
  Summary: Terminal utilities
5
5
  Requires-Python: >=3.7
6
6
  Description-Content-Type: text/markdown
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "loopstring"
7
- version = "0.0.5"
7
+ version = "0.2.0"
8
8
  description = "Terminal utilities"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.7"
@@ -1,100 +0,0 @@
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
-
12
- class BG:
13
- """Background colors"""
14
- BLACK = "\033[40m"
15
- RED = "\033[41m"
16
- GREEN = "\033[42m"
17
- YELLOW = "\033[43m"
18
- BLUE = "\033[44m"
19
- MAGENTA = "\033[45m"
20
- CYAN = "\033[46m"
21
- WHITE = "\033[47m"
22
- RESET = "\033[49m"
23
-
24
- class FORMAT:
25
- """Formatting tags"""
26
- BOLD = '\033[1m' # Bold
27
- DIM = '\033[2m' # Dim
28
- ITALIC = '\033[3m' # Italic
29
- UNDERLINE = '\033[4m' # Underline
30
- REVERSE = '\033[7m' # Reverse video
31
- STRIKETHROUGH = '\033[9m' # Strikethrough
32
- RESET = "\033[39m"
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
- # ... keep all your existing draw_box code exactly the same ...
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
- 'dashed': {'h': '┄', 'v': '┆', 'tl': '┌', 'tr': '┐', 'bl': '└', 'br': '┘'}
48
- }
49
- g = glyphs.get(style.lower(), glyphs['light'])
50
- lines = text.split('\n')
51
- max_width = max(len(line) for line in lines) if lines else 0
52
- box = []
53
- box.append(f"{g['tl']}{g['h'] * (max_width + 2)}{g['tr']}")
54
- for line in lines:
55
- box.append(f"{g['v']} {line.ljust(max_width)} {g['v']}")
56
- box.append(f"{g['bl']}{g['h'] * (max_width + 2)}{g['br']}")
57
- return '\n'.join(box)
58
-
59
- # 🚀 NEW SHORTCUTS FOR VERSION 0.0.5 🚀
60
- @staticmethod
61
- def rounded(text: str) -> str:
62
- """Shortcut to draw a rounded box."""
63
- return BOXES.draw_box(text, style='rounded')
64
-
65
- @staticmethod
66
- def heavy(text: str) -> str:
67
- """Shortcut to draw a heavy box."""
68
- return BOXES.draw_box(text, style='heavy')
69
-
70
- @staticmethod
71
- def double(text: str) -> str:
72
- """Shortcut to draw a double box."""
73
- return BOXES.draw_box(text, style='double')
74
-
75
- @staticmethod
76
- def dashed(text: str) -> str:
77
- """Shortcut to draw a dashed box."""
78
- return BOXES.draw_box(text, style='dashed')
79
-
80
-
81
- class SYMBOLS:
82
- """Cool symbols!"""
83
- HEXAGON = '⬢'
84
- PENTAGON = '⬟'
85
- STAR = '⭑'
86
- DOWNLOAD = '⤓'
87
- LIGHTSHADE = '░'
88
- MEDIUMSHADE = '▒'
89
- DARKSHADE = '▓'
90
- FULLSHADE = '█'
91
- PHONE = '☎'
92
- PENTAGONARROW = '⭔'
93
- ENTERKEY = '⏎'
94
- CHECKMARK = '✓'
95
- SPACEBAR = '␣'
96
- THINSQUARE = '⌷'
97
- SLOPE = '⌳'
98
- FILLEDRIGHTTRIANGLE = '▶'
99
- RIGHTTRIANGLE = '▷'
100
- ASTROIDSTAR = '✦'
File without changes
File without changes
File without changes