diff --git a/packages/codemirror/codemirror.mjs b/packages/codemirror/codemirror.mjs index 6ba1d9c40..f47f6eba5 100644 --- a/packages/codemirror/codemirror.mjs +++ b/packages/codemirror/codemirror.mjs @@ -38,6 +38,13 @@ const extensions = { isFlashEnabled, keybindings, isTabIndentationEnabled: (on) => (on ? keymap.of([indentWithTab]) : []), + isMultiCursorEnabled: (on) => + on + ? [ + EditorState.allowMultipleSelections.of(true), + EditorView.clickAddsSelectionRange.of((ev) => ev.metaKey || ev.ctrlKey), + ] + : [], }; const compartments = Object.fromEntries(Object.keys(extensions).map((key) => [key, new Compartment()])); @@ -53,6 +60,7 @@ export const defaultSettings = { isTooltipEnabled: false, isLineWrappingEnabled: false, isTabIndentationEnabled: false, + isMultiCursorEnabled: false, theme: 'strudelTheme', fontFamily: 'monospace', fontSize: 18, diff --git a/website/src/repl/components/panel/SettingsTab.jsx b/website/src/repl/components/panel/SettingsTab.jsx index e82d03d87..cf2978a1a 100644 --- a/website/src/repl/components/panel/SettingsTab.jsx +++ b/website/src/repl/components/panel/SettingsTab.jsx @@ -110,6 +110,7 @@ export function SettingsTab({ started }) { maxPolyphony, multiChannelOrbits, isTabIndentationEnabled, + isMultiCursorEnabled, } = useSettings(); const shouldAlwaysSync = isUdels(); const canChangeAudioDevice = AudioContext.prototype.setSinkId != null; @@ -268,6 +269,11 @@ export function SettingsTab({ started }) { onChange={(cbEvent) => settingsMap.setKey('isTabIndentationEnabled', cbEvent.target.checked)} value={isTabIndentationEnabled} /> + settingsMap.setKey('isMultiCursorEnabled', cbEvent.target.checked)} + value={isMultiCursorEnabled} + /> settingsMap.setKey('isFlashEnabled', cbEvent.target.checked)} diff --git a/website/src/settings.mjs b/website/src/settings.mjs index 6212a6da0..3d99b656c 100644 --- a/website/src/settings.mjs +++ b/website/src/settings.mjs @@ -22,6 +22,7 @@ export const defaultSettings = { isLineWrappingEnabled: false, isPatternHighlightingEnabled: true, isTabIndentationEnabled: false, + isMultiCursorEnabled: false, theme: 'strudelTheme', fontFamily: 'monospace', fontSize: 18, @@ -79,6 +80,7 @@ export function useSettings() { isFlashEnabled: parseBoolean(state.isFlashEnabled), isSyncEnabled: isUdels() ? true : parseBoolean(state.isSyncEnabled), isTabIndentationEnabled: parseBoolean(state.isTabIndentationEnabled), + isMultiCursorEnabled: parseBoolean(state.isMultiCursorEnabled), fontSize: Number(state.fontSize), panelPosition: state.activeFooter !== '' && !isUdels() ? state.panelPosition : 'bottom', // <-- keep this 'bottom' where it is! isPanelPinned: parseBoolean(state.isPanelPinned),