src/JsRender/NodeToGtk.vala
[app.Builder.js] / src / JsRender / Node.vala
index b034701..2f9893b 100644 (file)
@@ -102,6 +102,8 @@ public class JsRender.Node : Object {
        public string  xvala_cls;
        public string xvala_xcls; // 'Xcls_' + id;
        public string xvala_id; // item id or ""
+       
+       // line markers..
        public int line_start;
        public int line_end;
        public Gee.ArrayList<int> lines;
@@ -129,26 +131,33 @@ public class JsRender.Node : Object {
        }
        
        public void setNodeLine(int line, Node node) {
+               print("Add node @ %d\n", line);
                this.node_lines.add(line);
                this.node_lines_map.set(line, node);
        }
        
        public void setLine(int line, string type, string prop) {
                this.lines.add(line);
-               this.line_map.set(line, type +":" + prop);
+               this.line_map.set(line, type + ":" + prop);
        }
        public void sortLines() {
+               print("sortLines\n");
                this.lines.sort((a,b) => {   
                        return (int)b-(int)a;
                });
                this.node_lines.sort((a,b) => {   
-                       return (int)b-(int)a;
+                       return (int)a-(int)b;
                });
        }
        public Node? lineToNode(int line)
        {
                print("Searching for line %d\n",line);
                var l = -1;
+               foreach(int el in this.node_lines) {
+                       print("all lines %d\n", el);
+               }
+               
+               
                foreach(int el in this.node_lines) {
                        print("?match %d\n", el);
                        if (el < line) {
@@ -160,6 +169,7 @@ public class JsRender.Node : Object {
                        if (el == line) {
                                print("SAME\n");
                                l = el;
+                               break;
                        }
                        if (l > -1) {
                                print("RETURNING NODE ON LINE %d", l);
@@ -274,9 +284,17 @@ public class JsRender.Node : Object {
                // $ XXX - with flag (no type)
                // $ string XXX - with flag
                kname = "";
-               ktype = "-";
-               kflag = "-";
-               var kk = key.strip().split(" ");
+               ktype = ""; // these used to contain '-' ???
+               kflag = ""; // these used to contain '-' ???
+               var kkv = key.strip().split(" ");
+               string[] kk = {};
+               for (var i = 0; i < kkv.length; i++) {
+                       if (kkv[i].length > 0 ) {
+                               kk+= kkv[i];
+                       }
+               }
+               print("normalize %s => %s\n", key,string.joinv("=:=",kk));
+               
                switch(kk.length) {
                        case 1: 
                                kname = kk[0];