Skip to content

Commit

Permalink
keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Strilanc committed May 29, 2024
1 parent 71183a4 commit fff6dda
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
22 changes: 19 additions & 3 deletions glue/crumble/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ button (now labelled "Hide Import/Export") again.

**Editing**

- `e`: Move to next layer.
- `q`: Move to previous layer.
- `shift+e`: Move forward 10 layers.
- `shift+q`: Move backward 10 layers.
- `escape`: Unselect. Set current selection to the empty set.
- `delete`: Delete gates at current selection.
- `backspace`: Delete gates at current selection.
Expand All @@ -112,11 +116,13 @@ button (now labelled "Hide Import/Export") again.
- `ctrl+z`: Undo
- `ctrl+y`: Redo
- `ctrl+shift+z`: Redo
- `ctrl+c`: Copy selection to clipboard.
- `ctrl+v`: Past clipboard contents at current selection.
- `ctrl+x`: Cut selection to clipboard.
- `ctrl+c`: Copy selection to clipboard (or entire layer if nothing selected).
- `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).
- `t`: Rotate circuit 45 degrees clockwise.
- `shift+t`: Rotate circuit 45 degrees counter-clockwise.
- `home`: Jump to the first layer of the circuit.
- `end`: Jump to the last layer of the circuit.

**Single Qubit Gates**

Expand All @@ -138,6 +144,9 @@ Note: use `shift` to get the inverse of a gate.
- `m+r+y`: Overwrite selection with `MRY` gate
- `m+r`: Overwrite selection with `MR` gate
- `f`: Overwrite selection with `C_XYZ` gate
- `j+x`: Overwrite selection with **j**ust a Pauli `X` gate
- `j+y`: Overwrite selection with **j**ust a Pauli `Y` gate
- `j+z`: Overwrite selection with **j**ust a Pauli `Z` gate

**Two Qubit Gates**

Expand Down Expand Up @@ -165,6 +174,12 @@ Note: use `shift` to get the inverse of a gate.
- `c+m+y`: Overwrite selection with `MYY` gate targeting mouse
- `c+m+z`: Overwrite selection with `MZZ` gate targeting mouse

**Multi Qubit Gates**

- `m+p+x`: Overwrite selection with a single `MPP` gate targeting the tensor product of X on each selected qubit.
- `m+p+y`: Overwrite selection with a single `MPP` gate targeting the tensor product of Y on each selected qubit.
- `m+p+z`: Overwrite selection with a single `MPP` gate targeting the tensor product of Z on each selected qubit.

**Keyboard Buttons as Gate Adjectives**

Roughly speaking, the "keyboard language" for gates used by Crumble has the following "adjectives":
Expand All @@ -179,6 +194,7 @@ Roughly speaking, the "keyboard language" for gates used by Crumble has the foll
- `r` means "reset"
- `w` means "swap"
- `alt` means "no not that one, a different one"
- `j` means "just"

Here are some examples:

Expand Down
22 changes: 17 additions & 5 deletions glue/crumble/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,14 @@ function makeChordHandlers() {
res.set('ctrl+v', pasteFromClipboard);
res.set('ctrl+x', async preview => {
await copyToClipboard();
editorState.deleteAtFocus(preview);
if (editorState.focusedSet.size === 0) {
let c = editorState.copyOfCurCircuit();
c.layers[editorState.curLayer].id_ops.clear();
c.layers[editorState.curLayer].markers.length = 0;
editorState.commit_or_preview(c, preview);
} else {
editorState.deleteAtFocus(preview);
}
});
res.set('l', preview => {
if (!preview) {
Expand Down Expand Up @@ -270,6 +277,9 @@ function makeChordHandlers() {
addGateChords(['c+x'], "CX", "CX");
addGateChords(['c+y'], "CY", "CY");
addGateChords(['c+z'], "CZ", "CZ");
addGateChords(['j+x'], "X", "X");
addGateChords(['j+y'], "Y", "Y");
addGateChords(['j+z'], "Z", "Z");
addGateChords(['c+x+y'], "XCY", "XCY");
addGateChords(['alt+c+x'], "XCX", "XCX");
addGateChords(['alt+c+y'], "YCY", "YCY");
Expand Down Expand Up @@ -385,12 +395,14 @@ const CHORD_HANDLERS = makeChordHandlers();
function handleKeyboardEvent(ev) {
editorState.chorder.handleKeyEvent(ev);
if (ev.type === 'keydown') {
if (ev.key === 'q' || ev.key === 'Q') {
editorState.changeCurLayerTo(editorState.curLayer - 1);
if (ev.key.toLowerCase() === 'q') {
let d = ev.shiftKey ? 10 : 1;
editorState.changeCurLayerTo(editorState.curLayer - d);
return;
}
if (ev.key === 'e' || ev.key === 'E') {
editorState.changeCurLayerTo(editorState.curLayer + 1);
if (ev.key.toLowerCase() === 'e') {
let d = ev.shiftKey ? 10 : 1;
editorState.changeCurLayerTo(editorState.curLayer + d);
return;
}
if (ev.key === 'Home') {
Expand Down

0 comments on commit fff6dda

Please sign in to comment.