PicoCalc: a command row's icon lane is the first thing to go
Every icon on the console is a one-glyph stand-in for an emoji, and the menu is where that pinches hardest: the main menu drew @ for both Map and Mesh walk, … for both Live feed and Time machine, and ?? for Trace path, in a lane costing three of fifty-three columns on every row (JP, on-device). So drop the lane there, mark and emoji alike. A command row's icon is decoration — it names the action's family while the label names the action — so where it can only be approximated it is worth less than the cells it takes, and the label and its description get them back. This is a platform choice (Platform.menu_icons), not a per-emoji one: a glyph that carries *data* is not an icon in this sense and never goes, which is why the Channels page keeps its #/🌐/🔒 openness mark, the feed keeps the class icon it shows in place of the class word at 53 columns, and node types, status marks and the mute mark in the channel lane all stay put. Three funnels do the work, so a screen never asks the platform itself: command_label for a label carrying its own icon, command_icon for a row that builds its own lane, and marked_label where the icon carried a tint — a delete row's red moves onto its words rather than leaving with the 🗑. Section headings go through the same cut (a stand-in beside the ── rule is pure noise), which also retires the ?? that No revisits was drawing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
f46476bb84
commit
3376a18271
12 files changed
+192
-52
No files matched your search
@@ -43,6 +43,17 @@ class Platform:
|
||||
frame_border: Whether the base screen draws inside a bordered ``Panel``. ``False``
|
||||
swaps it for a title-bar row instead (+4 cols, +1 row reclaimed) — a PicoCalc
|
||||
chrome saving, wired in P4.
|
||||
menu_icons: Whether a *command row* leads with a decorative icon — the main menu's
|
||||
per-tool mark, an action list's ``🗑``/``🕒``, a body action's ``✎``. The label
|
||||
already names the action, so the icon is a family cue, not information; where
|
||||
the console can only spell it as a one-glyph stand-in the cue is worth less
|
||||
than the cells it costs and reads as noise besides (``@`` for both Map and
|
||||
Mesh walk, ``…`` for both Live feed and Time machine — JP, on-device,
|
||||
2026-08-11). ``False`` drops the whole lane, mark and emoji alike, and the
|
||||
cells go to the label and its description. This is about *decoration* only:
|
||||
a glyph that carries data — a channel's openness, a packet's class, a node's
|
||||
type, a status mark on an outcome — is not a menu icon and is never dropped
|
||||
(see :func:`~meshterm.ui.menus.command_label`).
|
||||
dialog_margin: Total columns a floating dialog leaves to the backdrop it sits over
|
||||
— half of it on each side (see
|
||||
:func:`~meshterm.ui.tui.frame._dialog_layout`). The gutter is what makes a
|
||||
@@ -106,6 +117,7 @@ class Platform:
|
||||
readable_cols: int
|
||||
readable_rows: int
|
||||
frame_border: bool
|
||||
menu_icons: bool
|
||||
dialog_margin: int
|
||||
header_atoms: tuple[str, ...]
|
||||
footer_fkeys: bool
|
||||
@@ -126,6 +138,7 @@ REGULAR = Platform(
|
||||
readable_cols=72,
|
||||
readable_rows=24,
|
||||
frame_border=True,
|
||||
menu_icons=True,
|
||||
dialog_margin=6,
|
||||
header_atoms=("version", "device", "badges", "pulse", "battery"),
|
||||
footer_fkeys=False,
|
||||
@@ -149,6 +162,7 @@ PICOCALC = Platform(
|
||||
readable_cols=53,
|
||||
readable_rows=26,
|
||||
frame_border=False,
|
||||
menu_icons=False,
|
||||
dialog_margin=4,
|
||||
# JP's call (2026-08-01, post-P7 review): the handheld's header brands the app —
|
||||
# "MeshTerm vX" — rather than naming the device/port (on a soldered radio the port
|
||||
|
||||
@@ -63,7 +63,7 @@ from ..core.connection import Device
|
||||
from ..core.models import Conversation
|
||||
from ..persistence.repository import ACTIVITY_DRAWN_BUCKETS
|
||||
from .braillechart import activity_peak, activity_sparkline
|
||||
from .menus import back_rows, fit_cells, menu_rows, section_heading
|
||||
from .menus import back_rows, command_label, fit_cells, menu_rows, section_heading
|
||||
from .qr import share_popup
|
||||
from .tui import CANCEL, Choice, SelectScreen, Separator
|
||||
from .widgets import _age_seconds, _format_age, channel_glyph, format_ago
|
||||
@@ -595,8 +595,9 @@ def _menu_items(
|
||||
items.append(section_heading("Organize"))
|
||||
# Two spaces after the arrow: ↕ (East-Asian-ambiguous width) renders one cell where
|
||||
# the sibling rows' glyphs (+ # 🔑 🔗) render two, so the extra space keeps this
|
||||
# label's text column-aligned with theirs.
|
||||
items.append(Choice(title="↕ Reorder channels", value=_REORDER))
|
||||
# label's text column-aligned with theirs. Both go together where the platform
|
||||
# draws no icon lane at all.
|
||||
items.append(Choice(title=command_label("↕ Reorder channels"), value=_REORDER))
|
||||
|
||||
items.append(section_heading("Add a channel"))
|
||||
rows = []
|
||||
|
||||
@@ -28,7 +28,7 @@ from typing import TYPE_CHECKING
|
||||
from rich.text import Text
|
||||
|
||||
from .contactlist import ContactListScreen, ContactRow
|
||||
from .menus import back_rows, menu_rows
|
||||
from .menus import back_rows, marked_label, menu_rows
|
||||
from .tui import Choice, Separator
|
||||
from .tui.screen import CANCEL
|
||||
from .widgets import ContactsSort, _age_seconds, _contact_pkts
|
||||
@@ -146,7 +146,7 @@ class ContactsScreen(ContactListScreen):
|
||||
tail = [
|
||||
Separator(" "),
|
||||
Choice(
|
||||
title=Text.assemble(("🗑 ", "err"), "Purge stale contacts…"),
|
||||
title=marked_label("🗑", "Purge stale contacts…", "err"),
|
||||
value=_PURGE,
|
||||
),
|
||||
*back_rows(_BACK),
|
||||
|
||||
@@ -29,7 +29,7 @@ from rich.text import Text
|
||||
|
||||
from ..core.courier_store import DELIVERED, QUEUED, QueuedMessage
|
||||
from ..core.models import Contact, is_direct_messageable, utcnow
|
||||
from .menus import back_rows, section_heading
|
||||
from .menus import back_rows, command_label, marked_label, section_heading
|
||||
from .contactlist import SORT_COLUMNS, SORT_OPENS_ASCENDING, ContactListScreen, ContactRow
|
||||
from .theme import glyph
|
||||
from .tui import CANCEL, DM_BYTE_LIMIT, Choice, SelectScreen, Separator
|
||||
@@ -472,8 +472,8 @@ async def _entry_actions(ctx: "AppContext", ident: int) -> None:
|
||||
await session.message_dialog(body, title=message.node_name)
|
||||
return
|
||||
items = [
|
||||
Choice("📤 Send now — one forced attempt", "send"),
|
||||
Choice(Text.assemble(("✗ ", "err"), "Cancel this message"), "cancel"),
|
||||
Choice(command_label("📤 Send now — one forced attempt"), "send"),
|
||||
Choice(marked_label("✗", "Cancel this message", "err"), "cancel"),
|
||||
]
|
||||
picked = await session.select(
|
||||
f"{message.node_name} — “{_shorten(message.text, 28)}”",
|
||||
|
||||
+4
-3
@@ -29,7 +29,7 @@ from ..platforms import get_platform
|
||||
from ..tools import all_tools
|
||||
from .surface import TuiUi
|
||||
from .braillechart import activity_peak, activity_sparkline
|
||||
from .menus import SEP_COMPACT, SEP_ROOMY, section_heading
|
||||
from .menus import SEP_COMPACT, SEP_ROOMY, command_icon, command_label, section_heading
|
||||
from .theme import make_console
|
||||
from .widgets import battery_cell
|
||||
from .tui import (
|
||||
@@ -464,7 +464,8 @@ async def _menu_loop(ctx: AppContext, session: TuiSession) -> None:
|
||||
|
||||
def _label(tool) -> str: # noqa: ANN001 - registry Tool; typed at the source
|
||||
title = tool.title or tool.name
|
||||
return f"{tool.icon} {title}" if tool.icon else title
|
||||
icon = command_icon(tool.icon)
|
||||
return f"{icon} {title}" if icon else title
|
||||
|
||||
name_w = max((cell_len(_label(tool)) for tool in tools), default=0)
|
||||
items: list = []
|
||||
@@ -479,7 +480,7 @@ async def _menu_loop(ctx: AppContext, session: TuiSession) -> None:
|
||||
row.append(tool.help, style="muted")
|
||||
items.append(Choice(title=row, value=tool.name))
|
||||
items.append(Separator(" "))
|
||||
items.append(Choice(title="🚪 Quit", value="__quit__"))
|
||||
items.append(Choice(title=command_label("🚪 Quit"), value="__quit__"))
|
||||
|
||||
# Drive the menu list ourselves (rather than via session.select) so it stays on the
|
||||
# stack while the quit dialog floats over it: the confirm is drawn as a centered box
|
||||
|
||||
+93
-3
@@ -34,11 +34,17 @@ from typing import TYPE_CHECKING, Any, Iterable, Sequence, Union
|
||||
from rich.cells import cell_len
|
||||
from rich.text import Text
|
||||
|
||||
from ..platforms import get_platform
|
||||
from .theme import glyph
|
||||
from .tui import Choice, Separator
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..context import AppContext
|
||||
|
||||
#: What a command row's label may be: plain text, or styled text whose spans survive the
|
||||
#: icon cut (an err-tinted destructive row, a live unread badge).
|
||||
LabelT = Union[str, Text]
|
||||
|
||||
|
||||
#: The app's status-atom separator, in its two widths. ``·`` chains atoms (the standards'
|
||||
#: rule — ``Map · z12 · 34 nodes``); the roomy form is the default, and a surface running
|
||||
@@ -50,6 +56,79 @@ SEP_ROOMY = " · "
|
||||
SEP_COMPACT = " · "
|
||||
|
||||
|
||||
def command_icon(icon: str) -> str:
|
||||
"""The glyph a command row leads with — empty where the platform drops the icon lane.
|
||||
|
||||
The compose-time half of :data:`~meshterm.platforms.Platform.menu_icons`, for a row
|
||||
that builds its own icon lane (a screen's body actions) rather than carrying the icon
|
||||
inside a label string — :func:`command_label` is that case. Returning ``""`` rather
|
||||
than a stand-in is the point: the caller measures what comes back, so an emptied lane
|
||||
costs no cells at all, and the padding it would have taken goes to the label.
|
||||
|
||||
Args:
|
||||
icon: The row's icon, as written on the regular platform.
|
||||
|
||||
Returns:
|
||||
:func:`~meshterm.ui.theme.glyph`'s rendering of it, or ``""``.
|
||||
"""
|
||||
return glyph(icon) if get_platform().menu_icons else ""
|
||||
|
||||
|
||||
def marked_label(icon: str, label: str, style: str) -> Text:
|
||||
"""A command row whose icon carries a tint — the tint moving to the label if it goes.
|
||||
|
||||
The app marks a destructive command by tinting its icon, not its words (``🗑`` in
|
||||
``err`` before a plain "Delete all records…"). Drop the icon on a platform without an
|
||||
icon lane and the tint would go with it, leaving a delete row looking like any other,
|
||||
so it lands on the label instead — the presentation the config editor's *Factory
|
||||
reset* has always used.
|
||||
|
||||
Args:
|
||||
icon: The row's icon, as written on the regular platform.
|
||||
label: The row's words, with no icon and no leading space.
|
||||
style: The theme style the mark (or, iconless, the label) is drawn in.
|
||||
|
||||
Returns:
|
||||
The composed row label.
|
||||
"""
|
||||
mark = command_icon(icon)
|
||||
return Text.assemble((f"{mark} ", style), label) if mark else Text(label, style=style)
|
||||
|
||||
|
||||
def command_label(label: LabelT) -> LabelT:
|
||||
"""``label`` with its leading icon dropped where the platform drops the icon lane.
|
||||
|
||||
A command row's icon is *decoration*: it names the action's family while the label
|
||||
names the action, so it is the first thing to go when cells are scarce (see
|
||||
:data:`~meshterm.platforms.Platform.menu_icons`). The icon is taken to be everything
|
||||
before the label's first space, and only when that head starts with a non-alphanumeric
|
||||
character — so ``"🗑 Clear this slot…"`` and ``"↻ Read settings"`` both lose their
|
||||
head while ``"Back"`` and ``"Trace target"`` pass through untouched.
|
||||
|
||||
What must *not* come through here: a glyph carrying data (a channel's openness, a
|
||||
packet's class, a node's type) or a status mark on an outcome or commit row
|
||||
(``✓ Apply…``, ``✗ Back — discard…``, built by :func:`exit_rows`). Those say something
|
||||
the label doesn't, on every platform.
|
||||
|
||||
Args:
|
||||
label: The row's full label, icon included — a plain string or a styled
|
||||
:class:`~rich.text.Text` (whose spans survive the cut).
|
||||
|
||||
Returns:
|
||||
The label, iconless or unchanged. The type is the one that went in.
|
||||
"""
|
||||
if get_platform().menu_icons:
|
||||
return label
|
||||
plain = label.plain if isinstance(label, Text) else label
|
||||
head, sep, rest = plain.partition(" ")
|
||||
if not sep or not head or head[0].isalnum() or not rest.strip():
|
||||
return label
|
||||
# Take the gap with the icon: a row that padded a one-cell mark out to the width of
|
||||
# its two-cell siblings ("↕ Reorder channels") must not leave the padding behind.
|
||||
cut = len(plain) - len(rest.lstrip(" "))
|
||||
return label[cut:]
|
||||
|
||||
|
||||
def back_rows(value: Any = None) -> list:
|
||||
"""The standard exit group closing a select list: a blank line, then ``Back``.
|
||||
|
||||
@@ -102,6 +181,10 @@ def menu_rows(rows: Iterable[tuple[Union[str, Text], str, Any]]) -> list:
|
||||
description column starting two cells past the widest label, padding computed in
|
||||
display cells so a double-width emoji can't skew it.
|
||||
|
||||
Each label passes through :func:`command_label` first, so a platform that draws no
|
||||
icon lane loses it *before* the lane is measured — the description column moves left
|
||||
with the labels rather than going ragged behind them.
|
||||
|
||||
Args:
|
||||
rows: ``(label, description, value)`` triples. A :class:`Text` label keeps its
|
||||
own styling (an err-tinted destructive row, a live unread badge).
|
||||
@@ -110,8 +193,10 @@ def menu_rows(rows: Iterable[tuple[Union[str, Text], str, Any]]) -> list:
|
||||
One :class:`Choice` per row, lanes aligned across them all.
|
||||
"""
|
||||
prepared = [
|
||||
(label if isinstance(label, Text) else Text(label), help_text, value)
|
||||
for label, help_text, value in rows
|
||||
(Text(label) if isinstance(label, str) else label.copy(), help_text, value)
|
||||
for label, help_text, value in (
|
||||
(command_label(label), help_text, value) for label, help_text, value in rows
|
||||
)
|
||||
]
|
||||
width = max((cell_len(label.plain) for label, _, _ in prepared), default=0)
|
||||
items: list = []
|
||||
@@ -267,8 +352,13 @@ def section_heading(label: str) -> Separator:
|
||||
:attr:`~meshterm.ui.tui.select.Separator.heading`, so it re-pins to the top row once its
|
||||
section scrolls under it and the Ctrl+PageUp/PageDown jumps step by it. Building the row
|
||||
by hand is how a section loses that — go through here.
|
||||
|
||||
A heading that leads with an icon (``📡 Channels``, a trophy discipline's mark) loses it
|
||||
on a platform that draws no icon lane, exactly as a command row does — a heading is the
|
||||
same kind of label, and a stand-in glyph beside the rule already drawing ``──`` reads as
|
||||
noise (see :func:`command_label`).
|
||||
"""
|
||||
return Separator(f"── {label} ──", style="accent", heading=True)
|
||||
return Separator(f"── {command_label(label)} ──", style="accent", heading=True)
|
||||
|
||||
|
||||
def fit_cells(text: str, width: int, *, align: str = "left") -> str:
|
||||
|
||||
@@ -81,6 +81,7 @@ from ..core.geo import EARTH_RADIUS_KM, usable_fix
|
||||
from ..core.models import NODE_TYPE_LABELS, Contact, utcnow
|
||||
from ..platforms import Platform, on_platform
|
||||
from .mapcanvas import RGB
|
||||
from .menus import command_icon
|
||||
from .minimap import MiniMap
|
||||
from .pathgraph import (
|
||||
DST_NODE,
|
||||
@@ -1043,8 +1044,11 @@ class NodeDetailScreen(Screen):
|
||||
def _action_line(self, action: _Action, selected: bool, width: int) -> str:
|
||||
"""One action row: ``❯`` + icon + label, the whole row brand when it is the cursor's."""
|
||||
text = Text("❯ " if selected else " ", style="brand" if selected else "")
|
||||
if action.glyph:
|
||||
text.append(f"{action.glyph} ", style=action.glyph_style)
|
||||
# The icon lane is decoration a platform may drop whole (command_icon); the label
|
||||
# is what names the action, so an emptied lane simply gives it the cells.
|
||||
mark = command_icon(action.glyph) if action.glyph else ""
|
||||
if mark:
|
||||
text.append(f"{mark} ", style=action.glyph_style)
|
||||
text.append(action.label)
|
||||
if selected:
|
||||
text.style = "brand"
|
||||
|
||||
@@ -47,7 +47,7 @@ from ..persistence.repository import DiscoveredPath
|
||||
from ..services import trace_runner
|
||||
from ..services.records import CATEGORIES, CATEGORY_BY_ID, Category, _local_xy
|
||||
from .mapcanvas import RGB, MapCanvas
|
||||
from .menus import back_rows, fit_cells, section_heading
|
||||
from .menus import back_rows, command_icon, fit_cells, marked_label, section_heading
|
||||
from .pathgraph import PathLayer, render_path_graph
|
||||
from .pathline import path_line
|
||||
from .theme import name_style, snr_style
|
||||
@@ -473,11 +473,11 @@ class RecordDialog(Screen):
|
||||
selected = i == self._index
|
||||
row = Text("❯ " if selected else " ", style="brand" if selected else "")
|
||||
if key == "trace":
|
||||
row.append("👣 ", style="accent")
|
||||
row.append("Trace this path — reopen in Trace path")
|
||||
row.append_text(marked_label(
|
||||
"👣", "Trace this path — reopen in Trace path", "accent"
|
||||
))
|
||||
elif key == "delete":
|
||||
row.append("🗑 ", style="err")
|
||||
row.append("Delete record…")
|
||||
row.append_text(marked_label("🗑", "Delete record…", "err"))
|
||||
else:
|
||||
row.append("Back")
|
||||
if selected:
|
||||
@@ -840,11 +840,11 @@ async def open_records(ctx: "AppContext") -> dict:
|
||||
items.append(Separator(" "))
|
||||
if total:
|
||||
items.append(Choice(
|
||||
title=Text.assemble(("🗑 ", "err"), "Delete a discipline's records…"),
|
||||
title=marked_label("🗑", "Delete a discipline's records…", "err"),
|
||||
value=("del_cat", None, 0, None),
|
||||
))
|
||||
items.append(Choice(
|
||||
title=Text.assemble(("🗑 ", "err"), "Delete all records…"),
|
||||
title=marked_label("🗑", "Delete all records…", "err"),
|
||||
value=("del_all", None, 0, None),
|
||||
))
|
||||
items.extend(back_rows(("back", None, 0, None)))
|
||||
|
||||
@@ -41,7 +41,7 @@ from .braillechart import (
|
||||
chart_span,
|
||||
timeline_rows,
|
||||
)
|
||||
from .menus import fit_cells, section_heading
|
||||
from .menus import command_label, fit_cells, section_heading
|
||||
from .contactlist import SORT_COLUMNS, SORT_OPENS_ASCENDING, ContactListScreen, ContactRow
|
||||
from .theme import name_style, snr_style
|
||||
from .tui.render import render_lines
|
||||
@@ -1272,7 +1272,7 @@ class TimeMachinePickerScreen(ContactListScreen):
|
||||
sort=sort,
|
||||
prompt=prompt,
|
||||
lead=[
|
||||
Choice("🌐 The whole mesh — days, arrivals, the ledger", MESH),
|
||||
Choice(command_label("🌐 The whole mesh — days, arrivals, the ledger"), MESH),
|
||||
Separator(" "),
|
||||
section_heading("Nodes"),
|
||||
],
|
||||
|
||||
+15
-13
@@ -96,8 +96,8 @@ from ..services import trace_runner
|
||||
from ..services.records import first_repeated_edge
|
||||
from ..services.topology import render_forced_spec
|
||||
from .braillechart import meter
|
||||
from .menus import back_rows, section_heading
|
||||
from .theme import glyph, snr_style
|
||||
from .menus import back_rows, command_icon, marked_label, section_heading
|
||||
from .theme import snr_style
|
||||
from .tui.render import render_lines, render_to_ansi
|
||||
from .tui.screen import ListWindow, Screen
|
||||
from .tui.spinner import Spinner, spinner_interval
|
||||
@@ -159,24 +159,26 @@ _ACTION_ICONS = ("✎", "⇄", "⚡", "⚙", "#", "▶")
|
||||
def _icon_lane() -> int:
|
||||
"""The action rows' icon column, in cells: the widest mark on this platform.
|
||||
|
||||
Measured rather than hard-coded because the marks themselves change width with
|
||||
the platform: on PicoCalc every icon funnels through :func:`~meshterm.ui.theme.glyph`
|
||||
to a single console-font character (``⚡`` → ``!``), so the column tightens to one
|
||||
cell and the labels move left with it — the same alignment rule at the console's
|
||||
own resolution.
|
||||
Measured rather than hard-coded because the marks themselves change with the
|
||||
platform: PicoCalc draws no icon lane on a command row at all
|
||||
(:func:`~meshterm.ui.menus.command_icon`), so the column measures zero and the labels
|
||||
take the cells — the same alignment rule wherever the icons land.
|
||||
"""
|
||||
return max(cell_len(glyph(icon)) for icon in _ACTION_ICONS)
|
||||
return max(cell_len(command_icon(icon)) for icon in _ACTION_ICONS)
|
||||
|
||||
|
||||
def _icon(text: Text, icon: str, style: str) -> None:
|
||||
"""Append an action row's mark in the icon column, its trailing space included.
|
||||
|
||||
A one-cell mark pads out to :func:`_icon_lane` so every label — narrow mark or
|
||||
wide emoji — starts in the same column.
|
||||
A one-cell mark pads out to :func:`_icon_lane` so every label starts in the same
|
||||
column; an emptied lane (see there) appends nothing, separator included.
|
||||
"""
|
||||
mark = glyph(icon)
|
||||
lane = _icon_lane()
|
||||
if not lane:
|
||||
return
|
||||
mark = command_icon(icon)
|
||||
text.append(mark, style=style)
|
||||
text.append(" " * (_icon_lane() - cell_len(mark) + 1))
|
||||
text.append(" " * (lane - cell_len(mark) + 1))
|
||||
|
||||
|
||||
def _lane_lines(label: str, value: list[Text], width: int) -> list[str]:
|
||||
@@ -1984,7 +1986,7 @@ async def _open_session(
|
||||
items.append(Separator(" "))
|
||||
items.append(
|
||||
Choice(
|
||||
title=Text.assemble(("⚡ ", "warn"), "Probe all — trace each path once and rank"),
|
||||
title=marked_label("⚡", "Probe all — trace each path once and rank", "warn"),
|
||||
value=("probe", None),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -33,6 +33,7 @@ import asyncio
|
||||
import re
|
||||
from typing import TYPE_CHECKING, Any, Callable, Optional
|
||||
|
||||
from rich.cells import cell_len
|
||||
from rich.console import Group, RenderableType
|
||||
from rich.table import Table
|
||||
from rich.text import Text
|
||||
@@ -41,6 +42,7 @@ from ..core.connection import REMOTE_TX_MAX, REMOTE_TX_MIN
|
||||
from ..core.models import Contact, TraceResult, TxLevelResult, TxOptResult
|
||||
from ..services import trace_runner, tx_optimizer
|
||||
from ..services.topology import build_topology, render_custom_spec
|
||||
from .menus import command_icon
|
||||
from .pathline import SELF_GLYPH, PathHop, PathLine, cut_to, path_line
|
||||
from .theme import name_style, snr_style
|
||||
from .trace_screen import TracingDialog, _collapse_trace_width, snr_bar
|
||||
@@ -67,6 +69,27 @@ STEP_CHOICES = (1, 2, 3, 4, 5)
|
||||
SAMPLE_CHOICES = (1, 2, 3, 5, 8)
|
||||
|
||||
|
||||
#: Every mark the sweep's action rows lead with. The list exists to *measure* the icon
|
||||
#: column so each label starts in the same place, and so a platform that draws no icon
|
||||
#: lane at all (see :func:`~meshterm.ui.menus.command_icon`) collapses it to nothing.
|
||||
_ACTION_ICONS = ("✎", "⚙", "#", "▶", "★")
|
||||
|
||||
|
||||
def _icon_lane() -> int:
|
||||
"""The action rows' icon column, in cells: the widest mark on this platform."""
|
||||
return max(cell_len(command_icon(icon)) for icon in _ACTION_ICONS)
|
||||
|
||||
|
||||
def _icon(text: Text, icon: str, style: str) -> None:
|
||||
"""Append an action row's mark in the icon column, its trailing space included."""
|
||||
lane = _icon_lane()
|
||||
if not lane:
|
||||
return
|
||||
mark = command_icon(icon)
|
||||
text.append(mark, style=style)
|
||||
text.append(" " * (lane - cell_len(mark) + 1))
|
||||
|
||||
|
||||
class TxSweepScreen(Screen):
|
||||
"""A full-screen TX-power sweep session — armed, but idle until told.
|
||||
|
||||
@@ -379,29 +402,29 @@ class TxSweepScreen(Screen):
|
||||
"""One action row: pointer, glyph, and label (current value inlined)."""
|
||||
text = Text("❯ " if selected else " ", style="brand" if selected else "")
|
||||
if key == "route":
|
||||
text.append("✎ ", style="brand")
|
||||
_icon(text, "✎", "brand")
|
||||
if self.route_hops:
|
||||
text.append("Route — via ")
|
||||
text.append_text(path_line(list(self.route_hops), self._resolve).text())
|
||||
else:
|
||||
text.append(f"Route — direct to {self._admin_label}")
|
||||
elif key == "range":
|
||||
text.append("⚙ ", style="accent")
|
||||
_icon(text, "⚙", "accent")
|
||||
text.append(f"Range — TX {self.tx_min}–{self.tx_max}")
|
||||
elif key == "step":
|
||||
text.append("⚙ ", style="accent")
|
||||
_icon(text, "⚙", "accent")
|
||||
text.append(f"Step — every {_nth(self.step)} level, then refine"
|
||||
if self.step > 1 else "Step — every level (no refine needed)")
|
||||
elif key == "samples":
|
||||
text.append("# ", style="accent")
|
||||
_icon(text, "#", "accent")
|
||||
text.append(
|
||||
f"Samples — {self.samples} trace{'s' if self.samples != 1 else ''} per level"
|
||||
)
|
||||
elif key == "sweep":
|
||||
text.append("▶ ", style="ok")
|
||||
_icon(text, "▶", "ok")
|
||||
text.append(f"Sweep — up to {self.estimated_traces()} paced transmissions")
|
||||
elif key == "apply":
|
||||
text.append("★ ", style="ok")
|
||||
_icon(text, "★", "ok")
|
||||
best = self._result.best_tx if self._result is not None else "?"
|
||||
text.append(f"Apply winner — set TX {best} on {self._admin_label}")
|
||||
else:
|
||||
|
||||
@@ -23,7 +23,7 @@ from rich.text import Text
|
||||
from ..core.models import Contact
|
||||
from ..core.watch_store import OFF, SILENCE_CHOICES_H, Alert, WatchedNode
|
||||
from ..services.trace_runner import make_name_key_resolver
|
||||
from .menus import back_rows, section_heading
|
||||
from .menus import back_rows, command_label, marked_label, section_heading
|
||||
from .theme import name_style
|
||||
from .tui import Choice, Separator
|
||||
from .widgets import _DEFAULT_GLYPH, _NODE_GLYPHS, _age_seconds, _format_age
|
||||
@@ -198,9 +198,9 @@ def _menu_items(
|
||||
unacked = sum(1 for a in alerts if not a.acked)
|
||||
acked = len(alerts) - unacked
|
||||
if unacked:
|
||||
items.append(Choice(f"✓ Acknowledge all ({unacked})", _ACK_ALL))
|
||||
items.append(Choice(marked_label("✓", f"Acknowledge all ({unacked})", "ok"), _ACK_ALL))
|
||||
if acked:
|
||||
items.append(Choice("🗑 Clear acknowledged", _CLEAR))
|
||||
items.append(Choice(marked_label("🗑", "Clear acknowledged", "err"), _CLEAR))
|
||||
|
||||
items.append(Separator(" "))
|
||||
items.append(section_heading("Watched nodes"))
|
||||
@@ -208,13 +208,16 @@ def _menu_items(
|
||||
items.append(Separator(" none starred yet — silence and SNR rules need one"))
|
||||
for key in sorted(watched, key=lambda k: watched[k].name.casefold()):
|
||||
items.append(Choice(_watched_row(watched[key], type_of), ("node", key)))
|
||||
items.append(Choice("⭐ Watch a node…", _WATCH))
|
||||
items.append(Choice(command_label("⭐ Watch a node…"), _WATCH))
|
||||
|
||||
items.append(Separator(" "))
|
||||
state = "[ok]on[/ok]" if new_node_alerts else "[muted]off[/muted]"
|
||||
items.append(
|
||||
Choice(
|
||||
Text.from_markup(f"🔔 New-node alerts: {state} [muted]— announce first-ever appearances[/muted]"),
|
||||
command_label(Text.from_markup(
|
||||
f"🔔 New-node alerts: {state}"
|
||||
" [muted]— announce first-ever appearances[/muted]"
|
||||
)),
|
||||
_TOGGLE_NEW,
|
||||
)
|
||||
)
|
||||
@@ -350,10 +353,12 @@ async def _node_rules(ctx: "AppContext", key: str) -> None:
|
||||
return
|
||||
silence = "off" if entry.silence_hours == OFF else f"after {entry.silence_hours} h"
|
||||
items = [
|
||||
Choice(f"🕒 Silence alarm {silence}", "silence"),
|
||||
Choice("📶 SNR watch " + ("on" if entry.snr_watch else "off"), "snr"),
|
||||
Choice(command_label(f"🕒 Silence alarm {silence}"), "silence"),
|
||||
Choice(command_label(
|
||||
"📶 SNR watch " + ("on" if entry.snr_watch else "off")
|
||||
), "snr"),
|
||||
Separator(" "),
|
||||
Choice(Text.assemble(("✗ ", "err"), "Stop watching this node"), "unwatch"),
|
||||
Choice(marked_label("✗", "Stop watching this node", "err"), "unwatch"),
|
||||
*back_rows(),
|
||||
]
|
||||
picked = await session.select(
|
||||
|
||||
Reference in new issue
Block a user