Chips: one chevron, a gap for the elision, and a star that fits
Three cuts to what a chip line spends its cells on. The seam was two: the previous chip tapering onto the page, the next notching back out of its own fill, a sliver of bare page between. That gap was insurance against two neighbours landing on one colour and fusing into a single block — but the hue wheel is 256 distinct values wide (measured: zero collisions across all 256 first bytes), so it was insurance against something that does not happen. One interlocked chevron now, the chip behind as foreground and the chip ahead as background. Where two fills really are equal the interlock cannot draw a chevron at all, and that case is not bad luck: a mirrored return leg is a run of identically faded hops by construction, and so is a stretch of keyless greys. There the point drops its background and the page cuts the wedge — still one cell, the old separation without the old width. The elision was a chip: pads, a fill, and a seam on each side, seven cells to say "some hops are missing" on a line that is short of room by definition. It is not a node called ⋯. It now breaks the ribbon instead — the chip before closes onto the page, the mark sits there bare, the chip after opens on its notch. Three cells, and elision_hop() is the one definition the widget and the mesh walk's trail share. Arrow mode needed no change: a bare label between two arrows already was a gap. The you chip was ` ★ ` in dark ink on pure white — five cells shouting the one node the reader never has to be told. Now the map's own yellow star (taken from marks.SELF_MARK, so the star in a route and the star on the map cannot drift) on a neutral dark grey, and padless, because the pads exist to keep a *word* off the chevrons and a single mark centred in its cell needs no such room. Three cells. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
6a12104cf7
commit
1ba44ad252
4 files changed
+194
-91
No files matched your search
@@ -131,9 +131,14 @@ Relative ages: `format_ago` for prose ("now", "5m ago", "never" — never "now a
|
||||
from `⋯`, which marks whole hops *elided* out of the middle (`PathLine.ellipsized`).
|
||||
- Path endpoints: a path line runs between the nodes it actually went between — the true
|
||||
origin and destination, never the first and last *relay*. Our own end is always the
|
||||
app-wide `★` (`pathline.SELF_GLYPH`, or `path_line(bare_self=True)`), never our name:
|
||||
the one node the reader never has to be told, and the cells belong to the hops that
|
||||
differ from row to row.
|
||||
app-wide `★` (`pathline.SELF_GLYPH`, taken straight from `marks.SELF_MARK`), never our
|
||||
name: the one node the reader never has to be told, and the cells belong to the hops
|
||||
that differ from row to row. As a chip it is the map's yellow star on neutral dark
|
||||
grey, padless — three cells, not five.
|
||||
- Chip seams are **one** interlocked chevron (previous fill on next). Two chips of the
|
||||
same fill are the exception the interlock can't draw: the point drops its background so
|
||||
the page cuts the wedge. An elision breaks the ribbon rather than joining it — bare `⋯`
|
||||
on the page between a closing point and the next chip's notch, no fill, no padding.
|
||||
- Concept icons: 📡 advert · 🕒 clock/sync · 🔄 reboot · 💾 backup · 📂 restore ·
|
||||
🔑 channel/credential key · 🔐 identity/auth secret · 🗑 clear/delete · ✎ compose/edit ·
|
||||
⚙ parameter · `#` count · ▶ run · ⚡ explore/probe · ★ best/winner · ⭐ watch ·
|
||||
|
||||
+116
-55
@@ -8,14 +8,19 @@ caller), a :class:`PathLine` separates *what the hops are* from *how the line is
|
||||
drawn*, so every surface the survey found can eventually route through it:
|
||||
|
||||
* **Two separator styles.** ``plain`` joins hops with muted ``→`` arrows — today's
|
||||
look, unchanged. ``powerline`` renders each hop as a colour-filled chip, seams drawn
|
||||
as two solid triangles U+E0B0 — the previous chip tapering out to a point, the next
|
||||
one notched inward out of its own fill, a sliver of bare page between them: the gapped
|
||||
oh-my-posh look, where a route reads as a row of distinct blocks rather than one
|
||||
fused ribbon. The chip fill is the node's hash-derived hue
|
||||
(:func:`~meshterm.ui.theme.node_style`), our own node the pure ``you`` white, a
|
||||
faded hop dark slate, a keyless hop grey. A chip caught by a *cut* — a lane that ran
|
||||
out, a line scrolled past its edge — breaks off on a half block in its own fill
|
||||
look, unchanged. ``powerline`` renders each hop as a colour-filled chip, joined by one
|
||||
solid triangle U+E0B0 interlocked between them — the chip behind as its foreground, the
|
||||
chip ahead as its background — so a route reads as a ribbon whose segments meet on a
|
||||
chevron: the oh-my-posh look, at one cell a seam. The chip fill is the node's
|
||||
hash-derived hue (:func:`~meshterm.ui.theme.node_style`), our own node the map's yellow
|
||||
``★`` on a neutral dark grey, a faded hop dark slate, a keyless hop grey. Two chips that
|
||||
land on the *same* fill — a mirrored return leg, a stretch of keyless greys — take the
|
||||
one exception the interlock can't draw, dropping the background so the page cuts the
|
||||
wedge (:meth:`PathLine._seam`). Hops elided out of the middle break the ribbon instead
|
||||
of joining it: the mark sits bare on the page between a closing point and the next
|
||||
chip's notch (:func:`elision_hop`), because a filled ``⋯`` chip would read as a node by
|
||||
that name. A chip caught by a *cut* — a lane that ran out, a line scrolled past its
|
||||
edge — breaks off on a half block in its own fill
|
||||
(:func:`cut_mark`), and that crack is what says the segment continues; only chips
|
||||
crack, an arrow line still ellipsizes. ``auto`` (the default) picks powerline exactly
|
||||
when the terminal can draw it (:func:`~meshterm.ui.termfont.powerline_enabled` —
|
||||
@@ -69,6 +74,7 @@ from rich.measure import Measurement
|
||||
from rich.text import Text
|
||||
|
||||
from ..core.models import LOCAL_DEVICE_LABEL
|
||||
from .marks import SELF_MARK
|
||||
from .termfont import powerline_enabled, powerline_full
|
||||
from .theme import active_theme, node_style
|
||||
|
||||
@@ -87,8 +93,10 @@ POWERLINE_ROUND_OPEN = ""
|
||||
POWERLINE_ROUND_CLOSE = ""
|
||||
|
||||
#: Our own node, wherever a surface asks for it stripped of name and hash
|
||||
#: (``bare_self``): the app-wide ``★`` — the same mark the map plants on us.
|
||||
SELF_GLYPH = "★"
|
||||
#: (``bare_self``): the app-wide ``★`` — literally the map's own marker, taken from
|
||||
#: :data:`~meshterm.ui.marks.SELF_MARK` so the star in a route and the star on the map
|
||||
#: can never drift apart, in glyph or in hue.
|
||||
SELF_GLYPH, _SELF_INK = SELF_MARK
|
||||
|
||||
#: The composer's insertion cursor, standing in the route as a hop of its own: the
|
||||
#: empty slot the next chosen hop drops into. A ``+`` because that is exactly what
|
||||
@@ -106,8 +114,11 @@ _CHIP_FG_SOFT = "#334155"
|
||||
#: Chip fill for a keyless hop — the ``faint`` grey; colour stays reserved for
|
||||
#: keyed identities in chips just as it is in arrow mode.
|
||||
_KEYLESS_BG = "#64748b"
|
||||
#: Our own node's chip fill: the pure ``you`` white.
|
||||
_YOU_BG = "#ffffff"
|
||||
#: Our own node's chip fill: a neutral dark grey, so the yellow ``★`` riding it reads as
|
||||
#: the map's marker rather than as a node's hue (JP, 2026-08-09). Deliberately *not* a
|
||||
#: spectrum colour and not the white it used to be — our end of a route is a fixture the
|
||||
#: reader already knows, so it sits back and lets the hops that differ carry the colour.
|
||||
_YOU_BG = "#3f3f46"
|
||||
#: A dimmed hop's chip: dark slate fill with muted ink, receding like ``faint`` text.
|
||||
_DIM_BG = "#334155"
|
||||
_DIM_FG = "#94a3b8"
|
||||
@@ -156,7 +167,10 @@ class PathHop:
|
||||
key: Any known prefix of the node's key/hash — picks the hash-derived hue
|
||||
(its first byte, so every prefix agrees). ``None`` renders muted/grey:
|
||||
colour is reserved for keyed identities.
|
||||
you: Our own node — pure white, in either mode.
|
||||
you: Our own node. Arrows draw it in the pure-white ``you`` style; chips draw it
|
||||
in the map's own yellow on the neutral dark grey :data:`_YOU_BG` — and where
|
||||
the label is the bare :data:`SELF_GLYPH`, without the padding a word would
|
||||
need, so our end of a route costs three cells rather than five.
|
||||
annotation: The trace-flavour hash note, rendered ``" (3d)"`` after the
|
||||
label in both modes (pass the bare ``3d``, no parentheses).
|
||||
lit_bytes: For a hash label: leading *bytes* drawn in the hue (the
|
||||
@@ -170,6 +184,12 @@ class PathHop:
|
||||
:data:`CURSOR_GLYPH` in the app's brand accent, the same colour the list
|
||||
cursor (``❯``) below it wears, so the two halves of one gesture (the row
|
||||
you pick, the slot it lands in) read as one thing.
|
||||
gap: This hop is a mark standing *between* two nodes rather than being one — the
|
||||
elision (:func:`elision_hop`). Chips draw it in the break between two
|
||||
segments, bare on the page with no fill and no padding, because what it says
|
||||
is "the ribbon stops here and picks up again"; a chip would say the opposite,
|
||||
that some node in the route is called ``⋯``. Arrow mode needs no special case:
|
||||
a bare label between two arrows is already exactly that.
|
||||
"""
|
||||
|
||||
label: str
|
||||
@@ -180,6 +200,17 @@ class PathHop:
|
||||
dim: bool = False
|
||||
style: Optional[str] = None
|
||||
cursor: bool = False
|
||||
gap: bool = False
|
||||
|
||||
|
||||
def elision_hop() -> PathHop:
|
||||
"""The mark standing in for hops dropped out of a path's middle (or its head).
|
||||
|
||||
THE way to say "hops were left out here", so every surface that shortens a path
|
||||
agrees on the glyph *and* on the fact that it is a gap rather than a node (see
|
||||
:attr:`PathHop.gap`).
|
||||
"""
|
||||
return PathHop(_ELISION, dim=True, gap=True)
|
||||
|
||||
|
||||
def _style_hex(style: str) -> Optional[str]:
|
||||
@@ -366,7 +397,7 @@ class PathLine:
|
||||
full = self.text()
|
||||
if full.cell_len <= width or not self._hops:
|
||||
return full
|
||||
mark = PathHop(_ELISION, dim=True)
|
||||
mark = elision_hop()
|
||||
count = len(self._hops)
|
||||
# The heads worth trying, most-rescued first: a tail-side elision spares the
|
||||
# origin while it fits and gives it up only when it must; a head-side one is
|
||||
@@ -498,19 +529,23 @@ class PathLine:
|
||||
|
||||
Returns:
|
||||
``(cells, join, tail, lead, head)`` — each hop's cells, the cells one join
|
||||
between two hops costs (chip mode's seam is two: the point tapering out and
|
||||
the notch cut into the next chip), the cells a line always closes with (chip
|
||||
mode's edge; nothing in arrow mode), the cells every line *after the first*
|
||||
opens with (chip mode's notch, the seam's second half redrawn), and the
|
||||
cells the *first* line opens with (chip mode's rounded cap, nothing where
|
||||
the font has none).
|
||||
between two hops costs (chip mode's seam is the single interlocked chevron —
|
||||
and so is either side of an elision gap, so the figure holds there too), the
|
||||
cells a line always closes with (chip mode's edge; nothing in arrow mode), the
|
||||
cells every line *after the first* opens with (chip mode's notch, the seam
|
||||
redrawn), and the cells the *first* line opens with (chip mode's rounded cap,
|
||||
nothing where the font has none).
|
||||
"""
|
||||
if plain:
|
||||
return [self._plain_hop(hop).cell_len for hop in hops], cell_len(self._separator), 0, 0, 0
|
||||
widths = [self._chip(hop, self._chip_fill(hop)).cell_len for hop in hops]
|
||||
widths = [
|
||||
cell_len(hop.label) if hop.gap
|
||||
else self._chip(hop, self._chip_fill(hop)).cell_len
|
||||
for hop in hops
|
||||
]
|
||||
sep = cell_len(POWERLINE_SEP)
|
||||
head = cell_len(POWERLINE_ROUND_OPEN) if powerline_full() else 0
|
||||
return widths, sep * 2, sep, sep, head
|
||||
return widths, sep, sep, sep, head
|
||||
|
||||
@staticmethod
|
||||
def _fill(
|
||||
@@ -711,6 +746,11 @@ class PathLine:
|
||||
outruns closes on the point, the same "goes on" cue arrow mode spells with a
|
||||
trailing ``→``.
|
||||
|
||||
An elision (:attr:`PathHop.gap`) interrupts the ribbon rather than joining it: the
|
||||
chip before it closes on the page, the mark sits on the page bare, and the chip
|
||||
after it opens on its notch — the picture of a route whose middle was left out,
|
||||
where a filled ``⋯`` chip would have read as a node by that name.
|
||||
|
||||
Args:
|
||||
hops: The hops of this one line, in order.
|
||||
carry_in: This line continues a wrapped path (it does not open one).
|
||||
@@ -721,43 +761,54 @@ class PathLine:
|
||||
text = Text()
|
||||
if carry_in:
|
||||
text.append_text(self._notch(fills[0])) # the break's other half
|
||||
elif rounded:
|
||||
elif rounded and not hops[0].gap:
|
||||
text.append(POWERLINE_ROUND_OPEN, style=fills[0])
|
||||
for i, hop in enumerate(hops):
|
||||
if i:
|
||||
text.append_text(self._seam(fills[i - 1], fills[i]))
|
||||
text.append_text(self._chip(hop, fills[i]))
|
||||
if hops[i - 1].gap:
|
||||
text.append_text(self._notch(fills[i])) # the ribbon picks up again
|
||||
elif hop.gap:
|
||||
text.append(POWERLINE_SEP, style=fills[i - 1]) # …and stops here
|
||||
else:
|
||||
text.append_text(self._seam(fills[i - 1], fills[i]))
|
||||
if hop.gap:
|
||||
text.append(hop.label, style="faint" if hop.dim else "muted")
|
||||
else:
|
||||
text.append_text(self._chip(hop, fills[i]))
|
||||
if hops[-1].gap:
|
||||
return text # the line ended on the page; there is no chip left to close
|
||||
close = POWERLINE_SEP if carry_on or not rounded else POWERLINE_ROUND_CLOSE
|
||||
text.append(close, style=fills[-1]) # the edge into the page: pointed or round
|
||||
return text
|
||||
|
||||
@classmethod
|
||||
def _seam(cls, before: str, after: str) -> Text:
|
||||
"""The two cells between two chips: a point tapering out, a notch cut back in.
|
||||
@staticmethod
|
||||
def _seam(before: str, after: str) -> Text:
|
||||
"""The one cell between two chips: the previous fill's point, laid on the next.
|
||||
|
||||
The previous chip's point carries *no* background, so the page shows through the
|
||||
wedge it tapers into; the next chip's left edge then opens on the same point in
|
||||
the page's own colour, notched inward out of its fill. Both faces angle the way
|
||||
the path flows, and between them sits a sliver of bare page — the small gap
|
||||
oh-my-posh leaves between its segments.
|
||||
The classic interlock — foreground the chip behind, background the chip ahead —
|
||||
so the route reads as one ribbon whose segments meet on a chevron. It costs a
|
||||
single cell, and with 256 node hues on the wheel two neighbours are near enough
|
||||
to always differ that the join reads as a join (JP, 2026-08-09; the widget used
|
||||
to spend two cells leaving a sliver of page between every pair, insurance against
|
||||
a collision that the palette makes rare).
|
||||
|
||||
The alternative (one cell, the previous fill interlocked *on* the next) packs
|
||||
the row tighter but fuses the route into a continuous ribbon, and two neighbours
|
||||
that happen to land on the same fill — a hue collision, a run of faded hops, two
|
||||
keyless greys — then read as a single block where the route has two nodes. One
|
||||
gap, every seam: a chip is always a chip.
|
||||
Two fills that *do* land the same are the exception the interlock cannot draw —
|
||||
a chevron in its own background is no chevron — and they are not always bad luck:
|
||||
a mirrored return leg is a run of identically faded hops by construction, and so
|
||||
is a stretch of keyless greys. There the point drops its background and the page
|
||||
shows through the wedge instead, which is the one thing that still separates two
|
||||
blocks of one colour. One cell either way.
|
||||
|
||||
Args:
|
||||
before: The fill the seam tapers out of (the previous chip's).
|
||||
after: The fill the seam notches back into (the next chip's).
|
||||
before: The fill the point is drawn in (the previous chip's).
|
||||
after: The fill it is laid on (the next chip's).
|
||||
|
||||
Returns:
|
||||
The seam's two cells, styled.
|
||||
The seam's single styled cell.
|
||||
"""
|
||||
text = Text()
|
||||
text.append(POWERLINE_SEP, style=before)
|
||||
text.append_text(cls._notch(after))
|
||||
return text
|
||||
if before == after:
|
||||
return Text(POWERLINE_SEP, style=before) # fg only — the page cuts the wedge
|
||||
return Text(POWERLINE_SEP, style=f"{before} on {after}")
|
||||
|
||||
@staticmethod
|
||||
def _notch(fill: str) -> Text:
|
||||
@@ -779,16 +830,15 @@ class PathLine:
|
||||
return text
|
||||
|
||||
def _chip_fill(self, hop: PathHop) -> str:
|
||||
"""A chip's fill: cursor accent, override, dim slate, white you, hue, grey.
|
||||
"""A chip's fill: cursor accent, override, dim slate, our grey, hue, keyless grey.
|
||||
|
||||
The insertion slot outranks everything — it is the one chip that isn't a node,
|
||||
and it wears the brand accent so it reads as chrome among identities rather than
|
||||
as a hop with an unlucky hue. The fade comes next, outranking identity including
|
||||
our own. A dimmed hop is one nobody composed (an automatic landing back home, a
|
||||
mirrored return leg), and the white ``you`` chip is the loudest thing on the
|
||||
line: our automatic end must recede with the rest of the automatic half, not
|
||||
shout over the hops that *are* news. Plain mode says the same thing by fading
|
||||
the name.
|
||||
our own: a dimmed hop is one nobody composed (an automatic landing back home, a
|
||||
mirrored return leg), and our end must recede with the rest of that automatic
|
||||
half rather than keep its yellow among the greys. Plain mode says the same thing
|
||||
by fading the name.
|
||||
"""
|
||||
if hop.cursor:
|
||||
return _style_hex("brand") or _KEYLESS_BG
|
||||
@@ -805,11 +855,21 @@ class PathLine:
|
||||
return _KEYLESS_BG
|
||||
|
||||
def _chip(self, hop: PathHop, fill: str) -> Text:
|
||||
"""One chip: same words as arrow mode, dark ink on the identity fill."""
|
||||
ink = _DIM_FG if hop.dim else _CHIP_FG
|
||||
"""One chip: same words as arrow mode, dark ink on the identity fill.
|
||||
|
||||
A chip whose whole label is the ``★`` drops its padding: the pads exist to keep a
|
||||
*word* off the chevrons that bracket it, and a single mark centred in its own cell
|
||||
needs no such room — so our end of a route is three cells (cap, star, cap) rather
|
||||
than five. Its ink is the map's own yellow, on the neutral dark grey
|
||||
:data:`_YOU_BG`, so the star in the line and the star on the map read as one mark.
|
||||
"""
|
||||
star = hop.you and hop.label == SELF_GLYPH
|
||||
ink = _DIM_FG if hop.dim else (_SELF_INK if hop.you else _CHIP_FG)
|
||||
soft = _DIM_FG if hop.dim else _CHIP_FG_SOFT
|
||||
pad = "" if star else " "
|
||||
text = Text()
|
||||
text.append(" ", style=f"on {fill}")
|
||||
if pad:
|
||||
text.append(pad, style=f"on {fill}")
|
||||
if hop.lit_bytes > 0 and not hop.dim:
|
||||
split = hop.lit_bytes * 2
|
||||
text.append(hop.label[:split], style=f"bold {ink} on {fill}")
|
||||
@@ -819,7 +879,8 @@ class PathLine:
|
||||
text.append(hop.label, style=f"{weight}{ink} on {fill}")
|
||||
if hop.annotation:
|
||||
text.append(f" ({hop.annotation})", style=f"{soft} on {fill}")
|
||||
text.append(" ", style=f"on {fill}")
|
||||
if pad:
|
||||
text.append(pad, style=f"on {fill}")
|
||||
return text
|
||||
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ from ..services.topology import Link, MeshTopology
|
||||
from .map_render import _SELF, _UNKNOWN
|
||||
from .mapcanvas import RGB, MapCanvas, parse_hex
|
||||
from .menus import fit_cells
|
||||
from .pathline import ELIDE_HEAD, SELF_GLYPH, PathHop, PathLine
|
||||
from .pathline import ELIDE_HEAD, SELF_GLYPH, PathHop, PathLine, elision_hop
|
||||
from .theme import mark_rgb, name_style, snr_style
|
||||
from .trace_screen import snr_bar
|
||||
from .tui.render import query_line, render_to_ansi
|
||||
@@ -136,12 +136,11 @@ _FAN_MIN_SLOTS = 7
|
||||
#: never collide with a canonical id (those are hex).
|
||||
_MORE = "\x00more"
|
||||
|
||||
#: The breadcrumb trail's own hop joiner (``›``, not the app-wide ``→``) and the mark it
|
||||
#: shows on whichever side holds walk that is out of view (see :meth:`WalkScreen._trail_text`).
|
||||
#: The mark is the one :mod:`~meshterm.ui.pathline` elides with, so a head the widget hid
|
||||
#: and a tail the scroll hid read as the same thing.
|
||||
#: The breadcrumb trail's own hop joiner (``›``, not the app-wide ``→``). The mark it shows
|
||||
#: on whichever side holds walk that is out of view is
|
||||
#: :func:`~meshterm.ui.pathline.elision_hop` itself (see :meth:`WalkScreen._trail_text`), so
|
||||
#: a head the widget hid and a tail the scroll hid read as the same thing.
|
||||
_TRAIL_SEP = " › "
|
||||
_ELISION = "⋯"
|
||||
|
||||
#: How many find matches the list shows at most (the filter narrows it fast).
|
||||
_MAX_MATCHES = 10
|
||||
@@ -634,7 +633,7 @@ class WalkScreen(Screen):
|
||||
return full
|
||||
kept = hops[: len(hops) - self._trail_scroll]
|
||||
if self._trail_scroll:
|
||||
kept.append(PathHop(_ELISION, dim=True)) # the focus is off to the right
|
||||
kept.append(elision_hop()) # the focus is off to the right
|
||||
fitted = PathLine(kept, separator=_TRAIL_SEP).ellipsized(width, elide=ELIDE_HEAD)
|
||||
snapped = Text(" " * max(0, width - fitted.cell_len)) # snap the tail to the edge
|
||||
snapped.append_text(fitted)
|
||||
@@ -657,7 +656,7 @@ class WalkScreen(Screen):
|
||||
hops = [self._trail_hop(node) for node in self._trail]
|
||||
limit = 0
|
||||
if PathLine(hops, separator=_TRAIL_SEP).text().cell_len > width:
|
||||
mark = PathHop(_ELISION, dim=True)
|
||||
mark = elision_hop()
|
||||
for dropped in range(1, len(hops)):
|
||||
limit = dropped
|
||||
head = PathLine(hops[: len(hops) - dropped] + [mark], separator=_TRAIL_SEP)
|
||||
|
||||
+63
-25
@@ -16,7 +16,7 @@ import meshterm.ui.pathline as pathline
|
||||
from meshterm.ui.pathline import (
|
||||
CRACK_HEAD, CRACK_TAIL, CURSOR_GLYPH, ELIDE_HEAD, ELIDE_TAIL, POWERLINE_ROUND_CLOSE,
|
||||
POWERLINE_ROUND_OPEN, POWERLINE_SEP, SELF_GLYPH, WRAP_OFFSET, PathHop, PathLine,
|
||||
_style_hex, cut_mark, cut_to, path_line,
|
||||
_SELF_INK, _YOU_BG, _style_hex, cut_mark, cut_to, elision_hop, path_line,
|
||||
)
|
||||
from meshterm.ui.theme import node_style
|
||||
from meshterm.ui.widgets import path_text
|
||||
@@ -87,22 +87,19 @@ def test_empty_path_reads_as_the_callers_word() -> None:
|
||||
assert PathLine([], mode="plain").wrapped(40)[0].plain == "direct"
|
||||
|
||||
|
||||
def test_chips_are_separated_by_a_gap_not_an_interlock() -> None:
|
||||
"""A seam is two points, not one interlock: the previous chip tapers out with no
|
||||
background of its own (the page shows through the wedge), and the next chip's left
|
||||
edge notches the same point back inward out of its own fill. The closing edge keeps
|
||||
its single taper — nothing follows it to notch."""
|
||||
def test_chips_are_joined_by_one_interlocked_chevron() -> None:
|
||||
"""A seam is one cell, not two: the previous chip's point laid *on* the next chip's
|
||||
fill, so the route reads as a ribbon whose segments meet on a chevron. The closing
|
||||
edge keeps its lone taper — nothing follows it to lay the point on."""
|
||||
alice_fill = node_style("aa").split()[-1]
|
||||
line = PathLine(
|
||||
[PathHop("Alice", key="aa"), PathHop("you", you=True)], mode="powerline"
|
||||
)
|
||||
text = line.text()
|
||||
assert text.plain == f" Alice {POWERLINE_SEP * 2} you {POWERLINE_SEP}"
|
||||
assert text.plain == f" Alice {POWERLINE_SEP} you {POWERLINE_SEP}"
|
||||
seam_styles = [str(s.style) for s in text.spans
|
||||
if text.plain[s.start:s.end] == POWERLINE_SEP]
|
||||
# taper out of Alice, notch into you (reverse = the page's own colour), closing edge
|
||||
assert seam_styles == [alice_fill, "#ffffff reverse", "#ffffff"]
|
||||
assert all(" on " not in style for style in seam_styles) # never an interlock
|
||||
assert seam_styles == [f"{alice_fill} on {_YOU_BG}", _YOU_BG]
|
||||
|
||||
|
||||
def test_chips_keep_the_same_words_and_honour_style_overrides() -> None:
|
||||
@@ -136,7 +133,7 @@ def test_the_cursor_is_a_hop_of_its_own_in_either_mode() -> None:
|
||||
assert _styles(plain)[CURSOR_GLYPH] == "selected" # the reverse-video block
|
||||
|
||||
chips = PathLine(hops, mode="powerline").text()
|
||||
assert chips.plain == f" a {POWERLINE_SEP * 2} {CURSOR_GLYPH} {POWERLINE_SEP * 2} b {POWERLINE_SEP}"
|
||||
assert chips.plain == f" a {POWERLINE_SEP} {CURSOR_GLYPH} {POWERLINE_SEP} b {POWERLINE_SEP}"
|
||||
slot = next(s for s in chips.spans if chips.plain[s.start : s.end] == CURSOR_GLYPH)
|
||||
assert str(slot.style).endswith(f"on {_style_hex('brand')}") # the brand accent fill
|
||||
|
||||
@@ -209,14 +206,18 @@ def test_cut_to_leaves_arrow_lines_on_the_ellipsis() -> None:
|
||||
|
||||
def test_cut_mark_mirrors_itself_and_reads_the_visible_side() -> None:
|
||||
"""The head mark is the tail's mirror, and each takes the fill of the nearest cell
|
||||
still *drawn* — so a cut landing on a seam cracks in the colour the reader can see,
|
||||
which is a different chip on each side of it."""
|
||||
still *drawn* — scanning back for a tail cut, forward for a head cut."""
|
||||
full = _chips().text()
|
||||
seam = full.plain.index(POWERLINE_SEP) # the two cells between AAAA and BBBB
|
||||
head, tail = cut_mark(full, seam, ELIDE_HEAD), cut_mark(full, seam, ELIDE_TAIL)
|
||||
body = full.plain.index("AAAA") # inside the first chip, either way you scan
|
||||
head, tail = cut_mark(full, body, ELIDE_HEAD), cut_mark(full, body, ELIDE_TAIL)
|
||||
assert (head.plain, tail.plain) == (CRACK_HEAD, CRACK_TAIL)
|
||||
assert str(head.style) == _style_hex(node_style("22bb")) # forward, into BBBB
|
||||
assert str(tail.style) == _style_hex(node_style("11aa")) # back, into AAAA
|
||||
assert str(head.style) == str(tail.style) == _style_hex(node_style("11aa"))
|
||||
|
||||
# A cut landing on the interlocked seam itself cracks in the field that cell carries —
|
||||
# the chip *ahead*, whose fill is literally the seam's background — so the mark reads
|
||||
# as the next segment beginning and being sheared, not as a colour off the line.
|
||||
seam = full.plain.index(POWERLINE_SEP)
|
||||
assert str(cut_mark(full, seam, ELIDE_TAIL).style) == _style_hex(node_style("22bb"))
|
||||
|
||||
|
||||
def test_cut_mark_falls_back_to_the_ellipsis_off_a_chip() -> None:
|
||||
@@ -229,6 +230,36 @@ def test_cut_mark_falls_back_to_the_ellipsis_off_a_chip() -> None:
|
||||
assert str(mark.style) == "muted"
|
||||
|
||||
|
||||
def test_the_elision_sits_between_chips_rather_than_being_one() -> None:
|
||||
"""Hops dropped out of a path are a break *in* the ribbon, not a node called ``⋯``.
|
||||
|
||||
The chip before it closes onto the page, the mark sits there bare — no fill, no
|
||||
padding — and the chip after it opens on its notch. Three cells for the whole gap
|
||||
where a filled ``⋯`` chip with its pads and two seams cost seven, which is four more
|
||||
hops of route on a line that is short of room by definition.
|
||||
"""
|
||||
line = PathLine(
|
||||
[PathHop(f"NODE{i:02d}", key=f"{i:02x}aa") for i in range(5)], mode="powerline"
|
||||
)
|
||||
fitted = line.ellipsized(30)
|
||||
assert fitted.cell_len <= 30
|
||||
at = fitted.plain.index("⋯")
|
||||
assert fitted.plain[at - 1] == POWERLINE_SEP and fitted.plain[at + 1] == POWERLINE_SEP
|
||||
styles = {fitted.plain[s.start : s.end]: str(s.style) for s in fitted.spans}
|
||||
assert styles["⋯"] == "faint" # bare on the page: no ``on`` fill, and no pads either
|
||||
|
||||
# Arrow mode needed no special case — a bare label between two arrows already *is* a gap.
|
||||
plain = PathLine(line.hops, mode="plain").ellipsized(30)
|
||||
assert " ⋯ " in plain.plain and "→ ⋯ →" in plain.plain
|
||||
|
||||
|
||||
def test_elision_hop_is_the_one_definition_both_surfaces_share() -> None:
|
||||
"""The widget and the mesh walk's trail elide with the same mark *and* the same
|
||||
gap semantics, so a head the widget hid reads as a tail the scroll hid."""
|
||||
mark = elision_hop()
|
||||
assert (mark.label, mark.gap, mark.dim) == ("⋯", True, True)
|
||||
|
||||
|
||||
def test_wrapped_cracks_an_over_wide_lone_chip() -> None:
|
||||
"""The one place a chip line is cut mid-hop rather than folded: a hop wider than the
|
||||
content column stands alone, cracked, still inside the budget."""
|
||||
@@ -439,19 +470,24 @@ def test_rounded_caps_finish_a_path_only_where_the_font_has_them(monkeypatch) ->
|
||||
assert all(text.cell_len <= 20 for text in wrapped)
|
||||
|
||||
|
||||
def test_every_seam_opens_onto_the_page_whatever_the_fills() -> None:
|
||||
"""One gap rule, no exceptions: a seam never takes a background, so two chips of
|
||||
one colour — a hue collision, a run of dimmed hops — can't fuse into a single block,
|
||||
and two chips of different colours are still visibly two chips."""
|
||||
def test_a_seam_between_two_of_one_colour_falls_back_to_the_page() -> None:
|
||||
"""The interlock can't draw a chevron in its own background, so where two chips land
|
||||
on the same fill the point drops its background and the page cuts the wedge instead.
|
||||
|
||||
Not a rare accident, either: a mirrored return leg is a run of identically faded hops
|
||||
by construction, and a stretch of keyless hops shares one grey. Either way it stays a
|
||||
single cell — the fallback trades the blend for the separation, not for width.
|
||||
"""
|
||||
hue = _style_hex(node_style("aa"))
|
||||
same = PathLine([PathHop("A", key="aa"), PathHop("B", key="aa")], mode="powerline")
|
||||
seam = next(s for s in same.text().spans if same.text().plain[s.start] == POWERLINE_SEP)
|
||||
assert str(seam.style) == hue # foreground only: the page shows through the taper
|
||||
text = same.text()
|
||||
seam = next(s for s in text.spans if text.plain[s.start] == POWERLINE_SEP)
|
||||
assert str(seam.style) == hue # foreground only: the page shows through the wedge
|
||||
|
||||
apart = PathLine([PathHop("A", key="aa"), PathHop("B", key="77")], mode="powerline")
|
||||
text = apart.text()
|
||||
seams = [str(s.style) for s in text.spans if text.plain[s.start] == POWERLINE_SEP]
|
||||
assert seams[0] == hue # the fill it tapers out of, and nothing behind it
|
||||
assert seams[0] == f"{hue} on {_style_hex(node_style('77'))}" # blended, one cell
|
||||
|
||||
dimmed = PathLine([PathHop("A", dim=True), PathHop("B", dim=True)], mode="powerline")
|
||||
text = dimmed.text()
|
||||
@@ -504,11 +540,13 @@ def test_bare_self_keeps_us_in_the_you_white_where_nothing_is_composed() -> None
|
||||
dim_self=False, mode="plain").text()
|
||||
stars = [s for s in text.spans if text.plain[s.start : s.end] == SELF_GLYPH]
|
||||
assert [str(s.style) for s in stars] == ["you", "you"]
|
||||
# In chips the same identity is the map's yellow star on the neutral dark grey — the
|
||||
# marker itself rather than a hue, since our end is a fixture and not a node to tell apart.
|
||||
chips = path_line(hops, prefix_bytes=2, self_name="Me", bare_self=True,
|
||||
dim_self=False, mode="powerline").text()
|
||||
fills = [str(s.style) for s in chips.spans
|
||||
if chips.plain[s.start : s.end] == SELF_GLYPH]
|
||||
assert all("#ffffff" in fill for fill in fills) # the you white, as a chip fill
|
||||
assert fills == [f"bold {_SELF_INK} on {_YOU_BG}"] * 2
|
||||
|
||||
# The explicit fade still rules: a star inside a dimmed return leg stays grey.
|
||||
faded = path_line(hops, prefix_bytes=2, self_name="Me", bare_self=True,
|
||||
|
||||
Reference in new issue
Block a user