Skip to content

Host-pushed styling: style_response for nets, instances and pins - #47

Merged
xtofalex merged 1 commit into
mainfrom
host-styling
Nov 14, 2026
Merged

xtofalex merged 1 commit into
mainfrom
host-styling

Conversation

@xtofalex

Copy link
Copy Markdown
Contributor

What

A host can now style the netlist it shows: colors, stroke widths, fills and labels on nets, instances and pins. For example, a fanout-fix report showing the enable net in orange, each driver copy's net in its own color, and the sinks tinted to match, with no SVG post-processing.

Wire format

A new style_response server push:

{ "response": "style_response",
  "items": [ { "kind": "net", "id_path": [3], "path": ["drv_0"], "terminal": "O", "bit": 0,
               "color": "#1f77b4", "width": 2.5, "fill": "#1f77b455", "label": "copy 0" } ] }
  • net: every wire of the net through that pin (color, width, label on the wire)
  • instance: body fill (#rrggbbaa tints the default fill), outline color/width, label replaces the drawn name
  • term: the pin's tick color/width, label replaces its name

Items on the same object merge in order.

Viewer (C++)

  • StyleStore (same static-store pattern as DiagnosisStore), cleared on every root load. Hosts re-send styles after each root_response, like diagnoses.
  • Applied in EquipotentialView while building shapes and drawn by SchematicView through the painter, so styles show on screen, in File > Export SVG, in native --export and in the headless renderer.
  • Color precedence: diagnosis colors win over style colors, which win over trace colors (a trace's own color, the convergence outline and the shared-net stripes). Width, fill and label apply whatever the color, and the selection is drawn on top.
  • Native: --style <file> (loadStyleFile()), also used by --export.

Python

  • style(items) on ViewerSession, ViewerServer and Schematic; show(style=), design_changed(style=), export_svg(style=) / export_svgs jobs, naja_schematic.style_response().
  • --style styles.json on the naja-schematic server and render CLIs.
  • Items are resolved up front: a bad one raises ValueError instead of being silently skipped. An item can use "target", taking anything show_instance()/show_net() accept.
  • The viewer only knows the pins it draws, so each net item is sent once per bit on its net's driver (a top-level port, else an output leaf pin). A net named through a hierarchical pin, or shown only partly by a trace, still matches.

Limits

  • Wiring nested inside an expanded instance isn't styled.
  • Net labels aren't avoided by the router, so they can overlap nearby wires.
  • Natively, --style only checks the file's format; an item naming a missing instance just doesn't match.

Tests

  • tests/StyleStoreTest.cpp: parsing, matching, merging, the shapes and SVG output, and the diagnosis > style > trace precedence.
  • python/tests/test_style.py: item validation, resolution to the driver (hierarchical pin, bus → per bit), re-push after each root, and an end-to-end naja-schematic render --style on tests/data/fanout.v checking the orange/blue/green/purple strokes and tinted sinks in the SVG.
  • Locally: 270 C++ tests and 233 Python tests pass (test_notebook.py not run), reuse lint is clean, and native --export --style was checked by eye. The WASM build wasn't run.

Note: the Debug-build renderer aborts on an ImGui font-atlas assert and fails 3 existing test_render.py tests on main too. That's unrelated to this PR; the Release renderer passes everything.

Colors, stroke widths, fills and labels a host puts on the netlist,
kept in StyleStore, re-sent after every root load like diagnoses, and
drawn through the painter so they reach SVG and headless exports.
Precedence: diagnosis > style > trace colors.

Python: style() on ViewerSession/ViewerServer/Schematic, show(style=),
export_svg(style=), --style on the server and render CLIs; net items
are resolved to their net's driver, per bit. Native: --style, kept by
--export.
@xtofalex
xtofalex merged commit b59eadf into main Nov 14, 2026
27 of 28 checks passed
@xtofalex
xtofalex deleted the host-styling branch November 14, 2026 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant