Skip to content

Commit bd0ce9a

Browse files
qclaude
andcommitted
fix: title/subtitle/separator support for plain text input
render_text now accepts header params and passes them through _place_header, so --title, --subtitle, and --separator work regardless of input type. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8b3e798 commit bd0ce9a

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

vesta.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -762,14 +762,16 @@ def _tone_to_color(tone: str | None) -> Color | None:
762762
# -----------------------------------------------------------------------------
763763

764764

765-
def render_text(profile: BoardProfile, text: str, align: str = "center", valign: str = "center") -> RenderedMessage:
765+
def render_text(profile: BoardProfile, text: str, align: str = "center", valign: str = "center", title: str | None = None, title_color: Color | list[Color] | None = None, subtitle: str | None = None, subtitle_color: Color | list[Color] | None = None, separator: str | None = None) -> RenderedMessage:
766766
text = _expand_escapes(text)
767767
grid = _blank_grid(profile)
768-
lines = _wrap_text(text, profile.cols, profile.rows)
768+
header_row = _place_header(grid, profile, title, title_color, subtitle, subtitle_color, separator)
769+
available_rows = profile.rows - header_row
770+
lines = _wrap_text(text, profile.cols, available_rows)
769771
if valign == "center":
770-
top = max(0, (profile.rows - len(lines)) // 2)
772+
top = header_row + max(0, (available_rows - len(lines)) // 2)
771773
else:
772-
top = 0
774+
top = header_row
773775
for i, line in enumerate(lines):
774776
_place_line(grid, top + i, line.rstrip(), align=align)
775777
return RenderedMessage(profile=profile, grid=grid)
@@ -1151,12 +1153,12 @@ def _render_metrics(profile: BoardProfile, data: dict[str, Any], title: str | No
11511153
def render_auto(profile: BoardProfile, payload: Any, title: str | None = None, title_color: Color | list[Color] | None = None, subtitle: str | None = None, subtitle_color: Color | list[Color] | None = None, align: str | None = None, valign: str = "top", separator: str | None = None) -> RenderedMessage:
11521154
"""Infer the best renderer from the payload type and content."""
11531155
if isinstance(payload, str):
1154-
return render_text(profile, payload, valign=valign)
1156+
return render_text(profile, payload, valign=valign, title=title, title_color=title_color, subtitle=subtitle, subtitle_color=subtitle_color, separator=separator)
11551157
if isinstance(payload, dict):
11561158
return render_data(profile, payload, title=title, title_color=title_color, subtitle=subtitle, subtitle_color=subtitle_color, align=align, valign=valign, separator=separator)
11571159
if isinstance(payload, list) and payload and all(isinstance(x, dict) for x in payload):
11581160
return render_data(profile, payload, title=title, title_color=title_color, subtitle=subtitle, subtitle_color=subtitle_color, align=align, valign=valign, separator=separator)
1159-
return render_text(profile, json.dumps(payload, separators=(",", ":")), align="left", valign=valign)
1161+
return render_text(profile, json.dumps(payload, separators=(",", ":")), align="left", valign=valign, title=title, title_color=title_color, subtitle=subtitle, subtitle_color=subtitle_color, separator=separator)
11601162

11611163

11621164
# -----------------------------------------------------------------------------
@@ -1497,7 +1499,7 @@ def _build_message(profile: BoardProfile, template: str, payload: Any, title: st
14971499
if _is_raw_grid(payload, profile):
14981500
return _from_characters(payload, profile)
14991501
if template == "text":
1500-
return render_text(profile, str(payload), valign=valign)
1502+
return render_text(profile, str(payload), valign=valign, title=title, title_color=title_color, subtitle=subtitle, subtitle_color=subtitle_color, separator=separator)
15011503
if template == "kv":
15021504
if not isinstance(payload, dict):
15031505
raise SystemExit("template=kv requires a JSON object")

0 commit comments

Comments
 (0)