flexablelib 3.3.0__tar.gz → 3.4.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.
- {flexablelib-3.3.0 → flexablelib-3.4.0}/CHANGELOG.md +105 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/PKG-INFO +37 -10
- {flexablelib-3.3.0 → flexablelib-3.4.0}/README.md +30 -3
- {flexablelib-3.3.0 → flexablelib-3.4.0}/examples/admin.py +36 -8
- flexablelib-3.4.0/examples/keys.py +158 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/__init__.py +4 -2
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/_frames.py +166 -2
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/cells.py +2 -1
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/colors.py +13 -3
- flexablelib-3.4.0/flexablelib/identifiers.py +91 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/layout.py +24 -7
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/readers.py +13 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/table.py +126 -16
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/text_width.py +37 -2
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/writers.py +3 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib.egg-info/PKG-INFO +37 -10
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib.egg-info/SOURCES.txt +13 -0
- flexablelib-3.4.0/flexablelib.egg-info/requires.txt +26 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/package.json +1 -1
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v330_tui.py +3 -3
- flexablelib-3.4.0/tests/test_v331_formats.py +141 -0
- flexablelib-3.4.0/tests/test_v331_panel_width.py +85 -0
- flexablelib-3.4.0/tests/test_v331_readers_bom.py +45 -0
- flexablelib-3.4.0/tests/test_v331_readers_edges.py +99 -0
- flexablelib-3.4.0/tests/test_v331_tabs.py +154 -0
- flexablelib-3.4.0/tests/test_v340_accessibility.py +796 -0
- flexablelib-3.4.0/tests/test_v340_core.py +131 -0
- flexablelib-3.4.0/tests/test_v340_input.py +802 -0
- flexablelib-3.4.0/tests/wincon_child.py +124 -0
- flexablelib-3.4.0/tools/gen_ascii_table.py +34 -0
- flexablelib-3.4.0/tools/pty_check.py +125 -0
- flexablelib-3.3.0/flexablelib.egg-info/requires.txt +0 -26
- {flexablelib-3.3.0 → flexablelib-3.4.0}/.coveragerc +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/LICENSE +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/MANIFEST.in +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/examples/dashboard.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/_legacy/__init__.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/_legacy/screen.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/_legacy/widgets.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/_speedups.c +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/_width_tables.h +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/box_topology.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/columns.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/fast.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/merges.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/options.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/py.typed +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/screen.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/style_compositions.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/table_strings.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/utils.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib/widgets.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib.egg-info/dependency_links.txt +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/flexablelib.egg-info/top_level.txt +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/pytest.ini +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/setup.cfg +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/setup.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/style_examples.md +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/conftest.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/helpers.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_align_indicators.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_box_topology.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_cells.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_columns.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_excel.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_features.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_issues.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_merge_edge_matrix.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_merge_fill.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_merges.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_public_api_edges.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_readme_examples.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_stress_matrix.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_style_line_widths.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_styles.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_text_width.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_two_pass_measurement.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_upstream_issues.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v2021_fixes.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v210_rows_copy.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v2110_fixes.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v211_fixes.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v213_features.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v214_features.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v215_features.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v216_features.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v217_features.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v218_features.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v219_coverage.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v219_fixes.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v220_exports.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v221_fixes.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v222_fixes.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v223_fixes.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v224_fixes.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v230_none.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v231_fixes.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v232_merge_ansi.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v300_style_names.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v310_layout.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v320_tui.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v330_components.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v330_frames.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tests/test_v330_layout.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tools/bench_frames.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tools/benchmark.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tools/generate_width_tables.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tools/readme_gallery.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tools/stress_matrix.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tools/style_examples.py +0 -0
- {flexablelib-3.3.0 → flexablelib-3.4.0}/tools/text_to_png.py +0 -0
|
@@ -2,6 +2,111 @@
|
|
|
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.4.0] - 2026-11-12
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **Keyboard input, complete** (`flexablelib-tui`, see `docs/INPUT.md`):
|
|
9
|
+
one key name whatever the terminal sends -- xterm/VT100/VT220 (CSI, SS3,
|
|
10
|
+
8-bit CSI), rxvt/urxvt, the Linux console, Alt as an ESC prefix, F1–F24
|
|
11
|
+
(F35 with kitty) with any modifier, Ctrl/Alt/Shift/Meta/Super/Hyper in a
|
|
12
|
+
fixed order (`ctrl+alt+shift+f12`), the **kitty keyboard protocol**
|
|
13
|
+
(Ctrl+I vs Tab, Ctrl+Enter, keypad, press/repeat/release), xterm
|
|
14
|
+
**modifyOtherKeys**, bracketed paste (even split across reads), terminal
|
|
15
|
+
focus in/out and terminal answers (DA, DECRQM, XTVERSION, kitty flags).
|
|
16
|
+
`Key` carries `char`, `event`, `mouse`, `data` and `raw`;
|
|
17
|
+
`normalize_key`, `key_label`.
|
|
18
|
+
- **Windows Console API input** (`wincon`): `ReadConsoleInputW` records
|
|
19
|
+
with virtual-key codes and modifiers (AltGr, F13–F24, surrogate pairs,
|
|
20
|
+
mouse, wheel, resize, focus), virtual-terminal input and the `msvcrt`
|
|
21
|
+
fallback (`Terminal(windows='records' | 'vt' | 'msvcrt')`). CI injects
|
|
22
|
+
records into a real console on `windows-latest`.
|
|
23
|
+
- **Capability detection** (`detect_capabilities`, `capabilities.probe`):
|
|
24
|
+
colour level, Unicode, size and terminal from the environment, then a
|
|
25
|
+
probe of the terminal itself; `Terminal(keyboard='auto')` turns on the
|
|
26
|
+
kitty protocol or modifyOtherKeys when available and restores everything
|
|
27
|
+
on exit.
|
|
28
|
+
- **Key map** (`KeyMap`): remap keys, name actions (`focus_next`, `quit`,
|
|
29
|
+
`help`, `read_screen` ...), `describe`, `conflicts`, save/load JSON;
|
|
30
|
+
`App(keymap=...)`.
|
|
31
|
+
- **Mouse in every component**: `App(mouse=True)` (or `'hover'`) knows
|
|
32
|
+
which component drew each cell and focuses and passes clicks to it --
|
|
33
|
+
buttons, checkboxes, switches, radios, tabs, menus, sidebar, pagination,
|
|
34
|
+
sort controls, calendars and date pickers, selects, autocomplete, file
|
|
35
|
+
entries, trees, accordions, carousels, links, alerts, `DataTable` rows,
|
|
36
|
+
checkbox column and headers, catalog cards. The wheel scrolls what is
|
|
37
|
+
under the pointer; drags move `Split` dividers and scroll bars, with
|
|
38
|
+
capture until release. `Component.on_mouse(event)` in local coordinates;
|
|
39
|
+
`_Themed.hot()` registers clickable spots.
|
|
40
|
+
- **Accessibility** (`flexablelib_tui.accessibility`, see
|
|
41
|
+
`docs/ACCESSIBILITY.md`): settings from the environment
|
|
42
|
+
(`FLEXABLELIB_SCREEN_READER`, `_REDUCED_MOTION`, `_ASCII`,
|
|
43
|
+
`_FOCUS_MARKER`, `_THEME`, `_LANG`, `_A11Y`) or `App(...)` arguments;
|
|
44
|
+
**screen-reader mode** (linear text with role, label, value, state and
|
|
45
|
+
description; announcements of focus, changes, dialogs and notifications
|
|
46
|
+
to stdout, stderr, a file or a callback; Ctrl+R reads the screen);
|
|
47
|
+
roles, accessible names, values and states for every component;
|
|
48
|
+
focus visible without colour (text markers); **themes** `high-contrast`,
|
|
49
|
+
`high-contrast-light`, `deuteranopia`, `protanopia`, `tritanopia`,
|
|
50
|
+
`monochrome` with WCAG contrast (`Theme.contrast()`, `contrast_ratio`)
|
|
51
|
+
and colour-blindness simulation (`simulate_cvd`, `delta_e`);
|
|
52
|
+
`App(theme=...)`; static spinners and skeletons with reduced motion;
|
|
53
|
+
status with symbol and word (`status_symbol`), chart markers per series;
|
|
54
|
+
ASCII fallback for frames; `App(min_size=...)`; F1 help screen built from
|
|
55
|
+
the bindings; `tab_index`; `audit()` checks role, label and visible focus.
|
|
56
|
+
- **Folios** (see `docs/FOLIOS.md`): `Table.id_columns` (`'auto'`, a list,
|
|
57
|
+
or `None` as before) and `Table.id_names` print identifiers -- folios,
|
|
58
|
+
IDs, codes, SKUs, postal codes, years -- without thousands separators
|
|
59
|
+
while quantities and money keep them; `flexablelib.is_id_column` and
|
|
60
|
+
`ID_COLUMN_NAMES`; `to_excel` follows. `DataTable` column `type`
|
|
61
|
+
`'id'` / `'number'` / `'money'`, `id_columns`, `id_names`.
|
|
62
|
+
- C: `ascii_fold` (8× faster) and `extract_marks` (click zones, 2× faster)
|
|
63
|
+
in `flexablelib-speedups`, with Python fallbacks and parity tests.
|
|
64
|
+
- `examples/keys.py`: live key and mouse detector. `examples/admin.py`
|
|
65
|
+
takes `--theme`, `--screen-reader`, `--ascii`, `--reduced-motion`,
|
|
66
|
+
`--focus-marker` and `click:X:Y` keys.
|
|
67
|
+
|
|
68
|
+
### Changed
|
|
69
|
+
- `DataTable` no longer puts thousands separators in identifier columns
|
|
70
|
+
by name (`id_columns=False` restores 3.3).
|
|
71
|
+
- The default selection style is bold as well as coloured; without colour,
|
|
72
|
+
focus and selection use text markers (`[>Guardar<]`, `>` before the
|
|
73
|
+
current item).
|
|
74
|
+
- On `TERM=dumb` the app prints linear text and switches no terminal
|
|
75
|
+
modes (no paste, focus or mouse escape sequences).
|
|
76
|
+
- `FORCE_COLOR=0` turns colour off. Colour specs accept attributes after
|
|
77
|
+
the background (`black on cyan underline`).
|
|
78
|
+
|
|
79
|
+
## [3.3.1] - 2026-11-12
|
|
80
|
+
|
|
81
|
+
### Fixed
|
|
82
|
+
- Tabs no longer push tables and cards past their width. A tab measures
|
|
83
|
+
nothing, so a cell holding one was sized and wrapped as narrower than the
|
|
84
|
+
spaces it became: the table came out wider than ``max_width`` (or
|
|
85
|
+
``render(width)``), and in card mode the raw tab displaced the frame.
|
|
86
|
+
Cells are expanded before they are measured, headers are trimmed on their
|
|
87
|
+
expanded width with ``overflow='truncate'``, and ``wrap_to_width`` expands
|
|
88
|
+
tabs itself, so cards, grids, widgets and components get it too.
|
|
89
|
+
- A newline in a card title, or in a title set into a border
|
|
90
|
+
(``title_position='border'``), split the frame in two; the title now
|
|
91
|
+
goes on one line. Multi-line table titles and captions are aligned line
|
|
92
|
+
by line instead of only the first line.
|
|
93
|
+
- ``max_width`` now counts the ``panel`` (two columns) and ``shadow``
|
|
94
|
+
(one): squeezing, ``expand_to_window`` and ``too_narrow_message`` sized
|
|
95
|
+
the columns for the full width and then drew the panel outside it.
|
|
96
|
+
- ``from_csv`` and ``from_markdown`` drop a leading UTF-8 byte-order mark
|
|
97
|
+
(Excel's "CSV UTF-8"): it was kept as the first character of the first
|
|
98
|
+
header, and a Markdown table gained an extra empty column.
|
|
99
|
+
- A brace format template (``custom_format={'price': '{:,.2f}'}``,
|
|
100
|
+
``float_format='$ {:,.2f}'``) no longer aborts the whole render on a text
|
|
101
|
+
cell in the column; the cell prints as it is, as it already did with a
|
|
102
|
+
plain spec. A template that needs more than one value raises a
|
|
103
|
+
``ValueError`` that says so.
|
|
104
|
+
|
|
105
|
+
### Added
|
|
106
|
+
- ``flexablelib.text_width.expand_tabs(text, tabsize=8)``: tab expansion
|
|
107
|
+
that counts terminal columns (wide characters two, escape sequences
|
|
108
|
+
none).
|
|
109
|
+
|
|
5
110
|
## [3.3.0] - 2026-11-12
|
|
6
111
|
|
|
7
112
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flexablelib
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.4.0
|
|
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,18 +46,18 @@ 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.
|
|
49
|
+
Requires-Dist: flexablelib-tui==3.4.0; extra == "tui"
|
|
50
50
|
Provides-Extra: components
|
|
51
|
-
Requires-Dist: flexablelib-components==3.
|
|
51
|
+
Requires-Dist: flexablelib-components==3.4.0; extra == "components"
|
|
52
52
|
Provides-Extra: speed
|
|
53
|
-
Requires-Dist: flexablelib-speedups==3.
|
|
53
|
+
Requires-Dist: flexablelib-speedups==3.4.0; extra == "speed"
|
|
54
54
|
Provides-Extra: all
|
|
55
55
|
Requires-Dist: pandas>=1.0; extra == "all"
|
|
56
56
|
Requires-Dist: openpyxl>=3.0; extra == "all"
|
|
57
57
|
Requires-Dist: lxml>=4.0; extra == "all"
|
|
58
|
-
Requires-Dist: flexablelib-tui==3.
|
|
59
|
-
Requires-Dist: flexablelib-components==3.
|
|
60
|
-
Requires-Dist: flexablelib-speedups==3.
|
|
58
|
+
Requires-Dist: flexablelib-tui==3.4.0; extra == "all"
|
|
59
|
+
Requires-Dist: flexablelib-components==3.4.0; extra == "all"
|
|
60
|
+
Requires-Dist: flexablelib-speedups==3.4.0; extra == "all"
|
|
61
61
|
Dynamic: author
|
|
62
62
|
Dynamic: author-email
|
|
63
63
|
Dynamic: classifier
|
|
@@ -95,7 +95,7 @@ Dynamic: summary
|
|
|
95
95
|
|
|
96
96
|
**flexablelib** turns rows and columns into readable tables for terminals, logs,
|
|
97
97
|
reports and docs. It has **no runtime dependencies**, ships **prebuilt wheels
|
|
98
|
-
with an optional C speed-up**, and is covered by **
|
|
98
|
+
with an optional C speed-up**, and is covered by **4,400+ tests** on Python
|
|
99
99
|
3.8 – 3.14 (Linux, Windows, macOS).
|
|
100
100
|
|
|
101
101
|
Since 3.3.0 the same library builds **complete interactive terminal
|
|
@@ -181,6 +181,33 @@ in colour or plain text: the full list, what each does and its keys is in
|
|
|
181
181
|
</tr>
|
|
182
182
|
</table>
|
|
183
183
|
|
|
184
|
+
### Keyboard, mouse and accessibility
|
|
185
|
+
|
|
186
|
+
Since 3.4.0: [docs/INPUT.md](https://github.com/Opus-Perpetuus/flexablelib/blob/main/docs/INPUT.md) · [docs/ACCESSIBILITY.md](https://github.com/Opus-Perpetuus/flexablelib/blob/main/docs/ACCESSIBILITY.md) · [docs/FOLIOS.md](https://github.com/Opus-Perpetuus/flexablelib/blob/main/docs/FOLIOS.md).
|
|
187
|
+
|
|
188
|
+
<table>
|
|
189
|
+
<tr>
|
|
190
|
+
<td width="50%"><b>Every key detected</b> — F1–F24, Ctrl/Alt/Shift/Super, paste, focus, mouse — <code>examples/keys.py</code><br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/01_detector_teclas.png" alt="Live key detector" width="420"></td>
|
|
191
|
+
<td width="50%"><b>Mouse in every component</b> — click, wheel, drag<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/02_raton.png" alt="Clicks on buttons, tabs, tables and calendars" width="420"></td>
|
|
192
|
+
</tr>
|
|
193
|
+
<tr>
|
|
194
|
+
<td><b>Focus visible without colour</b> — text markers, not colour alone<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/03_foco_visible.png" alt="Focus with and without colour" width="420"></td>
|
|
195
|
+
<td><b>High contrast</b> — WCAG AAA text, checked by the tests<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/04_alto_contraste.png" alt="High-contrast theme with contrast ratios" width="420"></td>
|
|
196
|
+
</tr>
|
|
197
|
+
<tr>
|
|
198
|
+
<td><b>Colour-blind themes</b> — deuteranopia, protanopia, tritanopia — simulated<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/05_daltonismo.png" alt="Status colours under colour-blindness simulation" width="420"></td>
|
|
199
|
+
<td><b>Screen readers</b> — linear text, roles, labels, announcements<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/06_lector_pantalla.png" alt="Screen-reader linear output" width="420"></td>
|
|
200
|
+
</tr>
|
|
201
|
+
<tr>
|
|
202
|
+
<td><b>ASCII and reduced motion</b> — no Unicode, still spinners<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/07_ascii.png" alt="The app in ASCII mode" width="420"></td>
|
|
203
|
+
<td><b>Folios</b> — IDs without thousands separators, money with them<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/08_folios.png" alt="Folio columns versus money columns" width="420"></td>
|
|
204
|
+
</tr>
|
|
205
|
+
<tr>
|
|
206
|
+
<td><b>One name per key</b> — xterm, rxvt, Linux console, kitty, modifyOtherKeys, Windows<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/10_protocolos.png" alt="Key names across protocols" width="420"></td>
|
|
207
|
+
<td><b>C acceleration</b> — ASCII fallback and click zones<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/09_benchmark.png" alt="C versus Python timings" width="420"></td>
|
|
208
|
+
</tr>
|
|
209
|
+
</table>
|
|
210
|
+
|
|
184
211
|
### Speed
|
|
185
212
|
|
|
186
213
|
<p align="center">
|
|
@@ -470,10 +497,10 @@ Open work and the issue map: [docs/ISSUES.md](https://github.com/Opus-Perpetuus/
|
|
|
470
497
|
## Project layout
|
|
471
498
|
|
|
472
499
|
- `flexablelib/` — the core package (no runtime dependencies): `table.py` (the Table class), `layout.py` (Card, Grid, GridCell), `_frames.py` (frame primitives, C or Python), `columns.py`, `cells.py`, `table_strings.py`, `style_compositions.py` (the 54 styles, as data), `text_width.py` / `fast.py` (terminal-width measurement, C or Python), readers and writers.
|
|
473
|
-
- `packages/tui/` — `flexablelib-tui`: widgets, Screen, Live, App, keyboard input.
|
|
500
|
+
- `packages/tui/` — `flexablelib-tui`: widgets, Screen, Live, App, keyboard and mouse input, accessibility.
|
|
474
501
|
- `packages/components/` — `flexablelib-components`: the terminal components.
|
|
475
502
|
- `packages/speedups/` — `flexablelib-speedups`: the C frame code.
|
|
476
|
-
- `examples/` — `dashboard.py`, `admin.py
|
|
503
|
+
- `examples/` — `dashboard.py`, `admin.py`, `keys.py` (live key detector).
|
|
477
504
|
- `tests/` — the pytest suite; `tools/` — benchmarks and generators; `docs/` — guides and images.
|
|
478
505
|
- `ARCHITECTURE.md` — how it all fits together; `style_examples.md` — all 54 styles; `package.json` — the canonical version number.
|
|
479
506
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
**flexablelib** turns rows and columns into readable tables for terminals, logs,
|
|
23
23
|
reports and docs. It has **no runtime dependencies**, ships **prebuilt wheels
|
|
24
|
-
with an optional C speed-up**, and is covered by **
|
|
24
|
+
with an optional C speed-up**, and is covered by **4,400+ tests** on Python
|
|
25
25
|
3.8 – 3.14 (Linux, Windows, macOS).
|
|
26
26
|
|
|
27
27
|
Since 3.3.0 the same library builds **complete interactive terminal
|
|
@@ -107,6 +107,33 @@ in colour or plain text: the full list, what each does and its keys is in
|
|
|
107
107
|
</tr>
|
|
108
108
|
</table>
|
|
109
109
|
|
|
110
|
+
### Keyboard, mouse and accessibility
|
|
111
|
+
|
|
112
|
+
Since 3.4.0: [docs/INPUT.md](https://github.com/Opus-Perpetuus/flexablelib/blob/main/docs/INPUT.md) · [docs/ACCESSIBILITY.md](https://github.com/Opus-Perpetuus/flexablelib/blob/main/docs/ACCESSIBILITY.md) · [docs/FOLIOS.md](https://github.com/Opus-Perpetuus/flexablelib/blob/main/docs/FOLIOS.md).
|
|
113
|
+
|
|
114
|
+
<table>
|
|
115
|
+
<tr>
|
|
116
|
+
<td width="50%"><b>Every key detected</b> — F1–F24, Ctrl/Alt/Shift/Super, paste, focus, mouse — <code>examples/keys.py</code><br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/01_detector_teclas.png" alt="Live key detector" width="420"></td>
|
|
117
|
+
<td width="50%"><b>Mouse in every component</b> — click, wheel, drag<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/02_raton.png" alt="Clicks on buttons, tabs, tables and calendars" width="420"></td>
|
|
118
|
+
</tr>
|
|
119
|
+
<tr>
|
|
120
|
+
<td><b>Focus visible without colour</b> — text markers, not colour alone<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/03_foco_visible.png" alt="Focus with and without colour" width="420"></td>
|
|
121
|
+
<td><b>High contrast</b> — WCAG AAA text, checked by the tests<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/04_alto_contraste.png" alt="High-contrast theme with contrast ratios" width="420"></td>
|
|
122
|
+
</tr>
|
|
123
|
+
<tr>
|
|
124
|
+
<td><b>Colour-blind themes</b> — deuteranopia, protanopia, tritanopia — simulated<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/05_daltonismo.png" alt="Status colours under colour-blindness simulation" width="420"></td>
|
|
125
|
+
<td><b>Screen readers</b> — linear text, roles, labels, announcements<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/06_lector_pantalla.png" alt="Screen-reader linear output" width="420"></td>
|
|
126
|
+
</tr>
|
|
127
|
+
<tr>
|
|
128
|
+
<td><b>ASCII and reduced motion</b> — no Unicode, still spinners<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/07_ascii.png" alt="The app in ASCII mode" width="420"></td>
|
|
129
|
+
<td><b>Folios</b> — IDs without thousands separators, money with them<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/08_folios.png" alt="Folio columns versus money columns" width="420"></td>
|
|
130
|
+
</tr>
|
|
131
|
+
<tr>
|
|
132
|
+
<td><b>One name per key</b> — xterm, rxvt, Linux console, kitty, modifyOtherKeys, Windows<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/10_protocolos.png" alt="Key names across protocols" width="420"></td>
|
|
133
|
+
<td><b>C acceleration</b> — ASCII fallback and click zones<br><img src="https://raw.githubusercontent.com/Opus-Perpetuus/flexablelib/main/docs/img/v34/09_benchmark.png" alt="C versus Python timings" width="420"></td>
|
|
134
|
+
</tr>
|
|
135
|
+
</table>
|
|
136
|
+
|
|
110
137
|
### Speed
|
|
111
138
|
|
|
112
139
|
<p align="center">
|
|
@@ -396,10 +423,10 @@ Open work and the issue map: [docs/ISSUES.md](https://github.com/Opus-Perpetuus/
|
|
|
396
423
|
## Project layout
|
|
397
424
|
|
|
398
425
|
- `flexablelib/` — the core package (no runtime dependencies): `table.py` (the Table class), `layout.py` (Card, Grid, GridCell), `_frames.py` (frame primitives, C or Python), `columns.py`, `cells.py`, `table_strings.py`, `style_compositions.py` (the 54 styles, as data), `text_width.py` / `fast.py` (terminal-width measurement, C or Python), readers and writers.
|
|
399
|
-
- `packages/tui/` — `flexablelib-tui`: widgets, Screen, Live, App, keyboard input.
|
|
426
|
+
- `packages/tui/` — `flexablelib-tui`: widgets, Screen, Live, App, keyboard and mouse input, accessibility.
|
|
400
427
|
- `packages/components/` — `flexablelib-components`: the terminal components.
|
|
401
428
|
- `packages/speedups/` — `flexablelib-speedups`: the C frame code.
|
|
402
|
-
- `examples/` — `dashboard.py`, `admin.py
|
|
429
|
+
- `examples/` — `dashboard.py`, `admin.py`, `keys.py` (live key detector).
|
|
403
430
|
- `tests/` — the pytest suite; `tools/` — benchmarks and generators; `docs/` — guides and images.
|
|
404
431
|
- `ARCHITECTURE.md` — how it all fits together; `style_examples.md` — all 54 styles; `package.json` — the canonical version number.
|
|
405
432
|
|
|
@@ -7,11 +7,16 @@ terminal packages (``pip install flexablelib[tui,components,speed]``).
|
|
|
7
7
|
python examples/admin.py --frame 120x36 # print one frame and exit
|
|
8
8
|
python examples/admin.py --frame 120x36 --keys "tab,down,down,enter"
|
|
9
9
|
python examples/admin.py --frame 80x24 --no-color
|
|
10
|
+
python examples/admin.py --theme high-contrast --screen-reader
|
|
11
|
+
python examples/admin.py --frame 100x30 --keys "click:3:5" --ascii
|
|
10
12
|
|
|
11
13
|
Keys: Tab / Shift-Tab move the focus, Ctrl-B shows or hides the sidebar,
|
|
12
14
|
Ctrl-K opens the command palette, Ctrl-N a new-customer form, F1 the help,
|
|
13
|
-
Ctrl-Q quits
|
|
14
|
-
selects, Enter opens the
|
|
15
|
+
Ctrl-Q quits, Ctrl-R reads the screen aloud (screen-reader mode). In the
|
|
16
|
+
orders table: arrows, 1-9 sort, / filter, Space selects, Enter opens the
|
|
17
|
+
order. The mouse works too: click to focus and press, wheel to scroll,
|
|
18
|
+
drag the scroll bars; ``--theme`` picks a theme (high-contrast,
|
|
19
|
+
deuteranopia, protanopia, tritanopia, monochrome ...).
|
|
15
20
|
|
|
16
21
|
Pieces: AppShell (sidebar, top bar, pages), Stat cards, LineChart,
|
|
17
22
|
DataTable bound to a FilterBar, Form with validation, Calendar, Timeline,
|
|
@@ -36,7 +41,7 @@ for path in (ROOT, os.path.join(ROOT, 'packages', 'tui'),
|
|
|
36
41
|
import flexablelib_components as C # noqa: E402
|
|
37
42
|
from flexablelib import KeyHints # noqa: E402
|
|
38
43
|
from flexablelib import _frames # noqa: E402
|
|
39
|
-
from flexablelib_tui import App, Component # noqa: E402
|
|
44
|
+
from flexablelib_tui import App, Component, parse_keys # noqa: E402
|
|
40
45
|
|
|
41
46
|
TODAY = dt.date(2026, 11, 11)
|
|
42
47
|
|
|
@@ -70,7 +75,7 @@ STATES = {'pagado': 'green', 'pendiente': 'yellow', 'enviado': 'cyan',
|
|
|
70
75
|
class Admin(object):
|
|
71
76
|
"""Builds the screens and wires the actions."""
|
|
72
77
|
|
|
73
|
-
def __init__(self):
|
|
78
|
+
def __init__(self, **app_options):
|
|
74
79
|
self.orders = C.DataTable(
|
|
75
80
|
[{'key': 'folio', 'title': 'Folio', 'align': 'r', 'format': str},
|
|
76
81
|
{'key': 'cliente', 'title': 'Cliente'},
|
|
@@ -92,13 +97,15 @@ class Admin(object):
|
|
|
92
97
|
self.shell = C.AppShell(sidebar=self.sidebar, topbar=self.topbar,
|
|
93
98
|
pages=self.pages())
|
|
94
99
|
self.app = App(
|
|
100
|
+
mouse=True, title='Tienda · administración', **app_options,
|
|
95
101
|
body=self.shell,
|
|
96
102
|
footer=KeyHints([('Tab', 'Foco'), ('Ctrl-B', 'Menú'),
|
|
97
103
|
('Ctrl-K', 'Comandos'), ('Ctrl-N', 'Nuevo'),
|
|
98
104
|
('F1', 'Ayuda'), ('Ctrl-Q', 'Salir')]),
|
|
99
|
-
bindings={'ctrl+q': lambda: self.app.exit(),
|
|
100
|
-
'ctrl+k': self.palette, '
|
|
101
|
-
'
|
|
105
|
+
bindings={'ctrl+q': (lambda: self.app.exit(), 'Salir'),
|
|
106
|
+
'ctrl+k': (self.palette, 'Paleta de comandos'),
|
|
107
|
+
'ctrl+n': (self.new_customer, 'Nuevo cliente'),
|
|
108
|
+
'f1': (self.help, 'Ayuda')})
|
|
102
109
|
|
|
103
110
|
# -- pages --------------------------------------------------------------
|
|
104
111
|
|
|
@@ -234,10 +241,24 @@ def main(argv=None):
|
|
|
234
241
|
parser.add_argument('--keys', default='',
|
|
235
242
|
help='comma-separated keys fed before the frame')
|
|
236
243
|
parser.add_argument('--no-color', action='store_true')
|
|
244
|
+
parser.add_argument('--theme', help='high-contrast, deuteranopia, '
|
|
245
|
+
'protanopia, tritanopia, monochrome ...')
|
|
246
|
+
parser.add_argument('--screen-reader', action='store_true',
|
|
247
|
+
help='linear text with roles; announcements')
|
|
248
|
+
parser.add_argument('--announce', metavar='TARGET',
|
|
249
|
+
help='stdout, stderr or a file for announcements')
|
|
250
|
+
parser.add_argument('--ascii', action='store_true')
|
|
251
|
+
parser.add_argument('--focus-marker', action='store_true')
|
|
252
|
+
parser.add_argument('--reduced-motion', action='store_true')
|
|
237
253
|
args = parser.parse_args(argv)
|
|
238
254
|
if args.no_color:
|
|
239
255
|
Component.use_colors = False
|
|
240
|
-
|
|
256
|
+
options = dict((k, v) for k, v in (('theme', args.theme),
|
|
257
|
+
('announce', args.announce)) if v)
|
|
258
|
+
for name in ('screen_reader', 'ascii', 'focus_marker', 'reduced_motion'):
|
|
259
|
+
if getattr(args, name):
|
|
260
|
+
options[name] = True
|
|
261
|
+
admin = Admin(**options)
|
|
241
262
|
if not args.frame:
|
|
242
263
|
admin.app.run()
|
|
243
264
|
return 0
|
|
@@ -248,6 +269,13 @@ def main(argv=None):
|
|
|
248
269
|
keys = [k.strip() for k in args.keys.split(',') if k.strip()]
|
|
249
270
|
for key in keys:
|
|
250
271
|
admin.app.render(width, height)
|
|
272
|
+
if key.startswith('click:'):
|
|
273
|
+
# click:X:Y -- a mouse click at that cell (0-based).
|
|
274
|
+
x, y = (int(n) + 1 for n in key.split(':')[1:3])
|
|
275
|
+
for seq in ('\x1b[<0;{0};{1}M', '\x1b[<0;{0};{1}m'):
|
|
276
|
+
for parsed in parse_keys(seq.format(x, y)):
|
|
277
|
+
admin.app.dispatch(parsed)
|
|
278
|
+
continue
|
|
251
279
|
admin.app.dispatch(key)
|
|
252
280
|
sys.stdout.write(admin.app.render(width, height) + '\n')
|
|
253
281
|
sys.stderr.write('frames backend: {0}\n'.format(_frames.BACKEND))
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
A live key and mouse detector: shows every key, combination, paste, focus
|
|
4
|
+
change and mouse event the terminal sends, with the name flexablelib gives
|
|
5
|
+
it, how it is shown to people, the raw bytes and the protocol in use.
|
|
6
|
+
|
|
7
|
+
python examples/keys.py # interactive (Ctrl-Q quits)
|
|
8
|
+
python examples/keys.py --frame 100x30 --feed '\\x1b[1;5A,\\x1b[<0;12;6M'
|
|
9
|
+
|
|
10
|
+
Try Ctrl/Alt/Shift combinations, F1-F24, Home/End, the keypad, pasting
|
|
11
|
+
text, clicking the buttons, the wheel over the list and switching to
|
|
12
|
+
another window and back (focus events). On terminals with the kitty
|
|
13
|
+
keyboard protocol (kitty, WezTerm, foot, Ghostty, recent iTerm2) or
|
|
14
|
+
xterm's modifyOtherKeys, combinations such as Ctrl+Enter, Ctrl+Shift+A or
|
|
15
|
+
Ctrl+I versus Tab are told apart, and releases are shown.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
import argparse
|
|
19
|
+
import codecs
|
|
20
|
+
import os
|
|
21
|
+
import sys
|
|
22
|
+
|
|
23
|
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
24
|
+
ROOT = os.path.dirname(HERE)
|
|
25
|
+
for path in (ROOT, os.path.join(ROOT, 'packages', 'tui'),
|
|
26
|
+
os.path.join(ROOT, 'packages', 'components'),
|
|
27
|
+
os.path.join(ROOT, 'packages', 'speedups')):
|
|
28
|
+
if os.path.isdir(path) and path not in sys.path:
|
|
29
|
+
sys.path.insert(0, path)
|
|
30
|
+
|
|
31
|
+
import flexablelib_components as C # noqa: E402
|
|
32
|
+
from flexablelib import KeyHints # noqa: E402
|
|
33
|
+
from flexablelib_tui import (App, Component, ScrollView, # noqa: E402
|
|
34
|
+
Key, detect_capabilities, key_label,
|
|
35
|
+
parse_keys)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class KeyLog(Component):
|
|
39
|
+
"""The latest keys, newest first, as a small table."""
|
|
40
|
+
|
|
41
|
+
role = 'log'
|
|
42
|
+
expand = True
|
|
43
|
+
|
|
44
|
+
def __init__(self, rows=12, **kwargs):
|
|
45
|
+
super(KeyLog, self).__init__(**kwargs)
|
|
46
|
+
self.rows = rows
|
|
47
|
+
self.entries = []
|
|
48
|
+
|
|
49
|
+
def add(self, key):
|
|
50
|
+
name = str(key)
|
|
51
|
+
if name == 'mouse':
|
|
52
|
+
m = key.mouse
|
|
53
|
+
what = '{0} b{1} ({2},{3}){4}'.format(
|
|
54
|
+
m.action, m.button, m.x, m.y,
|
|
55
|
+
(' + ' + '+'.join(m.mods)) if m.mods else '')
|
|
56
|
+
label = 'Ratón'
|
|
57
|
+
elif name == 'paste':
|
|
58
|
+
what = repr(key.char[:30])
|
|
59
|
+
label = 'Pegar'
|
|
60
|
+
elif name in ('focusin', 'focusout'):
|
|
61
|
+
what = 'ventana'
|
|
62
|
+
label = key_label(name)
|
|
63
|
+
else:
|
|
64
|
+
what = key.event
|
|
65
|
+
label = key_label(name)
|
|
66
|
+
raw = repr(key.raw or key.char or '')[1:-1]
|
|
67
|
+
self.entries.insert(0, (name, label, what, raw))
|
|
68
|
+
del self.entries[200:]
|
|
69
|
+
self.refresh()
|
|
70
|
+
|
|
71
|
+
def a11y_value(self):
|
|
72
|
+
if not self.entries:
|
|
73
|
+
return 'sin teclas todavía'
|
|
74
|
+
name, label, what, raw = self.entries[0]
|
|
75
|
+
return 'última: {0} ({1})'.format(label, what)
|
|
76
|
+
|
|
77
|
+
def draw(self, width, height):
|
|
78
|
+
rows = (height - 2) if height else self.rows
|
|
79
|
+
name_w, label_w, raw_w = 18, 14, 16
|
|
80
|
+
what_w = max(8, width - name_w - label_w - raw_w - 3)
|
|
81
|
+
fmt = '{0:<%d} {1:<%d} {2:<%d} {3}' % (name_w, label_w, what_w)
|
|
82
|
+
head = fmt.format('nombre', 'se muestra', 'detalle', 'bytes')
|
|
83
|
+
out = [self.paint(head, 'bold') if self._active() else head,
|
|
84
|
+
'─' * width]
|
|
85
|
+
for name, label, what, raw in self.entries[:max(1, rows)]:
|
|
86
|
+
out.append(fmt.format(name[:name_w], label[:label_w],
|
|
87
|
+
what[:what_w], raw[:raw_w]))
|
|
88
|
+
if not self.entries:
|
|
89
|
+
out.append('Pulsa cualquier tecla, combinación o haz clic…')
|
|
90
|
+
return out
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class Detector(App):
|
|
94
|
+
def __init__(self, **options):
|
|
95
|
+
self.log = KeyLog()
|
|
96
|
+
self.clicks = C.Badge('0 clics', kind='info')
|
|
97
|
+
self.count = 0
|
|
98
|
+
caps = detect_capabilities()
|
|
99
|
+
buttons = C.Stack([C.Toolbar([C.Button('Botón A', self._click),
|
|
100
|
+
C.Button('Botón B', self._click)]),
|
|
101
|
+
C.Checkbox('Casilla')])
|
|
102
|
+
items = ScrollView('\n'.join('Elemento {0:02d}'.format(i)
|
|
103
|
+
for i in range(1, 41)), height=6,
|
|
104
|
+
a11y_label='Lista (rueda del ratón)')
|
|
105
|
+
info = C.DetailView([(k.split(':')[0], k.split(': ', 1)[1])
|
|
106
|
+
for k in caps.summary()],
|
|
107
|
+
a11y_label='Capacidades')
|
|
108
|
+
body = C.Split(C.Box(self.log, title='Teclas y ratón'),
|
|
109
|
+
C.Stack([C.Box(info, title='Terminal'),
|
|
110
|
+
C.Box(C.Stack([buttons, self.clicks]),
|
|
111
|
+
title='Clic aquí'),
|
|
112
|
+
C.Box(items, title='Rueda aquí')]),
|
|
113
|
+
ratio=0.62)
|
|
114
|
+
super(Detector, self).__init__(
|
|
115
|
+
body=body, mouse='hover', title='Detector de teclas',
|
|
116
|
+
footer=KeyHints([('Ctrl-Q', 'Salir'), ('F1', 'Ayuda'),
|
|
117
|
+
('Tab', 'Foco')]),
|
|
118
|
+
bindings={'ctrl+q': (lambda: self.exit(), 'Salir')}, **options)
|
|
119
|
+
|
|
120
|
+
def _click(self):
|
|
121
|
+
self.count += 1
|
|
122
|
+
self.clicks.text = '{0} clic{1}'.format(
|
|
123
|
+
self.count, 's' if self.count != 1 else '')
|
|
124
|
+
|
|
125
|
+
def dispatch(self, key):
|
|
126
|
+
if isinstance(key, Key) and str(key) != 'response':
|
|
127
|
+
if str(key) != 'mouse' or key.mouse.action != 'move':
|
|
128
|
+
self.log.add(key)
|
|
129
|
+
return super(Detector, self).dispatch(key)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def main(argv=None):
|
|
133
|
+
parser = argparse.ArgumentParser(description=__doc__.split('\n')[1])
|
|
134
|
+
parser.add_argument('--frame', metavar='WxH',
|
|
135
|
+
help='print one frame of this size and exit')
|
|
136
|
+
parser.add_argument('--feed', default='',
|
|
137
|
+
help='comma-separated raw input (Python escapes) '
|
|
138
|
+
'parsed before the frame')
|
|
139
|
+
parser.add_argument('--no-color', action='store_true')
|
|
140
|
+
args = parser.parse_args(argv)
|
|
141
|
+
if args.no_color:
|
|
142
|
+
Component.use_colors = False
|
|
143
|
+
app = Detector(use_colors=not args.no_color if args.frame else None)
|
|
144
|
+
if not args.frame:
|
|
145
|
+
app.run()
|
|
146
|
+
return 0
|
|
147
|
+
width, height = (int(n) for n in args.frame.lower().split('x'))
|
|
148
|
+
for chunk in [c for c in args.feed.split(',') if c]:
|
|
149
|
+
app.render(width, height)
|
|
150
|
+
data = codecs.decode(chunk, 'unicode_escape')
|
|
151
|
+
for key in parse_keys(data, kitty=True):
|
|
152
|
+
app.dispatch(key)
|
|
153
|
+
sys.stdout.write(app.render(width, height) + '\n')
|
|
154
|
+
return 0
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
if __name__ == '__main__':
|
|
158
|
+
sys.exit(main())
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from .table import Table
|
|
2
2
|
from .style_compositions import TableComposition, SeparatorLine
|
|
3
3
|
from .layout import Card, Grid, GridCell
|
|
4
|
+
from .identifiers import ID_COLUMN_NAMES, is_id_column
|
|
4
5
|
|
|
5
6
|
# Terminal interfaces are optional packages, imported on first use:
|
|
6
7
|
#
|
|
@@ -16,13 +17,14 @@ _COMPAT = {
|
|
|
16
17
|
'Text': 'widgets', 'Rule': 'widgets', 'Screen': 'screen', 'Live': 'screen',
|
|
17
18
|
}
|
|
18
19
|
_TUI = ('App', 'Component', 'ScrollView', 'Terminal', 'Key', 'KeyParser',
|
|
19
|
-
'WindowsKeyParser', 'parse_keys', 'overlay')
|
|
20
|
+
'WindowsKeyParser', 'parse_keys', 'overlay', 'MouseEvent', 'KeyMap')
|
|
20
21
|
|
|
21
22
|
# Names, not the objects themselves: `from flexablelib import *` walks this
|
|
22
23
|
# list and raises TypeError on anything that is not a string.
|
|
23
24
|
__all__ = ['Table', 'TableComposition', 'SeparatorLine', 'Card', 'Grid',
|
|
24
25
|
'GridCell', 'ProgressBar', 'Sparkline', 'BarChart', 'StatusBar',
|
|
25
|
-
'KeyHints', 'LogView', 'Text', 'Rule', 'Screen', 'Live'
|
|
26
|
+
'KeyHints', 'LogView', 'Text', 'Rule', 'Screen', 'Live',
|
|
27
|
+
'is_id_column', 'ID_COLUMN_NAMES']
|
|
26
28
|
|
|
27
29
|
|
|
28
30
|
def _optional(package, extra):
|