Refactor: extract export commands; co-locate sigtype popup logic.

Two focused, behaviour-preserving moves:

1. `OpenSignalTypeDialog` + `ApplySignalTypeChoice` moved from
   `shell.cpp` to `screen_sigtype_modal.cpp` so the popup owns all of
   its logic instead of having its open/apply functions live in the
   shell file.

2. The `export` command extracted from `commands.cpp` to a new
   `commands_export.cpp` under a `Tui::RegisterExportCommands()`
   member. `RegisterCommands()` calls it at the end. File-local
   helpers (`csv_quote`, `pin_side`) move alongside in an anonymous
   namespace.

Establishes the pattern for future per-group splits: declare a
`Register<X>Commands()` member, define it in its own file, call it
from the orchestrator. Other groups stay in `commands.cpp` for now —
nothing else has grown large enough to warrant the split.

Sizes: shell.cpp 497 → 448, commands.cpp 846 → 675 (+ 191 for the
new commands_export.cpp). DESIGN.md updated.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-16 12:18:58 +02:00
parent 7d307dad57
commit 67de4dcaf3
6 changed files with 261 additions and 225 deletions

View File

@@ -49,7 +49,8 @@ src/
tui_helpers.{hpp,cpp} Free helpers: ToLower, NaturalLess, LongestCommonPrefix
shell.cpp Print, Submit, Dispatch, Finalize, Tokenize, history persistence
completion.cpp CompleteCommand, CompletePath, CompleteInline
commands.cpp RegisterCommands (all built-in commands declared here)
commands.cpp RegisterCommands (orchestrator + lifecycle / shell / topology commands)
commands_export.cpp RegisterExportCommands (export → CSV / ODS, file-dialog hook)
screen_main.cpp BuildMainScreen (visualisation area + bottom input)
screen_connect.cpp BuildConnectScreen + shared RefreshFilteredPartList helper
screen_settype.cpp BuildSettypeScreen
@@ -162,6 +163,8 @@ Exposed as the `analyze` shell command which prints groups (sorted by module + l
Everything is recomputed every frame so manual overrides via the signal-type popup are reflected immediately. Esc returns to the dashboard. The dashboard's previous `[v]erify` letter shortcut was removed — its content is fully covered by this screen. The textual `verify` / `analyze` commands still exist for scripts.
**Command group factorisation**: `RegisterCommands()` in `commands.cpp` owns most built-ins, but self-contained groups live in their own files (one `Register<X>Commands()` member each). Today only `RegisterExportCommands()` in `commands_export.cpp` follows the pattern. Adding a new group is mechanical: declare a new member in `tui.hpp`'s `private:` section, define it in `commands_<group>.cpp`, and call it from the orchestrator. Each group can have file-local helpers (e.g. `commands_export.cpp` has its own anonymous-namespace `csv_quote` and `pin_side`).
**Generic file-picker dialog** (`screen_filedialog.cpp`): one reusable modal for every "pick a path" interaction. State lives in `Tui::file_dialog` (a single `FileDialogState`); attached to the tab tree via `Modal(BuildFileDialog(), &file_dialog.open)` in `Run()`. API:
- `OpenFileDialog(title, persist_key, default_filename, filters, on_confirm)` — opens the modal, restoring the last-used `(dir, filename)` for `persist_key` if previously saved.