diff --git a/AGENTS.md b/AGENTS.md
index c59cbae..d7e3943 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -56,8 +56,8 @@ when W110 puts the regions in zooms of their own, their groups get a note instea
- Ranges are inclusive: end = start + size - 1.
- Prefer `size` over `end`, and sequential placement over explicit `start`.
- Display tweaks go in `view`, never by changing `memory`.
-- The look is fixed on purpose: font family, address format, outlines, connectors and label side
- have no keys.
+- The look is fixed on purpose: font family, address format, outlines and label side have no
+ keys. Connectors only choose solid or dashed lines (`style.connectors`).
- Use `--strict` on `check` and `render` to fail on warnings. Without it they exit 0 with
warnings, and a flash sector misalignment (W100) or colliding text (W106) is a warning.
- PNG and PDF need the `raster` extra and the system cairo library. Without cairo, `render`
@@ -68,6 +68,7 @@ when W110 puts the regions in zooms of their own, their groups get a note instea
- Boundary + prev end: view.defaults.labels.address: both
- Hide addresses: view.defaults.labels.address: none
- Zoom into a region: view.expand: [region_id]
+- Dashed zoom lines: style.connectors: dashed
- Title a column: view.columns: [{ id: a, root: flash, title: Flash }]
- Title a zoom: view.expand: [{ region: flash, title: Flash }]
- Datasheet look: style.palette: datasheet, view.defaults.scale.mode: equal
diff --git a/README.md b/README.md
index 280389e..05d1933 100644
--- a/README.md
+++ b/README.md
@@ -161,7 +161,7 @@ scripts and agents.
| [nrf52840_boot_chain.yaml](examples/nrf52840_boot_chain.yaml) | Chained zooms, column `range`, per-column labels and scale, `start_of_next` |
| [riscv64_soc.yaml](examples/riscv64_soc.yaml) | 64-bit addresses, `collapse_reserved_over`, relative heights, style options |
| [rtos_mpu_ram.yaml](examples/rtos_mpu_ram.yaml) | `check_alignment`, `fill_gaps: none`, `depth`, two columns of one memory |
-| [ota_package_format.yaml](examples/ota_package_format.yaml) | A file format instead of memory: `address: none`, byte sizes, a zoom to the left |
+| [ota_package_format.yaml](examples/ota_package_format.yaml) | A file format instead of memory: `address: none`, byte sizes, a dashed zoom to the left |
To render them all into `build/`:
diff --git a/examples/ota_package_format.yaml b/examples/ota_package_format.yaml
index eef871b..33ca8a7 100644
--- a/examples/ota_package_format.yaml
+++ b/examples/ota_package_format.yaml
@@ -39,4 +39,4 @@ view:
expand:
- { region: header, from: package_col, to: header_col }
-style: { palette: color }
+style: { palette: color, connectors: dashed }
diff --git a/memmap/layout/__init__.py b/memmap/layout/__init__.py
index d5bbbed..9ef62a8 100644
--- a/memmap/layout/__init__.py
+++ b/memmap/layout/__init__.py
@@ -368,7 +368,8 @@ def layout_figure(
target = by_id[link.target.id]
pieces = [block for block in source.blocks if block.node is link.region]
between = lanes_between(layouts, source.lane, target.lane)
- lines, clear = connector_lines(pieces, target, [column_box(other) for other in between])
+ boxes = [column_box(other) for other in between]
+ lines, clear = connector_lines(pieces, target, boxes, style.connectors == "dashed")
primitives += lines
if not clear:
out.append(_through_columns(link.region.id, link.region.path, target, between))
diff --git a/memmap/layout/connectors.py b/memmap/layout/connectors.py
index 8e7f7d3..398bcb1 100644
--- a/memmap/layout/connectors.py
+++ b/memmap/layout/connectors.py
@@ -6,13 +6,16 @@
from .primitives import INK, Polyline
from .routing import Box, make_fan, route, straight
+DASH = "4 3" # px on, px off, for style.connectors: dashed
+
def connector_lines(
- source_blocks: list[Block], target: ColumnLayout, between: list[Box]
+ source_blocks: list[Block], target: ColumnLayout, between: list[Box], dashed: bool = False
) -> tuple[list[Polyline], bool]:
"""One line for the top edge and one for the bottom edge of the expanded region. Each is
straight, or bent at a corner to go around `between`, the columns in the lanes the lines
- cross. The flag is False when they cannot go around and run straight through them."""
+ cross. The flag is False when they cannot go around and run straight through them. With
+ `dashed` the lines are drawn dashed."""
top = min(block.y for block in source_blocks)
bottom = max(block.y + block.h for block in source_blocks)
left = source_blocks[0].x
@@ -21,4 +24,5 @@ def connector_lines(
clear = lines is not None
if lines is None:
lines = straight(fan)
- return [Polyline(points, INK) for points in lines], clear
+ dash = DASH if dashed else None
+ return [Polyline(points, INK, dash=dash) for points in lines], clear
diff --git a/memmap/layout/primitives.py b/memmap/layout/primitives.py
index 5fecbb8..738dbe8 100644
--- a/memmap/layout/primitives.py
+++ b/memmap/layout/primitives.py
@@ -40,11 +40,13 @@ class Line:
@dataclass
class Polyline:
- """A line through a list of points, as used for fan lines."""
+ """A line through a list of points, as used for fan lines. `dash` is an SVG dash pattern
+ such as "4 3"; None draws a solid line."""
points: list[tuple[float, float]]
stroke: str
width: float = 1
+ dash: str | None = None
@dataclass
diff --git a/memmap/render/svg.py b/memmap/render/svg.py
index 1fc5bac..8756f4a 100644
--- a/memmap/render/svg.py
+++ b/memmap/render/svg.py
@@ -65,6 +65,8 @@ def _element(primitive: Primitive) -> str:
"stroke": primitive.stroke,
"stroke-width": primitive.width,
}
+ if primitive.dash is not None:
+ values["stroke-dasharray"] = primitive.dash
return f""
if isinstance(primitive, Text):
values = {
diff --git a/memmap/schema.py b/memmap/schema.py
index db8a8f4..25b8fe4 100644
--- a/memmap/schema.py
+++ b/memmap/schema.py
@@ -313,6 +313,9 @@ class Style(Model):
sector_ticks: bool = Field(
default=True, description="Draw tick marks at flash sector boundaries.", examples=[False]
)
+ connectors: Literal["solid", "dashed"] = Field(
+ default="solid", description="Line style of the zoom fan lines.", examples=["dashed"]
+ )
class ColumnStyle(Model):
diff --git a/tests/golden/example_ota_package.svg b/tests/golden/example_ota_package.svg
index 00c1af6..6c83cde 100644
--- a/tests/golden/example_ota_package.svg
+++ b/tests/golden/example_ota_package.svg
@@ -2,8 +2,8 @@
OTA update package format
-
-
+
+
Header fields
Package
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 60a8fb0..ff14d1a 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -295,6 +295,7 @@ def test_group_help_points_to_the_guide():
["view.defaults.labels.address=both"],
["view.defaults.labels.address=none"],
["view.columns[0]={id: a, root: /}", "view.expand=[flash]"],
+ ["view.columns[0]={id: a, root: /}", "view.expand=[flash]", "style.connectors=dashed"],
["view.columns[0]={id: a, root: flash, title: Flash}"],
["view.columns[0]={id: a, root: /}", "view.expand=[{region: flash, title: Flash}]"],
["style.palette=datasheet", "view.defaults.scale.mode=equal"],
diff --git a/tests/test_layout.py b/tests/test_layout.py
index 3238f48..8af02b0 100644
--- a/tests/test_layout.py
+++ b/tests/test_layout.py
@@ -6,11 +6,13 @@
from memmap.describe import describe_data
from memmap.layout.columns import LANE_STACK_GAP, MAX_STRETCH
+from memmap.layout.connectors import DASH
from memmap.layout.primitives import Line, Polyline
from memmap.layout.routing import _clear, column_box
from memmap.layout.text import text_width, wrap
from memmap.options import OptionResolver
from memmap.pipeline import run
+from memmap.render.svg import render_svg
def blocks(result, column=0):
@@ -171,6 +173,14 @@ def test_negative_offset_stays_on_the_canvas():
assert blocks(result)[-1].y > 0
+@pytest.mark.parametrize("style, dash", [("solid", None), ("dashed", DASH)])
+def test_connector_style_sets_the_dash_of_every_fan_line(style, dash):
+ result = run(ROOT / "examples" / "stm32f303_fig8.yaml", [f"style.connectors={style}"])
+ lines = [p for p in drawn(result).primitives if isinstance(p, Polyline)]
+ assert lines and all(line.dash == dash for line in lines)
+ assert ("stroke-dasharray" in render_svg(drawn(result))) == (dash is not None)
+
+
def test_connectors_run_corner_to_corner():
from memmap.layout.primitives import Polyline