From 73a98349596c68031b33b1fe44b830498faea920 Mon Sep 17 00:00:00 2001 From: dtricks Date: Fri, 3 Oct 2025 18:12:47 +0200 Subject: [PATCH] codeformat --- packages/codemirror/codemirror.mjs | 2 +- packages/codemirror/keybindings.mjs | 56 +++++++++++----------- packages/osc/server.js | 0 website/src/pages/technical-manual/vim.mdx | 3 ++ 4 files changed, 32 insertions(+), 29 deletions(-) mode change 100644 => 100755 packages/osc/server.js diff --git a/packages/codemirror/codemirror.mjs b/packages/codemirror/codemirror.mjs index 6359609ca..f3ab3890e 100644 --- a/packages/codemirror/codemirror.mjs +++ b/packages/codemirror/codemirror.mjs @@ -298,7 +298,7 @@ export class StrudelMirror { async stop() { this.repl.scheduler.stop(); } - + // Listen for global stop requests (e.g., from Vim :q) onStopRequest = (e) => { try { diff --git a/packages/codemirror/keybindings.mjs b/packages/codemirror/keybindings.mjs index 7de2a7238..06aaad523 100644 --- a/packages/codemirror/keybindings.mjs +++ b/packages/codemirror/keybindings.mjs @@ -1,20 +1,22 @@ -import {defaultKeymap} from '@codemirror/commands'; -import {Prec} from '@codemirror/state'; -import {keymap, ViewPlugin} from '@codemirror/view'; +import { defaultKeymap } from '@codemirror/commands'; +import { Prec } from '@codemirror/state'; +import { keymap, ViewPlugin } from '@codemirror/view'; // import { searchKeymap } from '@codemirror/search'; -import {emacs} from '@replit/codemirror-emacs'; -import {vim, Vim} from '@replit/codemirror-vim'; +import { emacs } from '@replit/codemirror-emacs'; +import { vim, Vim } from '@replit/codemirror-vim'; import { logger } from '@strudel/core'; // import { vim } from './vim_test.mjs'; -import {vscodeKeymap} from '@replit/codemirror-vscode-keymap'; +import { vscodeKeymap } from '@replit/codemirror-vscode-keymap'; const vscodePlugin = ViewPlugin.fromClass( - class { - constructor() {} - }, - { - provide : () => { return Prec.highest(keymap.of([...vscodeKeymap ])); }, + class { + constructor() {} + }, + { + provide: () => { + return Prec.highest(keymap.of([...vscodeKeymap])); }, + }, ); const vscodeExtension = (options) => [vscodePlugin].concat(options ?? []); @@ -73,9 +75,7 @@ try { // :w to evaluate // :w to evaluate Vim.defineEx('write', 'w', (cm) => { - const view = - cm?.view || - cm; // CM6 Vim passes either an object with view or the view itself + const view = cm?.view || cm; // CM6 Vim passes either an object with view or the view itself try { view?.focus?.(); // Let the app know this came from Vim :w @@ -93,22 +93,22 @@ try { } // Try Ctrl+Enter first if not handled by custom event const ctrlEnter = new KeyboardEvent('keydown', { - key : 'Enter', - code : 'Enter', - ctrlKey : true, - bubbles : true, - cancelable : true, + key: 'Enter', + code: 'Enter', + ctrlKey: true, + bubbles: true, + cancelable: true, }); view?.dom?.dispatchEvent?.(ctrlEnter); // If not handled (no handler called preventDefault), try Alt+Enter as // fallback if (!ctrlEnter.defaultPrevented) { const altEnter = new KeyboardEvent('keydown', { - key : 'Enter', - code : 'Enter', - altKey : true, - bubbles : true, - cancelable : true, + key: 'Enter', + code: 'Enter', + altKey: true, + bubbles: true, + cancelable: true, }); view?.dom?.dispatchEvent?.(altEnter); } @@ -122,16 +122,16 @@ try { } const keymaps = { - vim, + vim, // Add extra Vim keymap for gc to toggle line comment // We will include a Vim-specific keymap that calls the CM command // respecting the current selection. emacs, - codemirror : () => keymap.of(defaultKeymap), - vscode : vscodeExtension, + codemirror: () => keymap.of(defaultKeymap), + vscode: vscodeExtension, }; export function keybindings(name) { const active = keymaps[name]; - return [ active ? Prec.high(active()) : [] ]; + return [active ? Prec.high(active()) : []]; } diff --git a/packages/osc/server.js b/packages/osc/server.js old mode 100644 new mode 100755 diff --git a/website/src/pages/technical-manual/vim.mdx b/website/src/pages/technical-manual/vim.mdx index ec284d0bf..b18a259ec 100644 --- a/website/src/pages/technical-manual/vim.mdx +++ b/website/src/pages/technical-manual/vim.mdx @@ -8,6 +8,7 @@ layout: ../../layouts/MainLayout.astro When the REPL editor (CodeMirror) is configured to use Vim keybindings, the following commands are available: - :w — Evaluate the current code + - Triggers the same evaluation as Ctrl+Enter / Alt+Enter - You’ll see messages in the Console panel such as: - [vim] :w — evaluating code @@ -15,10 +16,12 @@ When the REPL editor (CodeMirror) is configured to use Vim keybindings, the foll - [eval] code updated - :q — Stop/pause playback + - Triggers the same stop action as Alt+. - Useful to quickly stop scheduling without leaving Vim mode - gc — Toggle line comments for the current selection(s) + - Works in normal and visual mode - If there’s a selection, all selected lines are toggled