Splash: a short terminal thins the mark instead of clipping the box

The block was laid out at its full height and whatever overran the screen was
cut off the bottom — which is the box: the device list, the PIN prompt, the
thing the user opened the app to use. The mark kept every row it had.

So a terminal too short for all of it now gives rows back, cheapest first: the
blank line under the mark, which is breathing room and nothing else, and then
the top of the mark itself, up to nine rows of it. Nine is the globe standing
over the lettering — decoration, where the lettering is what says whose splash
this is. Cropping from the top means the lettering and its copyright hold their
place while the mark thins above them, rather than the whole block sliding.

The bound is the art's own height too, so a mark drawn without a globe is never
sheared into its letters, and past the bound the old clip still applies.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 5 committed 2026-08-25 02:26:17 -04:00
1 parent e0a681b293
commit 5f4ad341c5
2 files changed
+75 -6

No files matched your search

+29 -6
View File
@@ -29,6 +29,14 @@ from .screen import Screen
#: point at the pin counts screens actually use (a column header and a section heading).
_PIN_SETTLE_PASSES = 3
#: Rows the splash may shear off the *top* of the wordmark when the terminal is too short
#: to hold the whole block. Both marks are drawn as a globe standing over the lettering, and
#: the globe is decoration: on a short screen the box below it — the device list, the PIN
#: prompt — is what the user came for. Cropping from the top keeps the lettering and its
#: copyright sitting exactly where they were, so the mark thins rather than moves. The art's
#: own height bounds this, so a mark drawn without a globe is never sheared into its letters.
_BANNER_CROP_ROWS = 9
def _window_start(scroll: int, total: int, viewport: int, pinned: int) -> int:
"""The body line the visible window starts at, given ``pinned`` reserved top rows.
@@ -377,6 +385,27 @@ def compose_startup(screen: Screen, cols: int, rows: int) -> str:
inner_w = max(measured, cell_len(screen.title), cell_len(sizing_footer))
inner_w = max(10, min(inner_w, cols - 6))
# The probe render is the answer whenever it was already made at the width we settled
# on — the common case, since a body narrower than the probe *is* what set inner_w.
# The splash repaints on every tick while the device list sits there, and rendering
# the same body twice was a measured third of that paint on the PicoCalc.
body_lines = probe_lines if inner_w == probe else screen.render_body(inner_w)
footnote_h = 1 if screen.footnote else 0 # the note sits directly under the logo
# A terminal too short for the whole block gives rows back in a fixed order, cheapest
# first: the blank line under the mark (breathing room, and nothing else), then the top
# of the mark itself — the globe over the lettering, up to _BANNER_CROP_ROWS of it. The
# lettering and its copyright are the part that says what this is, so they are the part
# that never moves: the mark thins from above while the box below keeps its rows. Past
# that the block is simply taller than the screen and the trailing clip still applies.
short = banner_h + footnote_h + gap + len(body_lines) + 2 - rows
if short > 0 and gap:
gap = 0
short -= 1
if short > 0 and banner:
banner = banner[min(short, _BANNER_CROP_ROWS, banner_h) :]
banner_h = len(banner)
# Pin the banner to a fixed vertical anchor that depends only on the terminal height and
# the banner's own (constant) height, so the wordmark never moves as the box below it
# swaps contents between splash states (device list → spinner → message). The box hangs
@@ -385,14 +414,8 @@ def compose_startup(screen: Screen, cols: int, rows: int) -> str:
# once the device list has populated (the box only ever grows downward); the brief small
# states sit slightly high, the conventional optical placement for dialogs.
top = max(0, rows * 2 // 5 - banner_h - gap)
footnote_h = 1 if screen.footnote else 0 # the note sits directly under the logo
# Rows left for the box below the fixed banner block: the panel border is 2 rows.
below = rows - top - banner_h - footnote_h - gap
# The probe render is the answer whenever it was already made at the width we settled
# on — the common case, since a body narrower than the probe *is* what set inner_w.
# The splash repaints on every tick while the device list sits there, and rendering
# the same body twice was a measured third of that paint on the PicoCalc.
body_lines = probe_lines if inner_w == probe else screen.render_body(inner_w)
budget = below - 2
vpad = _breathing_room(len(body_lines), budget)
viewport = max(1, min(len(body_lines), budget - 2 * vpad))
+46
View File
@@ -760,6 +760,52 @@ def test_compose_startup_is_chromeless_and_shows_banner() -> None:
assert all(len(line.rstrip()) < 80 for line in plain.split("\n"))
def test_startup_splash_gives_rows_back_in_order_when_short() -> None:
"""A short terminal sheds the blank line first, then the top of the mark — never the box.
The lettering says what the app is and the box is what the user came to use; the globe
over the lettering is decoration, so it is what pays. Cropping from the *top* means the
lettering holds its place while the mark thins above it.
"""
marks = [f"MARK{i:02d}" for i in range(16)] # a stand-in with the real mark's height
def splash(rows: int) -> list[str]:
screen = SelectScreen("pick", [Choice("alpha", 1), Choice("beta", 2)])
screen.chrome = False
screen.banner = list(marks)
return Text.from_ansi(frame.compose_startup(screen, 80, rows)).plain.split("\n")
tall = splash(40)
# Roomy: every row of the mark, and a blank line between it and the box.
assert all(m in "\n".join(tall) for m in marks)
mark_end = max(i for i, line in enumerate(tall) if marks[-1] in line)
assert tall[mark_end + 1].strip() == ""
# Walk the terminal down a row at a time and note when each concession is made. The
# exact heights depend on how tall the box below happens to be, so pin the order.
gap_lost = cropped = None
for rows in range(40, 8, -1):
lines = splash(rows)
end = max((i for i, ln in enumerate(lines) if marks[-1] in ln), default=None)
has_gap = end is not None and end + 1 < len(lines) and lines[end + 1].strip() == ""
if gap_lost is None and not has_gap:
gap_lost = rows
if cropped is None and marks[0] not in "\n".join(lines):
cropped = rows
if end is not None: # while any of the mark is drawn, its last row is drawn
assert marks[-1] in "\n".join(lines), f"{rows} rows: lost the mark's last row"
assert gap_lost is not None, "the blank line was never given back"
assert cropped is not None, "the mark was never cropped"
assert gap_lost > cropped, "the blank line must go before the mark is cropped"
# The crop is bounded: the first row past _BANNER_CROP_ROWS is never sheared, however
# short the terminal gets. (Below a certain height the block simply outgrows the screen
# and the trailing clip takes the bottom — a different mechanism, not the crop.)
keeper = marks[frame._BANNER_CROP_ROWS]
for rows in range(20, 5, -1):
assert keeper in "\n".join(splash(rows)), f"{rows} rows: cropped past the bound"
def test_startup_splash_fits_every_platform_width() -> None:
"""The real wordmark, drawn at each platform's own width, never overruns it.