src/Builder4/ValaCompileErrors.bjs
authorAlan Knowles <alan@roojs.com>
Mon, 18 May 2015 09:33:33 +0000 (17:33 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 18 May 2015 09:33:33 +0000 (17:33 +0800)
src/Builder4/ValaCompileErrors.vala

src/Builder4/ValaCompileErrors.bjs
src/Builder4/ValaCompileErrors.vala

index a73426c..7e4e347 100644 (file)
@@ -76,7 +76,7 @@
            "gboolean show_line_marks" : true,
            "id" : "sourceview",
            "* init" : "{\n    this.curfname = \"\";\n       var description =   Pango.FontDescription.from_string(\"monospace\");\n    description.set_size(8000);\n    this.el.override_font(description);\n\n    var attrs = new Gtk.SourceMarkAttributes();\n    var  pink = new Gdk.RGBA();\n    pink.parse ( \"pink\");\n    attrs.set_background ( pink);\n    attrs.set_icon_name ( \"process-stop\");    \n    attrs.query_tooltip_text.connect(( mark) => {\n        //print(\"tooltip query? %s\\n\", mark.name);\n        return mark.name;\n    });\n    \n    this.el.set_mark_attributes (\"error\", attrs, 1);\n    \n}\n",
-           "| void loadFile" : "(string fname, int line ) {\n\n \n    \n\n\n    var buf = ((Gtk.SourceBuffer)(this.el.get_buffer()));\n      \n    if (this.curfname != fname) {\n        this.curfname = fname;\n        \n        \n        Regex regex = new Regex(\"\\\\.vala$\");\n\n        var bjsf = regex.replace(fname,fname.length , 0 , \".bjs\");\n        \n        var p = _this.window.project;\n        \n        var jsr = p.getByPath(bjsf);\n        \n        if (_this.file != null) {\n            // remove listeners from the file...\n        }\n        \n        _this.file = null;\n        \n        if (jsr != null) {\n            _this.file = jsr;\n            \n            return;\n        \n        }\n        \n        \n        \n\n        Gtk.TextIter start;\n        Gtk.TextIter end;     \n        buf.get_bounds (out start, out end);\n            \n        buf.remove_source_marks (start, end, null);\n             \n         \n        \n        string str;\n        FileUtils.get_contents(fname, out str);\n\t\t\t\n        buf.set_text(str, str.length);\n        var lm = Gtk.SourceLanguageManager.get_default();\n        \n       \n        buf.set_language(lm.get_language(\"vala\"));\n     \n         \n        this.el.grab_focus();\n\n\n       \n        var lines = _this.notices.get_object_member(fname);\n         \n            \n        lines.foreach_member((obj, line, node) => {\n            \n                 Gtk.TextIter iter;\n        //        print(\"get inter\\n\");\n                var eline = int.parse(line) -1 ;\n                 \n                \n                buf.get_iter_at_line( out iter, eline);\n                //print(\"mark line\\n\");\n                var msg  = \"Line: %d\".printf(eline+1);\n                var ar = lines.get_array_member(line);\n                for (var i = 0 ; i < ar.get_length(); i++) {\n\t\t        msg += (msg.length > 0) ? \"\\n\" : \"\";\n\t\t        msg += ar.get_string_element(i);\n\t        }\n                \n                \n                buf.create_source_mark(msg, \"error\", iter);\n            } );\n    }\n    // jump to the line...\n    Gtk.TextIter liter;\n    buf.get_iter_at_line (out liter,  line);\n    print(\"Scroll to \\n\");\n    this.el.scroll_to_iter (liter, 0.0f, false, 0.0f, 0.5f);\n    print(\"End Scroll to \\n\");\n\n\n}\n",
+           "| void loadFile" : "(string fname, int line ) {\n\n \n     int w,h;\n    _this.window.el.get_size(out w, out h);\n    \n    // left tree = 250, editor area = 500?\n    \n    var new_w = int.min(750, w-100);\n    if (new_w > (w-100)) {\n        new_w = w-100;\n    }\n    _this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));\n\n\n    \n    _this.hpane.el.set_position( _this.hpane.el.max_postion - 250);\n\n\n    var buf = ((Gtk.SourceBuffer)(this.el.get_buffer()));\n      \n    if (this.curfname != fname) {\n        this.curfname = fname;\n        \n        \n        Regex regex = new Regex(\"\\\\.vala$\");\n\n        var bjsf = regex.replace(fname,fname.length , 0 , \".bjs\");\n        \n        var p = _this.window.project;\n        \n        var jsr = p.getByPath(bjsf);\n        \n        if (_this.file != null) {\n            // remove listeners from the file...\n        }\n        \n        _this.file = null;\n        \n        if (jsr != null) {\n            _this.file = jsr;\n            \n            return;\n        \n        }\n        \n        \n        \n\n        Gtk.TextIter start;\n        Gtk.TextIter end;     \n        buf.get_bounds (out start, out end);\n            \n        buf.remove_source_marks (start, end, null);\n             \n         \n        \n        string str;\n        FileUtils.get_contents(fname, out str);\n\t\t\t\n        buf.set_text(str, str.length);\n        var lm = Gtk.SourceLanguageManager.get_default();\n        \n       \n        buf.set_language(lm.get_language(\"vala\"));\n     \n         \n        this.el.grab_focus();\n\n\n       \n        var lines = _this.notices.get_object_member(fname);\n         \n            \n        lines.foreach_member((obj, line, node) => {\n            \n                 Gtk.TextIter iter;\n        //        print(\"get inter\\n\");\n                var eline = int.parse(line) -1 ;\n                 \n                \n                buf.get_iter_at_line( out iter, eline);\n                //print(\"mark line\\n\");\n                var msg  = \"Line: %d\".printf(eline+1);\n                var ar = lines.get_array_member(line);\n                for (var i = 0 ; i < ar.get_length(); i++) {\n\t\t        msg += (msg.length > 0) ? \"\\n\" : \"\";\n\t\t        msg += ar.get_string_element(i);\n\t        }\n                \n                \n                buf.create_source_mark(msg, \"error\", iter);\n            } );\n    }\n    // jump to the line...\n    Gtk.TextIter liter;\n    buf.get_iter_at_line (out liter,  line);\n    print(\"Scroll to \\n\");\n    this.el.scroll_to_iter (liter, 0.0f, false, 0.0f, 0.5f);\n    print(\"End Scroll to \\n\");\n\n\n}\n",
            "* pack" : "add",
            "xtype" : "SourceView",
            "$ xns" : "Gtk",
index de0b3b4..b47579d 100644 (file)
@@ -376,7 +376,20 @@ public class Xcls_ValaCompileErrors : Object
         public void loadFile (string fname, int line ) {
         
          
+             int w,h;
+            _this.window.el.get_size(out w, out h);
             
+            // left tree = 250, editor area = 500?
+            
+            var new_w = int.min(750, w-100);
+            if (new_w > (w-100)) {
+                new_w = w-100;
+            }
+            _this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));
+        
+        
+            
+            _this.hpane.el.set_position( _this.hpane.el.max_postion - 250);
         
         
             var buf = ((Gtk.SourceBuffer)(this.el.get_buffer()));