flexablelib-tui 3.5.5__tar.gz → 3.7.0__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.5/flexablelib_tui.egg-info → flexablelib_tui-3.7.0}/PKG-INFO +2 -2
  2. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/flexablelib_tui/__init__.py +1 -1
  3. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/flexablelib_tui/app.py +54 -1
  4. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0/flexablelib_tui.egg-info}/PKG-INFO +2 -2
  5. flexablelib_tui-3.7.0/flexablelib_tui.egg-info/requires.txt +1 -0
  6. flexablelib_tui-3.5.5/flexablelib_tui.egg-info/requires.txt +0 -1
  7. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/LICENSE +0 -0
  8. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/MANIFEST.in +0 -0
  9. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/README.md +0 -0
  10. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/flexablelib_tui/accessibility.py +0 -0
  11. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/flexablelib_tui/capabilities.py +0 -0
  12. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/flexablelib_tui/graphics.py +0 -0
  13. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/flexablelib_tui/keymap.py +0 -0
  14. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/flexablelib_tui/keys.py +0 -0
  15. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/flexablelib_tui/py.typed +0 -0
  16. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/flexablelib_tui/screen.py +0 -0
  17. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/flexablelib_tui/terminal.py +0 -0
  18. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/flexablelib_tui/widgets.py +0 -0
  19. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/flexablelib_tui/wincon.py +0 -0
  20. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/flexablelib_tui.egg-info/SOURCES.txt +0 -0
  21. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/flexablelib_tui.egg-info/dependency_links.txt +0 -0
  22. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/flexablelib_tui.egg-info/top_level.txt +0 -0
  23. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/setup.cfg +0 -0
  24. {flexablelib_tui-3.5.5 → flexablelib_tui-3.7.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib-tui
3
- Version: 3.5.5
3
+ Version: 3.7.0
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.5
20
+ Requires-Dist: flexablelib>=3.7.0
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.5'
15
+ __version__ = '3.7.0'
16
16
 
17
17
  from .widgets import (ProgressBar, Sparkline, BarChart, StatusBar, KeyHints,
18
18
  LogView, Text, Rule)
@@ -1115,6 +1115,10 @@ class ScrollView(Component):
1115
1115
  view's width minus the scroll bar). ``height`` fixes the view's height;
1116
1116
  otherwise it takes the height its slot gives it. ``follow=True`` keeps
1117
1117
  the view at the bottom while it is there (for logs).
1118
+ ``follow_focus=True`` (the default) scrolls to the component inside
1119
+ the content that takes the focus (Tab reaches the ones out of view):
1120
+ each time the focus moves to another component inside, its rows are
1121
+ brought into view; scrolling by hand afterwards is left alone.
1118
1122
  """
1119
1123
 
1120
1124
  focusable = True
@@ -1122,8 +1126,11 @@ class ScrollView(Component):
1122
1126
  role = 'scrollbar'
1123
1127
 
1124
1128
  def __init__(self, content='', height=None, follow=False, scrollbar=True,
1125
- color='bright_black', focus_color='cyan', step=3, **kwargs):
1129
+ color='bright_black', focus_color='cyan', step=3,
1130
+ follow_focus=True, **kwargs):
1126
1131
  super(ScrollView, self).__init__(**kwargs)
1132
+ self.follow_focus = bool(follow_focus)
1133
+ self._followed = None
1127
1134
  self.content = content
1128
1135
  self.height = None if height is None else max(1, int(height))
1129
1136
  self.follow = bool(follow)
@@ -1165,10 +1172,56 @@ class ScrollView(Component):
1165
1172
 
1166
1173
  _last_width = None
1167
1174
 
1175
+ def _focused_inside(self):
1176
+ target = self.app.focused if self.app is not None else None
1177
+ if target is None or target is self or \
1178
+ isinstance(self.content, (str, list)):
1179
+ return None
1180
+ node, seen = getattr(target, 'parent', None), 0
1181
+ while node is not None and seen < 256:
1182
+ if node is self:
1183
+ return target
1184
+ node, seen = getattr(node, 'parent', None), seen + 1
1185
+ return None
1186
+
1187
+ def focus_rows(self, width):
1188
+ """``(first, last)`` content rows of the focused component inside
1189
+ the view, or None."""
1190
+ target = self._focused_inside()
1191
+ if target is None:
1192
+ return None
1193
+ saved = _HIT['on'], _HIT['items']
1194
+ _HIT['on'], _HIT['items'] = True, []
1195
+ try:
1196
+ text = _render_child(self.content, width)
1197
+ items = _HIT['items']
1198
+ finally:
1199
+ _HIT['on'], _HIT['items'] = saved
1200
+ _lines, regions = _fx.extract_marks(text.split('\n') if text else [])
1201
+ rows = [row for i, row, x0, x1, depth in regions
1202
+ if 0 <= i < len(items) and items[i] is target]
1203
+ return (min(rows), max(rows)) if rows else None
1204
+
1205
+ def _follow(self, inner, h):
1206
+ target = self._focused_inside()
1207
+ if target is self._followed:
1208
+ return
1209
+ self._followed = target
1210
+ span = self.focus_rows(inner) if target is not None else None
1211
+ if span is None:
1212
+ return
1213
+ first, last = span
1214
+ if first < self.offset or last - first + 1 > h:
1215
+ self.offset = first
1216
+ elif last >= self.offset + h:
1217
+ self.offset = last - h + 1
1218
+
1168
1219
  def draw(self, width, height):
1169
1220
  self._last_width = width
1170
1221
  h = self.height or height or self.view_height
1171
1222
  inner = max(1, width - 1) if self.scrollbar else width
1223
+ if self.follow_focus:
1224
+ self._follow(inner, max(1, h))
1172
1225
  lines = self._lines(inner)
1173
1226
  at_bottom = self.offset >= self.max_offset
1174
1227
  self.total = len(lines)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib-tui
3
- Version: 3.5.5
3
+ Version: 3.7.0
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.5
20
+ Requires-Dist: flexablelib>=3.7.0
21
21
  Dynamic: author
22
22
  Dynamic: author-email
23
23
  Dynamic: classifier
@@ -0,0 +1 @@
1
+ flexablelib>=3.7.0
@@ -1 +0,0 @@
1
- flexablelib>=3.5.5
File without changes