3 public class Editor : Object
8 public static Editor singleton()
10 if (_Editor == null) {
11 _Editor= new Editor();
15 public Xcls_save_button save_button;
16 public Xcls_close_btn close_btn;
17 public Xcls_RightEditor RightEditor;
18 public Xcls_view view;
19 public Xcls_buffer buffer;
20 public Xcls_keystate keystate;
21 public Xcls_search_entry search_entry;
22 public Xcls_search_results search_results;
23 public Xcls_nextBtn nextBtn;
24 public Xcls_backBtn backBtn;
25 public Xcls_search_settings search_settings;
26 public Xcls_case_sensitive case_sensitive;
27 public Xcls_regex regex;
28 public Xcls_multiline multiline;
29 public Xcls_navigationwindow navigationwindow;
30 public Xcls_navigation navigation;
31 public Xcls_navigationselmodel navigationselmodel;
32 public Xcls_navigationsort navigationsort;
33 public Xcls_navliststore navliststore;
36 public int pos_root_x;
37 public Xcls_MainWindow window;
39 public int pos_root_y;
41 public int last_error_counter;
42 public GtkSource.SearchContext searchcontext;
43 public int last_search_end;
44 public signal void save ();
45 public JsRender.JsRender? file;
46 public JsRender.Node node;
47 public JsRender.NodeProp? prop;
48 public string activeEditor;
54 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
60 this.last_error_counter = 0;
61 this.searchcontext = null;
62 this.last_search_end = 0;
66 this.activeEditor = "\"\"";
69 this.el.homogeneous = false;
70 this.el.hexpand = true;
71 this.el.vexpand = true;
72 var child_1 = new Xcls_Paned1( _this );
74 this.el.append( child_1.el );
77 // user defined functions
78 public bool saveContents () {
81 if (_this.file == null) {
87 var str = _this.buffer.toString();
89 _this.buffer.checkSyntax();
93 // LeftPanel.model.changed( str , false);
95 _this.save_button.el.sensitive = false;
97 // find the text for the node..
98 if (_this.file.xtype != "PlainFile") {
99 // in theory these properties have to exist!?!
101 //this.window.windowstate.left_props.reload();
103 _this.file.setSource( str );
112 public void forwardSearch (bool change_focus) {
114 if (this.searchcontext == null) {
118 Gtk.TextIter beg, st,en;
119 bool has_wrapped_around;
120 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end);
121 if (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {
123 this.last_search_end = 0; // not sure if this should happen
125 if (has_wrapped_around) {
129 this.last_search_end = en.get_offset();
131 this.view.el.grab_focus();
133 this.buffer.el.place_cursor(st);
134 this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);
138 public void show (JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)
141 if (this.file != null) {
142 this.file.navigation_tree_updated.disconnect(
143 _this.navigation.show
147 this.file.navigation_tree_updated.connect(
148 _this.navigation.show
150 if (file.xtype != "PlainFile") {
154 // find the text for the node..
155 this.view.load( prop.val );
156 this.updateErrorMarks();
160 this.close_btn.el.show();
163 this.view.load( file.toSource() );
164 this.updateErrorMarks();
165 this.close_btn.el.hide();
166 var ls = file.getLanguageServer();
167 ls.queueDocumentSymbols(file);
168 ////ls.documentSymbols.begin(file, (a,o) => {
169 // _this.navigation.show(ls.documentSymbols.end(o));
176 public void backSearch (bool change_focus) {
178 if (this.searchcontext == null) {
182 Gtk.TextIter beg, st,en;
183 bool has_wrapped_around;
184 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );
186 if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {
187 this.last_search_end = 0;
189 this.last_search_end = en.get_offset();
191 this.view.el.grab_focus();
193 this.buffer.el.place_cursor(st);
194 this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);
198 public string tempFileContents () {
201 if (_this.file == null) {
204 var str= this.buffer.toString();
205 if (_this.file.xtype == "PlainFile") {
213 GLib.debug("calling validate");
214 // clear the buttons.
215 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
216 return this.file.toSource(); ;
219 var oldcode = _this.prop.val;
220 _this.prop.val = str;
221 var ret = _this.file.toSource();
222 _this.prop.val = oldcode;
226 public void reset () {
231 this.searchcontext = null;
234 public int search (string in_txt) {
236 var s = new GtkSource.SearchSettings();
237 s.case_sensitive = _this.case_sensitive.el.active;
238 s.regex_enabled = _this.regex.el.active;
239 s.wrap_around = false;
241 this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);
242 this.searchcontext.set_highlight(true);
245 if (_this.multiline.el.active) {
246 txt = in_txt.replace("\\n", "\n");
249 s.set_search_text(txt);
250 Gtk.TextIter beg, st,en;
252 this.buffer.el.get_start_iter(out beg);
253 bool has_wrapped_around;
254 this.searchcontext.forward(beg, out st, out en, out has_wrapped_around);
255 this.last_search_end = 0;
257 return this.searchcontext.get_occurrences_count();
263 public void updateErrorMarks () {
267 var buf = _this.buffer.el;
270 buf.get_bounds (out start, out end);
275 //GLib.debug("highlight errors");
277 // we should highlight other types of errors..
279 if (_this.window.windowstate.state != WindowState.State.CODEONLY
281 _this.window.windowstate.state != WindowState.State.CODE
283 //GLib.debug("windowstate != CODEONLY?");
289 if (_this.file == null) {
290 GLib.debug("file is null?");
294 var ar = this.file.getErrors();
296 buf.remove_source_marks (start, end, "ERR");
297 buf.remove_source_marks (start, end, "WARN");
298 buf.remove_source_marks (start, end, "DEPR");
299 buf.remove_tag_by_name ("ERR", start, end);
300 buf.remove_tag_by_name ("WARN", start, end);
301 buf.remove_tag_by_name ("DEPR", start, end);
302 this.last_error_counter = file.error_counter ;
303 //GLib.debug("highlight %s : %s has no errors", this.file.relpath, category);
308 // basicaly check if there is no change, then we do not do any update..
309 // we can do this by just using an error counter?
310 // if that's changed then we will do an update, otherwise dont bother.
316 var tlines = buf.get_line_count () +1;
318 if (_this.prop != null) {
319 // this still seems flaky...
321 tlines = _this.prop.end_line;
322 offset = _this.prop.start_line;
323 hoffset = _this.node.node_pad.length + 2; //shift it left by 2 ? ..
328 if (this.last_error_counter == file.error_counter) {
334 buf.remove_source_marks (start, end, "ERR");
335 buf.remove_source_marks (start, end, "WARN");
336 buf.remove_source_marks (start, end, "DEPR");
337 buf.remove_tag_by_name ("ERR", start, end);
338 buf.remove_tag_by_name ("WARN", start, end);
339 buf.remove_tag_by_name ("DEPR", start, end);
341 foreach(var diag in ar) {
343 // print("get inter\n");
344 var eline = (int)diag.range.start.line - offset;
345 var eline_to = (int)diag.range.end.line - offset;
346 //var eline = diag.range.end_line - offset;
347 //GLib.debug("GOT ERROR on line %d -- converted to %d (offset = %d)",
348 // err.line ,eline, offset);
351 if (eline > tlines || eline < 0) {
355 buf.get_iter_at_line( out iter, eline);
356 var msg = "Line: %d %s : %s".printf(eline+1, diag.category, diag.message);
357 buf.create_source_mark( msg, diag.category, iter);
359 var spos = (int)diag.range.start.character - hoffset;
360 if (spos < 0) { spos =0 ; }
361 if (spos > iter.get_chars_in_line()) {
362 spos = iter.get_chars_in_line();
364 buf.get_iter_at_line( out iter, eline_to);
365 var epos = (int)diag.range.end.character - hoffset;
366 if (epos < 0) { epos =0 ; }
367 if (epos > iter.get_chars_in_line()) {
368 epos = iter.get_chars_in_line();
372 buf.get_iter_at_line_offset( out start, eline, spos);
374 buf.get_iter_at_line_offset( out end, eline_to,epos);
376 buf.apply_tag_by_name(diag.category, start, end);
378 // GLib.debug("set line %d to %s", eline, msg);
379 //this.marks.set(eline, msg);
381 this.last_error_counter = file.error_counter ;
388 public void scroll_to_line (int line) {
390 GLib.Timeout.add(500, () => {
392 var buf = this.view.el.get_buffer();
394 var sbuf = (GtkSource.Buffer) buf;
398 sbuf.get_iter_at_line(out iter, line);
399 this.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
403 public class Xcls_Paned1 : Object
406 private Editor _this;
412 public Xcls_Paned1(Editor _owner )
415 this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL );
419 // set gobject values
420 var child_1 = new Xcls_Box2( _this );
422 this.el.start_child = child_1.el;
423 var child_2 = new Xcls_Box27( _this );
425 this.el.end_child = child_2.el;
428 // user defined functions
430 public class Xcls_Box2 : Object
433 private Editor _this;
439 public Xcls_Box2(Editor _owner )
442 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
446 // set gobject values
447 var child_1 = new Xcls_Box3( _this );
449 this.el.append( child_1.el );
450 new Xcls_RightEditor( _this );
451 this.el.append( _this.RightEditor.el );
452 var child_3 = new Xcls_Box15( _this );
454 this.el.append ( child_3.el );
457 // user defined functions
459 public class Xcls_Box3 : Object
462 private Editor _this;
468 public Xcls_Box3(Editor _owner )
471 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
475 // set gobject values
476 this.el.homogeneous = false;
477 this.el.hexpand = true;
478 new Xcls_save_button( _this );
479 this.el.append( _this.save_button.el );
480 var child_2 = new Xcls_Label5( _this );
482 this.el.append( child_2.el );
483 var child_3 = new Xcls_Scale6( _this );
485 this.el.append( child_3.el );
486 new Xcls_close_btn( _this );
487 this.el.append( _this.close_btn.el );
490 // user defined functions
492 public class Xcls_save_button : Object
494 public Gtk.Button el;
495 private Editor _this;
501 public Xcls_save_button(Editor _owner )
504 _this.save_button = this;
505 this.el = new Gtk.Button();
509 // set gobject values
510 this.el.label = "Save";
513 this.el.clicked.connect( () => {
514 _this.saveContents();
518 // user defined functions
521 public class Xcls_Label5 : Object
524 private Editor _this;
530 public Xcls_Label5(Editor _owner )
533 this.el = new Gtk.Label( null );
537 // set gobject values
538 this.el.hexpand = true;
541 // user defined functions
544 public class Xcls_Scale6 : Object
547 private Editor _this;
553 public Xcls_Scale6(Editor _owner )
556 this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1);
560 // set gobject values
561 this.el.width_request = 200;
562 this.el.has_origin = true;
563 this.el.draw_value = false;
565 this.el.sensitive = true;
570 //this.el.set_range(6,30);
571 this.el.set_value ( BuilderApplication.settings.editor_font_size);
572 BuilderApplication.settings.editor_font_size_updated.connect(
574 BuilderApplication.settings.editor_font_size_inchange = true;
575 // GLib.debug("update range");
576 this.el.set_value (BuilderApplication.settings.editor_font_size);
577 BuilderApplication.settings.editor_font_size_inchange = false;
585 this.el.change_value.connect( (st, val ) => {
586 if (BuilderApplication.settings.editor_font_size_inchange) {
589 BuilderApplication.settings.editor_font_size = val;
594 // user defined functions
597 public class Xcls_close_btn : Object
599 public Gtk.Button el;
600 private Editor _this;
606 public Xcls_close_btn(Editor _owner )
609 _this.close_btn = this;
610 this.el = new Gtk.Button();
614 // set gobject values
615 this.el.icon_name = "window-close";
616 var child_1 = new Xcls_Image8( _this );
618 this.el.child = child_1.el;
621 this.el.clicked.connect( () => {
622 _this.saveContents();
623 _this.window.windowstate.switchState(WindowState.State.PREVIEW);
627 // user defined functions
629 public class Xcls_Image8 : Object
632 private Editor _this;
638 public Xcls_Image8(Editor _owner )
641 this.el = new Gtk.Image();
645 // set gobject values
646 this.el.icon_name = "window-close";
647 this.el.icon_size = Gtk.IconSize.NORMAL;
650 // user defined functions
655 public class Xcls_RightEditor : Object
657 public Gtk.ScrolledWindow el;
658 private Editor _this;
664 public Xcls_RightEditor(Editor _owner )
667 _this.RightEditor = this;
668 this.el = new Gtk.ScrolledWindow();
672 // set gobject values
673 this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
674 this.el.vexpand = true;
675 this.el.overlay_scrolling = false;
676 this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
677 new Xcls_view( _this );
678 this.el.child = _this.view.el;
681 // user defined functions
683 public class Xcls_view : Object
685 public GtkSource.View el;
686 private Editor _this;
690 public Gtk.CssProvider css;
693 public Xcls_view(Editor _owner )
697 this.el = new GtkSource.View();
702 // set gobject values
703 this.el.auto_indent = true;
704 this.el.indent_width = 4;
705 this.el.name = "editor-view";
706 this.el.show_line_marks = true;
707 this.el.insert_spaces_instead_of_tabs = true;
708 this.el.show_line_numbers = true;
709 this.el.hexpand = true;
710 this.el.vexpand = true;
711 this.el.has_tooltip = true;
712 this.el.css_classes = { "code-editor" };
713 this.el.tab_width = 4;
714 this.el.highlight_current_line = true;
715 new Xcls_buffer( _this );
716 this.el.buffer = _this.buffer.el;
717 new Xcls_keystate( _this );
718 this.el.add_controller( _this.keystate.el );
719 var child_3 = new Xcls_EventControllerScroll13( _this );
721 this.el.add_controller( child_3.el );
722 var child_4 = new Xcls_GestureClick14( _this );
724 this.el.add_controller( child_4.el );
728 this.el.completion.add_provider(
729 new Palete.CompletionProvider(_this)
732 // hover seems pretty useless.. - ??
733 //var hover = this.el.get_hover();
734 //hover.add_provider(new Palete.HoverProvider(_this));
736 //this.el.completion.unblock_interactive();
737 this.el.completion.select_on_show = true; // select
738 //this.el.completion.remember_info_visibility = true;
741 var attrs = new GtkSource.MarkAttributes();
743 attrs.set_icon_name ( "process-stop");
744 attrs.query_tooltip_text.connect(( mark) => {
745 GLib.debug("tooltip query? %s", mark.name);
746 return strdup( mark.name);
748 attrs.query_tooltip_markup.connect(( mark) => {
749 GLib.debug("tooltip query? %s", mark.name);
750 return strdup( mark.name);
752 this.el.set_mark_attributes ("ERR", attrs, 1);
756 var wattrs = new GtkSource.MarkAttributes();
757 wattrs.set_icon_name ( "process-stop");
758 wattrs.query_tooltip_text.connect(( mark) => {
759 GLib.debug("tooltip query? %s", mark.name);
760 return strdup(mark.name);
762 wattrs.query_tooltip_markup.connect(( mark) => {
763 GLib.debug("tooltip query? %s", mark.name);
764 return strdup(mark.name);
766 this.el.set_mark_attributes ("WARN", wattrs, 1);
770 var dattrs = new GtkSource.MarkAttributes();
772 dattrs.set_icon_name ( "process-stop");
774 dattrs.query_tooltip_text.connect(( mark) => {
775 GLib.debug("tooltip query? %s", mark.name);
776 return strdup(mark.name);
778 //dattrs.query_tooltip_markup.connect(( mark) => {
779 // GLib.debug("tooltip query? %s", mark.name);
780 // return strdup(mark.name);
782 this.el.set_mark_attributes ("DEPR", dattrs, 1);
785 this.el.get_space_drawer().set_matrix(null);
786 this.el.get_space_drawer().set_types_for_locations(
787 GtkSource.SpaceLocationFlags.ALL,
788 GtkSource.SpaceTypeFlags.ALL
790 this.el.get_space_drawer().set_enable_matrix(true);
793 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
795 //GLib.debug("query tooltip");
799 var yoff = (int) _this.RightEditor.el.vadjustment.value;
801 // I think this is problematic - if it's compliing / updating at same time as query.
803 //if (_this.window.statusbar_compile_spinner.el.spinning) {
807 this.el.get_iter_at_position (out iter, out trailing, x, y + yoff);
809 var l = iter.get_line();
813 // GLib.debug("query tooltip line %d", (int) l);
819 if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {
820 GLib.debug("line %d setting tip to %s", l, _this.buffer.marks.get(l));
821 tooltip.set_text(_this.buffer.marks.get(l).dup());
829 // this crashes?? - not sure why.
830 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
831 if (marks.is_empty()) {
832 marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
834 if (marks.is_empty()) {
835 marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
838 // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length());
840 marks.@foreach((m) => {
841 //GLib.debug("got mark %s", m.name);
842 str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name;
844 // true if there is a mark..
845 if (str.length > 0 ) {
846 tooltip.set_text( str );
848 return str.length > 0 ? true : false;
853 // user defined functions
854 public void load (string str) {
856 // show the help page for the active node..
857 //this.get('/Help').show();
859 // this.get('/BottomPane').el.set_current_page(0);
860 GLib.debug("load called - Reset undo buffer");
862 var buf = (GtkSource.Buffer)this.el.get_buffer();
863 buf.begin_irreversible_action();
864 buf.set_text(str, str.length);
865 buf.end_irreversible_action();
867 var lm = GtkSource.LanguageManager.get_default();
869 if (_this.file != null) {
870 lang = _this.file.language;
872 print("lang=%s, content_type = %s\n", lang, _this.file.content_type);
873 var lg = _this.file.content_type.length > 0 ?
874 lm.guess_language(_this.file.path, _this.file.content_type) :
875 lm.get_language(lang);
878 ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg);
880 this.el.insert_spaces_instead_of_tabs = true;
882 print("sourcelanguage = %s\n", lg.name);
883 if (lg.name == "Vala") {
884 this.el.insert_spaces_instead_of_tabs = false;
888 this.el.grab_focus();
889 _this.save_button.el.sensitive = false;
890 _this.last_error_counter = -1;
893 public class Xcls_buffer : Object
895 public GtkSource.Buffer el;
896 private Editor _this;
900 public int error_line;
901 public Gee.HashMap<int,string>? xmarks;
902 public bool check_queued;
905 public Xcls_buffer(Editor _owner )
909 this.el = new GtkSource.Buffer( null );
912 this.error_line = -1;
914 this.check_queued = false;
916 // set gobject values
917 this.el.highlight_syntax = true;
918 this.el.highlight_matching_brackets = true;
919 this.el.enable_undo = true;
924 buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
925 buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
926 buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
927 buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
928 buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
929 buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
930 buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
931 buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
934 buf.create_tag ("ERR", "weight", Pango.Weight.BOLD, "background", "pink");
935 buf.create_tag ("WARN", "weight", Pango.Weight.BOLD, "background", "#ABF4EB");
936 buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
939 this.el.cursor_moved.connect( ( ) => {
942 this.el.get_iter_at_offset (
943 out iter, this.el.cursor_position);
945 _this.navigation.updateSelectedLine(
946 (uint)iter.get_line(),
947 (uint)iter.get_line_offset()
952 this.el.changed.connect( () => {
955 _this.save_button.el.sensitive = true;
956 print("EDITOR CHANGED");
961 // this.get('/LeftPanel.model').changed( str , false);
966 // user defined functions
967 public bool OLDhighlightErrorsJson (string type, Json.Object obj) {
970 this.el.get_bounds (out start, out end);
972 this.el.remove_source_marks (start, end, type);
973 GLib.debug("highlight errors");
975 // we should highlight other types of errors..
977 if (!obj.has_member(type)) {
978 GLib.debug("Return has no errors\n");
982 if (_this.window.windowstate.state != WindowState.State.CODEONLY
984 _this.window.windowstate.state != WindowState.State.CODE
986 GLib.debug("windowstate != CODEONLY?");
991 //this.marks = new Gee.HashMap<int,string>();
992 var err = obj.get_object_member(type);
994 if (_this.file == null) {
995 GLib.debug("file is null?");
999 var valafn = _this.file.path;
1001 if (_this.file.xtype != "PlainFile") {
1005 var regex = new Regex("\\.bjs$");
1006 // should not happen
1007 valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
1008 } catch (GLib.RegexError e) {
1015 if (!err.has_member(valafn)) {
1016 GLib.debug("File path has no errors");
1020 var lines = err.get_object_member(valafn);
1023 if (obj.has_member("line_offset")) { // ?? why??
1024 offset = (int)obj.get_int_member("line_offset") + 1;
1028 var tlines = this.el.get_line_count () +1;
1030 if (_this.prop != null) {
1032 tlines = _this.prop.end_line + 1;
1033 offset = _this.prop.start_line + 1;
1039 lines.foreach_member((obj, line, node) => {
1042 // print("get inter\n");
1043 var eline = int.parse(line) - offset;
1044 GLib.debug("GOT ERROR on line %s -- converted to %d (offset = %d)\n", line,eline, offset);
1047 if (eline > tlines || eline < 0) {
1052 this.el.get_iter_at_line( out iter, eline);
1053 //print("mark line\n");
1055 var ar = lines.get_array_member(line);
1056 for (var i = 0 ; i < ar.get_length(); i++) {
1057 if (ar.get_string_element(i) == "Success") {
1060 msg += (msg.length > 0) ? "\n" : "";
1061 msg += ar.get_string_element(i);
1066 msg = "Line: %d".printf(eline+1) + " " + msg;
1067 this.el.create_source_mark(msg, type, iter);
1068 GLib.debug("set line %d to %m", eline, msg);
1069 // this.marks.set(eline, msg);
1078 public bool checkSyntax () {
1081 var str = this.toString();
1084 if (this.error_line > 0) {
1087 this.el.get_bounds (out start, out end);
1089 this.el.remove_source_marks (start, end, null);
1091 if (str.length < 1) {
1092 print("checkSyntax - empty string?\n");
1097 if (_this.file.xtype == "PlainFile") {
1099 // assume it's gtk...
1100 var oldcode =_this.file.toSource();
1101 _this.file.setSource(str);
1102 BuilderApplication.showSpinner("appointment soon","document change pending");
1103 _this.file.getLanguageServer().document_change(_this.file);
1104 _this.file.getLanguageServer().queueDocumentSymbols(_this.file);
1105 _this.file.setSource(oldcode);
1111 if (_this.file == null) {
1119 GLib.debug("calling validate");
1120 // clear the buttons.
1121 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
1124 var oldcode = _this.prop.val;
1126 _this.prop.val = str;
1127 _this.node.updated_count++;
1128 _this.file.getLanguageServer().document_change(_this.file);
1129 _this.node.updated_count++;
1130 _this.prop.val = oldcode;
1133 //print("done mark line\n");
1135 return true; // at present allow saving - even if it's invalid..
1137 public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
1139 this.error_line = validate_res.size;
1141 if (this.error_line < 1) {
1144 var tlines = this.el.get_line_count ();
1146 var valiter = validate_res.map_iterator();
1147 while (valiter.next()) {
1149 // print("get inter\n");
1150 var eline = valiter.get_key();
1151 if (eline > tlines) {
1154 this.el.get_iter_at_line( out iter, eline);
1155 //print("mark line\n");
1156 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
1160 public string toString () {
1164 this.el.get_start_iter(out s);
1165 this.el.get_end_iter(out e);
1166 var ret = this.el.get_text(s,e,true);
1167 //print("TO STRING? " + ret);
1172 public class Xcls_keystate : Object
1174 public Gtk.EventControllerKey el;
1175 private Editor _this;
1179 public bool is_control;
1182 public Xcls_keystate(Editor _owner )
1185 _this.keystate = this;
1186 this.el = new Gtk.EventControllerKey();
1189 this.is_control = false;
1191 // set gobject values
1194 this.el.key_released.connect( (keyval, keycode, state) => {
1196 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1197 this.is_control = false;
1199 if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1200 GLib.debug("SAVE: ctrl-S pressed");
1201 _this.saveContents();
1205 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1206 GLib.debug("SAVE: ctrl-g pressed");
1207 _this.forwardSearch(true);
1210 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1211 GLib.debug("SAVE: ctrl-f pressed");
1212 _this.search_entry.el.grab_focus();
1213 _this.search_entry.el.select_region(0,-1);
1216 if (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1217 _this.view.el.show_completion();
1221 _this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);
1222 var line = iter.get_line();
1223 var offset = iter.get_line_offset();
1224 GLib.debug("line %d off %d", line ,offset);
1225 if (_this.prop != null) {
1226 line += _this.prop.start_line + 1; // i think..
1227 offset += 12; // should probably be 8 without namespaced
1228 GLib.debug("guess line %d off %d", line ,offset);
1230 //_this.view.el.show_completion();
1231 // print(event.key.keyval)
1238 this.el.key_pressed.connect( (keyval, keycode, state) => {
1240 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1241 this.is_control = true;
1247 // user defined functions
1250 public class Xcls_EventControllerScroll13 : Object
1252 public Gtk.EventControllerScroll el;
1253 private Editor _this;
1257 public double distance;
1260 public Xcls_EventControllerScroll13(Editor _owner )
1263 this.el = new Gtk.EventControllerScroll( Gtk.EventControllerScrollFlags.VERTICAL );
1266 this.distance = 0.0f;
1268 // set gobject values
1271 this.el.scroll.connect( (dx, dy) => {
1272 if (!_this.keystate.is_control) {
1275 //GLib.debug("scroll %f", dy);
1277 this.distance += dy;
1279 //GLib.debug("scroll %f / %f", dy, this.distance);
1281 if (this.distance < -1) {
1283 BuilderApplication.settings.editor_font_size ++;
1286 if (this.distance > 1) {
1287 BuilderApplication.settings.editor_font_size --;
1295 // user defined functions
1298 public class Xcls_GestureClick14 : Object
1300 public Gtk.GestureClick el;
1301 private Editor _this;
1307 public Xcls_GestureClick14(Editor _owner )
1310 this.el = new Gtk.GestureClick();
1314 // set gobject values
1317 this.el.pressed.connect( (n_press, x, y) => {
1319 int buffer_x, buffer_y;
1320 _this.view.el.window_to_buffer_coords (
1321 Gtk.TextWindowTyp.TEXT,
1322 (int)x, (int)y, out buffer_x, out buffer_y
1325 _this.view.el.get_iter_at_location (out iter,
1326 buffer_x, buffer_y);
1327 if (_this.buffer.el.iter_has_context_class(iter, "comment") ||
1328 _this.buffer.el.iter_has_context_class(iter, "string")
1332 var back = iter.copy();
1333 back.backward_char();
1335 // what's the character at the iter?
1336 var str = back.get_text(iter);
1337 if (str.strip().length < 1) {
1341 var ls = _this.file.getLanguageServer();
1343 _this.file, iter.get_line(), iter.get_line_offset(),
1345 var res = ls.hover.end(o );
1354 // user defined functions
1359 public class Xcls_Box15 : Object
1362 private Editor _this;
1368 public Xcls_Box15(Editor _owner )
1371 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1375 // set gobject values
1376 this.el.homogeneous = false;
1377 this.el.vexpand = false;
1378 new Xcls_search_entry( _this );
1379 this.el.append( _this.search_entry.el );
1380 new Xcls_search_results( _this );
1381 this.el.append( _this.search_results.el );
1382 new Xcls_nextBtn( _this );
1383 this.el.append( _this.nextBtn.el );
1384 new Xcls_backBtn( _this );
1385 this.el.append( _this.backBtn.el );
1386 var child_5 = new Xcls_MenuButton21( _this );
1388 this.el.append( child_5.el );
1391 // user defined functions
1393 public class Xcls_search_entry : Object
1395 public Gtk.SearchEntry el;
1396 private Editor _this;
1400 public Gtk.CssProvider css;
1403 public Xcls_search_entry(Editor _owner )
1406 _this.search_entry = this;
1407 this.el = new Gtk.SearchEntry();
1411 // set gobject values
1412 this.el.name = "editor-search-entry";
1413 this.el.hexpand = true;
1414 this.el.placeholder_text = "Press enter to search";
1415 this.el.search_delay = 3;
1416 var child_1 = new Xcls_EventControllerKey17( _this );
1418 this.el.add_controller( child_1.el );
1421 this.el.search_changed.connect( ( ) => {
1423 _this.search(_this.search_entry.el.text);
1424 _this.search_results.updateResults();
1426 GLib.Timeout.add_seconds(1,() => {
1427 _this.search_results.updateResults();
1433 // user defined functions
1434 public void forwardSearch (bool change_focus) {
1437 _this.forwardSearch(change_focus);
1441 switch(_this.windowstate.state) {
1442 case WindowState.State.CODEONLY:
1443 //case WindowState.State.CODE:
1444 // search the code being edited..
1445 _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1448 case WindowState.State.PREVIEW:
1449 if (_this.windowstate.file.xtype == "Gtk") {
1450 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1452 _this.windowstate.window_rooview.forwardSearch(change_focus);
1461 public class Xcls_EventControllerKey17 : Object
1463 public Gtk.EventControllerKey el;
1464 private Editor _this;
1470 public Xcls_EventControllerKey17(Editor _owner )
1473 this.el = new Gtk.EventControllerKey();
1477 // set gobject values
1480 this.el.key_pressed.connect( (keyval, keycode, state) => {
1482 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1483 GLib.debug("SAVE: ctrl-g pressed");
1484 _this.forwardSearch(true);
1489 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1490 _this.forwardSearch(true);
1496 // print(event.key.keyval)
1502 // user defined functions
1506 public class Xcls_search_results : Object
1508 public Gtk.Label el;
1509 private Editor _this;
1515 public Xcls_search_results(Editor _owner )
1518 _this.search_results = this;
1519 this.el = new Gtk.Label( "No Results" );
1523 // set gobject values
1524 this.el.margin_end = 4;
1525 this.el.margin_start = 4;
1528 // user defined functions
1529 public void updateResults () {
1530 this.el.visible = true;
1532 var res = _this.searchcontext.get_occurrences_count();
1534 _this.search_results.el.label = "??? Matches";
1538 _this.nextBtn.el.sensitive = false;
1539 _this.backBtn.el.sensitive = false;
1542 _this.search_results.el.label = "%d Matches".printf(res);
1543 _this.nextBtn.el.sensitive = true;
1544 _this.backBtn.el.sensitive = true;
1547 _this.search_results.el.label = "No Matches";
1552 public class Xcls_nextBtn : Object
1554 public Gtk.Button el;
1555 private Editor _this;
1559 public bool always_show_image;
1562 public Xcls_nextBtn(Editor _owner )
1565 _this.nextBtn = this;
1566 this.el = new Gtk.Button();
1569 this.always_show_image = true;
1571 // set gobject values
1572 this.el.icon_name = "go-down";
1573 this.el.sensitive = false;
1576 this.el.clicked.connect( (event) => {
1578 _this.forwardSearch(true);
1584 // user defined functions
1587 public class Xcls_backBtn : Object
1589 public Gtk.Button el;
1590 private Editor _this;
1594 public bool always_show_image;
1597 public Xcls_backBtn(Editor _owner )
1600 _this.backBtn = this;
1601 this.el = new Gtk.Button();
1604 this.always_show_image = true;
1606 // set gobject values
1607 this.el.icon_name = "go-up";
1608 this.el.sensitive = false;
1611 this.el.clicked.connect( (event) => {
1613 _this.backSearch(true);
1618 // user defined functions
1621 public class Xcls_MenuButton21 : Object
1623 public Gtk.MenuButton el;
1624 private Editor _this;
1628 public bool always_show_image;
1631 public Xcls_MenuButton21(Editor _owner )
1634 this.el = new Gtk.MenuButton();
1637 this.always_show_image = true;
1639 // set gobject values
1640 this.el.icon_name = "emblem-system";
1641 this.el.always_show_arrow = true;
1642 new Xcls_search_settings( _this );
1643 this.el.popover = _this.search_settings.el;
1646 // user defined functions
1648 public class Xcls_search_settings : Object
1650 public Gtk.Popover el;
1651 private Editor _this;
1657 public Xcls_search_settings(Editor _owner )
1660 _this.search_settings = this;
1661 this.el = new Gtk.Popover();
1665 // set gobject values
1666 var child_1 = new Xcls_Box23( _this );
1668 this.el.child = child_1.el;
1671 // user defined functions
1673 public class Xcls_Box23 : Object
1676 private Editor _this;
1682 public Xcls_Box23(Editor _owner )
1685 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1689 // set gobject values
1690 new Xcls_case_sensitive( _this );
1691 this.el.append( _this.case_sensitive.el );
1692 new Xcls_regex( _this );
1693 this.el.append( _this.regex.el );
1694 new Xcls_multiline( _this );
1695 this.el.append( _this.multiline.el );
1698 // user defined functions
1700 public class Xcls_case_sensitive : Object
1702 public Gtk.CheckButton el;
1703 private Editor _this;
1709 public Xcls_case_sensitive(Editor _owner )
1712 _this.case_sensitive = this;
1713 this.el = new Gtk.CheckButton();
1717 // set gobject values
1718 this.el.label = "Case Sensitive";
1727 // user defined functions
1730 public class Xcls_regex : Object
1732 public Gtk.CheckButton el;
1733 private Editor _this;
1739 public Xcls_regex(Editor _owner )
1743 this.el = new Gtk.CheckButton();
1747 // set gobject values
1748 this.el.label = "Regex";
1757 // user defined functions
1760 public class Xcls_multiline : Object
1762 public Gtk.CheckButton el;
1763 private Editor _this;
1769 public Xcls_multiline(Editor _owner )
1772 _this.multiline = this;
1773 this.el = new Gtk.CheckButton();
1777 // set gobject values
1778 this.el.label = "Multi-line (add \\n)";
1781 // user defined functions
1789 public class Xcls_Box27 : Object
1792 private Editor _this;
1798 public Xcls_Box27(Editor _owner )
1801 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1805 // set gobject values
1806 this.el.hexpand = true;
1807 this.el.vexpand = true;
1808 var child_1 = new Xcls_Box28( _this );
1810 this.el.append( child_1.el );
1811 new Xcls_navigationwindow( _this );
1812 this.el.append( _this.navigationwindow.el );
1815 // user defined functions
1817 public class Xcls_Box28 : Object
1820 private Editor _this;
1826 public Xcls_Box28(Editor _owner )
1829 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1833 // set gobject values
1836 // user defined functions
1839 public class Xcls_navigationwindow : Object
1841 public Gtk.ScrolledWindow el;
1842 private Editor _this;
1848 public Xcls_navigationwindow(Editor _owner )
1851 _this.navigationwindow = this;
1852 this.el = new Gtk.ScrolledWindow();
1856 // set gobject values
1857 this.el.hexpand = true;
1858 this.el.vexpand = true;
1859 this.el.visible = false;
1860 new Xcls_navigation( _this );
1861 this.el.child = _this.navigation.el;
1864 // user defined functions
1866 public class Xcls_navigation : Object
1868 public Gtk.ColumnView el;
1869 private Editor _this;
1873 public int last_selected_line;
1874 public Gtk.Widget? selected_row;
1877 public Xcls_navigation(Editor _owner )
1880 _this.navigation = this;
1881 new Xcls_navigationselmodel( _this );
1882 this.el = new Gtk.ColumnView( _this.navigationselmodel.el );
1885 this.last_selected_line = -1;
1886 this.selected_row = null;
1888 // set gobject values
1889 this.el.name = "editor-navigation";
1890 var child_2 = new Xcls_ColumnViewColumn31( _this );
1892 this.el.append_column( child_2.el );
1893 var child_3 = new Xcls_GestureClick40( _this );
1895 this.el.add_controller( child_3.el );
1898 // user defined functions
1899 public Gtk.Widget? getRowWidgetAt (double x, double y, out string pos) {
1902 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
1903 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
1908 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
1913 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
1917 //GLib.debug("row number is %d", rn);
1918 //GLib.debug("click %d, %d", (int)x, (int)y);
1920 Graphene.Rect bounds;
1921 row.compute_bounds(this.el, out bounds);
1922 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
1923 // (int)bounds.get_x(), (int)bounds.get_y(),
1924 // (int)bounds.get_width(), (int)bounds.get_height()
1926 var ypos = y - bounds.get_y();
1927 //GLib.debug("rel ypos = %d", (int)ypos);
1928 var rpos = 100.0 * (ypos / bounds.get_height());
1929 //GLib.debug("rel pos = %d %%", (int)rpos);
1934 } else if (rpos < 20) {
1939 public void show (Gee.ArrayList<Lsp.DocumentSymbol> syms) {
1940 _this.navigationwindow.el.show();
1941 //_this.navliststore.el.remove_all();
1944 var ls = new GLib.ListStore(typeof(Lsp.DocumentSymbol));
1946 foreach(var sym in syms) {
1949 Lsp.DocumentSymbol.copyList(ls, _this.navliststore.el);
1950 //_this.navliststore.el.append(sym);
1951 this.last_selected_line = -1;
1952 GLib.Idle.add(() => {
1953 _this.navigationsort.collapseOnLoad();
1955 _this.buffer.el.get_iter_at_offset (
1956 out iter, _this.buffer.el.cursor_position);
1958 GLib.debug("idle update scroll %d, %d", iter.get_line(),
1959 iter.get_line_offset());
1960 this.updateSelectedLine(
1961 (uint)iter.get_line(),
1962 (uint)iter.get_line_offset()
1968 public int getRowAt (double x, double y, out string pos) {
1971 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
1972 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
1977 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
1982 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
1987 while (cr.get_prev_sibling() != null) {
1989 cr = cr.get_prev_sibling();
1992 //GLib.debug("row number is %d", rn);
1993 //GLib.debug("click %d, %d", (int)x, (int)y);
1995 Graphene.Rect bounds;
1996 row.compute_bounds(this.el, out bounds);
1997 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
1998 // (int)bounds.get_x(), (int)bounds.get_y(),
1999 // (int)bounds.get_width(), (int)bounds.get_height()
2001 var ypos = y - bounds.get_y();
2002 //GLib.debug("rel ypos = %d", (int)ypos);
2003 var rpos = 100.0 * (ypos / bounds.get_height());
2004 //GLib.debug("rel pos = %d %%", (int)rpos);
2009 } else if (rpos < 20) {
2014 public void updateSelectedLine (uint line, uint chr) {
2015 if (line == this.last_selected_line) {
2018 GLib.debug("select line %d", (int)line);
2019 this.last_selected_line = (int)line;
2023 var sym = _this.navliststore.symbolAtLine(line, chr);
2025 new_row = _this.navigationsort.getRowFromSymbol(sym);
2026 GLib.debug("select line %d - row found %d", (int)line, new_row);
2028 GLib.debug(" no symbol found at line %d", (int)line);
2031 if (this.selected_row != null) {
2032 GLib.debug(" remove selected row");
2033 this.selected_row.remove_css_class("selected-row");
2035 this.selected_row = null;
2037 this.el.scroll_to(new_row,null,Gtk.ListScrollFlags.NONE, null);
2038 var row = sym.get_data<Gtk.Widget>("widget");
2040 GLib.debug(" Add selected row");
2042 row.add_css_class("selected-row");
2043 this.selected_row = row;
2047 GLib.debug("could not find widget on row %d", new_row);
2055 public class Xcls_ColumnViewColumn31 : Object
2057 public Gtk.ColumnViewColumn el;
2058 private Editor _this;
2064 public Xcls_ColumnViewColumn31(Editor _owner )
2067 var child_1 = new Xcls_SignalListItemFactory32( _this );
2069 this.el = new Gtk.ColumnViewColumn( "Code Navigation", child_1.el );
2073 // set gobject values
2074 this.el.expand = true;
2077 // user defined functions
2079 public class Xcls_SignalListItemFactory32 : Object
2081 public Gtk.SignalListItemFactory el;
2082 private Editor _this;
2088 public Xcls_SignalListItemFactory32(Editor _owner )
2091 this.el = new Gtk.SignalListItemFactory();
2095 // set gobject values
2098 this.el.setup.connect( (listitem) => {
2100 var expand = new Gtk.TreeExpander();
2102 expand.set_indent_for_depth(true);
2103 expand.set_indent_for_icon(true);
2104 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2105 var icon = new Gtk.Image();
2106 var lbl = new Gtk.Label("");
2107 lbl.use_markup = true;
2108 lbl.ellipsize = Pango.EllipsizeMode.END;
2110 icon.margin_end = 4;
2111 lbl.justify = Gtk.Justification.LEFT;
2114 // listitem.activatable = true; ??
2118 expand.set_child(hbox);
2119 ((Gtk.ListItem)listitem).set_child(expand);
2122 this.el.bind.connect( (listitem) => {
2124 // GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name());
2126 //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2127 var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2130 var hbox = (Gtk.Box) expand.child;
2133 var img = (Gtk.Image) hbox.get_first_child();
2134 var lbl = (Gtk.Label) img.get_next_sibling();
2136 var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();
2137 var sym = (Lsp.DocumentSymbol) lr.get_item();
2139 sym.set_data<Gtk.Widget>("widget", expand.get_parent());
2140 expand.get_parent().get_parent().set_data<Lsp.DocumentSymbol>("symbol", sym);
2142 //GLib.debug("save sym on %s", expand.get_parent().get_parent().get_type().name());
2144 //GLib.debug("got %d children for %s" , (int)sym.children.get_n_items(), sym.name);
2146 expand.set_hide_expander( sym.children.get_n_items() < 1);
2147 expand.set_list_row(lr);
2148 //this.in_bind = true;
2149 // default is to expand
2151 //this.in_bind = false;
2153 sym.bind_property("symbol_icon",
2155 GLib.BindingFlags.SYNC_CREATE);
2157 hbox.css_classes = { sym.symbol_icon };
2159 sym.bind_property("name",
2161 GLib.BindingFlags.SYNC_CREATE);
2162 // should be better?- --line no?
2163 sym.bind_property("tooltip",
2164 lbl, "tooltip_markup",
2165 GLib.BindingFlags.SYNC_CREATE);
2171 // user defined functions
2175 public class Xcls_navigationselmodel : Object
2177 public Gtk.NoSelection el;
2178 private Editor _this;
2184 public Xcls_navigationselmodel(Editor _owner )
2187 _this.navigationselmodel = this;
2188 new Xcls_navigationsort( _this );
2189 this.el = new Gtk.NoSelection( _this.navigationsort.el );
2193 // set gobject values
2196 // user defined functions
2198 public class Xcls_navigationsort : Object
2200 public Gtk.SortListModel el;
2201 private Editor _this;
2207 public Xcls_navigationsort(Editor _owner )
2210 _this.navigationsort = this;
2211 var child_1 = new Xcls_TreeListModel35( _this );
2213 var child_2 = new Xcls_TreeListRowSorter37( _this );
2215 this.el = new Gtk.SortListModel( child_1.el, child_2.el );
2219 // set gobject values
2222 // user defined functions
2223 public void collapseOnLoad () {
2224 for (var i=0;i < this.el.get_n_items(); i++) {
2225 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2226 var sym = (Lsp.DocumentSymbol)tr.get_item();
2228 case Lsp.SymbolKind.Enum:
2229 tr.expanded = false;
2232 //tr.expanded = true;
2241 public int getRowFromSymbol (Lsp.DocumentSymbol sym) {
2243 for (var i=0;i < this.el.get_n_items(); i++) {
2244 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2246 if (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {
2252 public Lsp.DocumentSymbol? getSymbolAt (uint row) {
2254 var tr = (Gtk.TreeListRow)this.el.get_item(row);
2256 var a = tr.get_item();;
2257 GLib.debug("get_item (2) = %s", a.get_type().name());
2260 return (Lsp.DocumentSymbol)tr.get_item();
2264 public class Xcls_TreeListModel35 : Object
2266 public Gtk.TreeListModel el;
2267 private Editor _this;
2273 public Xcls_TreeListModel35(Editor _owner )
2276 new Xcls_navliststore( _this );
2277 this.el = new Gtk.TreeListModel( _this.navliststore.el, false, true, (item) => {
2279 return ((Lsp.DocumentSymbol)item).children;
2285 // set gobject values
2288 this.el.items_changed.connect( (position, removed, added) => {
2289 GLib.debug("tree item changed %d , %d , %d",(int) position, (int)removed, (int) added);
2293 //var sym = (Lsp.DocumentSymbol) this.el.get_item(position);
2294 var row = this.el.get_row(position);
2296 GLib.debug("got %s", row.get_item().get_type().name());
2302 // user defined functions
2304 public class Xcls_navliststore : Object
2306 public GLib.ListStore el;
2307 private Editor _this;
2313 public Xcls_navliststore(Editor _owner )
2316 _this.navliststore = this;
2317 this.el = new GLib.ListStore( typeof(Lsp.DocumentSymbol) );
2321 // set gobject values
2324 // user defined functions
2325 public Lsp.DocumentSymbol? symbolAtLine (uint line, uint chr) {
2328 for(var i = 0; i < this.el.get_n_items();i++) {
2329 var el = (Lsp.DocumentSymbol)this.el.get_item(i);
2330 //GLib.debug("Check sym %s : %d-%d",
2331 // el.name , (int)el.range.start.line,
2332 // (int)el.range.end.line
2334 var ret = el.containsLine(line,chr);
2346 public class Xcls_TreeListRowSorter37 : Object
2348 public Gtk.TreeListRowSorter el;
2349 private Editor _this;
2355 public Xcls_TreeListRowSorter37(Editor _owner )
2358 var child_1 = new Xcls_StringSorter38( _this );
2360 this.el = new Gtk.TreeListRowSorter( child_1.el );
2364 // set gobject values
2367 // user defined functions
2369 public class Xcls_StringSorter38 : Object
2371 public Gtk.StringSorter el;
2372 private Editor _this;
2378 public Xcls_StringSorter38(Editor _owner )
2381 var child_1 = new Xcls_PropertyExpression39( _this );
2383 this.el = new Gtk.StringSorter( child_1.el );
2387 // set gobject values
2390 // user defined functions
2392 public class Xcls_PropertyExpression39 : Object
2394 public Gtk.PropertyExpression el;
2395 private Editor _this;
2401 public Xcls_PropertyExpression39(Editor _owner )
2404 this.el = new Gtk.PropertyExpression( typeof(Lsp.DocumentSymbol), null, "sort_key" );
2408 // set gobject values
2411 // user defined functions
2418 public class Xcls_GestureClick40 : Object
2420 public Gtk.GestureClick el;
2421 private Editor _this;
2427 public Xcls_GestureClick40(Editor _owner )
2430 this.el = new Gtk.GestureClick();
2434 // set gobject values
2437 this.el.pressed.connect( (n_press, x, y) => {
2439 var row = _this.navigation.getRowWidgetAt(x,y, out pos );
2442 GLib.debug("no row selected items");
2445 GLib.debug("got click on %s", row.get_type().name());
2446 //Lsp.DocumentSymbol
2447 var sym = row.get_data<Lsp.DocumentSymbol>("symbol");
2463 GLib.debug("goto line %d", (int)sym.range.start.line);
2464 _this.scroll_to_line((int)sym.range.start.line);
2466 _this.buffer.el.get_iter_at_line_offset(out iter,
2467 (int)sym.range.start.line,
2468 (int)sym.range.start.character
2470 _this.buffer.el.place_cursor(iter);
2475 // user defined functions