aboutsummaryrefslogtreecommitdiff
path: root/www/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/index.js')
-rw-r--r--www/index.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/www/index.js b/www/index.js
index 52253c0..f870e92 100644
--- a/www/index.js
+++ b/www/index.js
@@ -32,6 +32,7 @@ const highlightField = StateField.define({
32 add: [hlMark.range(e.value.from, e.value.to)] 32 add: [hlMark.range(e.value.from, e.value.to)]
33 }); 33 });
34 } 34 }
35 return Decoration.none;
35 }, 36 },
36 provide: f => EditorView.decorations.from(f) 37 provide: f => EditorView.decorations.from(f)
37}) 38})
@@ -39,7 +40,9 @@ const highlightField = StateField.define({
39const hlMark = Decoration.mark({class: "cm-highlight"}) 40const hlMark = Decoration.mark({class: "cm-highlight"})
40 41
41const hlTheme = EditorView.baseTheme({ 42const hlTheme = EditorView.baseTheme({
42 ".cm-highlight": { textDecoration: "underline 3px red" } 43 ".cm-highlight": {
44 backgroundColor: "#ff3299aa"
45 }
43}) 46})
44 47
45function highlightArea(view, textRange) { 48function highlightArea(view, textRange) {
@@ -54,9 +57,8 @@ function render_cst(synRoot) {
54 let nodeDiv = document.createElement("div"); 57 let nodeDiv = document.createElement("div");
55 nodeDiv.className = "syntax-node"; 58 nodeDiv.className = "syntax-node";
56 let r = synRoot.range(); 59 let r = synRoot.range();
57 let synText = wrap(synRoot.text() + synRoot.range().to_string(), "pre"); 60 let synText = wrap(synRoot.kind() + " @ " + r.to_string() + " " +synRoot.text(), "pre");
58 synText.onmouseover = () => { 61 synText.onmouseover = () => {
59 console.log(r.to_string());
60 highlightArea(view, r); 62 highlightArea(view, r);
61 } 63 }
62 nodeDiv.appendChild(synText); 64 nodeDiv.appendChild(synText);
@@ -79,7 +81,7 @@ function render_err(errorList) {
79 errDiv.className = "syntax-err"; 81 errDiv.className = "syntax-err";
80 errorList.forEach(err => { 82 errorList.forEach(err => {
81 errDiv.appendChild(wrap(err.to_string(), "pre")); 83 errDiv.appendChild(wrap(err.to_string(), "pre"));
82 highlightArea(view, err.range()); 84 // highlightArea(view, err.range());
83 }); 85 });
84 return errDiv; 86 return errDiv;
85} 87}