billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=a2ba1a39ea76adc7ae3393ba1c20627fd61c0e46

commit a2ba1a39ea76adc7ae3393ba1c20627fd61c0e46
Author: Boris Faure <bill...@gmail.com>
Date:   Thu Sep 24 23:52:46 2020 +0200

    colorschemes: use json as source as it seems easier to fill in
---
 data/colorschemes/Nord.desc       | 211 --------------------------------------
 data/colorschemes/Nord.json       |  41 ++++++++
 data/colorschemes/PaperColor.desc | 211 --------------------------------------
 data/colorschemes/PaperColor.json |  41 ++++++++
 data/colorschemes/builder.sh      |   7 +-
 data/colorschemes/json2desc.py    |  82 +++++++++++++++
 data/colorschemes/meson.build     |   4 +-
 7 files changed, 171 insertions(+), 426 deletions(-)

diff --git a/data/colorschemes/Nord.desc b/data/colorschemes/Nord.desc
deleted file mode 100644
index 6878791..0000000
--- a/data/colorschemes/Nord.desc
+++ /dev/null
@@ -1,211 +0,0 @@
-group "Color_Scheme" struct {
-    value "version" int: 1;
-    value "md.version" int: 1;
-    value "md.name" string: "Nord";
-    value "md.author" string: "Arctic Ice Studio";
-    value "md.website" string: "https://git.io/nord";;
-    value "md.license" string: "MIT";
-    group "def" struct {
-        group "Color" struct {
-            value "r" uchar: 216;
-            value "g" uchar: 222;
-            value "b" uchar: 233;
-            value "a" uchar: 255;
-        }
-    }
-    group "bg" struct {
-        group "Color" struct {
-            value "r" uchar: 46;
-            value "g" uchar: 52;
-            value "b" uchar: 64;
-            value "a" uchar: 255;
-        }
-    }
-    group "fg" struct {
-        group "Color" struct {
-            value "r" uchar: 216;
-            value "g" uchar: 222;
-            value "b" uchar: 233;
-            value "a" uchar: 255;
-        }
-    }
-    group "main" struct {
-        group "Color" struct {
-            value "r" uchar: 136;
-            value "g" uchar: 192;
-            value "b" uchar: 208;
-            value "a" uchar: 255;
-        }
-    }
-    group "hl" struct {
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 255;
-            value "b" uchar: 255;
-            value "a" uchar: 255;
-        }
-    }
-    group "end_sel" struct {
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 51;
-            value "b" uchar: 0;
-            value "a" uchar: 255;
-        }
-    }
-    group "tab_missed_1" struct {
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 153;
-            value "b" uchar: 51;
-            value "a" uchar: 255;
-        }
-    }
-    group "tab_missed_2" struct {
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 51;
-            value "b" uchar: 0;
-            value "a" uchar: 255;
-        }
-    }
-    group "tab_missed_3" struct {
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 0;
-            value "b" uchar: 0;
-            value "a" uchar: 255;
-        }
-    }
-    group "tab_missed_over_1" struct {
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 255;
-            value "b" uchar: 64;
-            value "a" uchar: 255;
-        }
-    }
-    group "tab_missed_over_2" struct {
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 153;
-            value "b" uchar: 51;
-            value "a" uchar: 255;
-        }
-    }
-    group "tab_missed_over_3" struct {
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 0;
-            value "b" uchar: 0;
-            value "a" uchar: 255;
-        }
-    }
-    group "tab_title_2" struct {
-        group "Color" struct {
-            value "r" uchar: 0;
-            value "g" uchar: 0;
-            value "b" uchar: 0;
-            value "a" uchar: 255;
-        }
-    }
-    group "ansi" array {
-        count 16;
-        group "Color" struct {
-            value "r" uchar: 59;
-            value "g" uchar: 66;
-            value "b" uchar: 82;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 191;
-            value "g" uchar: 97;
-            value "b" uchar: 106;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 163;
-            value "g" uchar: 190;
-            value "b" uchar: 140;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 235;
-            value "g" uchar: 203;
-            value "b" uchar: 139;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 129;
-            value "g" uchar: 161;
-            value "b" uchar: 193;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 180;
-            value "g" uchar: 142;
-            value "b" uchar: 173;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 136;
-            value "g" uchar: 192;
-            value "b" uchar: 208;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 229;
-            value "g" uchar: 233;
-            value "b" uchar: 248;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 76;
-            value "g" uchar: 86;
-            value "b" uchar: 106;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 191;
-            value "g" uchar: 97;
-            value "b" uchar: 106;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 163;
-            value "g" uchar: 190;
-            value "b" uchar: 140;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 235;
-            value "g" uchar: 203;
-            value "b" uchar: 139;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 129;
-            value "g" uchar: 161;
-            value "b" uchar: 193;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 180;
-            value "g" uchar: 142;
-            value "b" uchar: 173;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 143;
-            value "g" uchar: 188;
-            value "b" uchar: 187;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 236;
-            value "g" uchar: 239;
-            value "b" uchar: 244;
-            value "a" uchar: 255;
-        }
-    }
-}
diff --git a/data/colorschemes/Nord.json b/data/colorschemes/Nord.json
new file mode 100644
index 0000000..2456693
--- /dev/null
+++ b/data/colorschemes/Nord.json
@@ -0,0 +1,41 @@
+{
+    "version": 1,
+    "md": {
+        "version": 1,
+        "name": "Nord",
+        "author": "Arctic Ice Studio",
+        "website": "https://git.io/nord";,
+        "license": "MIT"
+    },
+    "def": "#d8dee9",
+    "bg": "#2e3440",
+    "fg": "#d8dee9",
+    "main": "#88c0d0",
+    "hl": "#ffffff",
+    "end_sel": "#ff3300",
+    "tab_missed_1": "#ff9933",
+    "tab_missed_2": "#ff3300",
+    "tab_missed_3": "#ff0000",
+    "tab_missed_over_1": "#ffff40",
+    "tab_missed_over_2": "#ff9933",
+    "tab_missed_over_3": "#ff0000",
+    "tab_title_2": "#000000",
+    "ansi": [
+        "#3b4252",
+        "#bf616a",
+        "#a3be8c",
+        "#ebcb8b",
+        "#81a1c1",
+        "#b48ead",
+        "#88c0d0",
+        "#e5e9f8",
+        "#4c566a",
+        "#bf616a",
+        "#a3be8c",
+        "#ebcb8b",
+        "#81a1c1",
+        "#b48ead",
+        "#8fbcbb",
+        "#eceff4"
+    ]
+}
diff --git a/data/colorschemes/PaperColor.desc 
b/data/colorschemes/PaperColor.desc
deleted file mode 100644
index 93d1a44..0000000
--- a/data/colorschemes/PaperColor.desc
+++ /dev/null
@@ -1,211 +0,0 @@
-group "Color_Scheme" struct {
-    value "version" int: 1;
-    value "md.version" int: 1;
-    value "md.name" string: "PaperColor";
-    value "md.author" string: "Nikyle Nguyen";
-    value "md.website" string: "https://github.com/NLKNguyen/papercolor-theme";;
-    value "md.license" string: "MIT";
-    group "def" struct {
-        group "Color" struct {
-            value "r" uchar:  68;
-            value "g" uchar:  68;
-            value "b" uchar:  68;
-            value "a" uchar: 255;
-        }
-    }
-    group "bg" struct {
-        group "Color" struct {
-            value "r" uchar: 238;
-            value "g" uchar: 238;
-            value "b" uchar: 238;
-            value "a" uchar: 255;
-        }
-    }
-    group "fg" struct {
-        group "Color" struct {
-            value "r" uchar:  68;
-            value "g" uchar:  68;
-            value "b" uchar:  68;
-            value "a" uchar: 255;
-        }
-    }
-    group "main" struct {
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 2;
-            value "b" uchar: 102;
-            value "a" uchar: 255;
-        }
-    }
-    group "hl" struct {
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 255;
-            value "b" uchar: 255;
-            value "a" uchar: 255;
-        }
-    }
-    group "end_sel" struct {
-        group "Color" struct {
-            value "r" uchar: 136;
-            value "g" uchar:   0;
-            value "b" uchar:  61;
-            value "a" uchar: 255;
-        }
-    }
-    group "tab_missed_1" struct {
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 153;
-            value "b" uchar: 51;
-            value "a" uchar: 255;
-        }
-    }
-    group "tab_missed_2" struct {
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 51;
-            value "b" uchar: 0;
-            value "a" uchar: 255;
-        }
-    }
-    group "tab_missed_3" struct {
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 0;
-            value "b" uchar: 0;
-            value "a" uchar: 255;
-        }
-    }
-    group "tab_missed_over_1" struct {
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 255;
-            value "b" uchar: 64;
-            value "a" uchar: 255;
-        }
-    }
-    group "tab_missed_over_2" struct {
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 153;
-            value "b" uchar: 51;
-            value "a" uchar: 255;
-        }
-    }
-    group "tab_missed_over_3" struct {
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 0;
-            value "b" uchar: 0;
-            value "a" uchar: 255;
-        }
-    }
-    group "tab_title_2" struct {
-        group "Color" struct {
-            value "r" uchar: 0;
-            value "g" uchar: 0;
-            value "b" uchar: 0;
-            value "a" uchar: 255;
-        }
-    }
-    group "ansi" array {
-        count 16;
-        group "Color" struct {
-            value "r" uchar: 242;
-            value "g" uchar: 242;
-            value "b" uchar: 242;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 198;
-            value "g" uchar:  40;
-            value "b" uchar:  40;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar:  85;
-            value "g" uchar: 139;
-            value "b" uchar:  46;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 143;
-            value "b" uchar:   1;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar:  21;
-            value "g" uchar: 101;
-            value "b" uchar: 192;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 106;
-            value "g" uchar:  30;
-            value "b" uchar: 154;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar:   0;
-            value "g" uchar: 131;
-            value "b" uchar: 143;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar:  44;
-            value "g" uchar:  44;
-            value "b" uchar:  44;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 251;
-            value "g" uchar: 251;
-            value "b" uchar: 251;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 225;
-            value "g" uchar: 126;
-            value "b" uchar: 133;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar:  97;
-            value "g" uchar: 186;
-            value "b" uchar: 134;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 255;
-            value "g" uchar: 182;
-            value "b" uchar: 142;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar:  76;
-            value "g" uchar: 178;
-            value "b" uchar: 255;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar: 190;
-            value "g" uchar: 134;
-            value "b" uchar: 227;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar:  45;
-            value "g" uchar: 206;
-            value "b" uchar: 208;
-            value "a" uchar: 255;
-        }
-        group "Color" struct {
-            value "r" uchar:  84;
-            value "g" uchar:  99;
-            value "b" uchar: 134;
-            value "a" uchar: 255;
-        }
-    }
-}
diff --git a/data/colorschemes/PaperColor.json 
b/data/colorschemes/PaperColor.json
new file mode 100644
index 0000000..ca65c03
--- /dev/null
+++ b/data/colorschemes/PaperColor.json
@@ -0,0 +1,41 @@
+{
+    "version": 1,
+    "md": {
+        "version": 1,
+        "name": "PaperColor",
+        "author": "Nikyle Nguyen",
+        "website": "https://github.com/NLKNguyen/papercolor-theme";,
+        "license": "MIT"
+    },
+    "def": "#444444",
+    "bg": "#eeeeee",
+    "fg": "#444444",
+    "main": "#ff0266",
+    "hl": "#ffffff",
+    "end_sel": "#88003d",
+    "tab_missed_1": "#ff9933",
+    "tab_missed_2": "#ff3300",
+    "tab_missed_3": "#ff0000",
+    "tab_missed_over_1": "#ffff40",
+    "tab_missed_over_2": "#ff9933",
+    "tab_missed_over_3": "#ff0000",
+    "tab_title_2": "#000000",
+    "ansi": [
+        "#f2f2f2",
+        "#c62828",
+        "#558b2e",
+        "#ff8f01",
+        "#1565c0",
+        "#6a1e9a",
+        "#00838f",
+        "#2c2c2c",
+        "#fbfbdb",
+        "#e17e85",
+        "#61ba86",
+        "#ffb68e",
+        "#4cb2ff",
+        "#be86e3",
+        "#2dced0",
+        "#546386"
+    ]
+}
diff --git a/data/colorschemes/builder.sh b/data/colorschemes/builder.sh
index 6ad59b7..36994f6 100755
--- a/data/colorschemes/builder.sh
+++ b/data/colorschemes/builder.sh
@@ -8,16 +8,19 @@ EET=$1
 shift
 OUTPUT=$1
 shift
