diff options
author | 2021-06-27 17:59:54 +0200 | |
---|---|---|
committer | 2021-06-27 18:09:46 +0200 | |
commit | 5785f36b17d2b290d88c05fee54e39060a07b6d4 (patch) | |
tree | 31f4f319b493d6f29e13ef63fe46eb18935178b5 /language-web/src/main/webapp | |
parent | Fix running outside of Eclipse (diff) | |
download | refinery-5785f36b17d2b290d88c05fee54e39060a07b6d4.tar.gz refinery-5785f36b17d2b290d88c05fee54e39060a07b6d4.tar.zst refinery-5785f36b17d2b290d88c05fee54e39060a07b6d4.zip |
Customize client-side CodeMirror mode
Diffstat (limited to 'language-web/src/main/webapp')
-rw-r--r-- | language-web/src/main/webapp/index.html | 4 | ||||
-rw-r--r-- | language-web/src/main/webapp/script.js | 2 | ||||
-rw-r--r-- | language-web/src/main/webapp/style.css | 11 | ||||
-rw-r--r-- | language-web/src/main/webapp/xtext-resources/generated/mode-problem.js | 30 |
4 files changed, 31 insertions, 16 deletions
diff --git a/language-web/src/main/webapp/index.html b/language-web/src/main/webapp/index.html index 3fb66d62..753ed63a 100644 --- a/language-web/src/main/webapp/index.html +++ b/language-web/src/main/webapp/index.html | |||
@@ -30,6 +30,7 @@ enum TaxStatus { | |||
30 | child, student, adult, retired | 30 | child, student, adult, retired |
31 | } | 31 | } |
32 | 32 | ||
33 | % A child cannot have any dependents. | ||
33 | error invalidTaxStatus(Person p) :- | 34 | error invalidTaxStatus(Person p) :- |
34 | taxStatus(p, child), children(p, _q). | 35 | taxStatus(p, child), children(p, _q). |
35 | 36 | ||
@@ -41,7 +42,8 @@ children(anne, ciri). | |||
41 | ?children(bob, ciri). | 42 | ?children(bob, ciri). |
42 | taxStatus(anne, adult). | 43 | taxStatus(anne, adult). |
43 | 44 | ||
44 | scope Family = 1, Person += 5..10.</pre></div> | 45 | scope Family = 1, Person += 5..10. |
46 | </pre></div> | ||
45 | </div> | 47 | </div> |
46 | </div> | 48 | </div> |
47 | <script type="text/javascript" src="webjars/requirejs/2.3.6/require.min.js"></script> | 49 | <script type="text/javascript" src="webjars/requirejs/2.3.6/require.min.js"></script> |
diff --git a/language-web/src/main/webapp/script.js b/language-web/src/main/webapp/script.js index dced7eca..818a056c 100644 --- a/language-web/src/main/webapp/script.js +++ b/language-web/src/main/webapp/script.js | |||
@@ -16,5 +16,5 @@ require.config({ | |||
16 | }] | 16 | }] |
17 | }); | 17 | }); |
18 | require(["xtext-resources/generated/mode-problem", "xtext/xtext-codemirror"], function(mode, xtext) { | 18 | require(["xtext-resources/generated/mode-problem", "xtext/xtext-codemirror"], function(mode, xtext) { |
19 | window.xtextEditor = xtext.createEditor({baseUrl: baseUrl,}); | 19 | xtext.createEditor({baseUrl: baseUrl, indentUnit: 4,}); |
20 | }); | 20 | }); |
diff --git a/language-web/src/main/webapp/style.css b/language-web/src/main/webapp/style.css index 9a89dd81..03018f93 100644 --- a/language-web/src/main/webapp/style.css +++ b/language-web/src/main/webapp/style.css | |||
@@ -59,7 +59,7 @@ a:hover { | |||
59 | bottom: 16px; | 59 | bottom: 16px; |
60 | left: 16px; | 60 | left: 16px; |
61 | right: 16px; | 61 | right: 16px; |
62 | border: 1px solid #aaa; | 62 | border: 1px solid #999; |
63 | } | 63 | } |
64 | 64 | ||
65 | .problem-class { | 65 | .problem-class { |
@@ -82,12 +82,7 @@ a:hover { | |||
82 | font-weight: bold; | 82 | font-weight: bold; |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | .CodeMirror .cm-quoted-name, .problem-enum-node { | |
86 | .CodeMirror .problem-node { | ||
87 | color: inherit; | ||
88 | } | ||
89 | |||
90 | .problem-enum-node { | ||
91 | color: #1a1a1a !important; | 86 | color: #1a1a1a !important; |
92 | font-weight: bold; | 87 | font-weight: bold; |
93 | } | 88 | } |
@@ -101,5 +96,5 @@ a:hover { | |||
101 | } | 96 | } |
102 | 97 | ||
103 | .problem-singleton-variable { | 98 | .problem-singleton-variable { |
104 | opacity: 0.7; | 99 | color: #a1706f; |
105 | } | 100 | } |
diff --git a/language-web/src/main/webapp/xtext-resources/generated/mode-problem.js b/language-web/src/main/webapp/xtext-resources/generated/mode-problem.js index 89373b1c..1640d13d 100644 --- a/language-web/src/main/webapp/xtext-resources/generated/mode-problem.js +++ b/language-web/src/main/webapp/xtext-resources/generated/mode-problem.js | |||
@@ -2,12 +2,16 @@ define(["codemirror", "codemirror/addon/mode/simple"], function(CodeMirror, Simp | |||
2 | var keywords = "abstract|class|contains|enum|error|extends|false|opposite|pred|problem|refers|scope|true|unknown"; | 2 | var keywords = "abstract|class|contains|enum|error|extends|false|opposite|pred|problem|refers|scope|true|unknown"; |
3 | CodeMirror.defineSimpleMode("xtext/problem", { | 3 | CodeMirror.defineSimpleMode("xtext/problem", { |
4 | start: [ | 4 | start: [ |
5 | {token: "comment", regex: "\\/\\/.*$"}, | ||
6 | {token: "comment", regex: "\\/\\*", next : "comment"}, | 5 | {token: "comment", regex: "\\/\\*", next : "comment"}, |
7 | {token: "string", regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'}, | 6 | {token: "string", regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'}, |
8 | {token: "constant.numeric", regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"}, | 7 | {token: "quoted-name", regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"}, |
9 | {token: "lparen", regex: "[\\[({]"}, | 8 | {token: "number", regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"}, |
10 | {token: "rparen", regex: "[\\])}]"}, | 9 | {token: "number", regex: "[*]"}, |
10 | {token: "comment", regex: "%.*$"}, | ||
11 | {token: "comment", regex: "\\/\\/.*$"}, | ||
12 | {token: "lparen", indent: true, regex: "[[({]"}, | ||
13 | {token: "rparen", dedent: true, dedentIfLineStart: true, regex: "[\\])}]"}, | ||
14 | {indent: true, push: "predicateBody", regex: ":-"}, | ||
11 | {token: "keyword", regex: "\\b(?:" + keywords + ")\\b"} | 15 | {token: "keyword", regex: "\\b(?:" + keywords + ")\\b"} |
12 | ], | 16 | ], |
13 | comment: [ | 17 | comment: [ |
@@ -16,7 +20,21 @@ define(["codemirror", "codemirror/addon/mode/simple"], function(CodeMirror, Simp | |||
16 | ], | 20 | ], |
17 | meta: { | 21 | meta: { |
18 | dontIndentStates: ["comment"], | 22 | dontIndentStates: ["comment"], |
19 | lineComment: "//" | 23 | lineComment: "%", |
20 | } | 24 | electricChars: "])]" |
25 | }, | ||
26 | predicateBody: [ | ||
27 | {token: "comment", regex: "\\/\\*", next : "comment"}, | ||
28 | {token: "string", regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'}, | ||
29 | {token: "quoted-name", regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"}, | ||
30 | {token: "number", regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"}, | ||
31 | {token: "number", regex: "[*]"}, | ||
32 | {token: "comment", regex: "%.*$"}, | ||
33 | {token: "comment", regex: "\\/\\/.*$"}, | ||
34 | {token: "lparen", indent: true, regex: "[[({]"}, | ||
35 | {token: "rparen", dedent: true, dedentIfLineStart: true, regex: "[\\])}]"}, | ||
36 | {dedent: true, dedentIfLineStart: false, pop: true, regex: "\\.\\s*$"}, | ||
37 | {token: "keyword", regex: "\\b(?:" + keywords + ")\\b"} | ||
38 | ] | ||
21 | }); | 39 | }); |
22 | }); | 40 | }); |