Skip to content

Commit

Permalink
flip order
Browse files Browse the repository at this point in the history
  • Loading branch information
Strilanc committed May 29, 2024
1 parent 37f4663 commit ea63c5a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions glue/crumble/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ button (now labelled "Hide Import/Export") again.
- `ctrl+v`: Past clipboard contents at current selection (or entire layer if nothing selected).
- `ctrl+x`: Cut selection to clipboard (or entire layer if nothing selected).
- `f`: Flip qubit order of selected operations (e.g. flip the control-to-target direction of a CNOT).
- `shift+f`: Flip order of all circuit layers, starting from the current layer until the next empty layer.
- `home`: Jump to the first layer of the circuit.
- `end`: Jump to the last layer of the circuit.
- `t`: Rotate circuit 45 degrees clockwise.
Expand Down
16 changes: 16 additions & 0 deletions glue/crumble/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,22 @@ function makeChordHandlers() {
}
editorState.commit_or_preview(newCircuit, preview);
});
res.set('shift+f', preview => {
let newCircuit = editorState.copyOfCurCircuit();
let end = editorState.curLayer;
while (end < newCircuit.layers.length && !newCircuit.layers[end].empty()) {
end += 1;
}
let layers = [];
for (let k = editorState.curLayer; k < end; k++) {
layers.push(newCircuit.layers[k]);
}
layers.reverse();
for (let k = editorState.curLayer; k < end; k++) {
newCircuit.layers[k] = layers[k - editorState.curLayer];
}
editorState.commit_or_preview(newCircuit, preview);
});
res.set('shift+>', preview => editorState.applyCoordinateTransform((x, y) => [x + 1, y], preview));
res.set('shift+<', preview => editorState.applyCoordinateTransform((x, y) => [x - 1, y], preview));
res.set('shift+v', preview => editorState.applyCoordinateTransform((x, y) => [x, y + 1], preview));
Expand Down

0 comments on commit ea63c5a

Please sign in to comment.