diff options
Diffstat (limited to 'app/ui/tui.py')
| -rw-r--r-- | app/ui/tui.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/app/ui/tui.py b/app/ui/tui.py index f1c5419..319c123 100644 --- a/app/ui/tui.py +++ b/app/ui/tui.py @@ -920,7 +920,11 @@ def form(scr, title: str, fields: Sequence[dict], An optional ``note`` string on a field renders as a dim, non-selectable line in a blank-line frame above that field's row — a - section divider with a short explanation. Up/Down (or k/j) move the + section divider with a short explanation. An optional ``help`` list + of strings is shown as dim lines inside the field's edit dialog + (line editor / choice menu / directory browser title screens), + letting a field explain itself at edit time; like ``label`` it may + be a callable of the field list. Up/Down (or k/j) move the cursor; Enter edits or toggles the highlighted field. Tab, Left/Right, j or k at the ends of the list move focus to the BUTTONS — Down from the last field and Up from the first field both land on the first @@ -952,6 +956,13 @@ def form(scr, title: str, fields: Sequence[dict], label = field["label"] return str(label(fields)) if callable(label) else str(label) + def field_help(field: dict) -> Optional[List[str]]: + """Resolve FIELD's optional help lines (static or computed).""" + help_lines = field.get("help") + if callable(help_lines): + help_lines = help_lines(fields) + return list(help_lines) if help_lines else None + def shown_fields() -> List[dict]: result: List[dict] = [] for field in fields: @@ -1126,6 +1137,7 @@ def form(scr, title: str, fields: Sequence[dict], edited = line_edit(scr, field_label(field), field["value"], validate=field.get("validate"), + help_lines=field_help(field), back_value=edit_cancel) if edited is not edit_cancel: field["value"] = edited |
