1 static Xcls_ValaCompileErrors _ValaCompileErrors;
3 public class Xcls_ValaCompileErrors : Object
6 private Xcls_ValaCompileErrors _this;
8 public static Xcls_ValaCompileErrors singleton()
10 if (_ValaCompileErrors == null) {
11 _ValaCompileErrors= new Xcls_ValaCompileErrors();
13 return _ValaCompileErrors;
15 public Xcls_compile_view compile_view;
16 public Xcls_save_btn save_btn;
17 public Xcls_hpane hpane;
18 public Xcls_compile_tree compile_tree;
19 public Xcls_compile_result_store compile_result_store;
20 public Xcls_renderer renderer;
21 public Xcls_sourceview sourceview;
24 public Xcls_MainWindow window;
26 public JsRender.JsRender? file;
27 public Json.Object notices;
30 public Xcls_ValaCompileErrors()
33 this.el = new Gtk.Popover( null );
39 this.el.width_request = 900;
40 this.el.height_request = 800;
41 this.el.modal = false;
42 this.el.position = Gtk.PositionType.TOP;
43 var child_0 = new Xcls_compile_view( _this );
45 this.el.add ( child_0.el );
48 this.el.closed.connect( () => {
57 // user defined functions
58 public void show (Json.Object tree, Gtk.Widget onbtn) {
64 //print("looking for %s\n", id);
65 // loop through parent childnre
68 var store = this.compile_result_store.el;
73 tree.foreach_member((obj, file, node) => {
74 // id line "display text", file
76 var title = GLib.Path.get_basename(GLib.Path.get_dirname( file)) + "/" + GLib.Path.get_basename( file) ;
78 print("Add file %s", title);
79 store.append(out iter, null);
80 var lines = tree.get_object_member(file);
81 title += " (" + lines.get_size().to_string() + ")";
82 store.set(iter, 0, file, 1, 0, 2, title, 3, file,-1);
84 lines.foreach_member((obja, line, nodea) => {
86 var ar = lines.get_array_member(line);
87 for (var i = 0 ; i < ar.get_length(); i++) {
88 msg += (msg.length > 0) ? "\n" : "";
89 msg += ar.get_string_element(i);
92 print("Add line %s", line);
93 store.append(out citer, iter);
97 2, GLib.Markup.escape_text(line + ": " + msg),
107 this.window.el.get_size(out w, out h);
109 // left tree = 250, editor area = 500?
111 var new_w = int.min(750, w-100);
112 if (new_w > (w-100)) {
115 this.el.set_size_request( int.max(100, new_w), int.max(100, h-120));
118 this.hpane.el.set_position( int.max(100, new_w));
119 if (this.el.relative_to == null) {
120 this.el.set_relative_to(onbtn);
123 this.save_btn.el.hide();
126 public class Xcls_compile_view : Object
129 private Xcls_ValaCompileErrors _this;
135 public Xcls_compile_view(Xcls_ValaCompileErrors _owner )
138 _this.compile_view = this;
139 this.el = new Gtk.VBox( false, 0 );
143 // set gobject values
144 var child_0 = new Xcls_HBox3( _this );
146 this.el.pack_start ( child_0.el , false,false,0 );
147 var child_1 = new Xcls_hpane( _this );
149 this.el.pack_start ( child_1.el , true,true,0 );
152 // user defined functions
154 public class Xcls_HBox3 : Object
157 private Xcls_ValaCompileErrors _this;
163 public Xcls_HBox3(Xcls_ValaCompileErrors _owner )
166 this.el = new Gtk.HBox( true, 0 );
170 // set gobject values
171 var child_0 = new Xcls_Button4( _this );
173 this.el.pack_start ( child_0.el , true,true,0 );
174 var child_1 = new Xcls_Button5( _this );
176 this.el.pack_start ( child_1.el , true,true,0 );
177 var child_2 = new Xcls_save_btn( _this );
179 this.el.pack_start ( child_2.el , true,true,0 );
182 // user defined functions
184 public class Xcls_Button4 : Object
186 public Gtk.Button el;
187 private Xcls_ValaCompileErrors _this;
193 public Xcls_Button4(Xcls_ValaCompileErrors _owner )
196 this.el = new Gtk.Button();
200 // set gobject values
201 this.el.label = "Compile and Run";
204 // user defined functions
206 public class Xcls_Button5 : Object
208 public Gtk.Button el;
209 private Xcls_ValaCompileErrors _this;
215 public Xcls_Button5(Xcls_ValaCompileErrors _owner )
218 this.el = new Gtk.Button();
222 // set gobject values
223 this.el.label = "Edit";
226 this.el.clicked.connect( () => {
227 // is the file managed by the builder?
229 var f = _this.sourceview.curfname;
231 Regex regex = new Regex("\\.vala$");
233 var bjsf = regex.replace(f,f.length , 0 , ".bjs");
235 var p = _this.window.project;
239 var jsr = p.getByPath(bjsf);
241 _this.window.windowstate.fileViewOpen(jsr);
251 // user defined functions
253 public class Xcls_save_btn : Object
255 public Gtk.Button el;
256 private Xcls_ValaCompileErrors _this;
262 public Xcls_save_btn(Xcls_ValaCompileErrors _owner )
265 _this.save_btn = this;
266 this.el = new Gtk.Button();
270 // set gobject values
271 this.el.label = "Save";
272 this.el.visible = false;
275 // user defined functions
277 public class Xcls_hpane : Object
279 public Gtk.HPaned el;
280 private Xcls_ValaCompileErrors _this;
286 public Xcls_hpane(Xcls_ValaCompileErrors _owner )
290 this.el = new Gtk.HPaned();
294 // set gobject values
295 var child_0 = new Xcls_ScrolledWindow8( _this );
297 this.el.add ( child_0.el );
298 var child_1 = new Xcls_ScrolledWindow13( _this );
300 this.el.add ( child_1.el );
303 // user defined functions
305 public class Xcls_ScrolledWindow8 : Object
307 public Gtk.ScrolledWindow el;
308 private Xcls_ValaCompileErrors _this;
314 public Xcls_ScrolledWindow8(Xcls_ValaCompileErrors _owner )
317 this.el = new Gtk.ScrolledWindow( null, null );
321 // set gobject values
322 var child_0 = new Xcls_compile_tree( _this );
324 this.el.add ( child_0.el );
329 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
335 // user defined functions
337 public class Xcls_compile_tree : Object
339 public Gtk.TreeView el;
340 private Xcls_ValaCompileErrors _this;
346 public Xcls_compile_tree(Xcls_ValaCompileErrors _owner )
349 _this.compile_tree = this;
350 this.el = new Gtk.TreeView();
354 // set gobject values
355 var child_0 = new Xcls_compile_result_store( _this );
357 this.el.set_model ( child_0.el );
358 var child_1 = new Xcls_column( _this );
360 this.el.append_column ( child_1.el );
365 var description = new Pango.FontDescription();
366 description.set_size(8000);
367 this.el.modify_font(description);
372 this.el.cursor_changed.connect( () => {
373 var sel = this.el.get_selection();
375 if (sel.count_selected_rows() < 1) {
377 print("selected rows < 1\n");
382 //console.log('changed');
386 sel.get_selected(out mod, out iter);
389 0, file + ":" + line,
391 2, GLib.Markup.escape_text(line + ": " + msg),
401 _this.compile_result_store.el.get_value(iter, 3, out value);
402 var fname = (string)value;
404 _this.compile_result_store.el.get_value(iter, 1, out lvalue);
405 var line = (int) lvalue;
412 print ("loadfile %s : %d", fname,line);
414 _this.sourceview.loadFile(fname, line);
422 // user defined functions
424 public class Xcls_compile_result_store : Object
426 public Gtk.TreeStore el;
427 private Xcls_ValaCompileErrors _this;
433 public Xcls_compile_result_store(Xcls_ValaCompileErrors _owner )
436 _this.compile_result_store = this;
437 this.el = new Gtk.TreeStore( 4, typeof(string), typeof(int), typeof(string), typeof(string) );
441 // set gobject values
444 // user defined functions
446 public class Xcls_column : Object
448 public Gtk.TreeViewColumn el;
449 private Xcls_ValaCompileErrors _this;
455 public Xcls_column(Xcls_ValaCompileErrors _owner )
458 this.el = new Gtk.TreeViewColumn();
462 // set gobject values
463 this.el.title = "Compile output";
464 var child_0 = new Xcls_renderer( _this );
466 this.el.pack_start ( child_0.el , true );
471 this.el.add_attribute(_this.renderer.el , "markup", 2 );
476 // user defined functions
478 public class Xcls_renderer : Object
480 public Gtk.CellRendererText el;
481 private Xcls_ValaCompileErrors _this;
487 public Xcls_renderer(Xcls_ValaCompileErrors _owner )
490 _this.renderer = this;
491 this.el = new Gtk.CellRendererText();
495 // set gobject values
498 // user defined functions
500 public class Xcls_ScrolledWindow13 : Object
502 public Gtk.ScrolledWindow el;
503 private Xcls_ValaCompileErrors _this;
509 public Xcls_ScrolledWindow13(Xcls_ValaCompileErrors _owner )
512 this.el = new Gtk.ScrolledWindow( null, null );
516 // set gobject values
517 var child_0 = new Xcls_sourceview( _this );
519 this.el.add ( child_0.el );
522 // user defined functions
524 public class Xcls_sourceview : Object
526 public Gtk.SourceView el;
527 private Xcls_ValaCompileErrors _this;
531 public string curfname;
534 public Xcls_sourceview(Xcls_ValaCompileErrors _owner )
537 _this.sourceview = this;
538 this.el = new Gtk.SourceView();
542 // set gobject values
543 this.el.editable = false;
544 this.el.show_line_marks = true;
545 this.el.show_line_numbers = true;
551 var description = Pango.FontDescription.from_string("monospace");
552 description.set_size(8000);
553 this.el.override_font(description);
555 var attrs = new Gtk.SourceMarkAttributes();
556 var pink = new Gdk.RGBA();
557 pink.parse ( "pink");
558 attrs.set_background ( pink);
559 attrs.set_icon_name ( "process-stop");
560 attrs.query_tooltip_text.connect(( mark) => {
561 //print("tooltip query? %s\n", mark.name);
565 this.el.set_mark_attributes ("error", attrs, 1);
570 // user defined functions
571 public void loadFile (string fname, int line ) {
577 var buf = ((Gtk.SourceBuffer)(this.el.get_buffer()));
579 if (this.curfname != fname) {
580 this.curfname = fname;
583 Regex regex = new Regex("\\.vala$");
585 var bjsf = regex.replace(fname,fname.length , 0 , ".bjs");
587 var p = _this.window.project;
589 var jsr = p.getByPath(bjsf);
591 if (_this.file != null) {
592 // remove listeners from the file...
609 buf.get_bounds (out start, out end);
611 buf.remove_source_marks (start, end, null);
616 FileUtils.get_contents(fname, out str);
618 buf.set_text(str, str.length);
619 var lm = Gtk.SourceLanguageManager.get_default();
622 buf.set_language(lm.get_language("vala"));
625 this.el.grab_focus();
629 var lines = _this.notices.get_object_member(fname);
632 lines.foreach_member((obj, line, node) => {
635 // print("get inter\n");
636 var eline = int.parse(line) -1 ;
639 buf.get_iter_at_line( out iter, eline);
640 //print("mark line\n");
641 var msg = "Line: %d".printf(eline+1);
642 var ar = lines.get_array_member(line);
643 for (var i = 0 ; i < ar.get_length(); i++) {
644 msg += (msg.length > 0) ? "\n" : "";
645 msg += ar.get_string_element(i);
649 buf.create_source_mark(msg, "error", iter);
652 // jump to the line...
654 buf.get_iter_at_line (out liter, line);
655 print("Scroll to \n");
656 this.el.scroll_to_iter (liter, 0.0f, false, 0.0f, 0.5f);
657 print("End Scroll to \n");