Files
Teknium 7c74dc87e4 refactor(cli): move resume-arg steps and panel wrap helpers to siblings
main.py and cli_tui_mixin.py are over the file-size cap, and the N8
resume recreate and the TUI-26 consumed-stop branch grew them. The
code-health ratchet asks for the growth to be offset in the same PR.
Moved unchanged:
- _import_foreign_resume and the new resume worktree recreate go to
  hermes_cli/main_resume_args.py.
- _wrap_rows and _prefix_wrapped_rows go to hermes_cli/cli_tui_wrap.py.

Refs #134889 (N8)
2026-10-19 11:58:44 -07:00

21 lines
1.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Row-wrapping helpers for the classic CLI's prompt_toolkit panels (moved from ``cli_tui_mixin``)."""
def _wrap_rows(wrap, items, width, indent) -> list[tuple[int, str]]:
"""``(index, wrapped_line)`` pairs so selected styling can be re-applied per row."""
return [(i, w) for i, label in enumerate(items) for w in wrap(label, width, subsequent_indent=indent)]
def _prefix_wrapped_rows(wrap, label, width, first_prefix, indent) -> list[str]:
"""Wrap ``label``, then prefix the rows with ``first_prefix`` / ``indent``.
The prefix is applied *after* wrapping on purpose. Folding it into the
string handed to the wrapper charges those columns against the label's own
width budget — so a selected row wraps one line early and strands the ``❯``
cursor on a row of its own — and whitespace-trimming wrappers drop the
leading indent entirely, leaving long unselected labels flush against the
panel border, out of alignment with every other row.
"""
rows = wrap(label, width)
return [(first_prefix if i == 0 else indent) + row for i, row in enumerate(rows)]