forked from fluidd-core/fluidd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvertTheme.js
More file actions
61 lines (54 loc) · 2.04 KB
/
convertTheme.js
File metadata and controls
61 lines (54 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* This automates theme conversion from VSCode -> a textmate theme which is
* usable by Fluidd's monaco implementation.
*
* The base dark theme is Ayu Mirage
* The base light theme is VSCode's Light+
*
* Both the klipper-config and gcode extensions must be installed before
* generating the base themes, otherwise the correct token colors won't be
* generated.
*
* You can create the base theme by using VSCodes command pallette and using
* the following command;
* Developer: Generate Color Theme From Current Settings
*
* This is all otherwise pretty horrid, and we should think about automating
* this further in the future.
*
* You can invoke this script using npm;
* npm run theme.convert
*
* which will write the appropriate theme files in their intended location.
*/
const converter = require('monaco-vscode-textmate-theme-converter')
const fs = require('fs')
// Load the themes.
const dark = fs.readFileSync('../src/monaco/theme/base.theme.dark.json', 'utf8')
const baseDarkTheme = JSON.parse(dark)
const light = fs.readFileSync('../src/monaco/theme/base.theme.light.json', 'utf8')
const baseLightTheme = JSON.parse(light)
// Convert it.
const themeDark = converter.convertTheme(baseDarkTheme)
const themeLight = converter.convertTheme(baseLightTheme)
// Our themes should have some base colors applied to match Fluidd.
themeDark.inherit = true
themeDark.colors['editor.background'] = '#28282b'
themeDark.colors['editor.lineHighlightBackground'] = '#3a3a3e'
themeDark.colors['minimap.background'] = themeDark.colors['editor.background']
themeDark.rules.forEach(rule => {
if (rule.foreground === '#5C6773') rule.foreground = '#7C8A99'
})
themeLight.inherit = false
themeLight.colors['minimap.background'] = themeLight.colors['editor.background']
// ..and write it to the file system.
fs.writeFile('../src/monaco/theme/editor.dark.theme.json', JSON.stringify(themeDark), (err) => {
if (err) {
throw err
}
})
fs.writeFile('../src/monaco/theme/editor.light.theme.json', JSON.stringify(themeLight), (err) => {
if (err) {
throw err
}
})