flexablelib 3.5.1__tar.gz → 3.5.2__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 (122) hide show
  1. {flexablelib-3.5.1 → flexablelib-3.5.2}/CHANGELOG.md +15 -0
  2. {flexablelib-3.5.1 → flexablelib-3.5.2}/PKG-INFO +9 -9
  3. {flexablelib-3.5.1 → flexablelib-3.5.2}/examples/admin.py +7 -6
  4. flexablelib-3.5.2/examples/video/demo.py +332 -0
  5. flexablelib-3.5.2/examples/video/render.py +72 -0
  6. flexablelib-3.5.2/examples/video/scenes.py +839 -0
  7. flexablelib-3.5.2/examples/video/thumbnail.py +56 -0
  8. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/_legacy/widgets.py +3 -1
  9. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib.egg-info/PKG-INFO +9 -9
  10. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib.egg-info/SOURCES.txt +5 -0
  11. flexablelib-3.5.2/flexablelib.egg-info/requires.txt +35 -0
  12. {flexablelib-3.5.1 → flexablelib-3.5.2}/package.json +1 -1
  13. flexablelib-3.5.2/tests/test_v352_fixes.py +169 -0
  14. flexablelib-3.5.1/flexablelib.egg-info/requires.txt +0 -35
  15. {flexablelib-3.5.1 → flexablelib-3.5.2}/.coveragerc +0 -0
  16. {flexablelib-3.5.1 → flexablelib-3.5.2}/LICENSE +0 -0
  17. {flexablelib-3.5.1 → flexablelib-3.5.2}/MANIFEST.in +0 -0
  18. {flexablelib-3.5.1 → flexablelib-3.5.2}/README.md +0 -0
  19. {flexablelib-3.5.1 → flexablelib-3.5.2}/examples/dashboard.py +0 -0
  20. {flexablelib-3.5.1 → flexablelib-3.5.2}/examples/keys.py +0 -0
  21. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/__init__.py +0 -0
  22. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/_frames.py +0 -0
  23. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/_images.py +0 -0
  24. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/_legacy/__init__.py +0 -0
  25. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/_legacy/screen.py +0 -0
  26. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/_speedups.c +0 -0
  27. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/_width_tables.h +0 -0
  28. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/box_topology.py +0 -0
  29. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/cells.py +0 -0
  30. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/colors.py +0 -0
  31. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/columns.py +0 -0
  32. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/fast.py +0 -0
  33. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/identifiers.py +0 -0
  34. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/layout.py +0 -0
  35. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/merges.py +0 -0
  36. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/options.py +0 -0
  37. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/py.typed +0 -0
  38. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/readers.py +0 -0
  39. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/screen.py +0 -0
  40. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/style_compositions.py +0 -0
  41. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/table.py +0 -0
  42. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/table_strings.py +0 -0
  43. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/text_width.py +0 -0
  44. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/utils.py +0 -0
  45. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/widgets.py +0 -0
  46. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib/writers.py +0 -0
  47. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib.egg-info/dependency_links.txt +0 -0
  48. {flexablelib-3.5.1 → flexablelib-3.5.2}/flexablelib.egg-info/top_level.txt +0 -0
  49. {flexablelib-3.5.1 → flexablelib-3.5.2}/pytest.ini +0 -0
  50. {flexablelib-3.5.1 → flexablelib-3.5.2}/setup.cfg +0 -0
  51. {flexablelib-3.5.1 → flexablelib-3.5.2}/setup.py +0 -0
  52. {flexablelib-3.5.1 → flexablelib-3.5.2}/style_examples.md +0 -0
  53. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/conftest.py +0 -0
  54. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/helpers.py +0 -0
  55. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_align_indicators.py +0 -0
  56. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_box_topology.py +0 -0
  57. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_cells.py +0 -0
  58. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_columns.py +0 -0
  59. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_excel.py +0 -0
  60. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_features.py +0 -0
  61. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_issues.py +0 -0
  62. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_merge_edge_matrix.py +0 -0
  63. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_merge_fill.py +0 -0
  64. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_merges.py +0 -0
  65. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_public_api_edges.py +0 -0
  66. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_readme_examples.py +0 -0
  67. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_stress_matrix.py +0 -0
  68. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_style_line_widths.py +0 -0
  69. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_styles.py +0 -0
  70. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_text_width.py +0 -0
  71. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_two_pass_measurement.py +0 -0
  72. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_upstream_issues.py +0 -0
  73. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v2021_fixes.py +0 -0
  74. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v210_rows_copy.py +0 -0
  75. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v2110_fixes.py +0 -0
  76. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v211_fixes.py +0 -0
  77. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v213_features.py +0 -0
  78. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v214_features.py +0 -0
  79. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v215_features.py +0 -0
  80. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v216_features.py +0 -0
  81. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v217_features.py +0 -0
  82. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v218_features.py +0 -0
  83. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v219_coverage.py +0 -0
  84. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v219_fixes.py +0 -0
  85. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v220_exports.py +0 -0
  86. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v221_fixes.py +0 -0
  87. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v222_fixes.py +0 -0
  88. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v223_fixes.py +0 -0
  89. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v224_fixes.py +0 -0
  90. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v230_none.py +0 -0
  91. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v231_fixes.py +0 -0
  92. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v232_merge_ansi.py +0 -0
  93. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v300_style_names.py +0 -0
  94. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v310_layout.py +0 -0
  95. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v320_tui.py +0 -0
  96. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v330_components.py +0 -0
  97. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v330_frames.py +0 -0
  98. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v330_layout.py +0 -0
  99. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v330_tui.py +0 -0
  100. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v331_formats.py +0 -0
  101. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v331_panel_width.py +0 -0
  102. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v331_readers_bom.py +0 -0
  103. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v331_readers_edges.py +0 -0
  104. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v331_tabs.py +0 -0
  105. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v340_accessibility.py +0 -0
  106. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v340_core.py +0 -0
  107. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v340_input.py +0 -0
  108. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v350_images.py +0 -0
  109. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/test_v350_images_core.py +0 -0
  110. {flexablelib-3.5.1 → flexablelib-3.5.2}/tests/wincon_child.py +0 -0
  111. {flexablelib-3.5.1 → flexablelib-3.5.2}/tools/bench_frames.py +0 -0
  112. {flexablelib-3.5.1 → flexablelib-3.5.2}/tools/bench_images.py +0 -0
  113. {flexablelib-3.5.1 → flexablelib-3.5.2}/tools/benchmark.py +0 -0
  114. {flexablelib-3.5.1 → flexablelib-3.5.2}/tools/gen_ascii_table.py +0 -0
  115. {flexablelib-3.5.1 → flexablelib-3.5.2}/tools/generate_width_tables.py +0 -0
  116. {flexablelib-3.5.1 → flexablelib-3.5.2}/tools/image_demo.py +0 -0
  117. {flexablelib-3.5.1 → flexablelib-3.5.2}/tools/pty_check.py +0 -0
  118. {flexablelib-3.5.1 → flexablelib-3.5.2}/tools/readme_gallery.py +0 -0
  119. {flexablelib-3.5.1 → flexablelib-3.5.2}/tools/stress_matrix.py +0 -0
  120. {flexablelib-3.5.1 → flexablelib-3.5.2}/tools/style_examples.py +0 -0
  121. {flexablelib-3.5.1 → flexablelib-3.5.2}/tools/text_to_png.py +0 -0
  122. {flexablelib-3.5.1 → flexablelib-3.5.2}/tools/wheel_check.py +0 -0
