diff --git a/meshterm/ui/tui/fkeys.py b/meshterm/ui/tui/fkeys.py index fab788d..5aca882 100644 --- a/meshterm/ui/tui/fkeys.py +++ b/meshterm/ui/tui/fkeys.py @@ -2,12 +2,18 @@ The PicoCalc keyboard has five dedicated function keys; its MCU translates Shift+F1..F5 into plain F6-F10 keycodes (measured in P0), so "Shift+key = the opposite action" is -literal hardware behaviour and the app simply binds all ten. By JP's spec -(2026-08-01), the five *plain* keys carry a screen's most-used actions — reachable with -no Shift at all — and the Shift bank (F6-F10) is overflow, consulted only when a screen -has more than five things worth a key. F4 and F5 sit closest to the thumbs and take the -highest-priority pair (e.g. commit/leave); F1/F2 take the next pair; F3 is the one lone, -unpaired slot a screen reaches for when it has a single extra action. +literal hardware behaviour and the app simply binds all ten. + +By JP's spec (2026-08-01): a lane slot is for functionality that would otherwise be +*hard to reach* — not a shortcut to a key that is already close at hand. Enter and Esc +sit right on the keyboard and are already the easiest keys to hit, so they never occupy +a slot. Paging (PgUp/PgDn) has no physical key at all, so a screen that scrolls earns it +the prime F4/F5 pair. Ctrl+letter chords (Ctrl+P for message paths, Ctrl+arrows for a +sort column, …) are fiddly to hold on this keyboard, so a screen promotes its own onto +the lone F3 slot (a second, if it has one, riding F3's Shift companion). The five +*plain* keys carry a screen's most-used, otherwise-awkward actions — reachable with no +Shift at all — and the Shift bank (F6-F10) is overflow for a screen with more than five +such actions. A lane can, and does, differ from screen to screen. A screen describes its lane as five :class:`FPair` slots (``None`` = unassigned); the session resolves a pressed F-key to the slot's action string and dispatches it through @@ -55,18 +61,18 @@ class FPair: #: A lane is five slots, F1..F5 left to right; ``None`` leaves a slot unassigned. Lane = Sequence[Optional[FPair]] -#: The screen-agnostic default lane, per JP's slot-priority spec: F4/F5 (the most -#: reachable pair) carry commit/leave — the one action every screen needs and needs -#: without Shift; F1/F2 (the next pair) carry the nav cluster's most common half (jump to -#: top/end), with the paging half riding their Shift bank since it is reached for less -#: often; F3 is the lone slot a screen's own :attr:`~meshterm.ui.tui.screen.Screen.fkey_lane` -#: override reaches for first. +#: The screen-agnostic default lane. No Enter or Esc slot — both keys sit right on the +#: keyboard already. F4/F5 (the most reachable pair) carry paging, which has no physical +#: key at all; F1/F2 carry the nav cluster's jump-to-top/end, Fn-layered on the physical +#: keyboard and so worth a slot too, just a notch behind paging; F3 is the lone slot a +#: screen's own :attr:`~meshterm.ui.tui.screen.Screen.fkey_lane` override reaches for +#: first — typically a Ctrl+letter chord promoted up because chording is a pain here. DEFAULT_LANE: tuple[Optional[FPair], ...] = ( - FPair("Top", "home", "PgUp", "pageup"), - FPair("End", "end", "PgDn", "pagedown"), + FPair("Top", "home"), + FPair("End", "end"), None, - FPair("OK", "enter"), - FPair("Back", "escape"), + FPair("PgUp", "pageup"), + FPair("PgDn", "pagedown"), ) diff --git a/meshterm/ui/tui/screen.py b/meshterm/ui/tui/screen.py index 7d99df0..e4a9f03 100644 --- a/meshterm/ui/tui/screen.py +++ b/meshterm/ui/tui/screen.py @@ -63,11 +63,13 @@ class Screen: def fkey_lane(self): """The screen's F-key lane (the PicoCalc footer; see :mod:`~meshterm.ui.tui.fkeys`). - Five slots, F1–F5, each with an optional F6–F10 Shift-bank companion. The - default puts commit/leave on the prime F4/F5 pair (no Shift needed), the nav - cluster's jump-to-top/end on F1/F2 with paging as their Shift companions, and - leaves F3 as the one lone slot — the first a screen with its own verbs reaches - for. A screen with richer needs overrides this property. + Five slots, F1–F5, each with an optional F6–F10 Shift-bank companion. A slot is + for functionality that is otherwise hard to reach — Enter/Esc never appear, since + both keys are already close at hand. The default puts paging (no physical key at + all) on the prime F4/F5 pair, the nav cluster's jump-to-top/end (Fn-layered) on + F1/F2, and leaves F3 as the one lone slot — the first a screen reaches for to + promote its own otherwise-fiddly shortcut (a Ctrl+letter chord, say). A screen + overrides this property for its own verbs; the lane may differ screen to screen. """ from .fkeys import DEFAULT_LANE diff --git a/tests/test_picocalc_chrome.py b/tests/test_picocalc_chrome.py index f44c149..488c622 100644 --- a/tests/test_picocalc_chrome.py +++ b/tests/test_picocalc_chrome.py @@ -70,24 +70,28 @@ def test_picocalc_header_brands_the_app_not_the_device() -> None: def test_fkey_lane_resolution_and_banks() -> None: lane = DEFAULT_LANE - # F4/F5 (commit/leave) are plain-key only — no Shift companion. - assert action_for(lane, 4) == "enter" and action_for(lane, 9) is None - assert action_for(lane, 5) == "escape" and action_for(lane, 10) is None - # F1/F2 carry the jump-to-top/end pair; paging rides their Shift bank. - assert action_for(lane, 1) == "home" and action_for(lane, 6) == "pageup" - assert action_for(lane, 2) == "end" and action_for(lane, 7) == "pagedown" + # F4/F5 (paging — no physical key at all) are plain-key only, no Shift companion. + assert action_for(lane, 4) == "pageup" and action_for(lane, 9) is None + assert action_for(lane, 5) == "pagedown" and action_for(lane, 10) is None + # F1/F2 carry the Fn-layered jump-to-top/end pair, also with no Shift companion. + assert action_for(lane, 1) == "home" and action_for(lane, 6) is None + assert action_for(lane, 2) == "end" and action_for(lane, 7) is None # F3 is the lone, unassigned slot a screen's own lane fills in. assert action_for(lane, 3) is None and action_for(lane, 8) is None + # Enter/Esc never occupy a slot — both keys are already close at hand. + assert "enter" not in {action_for(lane, n) for n in range(1, 11)} + assert "escape" not in {action_for(lane, n) for n in range(1, 11)} def test_fkey_lane_text_fits_and_flips() -> None: primary = lane_text(DEFAULT_LANE) shifted = lane_text(DEFAULT_LANE, shifted=True) assert cell_len(primary.plain) == 53 and cell_len(shifted.plain) == 53 - assert "F1 Top" in primary.plain and "F4 OK" in primary.plain and "F5 Back" in primary.plain - assert "F6 PgUp" in shifted.plain and "F7 PgDn" in shifted.plain - # F4/F5 have no Shift companion: their shifted chips (F9/F10) render unfilled. - assert "F9" in shifted.plain and "10" in shifted.plain + assert "F1 Top" in primary.plain and "F4 PgUp" in primary.plain and "F5 PgDn" in primary.plain + # No slot has a Shift companion by default: the whole shifted bank renders unfilled. + for number in (6, 7, 8, 9): + assert f"F{number}" in shifted.plain + assert "10" in shifted.plain wide = [FPair("Muchtoolonglabel", "a", "Muchtoolonglabel", "b")] * 5 assert cell_len(lane_text(wide).plain) == 53 # clipped to the slot budget assert cell_len(lane_text(wide, shifted=True).plain) == 53