diff --git a/frontend/app/view/term/term.tsx b/frontend/app/view/term/term.tsx index 4c2d1d04..e16cecf1 100644 --- a/frontend/app/view/term/term.tsx +++ b/frontend/app/view/term/term.tsx @@ -169,14 +169,22 @@ class TermViewModel { } getSettingsMenuItems(): ContextMenuItem[] { + const fullConfig = globalStore.get(atoms.fullConfigAtom); + const termThemes = fullConfig?.termthemes ?? {}; + const termThemeKeys = Object.keys(termThemes); + termThemeKeys.sort((a, b) => { + return termThemes[a]["display:order"] - termThemes[b]["display:order"]; + }); + const submenu: ContextMenuItem[] = termThemeKeys.map((themeName) => { + return { + label: termThemes[themeName]["display:name"] ?? themeName, + click: () => this.setTerminalTheme(themeName), + }; + }); return [ { label: "Themes", - submenu: [ - { label: "Default Dark", click: () => this.setTerminalTheme("default") }, - { label: "Dracula", click: () => this.setTerminalTheme("dracula") }, - { label: "Campbell", click: () => this.setTerminalTheme("campbell") }, - ], + submenu: submenu, }, ]; } diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index 5c117120..e8a2d229 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -438,6 +438,8 @@ declare global { // wconfig.TermThemeType type TermThemeType = { + "display:name": string; + "display:order": number; black: string; red: string; green: string; diff --git a/pkg/wconfig/defaultconfig/termthemes.json b/pkg/wconfig/defaultconfig/termthemes.json index a92e6833..66356465 100644 --- a/pkg/wconfig/defaultconfig/termthemes.json +++ b/pkg/wconfig/defaultconfig/termthemes.json @@ -1,5 +1,7 @@ { "default-dark": { + "display:name": "Default Dark", + "display:order": 1, "black": "#757575", "red": "#cc685c", "green": "#76c266", @@ -24,6 +26,8 @@ "cursorAccent": "" }, "dracula": { + "display:name": "Dracula", + "display:order": 2, "black": "#21222C", "red": "#FF5555", "green": "#50FA7B", @@ -47,7 +51,35 @@ "background": "#282a36", "cursorAccent": "#f8f8f2" }, + "monokai": { + "display:name": "Monokai", + "display:order": 3, + "black": "#1B1D1E", + "red": "#F92672", + "green": "#A6E22E", + "yellow": "#E6DB74", + "blue": "#66D9EF", + "magenta": "#AE81FF", + "cyan": "#A1EFE4", + "white": "#F8F8F2", + "brightBlack": "#75715E", + "brightRed": "#FD5FF1", + "brightGreen": "#A6E22E", + "brightYellow": "#E6DB74", + "brightBlue": "#66D9EF", + "brightMagenta": "#AE81FF", + "brightCyan": "#A1EFE4", + "brightWhite": "#F9F8F5", + "gray": "#75715E", + "cmdtext": "#F8F8F2", + "foreground": "#F8F8F2", + "selectionBackground": "#49483E", + "background": "#272822", + "cursorAccent": "#F8F8F2" + }, "campbell": { + "display:name": "Campbell", + "display:order": 4, "black": "#0C0C0C", "red": "#C50F1F", "green": "#13A10E", diff --git a/pkg/wconfig/settingsconfig.go b/pkg/wconfig/settingsconfig.go index 561d77b9..9d5a118d 100644 --- a/pkg/wconfig/settingsconfig.go +++ b/pkg/wconfig/settingsconfig.go @@ -302,26 +302,28 @@ type MimeTypeConfigType struct { } type TermThemeType struct { - Black string `json:"black"` - Red string `json:"red"` - Green string `json:"green"` - Yellow string `json:"yellow"` - Blue string `json:"blue"` - Magenta string `json:"magenta"` - Cyan string `json:"cyan"` - White string `json:"white"` - BrightBlack string `json:"brightBlack"` - BrightRed string `json:"brightRed"` - BrightGreen string `json:"brightGreen"` - BrightYellow string `json:"brightYellow"` - BrightBlue string `json:"brightBlue"` - BrightMagenta string `json:"brightMagenta"` - BrightCyan string `json:"brightCyan"` - BrightWhite string `json:"brightWhite"` - Gray string `json:"gray"` - CmdText string `json:"cmdtext"` - Foreground string `json:"foreground"` - SelectionBackground string `json:"selectionBackground"` - Background string `json:"background"` - CursorAccent string `json:"cursorAccent"` + DisplayName string `json:"display:name"` + DisplayOrder float64 `json:"display:order"` + Black string `json:"black"` + Red string `json:"red"` + Green string `json:"green"` + Yellow string `json:"yellow"` + Blue string `json:"blue"` + Magenta string `json:"magenta"` + Cyan string `json:"cyan"` + White string `json:"white"` + BrightBlack string `json:"brightBlack"` + BrightRed string `json:"brightRed"` + BrightGreen string `json:"brightGreen"` + BrightYellow string `json:"brightYellow"` + BrightBlue string `json:"brightBlue"` + BrightMagenta string `json:"brightMagenta"` + BrightCyan string `json:"brightCyan"` + BrightWhite string `json:"brightWhite"` + Gray string `json:"gray"` + CmdText string `json:"cmdtext"` + Foreground string `json:"foreground"` + SelectionBackground string `json:"selectionBackground"` + Background string `json:"background"` + CursorAccent string `json:"cursorAccent"` }