a4171d6b8a8cedd46abd09965ebe05e81821bbb8
[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_helper helper;
17         public Xcls_close_btn close_btn;
18         public Xcls_RightEditor RightEditor;
19         public Xcls_view view;
20         public Xcls_buffer buffer;
21         public Xcls_keystate keystate;
22         public Xcls_search_entry search_entry;
23         public Xcls_search_results search_results;
24         public Xcls_nextBtn nextBtn;
25         public Xcls_backBtn backBtn;
26         public Xcls_search_settings search_settings;
27         public Xcls_case_sensitive case_sensitive;
28         public Xcls_regex regex;
29         public Xcls_multiline multiline;
30         public Xcls_navigationwindow navigationwindow;
31         public Xcls_navigation navigation;
32         public Xcls_navigationselmodel navigationselmodel;
33         public Xcls_navigationsort navigationsort;
34         public Xcls_navliststore navliststore;
35
36                 // my vars (def)
37         public int pos_root_x;
38         public Xcls_MainWindow window;
39         public bool dirty;
40         public int pos_root_y;
41         public bool pos;
42         public int last_error_counter;
43         public GtkSource.SearchContext searchcontext;
44         public int last_search_end;
45         public signal void save ();
46         public JsRender.JsRender? file;
47         public JsRender.Node node;
48         public JsRender.NodeProp? prop;
49         public string activeEditor;
50
51         // ctor
52         public Editor()
53         {
54                 _this = this;
55                 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
56
57                 // my vars (dec)
58                 this.window = null;
59                 this.dirty = false;
60                 this.pos = false;
61                 this.last_error_counter = 0;
62                 this.searchcontext = null;
63                 this.last_search_end = 0;
64                 this.file = null;
65                 this.node = null;
66                 this.prop = null;
67                 this.activeEditor = "\"\"";
68
69                 // set gobject values
70                 this.el.homogeneous = false;
71                 this.el.hexpand = true;
72                 this.el.vexpand = true;
73                 var child_1 = new Xcls_Paned1( _this );
74                 child_1.ref();
75                 this.el.append( child_1.el );
76         }
77
78         // user defined functions
79         public bool saveContents ()  {
80             
81             
82             if (_this.file == null) {
83                 return true;
84             }
85             
86              
87              
88              var str = _this.buffer.toString();
89              
90              _this.buffer.checkSyntax();
91              
92              
93              
94              // LeftPanel.model.changed(  str , false);
95              _this.dirty = false;
96              _this.save_button.el.sensitive = false;
97              
98             // find the text for the node..
99             if (_this.file.xtype != "PlainFile") {
100                // in theory these properties have to exist!?!
101                 this.prop.val = str;
102                 //this.window.windowstate.left_props.reload();
103             } else {
104                 _this.file.setSource(  str );
105              }
106             
107             // call the signal..
108             this.save();
109             
110             return true;
111         
112         }
113         public void forwardSearch (bool change_focus) {
114         
115                 if (this.searchcontext == null) {
116                         return;
117                 } 
118         
119                 Gtk.TextIter beg, st,en;
120                  bool has_wrapped_around;
121                 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end);
122                 if (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {
123                 
124                         this.last_search_end = 0; // not sure if this should happen
125                 } else {
126                         if (has_wrapped_around) {
127                                 return;
128                         }
129                 
130                         this.last_search_end = en.get_offset();
131                         if (change_focus) {
132                                 this.view.el.grab_focus();
133                         }
134                         this.buffer.el.place_cursor(st);
135                         this.view.el.scroll_to_iter(st,  0.1f, true, 0.0f, 0.5f);
136                 }
137          
138         }
139         public void show (JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)
140         {
141             this.reset();
142             if (this.file != null) {
143                 this.file.navigation_tree_updated.disconnect(
144                         _this.navigation.show
145                 );
146             }
147             this.file = file;    
148             this.file.navigation_tree_updated.connect(
149                         _this.navigation.show
150                 );
151             if (file.xtype != "PlainFile") {
152                 this.prop = prop;
153                 this.node = node;
154         
155                 // find the text for the node..
156                 this.view.load( prop.val );
157                 this.updateErrorMarks();
158                 
159                 
160                 
161                 this.close_btn.el.show();       
162             
163             } else {
164                 this.view.load(        file.toSource() );
165                 this.updateErrorMarks();
166                 this.close_btn.el.hide();
167                 var ls = file.getLanguageServer();
168                 ls.queueDocumentSymbols(file);
169                 ////ls.documentSymbols.begin(file, (a,o) => {
170                 //      _this.navigation.show(ls.documentSymbols.end(o)); 
171                //});
172                 //documentSymbols
173                 
174             }
175          
176         }
177         public void backSearch (bool change_focus) {
178         
179                 if (this.searchcontext == null) {
180                         return;
181                 }
182                 
183                 Gtk.TextIter beg, st,en;
184                 bool has_wrapped_around;
185                 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );
186                 
187                 if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {
188                         this.last_search_end = 0;
189                 } else {
190                         this.last_search_end = en.get_offset();
191                         if (change_focus) {
192                                 this.view.el.grab_focus();
193                         }
194                         this.buffer.el.place_cursor(st);
195                         this.view.el.scroll_to_iter(st,  0.1f, true, 0.0f, 0.5f);
196                 }
197         
198         }
199         public string tempFileContents () {
200            
201            
202            if (_this.file == null) {
203                return "";
204            }
205                 var str= this.buffer.toString();
206                 if (_this.file.xtype == "PlainFile") {
207             
208                 return str;
209             
210             }
211           
212               
213              
214             GLib.debug("calling validate");    
215             // clear the buttons.
216                 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
217                         return this.file.toSource(); ;
218                 }
219                 
220                 var oldcode  = _this.prop.val;
221                 _this.prop.val = str;
222             var ret = _this.file.toSource();
223             _this.prop.val = oldcode;
224             return ret;
225             
226         }
227         public void reset () {
228                  this.file = null;    
229              
230             this.node = null;
231             this.prop = null;
232                 this.searchcontext = null;
233           
234         }
235         public int search (string in_txt) {
236         
237                 var s = new GtkSource.SearchSettings();
238                 s.case_sensitive = _this.case_sensitive.el.active;
239                 s.regex_enabled = _this.regex.el.active;        
240                 s.wrap_around = false;
241                 
242                 this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);
243                 this.searchcontext.set_highlight(true);
244                 var txt = in_txt;
245                 
246                 if (_this.multiline.el.active) {
247                         txt = in_txt.replace("\\n", "\n");
248                 }
249                 
250                 s.set_search_text(txt);
251                 Gtk.TextIter beg, st,en;
252                  
253                 this.buffer.el.get_start_iter(out beg);
254                 bool has_wrapped_around;
255                 this.searchcontext.forward(beg, out st, out en, out has_wrapped_around);
256                 this.last_search_end = 0;
257                 
258                 return this.searchcontext.get_occurrences_count();
259         
260          
261            
262         
263         }
264         public void updateErrorMarks () {
265                 
266          
267         
268                 var buf = _this.buffer.el;
269                 Gtk.TextIter start;
270                 Gtk.TextIter end;     
271                 buf.get_bounds (out start, out end);
272         
273                 
274         
275          
276                 //GLib.debug("highlight errors");                
277         
278                  // we should highlight other types of errors..
279         
280                 if (_this.window.windowstate.state != WindowState.State.CODEONLY 
281                         &&
282                         _this.window.windowstate.state != WindowState.State.CODE
283                         ) {
284                         //GLib.debug("windowstate != CODEONLY?");
285                         
286                         return;
287                 } 
288         
289                  
290                 if (_this.file == null) {
291                         GLib.debug("file is null?");
292                         return;
293         
294                 }
295                 var ar = this.file.getErrors();
296                 if (ar.size < 1) {
297                         buf.remove_source_marks (start, end, "ERR");
298                         buf.remove_source_marks (start, end, "WARN");
299                         buf.remove_source_marks (start, end, "DEPR");
300                         buf.remove_tag_by_name ("ERR", start, end);
301                         buf.remove_tag_by_name ("WARN", start, end);
302                         buf.remove_tag_by_name ("DEPR", start, end);
303                         this.last_error_counter = file.error_counter ;
304                         //GLib.debug("highlight %s :  %s has no errors", this.file.relpath, category);
305                         return;
306                 }
307                 
308         
309          // basicaly check if there is no change, then we do not do any update..
310          // we can do this by just using an error counter?
311          // if that's changed then we will do an update, otherwise dont bother.
312                   
313                 
314                 var offset = 0;
315                 var hoffset = 0;
316         
317                 var tlines = buf.get_line_count () +1;
318                 
319                 if (_this.prop != null) {
320                         // this still seems flaky...
321         
322                         tlines = _this.prop.end_line;
323                         offset = _this.prop.start_line;
324                         hoffset = _this.node.node_pad.length + 2; //shift it left  by 2 ? ..
325                         
326                          
327                 } else {
328                         // no update...
329                         if (this.last_error_counter == file.error_counter) {
330                         
331                                 return;
332                         }
333                 
334                 }
335                 buf.remove_source_marks (start, end, "ERR");
336                 buf.remove_source_marks (start, end, "WARN");
337                 buf.remove_source_marks (start, end, "DEPR");
338                 buf.remove_tag_by_name ("ERR", start, end);
339                 buf.remove_tag_by_name ("WARN", start, end);
340                 buf.remove_tag_by_name ("DEPR", start, end);
341                 
342                 foreach(var diag in ar) { 
343                      Gtk.TextIter iter;
344         //        print("get inter\n");
345                     var eline = (int)diag.range.start.line - offset;
346                     var eline_to = (int)diag.range.end.line - offset;
347                     //var eline =  diag.range.end_line - offset;
348                     //GLib.debug("GOT ERROR on line %d -- converted to %d  (offset = %d)",
349                     //  err.line ,eline, offset);
350                     
351                     
352                     if (eline > tlines || eline < 0) {
353                         continue;
354                     }
355                     
356                     buf.get_iter_at_line( out iter, eline);
357                         var msg = "Line: %d %s : %s".printf(eline+1, diag.category, diag.message);
358                     buf.create_source_mark( msg, diag.category, iter);
359                     
360                     var spos = (int)diag.range.start.character - hoffset;
361                     if (spos < 0) { spos =0 ; }
362                     if (spos > iter.get_chars_in_line()) {
363                         spos = iter.get_chars_in_line();
364                 }
365                         buf.get_iter_at_line( out iter, eline_to);
366                         var epos = (int)diag.range.end.character - hoffset;
367                     if (epos < 0) { epos =0 ; }
368                     if (epos > iter.get_chars_in_line()) {
369                         epos = iter.get_chars_in_line();
370                 }
371                      
372                     
373                     buf.get_iter_at_line_offset( out start, eline, spos); 
374                    
375                     buf.get_iter_at_line_offset( out end, eline_to,epos); 
376                         
377                     buf.apply_tag_by_name(diag.category, start, end);
378                     
379                    // GLib.debug("set line %d to %s", eline, msg);
380                     //this.marks.set(eline, msg);
381                 }
382                 this.last_error_counter = file.error_counter ;
383         
384         
385         
386          
387         
388         }
389         public void scroll_to_line (int line) {
390         
391                 GLib.Timeout.add(500, () => {
392            
393                         var buf = this.view.el.get_buffer();
394         
395                         var sbuf = (GtkSource.Buffer) buf;
396         
397         
398                         Gtk.TextIter iter;   
399                         sbuf.get_iter_at_line(out iter,  line);
400                         this.view.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);
401                         return false;
402                 });   
403         }
404         public class Xcls_Paned1 : Object
405         {
406                 public Gtk.Paned el;
407                 private Editor  _this;
408
409
410                         // my vars (def)
411
412                 // ctor
413                 public Xcls_Paned1(Editor _owner )
414                 {
415                         _this = _owner;
416                         this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL );
417
418                         // my vars (dec)
419
420                         // set gobject values
421                         var child_1 = new Xcls_Box2( _this );
422                         child_1.ref();
423                         this.el.start_child = child_1.el;
424                         var child_2 = new Xcls_Box27( _this );
425                         child_2.ref();
426                         this.el.end_child = child_2.el;
427                 }
428
429                 // user defined functions
430         }
431         public class Xcls_Box2 : Object
432         {
433                 public Gtk.Box el;
434                 private Editor  _this;
435
436
437                         // my vars (def)
438
439                 // ctor
440                 public Xcls_Box2(Editor _owner )
441                 {
442                         _this = _owner;
443                         this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
444
445                         // my vars (dec)
446
447                         // set gobject values
448                         var child_1 = new Xcls_Box3( _this );
449                         child_1.ref();
450                         this.el.append( child_1.el );
451                         new Xcls_RightEditor( _this );
452                         this.el.append( _this.RightEditor.el );
453                         var child_3 = new Xcls_Box15( _this );
454                         child_3.ref();
455                         this.el.append ( child_3.el  );
456                 }
457
458                 // user defined functions
459         }
460         public class Xcls_Box3 : Object
461         {
462                 public Gtk.Box el;
463                 private Editor  _this;
464
465
466                         // my vars (def)
467
468                 // ctor
469                 public Xcls_Box3(Editor _owner )
470                 {
471                         _this = _owner;
472                         this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
473
474                         // my vars (dec)
475
476                         // set gobject values
477                         this.el.homogeneous = false;
478                         this.el.hexpand = true;
479                         this.el.vexpand = false;
480                         new Xcls_save_button( _this );
481                         this.el.append( _this.save_button.el );
482                         new Xcls_helper( _this );
483                         this.el.append( _this.helper.el );
484                         var child_3 = new Xcls_Scale6( _this );
485                         child_3.ref();
486                         this.el.append( child_3.el );
487                         new Xcls_close_btn( _this );
488                         this.el.append( _this.close_btn.el );
489                 }
490
491                 // user defined functions
492         }
493         public class Xcls_save_button : Object
494         {
495                 public Gtk.Button el;
496                 private Editor  _this;
497
498
499                         // my vars (def)
500
501                 // ctor
502                 public Xcls_save_button(Editor _owner )
503                 {
504                         _this = _owner;
505                         _this.save_button = this;
506                         this.el = new Gtk.Button();
507
508                         // my vars (dec)
509
510                         // set gobject values
511                         this.el.vexpand = true;
512                         this.el.label = "Save";
513
514                         //listeners
515                         this.el.clicked.connect( () => { 
516                             _this.saveContents();
517                         });
518                 }
519
520                 // user defined functions
521         }
522
523         public class Xcls_helper : Object
524         {
525                 public Gtk.Label el;
526                 private Editor  _this;
527
528
529                         // my vars (def)
530
531                 // ctor
532                 public Xcls_helper(Editor _owner )
533                 {
534                         _this = _owner;
535                         _this.helper = this;
536                         this.el = new Gtk.Label( null );
537
538                         // my vars (dec)
539
540                         // set gobject values
541                         this.el.margin_end = 4;
542                         this.el.margin_start = 4;
543                         this.el.hexpand = true;
544                 }
545
546                 // user defined functions
547         }
548
549         public class Xcls_Scale6 : Object
550         {
551                 public Gtk.Scale el;
552                 private Editor  _this;
553
554
555                         // my vars (def)
556
557                 // ctor
558                 public Xcls_Scale6(Editor _owner )
559                 {
560                         _this = _owner;
561                         this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1);
562
563                         // my vars (dec)
564
565                         // set gobject values
566                         this.el.width_request = 200;
567                         this.el.has_origin = true;
568                         this.el.draw_value = false;
569                         this.el.digits = 0;
570                         this.el.sensitive = true;
571
572                         // init method
573
574                         {
575                                 //this.el.set_range(6,30);
576                                 this.el.set_value ( BuilderApplication.settings.editor_font_size);
577                                 BuilderApplication.settings.editor_font_size_updated.connect(
578                                         () => {
579                                                 BuilderApplication.settings.editor_font_size_inchange = true;
580                                         //      GLib.debug("update range");
581                                                 this.el.set_value (BuilderApplication.settings.editor_font_size);
582                                                 BuilderApplication.settings.editor_font_size_inchange = false;
583                                         }
584                                 );
585                                 
586                          
587                         }
588
589                         //listeners
590                         this.el.change_value.connect( (st, val ) => {
591                                 if (BuilderApplication.settings.editor_font_size_inchange) {
592                                         return false;
593                                 }
594                                 BuilderApplication.settings.editor_font_size = val;
595                                 return false;
596                         });
597                 }
598
599                 // user defined functions
600         }
601
602         public class Xcls_close_btn : Object
603         {
604                 public Gtk.Button el;
605                 private Editor  _this;
606
607
608                         // my vars (def)
609
610                 // ctor
611                 public Xcls_close_btn(Editor _owner )
612                 {
613                         _this = _owner;
614                         _this.close_btn = this;
615                         this.el = new Gtk.Button();
616
617                         // my vars (dec)
618
619                         // set gobject values
620                         this.el.icon_name = "window-close";
621                         var child_1 = new Xcls_Image8( _this );
622                         child_1.ref();
623                         this.el.child = child_1.el;
624
625                         //listeners
626                         this.el.clicked.connect( () => { 
627                             _this.saveContents();
628                             _this.window.windowstate.switchState(WindowState.State.PREVIEW);
629                         });
630                 }
631
632                 // user defined functions
633         }
634         public class Xcls_Image8 : Object
635         {
636                 public Gtk.Image el;
637                 private Editor  _this;
638
639
640                         // my vars (def)
641
642                 // ctor
643                 public Xcls_Image8(Editor _owner )
644                 {
645                         _this = _owner;
646                         this.el = new Gtk.Image();
647
648                         // my vars (dec)
649
650                         // set gobject values
651                         this.el.icon_name = "window-close";
652                         this.el.icon_size = Gtk.IconSize.NORMAL;
653                 }
654
655                 // user defined functions
656         }
657
658
659
660         public class Xcls_RightEditor : Object
661         {
662                 public Gtk.ScrolledWindow el;
663                 private Editor  _this;
664
665
666                         // my vars (def)
667
668                 // ctor
669                 public Xcls_RightEditor(Editor _owner )
670                 {
671                         _this = _owner;
672                         _this.RightEditor = this;
673                         this.el = new Gtk.ScrolledWindow();
674
675                         // my vars (dec)
676
677                         // set gobject values
678                         this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
679                         this.el.vexpand = true;
680                         this.el.overlay_scrolling = false;
681                         this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
682                         new Xcls_view( _this );
683                         this.el.child = _this.view.el;
684                 }
685
686                 // user defined functions
687         }
688         public class Xcls_view : Object
689         {
690                 public GtkSource.View el;
691                 private Editor  _this;
692
693
694                         // my vars (def)
695                 public Gtk.CssProvider css;
696
697                 // ctor
698                 public Xcls_view(Editor _owner )
699                 {
700                         _this = _owner;
701                         _this.view = this;
702                         this.el = new GtkSource.View();
703
704                         // my vars (dec)
705                         this.css = null;
706
707                         // set gobject values
708                         this.el.auto_indent = true;
709                         this.el.indent_width = 4;
710                         this.el.name = "editor-view";
711                         this.el.show_line_marks = true;
712                         this.el.insert_spaces_instead_of_tabs = true;
713                         this.el.show_line_numbers = true;
714                         this.el.hexpand = true;
715                         this.el.vexpand = true;
716                         this.el.has_tooltip = true;
717                         this.el.css_classes = { "code-editor" };
718                         this.el.tab_width = 4;
719                         this.el.highlight_current_line = true;
720                         new Xcls_buffer( _this );
721                         this.el.buffer = _this.buffer.el;
722                         new Xcls_keystate( _this );
723                         this.el.add_controller(  _this.keystate.el );
724                         var child_3 = new Xcls_EventControllerScroll13( _this );
725                         child_3.ref();
726                         this.el.add_controller(  child_3.el );
727                         var child_4 = new Xcls_GestureClick14( _this );
728                         child_4.ref();
729                         this.el.add_controller(  child_4.el );
730
731                         // init method
732
733                         this.el.completion.add_provider(
734                                 new Palete.CompletionProvider(_this)
735                         );
736                         
737                         // hover seems pretty useless.. - ??
738                         //var hover = this.el.get_hover();
739                         //hover.add_provider(new Palete.HoverProvider(_this));
740                         
741                         //this.el.completion.unblock_interactive();
742                         this.el.completion.select_on_show = true; // select
743                         //this.el.completion.remember_info_visibility    = true;
744                         
745                         
746                         var attrs = new GtkSource.MarkAttributes();
747                         
748                         attrs.set_icon_name ( "process-stop");    
749                         attrs.query_tooltip_text.connect(( mark) => {
750                              GLib.debug("tooltip query? %s", mark.name);
751                             return strdup( mark.name);
752                         });
753                          attrs.query_tooltip_markup.connect(( mark) => {
754                              GLib.debug("tooltip query? %s", mark.name);
755                             return strdup( mark.name);
756                         });
757                         this.el.set_mark_attributes ("ERR", attrs, 1);
758                         attrs.ref();
759                         
760                         
761                         var wattrs = new GtkSource.MarkAttributes();
762                         wattrs.set_icon_name ( "process-stop");    
763                         wattrs.query_tooltip_text.connect(( mark) => {
764                              GLib.debug("tooltip query? %s", mark.name);
765                             return strdup(mark.name);
766                         });
767                         wattrs.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 ("WARN", wattrs, 1);
772                         wattrs.ref();
773                         
774                          
775                         var dattrs = new GtkSource.MarkAttributes();
776                          
777                         dattrs.set_icon_name ( "process-stop"); 
778                         
779                         dattrs.query_tooltip_text.connect(( mark) => {
780                                 GLib.debug("tooltip query? %s", mark.name);
781                             return strdup(mark.name);
782                         });
783                         //dattrs.query_tooltip_markup.connect(( mark) => {
784                         //      GLib.debug("tooltip query? %s", mark.name);
785                          //   return strdup(mark.name);
786                         //});
787                         this.el.set_mark_attributes ("DEPR", dattrs, 1);
788                         dattrs.ref();    
789                         
790                          this.el.get_space_drawer().set_matrix(null);
791                          this.el.get_space_drawer().set_types_for_locations( 
792                                 GtkSource.SpaceLocationFlags.ALL,
793                                 GtkSource.SpaceTypeFlags.ALL
794                         );
795                         this.el.get_space_drawer().set_enable_matrix(true);
796
797                         //listeners
798                         this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
799                                 
800                                 //GLib.debug("query tooltip");
801                                 Gtk.TextIter iter;
802                                 int trailing;
803                                 
804                                 var yoff = (int) _this.RightEditor.el.vadjustment.value;
805                                 
806                                 // I think this is problematic - if it's compliing  / updating at same time as query.
807                                 
808                                 //if (_this.window.statusbar_compile_spinner.el.spinning) {
809                                 //      return false;
810                                 //}
811                                 
812                                 this.el.get_iter_at_position (out iter, out trailing,  x,  y + yoff);
813                                  
814                                 var l = iter.get_line();
815                         
816                                 
817                                  
818                                 // GLib.debug("query tooltip line %d", (int) l);
819                                 if (l < 0) {
820                         
821                                         return false;
822                                 }
823                                 /*
824                                 if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {
825                                         GLib.debug("line %d setting tip to %s", l,  _this.buffer.marks.get(l));
826                                         tooltip.set_text(_this.buffer.marks.get(l).dup());
827                                         return true;
828                                 }
829                          
830                                 return false;
831                                 */
832                                 
833                                   
834                                 // this crashes?? - not sure why.
835                                 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
836                                 if (marks.is_empty()) {
837                                         marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
838                                 }
839                                 if (marks.is_empty()) {
840                                         marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
841                                 }
842                                 
843                                 // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length());
844                                 var str = "";
845                                 marks.@foreach((m) => { 
846                                         //GLib.debug("got mark %s", m.name);
847                                         str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name;
848                                 });
849                                 // true if there is a mark..
850                                 if (str.length > 0 ) {
851                                         tooltip.set_text( str );
852                                 }
853                                 return str.length > 0 ? true : false;
854                                  
855                         });
856                 }
857
858                 // user defined functions
859                 public void load (string str) {
860                 
861                 // show the help page for the active node..
862                    //this.get('/Help').show();
863                  
864                   // this.get('/BottomPane').el.set_current_page(0);
865                         GLib.debug("load called - Reset undo buffer");
866                         
867                     var buf = (GtkSource.Buffer)this.el.get_buffer();
868                     buf.begin_irreversible_action();
869                     buf.set_text(str, str.length);
870                     buf.end_irreversible_action();
871                     
872                     var lm = GtkSource.LanguageManager.get_default();
873                     var lang = "vala";
874                     if (_this.file != null) {
875                          lang = _this.file.language;
876                     }
877                     print("lang=%s, content_type = %s\n", lang, _this.file.content_type);
878                     var lg = _this.file.content_type.length > 0  ?
879                             lm.guess_language(_this.file.path, _this.file.content_type) :
880                             lm.get_language(lang);
881                      
882                    
883                     ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg); 
884                 
885                     this.el.insert_spaces_instead_of_tabs = true;
886                     if (lg != null) {
887                                 print("sourcelanguage  = %s\n", lg.name);
888                                 if (lg.name == "Vala") {
889                                     this.el.insert_spaces_instead_of_tabs = false;
890                                 }
891                      }
892                     _this.dirty = false;
893                     this.el.grab_focus();
894                     _this.save_button.el.sensitive = false;
895                     _this.last_error_counter = -1;
896                 }
897         }
898         public class Xcls_buffer : Object
899         {
900                 public GtkSource.Buffer el;
901                 private Editor  _this;
902
903
904                         // my vars (def)
905                 public int error_line;
906                 public Gee.HashMap<int,string>? xmarks;
907                 public bool check_queued;
908
909                 // ctor
910                 public Xcls_buffer(Editor _owner )
911                 {
912                         _this = _owner;
913                         _this.buffer = this;
914                         this.el = new GtkSource.Buffer( null );
915
916                         // my vars (dec)
917                         this.error_line = -1;
918                         this.xmarks = null;
919                         this.check_queued = false;
920
921                         // set gobject values
922                         this.el.highlight_syntax = true;
923                         this.el.highlight_matching_brackets = true;
924                         this.el.enable_undo = true;
925
926                         // init method
927
928                         var buf = this.el;
929                         buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
930                         buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
931                         buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
932                         buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
933                         buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
934                         buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
935                         buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
936                         buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
937                         
938                         
939                         buf.create_tag ("ERR", "weight", Pango.Weight.BOLD, "background", "pink");
940                         buf.create_tag ("WARN", "weight", Pango.Weight.BOLD, "background", "#ABF4EB");
941                         buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
942
943                         //listeners
944                         this.el.cursor_moved.connect( ( ) => {
945                         
946                                 Gtk.TextIter iter;
947                                 this.el.get_iter_at_offset (
948                                                 out iter, this.el.cursor_position);
949                         
950                                 _this.navigation.updateSelectedLine(
951                                                 (uint)iter.get_line(),
952                                                 (uint)iter.get_line_offset()
953                                         );
954                         
955                         
956                         });
957                         this.el.changed.connect( () => {
958                             // check syntax??
959                             // ??needed..??
960                             _this.save_button.el.sensitive = true;
961                             print("EDITOR CHANGED");
962                             this.checkSyntax();
963                            
964                             _this.dirty = true;
965                         
966                             // this.get('/LeftPanel.model').changed(  str , false);
967                             return ;
968                         });
969                 }
970
971                 // user defined functions
972                 public bool OLDhighlightErrorsJson (string type, Json.Object obj) {
973                         Gtk.TextIter start;
974                         Gtk.TextIter end;     
975                         this.el.get_bounds (out start, out end);
976                 
977                         this.el.remove_source_marks (start, end, type);
978                         GLib.debug("highlight errors");          
979                 
980                          // we should highlight other types of errors..
981                 
982                         if (!obj.has_member(type)) {
983                                 GLib.debug("Return has no errors\n");
984                                 return true;
985                         }
986                 
987                         if (_this.window.windowstate.state != WindowState.State.CODEONLY 
988                                 &&
989                                 _this.window.windowstate.state != WindowState.State.CODE
990                                 ) {
991                                 GLib.debug("windowstate != CODEONLY?");
992                                 
993                                 return true;
994                         } 
995                 
996                         //this.marks = new Gee.HashMap<int,string>();
997                         var err = obj.get_object_member(type);
998                  
999                         if (_this.file == null) {
1000                                 GLib.debug("file is null?");
1001                                 return true;
1002                 
1003                         }
1004                         var valafn = _this.file.path;
1005                 
1006                         if (_this.file.xtype != "PlainFile") {
1007                 
1008                                 valafn = "";
1009                                 try {             
1010                                         var  regex = new Regex("\\.bjs$");
1011                                         // should not happen
1012                                         valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
1013                                 } catch (GLib.RegexError e) {
1014                                         return true;
1015                                 }   
1016                 
1017                 
1018                 
1019                         }
1020                         if (!err.has_member(valafn)) {
1021                                 GLib.debug("File path has no errors");
1022                                 return  true;
1023                         }
1024                 
1025                         var lines = err.get_object_member(valafn);
1026                         
1027                         var offset = 1;
1028                         if (obj.has_member("line_offset")) { // ?? why??
1029                                 offset = (int)obj.get_int_member("line_offset") + 1;
1030                         }
1031                 
1032                 
1033                         var tlines = this.el.get_line_count () +1;
1034                         
1035                         if (_this.prop != null) {
1036                         
1037                                 tlines = _this.prop.end_line + 1;
1038                                 offset = _this.prop.start_line + 1;
1039                         
1040                         }
1041                         
1042                 
1043                 
1044                         lines.foreach_member((obj, line, node) => {
1045                                 
1046                              Gtk.TextIter iter;
1047                 //        print("get inter\n");
1048                             var eline = int.parse(line) - offset;
1049                             GLib.debug("GOT ERROR on line %s -- converted to %d  (offset = %d)\n", line,eline, offset);
1050                             
1051                             
1052                             if (eline > tlines || eline < 0) {
1053                                 return;
1054                             }
1055                            
1056                             
1057                             this.el.get_iter_at_line( out iter, eline);
1058                             //print("mark line\n");
1059                             var msg  = "";
1060                             var ar = lines.get_array_member(line);
1061                             for (var i = 0 ; i < ar.get_length(); i++) {
1062                                 if (ar.get_string_element(i) == "Success") {
1063                                         continue;
1064                                 }
1065                                         msg += (msg.length > 0) ? "\n" : "";
1066                                         msg += ar.get_string_element(i);
1067                                 }
1068                                 if (msg == "") {
1069                                         return;
1070                                 }
1071                                 msg = "Line: %d".printf(eline+1) +  " " + msg;
1072                             this.el.create_source_mark(msg, type, iter);
1073                             GLib.debug("set line %d to %m", eline, msg);
1074                            // this.marks.set(eline, msg);
1075                         } );
1076                         return false;
1077                 
1078                 
1079                 
1080                 
1081                 
1082                         }
1083                 public bool checkSyntax () {
1084                  
1085                     
1086                     var str = this.toString();
1087                     
1088                     // needed???
1089                     if (this.error_line > 0) {
1090                          Gtk.TextIter start;
1091                          Gtk.TextIter end;     
1092                         this.el.get_bounds (out start, out end);
1093                 
1094                         this.el.remove_source_marks (start, end, null);
1095                     }
1096                     if (str.length < 1) {
1097                         print("checkSyntax - empty string?\n");
1098                         return true;
1099                     }
1100                     
1101                     // bit presumptiona
1102                     if (_this.file.xtype == "PlainFile") {
1103                     
1104                         // assume it's gtk...
1105                          var  oldcode =_this.file.toSource();
1106                         _this.file.setSource(str);
1107                             BuilderApplication.showSpinner("appointment soon","document change pending");
1108                         _this.file.getLanguageServer().document_change(_this.file);
1109                                 _this.file.getLanguageServer().queueDocumentSymbols(_this.file);
1110                         _this.file.setSource(oldcode);
1111                         
1112                                  
1113                         return true;
1114                     
1115                     }
1116                    if (_this.file == null) {
1117                        return true;
1118                    }
1119                  
1120                     
1121                 
1122                       
1123                      
1124                     GLib.debug("calling validate");    
1125                     // clear the buttons.
1126                         if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
1127                                 return true ;
1128                         }
1129                         var oldcode  = _this.prop.val;
1130                         
1131                         _this.prop.val = str;
1132                         _this.node.updated_count++;
1133                     _this.file.getLanguageServer().document_change(_this.file);
1134                     _this.node.updated_count++;
1135                     _this.prop.val = oldcode;
1136                     
1137                     
1138                     //print("done mark line\n");
1139                      
1140                     return true; // at present allow saving - even if it's invalid..
1141                 }
1142                 public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
1143                          
1144                         this.error_line = validate_res.size;
1145                 
1146                         if (this.error_line < 1) {
1147                                 return true;
1148                         }
1149                         var tlines = this.el.get_line_count ();
1150                         Gtk.TextIter iter;
1151                         var valiter = validate_res.map_iterator();
1152                         while (valiter.next()) {
1153                 
1154                         //        print("get inter\n");
1155                                 var eline = valiter.get_key();
1156                                 if (eline > tlines) {
1157                                         continue;
1158                                 }
1159                                 this.el.get_iter_at_line( out iter, eline);
1160                                 //print("mark line\n");
1161                                 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
1162                         }   
1163                         return false;
1164                 }
1165                 public string toString () {
1166                     
1167                     Gtk.TextIter s;
1168                     Gtk.TextIter e;
1169                     this.el.get_start_iter(out s);
1170                     this.el.get_end_iter(out e);
1171                     var ret = this.el.get_text(s,e,true);
1172                     //print("TO STRING? " + ret);
1173                     return ret;
1174                 }
1175         }
1176
1177         public class Xcls_keystate : Object
1178         {
1179                 public Gtk.EventControllerKey el;
1180                 private Editor  _this;
1181
1182
1183                         // my vars (def)
1184                 public bool is_control;
1185
1186                 // ctor
1187                 public Xcls_keystate(Editor _owner )
1188                 {
1189                         _this = _owner;
1190                         _this.keystate = this;
1191                         this.el = new Gtk.EventControllerKey();
1192
1193                         // my vars (dec)
1194                         this.is_control = false;
1195
1196                         // set gobject values
1197
1198                         //listeners
1199                         this.el.key_released.connect( (keyval, keycode, state) => {
1200                         
1201                                  if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1202                                         this.is_control = false;
1203                                 }
1204                             if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1205                                 GLib.debug("SAVE: ctrl-S  pressed");
1206                                 _this.saveContents();
1207                                 return;
1208                             }
1209                             
1210                             if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1211                                     GLib.debug("SAVE: ctrl-g  pressed");
1212                                         _this.forwardSearch(true);
1213                                     return;
1214                                 }
1215                                 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1216                                     GLib.debug("SAVE: ctrl-f  pressed");
1217                                         _this.search_entry.el.grab_focus();
1218                                         _this.search_entry.el.select_region(0,-1);
1219                                     return;
1220                                 }
1221                                 if (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1222                                         _this.view.el.show_completion();
1223                                 }
1224                                 
1225                                 Gtk.TextIter iter;
1226                                 _this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);  
1227                                 var line  = iter.get_line();
1228                                 var offset = iter.get_line_offset();
1229                                 GLib.debug("line  %d  off %d", line ,offset);
1230                                 if (_this.prop != null) {
1231                                         line += _this.prop.start_line + 1; // i think..
1232                                         offset += 12; // should probably be 8 without namespaced 
1233                                         GLib.debug("guess line  %d  off %d", line ,offset);
1234                                 } 
1235                             //_this.view.el.show_completion();
1236                            // print(event.key.keyval)
1237                             
1238                             
1239                             return;
1240                          
1241                          
1242                         });
1243                         this.el.key_pressed.connect( (keyval, keycode, state) => {
1244                         
1245                                 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1246                                         this.is_control = true;
1247                                 }
1248                                 return false;
1249                         });
1250                 }
1251
1252                 // user defined functions
1253         }
1254
1255         public class Xcls_EventControllerScroll13 : Object
1256         {
1257                 public Gtk.EventControllerScroll el;
1258                 private Editor  _this;
1259
1260
1261                         // my vars (def)
1262                 public double distance;
1263
1264                 // ctor
1265                 public Xcls_EventControllerScroll13(Editor _owner )
1266                 {
1267                         _this = _owner;
1268                         this.el = new Gtk.EventControllerScroll( Gtk.EventControllerScrollFlags.VERTICAL );
1269
1270                         // my vars (dec)
1271                         this.distance = 0.0f;
1272
1273                         // set gobject values
1274
1275                         //listeners
1276                         this.el.scroll.connect( (dx, dy) => {
1277                                 if (!_this.keystate.is_control) {
1278                                         return false;
1279                                 }
1280                                  //GLib.debug("scroll %f",  dy);
1281                                 
1282                                 this.distance += dy;
1283                                 
1284                                 //GLib.debug("scroll %f / %f",  dy, this.distance);
1285                          
1286                                  if (this.distance < -1) {
1287                          
1288                                         BuilderApplication.settings.editor_font_size ++;
1289                                         this.distance = 0;
1290                                 }
1291                                 if (this.distance > 1) {
1292                                         BuilderApplication.settings.editor_font_size --;
1293                                         this.distance = 0;
1294                                 }
1295                                  
1296                                 return true;
1297                         });
1298                 }
1299
1300                 // user defined functions
1301         }
1302
1303         public class Xcls_GestureClick14 : Object
1304         {
1305                 public Gtk.GestureClick el;
1306                 private Editor  _this;
1307
1308
1309                         // my vars (def)
1310
1311                 // ctor
1312                 public Xcls_GestureClick14(Editor _owner )
1313                 {
1314                         _this = _owner;
1315                         this.el = new Gtk.GestureClick();
1316
1317                         // my vars (dec)
1318
1319                         // set gobject values
1320
1321                         //listeners
1322                         this.el.pressed.connect( (n_press, x, y) => {
1323                                 Gtk.TextIter iter;
1324                                 int  buffer_x, buffer_y;
1325                                 var gut = _this.view.el.get_gutter(Gtk.TextWindowType.LEFT);
1326                                 
1327                                  _this.view.el.window_to_buffer_coords (Gtk.TextWindowType.TEXT,
1328                                         (int)x - gut.get_width(),  (int)y,
1329                                         out  buffer_x, out  buffer_y);
1330                                 _this.view.el.get_iter_at_location (out  iter,  
1331                                                 buffer_x,  buffer_y);;
1332                                 
1333                                 
1334                                 if (_this.buffer.el.iter_has_context_class(iter, "comment") ||
1335                                         _this.buffer.el.iter_has_context_class(iter, "string")
1336                                 ) { 
1337                                         return ;
1338                                 }
1339                                 var back = iter.copy();
1340                                 back.backward_char();
1341                                 
1342                                 var forward = iter.copy();
1343                                 forward.forward_char();
1344                                 
1345                                 // what's the character at the iter?
1346                                 var str = back.get_text(iter);
1347                                 str += iter.get_text(forward);
1348                                 if (str.strip().length < 1) {
1349                                         return;
1350                                 }
1351                                 var offset = iter.get_line_offset();
1352                                 var line = iter.get_line();
1353                                 if (_this.prop != null) {
1354                                                         // 
1355                                         line += _this.prop.start_line ; 
1356                                                                 // this is based on Gtk using tabs (hence 1/2 chars);
1357                                         offset += _this.node.node_pad.length;
1358                                                                 // javascript listeners are indented 2 more spaces.
1359                                         if (_this.prop.ptype == JsRender.NodePropType.LISTENER) {
1360                                                 offset += 2;
1361                                         }
1362                                 } 
1363                                 
1364                                 var ls = _this.file.getLanguageServer();
1365                                 ls.hover.begin(
1366                                         _this.file, line, offset,
1367                                         ( a, o)  => {
1368                                                 var res = ls.hover.end(o );
1369                                                 
1370                                         });
1371                                         
1372                                         /*
1373                                                 things that can ber returned..
1374                                                 "int" (type only)
1375                          
1376                                                 Editor xxxx._thisJ
1377                                                 Jsrennder.jsrender Editor.file 
1378                                                 Palete.LanguageClient? JsRender.JsRender.getLanguageServer ()
1379                                                 Palete.LanguageClient? ls = _this.file.getLanguageServer()
1380                                                 async Lsp.Hover Palete.LanguageClient.hover (JsRender.JsRender file, int line, int offset) throws GLib.Error
1381                                                 .string JsRender.Node.node_pad = \"\" 
1382                                                 Gtk.TextIter iter
1383                                                 
1384                                           string Gtk.TextIter.get_text (Gtk.TextIter end)
1385                              
1386                         
1387                                         */
1388                                         
1389                                          // could never get this to work anywhere..
1390                                          // looks like its probably for calling stuff..
1391                                          // but always returns null..
1392                                          /*
1393                                 ls.signatureHelp.begin(
1394                                         _this.file, iter.get_line(), iter.get_line_offset(),
1395                                         ( a, o)  => {
1396                                                 var res = ls.signatureHelp.end(o );
1397                                                 
1398                                         });     
1399                         
1400                         */
1401                         });
1402                 }
1403
1404                 // user defined functions
1405         }
1406
1407
1408
1409         public class Xcls_Box15 : Object
1410         {
1411                 public Gtk.Box el;
1412                 private Editor  _this;
1413
1414
1415                         // my vars (def)
1416
1417                 // ctor
1418                 public Xcls_Box15(Editor _owner )
1419                 {
1420                         _this = _owner;
1421                         this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1422
1423                         // my vars (dec)
1424
1425                         // set gobject values
1426                         this.el.homogeneous = false;
1427                         this.el.vexpand = false;
1428                         new Xcls_search_entry( _this );
1429                         this.el.append( _this.search_entry.el );
1430                         new Xcls_search_results( _this );
1431                         this.el.append( _this.search_results.el );
1432                         new Xcls_nextBtn( _this );
1433                         this.el.append( _this.nextBtn.el );
1434                         new Xcls_backBtn( _this );
1435                         this.el.append( _this.backBtn.el );
1436                         var child_5 = new Xcls_MenuButton21( _this );
1437                         child_5.ref();
1438                         this.el.append( child_5.el );
1439                 }
1440
1441                 // user defined functions
1442         }
1443         public class Xcls_search_entry : Object
1444         {
1445                 public Gtk.SearchEntry el;
1446                 private Editor  _this;
1447
1448
1449                         // my vars (def)
1450                 public Gtk.CssProvider css;
1451
1452                 // ctor
1453                 public Xcls_search_entry(Editor _owner )
1454                 {
1455                         _this = _owner;
1456                         _this.search_entry = this;
1457                         this.el = new Gtk.SearchEntry();
1458
1459                         // my vars (dec)
1460
1461                         // set gobject values
1462                         this.el.name = "editor-search-entry";
1463                         this.el.hexpand = true;
1464                         this.el.placeholder_text = "Press enter to search";
1465                         this.el.search_delay = 3;
1466                         var child_1 = new Xcls_EventControllerKey17( _this );
1467                         child_1.ref();
1468                         this.el.add_controller(  child_1.el );
1469
1470                         //listeners
1471                         this.el.search_changed.connect( ( ) => {
1472                         
1473                         _this.search(_this.search_entry.el.text);
1474                                  _this.search_results.updateResults();
1475                         
1476                                 GLib.Timeout.add_seconds(1,() => {
1477                                          _this.search_results.updateResults();
1478                                          return false;
1479                                  });
1480                         });
1481                 }
1482
1483                 // user defined functions
1484                 public void forwardSearch (bool change_focus) {
1485                 
1486                 
1487                         _this.forwardSearch(change_focus);
1488                 
1489                 /*
1490                 
1491                         switch(_this.windowstate.state) {
1492                                 case WindowState.State.CODEONLY:
1493                                 //case WindowState.State.CODE:
1494                                         // search the code being edited..
1495                                         _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1496                                          
1497                                         break;
1498                                 case WindowState.State.PREVIEW:
1499                                         if (_this.windowstate.file.xtype == "Gtk") {
1500                                                 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1501                                         } else { 
1502                                                  _this.windowstate.window_rooview.forwardSearch(change_focus);
1503                                         }
1504                                 
1505                                         break;
1506                         }
1507                         */
1508                         
1509                 }
1510         }
1511         public class Xcls_EventControllerKey17 : Object
1512         {
1513                 public Gtk.EventControllerKey el;
1514                 private Editor  _this;
1515
1516
1517                         // my vars (def)
1518
1519                 // ctor
1520                 public Xcls_EventControllerKey17(Editor _owner )
1521                 {
1522                         _this = _owner;
1523                         this.el = new Gtk.EventControllerKey();
1524
1525                         // my vars (dec)
1526
1527                         // set gobject values
1528
1529                         //listeners
1530                         this.el.key_pressed.connect( (keyval, keycode, state) => {
1531                         
1532                                 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1533                                     GLib.debug("SAVE: ctrl-g  pressed");
1534                                         _this.forwardSearch(true);
1535                                     return true;
1536                                 }
1537                             
1538                           
1539                                 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1540                                         _this.forwardSearch(true);
1541                                         
1542                                         
1543                                     return true;
1544                         
1545                                 }    
1546                            // print(event.key.keyval)
1547                            
1548                             return false;
1549                         });
1550                 }
1551
1552                 // user defined functions
1553         }
1554
1555
1556         public class Xcls_search_results : Object
1557         {
1558                 public Gtk.Label el;
1559                 private Editor  _this;
1560
1561
1562                         // my vars (def)
1563
1564                 // ctor
1565                 public Xcls_search_results(Editor _owner )
1566                 {
1567                         _this = _owner;
1568                         _this.search_results = this;
1569                         this.el = new Gtk.Label( "No Results" );
1570
1571                         // my vars (dec)
1572
1573                         // set gobject values
1574                         this.el.margin_end = 4;
1575                         this.el.margin_start = 4;
1576                 }
1577
1578                 // user defined functions
1579                 public void updateResults () {
1580                         this.el.visible = true;
1581                         
1582                         var res = _this.searchcontext.get_occurrences_count();
1583                         if (res < 0) {
1584                                 _this.search_results.el.label = "??? Matches";          
1585                                 return;
1586                         }
1587                 
1588                         _this.nextBtn.el.sensitive = false;
1589                         _this.backBtn.el.sensitive = false;     
1590                 
1591                         if (res > 0) {
1592                                 _this.search_results.el.label = "%d Matches".printf(res);
1593                                 _this.nextBtn.el.sensitive = true;
1594                                 _this.backBtn.el.sensitive = true;
1595                                 return;
1596                         } 
1597                         _this.search_results.el.label = "No Matches";
1598                         
1599                 }
1600         }
1601
1602         public class Xcls_nextBtn : Object
1603         {
1604                 public Gtk.Button el;
1605                 private Editor  _this;
1606
1607
1608                         // my vars (def)
1609                 public bool always_show_image;
1610
1611                 // ctor
1612                 public Xcls_nextBtn(Editor _owner )
1613                 {
1614                         _this = _owner;
1615                         _this.nextBtn = this;
1616                         this.el = new Gtk.Button();
1617
1618                         // my vars (dec)
1619                         this.always_show_image = true;
1620
1621                         // set gobject values
1622                         this.el.icon_name = "go-down";
1623                         this.el.sensitive = false;
1624
1625                         //listeners
1626                         this.el.clicked.connect( (event) => {
1627                         
1628                                 _this.forwardSearch(true);
1629                                 
1630                                  
1631                         });
1632                 }
1633
1634                 // user defined functions
1635         }
1636
1637         public class Xcls_backBtn : Object
1638         {
1639                 public Gtk.Button el;
1640                 private Editor  _this;
1641
1642
1643                         // my vars (def)
1644                 public bool always_show_image;
1645
1646                 // ctor
1647                 public Xcls_backBtn(Editor _owner )
1648                 {
1649                         _this = _owner;
1650                         _this.backBtn = this;
1651                         this.el = new Gtk.Button();
1652
1653                         // my vars (dec)
1654                         this.always_show_image = true;
1655
1656                         // set gobject values
1657                         this.el.icon_name = "go-up";
1658                         this.el.sensitive = false;
1659
1660                         //listeners
1661                         this.el.clicked.connect( (event) => {
1662                         
1663                                 _this.backSearch(true);
1664                                  
1665                         });
1666                 }
1667
1668                 // user defined functions
1669         }
1670
1671         public class Xcls_MenuButton21 : Object
1672         {
1673                 public Gtk.MenuButton el;
1674                 private Editor  _this;
1675
1676
1677                         // my vars (def)
1678                 public bool always_show_image;
1679
1680                 // ctor
1681                 public Xcls_MenuButton21(Editor _owner )
1682                 {
1683                         _this = _owner;
1684                         this.el = new Gtk.MenuButton();
1685
1686                         // my vars (dec)
1687                         this.always_show_image = true;
1688
1689                         // set gobject values
1690                         this.el.icon_name = "emblem-system";
1691                         this.el.always_show_arrow = true;
1692                         new Xcls_search_settings( _this );
1693                         this.el.popover = _this.search_settings.el;
1694                 }
1695
1696                 // user defined functions
1697         }
1698         public class Xcls_search_settings : Object
1699         {
1700                 public Gtk.Popover el;
1701                 private Editor  _this;
1702
1703
1704                         // my vars (def)
1705
1706                 // ctor
1707                 public Xcls_search_settings(Editor _owner )
1708                 {
1709                         _this = _owner;
1710                         _this.search_settings = this;
1711                         this.el = new Gtk.Popover();
1712
1713                         // my vars (dec)
1714
1715                         // set gobject values
1716                         var child_1 = new Xcls_Box23( _this );
1717                         child_1.ref();
1718                         this.el.child = child_1.el;
1719                 }
1720
1721                 // user defined functions
1722         }
1723         public class Xcls_Box23 : Object
1724         {
1725                 public Gtk.Box el;
1726                 private Editor  _this;
1727
1728
1729                         // my vars (def)
1730
1731                 // ctor
1732                 public Xcls_Box23(Editor _owner )
1733                 {
1734                         _this = _owner;
1735                         this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1736
1737                         // my vars (dec)
1738
1739                         // set gobject values
1740                         new Xcls_case_sensitive( _this );
1741                         this.el.append( _this.case_sensitive.el );
1742                         new Xcls_regex( _this );
1743                         this.el.append( _this.regex.el );
1744                         new Xcls_multiline( _this );
1745                         this.el.append( _this.multiline.el );
1746                 }
1747
1748                 // user defined functions
1749         }
1750         public class Xcls_case_sensitive : Object
1751         {
1752                 public Gtk.CheckButton el;
1753                 private Editor  _this;
1754
1755
1756                         // my vars (def)
1757
1758                 // ctor
1759                 public Xcls_case_sensitive(Editor _owner )
1760                 {
1761                         _this = _owner;
1762                         _this.case_sensitive = this;
1763                         this.el = new Gtk.CheckButton();
1764
1765                         // my vars (dec)
1766
1767                         // set gobject values
1768                         this.el.label = "Case Sensitive";
1769
1770                         // init method
1771
1772                         {
1773                                 this.el.show();
1774                         }
1775                 }
1776
1777                 // user defined functions
1778         }
1779
1780         public class Xcls_regex : Object
1781         {
1782                 public Gtk.CheckButton el;
1783                 private Editor  _this;
1784
1785
1786                         // my vars (def)
1787
1788                 // ctor
1789                 public Xcls_regex(Editor _owner )
1790                 {
1791                         _this = _owner;
1792                         _this.regex = this;
1793                         this.el = new Gtk.CheckButton();
1794
1795                         // my vars (dec)
1796
1797                         // set gobject values
1798                         this.el.label = "Regex";
1799
1800                         // init method
1801
1802                         {
1803                                 this.el.show();
1804                         }
1805                 }
1806
1807                 // user defined functions
1808         }
1809
1810         public class Xcls_multiline : Object
1811         {
1812                 public Gtk.CheckButton el;
1813                 private Editor  _this;
1814
1815
1816                         // my vars (def)
1817
1818                 // ctor
1819                 public Xcls_multiline(Editor _owner )
1820                 {
1821                         _this = _owner;
1822                         _this.multiline = this;
1823                         this.el = new Gtk.CheckButton();
1824
1825                         // my vars (dec)
1826
1827                         // set gobject values
1828                         this.el.label = "Multi-line (add \\n)";
1829                 }
1830
1831                 // user defined functions
1832         }
1833
1834
1835
1836
1837
1838
1839         public class Xcls_Box27 : Object
1840         {
1841                 public Gtk.Box el;
1842                 private Editor  _this;
1843
1844
1845                         // my vars (def)
1846
1847                 // ctor
1848                 public Xcls_Box27(Editor _owner )
1849                 {
1850                         _this = _owner;
1851                         this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1852
1853                         // my vars (dec)
1854
1855                         // set gobject values
1856                         this.el.hexpand = true;
1857                         this.el.vexpand = true;
1858                         var child_1 = new Xcls_Box28( _this );
1859                         child_1.ref();
1860                         this.el.append( child_1.el );
1861                         new Xcls_navigationwindow( _this );
1862                         this.el.append( _this.navigationwindow.el );
1863                 }
1864
1865                 // user defined functions
1866         }
1867         public class Xcls_Box28 : Object
1868         {
1869                 public Gtk.Box el;
1870                 private Editor  _this;
1871
1872
1873                         // my vars (def)
1874
1875                 // ctor
1876                 public Xcls_Box28(Editor _owner )
1877                 {
1878                         _this = _owner;
1879                         this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1880
1881                         // my vars (dec)
1882
1883                         // set gobject values
1884                 }
1885
1886                 // user defined functions
1887         }
1888
1889         public class Xcls_navigationwindow : Object
1890         {
1891                 public Gtk.ScrolledWindow el;
1892                 private Editor  _this;
1893
1894
1895                         // my vars (def)
1896
1897                 // ctor
1898                 public Xcls_navigationwindow(Editor _owner )
1899                 {
1900                         _this = _owner;
1901                         _this.navigationwindow = this;
1902                         this.el = new Gtk.ScrolledWindow();
1903
1904                         // my vars (dec)
1905
1906                         // set gobject values
1907                         this.el.hexpand = true;
1908                         this.el.vexpand = true;
1909                         this.el.visible = false;
1910                         new Xcls_navigation( _this );
1911                         this.el.child = _this.navigation.el;
1912                 }
1913
1914                 // user defined functions
1915         }
1916         public class Xcls_navigation : Object
1917         {
1918                 public Gtk.ColumnView el;
1919                 private Editor  _this;
1920
1921
1922                         // my vars (def)
1923                 public int last_selected_line;
1924                 public Gtk.Widget? selected_row;
1925
1926                 // ctor
1927                 public Xcls_navigation(Editor _owner )
1928                 {
1929                         _this = _owner;
1930                         _this.navigation = this;
1931                         new Xcls_navigationselmodel( _this );
1932                         this.el = new Gtk.ColumnView( _this.navigationselmodel.el );
1933
1934                         // my vars (dec)
1935                         this.last_selected_line = -1;
1936                         this.selected_row = null;
1937
1938                         // set gobject values
1939                         this.el.name = "editor-navigation";
1940                         var child_2 = new Xcls_ColumnViewColumn31( _this );
1941                         child_2.ref();
1942                         this.el.append_column( child_2.el );
1943                         var child_3 = new Xcls_GestureClick40( _this );
1944                         child_3.ref();
1945                         this.el.add_controller(  child_3.el );
1946                 }
1947
1948                 // user defined functions
1949                 public Gtk.Widget? getRowWidgetAt (double x,  double  y, out string pos) {
1950                 
1951                         pos = "";
1952                         var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
1953                         //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
1954                         if (w == null) {
1955                                 return null;
1956                         }
1957                         
1958                         var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
1959                         if (row == null) {
1960                                 return null;
1961                         }
1962                         
1963                         //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
1964                          
1965                  
1966                         
1967                         //GLib.debug("row number is %d", rn);
1968                         //GLib.debug("click %d, %d", (int)x, (int)y);
1969                         // above or belw
1970                         Graphene.Rect  bounds;
1971                         row.compute_bounds(this.el, out bounds);
1972                         //GLib.debug("click x=%d, y=%d, w=%d, h=%d", 
1973                         //      (int)bounds.get_x(), (int)bounds.get_y(),
1974                         //      (int)bounds.get_width(), (int)bounds.get_height()
1975                         //      );
1976                         var ypos = y - bounds.get_y();
1977                         //GLib.debug("rel ypos = %d", (int)ypos);       
1978                         var rpos = 100.0 * (ypos / bounds.get_height());
1979                         //GLib.debug("rel pos = %d %%", (int)rpos);
1980                         pos = "over";
1981                         
1982                         if (rpos > 80) {
1983                                 pos = "below";
1984                         } else if (rpos < 20) {
1985                                 pos = "above";
1986                         } 
1987                         return row;
1988                  }
1989                 public void show (Gee.ArrayList<Lsp.DocumentSymbol> syms) {
1990                         _this.navigationwindow.el.show();
1991                         //_this.navliststore.el.remove_all();
1992                         
1993                         
1994                         var ls  = new GLib.ListStore(typeof(Lsp.DocumentSymbol));
1995                         
1996                         foreach(var sym in syms) {
1997                                 ls.append(sym);
1998                         }
1999                         Lsp.DocumentSymbol.copyList(ls, _this.navliststore.el);
2000                         //_this.navliststore.el.append(sym);
2001                         this.last_selected_line = -1;
2002                         GLib.Idle.add(() => {
2003                                 _this.navigationsort.collapseOnLoad();
2004                                 Gtk.TextIter iter;
2005                                 _this.buffer.el.get_iter_at_offset (
2006                                                 out iter, _this.buffer.el.cursor_position);
2007                                 
2008                                 GLib.debug("idle update scroll %d, %d", iter.get_line(),
2009                                                 iter.get_line_offset());
2010                                 this.updateSelectedLine(
2011                                                 (uint)iter.get_line(),
2012                                                 (uint)iter.get_line_offset()
2013                                 );
2014                                 return false;
2015                         });
2016                 
2017                 }
2018                 public int getRowAt (double x,  double  y, out string pos) {
2019                 
2020                         pos = "";
2021                         var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
2022                         //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
2023                         if (w == null) {
2024                                 return -1;
2025                         }
2026                         
2027                         var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
2028                         if (row == null) {
2029                                 return -1;
2030                         }
2031                         
2032                         //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2033                          
2034                         var rn = 0;
2035                         var cr = row;
2036                          
2037                         while (cr.get_prev_sibling() != null) {
2038                                 rn++;
2039                                 cr = cr.get_prev_sibling();
2040                         }
2041                         
2042                         //GLib.debug("row number is %d", rn);
2043                         //GLib.debug("click %d, %d", (int)x, (int)y);
2044                         // above or belw
2045                         Graphene.Rect  bounds;
2046                         row.compute_bounds(this.el, out bounds);
2047                         //GLib.debug("click x=%d, y=%d, w=%d, h=%d", 
2048                         //      (int)bounds.get_x(), (int)bounds.get_y(),
2049                         //      (int)bounds.get_width(), (int)bounds.get_height()
2050                         //      );
2051                         var ypos = y - bounds.get_y();
2052                         //GLib.debug("rel ypos = %d", (int)ypos);       
2053                         var rpos = 100.0 * (ypos / bounds.get_height());
2054                         //GLib.debug("rel pos = %d %%", (int)rpos);
2055                         pos = "over";
2056                         
2057                         if (rpos > 80) {
2058                                 pos = "below";
2059                         } else if (rpos < 20) {
2060                                 pos = "above";
2061                         } 
2062                         return rn;
2063                  }
2064                 public void updateSelectedLine (uint line, uint chr) {
2065                         if (line == this.last_selected_line) {
2066                                 return;
2067                         }
2068                         GLib.debug("select line %d", (int)line);
2069                         this.last_selected_line = (int)line;
2070                         
2071                         
2072                         var new_row = -1;
2073                         var sym = _this.navliststore.symbolAtLine(line, chr);
2074                         if (sym != null) {
2075                                 new_row = _this.navigationsort.getRowFromSymbol(sym);
2076                                 GLib.debug("select line %d - row found %d", (int)line, new_row);
2077                         } else {
2078                                 GLib.debug(" no symbol found at line %d", (int)line);
2079                         }
2080                         
2081                         if (this.selected_row != null) { 
2082                                 GLib.debug(" remove selected row");
2083                                 this.selected_row.remove_css_class("selected-row");
2084                         }
2085                         this.selected_row  = null;
2086                         if (new_row > -1) {
2087                                 this.el.scroll_to(new_row,null,Gtk.ListScrollFlags.NONE, null);
2088                                 var row = sym.get_data<Gtk.Widget>("widget");
2089                                 if (row != null) {
2090                                         GLib.debug(" Add selected row");
2091                                         
2092                                         row.add_css_class("selected-row");
2093                                         this.selected_row = row;
2094                 
2095                                         
2096                                 } else {
2097                                         GLib.debug("could not find widget on row %d", new_row);
2098                                 }
2099                 
2100                         }
2101                 
2102                 
2103                 }
2104         }
2105         public class Xcls_ColumnViewColumn31 : Object
2106         {
2107                 public Gtk.ColumnViewColumn el;
2108                 private Editor  _this;
2109
2110
2111                         // my vars (def)
2112
2113                 // ctor
2114                 public Xcls_ColumnViewColumn31(Editor _owner )
2115                 {
2116                         _this = _owner;
2117                         var child_1 = new Xcls_SignalListItemFactory32( _this );
2118                         child_1.ref();
2119                         this.el = new Gtk.ColumnViewColumn( "Code Navigation", child_1.el );
2120
2121                         // my vars (dec)
2122
2123                         // set gobject values
2124                         this.el.expand = true;
2125                 }
2126
2127                 // user defined functions
2128         }
2129         public class Xcls_SignalListItemFactory32 : Object
2130         {
2131                 public Gtk.SignalListItemFactory el;
2132                 private Editor  _this;
2133
2134
2135                         // my vars (def)
2136
2137                 // ctor
2138                 public Xcls_SignalListItemFactory32(Editor _owner )
2139                 {
2140                         _this = _owner;
2141                         this.el = new Gtk.SignalListItemFactory();
2142
2143                         // my vars (dec)
2144
2145                         // set gobject values
2146
2147                         //listeners
2148                         this.el.setup.connect( (listitem) => {
2149                                 
2150                                 var expand = new Gtk.TreeExpander();
2151                                  
2152                                 expand.set_indent_for_depth(true);
2153                                 expand.set_indent_for_icon(true);
2154                                 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2155                                 var icon = new Gtk.Image();
2156                                 var lbl = new Gtk.Label("");
2157                                 lbl.use_markup = true;
2158                                 lbl.ellipsize = Pango.EllipsizeMode.END;
2159                                 
2160                                 icon.margin_end = 4;
2161                                 lbl.justify = Gtk.Justification.LEFT;
2162                                 lbl.xalign = 0;
2163                         
2164                         //      listitem.activatable = true; ??
2165                                 
2166                                 hbox.append(icon);
2167                                 hbox.append(lbl);
2168                                 expand.set_child(hbox);
2169                                 ((Gtk.ListItem)listitem).set_child(expand);
2170                                 
2171                         });
2172                         this.el.bind.connect( (listitem) => {
2173                                  
2174                                 // GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name());
2175                                 
2176                                 //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2177                                 var expand = (Gtk.TreeExpander)  ((Gtk.ListItem)listitem).get_child();
2178                                  
2179                                  
2180                                 var hbox = (Gtk.Box) expand.child;
2181                          
2182                                 
2183                                 var img = (Gtk.Image) hbox.get_first_child();
2184                                 var lbl = (Gtk.Label) img.get_next_sibling();
2185                                 
2186                                 var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();
2187                                 var sym = (Lsp.DocumentSymbol) lr.get_item();
2188                                 
2189                                 sym.set_data<Gtk.Widget>("widget", expand.get_parent());
2190                                 expand.get_parent().get_parent().set_data<Lsp.DocumentSymbol>("symbol", sym);
2191                                 
2192                                 //GLib.debug("save sym on %s", expand.get_parent().get_parent().get_type().name());
2193                                 
2194                                 //GLib.debug("got %d children for %s" , (int)sym.children.get_n_items(), sym.name);
2195                             
2196                             expand.set_hide_expander( sym.children.get_n_items()  < 1);
2197                                 expand.set_list_row(lr);
2198                                 //this.in_bind = true;
2199                                 // default is to expand
2200                          
2201                                 //this.in_bind = false;
2202                                 
2203                                 sym.bind_property("symbol_icon",
2204                                             img, "icon_name",
2205                                            GLib.BindingFlags.SYNC_CREATE);
2206                                 
2207                                 hbox.css_classes = { sym.symbol_icon };
2208                                 
2209                                 sym.bind_property("name",
2210                                             lbl, "label",
2211                                            GLib.BindingFlags.SYNC_CREATE);
2212                                 // should be better?- --line no?
2213                                 sym.bind_property("tooltip",
2214                                             lbl, "tooltip_markup",
2215                                            GLib.BindingFlags.SYNC_CREATE);
2216                                 // bind image...
2217                                 
2218                         });
2219                 }
2220
2221                 // user defined functions
2222         }
2223
2224
2225         public class Xcls_navigationselmodel : Object
2226         {
2227                 public Gtk.NoSelection el;
2228                 private Editor  _this;
2229
2230
2231                         // my vars (def)
2232
2233                 // ctor
2234                 public Xcls_navigationselmodel(Editor _owner )
2235                 {
2236                         _this = _owner;
2237                         _this.navigationselmodel = this;
2238                         new Xcls_navigationsort( _this );
2239                         this.el = new Gtk.NoSelection( _this.navigationsort.el );
2240
2241                         // my vars (dec)
2242
2243                         // set gobject values
2244                 }
2245
2246                 // user defined functions
2247         }
2248         public class Xcls_navigationsort : Object
2249         {
2250                 public Gtk.SortListModel el;
2251                 private Editor  _this;
2252
2253
2254                         // my vars (def)
2255
2256                 // ctor
2257                 public Xcls_navigationsort(Editor _owner )
2258                 {
2259                         _this = _owner;
2260                         _this.navigationsort = this;
2261                         var child_1 = new Xcls_TreeListModel35( _this );
2262                         child_1.ref();
2263                         var child_2 = new Xcls_TreeListRowSorter37( _this );
2264                         child_2.ref();
2265                         this.el = new Gtk.SortListModel( child_1.el, child_2.el );
2266
2267                         // my vars (dec)
2268
2269                         // set gobject values
2270                 }
2271
2272                 // user defined functions
2273                 public void collapseOnLoad () {
2274                         for (var i=0;i < this.el.get_n_items(); i++) {
2275                                 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2276                                 var sym =  (Lsp.DocumentSymbol)tr.get_item();
2277                                 switch (sym.kind) {
2278                                         case Lsp.SymbolKind.Enum: 
2279                                                 tr.expanded = false;
2280                                                 break;
2281                                         default:
2282                                                 //tr.expanded = true;
2283                                                 break;
2284                                 }
2285                         }
2286                  
2287                         
2288                 
2289                 
2290                 }
2291                 public int getRowFromSymbol (Lsp.DocumentSymbol sym) {
2292                 
2293                         for (var i=0;i < this.el.get_n_items(); i++) {
2294                                 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2295                            
2296                                 if (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {
2297                                         return i;
2298                                 }
2299                         }
2300                         return -1;
2301                 }
2302                 public Lsp.DocumentSymbol? getSymbolAt (uint row) {
2303                 
2304                    var tr = (Gtk.TreeListRow)this.el.get_item(row);
2305                    
2306                    var a = tr.get_item();;   
2307                    GLib.debug("get_item (2) = %s", a.get_type().name());
2308                         
2309                    
2310                    return (Lsp.DocumentSymbol)tr.get_item();
2311                          
2312                 }
2313         }
2314         public class Xcls_TreeListModel35 : Object
2315         {
2316                 public Gtk.TreeListModel el;
2317                 private Editor  _this;
2318
2319
2320                         // my vars (def)
2321
2322                 // ctor
2323                 public Xcls_TreeListModel35(Editor _owner )
2324                 {
2325                         _this = _owner;
2326                         new Xcls_navliststore( _this );
2327                         this.el = new Gtk.TreeListModel( _this.navliststore.el, false, true, (item) => {
2328  
2329         return ((Lsp.DocumentSymbol)item).children;
2330 }
2331  );
2332
2333                         // my vars (dec)
2334
2335                         // set gobject values
2336
2337                         //listeners
2338                         this.el.items_changed.connect( (position, removed, added) => {
2339                                 GLib.debug("tree item changed %d , %d , %d",(int) position, (int)removed, (int) added);
2340                                  if (added < 1) { 
2341                                         return;
2342                                 }
2343                                 //var sym = (Lsp.DocumentSymbol) this.el.get_item(position);
2344                                 var row = this.el.get_row(position);
2345                                 
2346                                 GLib.debug("got %s", row.get_item().get_type().name());
2347                                 
2348                         
2349                         });
2350                 }
2351
2352                 // user defined functions
2353         }
2354         public class Xcls_navliststore : Object
2355         {
2356                 public GLib.ListStore el;
2357                 private Editor  _this;
2358
2359
2360                         // my vars (def)
2361
2362                 // ctor
2363                 public Xcls_navliststore(Editor _owner )
2364                 {
2365                         _this = _owner;
2366                         _this.navliststore = this;
2367                         this.el = new GLib.ListStore( typeof(Lsp.DocumentSymbol) );
2368
2369                         // my vars (dec)
2370
2371                         // set gobject values
2372                 }
2373
2374                 // user defined functions
2375                 public Lsp.DocumentSymbol? symbolAtLine (uint line, uint chr) {
2376                  
2377                         
2378                         for(var i = 0; i < this.el.get_n_items();i++) {
2379                                 var el = (Lsp.DocumentSymbol)this.el.get_item(i);
2380                                 //GLib.debug("Check sym %s : %d-%d",
2381                                 //      el.name , (int)el.range.start.line,
2382                                 //      (int)el.range.end.line
2383                                 //);
2384                                 var ret = el.containsLine(line,chr);
2385                                 if (ret != null) {
2386                                         return ret;
2387                                 }
2388                                 
2389                         }
2390                         
2391                         return null;
2392                 }
2393         }
2394
2395
2396         public class Xcls_TreeListRowSorter37 : Object
2397         {
2398                 public Gtk.TreeListRowSorter el;
2399                 private Editor  _this;
2400
2401
2402                         // my vars (def)
2403
2404                 // ctor
2405                 public Xcls_TreeListRowSorter37(Editor _owner )
2406                 {
2407                         _this = _owner;
2408                         var child_1 = new Xcls_StringSorter38( _this );
2409                         child_1.ref();
2410                         this.el = new Gtk.TreeListRowSorter( child_1.el );
2411
2412                         // my vars (dec)
2413
2414                         // set gobject values
2415                 }
2416
2417                 // user defined functions
2418         }
2419         public class Xcls_StringSorter38 : Object
2420         {
2421                 public Gtk.StringSorter el;
2422                 private Editor  _this;
2423
2424
2425                         // my vars (def)
2426
2427                 // ctor
2428                 public Xcls_StringSorter38(Editor _owner )
2429                 {
2430                         _this = _owner;
2431                         var child_1 = new Xcls_PropertyExpression39( _this );
2432                         child_1.ref();
2433                         this.el = new Gtk.StringSorter( child_1.el );
2434
2435                         // my vars (dec)
2436
2437                         // set gobject values
2438                 }
2439
2440                 // user defined functions
2441         }
2442         public class Xcls_PropertyExpression39 : Object
2443         {
2444                 public Gtk.PropertyExpression el;
2445                 private Editor  _this;
2446
2447
2448                         // my vars (def)
2449
2450                 // ctor
2451                 public Xcls_PropertyExpression39(Editor _owner )
2452                 {
2453                         _this = _owner;
2454                         this.el = new Gtk.PropertyExpression( typeof(Lsp.DocumentSymbol), null, "sort_key" );
2455
2456                         // my vars (dec)
2457
2458                         // set gobject values
2459                 }
2460
2461                 // user defined functions
2462         }
2463
2464
2465
2466
2467
2468         public class Xcls_GestureClick40 : Object
2469         {
2470                 public Gtk.GestureClick el;
2471                 private Editor  _this;
2472
2473
2474                         // my vars (def)
2475
2476                 // ctor
2477                 public Xcls_GestureClick40(Editor _owner )
2478                 {
2479                         _this = _owner;
2480                         this.el = new Gtk.GestureClick();
2481
2482                         // my vars (dec)
2483
2484                         // set gobject values
2485
2486                         //listeners
2487                         this.el.pressed.connect( (n_press, x, y) => {
2488                                 string pos;
2489                                 var row = _this.navigation.getRowWidgetAt(x,y, out pos );
2490                         
2491                             if (row == null) {
2492                                     GLib.debug("no row selected items");
2493                                     return;
2494                             }
2495                                 GLib.debug("got click on %s", row.get_type().name());    
2496                             //Lsp.DocumentSymbol
2497                             var sym =  row.get_data<Lsp.DocumentSymbol>("symbol");
2498                             if (sym == null) {
2499                                 return;
2500                                 }
2501                                 /*
2502                                  "range" : {
2503                                       "start" : {
2504                                         "line" : 1410,
2505                                         "character" : 8
2506                                       },
2507                                       "end" : {
2508                                         "line" : 1410,
2509                                         "character" : 39
2510                                       }
2511                                     },
2512                                 */
2513                              GLib.debug("goto line %d",   (int)sym.range.start.line); 
2514                             _this.scroll_to_line((int)sym.range.start.line);
2515                             Gtk.TextIter iter;
2516                             _this.buffer.el.get_iter_at_line_offset(out iter, 
2517                                 (int)sym.range.start.line,
2518                                 (int)sym.range.start.character
2519                                 );
2520                             _this.buffer.el.place_cursor(iter);
2521                                 
2522                         });
2523                 }
2524
2525                 // user defined functions
2526         }
2527
2528
2529
2530
2531
2532 }