Merge branch 'main' of github.com:Bubobubobubobubo/Topos
This commit is contained in:
15
src/API.ts
15
src/API.ts
@ -2278,10 +2278,25 @@ export class UserAPI {
|
|||||||
console.log("Changing color scheme for: ", color_scheme)
|
console.log("Changing color scheme for: ", color_scheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public themeName = (): string => {
|
||||||
|
return this.app.currentThemeName;
|
||||||
|
}
|
||||||
|
|
||||||
public randomTheme = (): void => {
|
public randomTheme = (): void => {
|
||||||
let theme_names = this.getThemes();
|
let theme_names = this.getThemes();
|
||||||
let selected_theme = theme_names[Math.floor(Math.random() * theme_names.length)];
|
let selected_theme = theme_names[Math.floor(Math.random() * theme_names.length)];
|
||||||
this.app.readTheme(selected_theme);
|
this.app.readTheme(selected_theme);
|
||||||
|
this.app.api.log(selected_theme);
|
||||||
|
}
|
||||||
|
|
||||||
|
public nextTheme = (): void => {
|
||||||
|
let theme_names = this.getThemes();
|
||||||
|
let current_theme = this.app.api.themeName();
|
||||||
|
let current_theme_idx = theme_names.indexOf(current_theme);
|
||||||
|
let next_theme_idx = (current_theme_idx + 1) % theme_names.length;
|
||||||
|
let next_theme = theme_names[next_theme_idx];
|
||||||
|
this.app.readTheme(next_theme);
|
||||||
|
this.app.api.log(next_theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getThemes = (): string[] => {
|
public getThemes = (): string[] => {
|
||||||
|
|||||||
@ -71,6 +71,7 @@ export class Editor {
|
|||||||
public _mouseX: number = 0;
|
public _mouseX: number = 0;
|
||||||
public _mouseY: number = 0;
|
public _mouseY: number = 0;
|
||||||
show_error: boolean = false;
|
show_error: boolean = false;
|
||||||
|
currentThemeName: string = "Everblush";
|
||||||
buttonElements: Record<string, HTMLButtonElement[]> = {};
|
buttonElements: Record<string, HTMLButtonElement[]> = {};
|
||||||
interface: ElementMap = {};
|
interface: ElementMap = {};
|
||||||
blinkTimeouts: Record<number, number> = {};
|
blinkTimeouts: Record<number, number> = {};
|
||||||
@ -611,6 +612,7 @@ export class Editor {
|
|||||||
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.currentThemeName = theme_name;
|
||||||
this.updateInterfaceTheme(selected_theme);
|
this.updateInterfaceTheme(selected_theme);
|
||||||
let codeMirrorTheme = getCodeMirrorTheme(selected_theme);
|
let codeMirrorTheme = getCodeMirrorTheme(selected_theme);
|
||||||
// Reconfigure the view with the new theme
|
// Reconfigure the view with the new theme
|
||||||
|
|||||||
Reference in New Issue
Block a user