src/Builder4/Editor.bjs
[roobuilder] / src / Builder4 / Editor.vala
1 static Editor  _Editor;
2
3 public class Editor : Object
4 {
5         public Gtk.Box el;
6         private Editor  _this;
7
8         public static Editor singleton()
9         {
10                 if (_Editor == null) {
11                     _Editor= new Editor();
12                 }
13                 return _Editor;
14         }
15         public Xcls_save_button save_button;
16         public Xcls_close_btn close_btn;
17         public Xcls_RightEditor RightEditor;
18         public Xcls_view view;
19         public Xcls_buffer buffer;
20         public Xcls_keystate keystate;
21         public Xcls_search_entry search_entry;
22         public Xcls_search_results search_results;
23         public Xcls_nextBtn nextBtn;
24         public Xcls_backBtn backBtn;
25         public Xcls_search_settings search_settings;
26         public Xcls_case_sensitive case_sensitive;
27         public Xcls_regex regex;
28         public Xcls_multiline multiline;
29         public Xcls_navigationwindow navigationwindow;
30         public Xcls_navigation navigation;
31         public Xcls_navliststore navliststore;
32
33                 // my vars (def)
34         public int pos_root_x;
35         public Xcls_MainWindow window;
36         public bool dirty;
37         public int pos_root_y;
38         public bool pos;
39         public int last_error_counter;
40         public GtkSource.SearchContext searchcontext;
41         public int last_search_end;
42         public signal void save ();
43         public JsRender.JsRender? file;
44         public JsRender.Node node;
45         public JsRender.NodeProp? prop;
46         public string activeEditor;
47
48         // ctor
49         public Editor()
50         {
51                 _this = this;
52                 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
53
54                 // my vars (dec)
55                 this.window = null;
56                 this.dirty = false;
57                 this.pos = false;
58                 this.last_error_counter = 0;
59                 this.searchcontext = null;
60                 this.last_search_end = 0;
61                 this.file = null;
62                 this.node = null;
63                 this.prop = null;
64                 this.activeEditor = "\"\"";
65
66                 // set gobject values
67                 this.el.homogeneous = false;
68                 this.el.hexpand = true;
69                 this.el.vexpand = true;
70                 var child_1 = new Xcls_Paned1( _this );
71                 child_1.ref();
72                 this.el.append( child_1.el );
73         }
74
75         // user defined functions
76         public bool saveContents ()  {
77             
78             
79             if (_this.file == null) {
80                 return true;
81             }
82             
83              
84              
85              var str = _this.buffer.toString();
86              
87              _this.buffer.checkSyntax();
88              
89              
90              
91              // LeftPanel.model.changed(  str , false);
92              _this.dirty = false;
93              _this.save_button.el.sensitive = false;
94              
95             // find the text for the node..
96             if (_this.file.xtype != "PlainFile") {
97                // in theory these properties have to exist!?!
98                 this.prop.val = str;
99                 //this.window.windowstate.left_props.reload();
100             } else {
101                 _this.file.setSource(  str );
102              }
103             
104             // call the signal..
105             this.save();
106             
107             return true;
108         
109         }
110         public void forwardSearch (bool change_focus) {
111         
112                 if (this.searchcontext == null) {
113                         return;
114                 } 
115         
116                 Gtk.TextIter beg, st,en;
117                  bool has_wrapped_around;
118                 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end);
119                 if (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {
120                 
121                         this.last_search_end = 0; // not sure if this should happen
122                 } else {
123                         if (has_wrapped_around) {
124                                 return;
125                         }
126                 
127                         this.last_search_end = en.get_offset();
128                         if (change_focus) {
129                                 this.view.el.grab_focus();
130                         }
131                         this.buffer.el.place_cursor(st);
132                         this.view.el.scroll_to_iter(st,  0.1f, true, 0.0f, 0.5f);
133                 }
134          
135         }
136         public void show (JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)
137         {
138             this.reset();
139             this.file = file;    
140             
141             if (file.xtype != "PlainFile") {
142                 this.prop = prop;
143                 this.node = node;
144         
145                 // find the text for the node..
146                 this.view.load( prop.val );
147                 this.updateErrorMarks();
148                 
149                 
150                 
151                 this.close_btn.el.show();       
152             
153             } else {
154                 this.view.load(        file.toSource() );
155                  this.updateErrorMarks();
156                 this.close_btn.el.hide();
157                 var ls = file.getLanguageServer();
158                 ls.documentSymbols.begin(file, (a,o) => {
159                         _this.navigation.show(ls.documentSymbols.end(o)); 
160                 });
161                 //documentSymbols
162                 
163             }
164          
165         }
166         public void backSearch (bool change_focus) {
167         
168                 if (this.searchcontext == null) {
169                         return;
170                 }
171                 
172                 Gtk.TextIter beg, st,en;
173                 bool has_wrapped_around;
174                 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );
175                 
176                 if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {
177                         this.last_search_end = 0;
178                 } else {
179                         this.last_search_end = en.get_offset();
180                         if (change_focus) {
181                                 this.view.el.grab_focus();
182                         }
183                         this.buffer.el.place_cursor(st);
184                         this.view.el.scroll_to_iter(st,  0.1f, true, 0.0f, 0.5f);
185                 }
186         
187         }
188         public string tempFileContents () {
189            
190            
191            if (_this.file == null) {
192                return "";
193            }
194                 var str= this.buffer.toString();
195                 if (_this.file.xtype == "PlainFile") {
196             
197                 return str;
198             
199             }
200           
201               
202              
203             GLib.debug("calling validate");    
204             // clear the buttons.
205                 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
206                         return this.file.toSource(); ;
207                 }
208                 
209                 var oldcode  = _this.prop.val;
210                 _this.prop.val = str;
211             var ret = _this.file.toSource();
212             _this.prop.val = oldcode;
213             return ret;
214             
215         }
216         public void reset () {
217                  this.file = null;    
218              
219             this.node = null;
220             this.prop = null;
221                 this.searchcontext = null;
222           
223         }
224         public int search (string in_txt) {
225         
226                 var s = new GtkSource.SearchSettings();
227                 s.case_sensitive = _this.case_sensitive.el.active;
228                 s.regex_enabled = _this.regex.el.active;        
229                 s.wrap_around = false;
230                 
231                 this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);
232                 this.searchcontext.set_highlight(true);
233                 var txt = in_txt;
234                 
235                 if (_this.multiline.el.active) {
236                         txt = in_txt.replace("\\n", "\n");
237                 }
238                 
239                 s.set_search_text(txt);
240                 Gtk.TextIter beg, st,en;
241                  
242                 this.buffer.el.get_start_iter(out beg);
243                 bool has_wrapped_around;
244                 this.searchcontext.forward(beg, out st, out en, out has_wrapped_around);
245                 this.last_search_end = 0;
246                 
247                 return this.searchcontext.get_occurrences_count();
248         
249          
250            
251         
252         }
253         public void updateErrorMarks () {
254                 
255          
256         
257                 var buf = _this.buffer.el;
258                 Gtk.TextIter start;
259                 Gtk.TextIter end;     
260                 buf.get_bounds (out start, out end);
261         
262                 
263         
264          
265                 //GLib.debug("highlight errors");                
266         
267                  // we should highlight other types of errors..
268         
269                 if (_this.window.windowstate.state != WindowState.State.CODEONLY 
270                         &&
271                         _this.window.windowstate.state != WindowState.State.CODE
272                         ) {
273                         //GLib.debug("windowstate != CODEONLY?");
274                         
275                         return;
276                 } 
277         
278                  
279                 if (_this.file == null) {
280                         GLib.debug("file is null?");
281                         return;
282         
283                 }
284                 var ar = this.file.getErrors();
285                 if (ar.size < 1) {
286                         buf.remove_source_marks (start, end, "ERR");
287                         buf.remove_source_marks (start, end, "WARN");
288                         buf.remove_source_marks (start, end, "DEPR");
289                         buf.remove_tag_by_name ("ERR", start, end);
290                         buf.remove_tag_by_name ("WARN", start, end);
291                         buf.remove_tag_by_name ("DEPR", start, end);
292                         this.last_error_counter = file.error_counter ;
293                         //GLib.debug("highlight %s :  %s has no errors", this.file.relpath, category);
294                         return;
295                 }
296                 
297         
298          // basicaly check if there is no change, then we do not do any update..
299          // we can do this by just using an error counter?
300          // if that's changed then we will do an update, otherwise dont bother.
301                   
302                 
303                 var offset = 0;
304                 var hoffset = 0;
305         
306                 var tlines = buf.get_line_count () +1;
307                 
308                 if (_this.prop != null) {
309                         // this still seems flaky...
310         
311                         tlines = _this.prop.end_line;
312                         offset = _this.prop.start_line;
313                         hoffset = _this.node.node_pad.length + 2; //shift it left  by 2 ? ..
314                         
315                          
316                 } else {
317                         // no update...
318                         if (this.last_error_counter == file.error_counter) {
319                         
320                                 return;
321                         }
322                 
323                 }
324                 buf.remove_source_marks (start, end, "ERR");
325                 buf.remove_source_marks (start, end, "WARN");
326                 buf.remove_source_marks (start, end, "DEPR");
327                 buf.remove_tag_by_name ("ERR", start, end);
328                 buf.remove_tag_by_name ("WARN", start, end);
329                 buf.remove_tag_by_name ("DEPR", start, end);
330                 
331                 foreach(var diag in ar) { 
332                      Gtk.TextIter iter;
333         //        print("get inter\n");
334                     var eline = (int)diag.range.start.line - offset;
335                     var eline_to = (int)diag.range.end.line - offset;
336                     //var eline =  diag.range.end_line - offset;
337                     //GLib.debug("GOT ERROR on line %d -- converted to %d  (offset = %d)",
338                     //  err.line ,eline, offset);
339                     
340                     
341                     if (eline > tlines || eline < 0) {
342                         continue;
343                     }
344                     
345                     buf.get_iter_at_line( out iter, eline);
346                         var msg = "Line: %d %s : %s".printf(eline+1, diag.category, diag.message);
347                     buf.create_source_mark( msg, diag.category, iter);
348                     
349                     var spos = (int)diag.range.start.character - hoffset;
350                     if (spos < 0) { spos =0 ; }
351                     if (spos > iter.get_chars_in_line()) {
352                         spos = iter.get_chars_in_line();
353                 }
354                         buf.get_iter_at_line( out iter, eline_to);
355                         var epos = (int)diag.range.end.character - hoffset;
356                     if (epos < 0) { epos =0 ; }
357                     if (epos > iter.get_chars_in_line()) {
358                         epos = iter.get_chars_in_line();
359                 }
360                      
361                     
362                     buf.get_iter_at_line_offset( out start, eline, spos); 
363                    
364                     buf.get_iter_at_line_offset( out end, eline_to,epos); 
365                         
366                     buf.apply_tag_by_name(diag.category, start, end);
367                     
368                    // GLib.debug("set line %d to %s", eline, msg);
369                     //this.marks.set(eline, msg);
370                 }
371                 this.last_error_counter = file.error_counter ;
372         
373         
374         
375          
376         
377         }
378         public void scroll_to_line (int line) {
379         
380                 GLib.Timeout.add(500, () => {
381            
382                         var buf = this.view.el.get_buffer();
383         
384                         var sbuf = (GtkSource.Buffer) buf;
385         
386         
387                         Gtk.TextIter iter;   
388                         sbuf.get_iter_at_line(out iter,  line);
389                         this.view.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);
390                         return false;
391                 });   
392         }
393         public class Xcls_Paned1 : Object
394         {
395                 public Gtk.Paned el;
396                 private Editor  _this;
397
398
399                         // my vars (def)
400
401                 // ctor
402                 public Xcls_Paned1(Editor _owner )
403                 {
404                         _this = _owner;
405                         this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL );
406
407                         // my vars (dec)
408
409                         // set gobject values
410                         var child_1 = new Xcls_Box2( _this );
411                         child_1.ref();
412                         this.el.start_child = child_1.el;
413                         new Xcls_navigationwindow( _this );
414                         this.el.end_child = _this.navigationwindow.el;
415                 }
416
417                 // user defined functions
418         }
419         public class Xcls_Box2 : Object
420         {
421                 public Gtk.Box el;
422                 private Editor  _this;
423
424
425                         // my vars (def)
426
427                 // ctor
428                 public Xcls_Box2(Editor _owner )
429                 {
430                         _this = _owner;
431                         this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
432
433                         // my vars (dec)
434
435                         // set gobject values
436                         var child_1 = new Xcls_Box3( _this );
437                         child_1.ref();
438                         this.el.append( child_1.el );
439                         new Xcls_RightEditor( _this );
440                         this.el.append( _this.RightEditor.el );
441                         var child_3 = new Xcls_Box15( _this );
442                         child_3.ref();
443                         this.el.append ( child_3.el  );
444                 }
445
446                 // user defined functions
447         }
448         public class Xcls_Box3 : Object
449         {
450                 public Gtk.Box el;
451                 private Editor  _this;
452
453
454                         // my vars (def)
455
456                 // ctor
457                 public Xcls_Box3(Editor _owner )
458                 {
459                         _this = _owner;
460                         this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
461
462                         // my vars (dec)
463
464                         // set gobject values
465                         this.el.homogeneous = false;
466                         this.el.hexpand = true;
467                         new Xcls_save_button( _this );
468                         this.el.append( _this.save_button.el );
469                         var child_2 = new Xcls_Label5( _this );
470                         child_2.ref();
471                         this.el.append( child_2.el );
472                         var child_3 = new Xcls_Scale6( _this );
473                         child_3.ref();
474                         this.el.append( child_3.el );
475                         new Xcls_close_btn( _this );
476                         this.el.append( _this.close_btn.el );
477                 }
478
479                 // user defined functions
480         }
481         public class Xcls_save_button : Object
482         {
483                 public Gtk.Button el;
484                 private Editor  _this;
485
486
487                         // my vars (def)
488
489                 // ctor
490                 public Xcls_save_button(Editor _owner )
491                 {
492                         _this = _owner;
493                         _this.save_button = this;
494                         this.el = new Gtk.Button();
495
496                         // my vars (dec)
497
498                         // set gobject values
499                         this.el.label = "Save";
500
501                         //listeners
502                         this.el.clicked.connect( () => { 
503                             _this.saveContents();
504                         });
505                 }
506
507                 // user defined functions
508         }
509
510         public class Xcls_Label5 : Object
511         {
512                 public Gtk.Label el;
513                 private Editor  _this;
514
515
516                         // my vars (def)
517
518                 // ctor
519                 public Xcls_Label5(Editor _owner )
520                 {
521                         _this = _owner;
522                         this.el = new Gtk.Label( null );
523
524                         // my vars (dec)
525
526                         // set gobject values
527                         this.el.hexpand = true;
528                 }
529
530                 // user defined functions
531         }
532
533         public class Xcls_Scale6 : Object
534         {
535                 public Gtk.Scale el;
536                 private Editor  _this;
537
538
539                         // my vars (def)
540
541                 // ctor
542                 public Xcls_Scale6(Editor _owner )
543                 {
544                         _this = _owner;
545                         this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1);
546
547                         // my vars (dec)
548
549                         // set gobject values
550                         this.el.width_request = 200;
551                         this.el.has_origin = true;
552                         this.el.draw_value = false;
553                         this.el.digits = 0;
554                         this.el.sensitive = true;
555
556                         // init method
557
558                         {
559                                 //this.el.set_range(6,30);
560                                 this.el.set_value ( BuilderApplication.settings.editor_font_size);
561                                 BuilderApplication.settings.editor_font_size_updated.connect(
562                                         () => {
563                                                 BuilderApplication.settings.editor_font_size_inchange = true;
564                                         //      GLib.debug("update range");
565                                                 this.el.set_value (BuilderApplication.settings.editor_font_size);
566                                                 BuilderApplication.settings.editor_font_size_inchange = false;
567                                         }
568                                 );
569                                 
570                          
571                         }
572
573                         //listeners
574                         this.el.change_value.connect( (st, val ) => {
575                                 if (BuilderApplication.settings.editor_font_size_inchange) {
576                                         return false;
577                                 }
578                                 BuilderApplication.settings.editor_font_size = val;
579                                 return false;
580                         });
581                 }
582
583                 // user defined functions
584         }
585
586         public class Xcls_close_btn : Object
587         {
588                 public Gtk.Button el;
589                 private Editor  _this;
590
591
592                         // my vars (def)
593
594                 // ctor
595                 public Xcls_close_btn(Editor _owner )
596                 {
597                         _this = _owner;
598                         _this.close_btn = this;
599                         this.el = new Gtk.Button();
600
601                         // my vars (dec)
602
603                         // set gobject values
604                         this.el.icon_name = "window-close";
605                         var child_1 = new Xcls_Image8( _this );
606                         child_1.ref();
607                         this.el.child = child_1.el;
608
609                         //listeners
610                         this.el.clicked.connect( () => { 
611                             _this.saveContents();
612                             _this.window.windowstate.switchState(WindowState.State.PREVIEW);
613                         });
614                 }
615
616                 // user defined functions
617         }
618         public class Xcls_Image8 : Object
619         {
620                 public Gtk.Image el;
621                 private Editor  _this;
622
623
624                         // my vars (def)
625
626                 // ctor
627                 public Xcls_Image8(Editor _owner )
628                 {
629                         _this = _owner;
630                         this.el = new Gtk.Image();
631
632                         // my vars (dec)
633
634                         // set gobject values
635                         this.el.icon_name = "window-close";
636                         this.el.icon_size = Gtk.IconSize.NORMAL;
637                 }
638
639                 // user defined functions
640         }
641
642
643
644         public class Xcls_RightEditor : Object
645         {
646                 public Gtk.ScrolledWindow el;
647                 private Editor  _this;
648
649
650                         // my vars (def)
651
652                 // ctor
653                 public Xcls_RightEditor(Editor _owner )
654                 {
655                         _this = _owner;
656                         _this.RightEditor = this;
657                         this.el = new Gtk.ScrolledWindow();
658
659                         // my vars (dec)
660
661                         // set gobject values
662                         this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
663                         this.el.vexpand = true;
664                         this.el.overlay_scrolling = false;
665                         this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
666                         new Xcls_view( _this );
667                         this.el.child = _this.view.el;
668                 }
669
670                 // user defined functions
671         }
672         public class Xcls_view : Object
673         {
674                 public GtkSource.View el;
675                 private Editor  _this;
676
677
678                         // my vars (def)
679                 public Gtk.CssProvider css;
680
681                 // ctor
682                 public Xcls_view(Editor _owner )
683                 {
684                         _this = _owner;
685                         _this.view = this;
686                         this.el = new GtkSource.View();
687
688                         // my vars (dec)
689                         this.css = null;
690
691                         // set gobject values
692                         this.el.auto_indent = true;
693                         this.el.indent_width = 4;
694                         this.el.name = "editor-view";
695                         this.el.show_line_marks = true;
696                         this.el.insert_spaces_instead_of_tabs = true;
697                         this.el.show_line_numbers = true;
698                         this.el.hexpand = true;
699                         this.el.vexpand = true;
700                         this.el.has_tooltip = true;
701                         this.el.css_classes = { "code-editor" };
702                         this.el.tab_width = 4;
703                         this.el.highlight_current_line = true;
704                         new Xcls_buffer( _this );
705                         this.el.buffer = _this.buffer.el;
706                         new Xcls_keystate( _this );
707                         this.el.add_controller(  _this.keystate.el );
708                         var child_3 = new Xcls_EventControllerScroll13( _this );
709                         child_3.ref();
710                         this.el.add_controller(  child_3.el );
711                         var child_4 = new Xcls_GestureClick14( _this );
712                         child_4.ref();
713                         this.el.add_controller(  child_4.el );
714
715                         // init method
716
717                         this.el.completion.add_provider(
718                                 new Palete.CompletionProvider(_this)
719                         );
720                         
721                         // hover seems pretty useless.. - ??
722                         //var hover = this.el.get_hover();
723                         //hover.add_provider(new Palete.HoverProvider(_this));
724                         
725                         //this.el.completion.unblock_interactive();
726                         this.el.completion.select_on_show = true; // select
727                         //this.el.completion.remember_info_visibility    = true;
728                         
729                         
730                         var attrs = new GtkSource.MarkAttributes();
731                         
732                         attrs.set_icon_name ( "process-stop");    
733                         attrs.query_tooltip_text.connect(( mark) => {
734                              GLib.debug("tooltip query? %s", mark.name);
735                             return strdup( mark.name);
736                         });
737                          attrs.query_tooltip_markup.connect(( mark) => {
738                              GLib.debug("tooltip query? %s", mark.name);
739                             return strdup( mark.name);
740                         });
741                         this.el.set_mark_attributes ("ERR", attrs, 1);
742                         attrs.ref();
743                         
744                         
745                         var wattrs = new GtkSource.MarkAttributes();
746                         wattrs.set_icon_name ( "process-stop");    
747                         wattrs.query_tooltip_text.connect(( mark) => {
748                              GLib.debug("tooltip query? %s", mark.name);
749                             return strdup(mark.name);
750                         });
751                         wattrs.query_tooltip_markup.connect(( mark) => {
752                              GLib.debug("tooltip query? %s", mark.name);
753                             return strdup(mark.name);
754                         });
755                         this.el.set_mark_attributes ("WARN", wattrs, 1);
756                         wattrs.ref();
757                         
758                          
759                         var dattrs = new GtkSource.MarkAttributes();
760                          
761                         dattrs.set_icon_name ( "process-stop"); 
762                         
763                         dattrs.query_tooltip_text.connect(( mark) => {
764                                 GLib.debug("tooltip query? %s", mark.name);
765                             return strdup(mark.name);
766                         });
767                         //dattrs.query_tooltip_markup.connect(( mark) => {
768                         //      GLib.debug("tooltip query? %s", mark.name);
769                          //   return strdup(mark.name);
770                         //});
771                         this.el.set_mark_attributes ("DEPR", dattrs, 1);
772                         dattrs.ref();    
773                         
774                          this.el.get_space_drawer().set_matrix(null);
775                          this.el.get_space_drawer().set_types_for_locations( 
776                                 GtkSource.SpaceLocationFlags.ALL,
777                                 GtkSource.SpaceTypeFlags.ALL
778                         );
779                         this.el.get_space_drawer().set_enable_matrix(true);
780
781                         //listeners
782                         this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
783                                 
784                                 //GLib.debug("query tooltip");
785                                 Gtk.TextIter iter;
786                                 int trailing;
787                                 
788                                 var yoff = (int) _this.RightEditor.el.vadjustment.value;
789                                 
790                                 // I think this is problematic - if it's compliing  / updating at same time as query.
791                                 
792                                 //if (_this.window.statusbar_compile_spinner.el.spinning) {
793                                 //      return false;
794                                 //}
795                                 
796                                 this.el.get_iter_at_position (out iter, out trailing,  x,  y + yoff);
797                                  
798                                 var l = iter.get_line();
799                         
800                                 
801                                  
802                                 // GLib.debug("query tooltip line %d", (int) l);
803                                 if (l < 0) {
804                         
805                                         return false;
806                                 }
807                                 /*
808                                 if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {
809                                         GLib.debug("line %d setting tip to %s", l,  _this.buffer.marks.get(l));
810                                         tooltip.set_text(_this.buffer.marks.get(l).dup());
811                                         return true;
812                                 }
813                          
814                                 return false;
815                                 */
816                                 
817                                   
818                                 // this crashes?? - not sure why.
819                                 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
820                                 if (marks.is_empty()) {
821                                         marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
822                                 }
823                                 if (marks.is_empty()) {
824                                         marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
825                                 }
826                                 
827                                 // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length());
828                                 var str = "";
829                                 marks.@foreach((m) => { 
830                                         //GLib.debug("got mark %s", m.name);
831                                         str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name;
832                                 });
833                                 // true if there is a mark..
834                                 if (str.length > 0 ) {
835                                         tooltip.set_text( str );
836                                 }
837                                 return str.length > 0 ? true : false;
838                                  
839                         });
840                 }
841
842                 // user defined functions
843                 public void load (string str) {
844                 
845                 // show the help page for the active node..
846                    //this.get('/Help').show();
847                  
848                   // this.get('/BottomPane').el.set_current_page(0);
849                         GLib.debug("load called - Reset undo buffer");
850                         
851                     var buf = (GtkSource.Buffer)this.el.get_buffer();
852                     buf.begin_irreversible_action();
853                     buf.set_text(str, str.length);
854                     buf.end_irreversible_action();
855                     
856                     var lm = GtkSource.LanguageManager.get_default();
857                     var lang = "vala";
858                     if (_this.file != null) {
859                          lang = _this.file.language;
860                     }
861                     print("lang=%s, content_type = %s\n", lang, _this.file.content_type);
862                     var lg = _this.file.content_type.length > 0  ?
863                             lm.guess_language(_this.file.path, _this.file.content_type) :
864                             lm.get_language(lang);
865                      
866                    
867                     ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg); 
868                 
869                     this.el.insert_spaces_instead_of_tabs = true;
870                     if (lg != null) {
871                                 print("sourcelanguage  = %s\n", lg.name);
872                                 if (lg.name == "Vala") {
873                                     this.el.insert_spaces_instead_of_tabs = false;
874                                 }
875                      }
876                     _this.dirty = false;
877                     this.el.grab_focus();
878                     _this.save_button.el.sensitive = false;
879                     _this.last_error_counter = -1;
880                 }
881         }
882         public class Xcls_buffer : Object
883         {
884                 public GtkSource.Buffer el;
885                 private Editor  _this;
886
887
888                         // my vars (def)
889                 public int error_line;
890                 public Gee.HashMap<int,string>? xmarks;
891                 public bool check_queued;
892
893                 // ctor
894                 public Xcls_buffer(Editor _owner )
895                 {
896                         _this = _owner;
897                         _this.buffer = this;
898                         this.el = new GtkSource.Buffer( null );
899
900                         // my vars (dec)
901                         this.error_line = -1;
902                         this.xmarks = null;
903                         this.check_queued = false;
904
905                         // set gobject values
906                         this.el.highlight_syntax = true;
907                         this.el.highlight_matching_brackets = true;
908                         this.el.enable_undo = true;
909
910                         // init method
911
912                         var buf = this.el;
913                         buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
914                         buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
915                         buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
916                         buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
917                         buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
918                         buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
919                         buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
920                         buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
921                         
922                         
923                         buf.create_tag ("ERR", "weight", Pango.Weight.BOLD, "background", "pink");
924                         buf.create_tag ("WARN", "weight", Pango.Weight.BOLD, "background", "#ABF4EB");
925                         buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
926
927                         //listeners
928                         this.el.changed.connect( () => {
929                             // check syntax??
930                             // ??needed..??
931                             _this.save_button.el.sensitive = true;
932                             print("EDITOR CHANGED");
933                             this.checkSyntax();
934                            
935                             _this.dirty = true;
936                         
937                             // this.get('/LeftPanel.model').changed(  str , false);
938                             return ;
939                         });
940                 }
941
942                 // user defined functions
943                 public bool OLDhighlightErrorsJson (string type, Json.Object obj) {
944                         Gtk.TextIter start;
945                         Gtk.TextIter end;     
946                         this.el.get_bounds (out start, out end);
947                 
948                         this.el.remove_source_marks (start, end, type);
949                         GLib.debug("highlight errors");          
950                 
951                          // we should highlight other types of errors..
952                 
953                         if (!obj.has_member(type)) {
954                                 GLib.debug("Return has no errors\n");
955                                 return true;
956                         }
957                 
958                         if (_this.window.windowstate.state != WindowState.State.CODEONLY 
959                                 &&
960                                 _this.window.windowstate.state != WindowState.State.CODE
961                                 ) {
962                                 GLib.debug("windowstate != CODEONLY?");
963                                 
964                                 return true;
965                         } 
966                 
967                         //this.marks = new Gee.HashMap<int,string>();
968                         var err = obj.get_object_member(type);
969                  
970                         if (_this.file == null) {
971                                 GLib.debug("file is null?");
972                                 return true;
973                 
974                         }
975                         var valafn = _this.file.path;
976                 
977                         if (_this.file.xtype != "PlainFile") {
978                 
979                                 valafn = "";
980                                 try {             
981                                         var  regex = new Regex("\\.bjs$");
982                                         // should not happen
983                                         valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
984                                 } catch (GLib.RegexError e) {
985                                         return true;
986                                 }   
987                 
988                 
989                 
990                         }
991                         if (!err.has_member(valafn)) {
992                                 GLib.debug("File path has no errors");
993                                 return  true;
994                         }
995                 
996                         var lines = err.get_object_member(valafn);
997                         
998                         var offset = 1;
999                         if (obj.has_member("line_offset")) { // ?? why??
1000                                 offset = (int)obj.get_int_member("line_offset") + 1;
1001                         }
1002                 
1003                 
1004                         var tlines = this.el.get_line_count () +1;
1005                         
1006                         if (_this.prop != null) {
1007                         
1008                                 tlines = _this.prop.end_line + 1;
1009                                 offset = _this.prop.start_line + 1;
1010                         
1011                         }
1012                         
1013                 
1014                 
1015                         lines.foreach_member((obj, line, node) => {
1016                                 
1017                              Gtk.TextIter iter;
1018                 //        print("get inter\n");
1019                             var eline = int.parse(line) - offset;
1020                             GLib.debug("GOT ERROR on line %s -- converted to %d  (offset = %d)\n", line,eline, offset);
1021                             
1022                             
1023                             if (eline > tlines || eline < 0) {
1024                                 return;
1025                             }
1026                            
1027                             
1028                             this.el.get_iter_at_line( out iter, eline);
1029                             //print("mark line\n");
1030                             var msg  = "";
1031                             var ar = lines.get_array_member(line);
1032                             for (var i = 0 ; i < ar.get_length(); i++) {
1033                                 if (ar.get_string_element(i) == "Success") {
1034                                         continue;
1035                                 }
1036                                         msg += (msg.length > 0) ? "\n" : "";
1037                                         msg += ar.get_string_element(i);
1038                                 }
1039                                 if (msg == "") {
1040                                         return;
1041                                 }
1042                                 msg = "Line: %d".printf(eline+1) +  " " + msg;
1043                             this.el.create_source_mark(msg, type, iter);
1044                             GLib.debug("set line %d to %m", eline, msg);
1045                            // this.marks.set(eline, msg);
1046                         } );
1047                         return false;
1048                 
1049                 
1050                 
1051                 
1052                 
1053                         }
1054                 public bool checkSyntax () {
1055                  
1056                     
1057                     var str = this.toString();
1058                     
1059                     // needed???
1060                     if (this.error_line > 0) {
1061                          Gtk.TextIter start;
1062                          Gtk.TextIter end;     
1063                         this.el.get_bounds (out start, out end);
1064                 
1065                         this.el.remove_source_marks (start, end, null);
1066                     }
1067                     if (str.length < 1) {
1068                         print("checkSyntax - empty string?\n");
1069                         return true;
1070                     }
1071                     
1072                     // bit presumptiona
1073                     if (_this.file.xtype == "PlainFile") {
1074                     
1075                         // assume it's gtk...
1076                          var  oldcode =_this.file.toSource();
1077                         _this.file.setSource(str);
1078                             BuilderApplication.showSpinner("appointment soon","document change pending");
1079                         _this.file.getLanguageServer().document_change(_this.file);
1080                 
1081                         _this.file.setSource(oldcode);
1082                         
1083                                  
1084                         return true;
1085                     
1086                     }
1087                    if (_this.file == null) {
1088                        return true;
1089                    }
1090                  
1091                     
1092                 
1093                       
1094                      
1095                     GLib.debug("calling validate");    
1096                     // clear the buttons.
1097                         if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
1098                                 return true ;
1099                         }
1100                         var oldcode  = _this.prop.val;
1101                         
1102                         _this.prop.val = str;
1103                         _this.node.updated_count++;
1104                     _this.file.getLanguageServer().document_change(_this.file);
1105                     _this.node.updated_count++;
1106                     _this.prop.val = oldcode;
1107                     
1108                     
1109                     //print("done mark line\n");
1110                      
1111                     return true; // at present allow saving - even if it's invalid..
1112                 }
1113                 public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
1114                          
1115                         this.error_line = validate_res.size;
1116                 
1117                         if (this.error_line < 1) {
1118                                 return true;
1119                         }
1120                         var tlines = this.el.get_line_count ();
1121                         Gtk.TextIter iter;
1122                         var valiter = validate_res.map_iterator();
1123                         while (valiter.next()) {
1124                 
1125                         //        print("get inter\n");
1126                                 var eline = valiter.get_key();
1127                                 if (eline > tlines) {
1128                                         continue;
1129                                 }
1130                                 this.el.get_iter_at_line( out iter, eline);
1131                                 //print("mark line\n");
1132                                 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
1133                         }   
1134                         return false;
1135                 }
1136                 public string toString () {
1137                     
1138                     Gtk.TextIter s;
1139                     Gtk.TextIter e;
1140                     this.el.get_start_iter(out s);
1141                     this.el.get_end_iter(out e);
1142                     var ret = this.el.get_text(s,e,true);
1143                     //print("TO STRING? " + ret);
1144                     return ret;
1145                 }
1146         }
1147
1148         public class Xcls_keystate : Object
1149         {
1150                 public Gtk.EventControllerKey el;
1151                 private Editor  _this;
1152
1153
1154                         // my vars (def)
1155                 public bool is_control;
1156
1157                 // ctor
1158                 public Xcls_keystate(Editor _owner )
1159                 {
1160                         _this = _owner;
1161                         _this.keystate = this;
1162                         this.el = new Gtk.EventControllerKey();
1163
1164                         // my vars (dec)
1165                         this.is_control = false;
1166
1167                         // set gobject values
1168
1169                         //listeners
1170                         this.el.key_released.connect( (keyval, keycode, state) => {
1171                         
1172                                  if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1173                                         this.is_control = false;
1174                                 }
1175                             if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1176                                 GLib.debug("SAVE: ctrl-S  pressed");
1177                                 _this.saveContents();
1178                                 return;
1179                             }
1180                             
1181                             if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1182                                     GLib.debug("SAVE: ctrl-g  pressed");
1183                                         _this.forwardSearch(true);
1184                                     return;
1185                                 }
1186                                 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1187                                     GLib.debug("SAVE: ctrl-f  pressed");
1188                                         _this.search_entry.el.grab_focus();
1189                                         _this.search_entry.el.select_region(0,-1);
1190                                     return;
1191                                 }
1192                                 if (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1193                                         _this.view.el.show_completion();
1194                                 }
1195                                 
1196                                 Gtk.TextIter iter;
1197                                 _this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);  
1198                                 var line  = iter.get_line();
1199                                 var offset = iter.get_line_offset();
1200                                 GLib.debug("line  %d  off %d", line ,offset);
1201                                 if (_this.prop != null) {
1202                                         line += _this.prop.start_line + 1; // i think..
1203                                         offset += 12; // should probably be 8 without namespaced 
1204                                         GLib.debug("guess line  %d  off %d", line ,offset);
1205                                 } 
1206                             //_this.view.el.show_completion();
1207                            // print(event.key.keyval)
1208                            
1209                            
1210                            
1211                             
1212                             return;
1213                          
1214                          
1215                         });
1216                         this.el.key_pressed.connect( (keyval, keycode, state) => {
1217                         
1218                                 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1219                                         this.is_control = true;
1220                                 }
1221                                 return false;
1222                         });
1223                 }
1224
1225                 // user defined functions
1226         }
1227
1228         public class Xcls_EventControllerScroll13 : Object
1229         {
1230                 public Gtk.EventControllerScroll el;
1231                 private Editor  _this;
1232
1233
1234                         // my vars (def)
1235                 public double distance;
1236
1237                 // ctor
1238                 public Xcls_EventControllerScroll13(Editor _owner )
1239                 {
1240                         _this = _owner;
1241                         this.el = new Gtk.EventControllerScroll( Gtk.EventControllerScrollFlags.VERTICAL );
1242
1243                         // my vars (dec)
1244                         this.distance = 0.0f;
1245
1246                         // set gobject values
1247
1248                         //listeners
1249                         this.el.scroll.connect( (dx, dy) => {
1250                                 if (!_this.keystate.is_control) {
1251                                         return false;
1252                                 }
1253                                  //GLib.debug("scroll %f",  dy);
1254                                 
1255                                 this.distance += dy;
1256                                 
1257                                 //GLib.debug("scroll %f / %f",  dy, this.distance);
1258                          
1259                                  if (this.distance < -1) {
1260                          
1261                                         BuilderApplication.settings.editor_font_size ++;
1262                                         this.distance = 0;
1263                                 }
1264                                 if (this.distance > 1) {
1265                                         BuilderApplication.settings.editor_font_size --;
1266                                         this.distance = 0;
1267                                 }
1268                                  
1269                                 return true;
1270                         });
1271                 }
1272
1273                 // user defined functions
1274         }
1275
1276         public class Xcls_GestureClick14 : Object
1277         {
1278                 public Gtk.GestureClick el;
1279                 private Editor  _this;
1280
1281
1282                         // my vars (def)
1283
1284                 // ctor
1285                 public Xcls_GestureClick14(Editor _owner )
1286                 {
1287                         _this = _owner;
1288                         this.el = new Gtk.GestureClick();
1289
1290                         // my vars (dec)
1291
1292                         // set gobject values
1293                 }
1294
1295                 // user defined functions
1296         }
1297
1298
1299
1300         public class Xcls_Box15 : Object
1301         {
1302                 public Gtk.Box el;
1303                 private Editor  _this;
1304
1305
1306                         // my vars (def)
1307
1308                 // ctor
1309                 public Xcls_Box15(Editor _owner )
1310                 {
1311                         _this = _owner;
1312                         this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1313
1314                         // my vars (dec)
1315
1316                         // set gobject values
1317                         this.el.homogeneous = false;
1318                         this.el.vexpand = false;
1319                         new Xcls_search_entry( _this );
1320                         this.el.append( _this.search_entry.el );
1321                         new Xcls_search_results( _this );
1322                         this.el.append( _this.search_results.el );
1323                         new Xcls_nextBtn( _this );
1324                         this.el.append( _this.nextBtn.el );
1325                         new Xcls_backBtn( _this );
1326                         this.el.append( _this.backBtn.el );
1327                         var child_5 = new Xcls_MenuButton21( _this );
1328                         child_5.ref();
1329                         this.el.append( child_5.el );
1330                 }
1331
1332                 // user defined functions
1333         }
1334         public class Xcls_search_entry : Object
1335         {
1336                 public Gtk.SearchEntry el;
1337                 private Editor  _this;
1338
1339
1340                         // my vars (def)
1341                 public Gtk.CssProvider css;
1342
1343                 // ctor
1344                 public Xcls_search_entry(Editor _owner )
1345                 {
1346                         _this = _owner;
1347                         _this.search_entry = this;
1348                         this.el = new Gtk.SearchEntry();
1349
1350                         // my vars (dec)
1351
1352                         // set gobject values
1353                         this.el.name = "editor-search-entry";
1354                         this.el.hexpand = true;
1355                         this.el.placeholder_text = "Press enter to search";
1356                         this.el.search_delay = 3;
1357                         var child_1 = new Xcls_EventControllerKey17( _this );
1358                         child_1.ref();
1359                         this.el.add_controller(  child_1.el );
1360
1361                         //listeners
1362                         this.el.search_changed.connect( ( ) => {
1363                         
1364                         _this.search(_this.search_entry.el.text);
1365                                  _this.search_results.updateResults();
1366                         
1367                                 GLib.Timeout.add_seconds(1,() => {
1368                                          _this.search_results.updateResults();
1369                                          return false;
1370                                  });
1371                         });
1372                 }
1373
1374                 // user defined functions
1375                 public void forwardSearch (bool change_focus) {
1376                 
1377                 
1378                         _this.forwardSearch(change_focus);
1379                 
1380                 /*
1381                 
1382                         switch(_this.windowstate.state) {
1383                                 case WindowState.State.CODEONLY:
1384                                 //case WindowState.State.CODE:
1385                                         // search the code being edited..
1386                                         _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1387                                          
1388                                         break;
1389                                 case WindowState.State.PREVIEW:
1390                                         if (_this.windowstate.file.xtype == "Gtk") {
1391                                                 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1392                                         } else { 
1393                                                  _this.windowstate.window_rooview.forwardSearch(change_focus);
1394                                         }
1395                                 
1396                                         break;
1397                         }
1398                         */
1399                         
1400                 }
1401         }
1402         public class Xcls_EventControllerKey17 : Object
1403         {
1404                 public Gtk.EventControllerKey el;
1405                 private Editor  _this;
1406
1407
1408                         // my vars (def)
1409
1410                 // ctor
1411                 public Xcls_EventControllerKey17(Editor _owner )
1412                 {
1413                         _this = _owner;
1414                         this.el = new Gtk.EventControllerKey();
1415
1416                         // my vars (dec)
1417
1418                         // set gobject values
1419
1420                         //listeners
1421                         this.el.key_pressed.connect( (keyval, keycode, state) => {
1422                         
1423                                 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1424                                     GLib.debug("SAVE: ctrl-g  pressed");
1425                                         _this.forwardSearch(true);
1426                                     return true;
1427                                 }
1428                             
1429                           
1430                                 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1431                                         _this.forwardSearch(true);
1432                                         
1433                                         
1434                                     return true;
1435                         
1436                                 }    
1437                            // print(event.key.keyval)
1438                            
1439                             return false;
1440                         });
1441                 }
1442
1443                 // user defined functions
1444         }
1445
1446
1447         public class Xcls_search_results : Object
1448         {
1449                 public Gtk.Label el;
1450                 private Editor  _this;
1451
1452
1453                         // my vars (def)
1454
1455                 // ctor
1456                 public Xcls_search_results(Editor _owner )
1457                 {
1458                         _this = _owner;
1459                         _this.search_results = this;
1460                         this.el = new Gtk.Label( "No Results" );
1461
1462                         // my vars (dec)
1463
1464                         // set gobject values
1465                         this.el.margin_end = 4;
1466                         this.el.margin_start = 4;
1467                 }
1468
1469                 // user defined functions
1470                 public void updateResults () {
1471                         this.el.visible = true;
1472                         
1473                         var res = _this.searchcontext.get_occurrences_count();
1474                         if (res < 0) {
1475                                 _this.search_results.el.label = "??? Matches";          
1476                                 return;
1477                         }
1478                 
1479                         _this.nextBtn.el.sensitive = false;
1480                         _this.backBtn.el.sensitive = false;     
1481                 
1482                         if (res > 0) {
1483                                 _this.search_results.el.label = "%d Matches".printf(res);
1484                                 _this.nextBtn.el.sensitive = true;
1485                                 _this.backBtn.el.sensitive = true;
1486                                 return;
1487                         } 
1488                         _this.search_results.el.label = "No Matches";
1489                         
1490                 }
1491         }
1492
1493         public class Xcls_nextBtn : Object
1494         {
1495                 public Gtk.Button el;
1496                 private Editor  _this;
1497
1498
1499                         // my vars (def)
1500                 public bool always_show_image;
1501
1502                 // ctor
1503                 public Xcls_nextBtn(Editor _owner )
1504                 {
1505                         _this = _owner;
1506                         _this.nextBtn = this;
1507                         this.el = new Gtk.Button();
1508
1509                         // my vars (dec)
1510                         this.always_show_image = true;
1511
1512                         // set gobject values
1513                         this.el.icon_name = "go-down";
1514                         this.el.sensitive = false;
1515
1516                         //listeners
1517                         this.el.clicked.connect( (event) => {
1518                         
1519                                 _this.forwardSearch(true);
1520                                 
1521                                  
1522                         });
1523                 }
1524
1525                 // user defined functions
1526         }
1527
1528         public class Xcls_backBtn : Object
1529         {
1530                 public Gtk.Button el;
1531                 private Editor  _this;
1532
1533
1534                         // my vars (def)
1535                 public bool always_show_image;
1536
1537                 // ctor
1538                 public Xcls_backBtn(Editor _owner )
1539                 {
1540                         _this = _owner;
1541                         _this.backBtn = this;
1542                         this.el = new Gtk.Button();
1543
1544                         // my vars (dec)
1545                         this.always_show_image = true;
1546
1547                         // set gobject values
1548                         this.el.icon_name = "go-up";
1549                         this.el.sensitive = false;
1550
1551                         //listeners
1552                         this.el.clicked.connect( (event) => {
1553                         
1554                                 _this.backSearch(true);
1555                                  
1556                         });
1557                 }
1558
1559                 // user defined functions
1560         }
1561
1562         public class Xcls_MenuButton21 : Object
1563         {
1564                 public Gtk.MenuButton el;
1565                 private Editor  _this;
1566
1567
1568                         // my vars (def)
1569                 public bool always_show_image;
1570
1571                 // ctor
1572                 public Xcls_MenuButton21(Editor _owner )
1573                 {
1574                         _this = _owner;
1575                         this.el = new Gtk.MenuButton();
1576
1577                         // my vars (dec)
1578                         this.always_show_image = true;
1579
1580                         // set gobject values
1581                         this.el.icon_name = "emblem-system";
1582                         this.el.always_show_arrow = true;
1583                         new Xcls_search_settings( _this );
1584                         this.el.popover = _this.search_settings.el;
1585                 }
1586
1587                 // user defined functions
1588         }
1589         public class Xcls_search_settings : Object
1590         {
1591                 public Gtk.Popover el;
1592                 private Editor  _this;
1593
1594
1595                         // my vars (def)
1596
1597                 // ctor
1598                 public Xcls_search_settings(Editor _owner )
1599                 {
1600                         _this = _owner;
1601                         _this.search_settings = this;
1602                         this.el = new Gtk.Popover();
1603
1604                         // my vars (dec)
1605
1606                         // set gobject values
1607                         var child_1 = new Xcls_Box23( _this );
1608                         child_1.ref();
1609                         this.el.child = child_1.el;
1610                 }
1611
1612                 // user defined functions
1613         }
1614         public class Xcls_Box23 : Object
1615         {
1616                 public Gtk.Box el;
1617                 private Editor  _this;
1618
1619
1620                         // my vars (def)
1621
1622                 // ctor
1623                 public Xcls_Box23(Editor _owner )
1624                 {
1625                         _this = _owner;
1626                         this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1627
1628                         // my vars (dec)
1629
1630                         // set gobject values
1631                         new Xcls_case_sensitive( _this );
1632                         this.el.append( _this.case_sensitive.el );
1633                         new Xcls_regex( _this );
1634                         this.el.append( _this.regex.el );
1635                         new Xcls_multiline( _this );
1636                         this.el.append( _this.multiline.el );
1637                 }
1638
1639                 // user defined functions
1640         }
1641         public class Xcls_case_sensitive : Object
1642         {
1643                 public Gtk.CheckButton el;
1644                 private Editor  _this;
1645
1646
1647                         // my vars (def)
1648
1649                 // ctor
1650                 public Xcls_case_sensitive(Editor _owner )
1651                 {
1652                         _this = _owner;
1653                         _this.case_sensitive = this;
1654                         this.el = new Gtk.CheckButton();
1655
1656                         // my vars (dec)
1657
1658                         // set gobject values
1659                         this.el.label = "Case Sensitive";
1660
1661                         // init method
1662
1663                         {
1664                                 this.el.show();
1665                         }
1666                 }
1667
1668                 // user defined functions
1669         }
1670
1671         public class Xcls_regex : Object
1672         {
1673                 public Gtk.CheckButton el;
1674                 private Editor  _this;
1675
1676
1677                         // my vars (def)
1678
1679                 // ctor
1680                 public Xcls_regex(Editor _owner )
1681                 {
1682                         _this = _owner;
1683                         _this.regex = this;
1684                         this.el = new Gtk.CheckButton();
1685
1686                         // my vars (dec)
1687
1688                         // set gobject values
1689                         this.el.label = "Regex";
1690
1691                         // init method
1692
1693                         {
1694                                 this.el.show();
1695                         }
1696                 }
1697
1698                 // user defined functions
1699         }
1700
1701         public class Xcls_multiline : Object
1702         {
1703                 public Gtk.CheckButton el;
1704                 private Editor  _this;
1705
1706
1707                         // my vars (def)
1708
1709                 // ctor
1710                 public Xcls_multiline(Editor _owner )
1711                 {
1712                         _this = _owner;
1713                         _this.multiline = this;
1714                         this.el = new Gtk.CheckButton();
1715
1716                         // my vars (dec)
1717
1718                         // set gobject values
1719                         this.el.label = "Multi-line (add \\n)";
1720                 }
1721
1722                 // user defined functions
1723         }
1724
1725
1726
1727
1728
1729
1730         public class Xcls_navigationwindow : Object
1731         {
1732                 public Gtk.ScrolledWindow el;
1733                 private Editor  _this;
1734
1735
1736                         // my vars (def)
1737
1738                 // ctor
1739                 public Xcls_navigationwindow(Editor _owner )
1740                 {
1741                         _this = _owner;
1742                         _this.navigationwindow = this;
1743                         this.el = new Gtk.ScrolledWindow();
1744
1745                         // my vars (dec)
1746
1747                         // set gobject values
1748                         this.el.visible = false;
1749                         new Xcls_navigation( _this );
1750                         this.el.child = _this.navigation.el;
1751                 }
1752
1753                 // user defined functions
1754         }
1755         public class Xcls_navigation : Object
1756         {
1757                 public Gtk.ColumnView el;
1758                 private Editor  _this;
1759
1760
1761                         // my vars (def)
1762
1763                 // ctor
1764                 public Xcls_navigation(Editor _owner )
1765                 {
1766                         _this = _owner;
1767                         _this.navigation = this;
1768                         var child_1 = new Xcls_SingleSelection31( _this );
1769                         child_1.ref();
1770                         this.el = new Gtk.ColumnView( child_1.el );
1771
1772                         // my vars (dec)
1773
1774                         // set gobject values
1775                         var child_2 = new Xcls_ColumnViewColumn29( _this );
1776                         child_2.ref();
1777                         this.el.append_column( child_2.el );
1778                 }
1779
1780                 // user defined functions
1781                 public void show (Gee.ArrayList<Lsp.DocumentSymbol> syms) {
1782                         _this.navigationwindow.el.show();
1783                         _this.navliststore.el.remove_all();
1784                         foreach(var sym in syms) {
1785                                 _this.navliststore.el.append(sym);
1786                         }
1787                         
1788                 
1789                 }
1790         }
1791         public class Xcls_ColumnViewColumn29 : Object
1792         {
1793                 public Gtk.ColumnViewColumn el;
1794                 private Editor  _this;
1795
1796
1797                         // my vars (def)
1798
1799                 // ctor
1800                 public Xcls_ColumnViewColumn29(Editor _owner )
1801                 {
1802                         _this = _owner;
1803                         var child_1 = new Xcls_SignalListItemFactory30( _this );
1804                         child_1.ref();
1805                         this.el = new Gtk.ColumnViewColumn( "Code Navigation", child_1.el );
1806
1807                         // my vars (dec)
1808
1809                         // set gobject values
1810                         this.el.expand = true;
1811                 }
1812
1813                 // user defined functions
1814         }
1815         public class Xcls_SignalListItemFactory30 : Object
1816         {
1817                 public Gtk.SignalListItemFactory el;
1818                 private Editor  _this;
1819
1820
1821                         // my vars (def)
1822
1823                 // ctor
1824                 public Xcls_SignalListItemFactory30(Editor _owner )
1825                 {
1826                         _this = _owner;
1827                         this.el = new Gtk.SignalListItemFactory();
1828
1829                         // my vars (dec)
1830
1831                         // set gobject values
1832
1833                         //listeners
1834                         this.el.setup.connect( (listitem) => {
1835                                 
1836                                 var expand = new Gtk.TreeExpander();
1837                                  
1838                                 expand.set_indent_for_depth(true);
1839                                 expand.set_indent_for_icon(true);
1840                                 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
1841                                 var icon = new Gtk.Image();
1842                                 var lbl = new Gtk.Label("");
1843                                 lbl.use_markup = true;
1844                                 lbl.ellipsize = Pango.EllipsizeMode.END;
1845                                 
1846                                 icon.margin_end = 4;
1847                                 lbl.justify = Gtk.Justification.LEFT;
1848                                 lbl.xalign = 0;
1849                         
1850                         //      listitem.activatable = true; ??
1851                                 
1852                                 hbox.append(icon);
1853                                 hbox.append(lbl);
1854                                 expand.set_child(hbox);
1855                                 ((Gtk.ListItem)listitem).set_child(expand);
1856                                 
1857                         });
1858                         this.el.bind.connect( (listitem) => {
1859                                 // GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name());
1860                                 
1861                                 //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
1862                                 var expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();
1863                                  
1864                                  
1865                                 var hbox = (Gtk.Box) expand.child;
1866                          
1867                                 
1868                                 var img = (Gtk.Image) hbox.get_first_child();
1869                                 var lbl = (Gtk.Label) img.get_next_sibling();
1870                                 
1871                                 var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();
1872                                 var sym = (Lsp.DocumentSymbol) lr.get_item();
1873                                 
1874                            
1875                             expand.set_hide_expander( sym.children.get_n_items()  < 1);
1876                                 expand.set_list_row(lr);
1877                                 
1878                                 //node.bind_property("iconResourceName",
1879                              //               img, "resource",
1880                              //              GLib.BindingFlags.SYNC_CREATE);
1881                                 
1882                                 sym.bind_property("name",
1883                                             lbl, "label",
1884                                            GLib.BindingFlags.SYNC_CREATE);
1885                                 // should be better?- --line no?
1886                                 sym.bind_property("detail",
1887                                             lbl, "tooltip_markup",
1888                                            GLib.BindingFlags.SYNC_CREATE);
1889                                 // bind image...
1890                                 
1891                         });
1892                 }
1893
1894                 // user defined functions
1895         }
1896
1897
1898         public class Xcls_SingleSelection31 : Object
1899         {
1900                 public Gtk.SingleSelection el;
1901                 private Editor  _this;
1902
1903
1904                         // my vars (def)
1905
1906                 // ctor
1907                 public Xcls_SingleSelection31(Editor _owner )
1908                 {
1909                         _this = _owner;
1910                         var child_1 = new Xcls_TreeListModel32( _this );
1911                         child_1.ref();
1912                         this.el = new Gtk.SingleSelection( child_1.el );
1913
1914                         // my vars (dec)
1915
1916                         // set gobject values
1917                 }
1918
1919                 // user defined functions
1920         }
1921         public class Xcls_TreeListModel32 : Object
1922         {
1923                 public Gtk.TreeListModel el;
1924                 private Editor  _this;
1925
1926
1927                         // my vars (def)
1928
1929                 // ctor
1930                 public Xcls_TreeListModel32(Editor _owner )
1931                 {
1932                         _this = _owner;
1933                         new Xcls_navliststore( _this );
1934                         this.el = new Gtk.TreeListModel( _this.navliststore.el, false, true, (item) => {
1935  
1936         return ((Lsp.DocumentSymbol)item).children;
1937 }
1938  );
1939
1940                         // my vars (dec)
1941
1942                         // set gobject values
1943                 }
1944
1945                 // user defined functions
1946         }
1947         public class Xcls_navliststore : Object
1948         {
1949                 public GLib.ListStore el;
1950                 private Editor  _this;
1951
1952
1953                         // my vars (def)
1954
1955                 // ctor
1956                 public Xcls_navliststore(Editor _owner )
1957                 {
1958                         _this = _owner;
1959                         _this.navliststore = this;
1960                         this.el = new GLib.ListStore( typeof(Lsp.DocumentSymbol) );
1961
1962                         // my vars (dec)
1963
1964                         // set gobject values
1965                 }
1966
1967                 // user defined functions
1968         }
1969
1970
1971
1972
1973
1974
1975 }