src/Builder4/ValaCompileErrors.bjs
[app.Builder.js] / src / Builder4 / ValaCompileErrors.bjs
1 {
2  "name" : "ValaCompileErrors",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/ValaCompileErrors.bjs",
6  "permname" : "",
7  "modOrder" : "",
8  "build_module" : "builder",
9  "items" : [
10   {
11    "listeners" : {
12     "closed" : "() => {\n    if (this.active) {\n        this.el.show();\n        return;\n    }\n   \n}"
13    },
14    "int height_request" : 800,
15    "id" : "ValaCompileErrors",
16    "Xcls_MainWindow window" : "",
17    "| void show" : "(Json.Object tree, Gtk.Widget onbtn) {\n\n        \n        this.file = null;\n        this.notices = tree;\n        this.active = true;\n         //print(\"looking for %s\\n\", id);\n        // loop through parent childnre\n          \n        \n        var store = this.compile_result_store.el;    \n        \n        store.clear();\n     \n        \n        tree.foreach_member((obj, file, node) => {\n            // id line \"display text\", file\n            \n            var title = GLib.Path.get_basename(GLib.Path.get_dirname( file)) + \"/\" +  GLib.Path.get_basename( file) ;\n            Gtk.TreeIter iter;\n            print(\"Add file %s\", title);\n            store.append(out iter, null);\n            var lines = tree.get_object_member(file);\n            title += \" (\" + lines.get_size().to_string() + \")\";\n            store.set(iter, 0, file, 1, 0, 2, title, 3, file,-1);\n            \n            lines.foreach_member((obja, line, nodea) => {\n                var msg  = \"\";\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                Gtk.TreeIter citer;  \n                print(\"Add line %s\", line);\n                store.append(out citer, iter);\n                store.set(citer, \n                    0, file + \":\" + line, \n                    1, int.parse(line), \n                    2, GLib.Markup.escape_text(line + \": \" + msg), \n                    3, file,-1);\n            \n            });\n            \n            \n        \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(250, 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    if (this.el.relative_to == null) {\n        this.el.set_relative_to(onbtn);\n    }\n    this.el.show_all();\n    this.save_btn.el.hide();       \n    while(Gtk.events_pending()) { \n            Gtk.main_iteration();\n    }       \n    this.hpane.el.set_position( 0);\n}\n",
18    "xtype" : "Popover",
19    "Gtk.PositionType position" : "Gtk.PositionType.TOP",
20    "bool active" : false,
21    "int width_request" : 900,
22    "$ xns" : "Gtk",
23    "JsRender.JsRender? file" : "",
24    "Json.Object notices" : "",
25    "bool modal" : false,
26    "items" : [
27     {
28      "id" : "compile_view",
29      "xtype" : "VBox",
30      "* pack" : "add",
31      "gboolean homogeneous" : false,
32      "$ xns" : "Gtk",
33      "items" : [
34       {
35        "xtype" : "HBox",
36        "* pack" : "pack_start,false,false,0",
37        "$ xns" : "Gtk",
38        "items" : [
39         {
40          "* pack" : "pack_start,true,true,0",
41          "xtype" : "Button",
42          "$ xns" : "Gtk",
43          "utf8 label" : "Compile and Run"
44         },
45         {
46          "listeners" : {
47           "clicked" : "() => {\n    // is the file managed by the builder?\n    \n    var f = _this.sourceview.curfname;\n    \n    Regex regex = new Regex(\"\\\\.vala$\");\n\n    var bjsf = regex.replace(f,f.length , 0 , \".bjs\");\n    \n    var p = _this.window.project;\n    \n    \n    \n    var jsr = p.getByPath(bjsf);\n    if (jsr != null) {\n        _this.window.windowstate.fileViewOpen(jsr);\n        \n        return;\n    \n    }\n\n\n}"
48          },
49          "* pack" : "pack_start,true,true,0",
50          "xtype" : "Button",
51          "$ xns" : "Gtk",
52          "utf8 label" : "Edit"
53         },
54         {
55          "id" : "save_btn",
56          "xtype" : "Button",
57          "* pack" : "pack_start,true,true,0",
58          "$ xns" : "Gtk",
59          "utf8 label" : "Save",
60          "bool visible" : false
61         }
62        ]
63       },
64       {
65        "* init" : "{\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n\n}\n",
66        "xtype" : "ScrolledWindow",
67        "* pack" : "add",
68        "$ xns" : "Gtk",
69        "items" : [
70         {
71          "listeners" : {
72           "cursor_changed" : "() => {\n    var sel = this.el.get_selection();\n\n    if (sel.count_selected_rows() < 1) {\n\n        print(\"selected rows < 1\\n\");\n        //??this.mo \n        return  ;\n    }\n        \n        //console.log('changed');\n     \n     Gtk.TreeIter iter;\n     Gtk.TreeModel mod;\n    sel.get_selected(out mod, out iter);\n    /*\n     store.set(citer, \n            0, file + \":\" + line, \n            1, int.parse(line), \n            2, GLib.Markup.escape_text(line + \": \" + msg), \n            3, file,-1);\n    \n    });\n    */\n    \n    \n    \n    // var val = \"\";\n    GLib.Value value;\n    _this.compile_result_store.el.get_value(iter, 3, out value);\n    var fname = (string)value;\n    GLib.Value lvalue;\n    _this.compile_result_store.el.get_value(iter, 1, out lvalue);\n    var line = (int) lvalue;\n    \n    \n    \n \n    \n    \n    print (\"loadfile %s : %d\", fname,line);\n    \n    _this.sourceview.loadFile(fname, line);\n    \n    \n            \n            \n}\n             "
73          },
74          "id" : "compile_tree",
75          "* init" : "{\n var description = new Pango.FontDescription();\n    description.set_size(8000);\n    this.el.modify_font(description);\n\n}\n",
76          "* pack" : "add",
77          "xtype" : "TreeView",
78          "$ xns" : "Gtk",
79          "items" : [
80           {
81            "gint n_columns" : 4,
82            "id" : "compile_result_store",
83            "columns" : "  typeof(string), typeof(int), typeof(string), typeof(string) ",
84            "* pack" : "set_model",
85            "xtype" : "TreeStore",
86            "$ xns" : "Gtk"
87           },
88           {
89            "utf8 title" : "Compile output",
90            "* init" : "{\n  this.el.add_attribute(_this.renderer.el , \"markup\", 2 );\n \n}\n",
91            "xtype" : "TreeViewColumn",
92            "* pack" : "append_column",
93            "string id" : "column",
94            "$ xns" : "Gtk",
95            "items" : [
96             {
97              "id" : "renderer",
98              "* pack" : "pack_start,true",
99              "xtype" : "CellRendererText",
100              "$ xns" : "Gtk"
101             }
102            ]
103           }
104          ]
105         }
106        ]
107       },
108       {
109        "id" : "hpane",
110        "xtype" : "HPaned",
111        "* pack" : "pack_start,true,true,0",
112        "$ xns" : "Gtk",
113        "items" : [
114         {
115          "xtype" : "ScrolledWindow",
116          "* pack" : "add",
117          "$ xns" : "Gtk",
118          "items" : [
119           {
120            "gboolean show_line_marks" : true,
121            "id" : "sourceview",
122            "* 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",
123            "| void loadFile" : "(string fname, int line ) {\n\n    \n    // resize the view...\n    \n    \n    //if (_this.hpane.el.get_position() < 1) {\n        // left tree = 250, editor area = 500?\n         int w,h;\n        _this.window.el.get_size(out w, out h);\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        // let it resize, then find out the new size..\n        while(Gtk.events_pending()) { \n            Gtk.main_iteration();\n        }\n        \n        _this.hpane.el.set_position( _this.hpane.el.max_position - 250);\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",
124            "* pack" : "add",
125            "xtype" : "SourceView",
126            "$ xns" : "Gtk",
127            "gboolean show_line_numbers" : true,
128            "string curfname" : "",
129            "gboolean editable" : false
130           }
131          ]
132         },
133         {
134          "* init" : "{\n this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n\n}\n",
135          "* pack" : "add",
136          "xtype" : "ScrolledWindow",
137          "$ xns" : "Gtk",
138          "items" : [
139           {
140            "listeners" : {
141             "cursor_changed" : "() => {\n    var sel = this.el.get_selection();\n\n    if (sel.count_selected_rows() < 1) {\n\n        print(\"selected rows < 1\\n\");\n        //??this.mo \n        return  ;\n    }\n        \n        //console.log('changed');\n     \n     Gtk.TreeIter iter;\n     Gtk.TreeModel mod;\n    sel.get_selected(out mod, out iter);\n    /*\n     store.set(citer, \n            0, file + \":\" + line, \n            1, int.parse(line), \n            2, GLib.Markup.escape_text(line + \": \" + msg), \n            3, file,-1);\n    \n    });\n    */\n    \n    \n    \n    // var val = \"\";\n    GLib.Value value;\n    _this.compile_result_store.el.get_value(iter, 3, out value);\n    var fname = (string)value;\n    GLib.Value lvalue;\n    _this.compile_result_store.el.get_value(iter, 1, out lvalue);\n    var line = (int) lvalue;\n    \n    \n    \n \n    \n    \n    print (\"loadfile %s : %d\", fname,line);\n    \n    _this.sourceview.loadFile(fname, line);\n    \n    \n            \n            \n}\n             "
142            },
143            "id" : "compile_tree",
144            "* init" : "{\n var description = new Pango.FontDescription();\n    description.set_size(8000);\n    this.el.modify_font(description);\n\n}\n",
145            "* pack" : "add",
146            "xtype" : "TreeView",
147            "$ xns" : "Gtk",
148            "items" : [
149             {
150              "gint n_columns" : 4,
151              "id" : "compile_result_store",
152              "columns" : "  typeof(string), typeof(int), typeof(string), typeof(string) ",
153              "* pack" : "set_model",
154              "xtype" : "TreeStore",
155              "$ xns" : "Gtk"
156             },
157             {
158              "utf8 title" : "Compile output",
159              "* init" : "{\n  this.el.add_attribute(_this.renderer.el , \"markup\", 2 );\n \n}\n",
160              "xtype" : "TreeViewColumn",
161              "* pack" : "append_column",
162              "string id" : "column",
163              "$ xns" : "Gtk",
164              "items" : [
165               {
166                "id" : "renderer",
167                "xtype" : "CellRendererText",
168                "* pack" : "pack_start,true",
169                "$ xns" : "Gtk"
170               }
171              ]
172             }
173            ]
174           }
175          ]
176         }
177        ]
178       }
179      ]
180     }
181    ]
182   }
183  ]
184 }