writing some very shady logic
This commit is contained in:
@ -2272,4 +2272,8 @@ export class UserAPI {
|
|||||||
this.cueTimes[functionName] = this.app.clock.pulses_since_origin;
|
this.cueTimes[functionName] = this.app.clock.pulses_since_origin;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public theme = (color_scheme: string): void => {
|
||||||
|
this.app.readTheme(color_scheme);
|
||||||
|
console.log("Changing color scheme for: ", color_scheme)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,8 +8,6 @@ import {
|
|||||||
drawSelection,
|
drawSelection,
|
||||||
highlightActiveLine,
|
highlightActiveLine,
|
||||||
dropCursor,
|
dropCursor,
|
||||||
// rectangularSelection,
|
|
||||||
// crosshairCursor,
|
|
||||||
highlightActiveLineGutter,
|
highlightActiveLineGutter,
|
||||||
} from "@codemirror/view";
|
} from "@codemirror/view";
|
||||||
import { Extension, EditorState } from "@codemirror/state";
|
import { Extension, EditorState } from "@codemirror/state";
|
||||||
@ -32,13 +30,12 @@ import { lintKeymap } from "@codemirror/lint";
|
|||||||
import { Compartment } from "@codemirror/state";
|
import { Compartment } from "@codemirror/state";
|
||||||
import { Editor } from "./main";
|
import { Editor } from "./main";
|
||||||
import { EditorView } from "codemirror";
|
import { EditorView } from "codemirror";
|
||||||
import { toposTheme } from "./themes/toposTheme";
|
|
||||||
import { javascript } from "@codemirror/lang-javascript";
|
import { javascript } from "@codemirror/lang-javascript";
|
||||||
import { inlineHoveringTips } from "./documentation/inlineHelp";
|
import { inlineHoveringTips } from "./documentation/inlineHelp";
|
||||||
import { toposCompletions, soundCompletions } from "./documentation/inlineHelp";
|
import { toposCompletions, soundCompletions } from "./documentation/inlineHelp";
|
||||||
import { javascriptLanguage } from "@codemirror/lang-javascript";
|
import { javascriptLanguage } from "@codemirror/lang-javascript";
|
||||||
|
|
||||||
export const updateCodeMirrorTheme = (theme: {[key: string]: string}): Extension => {
|
export const getCodeMirrorTheme = (theme: {[key: string]: string}): Extension => {
|
||||||
const color0 = theme["color0"],
|
const color0 = theme["color0"],
|
||||||
color1 = theme["color1"],
|
color1 = theme["color1"],
|
||||||
color2 = theme["color2"],
|
color2 = theme["color2"],
|
||||||
@ -300,7 +297,7 @@ export const installEditor = (app: Editor) => {
|
|||||||
app.settings.completions ? [jsCompletions, toposSoundCompletions] : [],
|
app.settings.completions ? [jsCompletions, toposSoundCompletions] : [],
|
||||||
),
|
),
|
||||||
editorSetup,
|
editorSetup,
|
||||||
toposTheme,
|
getCodeMirrorTheme(app.getColorScheme("Tomorrow Night Burns")),
|
||||||
app.chosenLanguage.of(javascript()),
|
app.chosenLanguage.of(javascript()),
|
||||||
];
|
];
|
||||||
app.dynamicPlugins = new Compartment();
|
app.dynamicPlugins = new Compartment();
|
||||||
|
|||||||
16
src/main.ts
16
src/main.ts
@ -5,6 +5,7 @@ import { javascript } from "@codemirror/lang-javascript";
|
|||||||
import { markdown } from "@codemirror/lang-markdown";
|
import { markdown } from "@codemirror/lang-markdown";
|
||||||
import { Extension } from "@codemirror/state";
|
import { Extension } from "@codemirror/state";
|
||||||
import { outputSocket } from "./IO/OSC";
|
import { outputSocket } from "./IO/OSC";
|
||||||
|
import { getCodeMirrorTheme } from "./EditorSetup";
|
||||||
import {
|
import {
|
||||||
initializeSelectedUniverse,
|
initializeSelectedUniverse,
|
||||||
AppSettings,
|
AppSettings,
|
||||||
@ -572,19 +573,24 @@ export class Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updateInterfaceTheme(selected_theme: {[key: string]: string}): void {
|
private updateInterfaceTheme(selected_theme: {[key: string]: string}): void {
|
||||||
// We will update CSS variables to change the theme
|
|
||||||
for (const [key, value] of Object.entries(selected_theme)) {
|
for (const [key, value] of Object.entries(selected_theme)) {
|
||||||
document.documentElement.style.setProperty(key, value);
|
document.documentElement.style.setProperty("--" + key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readTheme(theme_name: string): void {
|
getColorScheme(theme_name: string): {[key: string]: string} {
|
||||||
|
// Check if the theme exists in colors.json
|
||||||
|
let themes: Record<string, { [key: string]: any }> = colors;
|
||||||
|
return themes[theme_name];
|
||||||
|
}
|
||||||
|
|
||||||
|
readTheme(theme_name: string): void {
|
||||||
// Check if the theme exists in colors.json
|
// Check if the theme exists in colors.json
|
||||||
let themes: Record<string, { [key: string]: any }> = colors;
|
let themes: Record<string, { [key: string]: any }> = colors;
|
||||||
let selected_theme = themes[theme_name];
|
let selected_theme = themes[theme_name];
|
||||||
if (selected_theme) {
|
if (selected_theme) {
|
||||||
this.updateInterfaceTheme(selected_theme);
|
this.updateInterfaceTheme(selected_theme);
|
||||||
updateCodeMirrorTheme(selected_theme);
|
let codeMirrorTheme = getCodeMirrorTheme(selected_theme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user