flexablelib-components 3.7.4__tar.gz → 3.7.6__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.
- {flexablelib_components-3.7.4/flexablelib_components.egg-info → flexablelib_components-3.7.6}/PKG-INFO +3 -3
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/__init__.py +1 -1
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/base.py +19 -6
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/media.py +32 -5
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6/flexablelib_components.egg-info}/PKG-INFO +3 -3
- flexablelib_components-3.7.6/flexablelib_components.egg-info/requires.txt +2 -0
- flexablelib_components-3.7.4/flexablelib_components.egg-info/requires.txt +0 -2
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/LICENSE +0 -0
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/MANIFEST.in +0 -0
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/README.md +0 -0
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/data.py +0 -0
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/dates.py +0 -0
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/display.py +0 -0
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/inputs.py +0 -0
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/navigation.py +0 -0
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/overlays.py +0 -0
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/py.typed +0 -0
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components.egg-info/SOURCES.txt +0 -0
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components.egg-info/dependency_links.txt +0 -0
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components.egg-info/top_level.txt +0 -0
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/setup.cfg +0 -0
- {flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flexablelib-components
|
|
3
|
-
Version: 3.7.
|
|
3
|
+
Version: 3.7.6
|
|
4
4
|
Summary: Interactive terminal components for flexablelib: inputs, dates, tables, forms, menus, tabs, dialogs and more.
|
|
5
5
|
Home-page: https://github.com/Opus-Perpetuus/flexablelib
|
|
6
6
|
Author: Benjamin Ramirez
|
|
@@ -17,8 +17,8 @@ Classifier: Topic :: Software Development :: User Interfaces
|
|
|
17
17
|
Requires-Python: >=3.8
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
License-File: LICENSE
|
|
20
|
-
Requires-Dist: flexablelib>=3.7.
|
|
21
|
-
Requires-Dist: flexablelib-tui>=3.7.
|
|
20
|
+
Requires-Dist: flexablelib>=3.7.6
|
|
21
|
+
Requires-Dist: flexablelib-tui>=3.7.6
|
|
22
22
|
Dynamic: author
|
|
23
23
|
Dynamic: author-email
|
|
24
24
|
Dynamic: classifier
|
{flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/__init__.py
RENAMED
|
@@ -18,7 +18,7 @@ keys to the focused component) and also renders on its own with
|
|
|
18
18
|
``render(width)``. See docs/COMPONENTS.md.
|
|
19
19
|
"""
|
|
20
20
|
|
|
21
|
-
__version__ = '3.7.
|
|
21
|
+
__version__ = '3.7.6'
|
|
22
22
|
|
|
23
23
|
from .base import Theme, DEFAULT_THEME, Input, Box, Button, frame
|
|
24
24
|
from .inputs import (TextInput, PasswordInput, NumberInput, ExpressionInput,
|
{flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/base.py
RENAMED
|
@@ -4,7 +4,7 @@ labels, help text and validation, and a few drawing helpers.
|
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
from flexablelib import _frames as _fx
|
|
7
|
-
from flexablelib.colors import RESET, parse_spec
|
|
7
|
+
from flexablelib.colors import RESET, color_depth, parse_spec
|
|
8
8
|
from flexablelib_tui import Component
|
|
9
9
|
|
|
10
10
|
__all__ = ['Theme', 'DEFAULT_THEME', 'THEMES', 'Input', 'frame',
|
|
@@ -30,8 +30,8 @@ class Theme(object):
|
|
|
30
30
|
|
|
31
31
|
def __init__(self, accent='cyan', muted='bright_black', text=None,
|
|
32
32
|
selection='bold black on cyan', border='bright_black',
|
|
33
|
-
info='
|
|
34
|
-
error='
|
|
33
|
+
info='#5f87ff', success='green', warning='yellow',
|
|
34
|
+
error='bright_red', title='bold', field='on #262626',
|
|
35
35
|
background='#000000', foreground='#e5e5e5', marker=False,
|
|
36
36
|
name='custom'):
|
|
37
37
|
self.name = name
|
|
@@ -134,6 +134,17 @@ THEMES = {
|
|
|
134
134
|
|
|
135
135
|
DEFAULT_THEME = Theme(name='default')
|
|
136
136
|
|
|
137
|
+
|
|
138
|
+
def _text_on(colour):
|
|
139
|
+
"""``'black'`` or ``'white'``, whichever reads better on ``colour``."""
|
|
140
|
+
from flexablelib_tui.accessibility import spec_colors, contrast_ratio
|
|
141
|
+
rgb = spec_colors(colour)[0]
|
|
142
|
+
if rgb is None:
|
|
143
|
+
return 'white'
|
|
144
|
+
black = contrast_ratio((0, 0, 0), rgb)
|
|
145
|
+
white = contrast_ratio(spec_colors('white')[0], rgb)
|
|
146
|
+
return 'black' if black > white else 'white'
|
|
147
|
+
|
|
137
148
|
_SPEC_CACHE = {}
|
|
138
149
|
|
|
139
150
|
_BOXES = {
|
|
@@ -234,9 +245,10 @@ class _Themed(Component):
|
|
|
234
245
|
def paint(self, text, spec):
|
|
235
246
|
if not text or not spec or not self._active():
|
|
236
247
|
return text
|
|
237
|
-
|
|
248
|
+
key = (spec, color_depth())
|
|
249
|
+
prefix = _SPEC_CACHE.get(key)
|
|
238
250
|
if prefix is None:
|
|
239
|
-
prefix = _SPEC_CACHE[
|
|
251
|
+
prefix = _SPEC_CACHE[key] = parse_spec(spec)
|
|
240
252
|
if not prefix:
|
|
241
253
|
return text
|
|
242
254
|
return prefix + text.replace(RESET, RESET + prefix) + RESET
|
|
@@ -547,7 +559,8 @@ class Button(_Themed):
|
|
|
547
559
|
if self.disabled:
|
|
548
560
|
return theme.muted
|
|
549
561
|
base = {'primary': 'black on ' + theme.accent,
|
|
550
|
-
'danger': '
|
|
562
|
+
'danger': _text_on(theme.error) + ' on ' + theme.error
|
|
563
|
+
}.get(self.kind)
|
|
551
564
|
if self.focused:
|
|
552
565
|
return 'bold reverse' if base is None else 'bold ' + base
|
|
553
566
|
return base or 'on bright_black'
|
{flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/media.py
RENAMED
|
@@ -81,6 +81,8 @@ class Image(_Themed):
|
|
|
81
81
|
self.method = method
|
|
82
82
|
self.blocks = blocks
|
|
83
83
|
self.align = align
|
|
84
|
+
if background is not None:
|
|
85
|
+
_rgb(background) # refuse an unknown colour now
|
|
84
86
|
self.background = background
|
|
85
87
|
self.upscale = upscale
|
|
86
88
|
self.animate = animate
|
|
@@ -102,7 +104,13 @@ class Image(_Themed):
|
|
|
102
104
|
if isinstance(src, (str, os.PathLike)):
|
|
103
105
|
text = os.fspath(src)
|
|
104
106
|
if '://' in text:
|
|
105
|
-
|
|
107
|
+
# The file name: no query (a signed URL's token) or
|
|
108
|
+
# fragment, and %-escapes decoded.
|
|
109
|
+
from urllib.parse import unquote, urlsplit
|
|
110
|
+
parts = urlsplit(text)
|
|
111
|
+
path = parts.path.rstrip('/')
|
|
112
|
+
last = unquote(path.rsplit('/', 1)[-1]) if path else ''
|
|
113
|
+
return last or parts.netloc or text
|
|
106
114
|
return os.path.basename(text.rstrip('/\\')) or text
|
|
107
115
|
return getattr(src, 'name', None) or 'imagen'
|
|
108
116
|
|
|
@@ -310,6 +318,13 @@ class Image(_Themed):
|
|
|
310
318
|
if method == 'text':
|
|
311
319
|
cell_px = _img.CELL_PIXELS[mode]
|
|
312
320
|
cols, rows, crop = self._box(bm, width, height, cell)
|
|
321
|
+
limit = len(_g.DIACRITICS)
|
|
322
|
+
if method == 'kitty' and (info.kitty_placeholders or info.tmux) \
|
|
323
|
+
and (cols > limit or rows > limit):
|
|
324
|
+
# Placeholder cells number their row and column with one of
|
|
325
|
+
# these combining marks: a bigger picture is drawn smaller.
|
|
326
|
+
cols, rows, crop = self._box(bm, min(width, limit),
|
|
327
|
+
min(height or limit, limit), cell)
|
|
313
328
|
if cols < 2 or rows < 1:
|
|
314
329
|
return self._fallback(avail, 'no cabe ({0}×{1})'.format(
|
|
315
330
|
width, height)) + caption
|
|
@@ -546,12 +561,24 @@ class ImageViewer(_Themed):
|
|
|
546
561
|
|
|
547
562
|
|
|
548
563
|
def _rgb(color):
|
|
564
|
+
"""``(r, g, b)`` for a background: a tuple, or any colour the library
|
|
565
|
+
draws (``'#fff'``, ``'white'``, ``'color:15'``, ``'grey50'``, ``'on
|
|
566
|
+
white'``)."""
|
|
549
567
|
if isinstance(color, (tuple, list)):
|
|
550
568
|
return tuple(int(c) for c in color[:3])
|
|
551
|
-
text = str(color).
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
569
|
+
text = str(color).strip()
|
|
570
|
+
bare = text.lstrip('#')
|
|
571
|
+
if len(bare) in (3, 6, 8) and all(c in '0123456789abcdefABCDEF'
|
|
572
|
+
for c in bare):
|
|
573
|
+
if len(bare) == 3:
|
|
574
|
+
bare = ''.join(c * 2 for c in bare)
|
|
575
|
+
return int(bare[0:2], 16), int(bare[2:4], 16), int(bare[4:6], 16)
|
|
576
|
+
fg, bg, _attrs = _a11y.spec_colors(text)
|
|
577
|
+
rgb = bg or fg
|
|
578
|
+
if rgb is None:
|
|
579
|
+
raise ValueError('background: colour not understood: {0!r}'
|
|
580
|
+
.format(color))
|
|
581
|
+
return tuple(rgb)
|
|
555
582
|
|
|
556
583
|
|
|
557
584
|
def _wrap(text, width):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flexablelib-components
|
|
3
|
-
Version: 3.7.
|
|
3
|
+
Version: 3.7.6
|
|
4
4
|
Summary: Interactive terminal components for flexablelib: inputs, dates, tables, forms, menus, tabs, dialogs and more.
|
|
5
5
|
Home-page: https://github.com/Opus-Perpetuus/flexablelib
|
|
6
6
|
Author: Benjamin Ramirez
|
|
@@ -17,8 +17,8 @@ Classifier: Topic :: Software Development :: User Interfaces
|
|
|
17
17
|
Requires-Python: >=3.8
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
License-File: LICENSE
|
|
20
|
-
Requires-Dist: flexablelib>=3.7.
|
|
21
|
-
Requires-Dist: flexablelib-tui>=3.7.
|
|
20
|
+
Requires-Dist: flexablelib>=3.7.6
|
|
21
|
+
Requires-Dist: flexablelib-tui>=3.7.6
|
|
22
22
|
Dynamic: author
|
|
23
23
|
Dynamic: author-email
|
|
24
24
|
Dynamic: classifier
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/data.py
RENAMED
|
File without changes
|
{flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/dates.py
RENAMED
|
File without changes
|
{flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/display.py
RENAMED
|
File without changes
|
{flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/inputs.py
RENAMED
|
File without changes
|
{flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/navigation.py
RENAMED
|
File without changes
|
{flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/overlays.py
RENAMED
|
File without changes
|
{flexablelib_components-3.7.4 → flexablelib_components-3.7.6}/flexablelib_components/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|