From 6ccb6d443d2fb871b43d96ea61a95bc3e6a92355 Mon Sep 17 00:00:00 2001 From: historia Date: Wed, 26 Aug 2026 17:46:48 -0400 Subject: feat: combined install/configure tui screens into one menu, removed extraneous wizard screens --- app/ui/tui.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'app/ui/tui.py') diff --git a/app/ui/tui.py b/app/ui/tui.py index 11f5653..cc21c0b 100644 --- a/app/ui/tui.py +++ b/app/ui/tui.py @@ -883,13 +883,20 @@ def form(scr, title: str, fields: Sequence[dict], "validate": lambda s: None if s.isdigit() else "digits only"} {"key": "combine", "label": "Combine chapters", "kind": "bool", "value": False} + {"key": "voices", "label": "Voices directory", + "kind": "dir", "value": Path("./voices")} Fields render as a two-column table: each label is padded to the widest label so every value starts in the same column. KINDS: ``choice`` opens a single choice menu (its ``choices`` may be a callable of the field list, resolved when the menu opens); ``text`` opens a line editor (reusing its VALIDATE); ``bool`` shows Yes/No and - toggles in place on Enter or Space. + toggles in place on Enter or Space; ``dir`` opens the DOS-style + directory browser (browse_directory) on Enter — its VALUE is a Path + (or str path, used as the browse start), an empty value starts at + the working directory, and backing out of the browser keeps the old + value. Accepting a directory also moves focus to the first button, + so Enter right after picking continues to the next screen. A field may set ``visible`` to a bool or a callable of the field list; hidden fields are not drawn, are skipped by the cursor, and @@ -945,6 +952,9 @@ def form(scr, title: str, fields: Sequence[dict], def display_value(field: dict) -> str: if field.get("kind") == "bool": return "Yes" if field["value"] else "No" + if field.get("kind") == "dir": + value = field["value"] + return str(value) if value is not None else "" return str(field["value"]) while True: @@ -1047,6 +1057,21 @@ def form(scr, title: str, fields: Sequence[dict], if chosen is not edit_cancel: field["value"] = chosen run_on_change(field) + elif field.get("kind") == "dir": + start = field["value"] + start = Path(start) if start else Path.cwd() + picked = browse_directory( + scr, field["label"], start=start, + validate=field.get("validate"), + back_value=edit_cancel) + if picked is not edit_cancel: + field["value"] = picked + run_on_change(field) + # Picking a directory is a completed choice: + # hand focus straight to the accept button so + # Enter continues, with no extra Tab hunting. + on_buttons = True + btn_index = 0 else: edited = line_edit(scr, field["label"], field["value"], -- cgit v1.2.3