flexablelib-components 3.7.5__tar.gz → 3.7.7__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.
Files changed (22) hide show
  1. {flexablelib_components-3.7.5/flexablelib_components.egg-info → flexablelib_components-3.7.7}/PKG-INFO +3 -3
  2. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/flexablelib_components/__init__.py +1 -1
  3. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/flexablelib_components/media.py +32 -5
  4. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/flexablelib_components/navigation.py +9 -3
  5. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7/flexablelib_components.egg-info}/PKG-INFO +3 -3
  6. flexablelib_components-3.7.7/flexablelib_components.egg-info/requires.txt +2 -0
  7. flexablelib_components-3.7.5/flexablelib_components.egg-info/requires.txt +0 -2
  8. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/LICENSE +0 -0
  9. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/MANIFEST.in +0 -0
  10. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/README.md +0 -0
  11. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/flexablelib_components/base.py +0 -0
  12. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/flexablelib_components/data.py +0 -0
  13. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/flexablelib_components/dates.py +0 -0
  14. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/flexablelib_components/display.py +0 -0
  15. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/flexablelib_components/inputs.py +0 -0
  16. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/flexablelib_components/overlays.py +0 -0
  17. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/flexablelib_components/py.typed +0 -0
  18. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/flexablelib_components.egg-info/SOURCES.txt +0 -0
  19. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/flexablelib_components.egg-info/dependency_links.txt +0 -0
  20. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/flexablelib_components.egg-info/top_level.txt +0 -0
  21. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/setup.cfg +0 -0
  22. {flexablelib_components-3.7.5 → flexablelib_components-3.7.7}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib-components
3
- Version: 3.7.5
3
+ Version: 3.7.7
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.5
21
- Requires-Dist: flexablelib-tui>=3.7.5
20
+ Requires-Dist: flexablelib>=3.7.7
21
+ Requires-Dist: flexablelib-tui>=3.7.7
22
22
  Dynamic: author
23
23
  Dynamic: author-email
24
24
  Dynamic: classifier
@@ -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.5'
21
+ __version__ = '3.7.7'
22
22
 
23
23
  from .base import Theme, DEFAULT_THEME, Input, Box, Button, frame
24
24
  from .inputs import (TextInput, PasswordInput, NumberInput, ExpressionInput,
@@ -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
- return text.rstrip('/').rsplit('/', 1)[-1] or text
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).lstrip('#')
552
- if len(text) == 3:
553
- text = ''.join(c * 2 for c in text)
554
- return int(text[0:2], 16), int(text[2:4], 16), int(text[4:6], 16)
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):
@@ -6,7 +6,8 @@ the application shell that wires them together.
6
6
  """
7
7
 
8
8
  from flexablelib import _frames as _fx
9
- from flexablelib.layout import _accepts_height, _natural_width, _render_child
9
+ from flexablelib.layout import (_accepts_height, _natural_width, _one_line,
10
+ _render_child)
10
11
 
11
12
  from flexablelib_tui import Key
12
13
 
@@ -1752,8 +1753,13 @@ class GridView(_Themed):
1752
1753
 
1753
1754
  def draw(self, width, height):
1754
1755
  out = []
1755
- if self.title:
1756
- out.append(self.paint(self.title, 'bold'))
1756
+ if self.title and (height is None or height > 1):
1757
+ # One line no wider than the grid: a newline or a long title
1758
+ # would push the stack past its height or width.
1759
+ title = _one_line(self.title)
1760
+ if _fx.visible_width(title) > width:
1761
+ title = _fx.truncate(title, max(1, width), '\u2026')
1762
+ out.append(self.paint(title, 'bold'))
1757
1763
  room = None if height is None else max(1, height - len(out))
1758
1764
  grid = self.grid()
1759
1765
  text = grid.render(width=width, height=room) if room else \
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib-components
3
- Version: 3.7.5
3
+ Version: 3.7.7
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.5
21
- Requires-Dist: flexablelib-tui>=3.7.5
20
+ Requires-Dist: flexablelib>=3.7.7
21
+ Requires-Dist: flexablelib-tui>=3.7.7
22
22
  Dynamic: author
23
23
  Dynamic: author-email
24
24
  Dynamic: classifier
@@ -0,0 +1,2 @@
1
+ flexablelib>=3.7.7
2
+ flexablelib-tui>=3.7.7
@@ -1,2 +0,0 @@
1
- flexablelib>=3.7.5
2
- flexablelib-tui>=3.7.5