Debian Codegraph @

make/color.sample.gogh.js

raw symbols SCIP
1 const fs = require("fs");
2
3 if (process.argv.length < 2) {
4 console.error("usage: node color.sample.gogh.js <themes.json>");
5 process.exit(2);
6 }
7 const input_filename = process.argv[2];
8
9 const json = JSON.parse(fs.readFileSync(input_filename, "utf8"));
10
11 console.log(`# ${json.length} themes are found in ${input_filename}.`);
12
13 var max_name_width = 0;
14 json.forEach(theme => {
15 const name = theme.name.replace(/\s/g, "");
16 const base16_colors = [
17 theme.color_01,
18 theme.color_02,
19 theme.color_03,
20 theme.color_04,
21 theme.color_05,
22 theme.color_06,
23 theme.color_07,
24 theme.color_08,
25 theme.color_09,
26 theme.color_10,
27 theme.color_11,
28 theme.color_12,
29 theme.color_13,
30 theme.color_14,
31 theme.color_15,
32 theme.color_16,
33 theme.foreground,
34 theme.background,
35 theme.cursor,
36 ];
37
38 const buff = [];
39
40 if (name.length > max_name_width)
41 max_name_width = name.length;
42
43 const rpad = 30 - name.length;
44 buff.push(name);
45 for (var i = 0; i < rpad; i++)
46 buff.push(' ');
47 base16_colors.forEach(c => buff.push(' ', c.replace(/^#/g, "0x")));
48
49 console.log(buff.join(''));
50 });
51
52 console.log(`# max name width was ${max_name_width}`);