src/Builder4/Editor.bjs
authorAlan Knowles <alan@roojs.com>
Sat, 16 May 2015 09:59:27 +0000 (17:59 +0800)
committerAlan Knowles <alan@roojs.com>
Sat, 16 May 2015 09:59:27 +0000 (17:59 +0800)
src/Builder4/Editor.vala

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

index 20e0d33..0b675ee 100644 (file)
@@ -9,8 +9,8 @@
  "items" : [
   {
    "# Xcls_MainWindow window" : "null",
-   "# string activeEditor" : "\"\"",
    "|   bool saveContents" : "  ()  {\n    \n    \n    \n    \n    \n    \n    \n   \n     \n     var str = _this.buffer.toString();\n     \n      \n     \n     \n     if (!_this.buffer.checkSyntax()) {\n         print(\"check syntax failed\");\n         //this.get('/StandardErrorDialog').show(\"Fix errors in code and save..\"); \n         //return false;\n     }\n     \n     // LeftPanel.model.changed(  str , false);\n     _this.dirty = false;\n     _this.save_button.el.sensitive = false;\n     \n     \n        \n     \n    // find the text for the node..\n    if (ptype == \"listener\") {\n        this.node.listeners.set(key,str);\n    \n    } else {\n         this.node.props.set(key,str);\n    }\n\n     \n    \n    // call the signal..\n    this.save();\n    \n    return true;\n\n} ",
+   "# string activeEditor" : "\"\"",
    "# int pos_root_x" : "",
    "# int pos_root_y" : "",
    "# string ptype" : "\"\"",
@@ -45,8 +45,8 @@
       },
       {
        "id" : "key_edit",
-       "* pack" : "pack_end,true,true",
        "xtype" : "Entry",
+       "* pack" : "pack_end,true,true",
        "$ xns" : "Gtk"
       }
      ]
@@ -80,8 +80,8 @@
           "changed" : " () => {\n    // check syntax??\n    // ??needed..??\n    _this.save_button.el.sensitive = true;\n    print(\"EDITOR CHANGED\");\n    this.checkSyntax();\n   \n    _this.dirty = true;\n\n    // this.get('/LeftPanel.model').changed(  str , false);\n    return ;\n}\n\n \n"
          },
          "bool check_queued" : false,
-         "int error_line" : "-1",
          "id" : "buffer",
+         "int error_line" : "-1",
          "| bool highlightErrors" : "( Gee.HashMap<int,string> validate_res) {\n        this.error_line = validate_res.size;\n\n        if (this.error_line < 1) {\n              return true;\n        }\n        var tlines = this.el.get_line_count ();\n        Gtk.TextIter iter;\n        var valiter = validate_res.map_iterator();\n        while (valiter.next()) {\n        \n    //        print(\"get inter\\n\");\n            var eline = valiter.get_key();\n            if (eline > tlines) {\n                continue;\n            }\n            this.el.get_iter_at_line( out iter, eline);\n            //print(\"mark line\\n\");\n            this.el.create_source_mark(valiter.get_value(), \"error\", iter);\n        }   \n        return false;\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        print(\"calling validate javascript\\n\"); \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        \n    print(\"calling validate vala\\n\");    \n    // clear the buttons.\n    _this.window.statusbar_errors.el.hide();\n    _this.window.statusbar_warnings.el.hide();\n    _this.window.statusbar_depricated.el.hide();\n    \n    \n    \n    p.validateVala(\n        str, \n         _this.key, \n        _this.ptype,\n        _this.file,\n        _this.node,\n        (obj) => {\n            this.check_running = false;\n            this.highlightErrorsJson(obj);            \n            \n            //var validate_res = p.validateVala.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",
index 1ba9b26..79712a8 100644 (file)
@@ -19,35 +19,14 @@ public class Editor : Object
     public Xcls_buffer buffer;
 
         // my vars (def)
-    public Xcls_MainWindow window;
-    public string activeEditor;
-    public int pos_root_x;
-    public int pos_root_y;
-    public string ptype;
-    public string key;
-    public JsRender.JsRender file;
-    public bool pos;
-    public bool dirty;
-    public signal void save ();
-    public JsRender.Node node;
 
     // ctor 
     public Editor()
     {
         _this = this;
-        this.el = new Gtk.VBox( false, 0 );
+        this.el = new Gtk.VBox();
 
         // my vars (dec)
-        this.window = null;
-        this.activeEditor = "";
-        this.ptype = "";
-        this.key = "";
-        this.file = null;
-        this.pos = false;
-        this.dirty = false;
-        this.node = null;
-
-        // set gobject values
         var child_0 = new Xcls_HBox2( _this );
         child_0.ref();
         this.el.pack_start (  child_0.el , false,true );
@@ -132,11 +111,9 @@ public class Editor : Object
         public Xcls_HBox2(Editor _owner )
         {
             _this = _owner;
-            this.el = new Gtk.HBox( false, 0 );
+            this.el = new Gtk.HBox();
 
             // my vars (dec)
-
-            // set gobject values
             var child_0 = new Xcls_save_button( _this );
             child_0.ref();
             this.el.pack_start (  child_0.el , false,false );
@@ -164,9 +141,6 @@ public class Editor : Object
 
             // my vars (dec)
 
-            // set gobject values
-            this.el.label = "Save";
-
             // listeners 
             this.el.clicked.connect( () => { 
                 _this.saveContents();
@@ -191,8 +165,6 @@ public class Editor : Object
             this.el = new Gtk.Entry();
 
             // my vars (dec)
-
-            // set gobject values
         }
 
         // user defined functions 
@@ -210,11 +182,9 @@ public class Editor : Object
         {
             _this = _owner;
             _this.RightEditor = this;
-            this.el = new Gtk.ScrolledWindow( null, null );
+            this.el = new Gtk.ScrolledWindow();
 
             // my vars (dec)
-
-            // set gobject values
             var child_0 = new Xcls_view( _this );
             child_0.ref();
             this.el.add (  child_0.el  );
@@ -242,14 +212,6 @@ public class Editor : Object
             this.el = new Gtk.SourceView();
 
             // my vars (dec)
-
-            // set gobject values
-            this.el.auto_indent = true;
-            this.el.indent_width = 4;
-            this.el.show_line_marks = true;
-            this.el.insert_spaces_instead_of_tabs = true;
-            this.el.show_line_numbers = true;
-            this.el.highlight_current_line = true;
             var child_0 = new Xcls_buffer( _this );
             child_0.ref();
             this.el.set_buffer (  child_0.el  );
@@ -335,23 +297,15 @@ public class Editor : Object
 
 
             // my vars (def)
-        public bool check_queued;
-        public int error_line;
-        public bool check_running;
 
         // ctor 
         public Xcls_buffer(Editor _owner )
         {
             _this = _owner;
             _this.buffer = this;
-            this.el = new Gtk.SourceBuffer( null );
+            this.el = new Gtk.SourceBuffer();
 
             // my vars (dec)
-            this.check_queued = false;
-            this.error_line = -1;
-            this.check_running = false;
-
-            // set gobject values
 
             // listeners 
             this.el.changed.connect( () => {