Map: the console keymap turns Shift+arrows into other keys - rescue what arrives

Shift+Up/Down reach the app as PgUp/PgDn there; with Shift physically
held (the watcher knows) they fine-pan instead of zooming - no real
PgUp exists on that keyboard, so the code cannot mean anything else.
Shift+Left/Right the keymap eats outright; nothing arrives to rescue
until the console keymap maps them back to plain arrows.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Fable 5 committed 2026-08-09 00:10:53 -04:00
1 parent b83c9005c7
commit 9f6e1ac891
2 files changed
+42 -5

No files matched your search

+18 -5
View File
@@ -6,8 +6,11 @@ the UI never blocks on the network), and redraws via :func:`~meshterm.ui.map_ren
render_map`. Keys:
* the **arrow keys** pan; holding **Shift** pans by a single character cell for fine
positioning (on the PicoCalc too — the Shift watcher covers a console that strips the
modifier off an arrow),
positioning. On the PicoCalc the Shift watcher supplies the modifier the console
strips: its keymap turns Shift+↑/↓ into PgUp/PgDn (rescued back into fine pans here —
no physical PgUp exists there, so the code can't mean anything else) and eats
Shift+←/→ outright — those never reach the app at all until the console keymap maps
them back to plain arrows,
* ``PgUp`` / ``PgDn`` zoom in / out,
* ``Home`` recenters and refits to the dense core of the nodes — the *region* the mesh
covers, and the same default view the map opens on,
@@ -404,7 +407,7 @@ class MapScreen(Screen):
if vp is None:
return
if action in _PAN_DIRS:
# A shifted arrow the console reports as the bare arrow (the PicoCalc's VT
# A shifted arrow the console reports as the bare arrow (a keymap that
# strips the modifier) still fine-pans: the watcher knows whether Shift is
# physically held, and it stays False wherever it isn't watching — desktop
# terminals report shift_up/... themselves, on the branch below.
@@ -412,9 +415,19 @@ class MapScreen(Screen):
elif action.startswith("shift_") and action[len("shift_"):] in _PAN_DIRS:
self._pan(vp, action[len("shift_"):], fine=True)
elif action == "pageup":
self._viewport = vp.zoomed(1, max_zoom=self._max_tile_zoom + _OVERZOOM)
if modifier_watch.shift_down():
# The PicoCalc console's keymap translates Shift+↑ into PgUp (measured
# on-device, JP 2026-08-09: shifted vertical arrows were zooming). No
# physical PgUp exists on that keyboard — the pager rides the F-lane —
# so a raw PgUp with Shift held can only *be* a shifted arrow: fine-pan.
self._pan(vp, "up", fine=True)
else:
self._viewport = vp.zoomed(1, max_zoom=self._max_tile_zoom + _OVERZOOM)
elif action == "pagedown":
self._viewport = vp.zoomed(-1)
if modifier_watch.shift_down():
self._pan(vp, "down", fine=True) # Shift+↓ arrives as PgDn — see above
else:
self._viewport = vp.zoomed(-1)
elif action in ("home", "ctrl_home"):
self._reset_view(vp)
elif action == "locate":
+24
View File
@@ -1223,6 +1223,30 @@ def test_map_echoes_the_find_query_in_the_body_only_where_the_footer_is_gone() -
set_platform(REGULAR)
def test_map_shifted_vertical_arrows_survive_the_console_keymap(monkeypatch) -> None:
"""Shift+↑ arrives as PgUp on the PicoCalc console; with Shift physically down it
must fine-pan, not zoom — and plain PgUp (the F-lane's zoom) stays a zoom."""
from meshterm.services import modifier_watch
from meshterm.ui.map_render import MapMarker
from meshterm.ui.map_screen import MapScreen
screen = MapScreen(
_StubSession(80, 24), [MapMarker("A", 45.5, -73.6)], _StubSource(), 14
)
screen.render_body(80)
zoom = screen._viewport.zoom
lat = screen._viewport.center_lat
monkeypatch.setattr(modifier_watch, "_shift_down", True)
screen.handle("pageup") # the keymap's Shift+↑, rescued by the watcher
assert screen._viewport.zoom == zoom # no zoom happened
assert screen._viewport.center_lat > lat # …the view nudged north instead
monkeypatch.setattr(modifier_watch, "_shift_down", False)
screen.handle("pageup") # a real zoom press (the F5 chip's action)
assert screen._viewport.zoom == zoom + 1
def test_map_frame_chip_lights_only_with_matches_to_frame() -> None:
"""``Frame`` is the find's Enter under another name — dim, and inert, without a query."""
from meshterm.ui.map_render import MapMarker