From 6691afb9b9fe20857e0154b1bf23727bb15e69f1 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 18 Mar 2022 17:37:28 +0100 Subject: [PATCH] can now disable highlighting via comment --- repl/src/useCycle.ts | 2 +- repl/src/useRepl.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/repl/src/useCycle.ts b/repl/src/useCycle.ts index 2521eb96..7e56dadf 100644 --- a/repl/src/useCycle.ts +++ b/repl/src/useCycle.ts @@ -60,7 +60,7 @@ function useCycle(props: UseCycleProps) { useEffect(() => { ready && query(); - }, [onEvent, onSchedule, onQuery, ready]); + }, [onEvent, onSchedule, onQuery, onDraw, ready]); const start = async () => { setStarted(true); diff --git a/repl/src/useRepl.ts b/repl/src/useRepl.ts index 06758de9..5c4ff1d7 100644 --- a/repl/src/useRepl.ts +++ b/repl/src/useRepl.ts @@ -54,6 +54,14 @@ function useRepl({ tune, defaultSynth, autolink = true, onEvent, onDraw }: any) // pushLog(`# cycle ${cycle}\n` + _events.map((e: any) => e.show()).join('\n')); } }; + + // below block allows disabling the highlighting by including "strudel disable-highlighting" in the code (as comment) + onDraw = useMemo(() => { + if (activeCode && !activeCode.includes('strudel disable-highlighting')) { + return onDraw; + } + }, [activeCode]); + // cycle hook to control scheduling const cycle = useCycle({ onDraw,