flexablelib-tui 3.5.2__tar.gz → 3.5.3__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 (24) hide show
  1. {flexablelib_tui-3.5.2/flexablelib_tui.egg-info → flexablelib_tui-3.5.3}/PKG-INFO +2 -2
  2. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/flexablelib_tui/__init__.py +1 -1
  3. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/flexablelib_tui/accessibility.py +28 -16
  4. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3/flexablelib_tui.egg-info}/PKG-INFO +2 -2
  5. flexablelib_tui-3.5.3/flexablelib_tui.egg-info/requires.txt +1 -0
  6. flexablelib_tui-3.5.2/flexablelib_tui.egg-info/requires.txt +0 -1
  7. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/LICENSE +0 -0
  8. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/MANIFEST.in +0 -0
  9. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/README.md +0 -0
  10. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/flexablelib_tui/app.py +0 -0
  11. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/flexablelib_tui/capabilities.py +0 -0
  12. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/flexablelib_tui/graphics.py +0 -0
  13. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/flexablelib_tui/keymap.py +0 -0
  14. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/flexablelib_tui/keys.py +0 -0
  15. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/flexablelib_tui/py.typed +0 -0
  16. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/flexablelib_tui/screen.py +0 -0
  17. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/flexablelib_tui/terminal.py +0 -0
  18. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/flexablelib_tui/widgets.py +0 -0
  19. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/flexablelib_tui/wincon.py +0 -0
  20. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/flexablelib_tui.egg-info/SOURCES.txt +0 -0
  21. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/flexablelib_tui.egg-info/dependency_links.txt +0 -0
  22. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/flexablelib_tui.egg-info/top_level.txt +0 -0
  23. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/setup.cfg +0 -0
  24. {flexablelib_tui-3.5.2 → flexablelib_tui-3.5.3}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib-tui
3
- Version: 3.5.2
3
+ Version: 3.5.3
4
4
  Summary: Terminal interfaces for flexablelib: widgets, full-screen layout, diff redraw, keyboard input, focus and key bindings.
5
5
  Home-page: https://github.com/Opus-Perpetuus/flexablelib
6
6
  Author: Benjamin Ramirez
@@ -17,7 +17,7 @@ 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.5.2
20
+ Requires-Dist: flexablelib>=3.5.3
21
21
  Dynamic: author
22
22
  Dynamic: author-email
23
23
  Dynamic: classifier
@@ -12,7 +12,7 @@ Everything here is also reachable as ``flexablelib.ProgressBar``,
12
12
  ``flexablelib.App`` and so on once installed.
13
13
  """
14
14
 
15
- __version__ = '3.5.2'
15
+ __version__ = '3.5.3'
16
16
 
17
17
  from .widgets import (ProgressBar, Sparkline, BarChart, StatusBar, KeyHints,
18
18
  LogView, Text, Rule)
@@ -44,6 +44,7 @@ reader:
44
44
  import contextlib
45
45
  import math
46
46
  import os
47
+ import re
47
48
  import sys
48
49
 
49
50
  from flexablelib import _frames as _fx
@@ -340,6 +341,11 @@ _ANSI_RGB = {
340
341
  'bright_blue': (92, 92, 255), 'bright_magenta': (255, 0, 255),
341
342
  'bright_cyan': (0, 255, 255), 'bright_white': (255, 255, 255),
342
343
  }
344
+ _HEX_RE = re.compile(r'^#?([0-9a-f]{6})$|^#([0-9a-f]{3})$')
345
+ _DIGITS_RE = re.compile(r'^[0-9]{1,3}$')
346
+ _GREY_RE = re.compile(r'^gr[ae]y([0-9]{1,3})$')
347
+ # The greys of the xterm 256 palette: black, the 24-step ramp, white.
348
+ _GREY_LEVELS = [0] + [8 + 10 * i for i in range(24)] + [255]
343
349
  _ATTRS = ('bold', 'dim', 'italic', 'underline', 'blink', 'reverse',
344
350
  'hidden', 'strike', 'strikethrough', 'normal', 'faint')
345
351
 
@@ -359,33 +365,39 @@ def _xterm_rgb(index):
359
365
 
360
366
 
361
367
  def parse_color(token):
362
- """``(r, g, b)`` for ``'#rrggbb'``, ``'#rgb'``, a colour name,
363
- ``'color:N'`` / ``N`` (256 palette) or ``'greyNN'``; ``None`` if not."""
368
+ """``(r, g, b)`` for ``'#rrggbb'``, ``'#rgb'``, ``'rrggbb'``, a colour
369
+ name, ``'color:N'`` / ``'colour:N'`` / ``N`` (256 palette) or
370
+ ``'greyNN'`` (the xterm grey a terminal shows for it); ``None`` if not.
371
+
372
+ Every colour :func:`flexablelib.colors.parse_spec` draws is understood,
373
+ so contrast checks see the colour that is really on screen."""
364
374
  if token is None:
365
375
  return None
366
376
  if isinstance(token, tuple):
367
377
  return token
368
378
  token = str(token).strip().lower()
369
- if token.startswith('#'):
370
- digits = token[1:]
379
+ hex_match = _HEX_RE.match(token)
380
+ if hex_match:
381
+ digits = hex_match.group(1) or hex_match.group(2)
371
382
  if len(digits) == 3:
372
383
  digits = ''.join(c * 2 for c in digits)
373
- if len(digits) == 6:
374
- try:
375
- return tuple(int(digits[k:k + 2], 16) for k in (0, 2, 4))
376
- except ValueError:
377
- return None
384
+ return tuple(int(digits[k:k + 2], 16) for k in (0, 2, 4))
385
+ if token.startswith('#'):
378
386
  return None
379
387
  if token in _ANSI_RGB:
380
388
  return _ANSI_RGB[token]
381
- if token.startswith('color:'):
382
- token = token[6:]
383
- if token.isdigit() and int(token) < 256:
389
+ for prefix in ('color:', 'colour:'):
390
+ if token.startswith(prefix):
391
+ token = token[len(prefix):]
392
+ break
393
+ if _DIGITS_RE.match(token) and int(token) < 256:
384
394
  return _xterm_rgb(int(token))
385
- for prefix in ('grey', 'gray'):
386
- if token.startswith(prefix) and token[len(prefix):].isdigit():
387
- level = int(round(int(token[len(prefix):]) * 2.55))
388
- return (level, level, level)
395
+ grey = _GREY_RE.match(token)
396
+ if grey and int(grey.group(1)) <= 100:
397
+ # parse_spec draws the nearest xterm grey, not the exact level.
398
+ target = int(grey.group(1)) * 255 / 100.0
399
+ level = min(_GREY_LEVELS, key=lambda value: abs(value - target))
400
+ return (level, level, level)
389
401
  return None
390
402
 
391
403
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib-tui
3
- Version: 3.5.2
3
+ Version: 3.5.3
4
4
  Summary: Terminal interfaces for flexablelib: widgets, full-screen layout, diff redraw, keyboard input, focus and key bindings.
5
5
  Home-page: https://github.com/Opus-Perpetuus/flexablelib
6
6
  Author: Benjamin Ramirez
@@ -17,7 +17,7 @@ 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.5.2
20
+ Requires-Dist: flexablelib>=3.5.3
21
21
  Dynamic: author
22
22
  Dynamic: author-email
23
23
  Dynamic: classifier
@@ -0,0 +1 @@
1
+ flexablelib>=3.5.3
@@ -1 +0,0 @@
1
- flexablelib>=3.5.2
File without changes