From fff6ddabecccf68a9718f08733cb445c7d6322eb Mon Sep 17 00:00:00 2001 From: Craig Gidney Date: Wed, 29 May 2024 15:10:58 -0700 Subject: [PATCH] keys --- glue/crumble/README.md | 22 +++++++++++++++++++--- glue/crumble/main.js | 22 +++++++++++++++++----- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/glue/crumble/README.md b/glue/crumble/README.md index 67d263422..d4673789d 100644 --- a/glue/crumble/README.md +++ b/glue/crumble/README.md @@ -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. @@ -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** @@ -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** @@ -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": @@ -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: diff --git a/glue/crumble/main.js b/glue/crumble/main.js index a59dbbf7e..c6989c160 100644 --- a/glue/crumble/main.js +++ b/glue/crumble/main.js @@ -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) { @@ -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"); @@ -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') {