@@ -2,6 +2,21 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [3.5.2] - 2026-11-12
6
+
7
+ ### Fixed
8
+ - **Dialogs shown with `app.push()`** (`Modal`, `ConfirmDialog`,
9
+ `PromptDialog`, `Popover`) now close with Escape, their buttons and
10
+ `close()`, as when shown with `open(app)`. `close()` looks at the app's
11
+ layers instead of a flag only `open()` set.
12
+ - **A `Form` inside a modal** closes with Escape from any field, with or
13
+ without `on_cancel`. When the form's `on_cancel` (or any code) calls
14
+ `app.pop()`, the dialog's `is_open` goes back to False and `on_close` runs
15
+ once.
16
+ - **`Text` with `\r\n` or `\r` line endings** (for example the output of
17
+ `Table.to_csv()`): every line ending counts as a new line, so no `\r`
18
+ reaches the terminal and frames, grids and cards keep their borders.
19
+
5
20
  ## [3.5.1] - 2026-11-12
6
21
 
7
22
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flexablelib
3
- Version: 3.5.1
3
+ Version: 3.5.2
4
4
  Summary: Fast, dependency-free terminal tables for Python: 54 border styles, ANSI colors, cell merges, decimal alignment, width fitting, and CSV/Markdown/HTML/Excel/LaTeX I/O.
