Every grey is neutral
The Tailwind slate greys were cold. Each one is now r=g=b at its own OKLab lightness, so every contrast stays where it was: the theme's chrome, the path chips, the map's roads, labels and buildings, the heat tail, and the emulator window. test_neutral_greys fails any #rrggbb literal that reads as a grey and has a tint. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b5fc1f8930
commit
05428bd007
16 files changed
+180
-84
No files matched your search
@@ -524,6 +524,13 @@ as a grouped list does. Filling a page in is editing its `.md`; no Python follow
|
||||
|
||||
### Colour
|
||||
|
||||
- **A grey is neutral: r = g = b** (JP, 2026-10-14). Every grey MeshTerm defines — chrome,
|
||||
a keyless chip, a minor road, the emulator's window — has no tint, warm or cold; the
|
||||
Tailwind slates were each re-made at their own OKLab lightness (`#94a3b8` → `#a2a2a2`,
|
||||
`#64748b` → `#737373`, `#334155` → `#404040`), so every contrast stayed put. A colour
|
||||
that has a meaning gets real chroma instead. `tests/test_neutral_greys.py` fails any
|
||||
`#rrggbb` literal under OKLab chroma 0.045 that isn't r=g=b. Part of a wider pass: a
|
||||
colour that carries no meaning is on its way out.
|
||||
- Node names are always coloured: `name_style(name, key)` palette hue, derived from the
|
||||
node's key (its first byte — any known prefix agrees) so a rename keeps the colour.
|
||||
One rule on **every** platform; only the resolution changes (see **Platforms**).
|
||||
@@ -565,7 +572,7 @@ as a grouped list does. Filling a page in is editing its `.md`; no Python follow
|
||||
what makes the arrow form say what the chip form always said, its fills having never been
|
||||
in the fold's vocabulary. Reverse-video chips — a dialog's committing button,
|
||||
a running action's Abort, the arrow-mode composer slot, the editor cursor — are the
|
||||
`selected` fill, a **grey** block (`muted`'s slate; light grey slot 7 on the VT, the one
|
||||
`selected` fill, a **grey** block (`muted`'s grey; light grey slot 7 on the VT, the one
|
||||
grey a reverse can put behind text there, and the same fill the F-key lane uses). A chip
|
||||
marks where a press lands; it is chrome, and it does not get a hue.
|
||||
Recency heat colours heard/first-heard ages, never names — seven steps on plain human
|
||||
|
||||
@@ -81,8 +81,8 @@ _SHIFTS = ("Shift_L", "Shift_R")
|
||||
_REPEAT_GAP_MS = 30
|
||||
|
||||
#: The cap of a drawn lane key, and the ink of the digit that is printed on it.
|
||||
_KEY_BODY = "#1d2025"
|
||||
_KEY_DIGIT = "#eef1f4"
|
||||
_KEY_BODY = "#202020"
|
||||
_KEY_DIGIT = "#f1f1f1"
|
||||
|
||||
#: The modifier bits of Tk: Shift and Control on all platforms, Alt where the platform puts it.
|
||||
_SHIFT_BIT = 0x0001
|
||||
@@ -231,12 +231,12 @@ class EmulatorWindow:
|
||||
keys_h = 26 * scale if self._device.lane_keys else 0
|
||||
root = tk.Tk()
|
||||
root.title(f"MeshTerm — {self._device.name} emulator")
|
||||
root.configure(background="#2b2f36")
|
||||
root.configure(background="#2f2f2f")
|
||||
root.resizable(False, False)
|
||||
width = panel_w * scale + 2 * margin
|
||||
height = panel_h * scale + 2 * margin + keys_h
|
||||
canvas = tk.Canvas(
|
||||
root, width=width, height=height, background="#2b2f36", highlightthickness=0
|
||||
root, width=width, height=height, background="#2f2f2f", highlightthickness=0
|
||||
)
|
||||
canvas.pack()
|
||||
base = tk.PhotoImage(width=panel_w, height=panel_h)
|
||||
|
||||
+22
-22
@@ -59,20 +59,20 @@ _ROAD_STYLE: dict[str, tuple[str, int]] = {
|
||||
"trunk": ("map.highway", 26),
|
||||
"primary": ("#e8b24a", 25),
|
||||
"secondary": ("#d7c257", 24),
|
||||
"tertiary": ("#a7adb8", 23),
|
||||
"minor": ("#828894", 21),
|
||||
"unclassified": ("#828894", 21),
|
||||
"residential": ("#828894", 21),
|
||||
"living_street": ("#767c88", 20),
|
||||
"service": ("#5f646e", 19),
|
||||
"pedestrian": ("#5a5f69", 15),
|
||||
"path": ("#4b5560", 12),
|
||||
"track": ("#4b5560", 12),
|
||||
"footway": ("#454e58", 11),
|
||||
"cycleway": ("#455864", 12),
|
||||
"tertiary": ("#adadad", 23),
|
||||
"minor": ("#888888", 21),
|
||||
"unclassified": ("#888888", 21),
|
||||
"residential": ("#888888", 21),
|
||||
"living_street": ("#7c7c7c", 20),
|
||||
"service": ("#646464", 19),
|
||||
"pedestrian": ("#5f5f5f", 15),
|
||||
"path": ("#545454", 12),
|
||||
"track": ("#545454", 12),
|
||||
"footway": ("#4d4d4d", 11),
|
||||
"cycleway": ("#555555", 12),
|
||||
}
|
||||
_ROAD_DEFAULT = ("#5f646e", 18)
|
||||
_RAIL = ("#8a8f98", 22)
|
||||
_ROAD_DEFAULT = ("#646464", 18)
|
||||
_RAIL = ("#8f8f8f", 22)
|
||||
|
||||
# Waterway class -> (colour, priority).
|
||||
_WATERWAY_STYLE: dict[str, tuple[str, int]] = {
|
||||
@@ -90,16 +90,16 @@ _GREEN_CLASSES = {"wood", "forest", "grass", "park", "meadow", "scrub", "wetland
|
||||
# with a lower rank get screen space first. The minimum zoom hides the fine detail until
|
||||
# you zoom in.
|
||||
_PLACE_STYLE: dict[str, tuple[str, bool, int, int]] = {
|
||||
"city": ("#f8fafc", True, 0, 0),
|
||||
"town": ("#e6ebf2", True, 1, 9),
|
||||
"village": ("#cdd6e2", False, 2, 12),
|
||||
"suburb": ("#9fb0c4", False, 3, 12),
|
||||
"quarter": ("#94a5ba", False, 4, 13),
|
||||
"neighbourhood": ("#8496ab", False, 5, 13),
|
||||
"hamlet": ("#8496ab", False, 6, 14),
|
||||
"city": ("#fafafa", True, 0, 0),
|
||||
"town": ("#eaeaea", True, 1, 9),
|
||||
"village": ("#d5d5d5", False, 2, 12),
|
||||
"suburb": ("#aeaeae", False, 3, 12),
|
||||
"quarter": ("#a3a3a3", False, 4, 13),
|
||||
"neighbourhood": ("#949494", False, 5, 13),
|
||||
"hamlet": ("#949494", False, 6, 14),
|
||||
}
|
||||
_WATER_LABEL = ("#7dd3fc", False, 2)
|
||||
_STREET_LABEL = ("#9aa0aa", False, 7)
|
||||
_STREET_LABEL = ("#9f9f9f", False, 7)
|
||||
|
||||
#: The zoom at which street names appear. Below it, a canvas 53 cells wide cannot hold one
|
||||
#: name for each street. The few names that fit label a grid that is too coarse to show
|
||||
@@ -126,7 +126,7 @@ _FILL_LAYERS = ("water", "landcover", "landuse", "park")
|
||||
#: Below the zoom gate, a typical footprint is approximately two dots wide (less than half
|
||||
#: a cell). Thus the full layer becomes a haze that makes the streets hard to read, and it
|
||||
#: shows nothing that the street pattern does not already show.
|
||||
_BUILDING_FILL = ("#4a4f5a", 8)
|
||||
_BUILDING_FILL = ("#4f4f4f", 8)
|
||||
_BUILDING_STIPPLE = 2
|
||||
_BUILDING_MIN_ZOOM = 15
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ surface that the survey found can in the end use it.
|
||||
look, and each seam uses one cell. The label of the chip of a node has the hue that
|
||||
comes from its hash (:func:`~meshterm.ui.theme.node_style`). This is the colour that its
|
||||
name has on each surface. The fill is that hue, but darker (:data:`CHIP_LIGHTNESS`). Our
|
||||
node is the white ``★`` of the map on a neutral dark grey. A faded hop is dark slate. A
|
||||
node is the white ``★`` of the map on a neutral dark grey. A faded hop is dark grey. A
|
||||
keyless hop is light grey on grey. (On the 16-colour console of the PicoCalc, the fill
|
||||
is the dim twin of the hue. Refer to :func:`_slot_colours`.)
|
||||
|
||||
@@ -192,11 +192,11 @@ def _chip_label(fill: str) -> str:
|
||||
return oklab.to_hex(oklab.fitted((min(1.0, lightness / CHIP_LIGHTNESS), a, b)))
|
||||
|
||||
|
||||
#: The text of the composer's slot: near-black slate on the white chip.
|
||||
_CHIP_FG = "#0f172a"
|
||||
#: The text of the composer's slot: a grey that is almost black, on the white chip.
|
||||
_CHIP_FG = "#181818"
|
||||
#: The chip fill for a keyless hop: the ``faint`` grey. Colour is only for identities that
|
||||
#: have a key, in chips and in arrow mode.
|
||||
_KEYLESS_BG = "#64748b"
|
||||
_KEYLESS_BG = "#737373"
|
||||
#: The label of a keyless chip: the same pair as the chip of a node, in grey.
|
||||
_KEYLESS_FG = _chip_label(_KEYLESS_BG)
|
||||
#: The fill of a quiet chip (:attr:`PathHop.quiet`): the grey of plain text (``#cccccc``,
|
||||
@@ -214,11 +214,11 @@ _WHITE = "#ffffff"
|
||||
#: of the spectrum on purpose, and it is not the white that it was before. Our end of a
|
||||
#: route is a fixture that the user already knows. It stays back and lets the hops that
|
||||
#: differ carry the colour.
|
||||
_YOU_BG = "#3f3f46"
|
||||
#: The chip of a dimmed hop: a dark slate fill with muted ink. It recedes like ``faint``
|
||||
_YOU_BG = "#404040"
|
||||
#: The chip of a dimmed hop: a dark grey fill with muted ink. It recedes like ``faint``
|
||||
#: text.
|
||||
_DIM_BG = "#334155"
|
||||
_DIM_FG = "#94a3b8"
|
||||
_DIM_BG = "#404040"
|
||||
_DIM_FG = "#a2a2a2"
|
||||
|
||||
#: On the 16-colour console, the page: slot 0, black. It is the fill of a chip that the
|
||||
#: console cannot fill, because the VT has no dark grey background. That chip is our ``★``,
|
||||
|
||||
@@ -88,11 +88,11 @@ _WALK_EDGE = (255, 255, 255)
|
||||
#: around a scored walk. A fan grows past this number by itself, but nothing here fans.
|
||||
_GRAPH_ROWS = 3
|
||||
|
||||
#: The one body tone of the area drawing: a plain muted slate, for the enclosed region
|
||||
#: The one body tone of the area drawing: a plain muted grey, for the enclosed region
|
||||
#: and for its loop. It is one shade on purpose (no dimmer fill inside a brighter edge).
|
||||
#: An even-odd fill shades only the enclosed side, and the coloured node pins give the
|
||||
#: colour. Thus the shape shows as one flat silhouette, not as two brightnesses.
|
||||
_AREA_TONE: RGB = (148, 163, 184)
|
||||
_AREA_TONE: RGB = (162, 162, 162)
|
||||
|
||||
#: The cell box of the area drawing, which is the full stage of the Area tab. Its width
|
||||
#: is the width of the page. (The proportions are kept, thus a wider page gives a bigger
|
||||
|
||||
+21
-21
@@ -34,13 +34,13 @@ MESH_THEME = Theme(
|
||||
# it. It is a *grey* block, and the ink of the page shows through it. It was cyan
|
||||
# before. That cyan was the teal of the wordmark with a third job (identity, a
|
||||
# node hue, and now a selection). A chip is chrome. It shows where a press lands,
|
||||
# and it does not claim a colour. The slate is the slate of ``muted``. It is light
|
||||
# and it does not claim a colour. The grey is the grey of ``muted``. It is light
|
||||
# enough that the reversed ink reads on it, in any background of the terminal. It
|
||||
# must be a *single* theme name. Rich removes without a message a style string that
|
||||
# mixes a theme name with an attribute (for example "reverse muted" renders as plain
|
||||
# text). Thus the reverse is part of the definition here, and the call site does
|
||||
# not add it.
|
||||
"selected": "reverse bold #94a3b8",
|
||||
"selected": "reverse bold #a2a2a2",
|
||||
# The only ink for "this is the one that the user selected". It is the row that the
|
||||
# ❯ points at, in each select list and in each screen that draws its own rows
|
||||
# (feed, routes, records, walk, composer). It is also the lit column heading one
|
||||
@@ -105,7 +105,7 @@ MESH_THEME = Theme(
|
||||
"ok": "bold #4ade80",
|
||||
"warn": "bold #fbbf24",
|
||||
"err": "bold #f87171",
|
||||
"muted": "#94a3b8",
|
||||
"muted": "#a2a2a2",
|
||||
# A node that MeshTerm cannot identify: its ``○`` ring, and its label where a bare
|
||||
# key or hash is the name (refer to the return of name_style when there is no key).
|
||||
# It has its own name and does not use ``muted``, because the two styles must not
|
||||
@@ -113,13 +113,13 @@ MESH_THEME = Theme(
|
||||
# text. An unidentified node is *content* on which the user can still act. On the
|
||||
# console this difference is the whole ladder: chrome takes the dark grey slot,
|
||||
# and this style takes the light grey slot.
|
||||
"node.unknown": "#94a3b8",
|
||||
"node.unknown": "#a2a2a2",
|
||||
# The titles of panels and dialogs: the same hue as the border that they are in,
|
||||
# one shade brighter. Thus the title reads as part of its frame, and it is still
|
||||
# different from the frame. There is one entry for each border style that the frame
|
||||
# compositor receives (refer to theme.title_style).
|
||||
"title.accent": "bold #a5b4fc",
|
||||
"title.muted": "bold #cbd5e1",
|
||||
"title.muted": "bold #d4d4d4",
|
||||
"title.warn": "bold #fcd34d",
|
||||
"title.err": "bold #fca5a5",
|
||||
"title.ok": "bold #86efac",
|
||||
@@ -129,24 +129,24 @@ MESH_THEME = Theme(
|
||||
# The hint reads as part of the frame, and it stays behind the frame. There is one
|
||||
# entry for each border style (refer to theme.hint_style).
|
||||
"hint.accent": "#6366f1",
|
||||
"hint.muted": "#64748b",
|
||||
"hint.muted": "#737373",
|
||||
"hint.warn": "#f59e0b",
|
||||
"hint.err": "#ef4444",
|
||||
"hint.ok": "#22c55e",
|
||||
"hint.brand": "#2dd4bf",
|
||||
# A step darker than ``muted``, for placeholder dashes (the missing packet count or
|
||||
# age of a node). They must stay behind the real, muted values around them.
|
||||
"faint": "#64748b",
|
||||
"faint": "#737373",
|
||||
# The ``── Label ──`` of a section heading: in a grouped list, and the day divider
|
||||
# of a chat. It is a dark grey, and never the accent of the frame. When the rule of
|
||||
# a heading had the colour of the border, it looked like part of the frame that it
|
||||
# is in (JP, 2026-10-02). It is bold, so the label is still a landmark at that
|
||||
# shade.
|
||||
"heading": "bold #64748b",
|
||||
"heading": "bold #737373",
|
||||
# A further step darker than ``faint``, for the unlit track of a meter (the SNR
|
||||
# quality bars). It is dark enough to look like a background, and not like a
|
||||
# dimmer version of the reading.
|
||||
"track": "#334155",
|
||||
"track": "#404040",
|
||||
"snr.good": "bold #4ade80",
|
||||
"snr.ok": "bold #fbbf24",
|
||||
"snr.bad": "bold #f87171",
|
||||
@@ -174,9 +174,9 @@ MESH_THEME = Theme(
|
||||
"type.room": "#ffffff",
|
||||
"type.sensor": "#fb923c",
|
||||
# A region name (the scope of a flood). It is not a node, so it has no hue from the
|
||||
# node wheel. It is a light slate. Its slant makes it different from prose, as a
|
||||
# node wheel. It is a light grey. Its slant makes it different from prose, as a
|
||||
# tag is different from a sentence.
|
||||
"scope": "italic #cbd5e1",
|
||||
"scope": "italic #d4d4d4",
|
||||
# The features of the basemap for which the *hue* is the information: water is
|
||||
# blue, parks are green, and a highway is the warm colour. A naive downsample
|
||||
# damages them (the dark blue becomes grey, the dark green becomes black, and the
|
||||
@@ -205,13 +205,13 @@ MESH_THEME = Theme(
|
||||
"heat.hours": "#f87171", # 1 hour
|
||||
"heat.days": "#b45309", # 1 day
|
||||
"heat.weeks": "#dc2626", # 1 week
|
||||
"heat.months": "#94a3b8", # 1 month
|
||||
"heat.never": "#64748b", # 1 year, and never heard
|
||||
"heat.months": "#a2a2a2", # 1 month
|
||||
"heat.never": "#737373", # 1 year, and never heard
|
||||
# The chip fills of the F-key lane of the PicoCalc (refer to ui.tui.fkeys): grey for
|
||||
# the plain F1-F5 bank, and green while the Shift watcher reports F6-F10. The text
|
||||
# is white on both. They are also defined here so that the style names resolve on
|
||||
# each platform, although only footer_fkeys of the PicoCalc asks for them.
|
||||
"fkey.chip": "bold #ffffff on #475569",
|
||||
"fkey.chip": "bold #ffffff on #545454",
|
||||
"fkey.chip.shift": "bold #ffffff on #16a34a",
|
||||
# The fills of the Cardputer Zero deck, taken from its own keyboard (JP,
|
||||
# 2026-09-30). The normal fill is the orange-red in which the fn key and its F4–F8
|
||||
@@ -230,14 +230,14 @@ MESH_THEME = Theme(
|
||||
# and links have the two hues that nothing else in a body uses. A struck-out run
|
||||
# goes back to the placeholder grey. The bullet and the rail are the chrome on which
|
||||
# a list or a quote hangs.
|
||||
"md.strong": "bold #e2e8f0",
|
||||
"md.em": "italic #cbd5e1",
|
||||
"md.strong": "bold #e7e7e7",
|
||||
"md.em": "italic #d4d4d4",
|
||||
"md.code": "#7dd3fc",
|
||||
"md.link": "underline #a5b4fc",
|
||||
"md.quote": "italic #cbd5e1",
|
||||
"md.strike": "strike #64748b",
|
||||
"md.quote": "italic #d4d4d4",
|
||||
"md.strike": "strike #737373",
|
||||
"md.bullet": "#818cf8",
|
||||
"md.rail": "#475569",
|
||||
"md.rail": "#545454",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -380,7 +380,7 @@ MESH_THEME_16 = Theme(
|
||||
"node.unknown": "not bold color(7)",
|
||||
"title.accent": "bold color(12)",
|
||||
# The one promotion on purpose: bold moves slot 7 to 15. This title needs a colour
|
||||
# that is almost white (the regular theme writes it as #cbd5e1).
|
||||
# that is almost white (the regular theme writes it as #d4d4d4).
|
||||
"title.muted": "bold color(7)",
|
||||
"title.warn": "bold color(11)",
|
||||
"title.err": "bold color(9)",
|
||||
@@ -922,7 +922,7 @@ def _nearest_slot_params(background: bool, r: int, g: int, b: int) -> str:
|
||||
the console spells bright. Thus a bare ``31`` immediately after a ``90`` inherits the
|
||||
intensity bit, and renders as ``91`` without a message. Quantized art is a run of
|
||||
colour spans that are next to each other, and no style boundary between them resets
|
||||
the intensity (the bevel of the wordmark has a slate span in every other span, and a
|
||||
the intensity (the bevel of the wordmark has a grey span in every other span, and a
|
||||
map raster has neighbouring cells). Thus the promotion happens in the middle of a row
|
||||
and gives the wrong colour to half a row. The fourth row of the narrow wordmark (its
|
||||
only row with a dim slot) was part red and part light red. The split was at each span
|
||||
|
||||
@@ -40,7 +40,7 @@ _TITLE_COLOR = "bold #a5b4fc"
|
||||
_CHIP_COLOR = "bold #818cf8"
|
||||
|
||||
#: The colour of the caption (the theme's ``muted``, in hex so that the fade can dim it).
|
||||
_CAPTION_COLOR = "#94a3b8"
|
||||
_CAPTION_COLOR = "#a2a2a2"
|
||||
|
||||
|
||||
class BusyOverlay:
|
||||
|
||||
@@ -18,7 +18,7 @@ only its direct neighbours:
|
||||
**node-type mark** of the app, with its glyph and its colour: the same mark that the
|
||||
map and the route graph use for that node. The *identity* of the node is in the name
|
||||
next to the marker, in the hue of the node. Edges are braille lines. The median SNR of
|
||||
the link sets the colour of an edge (green → amber → red, and slate for a link with no
|
||||
the link sets the colour of an edge (green → amber → red, and grey for a link with no
|
||||
reading), and the age of the evidence makes it fainter. Each edge starts at the *right
|
||||
end of the focus name*, so that a line never crosses a label. The fan is on a grid of
|
||||
rows: one marker on each row, a blank row between two markers, and a blank row above
|
||||
@@ -202,7 +202,7 @@ _SNR_STOPS: tuple[tuple[float, RGB], ...] = (
|
||||
|
||||
#: The edge colour for a link with no SNR reading (for example, a link known only from a
|
||||
#: route).
|
||||
_NO_READING: RGB = (100, 116, 139)
|
||||
_NO_READING: RGB = (115, 115, 115)
|
||||
|
||||
#: One-letter tags for the types of evidence for a link, the same as in the path composer:
|
||||
#: T(race), R(oute), P(acket log), N(eighbour table).
|
||||
@@ -864,7 +864,7 @@ class WalkScreen(Screen):
|
||||
# The edge of the selected link is the brightest and is on top. It does not get
|
||||
# the age fade, so it shows as one lit line over the dimmer others. (The user can
|
||||
# still read the age in the age column of the row.) The edge of the collapsed
|
||||
# marker is slate. But when the selection is one of its nodes, it becomes the
|
||||
# marker is grey. But when the selection is one of its nodes, it becomes the
|
||||
# edge of that node.
|
||||
now = utcnow()
|
||||
for other, (x, y) in placed.items():
|
||||
|
||||
@@ -1159,10 +1159,10 @@ _HEAT_STOPS: tuple[tuple[float, tuple[int, int, int]], ...] = (
|
||||
(math.log10(3600), (250, 204, 21)), # ~1h: yellow
|
||||
(math.log10(21600), (251, 146, 60)), # ~6h: orange
|
||||
(math.log10(86400), (248, 113, 113)), # ~1d: red
|
||||
(math.log10(604800), (148, 163, 184)), # ~1w: grey
|
||||
(math.log10(2592000), (100, 116, 139)), # ~30d+: cold slate
|
||||
(math.log10(604800), (162, 162, 162)), # ~1w: grey
|
||||
(math.log10(2592000), (115, 115, 115)), # ~30d+: cold grey
|
||||
)
|
||||
_RECENCY_NEVER = "#64748b" # never heard: the coldest slate
|
||||
_RECENCY_NEVER = "#737373" # never heard: the coldest grey
|
||||
|
||||
|
||||
def age_seconds(when: datetime | None) -> float | None:
|
||||
@@ -1238,7 +1238,7 @@ def _recency_gradient(secs: float | None) -> str:
|
||||
|
||||
The function interpolates the RGB channels between the two stops on each side of
|
||||
``secs`` (in log-age space). Below the first stop, it gives white. Above the last stop,
|
||||
it gives cold slate.
|
||||
it gives cold grey.
|
||||
"""
|
||||
if secs is None:
|
||||
return _RECENCY_NEVER
|
||||
|
||||
+4
-4
@@ -650,7 +650,7 @@ def test_line_label_anchors_on_the_visible_stretch() -> None:
|
||||
# A line across the whole tile at the latitude of the view. Its midpoint is far away, but
|
||||
# it crosses the canvas, so the clip must find it.
|
||||
_add_line_label(
|
||||
frame, [[(0, cy), (4096, cy)]], 4096, 14, 4843, 5861, "Rue Long", ("#9aa0aa", False, 7)
|
||||
frame, [[(0, cy), (4096, cy)]], 4096, 14, 4843, 5861, "Rue Long", ("#9f9f9f", False, 7)
|
||||
)
|
||||
|
||||
assert len(frame.labels) == 1
|
||||
@@ -667,7 +667,7 @@ def test_line_label_off_screen_is_not_queued() -> None:
|
||||
frame = _Frame(canvas=MapCanvas(60, 20), viewport=vp)
|
||||
# A short line in the far corner of the tile, far outside a window at zoom 16.
|
||||
_add_line_label(
|
||||
frame, [[(0, 0), (8, 8)]], 4096, 14, 4843, 5861, "Nowhere", ("#9aa0aa", False, 7)
|
||||
frame, [[(0, 0), (8, 8)]], 4096, 14, 4843, 5861, "Nowhere", ("#9f9f9f", False, 7)
|
||||
)
|
||||
|
||||
assert frame.labels == []
|
||||
@@ -683,7 +683,7 @@ def test_line_label_offers_alternates_along_the_visible_run() -> None:
|
||||
cx, cy = _tile_local_of_view_centre(vp, 14, 4843, 5861)
|
||||
# A zig-zag across the view gives several visible pieces to choose from.
|
||||
ring = [(cx - 120 + i * 40, cy - 40 + (i % 2) * 80) for i in range(8)]
|
||||
_add_line_label(frame, [ring], 4096, 14, 4843, 5861, "Rue Zig", ("#9aa0aa", False, 7))
|
||||
_add_line_label(frame, [ring], 4096, 14, 4843, 5861, "Rue Zig", ("#9f9f9f", False, 7))
|
||||
|
||||
assert frame.labels and frame.labels[0].alts, "no fallback anchors offered"
|
||||
assert all(a != (frame.labels[0].x, frame.labels[0].y) for a in frame.labels[0].alts)
|
||||
@@ -2141,7 +2141,7 @@ def test_render_map_labels_take_the_name_hue_ours_white() -> None:
|
||||
assert _glyph_color(lines, "★") == mark_rgb(SELF_MARK[1]) # the colour of our star
|
||||
assert _glyph_color(lines, "US") == (255, 255, 255) # ...the label is the white of you
|
||||
assert _glyph_color(lines, "KEYED") == name_rgb("KEYED", "d4" * 32)
|
||||
assert _glyph_color(lines, "BARE") == (148, 163, 184) # no key: the muted grey
|
||||
assert _glyph_color(lines, "BARE") == (162, 162, 162) # no key: the muted grey
|
||||
|
||||
|
||||
def test_render_map_find_matches_still_label_white() -> None:
|
||||
|
||||
@@ -132,7 +132,7 @@ def test_paths_screen_shows_unknown_relay_as_grey_mode_width_hash() -> None:
|
||||
lines = screen.render_body(76)
|
||||
row = next(ln for ln in lines if "e839f2" in _plain([ln]))
|
||||
assert "(e8)" not in _plain([row]) # the identity with the mode width is alone
|
||||
assert "38;2;148;163;184" in row # muted grey over the hash
|
||||
assert "38;2;162;162;162" in row # muted grey over the hash
|
||||
assert not _plain([row]).startswith("❯") # not selected, so no highlight on it
|
||||
graph = _plain(lines).split("origin →")[0]
|
||||
assert "e8" in graph # the byte of the row still matches the label in the graph
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
"""Make sure that each grey that MeshTerm defines is neutral: red, green, and blue are equal.
|
||||
|
||||
A grey is chrome or an absence (``muted``, ``faint``, a keyless chip, a minor road), and
|
||||
it must not have a hue. Tailwind's slate greys were cold, and a cold grey on each screen
|
||||
added one more colour that had no meaning (JP, 2026-10-14). Thus a colour that the eye
|
||||
reads as a grey must be ``#rrggbb`` with ``rr == gg == bb``.
|
||||
|
||||
The test reads each ``#rrggbb`` string literal in the package and measures its chroma in
|
||||
OKLab. Below :data:`GREY_CHROMA`, the colour is a grey, and it must be neutral. The
|
||||
docstrings are not read, because an example in a docstring is not a colour that MeshTerm
|
||||
draws. The archived console palette (``theme._VT_SLOTS_CUSTOM``) is not read, because it
|
||||
is a record of what shipped first, and MeshTerm does not install it.
|
||||
"""
|
||||
|
||||
import ast
|
||||
import math
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from meshterm.ui import oklab
|
||||
from tests.conftest import not_ignored
|
||||
|
||||
PACKAGE = Path(__file__).parent.parent / "meshterm"
|
||||
|
||||
#: The OKLab chroma below which the eye reads a colour as a grey. The coldest slate that
|
||||
#: MeshTerm used (``#64748b``) measured 0.041. The dimmest colour that has a meaning (the
|
||||
#: dark green of a park on the map, ``#173a29``) measures 0.051.
|
||||
GREY_CHROMA = 0.045
|
||||
|
||||
_HEX = re.compile(r"#([0-9a-fA-F]{6})\b")
|
||||
|
||||
#: The assignments that the test does not read (refer to the module docstring).
|
||||
_ARCHIVED = {"_VT_SLOTS_CUSTOM"}
|
||||
|
||||
|
||||
def _skipped_nodes(tree: ast.AST) -> set[int]:
|
||||
"""The ids of the docstring nodes and of each node in an archived assignment."""
|
||||
skipped: set[int] = set()
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, ast.Expr) and isinstance(node.value, ast.Constant):
|
||||
skipped.add(id(node.value))
|
||||
targets = (
|
||||
node.targets
|
||||
if isinstance(node, ast.Assign)
|
||||
else [node.target]
|
||||
if isinstance(node, ast.AnnAssign)
|
||||
else []
|
||||
)
|
||||
if any(isinstance(t, ast.Name) and t.id in _ARCHIVED for t in targets):
|
||||
skipped.update(id(n) for n in ast.walk(node))
|
||||
return skipped
|
||||
|
||||
|
||||
def _literal_colours() -> list[tuple[str, int, str]]:
|
||||
"""Each ``#rrggbb`` in a string literal of the package: (file, line, colour)."""
|
||||
found = []
|
||||
for path in not_ignored(sorted(PACKAGE.rglob("*.py"))):
|
||||
tree = ast.parse(path.read_text(encoding="utf-8"))
|
||||
skipped = _skipped_nodes(tree)
|
||||
for node in ast.walk(tree):
|
||||
if (
|
||||
isinstance(node, ast.Constant)
|
||||
and isinstance(node.value, str)
|
||||
and id(node) not in skipped
|
||||
):
|
||||
for match in _HEX.finditer(node.value):
|
||||
found.append((str(path.relative_to(PACKAGE.parent)), node.lineno, match.group(1)))
|
||||
return found
|
||||
|
||||
|
||||
def test_the_scan_finds_the_greys_of_the_theme() -> None:
|
||||
"""The scan reads the theme. If it does not, the main test passes with no meaning."""
|
||||
colours = {colour.lower() for _, _, colour in _literal_colours()}
|
||||
assert {"a2a2a2", "737373", "404040"} <= colours
|
||||
|
||||
|
||||
def test_each_grey_is_neutral() -> None:
|
||||
"""A colour with almost no chroma must have equal red, green, and blue."""
|
||||
tinted = []
|
||||
for file, line, colour in _literal_colours():
|
||||
_, a, b = oklab.from_hex(colour)
|
||||
r, g, b_ = (int(colour[i : i + 2], 16) for i in (0, 2, 4))
|
||||
if math.hypot(a, b) < GREY_CHROMA and not r == g == b_:
|
||||
tinted.append(f" {file}:{line}: #{colour}")
|
||||
assert not tinted, (
|
||||
"These greys have a tint. Make each one r=g=b at the same OKLab lightness, or, if "
|
||||
"the colour has a meaning, give it more chroma:\n" + "\n".join(tinted)
|
||||
)
|
||||
+1
-1
@@ -18,7 +18,7 @@ def test_every_node_fill_round_trips_through_oklab_exactly() -> None:
|
||||
for byte in range(256):
|
||||
colour = _fill(f"{byte:02x}")
|
||||
assert oklab.to_hex(oklab.from_hex(colour)) == colour
|
||||
for grey in ("#000000", "#ffffff", "#64748b", "#334155", "#3f3f46"):
|
||||
for grey in ("#000000", "#ffffff", "#a2a2a2", "#737373", "#404040"):
|
||||
assert oklab.to_hex(oklab.from_hex(grey)) == grey
|
||||
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ def test_a_key_lane_s_lit_hash_folds_with_the_name_it_belongs_to() -> None:
|
||||
hues = _hues(render_to_ansi(row, 30))
|
||||
|
||||
assert node_style(_KEY).removeprefix("bold ") not in hues
|
||||
assert "#94a3b8" in hues, "the unlit tail of the key is muted and stays muted"
|
||||
assert "#a2a2a2" in hues, "the unlit tail of the key is muted and stays muted"
|
||||
|
||||
|
||||
def test_the_highlight_does_not_claim_to_know_an_unidentified_node() -> None:
|
||||
@@ -123,7 +123,7 @@ def test_the_highlight_does_not_claim_to_know_an_unidentified_node() -> None:
|
||||
row.append("3d", style="node.unknown")
|
||||
row.style = "cursor"
|
||||
|
||||
assert "#94a3b8" in _hues(render_to_ansi(row, 30))
|
||||
assert "#a2a2a2" in _hues(render_to_ansi(row, 30))
|
||||
|
||||
|
||||
def test_the_highlight_leaves_every_other_lane_its_own_colour() -> None:
|
||||
@@ -152,7 +152,7 @@ def test_a_path_line_s_chips_keep_their_fills_on_the_cursor_row() -> None:
|
||||
"""
|
||||
fill = node_style(_KEY).removeprefix("bold ")
|
||||
row = Text(" ")
|
||||
row.append(" Lakeside ", style=f"#0f172a on {fill}")
|
||||
row.append(" Lakeside ", style=f"#181818 on {fill}")
|
||||
row.style = "cursor"
|
||||
|
||||
assert f"48;2;{int(fill[1:3], 16)};" in render_to_ansi(row, 40)
|
||||
@@ -306,7 +306,7 @@ def test_every_hue_a_key_can_mint_is_recognised_as_one(platform) -> None: # noq
|
||||
"heat.now",
|
||||
"err",
|
||||
"bold #ffffff",
|
||||
"#94a3b8",
|
||||
"#a2a2a2",
|
||||
"",
|
||||
"none",
|
||||
],
|
||||
|
||||
@@ -245,9 +245,9 @@ def test_fold_keeps_ansi_sequences_intact() -> None:
|
||||
def test_fold_quantizes_embedded_truecolor_to_the_slots() -> None:
|
||||
"""Truecolour from the canvas (the braille rasters) goes to the nearest palette slot."""
|
||||
set_platform(PICOCALC_LYRA)
|
||||
folded = fold_text("\x1b[38;2;148;163;184m○\x1b[0m")
|
||||
folded = fold_text("\x1b[38;2;162;162;162m○\x1b[0m")
|
||||
assert "38;2;" not in folded
|
||||
# #94a3b8 → the nearest stock slot is 7 (#aaaaaa). A slot in the dim bank states its
|
||||
# #a2a2a2 → the nearest stock slot is 7 (#aaaaaa). A slot in the dim bank states its
|
||||
# intensity.
|
||||
assert "\x1b[22;37m" in folded
|
||||
background = fold_text("\x1b[48;2;94;234;212mX\x1b[0m")
|
||||
@@ -397,7 +397,7 @@ def test_canvas_drops_emphasis_where_bold_means_brightness() -> None:
|
||||
for platform, expect_bold in ((REGULAR, True), (PICOCALC_LYRA, False)):
|
||||
set_platform(platform)
|
||||
canvas = MapCanvas(6, 1)
|
||||
canvas.marker(0, 0, "x", (148, 163, 184)) # markers always draw in bold
|
||||
canvas.marker(0, 0, "x", (162, 162, 162)) # markers always draw in bold
|
||||
rendered = "".join(canvas.to_ansi_lines())
|
||||
assert ("\x1b[1m" in rendered) is expect_bold, (platform.name, repr(rendered))
|
||||
# The colour that the canvas received stays the same: a slot in the dim bank with its
|
||||
|
||||
@@ -271,8 +271,8 @@ def test_name_rgb_keyless_lands_on_the_muted_grey() -> None:
|
||||
"""The raster twin: the RGB of a keyless name is the muted grey, and never a crash."""
|
||||
from meshterm.ui.widgets import name_rgb
|
||||
|
||||
assert name_rgb("Stranger") == (148, 163, 184)
|
||||
assert name_rgb("Alice", "d4" + "0" * 62) != (148, 163, 184)
|
||||
assert name_rgb("Stranger") == (162, 162, 162)
|
||||
assert name_rgb("Alice", "d4" + "0" * 62) != (162, 162, 162)
|
||||
|
||||
|
||||
def test_route_graph_source_label_takes_its_resolved_keys_hue() -> None:
|
||||
@@ -294,7 +294,7 @@ def test_route_graph_source_label_takes_its_resolved_keys_hue() -> None:
|
||||
self_name="us",
|
||||
source="Alice",
|
||||
)
|
||||
assert rgb_unknown(SRC_NODE) == (148, 163, 184) # an origin that cannot be resolved stays muted
|
||||
assert rgb_unknown(SRC_NODE) == (162, 162, 162) # an origin that cannot be resolved stays muted
|
||||
|
||||
|
||||
def test_revisit_note_names_the_repeats_and_refuses_to_guess_why() -> None:
|
||||
@@ -350,7 +350,7 @@ def test_name_chip_draws_us_as_the_star_never_as_our_name(powerline) -> None:
|
||||
chip = name_chip("you", you=True)
|
||||
|
||||
assert "★" in chip.plain and "you" not in chip.plain
|
||||
assert _span_style(chip, "★").bgcolor.name == "#3f3f46" # a neutral grey, not a hue
|
||||
assert _span_style(chip, "★").bgcolor.name == "#404040" # a neutral grey, not a hue
|
||||
|
||||
|
||||
def test_self_chip_is_white_on_the_fill_of_our_key(powerline) -> None:
|
||||
@@ -432,7 +432,7 @@ def test_name_chip_greys_a_node_it_cannot_place(powerline) -> None:
|
||||
powerline(True)
|
||||
keyless = name_chip("·")
|
||||
|
||||
assert _span_style(keyless, "·").bgcolor.name == "#64748b" # the keyless grey
|
||||
assert _span_style(keyless, "·").bgcolor.name == "#737373" # the keyless grey
|
||||
|
||||
|
||||
def test_a_chat_chip_with_no_key_is_black_on_grey(powerline) -> None:
|
||||
|
||||
Reference in new issue
Block a user