mondo mode for StrudelMirror / repl / mini repl
This commit is contained in:
parent
6d21456423
commit
5eabcf0618
4 changed files with 11 additions and 2 deletions
|
|
@ -62,7 +62,7 @@ export const codemirrorSettings = persistentAtom('codemirror-settings', defaultS
|
||||||
});
|
});
|
||||||
|
|
||||||
// https://codemirror.net/docs/guide/
|
// https://codemirror.net/docs/guide/
|
||||||
export function initEditor({ initialCode = '', onChange, onEvaluate, onStop, root }) {
|
export function initEditor({ initialCode = '', onChange, onEvaluate, onStop, root, mondo }) {
|
||||||
const settings = codemirrorSettings.get();
|
const settings = codemirrorSettings.get();
|
||||||
const initialSettings = Object.keys(compartments).map((key) =>
|
const initialSettings = Object.keys(compartments).map((key) =>
|
||||||
compartments[key].of(extensions[key](parseBooleans(settings[key]))),
|
compartments[key].of(extensions[key](parseBooleans(settings[key]))),
|
||||||
|
|
@ -75,7 +75,7 @@ export function initEditor({ initialCode = '', onChange, onEvaluate, onStop, roo
|
||||||
/* search(),
|
/* search(),
|
||||||
highlightSelectionMatches(), */
|
highlightSelectionMatches(), */
|
||||||
...initialSettings,
|
...initialSettings,
|
||||||
javascript(),
|
mondo ? [] : javascript(),
|
||||||
sliderPlugin,
|
sliderPlugin,
|
||||||
widgetPlugin,
|
widgetPlugin,
|
||||||
// indentOnInput(), // works without. already brought with javascript extension?
|
// indentOnInput(), // works without. already brought with javascript extension?
|
||||||
|
|
@ -209,6 +209,7 @@ export class StrudelMirror {
|
||||||
},
|
},
|
||||||
onEvaluate: () => this.evaluate(),
|
onEvaluate: () => this.evaluate(),
|
||||||
onStop: () => this.stop(),
|
onStop: () => this.stop(),
|
||||||
|
mondo: replOptions.mondo,
|
||||||
});
|
});
|
||||||
const cmEditor = this.root.querySelector('.cm-editor');
|
const cmEditor = this.root.querySelector('.cm-editor');
|
||||||
if (cmEditor) {
|
if (cmEditor) {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ export function repl({
|
||||||
setInterval,
|
setInterval,
|
||||||
clearInterval,
|
clearInterval,
|
||||||
id,
|
id,
|
||||||
|
mondo = false,
|
||||||
}) {
|
}) {
|
||||||
const state = {
|
const state = {
|
||||||
schedulerError: undefined,
|
schedulerError: undefined,
|
||||||
|
|
@ -180,6 +181,10 @@ export function repl({
|
||||||
setTime(() => scheduler.now()); // TODO: refactor?
|
setTime(() => scheduler.now()); // TODO: refactor?
|
||||||
await beforeEval?.({ code });
|
await beforeEval?.({ code });
|
||||||
shouldHush && hush();
|
shouldHush && hush();
|
||||||
|
|
||||||
|
if (mondo) {
|
||||||
|
code = `mondolang\`${code}\``;
|
||||||
|
}
|
||||||
let { pattern, meta } = await _evaluate(code, transpiler, transpilerOptions);
|
let { pattern, meta } = await _evaluate(code, transpiler, transpilerOptions);
|
||||||
if (Object.keys(pPatterns).length) {
|
if (Object.keys(pPatterns).length) {
|
||||||
let patterns = Object.values(pPatterns);
|
let patterns = Object.values(pPatterns);
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ export const SIDEBAR: Sidebar = {
|
||||||
{ text: 'Visual Feedback', link: 'learn/visual-feedback' },
|
{ text: 'Visual Feedback', link: 'learn/visual-feedback' },
|
||||||
{ text: 'Offline', link: 'learn/pwa' },
|
{ text: 'Offline', link: 'learn/pwa' },
|
||||||
{ text: 'Patterns', link: 'technical-manual/patterns' },
|
{ text: 'Patterns', link: 'technical-manual/patterns' },
|
||||||
|
{ text: 'Mondo Notation', link: 'learn/mondo-notation' },
|
||||||
{ text: 'Music metadata', link: 'learn/metadata' },
|
{ text: 'Music metadata', link: 'learn/metadata' },
|
||||||
{ text: 'CSound', link: 'learn/csound' },
|
{ text: 'CSound', link: 'learn/csound' },
|
||||||
{ text: 'Hydra', link: 'learn/hydra' },
|
{ text: 'Hydra', link: 'learn/hydra' },
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ export function MiniRepl({
|
||||||
maxHeight,
|
maxHeight,
|
||||||
autodraw,
|
autodraw,
|
||||||
drawTime,
|
drawTime,
|
||||||
|
mondo = false,
|
||||||
}) {
|
}) {
|
||||||
const code = tunes ? tunes[0] : tune;
|
const code = tunes ? tunes[0] : tune;
|
||||||
const id = useMemo(() => s4(), []);
|
const id = useMemo(() => s4(), []);
|
||||||
|
|
@ -85,6 +86,7 @@ export function MiniRepl({
|
||||||
},
|
},
|
||||||
beforeStart: () => audioReady,
|
beforeStart: () => audioReady,
|
||||||
afterEval: ({ code }) => setVersionDefaultsFrom(code),
|
afterEval: ({ code }) => setVersionDefaultsFrom(code),
|
||||||
|
mondo,
|
||||||
});
|
});
|
||||||
// init settings
|
// init settings
|
||||||
editor.setCode(code);
|
editor.setCode(code);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue