tui-utilities 1.1.5__py3-none-any.whl → 1.1.6__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 tui-utilities might be problematic. Click here for more details.
- tui_utilities/console.py +28 -17
- {tui_utilities-1.1.5.dist-info → tui_utilities-1.1.6.dist-info}/METADATA +1 -1
- {tui_utilities-1.1.5.dist-info → tui_utilities-1.1.6.dist-info}/RECORD +5 -5
- {tui_utilities-1.1.5.dist-info → tui_utilities-1.1.6.dist-info}/WHEEL +0 -0
- {tui_utilities-1.1.5.dist-info → tui_utilities-1.1.6.dist-info}/top_level.txt +0 -0
tui_utilities/console.py
CHANGED
|
@@ -20,7 +20,8 @@ def _style(
|
|
|
20
20
|
top_padding = None,
|
|
21
21
|
right_padding = None,
|
|
22
22
|
bottom_padding = None,
|
|
23
|
-
left_padding = None
|
|
23
|
+
left_padding = None,
|
|
24
|
+
plain_text = False
|
|
24
25
|
):
|
|
25
26
|
def apply_text_styles(object):
|
|
26
27
|
styleable = Text()
|
|
@@ -62,27 +63,32 @@ def _style(
|
|
|
62
63
|
if current_segment: styleable.append(current_segment, style = style)
|
|
63
64
|
return styleable
|
|
64
65
|
|
|
65
|
-
def apply_alignment(alignable): return Align(alignable, alignment)
|
|
66
|
+
def apply_alignment(alignable): return Align(alignable, alignment)
|
|
66
67
|
|
|
67
68
|
def apply_padding(paddable):
|
|
68
|
-
if not padding and not top_padding and not right_padding and not bottom_padding and not left_padding: return paddable
|
|
69
69
|
final_padding = (
|
|
70
|
-
top_padding if top_padding else padding,
|
|
71
|
-
(right_padding if right_padding else padding) * 2,
|
|
72
|
-
bottom_padding if bottom_padding else padding,
|
|
73
|
-
(left_padding if left_padding else padding) * 2
|
|
70
|
+
top_padding if top_padding is not None else padding,
|
|
71
|
+
(right_padding if right_padding is not None else padding) * 2,
|
|
72
|
+
bottom_padding if bottom_padding is not None else padding,
|
|
73
|
+
(left_padding if left_padding is not None else padding) * 2
|
|
74
74
|
)
|
|
75
75
|
return Padding(paddable, final_padding)
|
|
76
76
|
|
|
77
|
+
needs_layout = (
|
|
78
|
+
alignment is not None or
|
|
79
|
+
padding is not None or
|
|
80
|
+
top_padding is not None or
|
|
81
|
+
right_padding is not None or
|
|
82
|
+
bottom_padding is not None or
|
|
83
|
+
left_padding is not None
|
|
84
|
+
)
|
|
77
85
|
if isinstance(object, (str, list)):
|
|
78
86
|
styled = apply_text_styles(object)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return padded
|
|
87
|
+
if not needs_layout: return styled
|
|
88
|
+
return apply_padding(apply_alignment(styled))
|
|
82
89
|
if isinstance(object, RenderableType):
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return padded
|
|
90
|
+
if not needs_layout: return object
|
|
91
|
+
return apply_padding(apply_alignment(object))
|
|
86
92
|
styled = apply_text_styles(str(object))
|
|
87
93
|
aligned = apply_alignment(styled)
|
|
88
94
|
padded = apply_padding(aligned)
|
|
@@ -104,6 +110,7 @@ def print(
|
|
|
104
110
|
left_padding = None,
|
|
105
111
|
separator = " ",
|
|
106
112
|
end = "\n",
|
|
113
|
+
plain_text = False,
|
|
107
114
|
**kwargs
|
|
108
115
|
):
|
|
109
116
|
renderables = []
|
|
@@ -121,7 +128,8 @@ def print(
|
|
|
121
128
|
top_padding = top_padding,
|
|
122
129
|
right_padding = right_padding,
|
|
123
130
|
bottom_padding = bottom_padding,
|
|
124
|
-
left_padding = left_padding
|
|
131
|
+
left_padding = left_padding,
|
|
132
|
+
plain_text = plain_text
|
|
125
133
|
))
|
|
126
134
|
_console.print(*renderables, sep = separator, end = end, **kwargs)
|
|
127
135
|
|
|
@@ -141,7 +149,8 @@ def input(
|
|
|
141
149
|
italic = italic,
|
|
142
150
|
underline = underline,
|
|
143
151
|
strike = strike,
|
|
144
|
-
reverse = reverse
|
|
152
|
+
reverse = reverse,
|
|
153
|
+
plain_text = True
|
|
145
154
|
)).strip()
|
|
146
155
|
|
|
147
156
|
def clear_console(): os.system("cls")
|
|
@@ -159,7 +168,8 @@ def wait_for_key(
|
|
|
159
168
|
top_padding = None,
|
|
160
169
|
right_padding = None,
|
|
161
170
|
bottom_padding = None,
|
|
162
|
-
left_padding = None
|
|
171
|
+
left_padding = None,
|
|
172
|
+
plain_text = True
|
|
163
173
|
):
|
|
164
174
|
print(
|
|
165
175
|
f"\n{text}",
|
|
@@ -175,6 +185,7 @@ def wait_for_key(
|
|
|
175
185
|
right_padding = right_padding,
|
|
176
186
|
bottom_padding = bottom_padding,
|
|
177
187
|
left_padding = left_padding,
|
|
178
|
-
end = ""
|
|
188
|
+
end = "",
|
|
189
|
+
plain_text = plain_text
|
|
179
190
|
)
|
|
180
191
|
readchar.readkey()
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
tui_utilities/__init__.py,sha256=zL2dBAmn6OgjnkjP7ABpgTaivse9WhCj_sQl2W3H0Uw,549
|
|
2
|
-
tui_utilities/console.py,sha256=
|
|
2
|
+
tui_utilities/console.py,sha256=Vnt5bJIjqdwc3It2aw8xLX5rU_v8-n8-pxu94XvFJcA,6163
|
|
3
3
|
tui_utilities/format.py,sha256=6Ou6aeRku1Fb5Nf0tKmCgh8CIsh3sRJZogog-f5_igc,657
|
|
4
4
|
tui_utilities/structure.py,sha256=DTNCopWHbURvWduDC1pP1JDjBL5B4bNu3NCzvTk8vHs,8544
|
|
5
5
|
tui_utilities/system.py,sha256=KGkEg11zlH18FiQsuywgW0Ls7aiPlvgJr7tDsQMJCBo,308
|
|
6
6
|
tui_utilities/validation.py,sha256=DGaVjTiLAsdG3wFIuiYWg9vRZZ5R0OgBB8cxWg-riZ8,6502
|
|
7
7
|
tui_utilities/_tlds/tlds.txt,sha256=ieHVMCtLqEoh8aiMZIZPepNdOjR3CGlO2QgH5LKCRuI,10916
|
|
8
|
-
tui_utilities-1.1.
|
|
9
|
-
tui_utilities-1.1.
|
|
10
|
-
tui_utilities-1.1.
|
|
11
|
-
tui_utilities-1.1.
|
|
8
|
+
tui_utilities-1.1.6.dist-info/METADATA,sha256=6cp6yBbGBTuSK1vbr1iUcUwBVz0rSx7mxHKolnTDkZ4,4727
|
|
9
|
+
tui_utilities-1.1.6.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
10
|
+
tui_utilities-1.1.6.dist-info/top_level.txt,sha256=TF1KuV0fMB1rkFRhqaCkqjprAnH-Tpc4Klsxwif5RWI,14
|
|
11
|
+
tui_utilities-1.1.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|