On the Cardputer the header folds into the title bar

The Cardputer's 14 rows had a whole one spent on the header. It has no
header row now: its unread and Watchtower badges and the battery ride the
title bar's right end, after the way out, so they sit in the top-right
corner they always had, one row up, and every screen gets that row back.
The way out gives way first and then the title, never the status. The
wordmark moves to the main menu's title, in the header's own colours, and
the activity pulse goes; the dashboard draws the mesh's activity in full.

A tall dialog now draws over the bar, eleven rows instead of ten, but
never over the lane, which is the dialog's own and names keys nowhere
else. Where a box covers the bar, the bar's ends either side of it are
blanked, since a stray "7%" beside the box would read as the battery.

JP chose the corner placement and the dialog height from rendered
mockups. The PicoCalc and the desktop are unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 5.5 committed 2026-10-03 17:00:22 -04:00
1 parent 032e686beb
commit fedb56bf9e
8 files changed
+318 -33

No files matched your search

+8
View File
@@ -628,6 +628,14 @@ branch on the platform per frame, and never `from meshterm.platforms import PLAT
pair that appeared and vanished, half of it a blank cell, asked the reader to compare
the row against a memory of itself; fixed furniture means the bar never changes width
as the body scrolls either.
- **The Cardputer has no header row** (`Platform.header_row`): the header's badges and
battery ride the title bar's right end, after the way out —
`↑↓ ── Title ──── Esc back ● 3 ⣷ 87%`, the top-right corner they always had, one row
up — and the wordmark is the main menu's title (`menu._menu_title`). The status never
gives way: the way out sheds first, then the title is cut on an ellipsis. A tall dialog
draws over the bar (`dialog_row_margin` 1) but never over the lane, which is the
dialog's own; the bar's ends either side of the box are blanked
(`frame.composite_float`), since a stray `7%` would read as the battery.
- **Never emit a raw emoji or bare hex colour into picocalc output.** Icons go through
`theme.glyph()` (the compact map); everything else is caught by the render-boundary
fold (`theme.fold_text`, applied in `tui/render.render_to_ansi` and
+25 -7
View File
@@ -65,14 +65,25 @@ class Platform:
row folds ``rssi`` onto a line of its own for want of two cells (JP, on-device,
2026-08-10). Two columns a side still reads as floating and buys them back.
dialog_row_margin: Rows a floating dialog leaves to the frame around it — the header
above and the footer below, which a dialog never covers, plus any blank row
between them and the box. One row of air above and below is what lets a box read
as floating on a 24-row terminal (4 in all); on the Cardputer's 14 rows those two
rows are a fifth of what a dialog could show, and its side gutters already say
it floats, so the box runs from the header to the lane (2).
above and the footer below, plus any blank row between them and the box. One row
of air above and below is what lets a box read as floating on a 24-row terminal
(4 in all). On the Cardputer's 14 rows every row a dialog gives up is a row it
can't show, its side gutters already say it floats, and there is no header row
above the title bar, so a tall box runs from the top row to the lane (1),
drawing over the bar — whose ends either side of the box are blanked rather than
left as fragments (see :func:`~meshterm.ui.tui.frame.composite_float`). Never
over the lane: a dialog's lane is the dialog's own, and the keys on it are named
nowhere else.
header_atoms: Which segments compose the persistent header, in the vocabulary
``"version"``, ``"device"``, ``"badges"``, ``"pulse"``, ``"battery"``. Wired
into :func:`~meshterm.ui.menu._header` in P4; unconsumed until then.
header_row: Whether the persistent header has a row of its own above the frame.
Where it doesn't (the Cardputer, JP 2026-10-03), the header's atoms ride the
borderless title bar's right end, after the way out — so its badges and battery
sit in the top-right corner they always had, one row up, and every screen gets
that row back — and the wordmark becomes the main menu's title (see
:func:`~meshterm.ui.menu._menu_title`). Only a borderless frame can fold it: the
bordered panel has no bar to carry it.
lane_deck: Which F-key lane deck the footer deals, by name (see
:data:`~meshterm.ui.tui.fkeys.DECKS`), or ``""`` where the footer is each
screen's own ``footer_hint`` string instead. A deck is everything about the lane
@@ -159,6 +170,7 @@ class Platform:
dialog_margin: int
dialog_row_margin: int
header_atoms: tuple[str, ...]
header_row: bool
lane_deck: str
width_reclaim: bool
emoji: bool
@@ -189,6 +201,7 @@ REGULAR = Platform(
dialog_margin=6,
dialog_row_margin=4,
header_atoms=("version", "device", "badges", "pulse", "battery"),
header_row=True,
lane_deck="",
width_reclaim=True,
emoji=True,
@@ -220,6 +233,7 @@ PICOCALC = Platform(
# "MeshTerm vX" — rather than naming the device/port (on a soldered radio the port
# never changes), and the activity pulse takes whatever room remains.
header_atoms=("version", "badges", "pulse", "battery"),
header_row=True,
lane_deck="picocalc",
width_reclaim=False,
emoji=False,
@@ -255,8 +269,12 @@ CARDPUTER = Platform(
frame_border=False,
menu_icons=False,
dialog_margin=4,
dialog_row_margin=2,
header_atoms=("version", "badges", "pulse", "battery"),
dialog_row_margin=1,
# No header row (JP, 2026-10-03): the badges and battery ride the title bar's right
# end, the wordmark is the main menu's title, and the pulse, which only ever had the
# header's leftover cells, goes — the dashboard draws the mesh's activity in full.
header_atoms=("badges", "battery"),
header_row=False,
lane_deck="cardputer",
width_reclaim=False,
emoji=False,
+42 -6
View File
@@ -168,6 +168,11 @@ def _header(ctx: AppContext, cache: dict, width: int) -> Text:
width: The terminal width in columns; the sparkline soaks up whatever the
fixed segments leave of it.
Where the platform has no header row (:attr:`~meshterm.platforms.Platform.header_row`,
the Cardputer), the same atoms ride the title bar's right end instead, so this returns
them alone — the badges, then the battery, a space apart, no padding and no pulse: the
bar places them, and the wordmark is the main menu's title there (:func:`_menu_title`).
Returns:
A Rich :class:`Text` shown at the top of every screen. The frame crops it to a
single line (see ``frame.compose_base``), so a too-narrow terminal chops the
@@ -176,11 +181,14 @@ def _header(ctx: AppContext, cache: dict, width: int) -> Text:
# Which items compose at all is platform data (see Platform.header_atoms): the
# PicoCalc's 53 columns drop the version mark and the pulse, keeping device, badges
# and battery. Read live — set_platform runs before the session, but tests swap.
atoms = get_platform().header_atoms
platform = get_platform()
atoms = platform.header_atoms
# The battery gauge is pinned to the row's right edge, so reserve its width (plus a
# leading separator) before the pulse claims the rest; a wider separator estimate for
# the fit decision is harmless slack.
battery = _battery_segment(ctx) if "battery" in atoms else Text()
if not platform.header_row:
return Text(" ").join(seg for seg in (*_header_segments(ctx, cache), battery) if seg)
# The separator choice changes only the *joins*, never the segments themselves, so the
# segments are built once and each candidate width is arithmetic: one separator per
# segment (each is preceded by one, and a trailing one leads into the pulse). Building
@@ -271,6 +279,16 @@ def _battery_segment(ctx: AppContext) -> Text:
return battery_cell(reading.percent, charging=reading.charging, frame=frame)
def _wordmark() -> Text:
"""The app's mark as the header draws it: ``MeshTerm`` in brand, its version muted."""
# Built per append rather than under a base style, which would blanket the version
# in the mark's brand.
mark = Text()
mark.append("MeshTerm", style="brand")
mark.append(f" v{__version__}", style="muted")
return mark
def _header_segments(ctx: AppContext, cache: dict) -> list[Text]:
"""The header's fixed segments — everything left of the pulse — unjoined.
@@ -292,10 +310,7 @@ def _header_segments(ctx: AppContext, cache: dict) -> list[Text]:
# passed to the constructor would instead blanket everything appended after it, layering
# the mark's brand under the version's muted.
if "version" in atoms:
mark = Text()
mark.append("MeshTerm", style="brand")
mark.append(f" v{__version__}", style="muted")
segments.append(mark)
segments.append(_wordmark())
if "device" in atoms:
device = Text()
@@ -539,6 +554,22 @@ async def _confirm_quit(ctx: AppContext, session: TuiSession) -> bool:
return choice in ("unpair", "quit")
#: The main menu's heading wherever a header row carries the wordmark above it.
_MENU_PROMPT = "What would you like to do?"
def _menu_title() -> str:
"""The main menu's heading: the question, or the wordmark where no header row carries it.
On a platform without a header row (the Cardputer), the header's badges and battery ride
the title bar and its wordmark has nowhere left to go, so the root screen — the one the
app opens on and every ^W lands back on — wears it as its title instead (JP,
2026-10-03). Every other screen names what it is; the menu's question names nothing the
reader doesn't already know, and is the one heading worth trading.
"""
return _MENU_PROMPT if get_platform().header_row else _wordmark().plain
class _MainMenu(SelectScreen):
"""The main menu's list, on which Esc peels a typed filter and otherwise does nothing.
@@ -559,6 +590,11 @@ class _MainMenu(SelectScreen):
return
super().handle(action, data)
def bar_title(self, title: str, style: str) -> Text:
"""The wordmark keeps the header's colours where it is the title (:func:`_menu_title`)."""
mark = _wordmark()
return mark if title == mark.plain else super().bar_title(title, style)
@property
def picocalc_lane(self):
"""The list's own lane, with the way out on F3: ``Quit?`` asks, ``Quit!`` doesn't.
@@ -708,7 +744,7 @@ async def _menu_loop(ctx: AppContext, session: TuiSession) -> None:
# stack while the quit dialog floats over it: the confirm is drawn as a centered box
# on top of the still-visible menu, not as a screen that replaces it.
menu = _MainMenu(
"What would you like to do?",
_menu_title(),
items,
# The one place the quit chord is named: the menu is where a reader looks for the
# way out, and with Esc inert here the footer would otherwise name none. Everywhere
+79 -15
View File
@@ -258,7 +258,13 @@ def _way_out(hint: str) -> str:
return found.group(1) if found else ""
def _title_bar(screen: Screen, cols: int, more_above: bool, more_below: bool) -> Text:
def _title_bar(
screen: Screen,
cols: int,
more_above: bool,
more_below: bool,
status: Text | None = None,
) -> Text:
"""The borderless frame's one-row title bar: clip arrows, a centered title, the way out.
The Panel border's whole vocabulary — where you are (title) and whether the body
@@ -294,19 +300,42 @@ def _title_bar(screen: Screen, cols: int, more_above: bool, more_below: bool) ->
long title would be crowded, the atom drops to its bare key and then out
altogether — the title is what the reader came for, and the arrows are two cells
nothing else can spend.
Where the platform has **no header row** (the Cardputer, JP 2026-10-03), the header's
atoms arrive as ``status`` and are pinned to the bar's right end, after the way out:
``↑↓ ── Title ──── Esc back ● 3 ⣷ 87%``. That is the top-right corner the badges and
battery always had, one row up, and every screen gets the header's row back. The status
gives way to nothing — an unread count and a dying battery are what it exists to say —
so the way out sheds first, as it does for a long title, and a title too long even then
is cut short on an ellipsis rather than pushing the status off the end of the row.
Args:
screen: The screen whose heading the bar carries.
cols: Bar width in cells.
more_above: Whether the body continues above the viewport.
more_below: Whether the body continues below it.
status: The header's atoms, for a platform without a header row; ``None`` (or
empty: nothing unread, no pack) draws the bar exactly as it is with a header.
"""
border = "accent"
head_span = 3 # the arrow pair, plus the space parting it from the rule
status = status if status is not None and status.cell_len else None
stat_span = status.cell_len + 1 if status else 0 # the space in front of the status
# The short form is chosen against the bar with no Esc tail at all: the title is what
# the reader came for, so the tail gives way to it before it gives way to the tail.
title = fitted_title(screen, cols - head_span - 2 - 2 * _MIN_RULE)
title = fitted_title(screen, cols - head_span - stat_span - 2 - 2 * _MIN_RULE)
label_w = cell_len(title) + 2 if title else 0 # a space either side
atom = _way_out(screen.footer_hint)
for esc in (atom, atom.split()[0] if atom else "", ""):
tail_span = cell_len(esc) + 1 if esc else 0 # the space in front of the tail
if not esc or cols - head_span - tail_span - label_w >= 2 * _MIN_RULE:
if not esc or cols - head_span - tail_span - stat_span - label_w >= 2 * _MIN_RULE:
break
rule_span = max(0, cols - head_span - tail_span)
rule_span = max(0, cols - head_span - tail_span - stat_span)
heading = screen.bar_title(title, title_style(border)) if title else Text()
if status and label_w > rule_span - 2:
# A rule cell either side, and whatever is left for the title; the status stays.
heading.truncate(max(1, rule_span - 4), overflow="ellipsis")
label_w = heading.cell_len + 2
bar = Text()
bar.append("↑", style=border if more_above else "muted")
@@ -317,19 +346,37 @@ def _title_bar(screen: Screen, cols: int, more_above: bool, more_below: bool) ->
right = max(1, rule_span - label_w - left)
bar.append("─" * left, style=border)
bar.append(" ", style=None)
bar.append(title, style=title_style(border))
bar.append_text(heading)
bar.append(" ", style=None)
bar.append("─" * right, style=border)
else:
bar.append("─" * rule_span, style=border)
if esc:
bar.append(" " + esc, style=hint_style(border))
if status:
bar.append(" ")
bar.append_text(status)
bar.truncate(cols)
return bar
def header_lines(header: Text, cols: int) -> list[str]:
"""The header's rows above the frame: its one line, or none where it has no row.
The header is a single status line, cropped to one row so a narrow terminal never wraps
it onto a second (which would push the panel down and misreport its height). A platform
without a header row (:attr:`~meshterm.platforms.Platform.header_row`) draws none here —
the title bar carries the header's atoms instead (see :func:`_title_bar`) — and this is
the one place that says so, for :func:`compose_base` and for the session sizing a body
against it alike.
"""
if not get_platform().header_row:
return []
return render_lines(header, cols, no_wrap=True)
def compose_base(
header: RenderableType,
header: Text,
base: Screen,
footer_hint: str,
cols: int,
@@ -339,7 +386,9 @@ def compose_base(
"""Compose the full-screen ANSI view: header, the base screen's panel, and a footer.
Args:
header: The persistent header renderable (banner + live status).
header: The persistent header (banner + live status) — a row of its own, or, on a
platform without a header row, the title bar's right end (see
:func:`header_lines`).
base: The screen filling the background (the deepest non-floating layer).
footer_hint: The active screen's key hint, shown at the very bottom.
cols: Terminal width.
@@ -354,10 +403,8 @@ def compose_base(
"""
global _BASE_BOX_CACHE
platform = get_platform()
# The header is a single status line: crop it to one row so a narrow terminal never
# wraps it onto a second line (which would push the panel down and misreport its height).
header_lines = render_lines(header, cols, no_wrap=True)
header_h = len(header_lines)
head = header_lines(header, cols)
header_h = len(head)
def footer_row() -> RenderableType:
"""The bottom line: the platform's F-key lane, else the muted hint string."""
@@ -401,13 +448,14 @@ def compose_base(
base.note_viewport(viewport)
body_lines = base.render_body(cols)
visible, more_above, more_below = _visible_slice(base, body_lines, viewport)
bar = _title_bar(base, cols, more_above, more_below)
status = None if platform.header_row else header
bar = _title_bar(base, cols, more_above, more_below, status)
body = (
render_lines(bar, cols, no_wrap=True)
+ visible
+ render_lines(footer_row(), cols, no_wrap=True)
)
lines = header_lines + body
lines = head + body
# Guarantee we never exceed the terminal height (pt would otherwise clip unpredictably).
if len(lines) > rows:
lines = lines[:rows]
@@ -858,6 +906,13 @@ def composite_float(base_rows: list[str], box: str, cols: int, rows: int) -> lis
cols: Terminal width.
rows: Terminal height.
A box that lands on the borderless frame's **title bar** takes the whole row: the
cells either side of it are blanked instead of letting the bar show through. Every
other row's gutter is the backdrop the box floats over, and reads as one; a bar cut by a
box is fragments of chrome — the base's clip arrows, the last letters of its way out,
and, where the bar carries the header's atoms (the Cardputer, whose tall dialogs draw
over the bar), the tail of a battery gauge, where a stray ``7%`` reads as a reading.
Returns:
A new list of rows with the box merged in. Rows the box doesn't reach are passed
through untouched — the same strings, so the row diff skips them for free.
@@ -870,18 +925,27 @@ def composite_float(base_rows: list[str], box: str, cols: int, rows: int) -> lis
for i, line in enumerate(lines):
y = top + i
if 0 <= y < len(out):
out[y] = _overlay_row(out[y], line, left, cols)
under = "" if y == _BAR_ROW else out[y]
out[y] = _overlay_row(under, line, left, cols)
return out
#: The row the borderless frame's title bar sits on — under the header's one line, or
#: the top row where the platform has no header row — or ``None`` on a bordered frame,
#: whose top rule is the panel's own and has no fragments to leave (bound in :func:`_bind`).
_BAR_ROW: int | None = None
@on_platform
def _bind(platform: Platform) -> None:
"""Drop the composition memos on a platform switch — their output bakes the theme in.
Also binds where the title bar sits (:data:`_BAR_ROW`), which only the platform decides.
Registered at module bottom so the immediate first run (see
:func:`~meshterm.platforms.on_platform`) finds every cache already defined.
"""
global _BASE_BOX_CACHE, _BANNER_CACHE
global _BASE_BOX_CACHE, _BANNER_CACHE, _BAR_ROW
_BAR_ROW = None if platform.frame_border else int(platform.header_row)
_BASE_BOX_CACHE = None
_BANNER_CACHE = None
_DIALOG_CACHE.clear()
+10
View File
@@ -175,6 +175,16 @@ class Screen:
return DEFAULT_LANE
def bar_title(self, title: str, style: str) -> Text:
"""The heading as the borderless title bar draws it: ``title`` in the bar's ``style``.
``title`` is whichever form the bar chose (:func:`~meshterm.ui.tui.frame.fitted_title`).
A heading that is a *mark* rather than words keeps the mark's own colours by
overriding this — the main menu's wordmark, on a frame with no header row to carry
it (see :attr:`~meshterm.platforms.Platform.header_row`).
"""
return Text(title, style=style)
def __init__(self) -> None:
"""Initialize scroll state and the (later-assigned) result future."""
self.scroll = 0
+1 -3
View File
@@ -1827,10 +1827,8 @@ class TuiSession:
Returns:
The inner content width and the body viewport height, both in character cells.
"""
from .render import render_lines
cols, rows = self._size()
header_h = len(render_lines(self._header(cols), cols, no_wrap=True))
header_h = len(frame.header_lines(self._header(cols), cols))
if get_platform().frame_border:
base = self._base_screen()
inset = frame.panel_inset(base is not None and base.flush)
+146
View File
@@ -0,0 +1,146 @@
# SPDX-License-Identifier: Apache-2.0
"""The Cardputer's frame: no header row, its atoms on the title bar, dialogs over the bar."""
from __future__ import annotations
from types import SimpleNamespace
from rich.cells import cell_len
from rich.text import Text
from meshterm import __version__
from meshterm.platforms import CARDPUTER, PICOCALC, set_platform
from meshterm.ui import menu
from meshterm.ui.tui import frame
from meshterm.ui.tui.screen import ScrollScreen
from meshterm.ui.widgets import battery_cell
from tests.conftest import plain as _plain
ROWS, COLS = CARDPUTER.readable_rows, CARDPUTER.readable_cols
def _status() -> Text:
"""Three unread and a pack at 87%, as the header callback hands them to the frame."""
status = Text()
status.append("●", style="err")
status.append(" 3", style="warn")
return Text(" ").join([status, battery_cell(87)])
def _screen(title: str = "Chrome probe", hint: str = "↑↓ move · Esc back") -> ScrollScreen:
body = Text("\n".join(f"row {i}" for i in range(40)))
screen = ScrollScreen(body, title=title, floating=False)
screen._footer_hint = hint
return screen
def _rows(header: Text, cols: int = COLS, rows: int = ROWS, **lane) -> list[str]:
"""The composed base frame, one ANSI string per row."""
return frame.compose_base(header, _screen(), "", cols, rows, **lane).split("\n")
def test_the_cardputer_has_no_header_row() -> None:
"""The title bar is the top row, and every screen gets the header's row for its body."""
set_platform(CARDPUTER)
assert not CARDPUTER.header_row
assert frame.header_lines(_status(), COLS) == []
composed = [_plain(line) for line in _rows(_status())]
assert len(composed) == ROWS
assert composed[0].startswith("↑↓ ") and "Chrome probe" in composed[0]
assert composed[1].startswith("row 0")
# Bar, then twelve body rows, then the footer: the header's row went to the body.
assert composed[12].startswith("row 11")
def test_a_platform_with_a_header_row_keeps_it() -> None:
"""The PicoCalc is unchanged: header on top, the bar under it, no status on the bar."""
set_platform(PICOCALC)
composed = [_plain(line) for line in _rows(Text("hdr"), 53, 26)]
assert composed[0].startswith("hdr")
assert composed[1].startswith("↑↓ ") and "hdr" not in composed[1]
def test_the_status_sits_in_the_corner_after_the_way_out() -> None:
"""``↑↓ ── Title ──── Esc back ● 3 ⣷ 87%``: the badges and battery keep their corner."""
set_platform(CARDPUTER)
bar = frame._title_bar(_screen(), COLS, False, True, _status()).plain
assert cell_len(bar) == COLS
assert bar.endswith("Esc back " + _status().plain)
assert bar.startswith("↑↓ ─") and "Chrome probe" in bar
def test_an_empty_status_draws_the_bar_as_it_always_was() -> None:
"""Nothing unread and no pack: the bar is exactly the one a header row would sit over."""
set_platform(CARDPUTER)
plain_bar = frame._title_bar(_screen(), COLS, False, True).plain
assert frame._title_bar(_screen(), COLS, False, True, Text()).plain == plain_bar
def test_a_long_title_gives_way_before_the_status_does() -> None:
"""The way out sheds first, then the title is cut short; the status is never pushed off."""
set_platform(CARDPUTER)
status = _status()
long_title = "Trace — Hilltop-Repeater over a much longer spec than fits"
bar = frame._title_bar(_screen(long_title), COLS, False, True, status).plain
assert cell_len(bar) == COLS
assert bar.endswith(" " + status.plain)
assert "Esc" not in bar
assert "…" in bar and "Trace — Hilltop" in bar
def test_the_header_is_its_atoms_alone_without_a_row() -> None:
"""No version, no pulse, no padding: the badges and the battery, a space apart."""
set_platform(CARDPUTER)
ctx = SimpleNamespace(
mock=False,
chat=SimpleNamespace(unread_total=lambda: 3),
watchtower=SimpleNamespace(unacked_count=lambda: 1),
battery=SimpleNamespace(reading=lambda: SimpleNamespace(percent=87, charging=False)),
)
header = menu._header(ctx, {}, COLS)
assert header.plain == f"● 3 ▲ 1 {battery_cell(87).plain}"
ctx.chat = SimpleNamespace(unread_total=lambda: 0)
ctx.watchtower = SimpleNamespace(unacked_count=lambda: 0)
ctx.battery = SimpleNamespace(reading=lambda: None)
assert menu._header(ctx, {}, COLS).plain == ""
def test_the_main_menu_wears_the_wordmark_where_no_header_row_does() -> None:
"""The root screen's title is ``MeshTerm vX`` in the header's colours, or else the question."""
set_platform(CARDPUTER)
assert menu._menu_title() == f"MeshTerm v{__version__}"
screen = menu._MainMenu(menu._menu_title(), [], footer_hint="↑↓ move · ^Q quit?")
bar = frame._title_bar(screen, COLS, False, False, _status())
start = bar.plain.index("MeshTerm")
styles = {str(span.style) for span in bar.spans if span.start <= start < span.end}
assert "brand" in styles
set_platform(PICOCALC)
assert menu._menu_title() == "What would you like to do?"
def test_a_tall_dialog_covers_the_bar_and_blanks_its_ends() -> None:
"""Over the bar, never over the lane — and no fragment of the bar shows beside the box.
A dialog's lane is the dialog's own, naming keys nowhere else, so the box stops a row
short of it. On the bar, the cells either side of the box are blanked: there, a stray
``7%`` would read as the battery.
"""
set_platform(CARDPUTER)
assert ROWS - 2 - CARDPUTER.dialog_row_margin == 11 # the dialog's budget
base = _rows(_status(), footer_lane=lambda: Text("LANE"))
box = "\n".join("|" + "x" * 45 + "|" for _ in range(ROWS - 1))
rows = [_plain(row) for row in frame.composite_float(base, box, COLS, ROWS)]
assert rows[0].strip() == "|" + "x" * 45 + "|" # the bar's ends are gone
assert rows[1].startswith("ro") # the backdrop still shows in the gutter below the bar
assert rows[ROWS - 1].startswith("LANE")
def test_a_short_dialog_leaves_the_bar_whole() -> None:
"""A box that doesn't reach the top row leaves the bar, and its status, in view."""
set_platform(CARDPUTER)
base = _rows(_status())
rows = frame.composite_float(base, "\n".join(["[box]"] * 5), COLS, ROWS)
assert rows[0] == base[0]
assert _plain(rows[0]).endswith(_status().plain)
+7 -2
View File
@@ -223,13 +223,18 @@ def test_the_raster_draws_a_cell_in_its_colours() -> None:
def test_meshterm_runs_inside_the_host(monkeypatch) -> None:
"""The ordinary CLI, hosted: the menu draws at 53x14 with the Cardputer's lane, ^Q^Q leaves."""
"""The ordinary CLI, hosted: the menu draws at 53x14 with the Cardputer's lane, ^Q^Q leaves.
No header row: the title bar is the top row, and the menu's title is the wordmark.
"""
from meshterm import __version__
from meshterm.ui import menu
# Quitting arms a watchdog that hard-exits the process if teardown wedges — right for
# the host, which ends with the TUI, but fatal to the test run it is hosted in here.
monkeypatch.setattr(menu, "_arm_exit_watchdog", lambda *args, **kwargs: None)
seen: dict[str, str] = {}
wordmark = f"MeshTerm v{__version__}"
class Headless:
def __init__(self, terminal, lock, type_text):
@@ -240,7 +245,7 @@ def test_meshterm_runs_inside_the_host(monkeypatch) -> None:
while time.monotonic() < deadline:
with self._lock:
text = terminal.text()
if "What would you like to do?" in text:
if text.startswith("↑↓") and wordmark in text.splitlines()[0]:
seen["menu"] = text
break
time.sleep(0.1)