The main menu's quit hint reads ^Q quit?, since it asks first

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-09-29 01:52:49 -04:00
1 parent dd64ea8e87
commit 2d6b8ada6e
6 files changed
+16 -16

No files matched your search

+2 -2
View File
@@ -153,7 +153,7 @@ deliberately, one at a time, and say why in the code.
nothing under it stops, and a second ^Q while it asks leaves at once
(`TuiSession.request_quit`; ^Q sits one key from ^W). Both are answered in
`TuiSession._dispatch`, and neither is advertised — a global verb has no screen to
belong to, and the F-key lane has only three free slots per screen — except `^Q quit`
belong to, and the F-key lane has only three free slots per screen — except `^Q quit?`
on the main menu's own hint, where Esc is inert and the reader looks for the way out.
On picocalc that atom rides the title bar's tail (`frame._way_out`), and the menu's lane
puts the way out on F3: `Quit?` asks, its Shift half F8 `Quit!` leaves without asking
@@ -275,7 +275,7 @@ as a grouped list does. Filling a page in is editing its `.md`; no Python follow
- ≤72 cells. Sentence shape: navigation keys, then action keys, **Esc last**.
- Esc verb by surface: `Esc back` leaves a screen · `Esc close` dismisses a read-only
floating view · `Esc cancel` abandons a prompt/dialog · `Esc keep` leaves a value
picker unchanged · no Esc atom at the main menu, which ends on `^Q quit` instead ·
picker unchanged · no Esc atom at the main menu, which ends on `^Q quit?` instead ·
`Esc bye` only on the device
splash, which is the door rather than a screen — nothing has been started there to
quit out of. While a find-as-you-type filter is standing the verb becomes `Esc clear`,
+1 -1
View File
@@ -706,7 +706,7 @@ async def _menu_loop(ctx: AppContext, session: TuiSession) -> None:
# 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
# else it stays unadvertised, like ^W (see session._CTRL_LETTER_CHORDS).
footer_hint="↑↓ move · type to filter · Enter select · ^Q quit",
footer_hint="↑↓ move · type to filter · Enter select · ^Q quit?",
)
session.set_root(menu)
loop = asyncio.get_running_loop()
+4 -4
View File
@@ -213,9 +213,9 @@ _BASE_BOX_CACHE: tuple[tuple, list[str]] | None = None
#: mandated — "navigation keys, then action keys, **Esc last**" — so the last atom is the
#: Esc clause wherever a screen has one, and its verb is the true one for that surface
#: (``back`` on a screen, ``keep`` in a value picker). The main menu is the one screen
#: whose way out is not Esc, which is inert there: its hint ends on ``^Q quit`` instead,
#: whose way out is not Esc, which is inert there: its hint ends on ``^Q quit?`` instead,
#: until a typed filter puts ``Esc clear`` after it.
_WAY_OUT_ATOM = re.compile(r"(?:^|·\s*)(Esc\s+\S+|\^[A-Z]\s+quit)\s*$")
_WAY_OUT_ATOM = re.compile(r"(?:^|·\s*)(Esc\s+\S+|\^[A-Z]\s+quit\??)\s*$")
#: Rule cells the title keeps on each side before the bar gives the Esc hint back. Below
#: this the title is being crowded, which is the one thing the hint must not do.
@@ -240,7 +240,7 @@ def fitted_title(screen: Screen, room: int) -> str:
def _way_out(hint: str) -> str:
"""The way-out atom a screen's footer hint ends on (``Esc …``, ``^Q quit``), or ``""``."""
"""The way-out atom a screen's footer hint ends on (``Esc …``, ``^Q quit?``), or ``""``."""
found = _WAY_OUT_ATOM.search(hint or "")
return found.group(1) if found else ""
@@ -276,7 +276,7 @@ def _title_bar(screen: Screen, cols: int, more_above: bool, more_below: bool) ->
its five slots do — so nothing on the screen said that Esc leaves, which is the one key
every screen answers to and the reason no screen spends a row on a *Back* item. The
verb is the screen's own (:func:`_way_out` lifts the atom off its footer hint, so a
value picker says ``keep``, and the main menu, where Esc is inert, says ``^Q quit``);
value picker says ``keep``, and the main menu, where Esc is inert, says ``^Q quit?``);
a screen whose hint names no way out gets nothing. Compact by construction: where a
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
+1 -1
View File
@@ -72,7 +72,7 @@ from .spinner import spinner_interval
#: to leave the app from anywhere — a second press while it asks is the leaving (see
#: :meth:`TuiSession.request_quit`). Neither is advertised in a footer hint or an F-key
#: chip — the lane has three free slots per screen and a global verb would claim one on
#: every screen forever (JP, 2026-08-30) — save ``^Q quit`` on the main menu's own hint,
#: every screen forever (JP, 2026-08-30) — save ``^Q quit?`` on the main menu's own hint,
#: where Esc is inert and the reader looks for the way out (issue #22). ^W was
#: picked for the close-this-whole-thing reflex; both were verified deliverable on the
#: Canadian Multilingual layout (^W ``U+0017``, ^Q ``U+0011``) and neither is eaten by the
+4 -4
View File
@@ -957,17 +957,17 @@ def test_esc_at_the_main_menu_does_nothing_but_peel_a_filter() -> None:
menu = _MainMenu(
"menu",
[Choice("alpha", 1), Choice("beta", 2)],
footer_hint="↑↓ move · type to filter · Enter select · ^Q quit",
footer_hint="↑↓ move · type to filter · Enter select · ^Q quit?",
)
menu.future = asyncio.new_event_loop().create_future()
menu.handle("escape")
assert not menu.future.done(), "a bare Esc at the menu resolves nothing"
assert not menu.footer_hint.endswith("Esc clear")
menu.handle("text", "b")
assert menu.footer_hint.endswith("^Q quit · Esc clear")
assert menu.footer_hint.endswith("^Q quit? · Esc clear")
menu.handle("escape")
assert menu._filter == "" and not menu.future.done()
assert menu.footer_hint.endswith("^Q quit")
assert menu.footer_hint.endswith("^Q quit?")
def test_the_main_menu_lane_puts_the_way_out_on_f3() -> None:
@@ -1065,7 +1065,7 @@ def test_neither_global_chord_is_advertised_anywhere() -> None:
and chord.search(node.value)
):
offenders.append(f"{path.name}:{node.lineno}: {node.value.strip()[:70]}")
menu_hint = [o for o in offenders if o.startswith("menu.py:") and o.endswith("· ^Q quit")]
menu_hint = [o for o in offenders if o.startswith("menu.py:") and o.endswith("· ^Q quit?")]
assert len(menu_hint) == 1, "the main menu's hint must name the quit chord, once"
offenders.remove(menu_hint[0])
assert not offenders, "the global chords must not appear in any hint or chip:\n" + "\n".join(
+4 -4
View File
@@ -140,16 +140,16 @@ def test_the_bar_speaks_the_screen_s_own_esc_verb() -> None:
def test_the_main_menu_s_way_out_is_the_quit_chord_until_a_filter_stands() -> None:
"""Esc is inert at the menu, so the bar carries ^Q there — and Esc clear over it.
The menu's hint ends on ``^Q quit`` rather than an Esc clause (issue #22); the tail
The menu's hint ends on ``^Q quit?`` rather than an Esc clause (issue #22); the tail
lifts whichever way out the hint ends on, so a typed filter's ``Esc clear`` wins while
it stands, because that is the key that does something then.
"""
title = "What would you like to do?"
idle = "↑↓ move · type to filter · Enter select · ^Q quit"
assert _bar(title, idle).endswith(" ^Q quit")
idle = "↑↓ move · type to filter · Enter select · ^Q quit?"
assert _bar(title, idle).endswith(" ^Q quit?")
assert _bar(title, f"{idle} · Esc clear").endswith(" Esc clear")
# Crowded, it gives way the way Esc does: its bare key first, never a stray "Esc".
verbless = _bar("Trace — Hilltop-Repeater over a specs", "↑↓ move · ^Q quit")
verbless = _bar("Trace — Hilltop-Repeater over a spec", "↑↓ move · ^Q quit?")
assert verbless.rstrip().endswith(" ^Q") and "Esc" not in verbless