5
5
  Home-page: https://github.com/Opus-Perpetuus/flexablelib
6
6
  Author: Benjamin Ramirez
@@ -46,15 +46,15 @@ Requires-Dist: openpyxl>=3.0; extra == "excel"
46
46
  Provides-Extra: html
47
47
  Requires-Dist: lxml>=4.0; extra == "html"
48
48
  Provides-Extra: tui
49
- Requires-Dist: flexablelib-tui==3.5.1; extra == "tui"
49
+ Requires-Dist: flexablelib-tui==3.5.2; extra == "tui"
50
50
  Provides-Extra: components
51
- Requires-Dist: flexablelib-components==3.5.1; extra == "components"
51
+ Requires-Dist: flexablelib-components==3.5.2; extra == "components"
52
52
  Provides-Extra: speed
53
- Requires-Dist: flexablelib-speedups==3.5.1; extra == "speed"
53
+ Requires-Dist: flexablelib-speedups==3.5.2; extra == "speed"
54
54
  Provides-Extra: images
55
55
  Requires-Dist: Pillow>=8; extra == "images"
56
- Requires-Dist: flexablelib-tui==3.5.1; extra == "images"
57
- Requires-Dist: flexablelib-components==3.5.1; extra == "images"
56
+ Requires-Dist: flexablelib-tui==3.5.2; extra == "images"
57
+ Requires-Dist: flexablelib-components==3.5.2; extra == "images"
58
58
  Provides-Extra: svg
59
59
  Requires-Dist: cairosvg>=2.5; extra == "svg"
60
60
  Provides-Extra: all
@@ -62,9 +62,9 @@ Requires-Dist: pandas>=1.0; extra == "all"
62
62
  Requires-Dist: openpyxl>=3.0; extra == "all"
63
63
  Requires-Dist: lxml>=4.0; extra == "all"
64
64
  Requires-Dist: Pillow>=8; extra == "all"
65
- Requires-Dist: flexablelib-tui==3.5.1; extra == "all"
66
- Requires-Dist: flexablelib-components==3.5.1; extra == "all"
67
- Requires-Dist: flexablelib-speedups==3.5.1; extra == "all"
65
+ Requires-Dist: flexablelib-tui==3.5.2; extra == "all"
66
+ Requires-Dist: flexablelib-components==3.5.2; extra == "all"
67
+ Requires-Dist: flexablelib-speedups==3.5.2; extra == "all"
68
68
  Dynamic: author
69
69
  Dynamic: author-email
70
70
  Dynamic: classifier
@@ -189,7 +189,7 @@ class Admin(object):
189
189
  ('Cancelar pedido',
190
190
  lambda: self.confirm_cancel(row))],
191
191
  width=50)
192
- self.app.push(modal)
192
+ modal.open(self.app)
193
193
 
194
194
  def confirm_cancel(self, row):
195
195
  def cancel():
@@ -197,11 +197,11 @@ class Admin(object):
197
197
  self.app.notify('Pedido {0} cancelado'.format(row['folio']),
198
198
  'warning')
199
199
  self.app.pop()
200
- self.app.push(C.ConfirmDialog(
200
+ C.ConfirmDialog(
201
201
  '¿Cancelar el pedido {0} de {1}?'.format(row['folio'],
202
202
  row['cliente']),
203
203
  on_confirm=cancel, confirm_label='Cancelar pedido',
204
- cancel_label='Volver', danger=True))
204
+ cancel_label='Volver', danger=True).open(self.app)
205
205
 
206
206
  def palette(self):
207
207
  def go(page):
@@ -224,14 +224,15 @@ class Admin(object):
224
224
  C.DateInput('Alta', TODAY, today=TODAY),
225
225
  C.Select('Ciudad', ['Mérida', 'Monterrey', 'CDMX', 'Puebla'])],
226
226
  on_submit=save, on_cancel=lambda: self.app.pop())
227
- self.app.push(C.Modal(form, title='Nuevo cliente', width=64))
227
+ C.Modal(form, title='Nuevo cliente', width=64).open(self.app)
228
228
 
229
229
  def help(self):
