urwid 2.6.0.post0__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 urwid might be problematic. Click here for more details.
- urwid/__init__.py +333 -0
- urwid/canvas.py +1413 -0
- urwid/command_map.py +137 -0
- urwid/container.py +59 -0
- urwid/decoration.py +65 -0
- urwid/display/__init__.py +97 -0
- urwid/display/_posix_raw_display.py +413 -0
- urwid/display/_raw_display_base.py +914 -0
- urwid/display/_web.css +12 -0
- urwid/display/_web.js +462 -0
- urwid/display/_win32.py +171 -0
- urwid/display/_win32_raw_display.py +269 -0
- urwid/display/common.py +1219 -0
- urwid/display/curses.py +690 -0
- urwid/display/escape.py +624 -0
- urwid/display/html_fragment.py +251 -0
- urwid/display/lcd.py +518 -0
- urwid/display/raw.py +37 -0
- urwid/display/web.py +636 -0
- urwid/event_loop/__init__.py +55 -0
- urwid/event_loop/abstract_loop.py +175 -0
- urwid/event_loop/asyncio_loop.py +231 -0
- urwid/event_loop/glib_loop.py +294 -0
- urwid/event_loop/main_loop.py +721 -0
- urwid/event_loop/select_loop.py +230 -0
- urwid/event_loop/tornado_loop.py +206 -0
- urwid/event_loop/trio_loop.py +302 -0
- urwid/event_loop/twisted_loop.py +269 -0
- urwid/event_loop/zmq_loop.py +275 -0
- urwid/font.py +695 -0
- urwid/graphics.py +96 -0
- urwid/highlight.css +19 -0
- urwid/listbox.py +1899 -0
- urwid/monitored_list.py +522 -0
- urwid/numedit.py +376 -0
- urwid/signals.py +330 -0
- urwid/split_repr.py +130 -0
- urwid/str_util.py +358 -0
- urwid/text_layout.py +632 -0
- urwid/treetools.py +515 -0
- urwid/util.py +557 -0
- urwid/version.py +16 -0
- urwid/vterm.py +1806 -0
- urwid/widget/__init__.py +181 -0
- urwid/widget/attr_map.py +161 -0
- urwid/widget/attr_wrap.py +140 -0
- urwid/widget/bar_graph.py +649 -0
- urwid/widget/big_text.py +77 -0
- urwid/widget/box_adapter.py +126 -0
- urwid/widget/columns.py +1145 -0
- urwid/widget/constants.py +574 -0
- urwid/widget/container.py +227 -0
- urwid/widget/divider.py +110 -0
- urwid/widget/edit.py +718 -0
- urwid/widget/filler.py +403 -0
- urwid/widget/frame.py +539 -0
- urwid/widget/grid_flow.py +539 -0
- urwid/widget/line_box.py +194 -0
- urwid/widget/overlay.py +829 -0
- urwid/widget/padding.py +597 -0
- urwid/widget/pile.py +971 -0
- urwid/widget/popup.py +170 -0
- urwid/widget/progress_bar.py +141 -0
- urwid/widget/scrollable.py +597 -0
- urwid/widget/solid_fill.py +44 -0
- urwid/widget/text.py +354 -0
- urwid/widget/widget.py +852 -0
- urwid/widget/widget_decoration.py +166 -0
- urwid/widget/wimp.py +792 -0
- urwid/wimp.py +23 -0
- urwid-2.6.0.post0.dist-info/COPYING +504 -0
- urwid-2.6.0.post0.dist-info/METADATA +332 -0
- urwid-2.6.0.post0.dist-info/RECORD +75 -0
- urwid-2.6.0.post0.dist-info/WHEEL +5 -0
- urwid-2.6.0.post0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import enum
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
if typing.TYPE_CHECKING:
|
|
7
|
+
from typing_extensions import Literal
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# define some names for these constants to avoid misspellings in the source
|
|
11
|
+
# and to document the constant strings we are using
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Sizing(str, enum.Enum):
|
|
15
|
+
"""Widget sizing methods."""
|
|
16
|
+
|
|
17
|
+
FLOW = "flow"
|
|
18
|
+
BOX = "box"
|
|
19
|
+
FIXED = "fixed"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Align(str, enum.Enum):
|
|
23
|
+
"""Text alignment modes"""
|
|
24
|
+
|
|
25
|
+
LEFT = "left"
|
|
26
|
+
RIGHT = "right"
|
|
27
|
+
CENTER = "center"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class VAlign(str, enum.Enum):
|
|
31
|
+
"""Filler alignment"""
|
|
32
|
+
|
|
33
|
+
TOP = "top"
|
|
34
|
+
MIDDLE = "middle"
|
|
35
|
+
BOTTOM = "bottom"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class WrapMode(str, enum.Enum):
|
|
39
|
+
"""Text wrapping modes"""
|
|
40
|
+
|
|
41
|
+
SPACE = "space"
|
|
42
|
+
ANY = "any"
|
|
43
|
+
CLIP = "clip"
|
|
44
|
+
ELLIPSIS = "ellipsis"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class WHSettings(str, enum.Enum):
|
|
48
|
+
"""Width and Height settings"""
|
|
49
|
+
|
|
50
|
+
PACK = "pack"
|
|
51
|
+
GIVEN = "given"
|
|
52
|
+
RELATIVE = "relative"
|
|
53
|
+
WEIGHT = "weight"
|
|
54
|
+
CLIP = "clip" # Used as "given" for widgets with fixed width (with clipping part of it)
|
|
55
|
+
FLOW = "flow" # Used as pack for flow widgets
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
RELATIVE_100 = (WHSettings.RELATIVE, 100)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@typing.overload
|
|
62
|
+
def normalize_align(
|
|
63
|
+
align: Literal["left", "center", "right"] | Align,
|
|
64
|
+
err: type[BaseException],
|
|
65
|
+
) -> tuple[Align, None]: ...
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@typing.overload
|
|
69
|
+
def normalize_align(
|
|
70
|
+
align: tuple[Literal["relative", WHSettings.RELATIVE], int],
|
|
71
|
+
err: type[BaseException],
|
|
72
|
+
) -> tuple[Literal[WHSettings.RELATIVE], int]: ...
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def normalize_align(
|
|
76
|
+
align: Literal["left", "center", "right"] | Align | tuple[Literal["relative", WHSettings.RELATIVE], int],
|
|
77
|
+
err: type[BaseException],
|
|
78
|
+
) -> tuple[Align, None] | tuple[Literal[WHSettings.RELATIVE], int]:
|
|
79
|
+
"""
|
|
80
|
+
Split align into (align_type, align_amount). Raise exception err
|
|
81
|
+
if align doesn't match a valid alignment.
|
|
82
|
+
"""
|
|
83
|
+
if align in {Align.LEFT, Align.CENTER, Align.RIGHT}:
|
|
84
|
+
return (Align(align), None)
|
|
85
|
+
|
|
86
|
+
if isinstance(align, tuple) and len(align) == 2 and align[0] == WHSettings.RELATIVE:
|
|
87
|
+
_align_type, align_amount = align
|
|
88
|
+
return (WHSettings.RELATIVE, align_amount)
|
|
89
|
+
|
|
90
|
+
raise err(
|
|
91
|
+
f"align value {align!r} is not one of 'left', 'center', 'right', ('relative', percentage 0=left 100=right)"
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
@typing.overload
|
|
96
|
+
def simplify_align(
|
|
97
|
+
align_type: Literal["relative", WHSettings.RELATIVE],
|
|
98
|
+
align_amount: int,
|
|
99
|
+
) -> tuple[Literal[WHSettings.RELATIVE], int]: ...
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
@typing.overload
|
|
103
|
+
def simplify_align(
|
|
104
|
+
align_type: Literal["relative", WHSettings.RELATIVE],
|
|
105
|
+
align_amount: None,
|
|
106
|
+
) -> typing.NoReturn: ...
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@typing.overload
|
|
110
|
+
def simplify_align(
|
|
111
|
+
align_type: Literal["left", "center", "right"] | Align,
|
|
112
|
+
align_amount: int | None,
|
|
113
|
+
) -> Align: ...
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def simplify_align(
|
|
117
|
+
align_type: Literal["left", "center", "right", "relative", WHSettings.RELATIVE] | Align,
|
|
118
|
+
align_amount: int | None,
|
|
119
|
+
) -> Align | tuple[Literal[WHSettings.RELATIVE], int]:
|
|
120
|
+
"""
|
|
121
|
+
Recombine (align_type, align_amount) into an align value.
|
|
122
|
+
Inverse of normalize_align.
|
|
123
|
+
"""
|
|
124
|
+
if align_type == WHSettings.RELATIVE:
|
|
125
|
+
if not isinstance(align_amount, int):
|
|
126
|
+
raise TypeError(align_amount)
|
|
127
|
+
|
|
128
|
+
return (WHSettings.RELATIVE, align_amount)
|
|
129
|
+
return Align(align_type)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
@typing.overload
|
|
133
|
+
def normalize_valign(
|
|
134
|
+
valign: Literal["top", "middle", "bottom"] | VAlign,
|
|
135
|
+
err: type[BaseException],
|
|
136
|
+
) -> tuple[VAlign, None]: ...
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
@typing.overload
|
|
140
|
+
def normalize_valign(
|
|
141
|
+
valign: tuple[Literal["relative", WHSettings.RELATIVE], int],
|
|
142
|
+
err: type[BaseException],
|
|
143
|
+
) -> tuple[Literal[WHSettings.RELATIVE], int]: ...
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def normalize_valign(
|
|
147
|
+
valign: Literal["top", "middle", "bottom"] | VAlign | tuple[Literal["relative", WHSettings.RELATIVE], int],
|
|
148
|
+
err: type[BaseException],
|
|
149
|
+
) -> tuple[VAlign, None] | tuple[Literal[WHSettings.RELATIVE], int]:
|
|
150
|
+
"""
|
|
151
|
+
Split align into (valign_type, valign_amount). Raise exception err
|
|
152
|
+
if align doesn't match a valid alignment.
|
|
153
|
+
"""
|
|
154
|
+
if valign in {VAlign.TOP, VAlign.MIDDLE, VAlign.BOTTOM}:
|
|
155
|
+
return (VAlign(valign), None)
|
|
156
|
+
|
|
157
|
+
if isinstance(valign, tuple) and len(valign) == 2 and valign[0] == WHSettings.RELATIVE:
|
|
158
|
+
_valign_type, valign_amount = valign
|
|
159
|
+
return (WHSettings.RELATIVE, valign_amount)
|
|
160
|
+
|
|
161
|
+
raise err(
|
|
162
|
+
f"valign value {valign!r} is not one of 'top', 'middle', 'bottom', ('relative', percentage 0=left 100=right)"
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
@typing.overload
|
|
167
|
+
def simplify_valign(
|
|
168
|
+
valign_type: Literal["top", "middle", "bottom"] | VAlign,
|
|
169
|
+
valign_amount: int | None,
|
|
170
|
+
) -> VAlign: ...
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
@typing.overload
|
|
174
|
+
def simplify_valign(
|
|
175
|
+
valign_type: Literal["relative", WHSettings.RELATIVE],
|
|
176
|
+
valign_amount: int,
|
|
177
|
+
) -> tuple[Literal[WHSettings.RELATIVE], int]: ...
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
@typing.overload
|
|
181
|
+
def simplify_valign(
|
|
182
|
+
valign_type: Literal["relative", WHSettings.RELATIVE],
|
|
183
|
+
valign_amount: None,
|
|
184
|
+
) -> typing.NoReturn: ...
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def simplify_valign(
|
|
188
|
+
valign_type: Literal["top", "middle", "bottom", "relative", WHSettings.RELATIVE] | VAlign,
|
|
189
|
+
valign_amount: int | None,
|
|
190
|
+
) -> VAlign | tuple[Literal[WHSettings.RELATIVE], int]:
|
|
191
|
+
"""
|
|
192
|
+
Recombine (valign_type, valign_amount) into an valign value.
|
|
193
|
+
Inverse of normalize_valign.
|
|
194
|
+
"""
|
|
195
|
+
if valign_type == WHSettings.RELATIVE:
|
|
196
|
+
if not isinstance(valign_amount, int):
|
|
197
|
+
raise TypeError(valign_amount)
|
|
198
|
+
return (WHSettings.RELATIVE, valign_amount)
|
|
199
|
+
return VAlign(valign_type)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
@typing.overload
|
|
203
|
+
def normalize_width(
|
|
204
|
+
width: Literal["clip", "pack", WHSettings.CLIP, WHSettings.PACK],
|
|
205
|
+
err: type[BaseException],
|
|
206
|
+
) -> tuple[Literal[WHSettings.CLIP, WHSettings.PACK], None]: ...
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
@typing.overload
|
|
210
|
+
def normalize_width(
|
|
211
|
+
width: int,
|
|
212
|
+
err: type[BaseException],
|
|
213
|
+
) -> tuple[Literal[WHSettings.GIVEN], int]: ...
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
@typing.overload
|
|
217
|
+
def normalize_width(
|
|
218
|
+
width: tuple[Literal["relative", WHSettings.RELATIVE], int],
|
|
219
|
+
err: type[BaseException],
|
|
220
|
+
) -> tuple[Literal[WHSettings.RELATIVE], int]: ...
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
@typing.overload
|
|
224
|
+
def normalize_width(
|
|
225
|
+
width: tuple[Literal["weight", WHSettings.WEIGHT], int],
|
|
226
|
+
err: type[BaseException],
|
|
227
|
+
) -> tuple[Literal[WHSettings.WEIGHT], int]: ...
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def normalize_width(
|
|
231
|
+
width: (
|
|
232
|
+
Literal["clip", "pack", WHSettings.CLIP, WHSettings.PACK]
|
|
233
|
+
| int
|
|
234
|
+
| tuple[Literal["relative", "weight", WHSettings.RELATIVE, WHSettings.WEIGHT], int]
|
|
235
|
+
),
|
|
236
|
+
err: type[BaseException],
|
|
237
|
+
) -> (
|
|
238
|
+
tuple[Literal[WHSettings.CLIP, WHSettings.PACK], None]
|
|
239
|
+
| tuple[Literal[WHSettings.GIVEN, WHSettings.RELATIVE, WHSettings.WEIGHT], int]
|
|
240
|
+
):
|
|
241
|
+
"""
|
|
242
|
+
Split width into (width_type, width_amount). Raise exception err
|
|
243
|
+
if width doesn't match a valid alignment.
|
|
244
|
+
"""
|
|
245
|
+
if width in {WHSettings.CLIP, WHSettings.PACK}:
|
|
246
|
+
return (WHSettings(width), None)
|
|
247
|
+
|
|
248
|
+
if isinstance(width, int):
|
|
249
|
+
return (WHSettings.GIVEN, width)
|
|
250
|
+
|
|
251
|
+
if isinstance(width, tuple) and len(width) == 2 and width[0] in {WHSettings.RELATIVE, WHSettings.WEIGHT}:
|
|
252
|
+
width_type, width_amount = width
|
|
253
|
+
return (WHSettings(width_type), width_amount)
|
|
254
|
+
|
|
255
|
+
raise err(
|
|
256
|
+
f"width value {width!r} is not one of"
|
|
257
|
+
f"fixed number of columns, 'pack', ('relative', percentage of total width), 'clip'"
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
@typing.overload
|
|
262
|
+
def simplify_width(
|
|
263
|
+
width_type: Literal["clip", "pack", WHSettings.CLIP, WHSettings.PACK],
|
|
264
|
+
width_amount: int | None,
|
|
265
|
+
) -> Literal[WHSettings.CLIP, WHSettings.PACK]: ...
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
@typing.overload
|
|
269
|
+
def simplify_width(
|
|
270
|
+
width_type: Literal["given", WHSettings.GIVEN],
|
|
271
|
+
width_amount: int,
|
|
272
|
+
) -> int: ...
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
@typing.overload
|
|
276
|
+
def simplify_width(
|
|
277
|
+
width_type: Literal["relative", WHSettings.RELATIVE],
|
|
278
|
+
width_amount: int,
|
|
279
|
+
) -> tuple[Literal[WHSettings.RELATIVE], int]: ...
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
@typing.overload
|
|
283
|
+
def simplify_width(
|
|
284
|
+
width_type: Literal["weight", WHSettings.WEIGHT],
|
|
285
|
+
width_amount: int,
|
|
286
|
+
) -> tuple[Literal[WHSettings.WEIGHT], int]: ...
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
@typing.overload
|
|
290
|
+
def simplify_width(
|
|
291
|
+
width_type: Literal["given", "relative", "weight", WHSettings.GIVEN, WHSettings.RELATIVE, WHSettings.WEIGHT],
|
|
292
|
+
width_amount: None,
|
|
293
|
+
) -> typing.NoReturn: ...
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def simplify_width(
|
|
297
|
+
width_type: Literal["clip", "pack", "given", "relative", "weight"] | WHSettings,
|
|
298
|
+
width_amount: int | None,
|
|
299
|
+
) -> Literal[WHSettings.CLIP, WHSettings.PACK] | int | tuple[Literal[WHSettings.RELATIVE, WHSettings.WEIGHT], int]:
|
|
300
|
+
"""
|
|
301
|
+
Recombine (width_type, width_amount) into an width value.
|
|
302
|
+
Inverse of normalize_width.
|
|
303
|
+
"""
|
|
304
|
+
if width_type in {WHSettings.CLIP, WHSettings.PACK}:
|
|
305
|
+
return WHSettings(width_type)
|
|
306
|
+
|
|
307
|
+
if not isinstance(width_amount, int):
|
|
308
|
+
raise TypeError(width_amount)
|
|
309
|
+
|
|
310
|
+
if width_type == WHSettings.GIVEN:
|
|
311
|
+
return width_amount
|
|
312
|
+
|
|
313
|
+
return (WHSettings(width_type), width_amount)
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
@typing.overload
|
|
317
|
+
def normalize_height(
|
|
318
|
+
height: int,
|
|
319
|
+
err: type[BaseException],
|
|
320
|
+
) -> tuple[Literal[WHSettings.GIVEN], int]: ...
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
@typing.overload
|
|
324
|
+
def normalize_height(
|
|
325
|
+
height: Literal["flow", "pack", Sizing.FLOW, WHSettings.PACK],
|
|
326
|
+
err: type[BaseException],
|
|
327
|
+
) -> tuple[Literal[Sizing.FLOW, WHSettings.PACK], None]: ...
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
@typing.overload
|
|
331
|
+
def normalize_height(
|
|
332
|
+
height: tuple[Literal["relative", WHSettings.RELATIVE], int],
|
|
333
|
+
err: type[BaseException],
|
|
334
|
+
) -> tuple[Literal[WHSettings.RELATIVE], int]: ...
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
@typing.overload
|
|
338
|
+
def normalize_height(
|
|
339
|
+
height: tuple[Literal["weight", WHSettings.WEIGHT], int],
|
|
340
|
+
err: type[BaseException],
|
|
341
|
+
) -> tuple[Literal[WHSettings.WEIGHT], int]: ...
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
def normalize_height(
|
|
345
|
+
height: (
|
|
346
|
+
int
|
|
347
|
+
| Literal["flow", "pack", Sizing.FLOW, WHSettings.PACK]
|
|
348
|
+
| tuple[Literal["relative", "weight", WHSettings.RELATIVE, WHSettings.WEIGHT], int]
|
|
349
|
+
),
|
|
350
|
+
err: type[BaseException],
|
|
351
|
+
) -> (
|
|
352
|
+
tuple[Literal[Sizing.FLOW, WHSettings.PACK], None]
|
|
353
|
+
| tuple[Literal[WHSettings.RELATIVE, WHSettings.GIVEN, WHSettings.WEIGHT], int]
|
|
354
|
+
):
|
|
355
|
+
"""
|
|
356
|
+
Split height into (height_type, height_amount). Raise exception err
|
|
357
|
+
if height isn't valid.
|
|
358
|
+
"""
|
|
359
|
+
if height == Sizing.FLOW:
|
|
360
|
+
return (Sizing.FLOW, None)
|
|
361
|
+
|
|
362
|
+
if height == WHSettings.PACK:
|
|
363
|
+
return (WHSettings.PACK, None)
|
|
364
|
+
|
|
365
|
+
if isinstance(height, tuple) and len(height) == 2 and height[0] in {WHSettings.RELATIVE, WHSettings.WEIGHT}:
|
|
366
|
+
return (WHSettings(height[0]), height[1])
|
|
367
|
+
|
|
368
|
+
if isinstance(height, int):
|
|
369
|
+
return (WHSettings.GIVEN, height)
|
|
370
|
+
|
|
371
|
+
raise err(
|
|
372
|
+
f"height value {height!r} is not one of "
|
|
373
|
+
f"fixed number of columns, 'pack', ('relative', percentage of total height)"
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
@typing.overload
|
|
378
|
+
def simplify_height(
|
|
379
|
+
height_type: Literal["flow", "pack", WHSettings.FLOW, WHSettings.PACK],
|
|
380
|
+
height_amount: int | None,
|
|
381
|
+
) -> Literal[WHSettings.FLOW, WHSettings.PACK]: ...
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
@typing.overload
|
|
385
|
+
def simplify_height(
|
|
386
|
+
height_type: Literal["given", WHSettings.GIVEN],
|
|
387
|
+
height_amount: int,
|
|
388
|
+
) -> int: ...
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
@typing.overload
|
|
392
|
+
def simplify_height(
|
|
393
|
+
height_type: Literal["relative", WHSettings.RELATIVE],
|
|
394
|
+
height_amount: int | None,
|
|
395
|
+
) -> tuple[Literal[WHSettings.RELATIVE], int]: ...
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
@typing.overload
|
|
399
|
+
def simplify_height(
|
|
400
|
+
height_type: Literal["weight", WHSettings.WEIGHT],
|
|
401
|
+
height_amount: int | None,
|
|
402
|
+
) -> tuple[Literal[WHSettings.WEIGHT], int]: ...
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
@typing.overload
|
|
406
|
+
def simplify_height(
|
|
407
|
+
height_type: Literal["relative", "given", "weight", WHSettings.RELATIVE, WHSettings.GIVEN, WHSettings.WEIGHT],
|
|
408
|
+
height_amount: None,
|
|
409
|
+
) -> typing.NoReturn: ...
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
def simplify_height(
|
|
413
|
+
height_type: Literal[
|
|
414
|
+
"flow",
|
|
415
|
+
"pack",
|
|
416
|
+
"relative",
|
|
417
|
+
"given",
|
|
418
|
+
"weight",
|
|
419
|
+
WHSettings.FLOW,
|
|
420
|
+
WHSettings.PACK,
|
|
421
|
+
WHSettings.RELATIVE,
|
|
422
|
+
WHSettings.GIVEN,
|
|
423
|
+
WHSettings.WEIGHT,
|
|
424
|
+
],
|
|
425
|
+
height_amount: int | None,
|
|
426
|
+
) -> int | Literal[WHSettings.FLOW, WHSettings.PACK] | tuple[Literal[WHSettings.RELATIVE, WHSettings.WEIGHT], int]:
|
|
427
|
+
"""
|
|
428
|
+
Recombine (height_type, height_amount) into a height value.
|
|
429
|
+
Inverse of normalize_height.
|
|
430
|
+
"""
|
|
431
|
+
if height_type in {WHSettings.FLOW, WHSettings.PACK}:
|
|
432
|
+
return WHSettings(height_type)
|
|
433
|
+
|
|
434
|
+
if not isinstance(height_amount, int):
|
|
435
|
+
raise TypeError(height_amount)
|
|
436
|
+
|
|
437
|
+
if height_type == WHSettings.GIVEN:
|
|
438
|
+
return height_amount
|
|
439
|
+
|
|
440
|
+
return (WHSettings(height_type), height_amount)
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
class _LightBoxSymbols(typing.NamedTuple):
|
|
444
|
+
"""Box symbols for drawing.
|
|
445
|
+
|
|
446
|
+
The Thin version includes extra symbols.
|
|
447
|
+
Symbols are ordered as in Unicode except dashes.
|
|
448
|
+
"""
|
|
449
|
+
|
|
450
|
+
# fmt: off
|
|
451
|
+
|
|
452
|
+
HORIZONTAL: str = "─"
|
|
453
|
+
VERTICAL: str = "│"
|
|
454
|
+
TOP_LEFT: str = "┌"
|
|
455
|
+
TOP_RIGHT: str = "┐"
|
|
456
|
+
BOTTOM_LEFT: str = "└"
|
|
457
|
+
BOTTOM_RIGHT: str = "┘"
|
|
458
|
+
# Joints for tables making
|
|
459
|
+
LEFT_T: str = "├"
|
|
460
|
+
RIGHT_T: str = "┤"
|
|
461
|
+
TOP_T: str = "┬"
|
|
462
|
+
BOTTOM_T: str = "┴"
|
|
463
|
+
CROSS: str = "┼"
|
|
464
|
+
# Dashes
|
|
465
|
+
HORIZONTAL_4_DASHES: str = "┈"
|
|
466
|
+
HORIZONTAL_3_DASHES: str = "┄"
|
|
467
|
+
HORIZONTAL_2_DASHES: str = "╌"
|
|
468
|
+
VERTICAL_2_DASH: str = "╎"
|
|
469
|
+
VERTICAL_3_DASH: str = "┆"
|
|
470
|
+
VERTICAL_4_DASH: str = "┊"
|
|
471
|
+
# Unique for light only
|
|
472
|
+
TOP_LEFT_ROUNDED: str = "╭"
|
|
473
|
+
TOP_RIGHT_ROUNDED: str = "╮"
|
|
474
|
+
BOTTOM_RIGHT_ROUNDED: str = "╯"
|
|
475
|
+
BOTTOM_LEFT_ROUNDED: str = "╰"
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
class _HeavyBoxSymbols(typing.NamedTuple):
|
|
479
|
+
"""Box symbols for drawing.
|
|
480
|
+
|
|
481
|
+
The Heavy version includes extra symbols.
|
|
482
|
+
Symbols are ordered as in Unicode except dashes.
|
|
483
|
+
"""
|
|
484
|
+
|
|
485
|
+
# fmt: off
|
|
486
|
+
|
|
487
|
+
HORIZONTAL: str = "━"
|
|
488
|
+
VERTICAL: str = "┃"
|
|
489
|
+
TOP_LEFT: str = "┏"
|
|
490
|
+
TOP_RIGHT: str = "┓"
|
|
491
|
+
BOTTOM_LEFT: str = "┗"
|
|
492
|
+
BOTTOM_RIGHT: str = "┛"
|
|
493
|
+
# Joints for tables making
|
|
494
|
+
LEFT_T: str = "┣"
|
|
495
|
+
RIGHT_T: str = "┫"
|
|
496
|
+
TOP_T: str = "┳"
|
|
497
|
+
BOTTOM_T: str = "┻"
|
|
498
|
+
CROSS: str = "╋"
|
|
499
|
+
# Dashes
|
|
500
|
+
HORIZONTAL_4_DASHES: str = "┉"
|
|
501
|
+
HORIZONTAL_3_DASHES: str = "┅"
|
|
502
|
+
HORIZONTAL_2_DASHES: str = "╍"
|
|
503
|
+
VERTICAL_2_DASH: str = "╏"
|
|
504
|
+
VERTICAL_3_DASH: str = "┇"
|
|
505
|
+
VERTICAL_4_DASH: str = "┋"
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
class _DoubleBoxSymbols(typing.NamedTuple):
|
|
509
|
+
"""Box symbols for drawing.
|
|
510
|
+
|
|
511
|
+
Symbols are ordered as in Unicode.
|
|
512
|
+
"""
|
|
513
|
+
|
|
514
|
+
# fmt: off
|
|
515
|
+
|
|
516
|
+
HORIZONTAL: str = "═"
|
|
517
|
+
VERTICAL: str = "║"
|
|
518
|
+
TOP_LEFT: str = "╔"
|
|
519
|
+
TOP_RIGHT: str = "╗"
|
|
520
|
+
BOTTOM_LEFT: str = "╚"
|
|
521
|
+
BOTTOM_RIGHT: str = "╝"
|
|
522
|
+
# Joints for tables making
|
|
523
|
+
LEFT_T: str = "╠"
|
|
524
|
+
RIGHT_T: str = "╣"
|
|
525
|
+
TOP_T: str = "╦"
|
|
526
|
+
BOTTOM_T: str = "╩"
|
|
527
|
+
CROSS: str = "╬"
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
class _BoxSymbolsCollection(typing.NamedTuple):
|
|
531
|
+
"""Standard Unicode box symbols for basic tables drawing.
|
|
532
|
+
|
|
533
|
+
.. note::
|
|
534
|
+
Transitions are not included: depends on line types, different kinds of transitions are available.
|
|
535
|
+
Please check Unicode table for transitions symbols if required.
|
|
536
|
+
"""
|
|
537
|
+
|
|
538
|
+
# fmt: off
|
|
539
|
+
|
|
540
|
+
LIGHT: _LightBoxSymbols = _LightBoxSymbols()
|
|
541
|
+
HEAVY: _HeavyBoxSymbols = _HeavyBoxSymbols()
|
|
542
|
+
DOUBLE: _DoubleBoxSymbols = _DoubleBoxSymbols()
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
BOX_SYMBOLS = _BoxSymbolsCollection()
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
class BAR_SYMBOLS(str, enum.Enum):
|
|
549
|
+
"""Standard Unicode bar symbols excluding empty space.
|
|
550
|
+
|
|
551
|
+
Start from space (0), then 1/8 till full block (1/1).
|
|
552
|
+
Typically used only 8 from this symbol collection depends on use-case:
|
|
553
|
+
* empty - 7/8 and styles for BG different on both sides (like standard `ProgressBar` and `BarGraph`)
|
|
554
|
+
* 1/8 - full block and single style for BG on the right side
|
|
555
|
+
"""
|
|
556
|
+
|
|
557
|
+
# fmt: off
|
|
558
|
+
|
|
559
|
+
HORISONTAL = " ▏▎▍▌▋▊▉█"
|
|
560
|
+
VERTICAL = " ▁▂▃▄▅▆▇█"
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
class _SHADE_SYMBOLS(typing.NamedTuple):
|
|
564
|
+
"""Standard shade symbols excluding empty space."""
|
|
565
|
+
|
|
566
|
+
# fmt: off
|
|
567
|
+
|
|
568
|
+
FULL_BLOCK: str = "█"
|
|
569
|
+
DARK_SHADE: str = "▓"
|
|
570
|
+
MEDIUM_SHADE: str = "▒"
|
|
571
|
+
LITE_SHADE: str = "░"
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
SHADE_SYMBOLS = _SHADE_SYMBOLS()
|