Files
MeshTerm/meshterm/ui/marks.py
T
Jean-Pierre MartineauandClaude Opus 5 42937ce411 The pairing PIN waits to be asked for
Device info is the page you open to read your radio out to somebody, the one that
gets screenshotted into a forum thread and left up while a colleague leans over
your shoulder. Every value on it is yours to give away except one: the BLE
pairing PIN is what lets another phone onto the radio, and it was sitting in the
Identity section in plain digits alongside the node name and the coordinates.

It now draws as the field rather than the value — six mask bullets, the same
glyph a password prompt types in, promoted to marks.MASK_MARK so the two can
never drift apart. Six is the width of the *field* (the setting's own bound is
999999), not of what is in it: masking per character is right while someone is
typing and counting their own digits, and wrong for a stored secret, where it
would say how many to guess. A device that reports no PIN keeps its "?" — an
absence is not a secret, and a "?" behind bullets would promise something to
uncover.

`p` uncovers it, and `p` puts it back. A bare letter is a read-only page's idiom
for its own verb (the Time Machine's `w`) and this page has no find-as-you-type
to compete for it; the footer names what the press would do *now* — `p show PIN`,
then `p hide PIN` — and on the console the same toggle is F3, `Reveal` then
`Hide`, since the lane is the only place that platform can learn the key exists.
A device with no PIN advertises neither: the atom drops and the slot stays empty,
because the action isn't a thing on that page at all.

The page is therefore its own screen now (ui/device_info_screen.py) rather than a
generic result window, and ScrollScreen grows `replace_content` — replace_items
for a read-only body — so the toggle swaps the page under a reader who keeps
their scroll position; nothing reflows, six cells become six. The CLI has no key
to press, so `meshterm info` and `config show` print it masked and
`config get device_pin` is the way to name it deliberately: one rule, which is
that the whole-device dump never carries the PIN. The editor one menu over still
lists it plainly — you go there to change it, a row at a time, and its letters
already belong to find-as-you-type.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-05 15:13:45 -04:00

61 lines
2.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""The shared mark constants: node-type glyphs, their colours, and path sentinels.
The app's spatial surfaces — the map, the path graph, the braille rasters, the node
rows — all pin nodes with the same marks in the same hues, and several of them need the
constants *without* the machinery around them. Before this module, ``ui.widgets`` pulled
``map_render``, ``mapcanvas`` and ``pathgraph`` onto the boot path for a handful of
tuples and type aliases (~60 ms of import on the PicoCalc); now the constants live here,
dependency-free, and the heavy modules import *from* the constants instead of hosting
them. ``map_render``/``mapcanvas``/``pathgraph`` re-export their old names, so existing
importers of those modules are untouched.
"""
from __future__ import annotations
from typing import Callable, Optional
#: An ``(r, g, b)`` colour triple, 0–255 per channel (the raster/canvas colour type).
RGB = tuple[int, int, int]
def parse_hex(color: str) -> RGB:
"""Convert ``"#rrggbb"`` (or ``"rrggbb"``) to an ``(r, g, b)`` tuple."""
c = color.lstrip("#")
return (int(c[0:2], 16), int(c[2:4], 16), int(c[4:6], 16))
# Marker palette, shared across the whole app. The basemap is blue (water), green (parks)
# and warm amber (roads), so markers use the hues a map never contains — pink/violet — to
# stand out against it. Ordinary nodes are the loudest (bright pink); repeaters recede a
# step (a calmer violet); our own node stays the fixed yellow star; a node heard of but
# never identified is a light grey ring. Every glyph is in the PicoCalc console font.
#
# A mark's colour is whatever :func:`~meshterm.ui.theme.mark_rgb` takes — a literal hex, or
# a theme style name where the platform must pick the shade itself. The unknown ring is
# named (``node.unknown``) so the ring and the grey label beside it can never disagree.
SELF_MARK = ("★", "#facc15")
REPEATER_MARK = ("▲", "#a78bfa")
NODE_MARK = ("●", "#f472b6")
UNKNOWN_MARK = ("○", "node.unknown")
#: THE concealed character: one bullet stands in for one character of something the screen
#: is holding back — a password being typed (``ui/tui/prompt.py``), the BLE pairing PIN on
#: the Device info page. One glyph for the concept, so a row of them reads the same way
#: wherever it appears, and it is deliberately *not* the ``●`` of an unread message or a
#: node: those are marks that mean something, this one means "not shown".
MASK_MARK = "•"
#: Sentinels naming a path's endpoints on the route graph. ``\x00`` never appears in a
#: node hash, so they can share the node-id namespace without colliding with one.
SRC_NODE = "\x00src"
DST_NODE = "\x00dst"
#: Maps a node id to its graph marker: a ``(glyph, colour)`` pair.
GlyphOf = Callable[[str], tuple[str, str]]
#: A node's graph label, or ``None``/``""`` to leave the marker bare.
LabelOf = Callable[[str], Optional[str]]
#: The colour a node's label is drawn in (usually the node's name hue).
LabelRgbOf = Callable[[str], RGB]