flexablelib-components 3.5.3__tar.gz → 3.5.4__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.5.3/flexablelib_components.egg-info → flexablelib_components-3.5.4}/PKG-INFO +3 -3
  2. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/flexablelib_components/__init__.py +1 -1
  3. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/flexablelib_components/inputs.py +19 -4
  4. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4/flexablelib_components.egg-info}/PKG-INFO +3 -3
  5. flexablelib_components-3.5.4/flexablelib_components.egg-info/requires.txt +2 -0
  6. flexablelib_components-3.5.3/flexablelib_components.egg-info/requires.txt +0 -2
  7. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/LICENSE +0 -0
  8. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/MANIFEST.in +0 -0
  9. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/README.md +0 -0
  10. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/flexablelib_components/base.py +0 -0
  11. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/flexablelib_components/data.py +0 -0
  12. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/flexablelib_components/dates.py +0 -0
  13. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/flexablelib_components/display.py +0 -0
  14. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/flexablelib_components/media.py +0 -0
  15. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/flexablelib_components/navigation.py +0 -0
  16. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/flexablelib_components/overlays.py +0 -0
  17. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/flexablelib_components/py.typed +0 -0
  18. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/flexablelib_components.egg-info/SOURCES.txt +0 -0
  19. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/flexablelib_components.egg-info/dependency_links.txt +0 -0
  20. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/flexablelib_components.egg-info/top_level.txt +0 -0
  21. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/setup.cfg +0 -0
  22. {flexablelib_components-3.5.3 → flexablelib_components-3.5.4}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib-components
3
- Version: 3.5.3
3
+ Version: 3.5.4
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.5.3
21
- Requires-Dist: flexablelib-tui>=3.5.3
20
+ Requires-Dist: flexablelib>=3.5.4
21
+ Requires-Dist: flexablelib-tui>=3.5.4
22
22
  Dynamic: author
23
23
  Dynamic: author-email
24
24
  Dynamic: classifier
@@ -17,7 +17,7 @@ keys to the focused component) and also renders on its own with
17
17
  ``render(width)``. See docs/COMPONENTS.md.
18
18
  """
19
19
 
20
- __version__ = '3.5.3'
20
+ __version__ = '3.5.4'
21
21
 
22
22
  from .base import Theme, DEFAULT_THEME, Input, Box, Button, frame
23
23
  from .inputs import (TextInput, PasswordInput, NumberInput, ExpressionInput,
@@ -145,7 +145,7 @@ class TextInput(Input):
145
145
  self.refresh()
146
146
 
147
147
  def _word_left(self):
148
- i = self.cursor_pos
148
+ i = max(0, min(self.cursor_pos, len(self.text)))
149
149
  while i > 0 and not _WORD.match(self.text[i - 1]):
150
150
  i -= 1
151
151
  while i > 0 and _WORD.match(self.text[i - 1]):
@@ -153,7 +153,8 @@ class TextInput(Input):
153
153
  return i
154
154
 
155
155
  def _word_right(self):
156
- i, n = self.cursor_pos, len(self.text)
156
+ n = len(self.text)
157
+ i = max(0, min(self.cursor_pos, n))
157
158
  while i < n and not _WORD.match(self.text[i]):
158
159
  i += 1
159
160
  while i < n and _WORD.match(self.text[i]):
@@ -162,7 +163,9 @@ class TextInput(Input):
162
163
 
163
164
  def on_key(self, key):
164
165
  k = str(key)
165
- pos, text = self.cursor_pos, self.text
166
+ text = self.text
167
+ # cursor_pos is public: keep a value set from outside in range.
168
+ pos = self.cursor_pos = max(0, min(self.cursor_pos, len(text)))
166
169
  if k == 'paste':
167
170
  return self.insert(key.char.replace('\r', '').replace('\n', ' '))
168
171
  if key.is_printable or k == 'space':
@@ -214,10 +217,15 @@ class TextInput(Input):
214
217
  break
215
218
  acc += w
216
219
  pos += 1
217
- self.cursor_pos = pos
220
+ self.cursor_pos = max(0, min(self._text_index(pos), len(self.text)))
218
221
  self.refresh()
219
222
  return True
220
223
 
224
+ def _text_index(self, shown_index):
225
+ """The ``text`` index under character ``shown_index`` of
226
+ ``shown_text()`` (they differ when a prefix is drawn)."""
227
+ return shown_index
228
+
221
229
  # drawing
222
230
  def shown_text(self):
223
231
  if self.mask_char:
@@ -469,6 +477,9 @@ class MoneyInput(NumberInput):
469
477
  return ''
470
478
  return '{0}{1:,.{2}f}'.format(self.symbol, value, self.decimals or 0)
471
479
 
480
+ def _text_index(self, shown_index):
481
+ return shown_index - (len(self.symbol) if self.focused else 0)
482
+
472
483
  def _viewport(self, shown, avail):
473
484
  # The symbol is not part of the editable text: shift the cursor.
474
485
  saved = self.cursor_pos
@@ -1576,6 +1587,10 @@ class CoordinatesInput(Input):
1576
1587
  return self.error
1577
1588
 
1578
1589
  def control(self, width, height):
1590
+ if width < 3:
1591
+ # No room for two columns: latitude above longitude.
1592
+ return (self.latitude.render(width=width).split('\n') +
1593
+ self.longitude.render(width=width).split('\n'))
1579
1594
  half = max(1, (width - 1) // 2)
1580
1595
  left = self.latitude.render(width=half).split('\n')
1581
1596
  right = self.longitude.render(width=width - half - 1).split('\n')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib-components
3
- Version: 3.5.3
3
+ Version: 3.5.4
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.5.3
21
- Requires-Dist: flexablelib-tui>=3.5.3
20
+ Requires-Dist: flexablelib>=3.5.4
21
+ Requires-Dist: flexablelib-tui>=3.5.4
22
22
  Dynamic: author
23
23
  Dynamic: author-email
24
24
  Dynamic: classifier
@@ -0,0 +1,2 @@
1
+ flexablelib>=3.5.4
2
+ flexablelib-tui>=3.5.4
@@ -1,2 +0,0 @@
1
- flexablelib>=3.5.3
2
- flexablelib-tui>=3.5.3