diff --git a/README.md b/README.md index 0d0f8c0..7a3f92c 100644 --- a/README.md +++ b/README.md @@ -6,18 +6,22 @@ Nuxt 4 (client-only editor, `ssr: false`), Tailwind CSS v4, Lucide icons via `@n ## What it does -- Parts: NAND, input switch, output pin, lamp, push button, clock, constant 1, ground, hex display, note. +- Parts: NAND, input switch, output pin, lamp, push button, clock, constant 1, ground, hex display, input panel, note. +- Input panel: one part with a column of controls; each row is a switch, button or clock. "Attach input panel" on a placed component docks one to its left with a row per free input, lined up with the pins and named after them. A docked panel moves with its component, gets a row when the component gains an input and loses it when the pin goes; inputs that are wired elsewhere, and rows you remove, are left alone. Inside a component a switch row keeps its position and a button row is 0. +- Automatic names: copies continue a series (D0 copied gives D1, D2; A gives B), and so does placing a new input or output after a numbered one. A switch, button, lamp or output pin without a name of its own (or with an automatic one) takes the name of the component pin it gets wired to, made unique (Cin, Cin2); a name typed by hand is kept. - Every circuit is a component. Its input and output nodes become its pins, ordered top to bottom. Double-click a component to open it. - Lamps and hex displays inside a component show on its box, with their labels, lit by that instance's state. They are laid out in rows the way they sit inside. A checkbox in the inspector turns this off per component. - Clicking anything opens its settings on the right. Parts can be swapped in place (wires stay on the pins in the same position): NAND and components with each other, switch/button/clock/constants with each other, output/lamp/display with each other. Clocks have their own frequency or follow the top bar. Switches and buttons can get a keyboard key. Lamps and displays have colours, notes have sizes, components a name on the canvas. Components can be unpacked into their parts or given their own copy of the definition; any part can have all its wires unlinked. - Select parts and press "Make component" to turn them into a new component; wires crossing the selection become pins. - Gate symbols in IEC 60617 (DIN, default) or ANSI. A component with one output can be drawn as a gate symbol. - Wires of different signals never share a line: auto-routed wires pick a free column or a detour, and anything still clashing (hand-placed bends) is drawn on its own lane. Crossings are drawn as a bow, triangle, bridge, gap or plain crossing (Display settings on the right with nothing selected). Clicking a junction dot selects its whole signal. +- Connecting: drag from a pin, or click a pin and then the other one. While a wire is drawn, every pin it can go to is ringed (dashed when it already has a wire, which would be replaced); dropping it on a part uses that part's next free pin. "Connect one by one" (W, or the button with several parts selected; on a component "Wire one by one: Inputs / Outputs") numbers the pins of the selection top to bottom and wires them in turn, one click each; clicking the same component again and again fills its pins in order. +- Tidy wiring (Display settings, or "Tidy all wires", which also drops hand-placed bends): every forward wire takes its vertical step in the free gap right in front of the part it feeds, wires sharing a gap get their own evenly spaced column in the order that crosses least, and one signal shares one trunk. On the 4-bit adder without hand routing this cuts crossings from 32 to 18. - Wire editing: drag any segment (a stub keeps the pin end straight), drag corner squares, Alt+drag to pull out a new bend, Ctrl+drag to branch a new wire off a signal, double-click to select the whole signal, Shift+click and box selection for several wires, arrow keys to shift them, six colour tags. - Several projects per browser (Projects dialog: open, rename, duplicate, delete). Export a project file, open a file as a new project, or add the components of a file to the open project. - Accounts: email and password. Signed in, every project in the browser is also kept in the account and synced in both directions (on sign-in, on focus, every minute, and two seconds after a change). If two computers changed the same project, both versions are kept. The untouched starter project of a new browser is not uploaded; signing in there opens your latest project instead. - Share links: `/p/`. The creator's changes save to the link automatically. Anyone else who opens it gets their own copy; their first edit detaches it from the link. -- Truth table, NAND count, gate delay, and loop detection for the open circuit. +- Truth table, NAND count, gate delay, and loop detection for the open circuit. The table can go full screen, be downloaded as CSV or copied as a Markdown table; the row the switches are set to is highlighted. - 17 challenges (NOT up to a D flip-flop) checked against a truth table or a step sequence. - Example library, all built from NAND: NOT, AND, OR, NOR, XOR, XNOR, Mux, Half/Full Adder, SR Latch, D Latch, D Flip-Flop, Register 4, Increment 4, Adder 4, Counter 4, and a counter demo with a hex display. @@ -30,7 +34,8 @@ All in [app/lib/logic/](app/lib/logic/), plain TypeScript with no Vue dependency - Gate outputs are keyed by their path ("chipNode/chipNode/nand"), so latch state survives editing. - `analyze.ts` builds truth tables, counts NANDs, computes the longest gate path, and runs challenge tests. - `examples.ts` builds the example library with a small builder; `ops.ts` holds project edits (package selection, copy/paste, prune dangling wires, recursion check). -- `routing.ts` lays out all wires of a circuit (free lanes, detours, separation, crossings). +- `routing.ts` lays out all wires of a circuit (free lanes, detours, separation, crossings, and the tidy layout). +- `panels.ts` docks input panels to components and keeps them in step; `labels.ts` does series names and names taken from pins. - `wires.ts` edits wire routes (segment and corner drags, splits, branches); `project.ts` validates project data for both the browser and the server; `storage.ts` is the browser's project library. The editor UI is in [app/components/editor/](app/components/editor/) with state in [app/composables/useEditor.ts](app/composables/useEditor.ts). diff --git a/app/assets/css/main.css b/app/assets/css/main.css index 0725841..b2bd1a5 100644 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -1019,6 +1019,78 @@ kbd { fill: rgb(76 194 255 / 0.3); } +/* Where a wire being drawn can go. */ +.pin-target { + fill: none; + stroke: var(--accent); + stroke-width: 1.5; + opacity: 0.75; + pointer-events: none; +} + +.pin-target.taken { + stroke: var(--muted); + stroke-dasharray: 2 2; + opacity: 0.45; +} + +.pin-snap { + fill: rgb(76 194 255 / 0.25); + stroke: var(--accent); + stroke-width: 2; + pointer-events: none; +} + +.queue-badge { + pointer-events: none; +} + +.queue-badge rect { + fill: var(--panel-2); + stroke: var(--border); +} + +.queue-badge text { + fill: var(--muted); + font-family: var(--font-mono); + font-size: 9px; + font-weight: 600; +} + +.queue-badge.current rect { + fill: var(--accent); + stroke: var(--accent); +} + +.queue-badge.current text { + fill: var(--bg); +} + +/* Input panel */ +.node .body.panel { + fill: #161d27; +} + +.node .body.panel.docked { + stroke: #4f7fa3; +} + +.panel-row { + cursor: pointer; +} + +.panel-row .row-hit { + fill: transparent; +} + +.panel-row:hover .row-hit { + fill: rgb(255 255 255 / 0.04); +} + +.panel-row .pin-label.named { + fill: var(--text); +} + .zoom-controls { position: absolute; right: 12px; @@ -1486,3 +1558,54 @@ kbd { .modal .hint a { color: var(--accent); } + +/* ── Truth table, full screen ───────────────────────────────────── */ +.modal.table-modal { + display: flex; + flex-direction: column; + width: min(1100px, 100%); + height: calc(100dvh - 32px); + overflow: hidden; +} + +.truth.large { + flex: 1; + max-height: none; + min-height: 0; +} + +.truth.large table { + font-size: 14px; +} + +.truth.large th, +.truth.large td { + padding: 5px 10px; +} + +.truth tr.current td { + background: rgb(76 194 255 / 0.12); +} + +/* ── Panel rows in the inspector ────────────────────────────────── */ +.panel-rows { + display: grid; + gap: 4px; + margin-bottom: 6px; +} + +.panel-rows li { + display: flex; + align-items: center; + gap: 4px; +} + +.panel-rows input, +.panel-rows select { + min-width: 0; + flex: 1; +} + +.panel-rows input.hz { + flex: 0 0 56px; +} diff --git a/app/components/editor/App.vue b/app/components/editor/App.vue index 0d8e211..0caf70d 100644 --- a/app/components/editor/App.vue +++ b/app/components/editor/App.vue @@ -1,6 +1,12 @@