+JSON2DESC=$(dirname "$0")/json2desc.py
 
 # work on a temporary file till every insertion worked
 TMP_EET=$(mktemp "$OUTPUT-XXXXXX")
 # trap to avoid creating orphan files
 trap 'rm -f "$TMPFILE"' INT TERM HUP EXIT
 
-for DESC in "$@"
+for JSON in "$@"
 do
    # use the name, without extension as key in eet
-   KEY=$(basename "$DESC" ".desc")
+   KEY=$(basename "$JSON" ".desc")
+   DESC="${KEY}.desc"
+   $JSON2DESC "$JSON" "$DESC"
    $EET -e "$TMP_EET" "$KEY" "$DESC" "$COMPRESS"
 done
 
diff --git a/data/colorschemes/json2desc.py b/data/colorschemes/json2desc.py
new file mode 100755
index 0000000..52493ee
--- /dev/null
+++ b/data/colorschemes/json2desc.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python3
+
+import argparse
+import json
+
+parser = argparse.ArgumentParser(description='Convert JSON colorschemes to EET 
description files.')
+parser.add_argument('input_file',
+                    type=argparse.FileType('r'),
+                    help='JSON File to convert')
+parser.add_argument('output_file',
+                    type=argparse.FileType('w'),
+                    help='EET description to write')
+args = parser.parse_args()
+
+d = json.load(args.input_file)
+out = args.output_file
+
+out.write('group "Color_Scheme" struct {\n')
+out.write('    value "version" int: {};\n'
+          .format(d['version']))
+out.write('    value "md.version" int: {};\n'
+          .format(d['md']['version']))
+out.write('    value "md.name" string: "{}";\n'
+          .format(d['md']['name']))
+out.write('    value "md.author" string: "{}";\n'
+          .format(d['md']['author']))
+out.write('    value "md.website" string: "{}";\n'
+          .format(d['md']['website']))
+out.write('    value "md.license" string: "{}";\n'
+          .format(d['md']['license']))
+
+def parse_color(color_string):
+    h = color_string.lstrip('#')
+    if len(h) == 6:
+        return tuple(int(h[i:i+2], 16) for i in (0, 2, 4)) + (255,)
+    elif len(h) == 3:
+        return tuple(int(h[i]+h[i], 16) for i in (0, 1, 2)) + (255,)
+    elif len(h) == 8:
+        return tuple(int(h[i:i+2], 16) for i in (0, 2, 4, 6))
+    elif len(h) == 4:
+        return tuple(int(h[i]+h[i], 16) for i in (0, 1, 2, 3))
+
+def write_color(color_string):
+    (r, g, b, a) = parse_color(color_string)
+    out.write('        group "Color" struct {\n')
+    out.write('            value "r" uchar: {};\n'.format(r))
+    out.write('            value "g" uchar: {};\n'.format(g))
+    out.write('            value "b" uchar: {};\n'.format(b))
+    out.write('            value "a" uchar: {};\n'.format(a))
+    out.write('        }\n')
+
+
+def write_name_color(color_name):
+    out.write('    group "{}" struct {{\n'.format(color_name))
+    write_color(d[color_name])
+    out.write('    }\n')
+
+
+write_name_color('def')
+write_name_color('bg')
+write_name_color('fg')
+write_name_color('main')
+write_name_color('hl')
+write_name_color('end_sel')
+write_name_color('tab_missed_1')
+write_name_color('tab_missed_2')
+write_name_color('tab_missed_3')
+write_name_color('tab_missed_over_1')
+write_name_color('tab_missed_over_2')
+write_name_color('tab_missed_over_3')
+write_name_color('tab_title_2')
+
+def write_ansi():
+    assert(len(d['ansi']) == 16)
+    out.write('    group "ansi" array {\n')
+    out.write('        count 16;\n')
+    for c in d['ansi']:
+        write_color(c)
+    out.write('    }\n')
+
+write_ansi()
+out.write('}\n')
diff --git a/data/colorschemes/meson.build b/data/colorschemes/meson.build
index b1e368d..e48de3d 100644
--- a/data/colorschemes/meson.build
+++ b/data/colorschemes/meson.build
@@ -1,6 +1,6 @@
 colorschemes_desc = [
-  'Nord.desc',
-  'PaperColor.desc',
+  'Nord.json',
+  'PaperColor.json',
 ]
 cs_builder = [join_paths(meson.source_root(),
                          'data', 'colorschemes', 'builder.sh'),

-- 


Reply via email to