src/Builder4/Editor.bjs
authorAlan Knowles <alan@roojs.com>
Thu, 30 Apr 2015 06:10:53 +0000 (14:10 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 30 Apr 2015 06:10:53 +0000 (14:10 +0800)
src/Builder4/Editor.vala

src/Builder4/Editor.bjs
src/Builder4/Editor.vala

index f234165..677bf69 100644 (file)
          "bool check_queued" : false,
          "id" : "buffer",
          "int error_line" : "-1",
+         "| bool highlightErrors" : "() {\n\n}\n",
          "|   string toString" : "  () {\n    \n    Gtk.TextIter s;\n    Gtk.TextIter e;\n    this.el.get_start_iter(out s);\n    this.el.get_end_iter(out e);\n    var ret = this.el.get_text(s,e,true);\n    //print(\"TO STRING? \" + ret);\n    return ret;\n}\n ",
          "|   bool checkSyntax" : " () {\n \n    if (this.check_running) {\n        print(\"Check is running\\n\");\n        if (this.check_queued) { \n            print(\"Check is already queued\");\n            return true;\n        }\n        this.check_queued = true;\n        print(\"Adding queued Check \");\n        GLib.Timeout.add_seconds(1, () => {\n            this.check_queued = false;\n            \n            this.checkSyntax();\n            return false;\n        });\n    \n\n        return true;\n    }\n   \n   \n    var p = Palete.factory(_this.file.xtype);   \n    \n    var str = this.toString();\n    \n    string res = \"\";\n    \n    if (this.error_line > 0) {\n         Gtk.TextIter start;\n         Gtk.TextIter end;     \n        this.el.get_bounds (out start, out end);\n\n        this.el.remove_source_marks (start, end, null);\n    }\n    \n    if (str.length < 1) {\n        print(\"checkSyntax - empty string?\\n\");\n        return true;\n    }\n    this.check_running = true;\n    \n    \n    if (_this.file.language == \"js\") {\n        this.check_running = false;\n        return this.highlightErrors(p.validateJavascript(\n            str, \n             _this.key, \n            _this.ptype,\n            _this.file,\n            _this.node\n        ));    \n        \n    }\n        \n    print(\"calling validate code\\n\");    \n    p.validateCode.begin(\n        str, \n         _this.key, \n        _this.ptype,\n        _this.file,\n        _this.node,\n        (obj, res) => {\n            this.check_running = false;\n            var validate_res = p.validateCode.end(res);\n            this.highlightErrors(validate_res);\n\n        }\n        \n    );\n     \n    \n    \n    //print(\"done mark line\\n\");\n     \n    return true; // at present allow saving - even if it's invalid..\n}\n",
          "* pack" : "set_buffer",
          "xtype" : "Buffer",
          "bool check_running" : false,
-         "$ xns" : "GtkSource",
-         "| return_type XXXX" : "() {\n\n}\n"
+         "$ xns" : "GtkSource"
         }
        ]
       }
index fd7c5a9..a055ccd 100644 (file)
@@ -367,6 +367,9 @@ public class Editor : Object
         }
 
         // user defined functions 
+        public bool highlightErrors () {
+        
+        }
         public   string toString () {
             
             Gtk.TextIter s;
@@ -454,8 +457,5 @@ public class Editor : Object
              
             return true; // at present allow saving - even if it's invalid..
         }
-        public return_type XXXX () {
-        
-        }
     }
 }