230
- self.app.push(C.Modal(C.MarkdownView(
230
+ C.Modal(C.MarkdownView(
231
231
  '**Tab** cambia el foco · **Ctrl-B** menú · **Ctrl-K** comandos'
232
232
  '\n\n- Tabla: flechas, `1`-`9` ordena, `/` filtra, Espacio '
233
233
  'selecciona, Enter abre\n- Filtros: `estado:pagado total>5000`'
234
- '\n- **Esc** cierra los diálogos'), title='Ayuda', width=60))
234
+ '\n- **Esc** cierra los diálogos'), title='Ayuda',
235
+ width=60).open(self.app)
235
236
 
236
237
 
237
238
  def main(argv=None):
@@ -0,0 +1,332 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Guion del video demo: teclea y ejecuta, en orden, los ejemplos del repo y las
4
+ escenas de scenes.py dentro de una terminal kitty real, y maneja teclado y
5
+ ratón con xdotool en las partes interactivas. record.sh lo lanza en una
6
+ pantalla virtual y graba con ffmpeg; aquí no se inventa ninguna salida.
7
+
8
+ python examples/video/demo.py # todo (dentro de kitty)
9
+ python examples/video/demo.py --only 5,8 # algunos capítulos
10
+ python examples/video/demo.py --log tiempos.json
11
+
12
+ Necesita kitty con ``allow_remote_control yes`` y ``--listen-on`` (variable
13
+ KITTY_LISTEN_ON), xdotool y, para el capítulo de imágenes, xterm (sixel).
14
+ """
15
+
16
+ import argparse
17
+ import fcntl
18
+ import json
19
+ import os
20
+ import shlex
21
+ import struct
22
+ import subprocess
23
+ import sys
24
+ import termios
25
+ import threading
26
+ import time
27
+
28
+ HERE = os.path.dirname(os.path.abspath(__file__))
29
+ ROOT = os.path.dirname(os.path.dirname(HERE))
30
+ sys.path.insert(0, ROOT)
31
+ from flexablelib.text_width import visible_width # noqa: E402
32
+
33
+ PROMPT = '\x1b[38;2;122;162;247m~/flexablelib\x1b[0m \x1b[38;2;187;154;247m❯\x1b[0m '
34
+ BASE_FONT = 15.0
35
+ SOCKET = os.environ.get('KITTY_LISTEN_ON', 'unix:/tmp/flexablelib-video.sock')
36
+ LOG = []
37
+ T0 = time.time()
38
+
39
+
40
+ def w(text):
41
+ sys.stdout.write(text)
42
+ sys.stdout.flush()
43
+
44
+
45
+ def clear():
46
+ w('\x1b[2J\x1b[3J\x1b[H')
47
+
48
+
49
+ def kitty(*args):
50
+ t = time.time()
51
+ try:
52
+ r = subprocess.run(['kitty', '@', '--to', SOCKET] + list(args),
53
+ capture_output=True, text=True, timeout=4)
54
+ except subprocess.TimeoutExpired as e:
55
+ r = subprocess.CompletedProcess(e.cmd, -1, '', 'timeout')
56
+ if os.environ.get('DEMO_DEBUG'):
57
+ with open(os.environ['DEMO_DEBUG'], 'a') as f:
58
+ f.write('{0} {1:.2f}s rc={2} {3!r} {4}\n'.format(
59
+ args[:2], time.time() - t, r.returncode, r.stderr[-200:], winsize()))
60
+ return r.stdout
61
+
62
+
63
+ _FONT = [None]
64
+
65
+
66
+ def font(size):
67
+ """Zoom the terminal; the screen is cleared first so nothing reflows
68
+ on camera, and the scene starts once kitty has resized."""
69
+ if _FONT[0] == size:
70
+ return
71
+ clear()
72
+ before = winsize()[:2]
73
+ for attempt in range(3):
74
+ kitty('set-font-size', str(size))
75
+ for _ in range(20):
76
+ time.sleep(0.1)
77
+ if winsize()[:2] != before:
78
+ break
79
+ else:
80
+ continue
81
+ break
82
+ time.sleep(0.6)
83
+ _FONT[0] = size
84
+
85
+
86
+ def winsize():
87
+ rows, cols, xp, yp = struct.unpack('HHHH', fcntl.ioctl(
88
+ sys.stdout.fileno(), termios.TIOCGWINSZ, b'\0' * 8))
89
+ return rows, cols, xp, yp
90
+
91
+
92
+ def cell_center(row, col):
93
+ rows, cols, xp, yp = winsize()
94
+ cw, ch = xp / cols, yp / rows
95
+ ox, oy = (1920 - xp) / 2, (1080 - yp) / 2
96
+ return int(ox + col * cw + cw / 2), int(oy + row * ch + ch / 2)
97
+
98
+
99
+ def find(text):
100
+ """Row and column of text on the kitty screen, read back from kitty."""
101
+ screen = kitty('get-text', '--extent', 'screen').split('\n')
102
+ for r, line in enumerate(screen):
103
+ i = line.find(text)
104
+ if i >= 0:
105
+ return r, visible_width(line[:i]) + 1
106
+ return None
107
+
108
+
109
+ def xdo(*args):
110
+ subprocess.run(['xdotool'] + list(args))
111
+
112
+
113
+ def act(actions):
114
+ for a in actions:
115
+ kind = a[0]
116
+ if kind == 'sleep':
117
+ time.sleep(a[1])
118
+ elif kind == 'key':
119
+ for k in a[1].split():
120
+ xdo('key', k)
121
+ time.sleep(a[2] if len(a) > 2 else 0.35)
122
+ elif kind == 'type':
123
+ xdo('type', '--delay', '90', a[1])
124
+ time.sleep(0.3)
125
+ elif kind in ('click', 'wheel', 'move'):
126
+ pos = find(a[1])
127
+ if pos is None:
128
+ continue
129
+ x, y = cell_center(*pos)
130
+ xdo('mousemove', str(x), str(y))
131
+ time.sleep(0.35)
132
+ if kind == 'click':
133
+ xdo('click', '1')
134
+ elif kind == 'wheel':
135
+ for _ in range(a[2]):
136
+ xdo('click', a[3] if len(a) > 3 else '5')
137
+ time.sleep(0.25)
138
+ time.sleep(0.4)
139
+ elif kind == 'park':
140
+ xdo('mousemove', '1910', '1070')
141
+
142
+
143
+ def type_command(command, speed=0.022):
144
+ w(PROMPT)
145
+ time.sleep(0.25)
146
+ for ch in command:
147
+ w(ch)
148
+ time.sleep(speed)
149
+ time.sleep(0.35)
150
+ w('\n')
151
+
152
+
153
+ def run(command, hold=3.0, size=None, actions=None, env=None, shown=None,
154
+ clear_first=True):
155
+ """Type the command, run it for real, drive it, then hold the result."""
156
+ if size:
157
+ font(size)
158
+ if clear_first:
159
+ clear()
160
+ type_command(shown or command)
161
+ full_env = dict(os.environ)
162
+ full_env.update(env or {})
163
+ for k, v in list(full_env.items()):
164
+ if v is None:
165
+ del full_env[k]
166
+ proc = subprocess.Popen(command, shell=True, cwd=ROOT, env=full_env)
167
+ if actions:
168
+ t = threading.Thread(target=act, args=(actions,), daemon=True)
169
+ t.start()
170
+ proc.wait()
171
+ time.sleep(hold)
172
+
173
+
174
+ def chapter(number, title, subtitle, hold=3.2):
175
+ LOG.append({'t': round(time.time() - T0, 2), 'n': number, 'title': title})
176
+ font(BASE_FONT)
177
+ clear()
178
+ subprocess.run([sys.executable, os.path.join(HERE, 'scenes.py'), 'titulo',
179
+ str(number), title, subtitle], cwd=ROOT)
180
+ time.sleep(hold)
181
+
182
+
183
+ S = 'python examples/video/scenes.py '
184
+
185
+
186
+ def ch0():
187
+ chapter(0, 'flexablelib — demo completa',
188
+ 'tablas, layouts, widgets, componentes y apps de terminal en Python · '
189
+ 'todo lo que ves es salida real de la terminal', hold=4.5)
190
+
191
+
192
+ def ch1():
193
+ chapter(1, 'Tablas', 'estilos · bordes · celdas combinadas · colores y temas · '
194
+ 'exportar a HTML, CSV y Markdown · streaming · paginación')
195
+ run(S + 'tablas-inicio', hold=4.5, size=22)
196
+ run(S + 'tablas-estilos', hold=5, size=18)
197
+ run(S + 'tablas-combinadas', hold=5, size=21)
198
+ run(S + 'tablas-temas', hold=5, size=18)
199
+ run(S + 'tablas-exportar', hold=6, size=17)
200
+ run(S + 'tablas-streaming', hold=2.5, size=18)
201
+ run(S + 'tablas-paginas', hold=1.5, size=20)
202
+
203
+
204
+ def ch2():
205
+ chapter(2, 'Grid y layout', 'bordes compartidos · span y row_span · títulos por celda · '
206
+ 'anchos fijos, fr y % · breakpoints · tarjetas')
207
+ run(S + 'grid', hold=6, size=18)
208
+
209
+
210
+ def ch3():
211
+ chapter(3, 'Widgets', 'ProgressBar · Sparkline · BarChart · StatusBar · LogView · '
212
+ 'KeyHints · Screen y Live')
213
+ run(S + 'widgets', hold=0.5, size=17)
214
+ run('python examples/dashboard.py --live 12 --interval 0.5 --theme neon', hold=0.5,
215
+ size=15)
216
+
217
+
218
+ def ch4():
219
+ chapter(4, 'Componentes', 'más de 90 componentes: entradas, fechas, visualización, '
220
+ 'navegación, datos, formularios y diálogos')
221
+ run(S + 'componentes', hold=0.3, size=20, env={'SCENE_PAUSE': '2.5'})
222
+
223
+
224
+ def ch5():
225
+ chapter(5, 'App TUI', 'teclado y ratón · foco con Tab · filtros y orden · diálogos · '
226
+ 'paleta de comandos · ayuda F1 · formularios')
227
+ run('python examples/admin.py', hold=0.3, size=17, actions=[
228
+ ('sleep', 2.5), ('key', 'Down', 0.6), ('key', 'Return', 1.4),
229
+ ('key', 'Tab', 0.5), ('type', 'estado:pagado'), ('key', 'space'),
230
+ ('type', 'total>5000'), ('key', 'Return', 1.0), ('key', 'Tab', 0.6),
231
+ ('key', '5 5', 0.8), ('key', 'Down Down', 0.5), ('key', 'Return', 2.2),
232
+ ('key', 'Escape', 0.8), ('wheel', 'Folio', 3, '5'), ('sleep', 0.6),
233
+ ('key', 'ctrl+k', 0.8), ('type', 'cli'), ('sleep', 1.4), ('key', 'Escape', 0.6),
234
+ ('click', 'Agenda'), ('sleep', 1.6), ('click', 'Resumen'), ('sleep', 1.0),
235
+ ('key', 'ctrl+n', 0.8), ('type', 'Yael'), ('key', 'Tab'), ('type', 'yael@ejemplo.mx'),
236
+ ('key', 'Tab'), ('type', '5512345678'), ('sleep', 0.8),
237
+ ('key', 'Tab Tab Tab Tab', 0.25), ('key', 'Return', 2.4),
238
+ ('key', 'F1', 2.6), ('key', 'Escape', 0.6), ('key', 'ctrl+b', 1.8),
239
+ ('park',), ('key', 'ctrl+q')])
240
+ run('python examples/keys.py', hold=0.3, size=17, actions=[
241
+ ('sleep', 2.0), ('key', 'ctrl+shift+a alt+x F5 ctrl+Return shift+Tab', 0.7),
242
+ ('type', 'hola'), ('click', 'Botón B'), ('sleep', 0.6), ('click', 'Casilla'),
243
+ ('sleep', 0.6), ('wheel', 'Elemento 03', 4, '5'), ('sleep', 1.4),
244
+ ('park',), ('key', 'ctrl+q')])
245
+
246
+
247
+ def ch6():
248
+ chapter(6, 'Accesibilidad', 'temas de alto contraste y para daltonismo · NO_COLOR · '
249
+ 'modo lector de pantalla · ASCII · foco visible sin color')
250
+ run('python examples/admin.py --theme high-contrast', hold=0.3, size=17, actions=[
251
+ ('sleep', 2.0), ('key', 'Down Return', 0.7), ('key', 'Tab Down Down', 0.5),
252
+ ('sleep', 1.2), ('key', 'ctrl+q')])
253
+ run('python examples/admin.py --theme deuteranopia', hold=0.3, size=17, actions=[
254
+ ('sleep', 2.6), ('key', 'ctrl+q')])
255
+ run('NO_COLOR=1 python examples/dashboard.py', hold=3.5, size=15,
256
+ shown='NO_COLOR=1 python examples/dashboard.py')
257
+ run(S + 'lector', hold=3.0, size=24)
258
+ run('python examples/admin.py --screen-reader --announce stdout', hold=0.3, size=17,
259
+ actions=[('sleep', 2.2), ('key', 'Tab', 1.1), ('key', 'Tab', 1.1), ('key', 'Down', 1.1),
260
+ ('key', 'Return', 1.6), ('key', 'ctrl+q')])
261
+ run('python examples/admin.py --ascii --focus-marker --no-color', hold=0.3, size=17,
262
+ actions=[('sleep', 2.6), ('key', 'ctrl+q')])
263
+
264
+
265
+ def ch7():
266
+ chapter(7, 'Folios', 'identificadores tal cual (1281, 2026, 06700) · '
267
+ 'cantidades y dinero con separadores · detección por nombre')
268
+ run(S + 'folios', hold=6, size=18)
269
+
270
+
271
+ def ch8():
272
+ chapter(8, 'Imágenes', 'kitty · iTerm2 · sixel · bloques Unicode · braille · ASCII · '
273
+ 'enlace al navegador · aviso sin navegador')
274
+ run(S + 'imagen', hold=5, size=15)
275
+ # sixel: the same scene in a real xterm (VT340 mode) on top of kitty.
276
+ clear()
277
+ type_command("xterm -ti vt340 -e 'python examples/video/scenes.py imagen sixel'")
278
+ env = dict(os.environ)
279
+ env.pop('KITTY_WINDOW_ID', None)
280
+ env['TERM'] = 'xterm-256color'
281
+ x = subprocess.Popen([
282
+ 'xterm', '-ti', 'vt340', '-xrm', 'XTerm*decTerminalID: vt340',
283
+ '-xrm', 'XTerm*numColorRegisters: 256', '-xrm', 'XTerm*sixelScrolling: true',
284
+ '-fa', 'DejaVu Sans Mono', '-fs', '12', '-bg', '#16161e', '-fg', '#c0caf5',
285
+ '-bw', '3', '-bd', '#7aa2f7', '-geometry', '104x34+300+150', '-T', 'xterm',
286
+ '-e', 'bash', '-c', 'cd {0} && {1} examples/video/scenes.py imagen sixel; sleep 6'.format(
287
+ shlex.quote(ROOT), shlex.quote(sys.executable))], env=env)
288
+ x.wait()
289
+ run(S + 'imagen-bloques', hold=5.5, size=15)
290
+ run(S + 'imagen-respaldo', hold=5, size=24)
291
+
292
+
293
+ def ch9():
294
+ chapter(9, 'Aceleración C', 'flexablelib[speed]: medición de texto, marcos, diff e '
295
+ 'imágenes en C · mismo resultado que Python · benchmark en vivo')
296
+ run(S + 'backend', hold=3.5, size=24)
297
+ run(S + 'carrera', hold=0.3, size=18, env={'SCENE_PAUSE': '4.5'})
298
+ run('python tools/bench_frames.py --frames 30', hold=4, size=26)
299
+
300
+
301
+ def ch10():
302
+ LOG.append({'t': round(time.time() - T0, 2), 'n': 10, 'title': 'Cierre'})
303
+ font(26)
304
+ clear()
305
+ subprocess.run([sys.executable, os.path.join(HERE, 'scenes.py'), 'cierre'], cwd=ROOT)
306
+ time.sleep(10)
307
+
308
+
309
+ CHAPTERS = [ch0, ch1, ch2, ch3, ch4, ch5, ch6, ch7, ch8, ch9, ch10]
310
+
311
+
312
+ def main():
313
+ parser = argparse.ArgumentParser()
314
+ parser.add_argument('--only', default='')
315
+ parser.add_argument('--log', default='')
316
+ args = parser.parse_args()
317
+ only = {int(n) for n in args.only.split(',') if n.strip()}
318
+ w('\x1b[?25l')
319
+ try:
320
+ for i, fn in enumerate(CHAPTERS):
321
+ if not only or i in only:
322
+ fn()
323
+ finally:
324
+ w('\x1b[?25h')
325
+ LOG.append({'t': round(time.time() - T0, 2), 'n': -1, 'title': 'fin'})
326
+ if args.log:
327
+ with open(args.log, 'w') as f:
328
+ json.dump({'start': T0, 'chapters': LOG}, f, indent=1, ensure_ascii=False)
329
+
330
+
331
+ if __name__ == '__main__':
332
+ main()
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Convierte la captura de record.sh en el MP4 final (1920x1080, H.264 + pista
4
+ AAC en silencio), con capítulos incrustados, y escribe la lista de capítulos
5
+ con marcas de tiempo para la descripción del video.
6
+
7
+ python examples/video/render.py /tmp/flexablelib-video/captura.mkv \\
8
+ salida.mp4 capitulos.txt
9
+ """
10
+
11
+ import json
12
+ import os
13
+ import subprocess
14
+ import sys
15
+
16
+ NAMES = {
17
+ 0: 'Introducción',
18
+ 1: 'Tablas: estilos, bordes, combinadas, colores, exportar, streaming y paginación',
19
+ 2: 'Grid y layout',
20
+ 3: 'Widgets: ProgressBar, Sparkline, BarChart, StatusBar, LogView, Live/Screen',
21
+ 4: 'Componentes',
22
+ 5: 'App TUI con teclado, ratón y foco',
23
+ 6: 'Accesibilidad: alto contraste, daltonismo, NO_COLOR, lector de pantalla, ASCII',
24
+ 7: 'Folios e identificadores',
25
+ 8: 'Imágenes: kitty, sixel, bloques, braille, ASCII y respaldo',
26
+ 9: 'Aceleración C y benchmark',
27
+ 10: 'Cierre e instalación',
28
+ }
29
+
30
+
31
+ def stamp(seconds):
32
+ seconds = int(round(seconds))
33
+ m, s = divmod(seconds, 60)
34
+ return '{0}:{1:02d}'.format(m, s)
35
+
36
+
37
+ def main(capture, output, chapters_txt):
38
+ work = os.path.dirname(capture)
39
+ log = json.load(open(os.path.join(work, 'tiempos.json')))
40
+ ff_start = float(open(os.path.join(work, 'ffmpeg.start')).read())
41
+ offset = log['start'] - ff_start # demo t=0 inside the capture
42
+ marks = log['chapters']
43
+ start = max(0.0, offset + marks[0]['t'] - 0.3)
44
+ # The closing card stays up for at most 11 s.
45
+ end = offset + min(marks[-1]['t'], marks[-2]['t'] + 11) + 0.3
46
+ duration = end - start
47
+ chapters = [(m['t'] + offset - start, m['n']) for m in marks if m['n'] >= 0]
48
+ chapters[0] = (0.0, chapters[0][1])
49
+ meta = os.path.join(work, 'chapters.ffmeta')
50
+ with open(meta, 'w') as f:
51
+ f.write(';FFMETADATA1\ntitle=flexablelib — demo completa\n')
52
+ for i, (t, n) in enumerate(chapters):
53
+ t_end = chapters[i + 1][0] if i + 1 < len(chapters) else duration
54
+ f.write('[CHAPTER]\nTIMEBASE=1/1000\nSTART={0}\nEND={1}\ntitle={2}\n'.format(
55
+ int(t * 1000), int(t_end * 1000), NAMES.get(n, str(n))))
56
+ subprocess.run([
57
+ 'ffmpeg', '-loglevel', 'error', '-y', '-ss', '{0:.3f}'.format(start),
58
+ '-t', '{0:.3f}'.format(duration), '-i', capture,
59
+ '-f', 'lavfi', '-i', 'anullsrc=channel_layout=stereo:sample_rate=48000',
60
+ '-i', meta, '-map', '0:v', '-map', '1:a', '-map_metadata', '2',
61
+ '-map_chapters', '2', '-c:v', 'libx264', '-preset', 'slow', '-crf', '20',
62
+ '-tune', 'stillimage', '-pix_fmt', 'yuv420p', '-profile:v', 'high',
63
+ '-r', '30', '-g', '60', '-c:a', 'aac', '-b:a', '96k', '-shortest',
64
+ '-movflags', '+faststart', output], check=True)
65
+ with open(chapters_txt, 'w') as f:
66
+ for t, n in chapters:
67
+ f.write('{0} {1}\n'.format(stamp(t), NAMES.get(n, str(n))))
68
+ print('duración {0} · {1} capítulos'.format(stamp(duration), len(chapters)))
69
+
70
+
71
+ if __name__ == '__main__':
72
+ main(*sys.argv[1:4])