mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-16 02:46:38 +03:00
06466a6512
The shared panel helpers counted characters, so a CJK prompt or UI rendered rows wider than the terminal and broke the right border. _wrap_panel_text wraps text holding wide characters by cells (splitting CJK runs with no spaces), row padding and the title rule count cells. Plain ASCII (newlines/tabs included) wraps exactly as before. Only the cli_render.py/cli_panel.py hunks of f4c8021efe6 and 67e689cb8f4 from #149354.
29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
"""Bordered overlay panels (approval, clarify, sudo, pickers) for the classic CLI's live region."""
|
|
|
|
from hermes_cli.cli_render import _append_blank_panel_line, _append_panel_line, _cells
|
|
|
|
|
|
class _Panel:
|
|
"""Fragment accumulator for one bordered overlay panel (``(style, text)`` tuples)."""
|
|
|
|
def __init__(self, border: str, box_width: int, title: str = "", title_style: str = ""):
|
|
self.lines, self.border, self.width = [], border, box_width
|
|
self._row, self._blank = _append_panel_line, _append_blank_panel_line
|
|
if title:
|
|
# Title inlined into the top rule: ``╭─ Title ───╮``.
|
|
self.lines.append((border, "╭─ "))
|
|
self.lines.append((title_style, title))
|
|
self.lines.append((border, " " + ("─" * max(0, box_width - _cells(title) - 3)) + "╮\n"))
|
|
else:
|
|
self.lines.append((border, "╭" + ("─" * box_width) + "╮\n"))
|
|
|
|
def row(self, style: str, text: str) -> None:
|
|
self._row(self.lines, self.border, style, text, self.width)
|
|
|
|
def blank(self) -> None:
|
|
self._blank(self.lines, self.border, self.width)
|
|
|
|
def close(self) -> list:
|
|
self.lines.append((self.border, "╰" + ("─" * self.width) + "╯\n"))
|
|
return self.lines
|