3 public class Editor : Object
8 public static Editor singleton()
10 if (_Editor == null) {
11 _Editor= new Editor();
15 public Xcls_paned paned;
16 public Xcls_save_button save_button;
17 public Xcls_helper helper;
18 public Xcls_close_btn close_btn;
19 public Xcls_RightEditor RightEditor;
20 public Xcls_view view;
21 public Xcls_buffer buffer;
22 public Xcls_keystate keystate;
23 public Xcls_search_entry search_entry;
24 public Xcls_search_results search_results;
25 public Xcls_nextBtn nextBtn;
26 public Xcls_backBtn backBtn;
27 public Xcls_search_settings search_settings;
28 public Xcls_case_sensitive case_sensitive;
29 public Xcls_regex regex;
30 public Xcls_multiline multiline;
31 public Xcls_navigation_holder navigation_holder;
32 public Xcls_navigationwindow navigationwindow;
33 public Xcls_navigation navigation;
34 public Xcls_navigationselmodel navigationselmodel;
35 public Xcls_navigationsort navigationsort;
36 public Xcls_navliststore navliststore;
39 public int pos_root_x;
40 public Xcls_MainWindow window;
42 public int pos_root_y;
44 public int last_error_counter;
45 public GtkSource.SearchContext searchcontext;
46 public int last_search_end;
47 public signal void save ();
48 public JsRender.JsRender? file;
49 public JsRender.Node node;
50 public JsRender.NodeProp? prop;
51 public string activeEditor;
57 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
63 this.last_error_counter = 0;
64 this.searchcontext = null;
65 this.last_search_end = 0;
69 this.activeEditor = "\"\"";
72 this.el.homogeneous = false;
73 this.el.hexpand = true;
74 this.el.vexpand = true;
75 new Xcls_paned( _this );
76 this.el.append( _this.paned.el );
79 // user defined functions
80 public bool saveContents () {
83 if (_this.file == null) {
89 var str = _this.buffer.toString();
91 _this.buffer.checkSyntax();
95 // LeftPanel.model.changed( str , false);
97 _this.save_button.el.sensitive = false;
99 // find the text for the node..
100 if (_this.file.xtype != "PlainFile") {
101 // in theory these properties have to exist!?!
103 //this.window.windowstate.left_props.reload();
105 _this.file.setSource( str );
114 public void forwardSearch (bool change_focus) {
116 if (this.searchcontext == null) {
120 Gtk.TextIter beg, st,en;
121 bool has_wrapped_around;
122 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end);
123 if (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {
125 this.last_search_end = 0; // not sure if this should happen
127 if (has_wrapped_around) {
131 this.last_search_end = en.get_offset();
133 this.view.el.grab_focus();
135 this.buffer.el.place_cursor(st);
136 this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);
140 public void show (JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)
143 if (this.file != null) {
144 this.file.navigation_tree_updated.disconnect(
145 _this.navigation.show
149 this.file.navigation_tree_updated.connect(
150 _this.navigation.show
152 if (file.xtype != "PlainFile") {
156 // find the text for the node..
157 this.view.load( prop.val );
158 this.updateErrorMarks();
162 this.close_btn.el.show();
165 this.view.load( file.toSource() );
166 this.updateErrorMarks();
167 this.close_btn.el.hide();
168 var ls = file.getLanguageServer();
169 ls.queueDocumentSymbols(file);
170 ////ls.documentSymbols.begin(file, (a,o) => {
171 // _this.navigation.show(ls.documentSymbols.end(o));
178 public void backSearch (bool change_focus) {
180 if (this.searchcontext == null) {
184 Gtk.TextIter beg, st,en;
185 bool has_wrapped_around;
186 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );
188 if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {
189 this.last_search_end = 0;
191 this.last_search_end = en.get_offset();
193 this.view.el.grab_focus();
195 this.buffer.el.place_cursor(st);
196 this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);
200 public string tempFileContents () {
203 if (_this.file == null) {
206 var str= this.buffer.toString();
207 if (_this.file.xtype == "PlainFile") {
215 GLib.debug("calling validate");
216 // clear the buttons.
217 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
218 return this.file.toSource(); ;
221 var oldcode = _this.prop.val;
222 _this.prop.val = str;
223 var ret = _this.file.toSource();
224 _this.prop.val = oldcode;
228 public void reset () {
233 this.searchcontext = null;
236 public int search (string in_txt) {
238 var s = new GtkSource.SearchSettings();
239 s.case_sensitive = _this.case_sensitive.el.active;
240 s.regex_enabled = _this.regex.el.active;
241 s.wrap_around = false;
243 this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);
244 this.searchcontext.set_highlight(true);
247 if (_this.multiline.el.active) {
248 txt = in_txt.replace("\\n", "\n");
251 s.set_search_text(txt);
252 Gtk.TextIter beg, st,en;
254 this.buffer.el.get_start_iter(out beg);
255 bool has_wrapped_around;
256 this.searchcontext.forward(beg, out st, out en, out has_wrapped_around);
257 this.last_search_end = 0;
259 return this.searchcontext.get_occurrences_count();
265 public void updateErrorMarks () {
269 var buf = _this.buffer.el;
272 buf.get_bounds (out start, out end);
277 //GLib.debug("highlight errors");
279 // we should highlight other types of errors..
281 if (_this.window.windowstate.state != WindowState.State.CODEONLY
283 _this.window.windowstate.state != WindowState.State.CODE
285 //GLib.debug("windowstate != CODEONLY?");
291 if (_this.file == null) {
292 GLib.debug("file is null?");
296 var ar = this.file.getErrors();
298 buf.remove_source_marks (start, end, "ERR");
299 buf.remove_source_marks (start, end, "WARN");
300 buf.remove_source_marks (start, end, "DEPR");
301 buf.remove_tag_by_name ("ERR", start, end);
302 buf.remove_tag_by_name ("WARN", start, end);
303 buf.remove_tag_by_name ("DEPR", start, end);
304 this.last_error_counter = file.error_counter ;
305 //GLib.debug("highlight %s : %s has no errors", this.file.relpath, category);
310 // basicaly check if there is no change, then we do not do any update..
311 // we can do this by just using an error counter?
312 // if that's changed then we will do an update, otherwise dont bother.
318 var tlines = buf.get_line_count () +1;
320 if (_this.prop != null) {
321 // this still seems flaky...
323 tlines = _this.prop.end_line;
324 offset = _this.prop.start_line;
325 hoffset = _this.node.node_pad.length + 2; //shift it left by 2 ? ..
330 if (this.last_error_counter == file.error_counter) {
336 buf.remove_source_marks (start, end, "ERR");
337 buf.remove_source_marks (start, end, "WARN");
338 buf.remove_source_marks (start, end, "DEPR");
339 buf.remove_tag_by_name ("ERR", start, end);
340 buf.remove_tag_by_name ("WARN", start, end);
341 buf.remove_tag_by_name ("DEPR", start, end);
343 foreach(var diag in ar) {
345 // print("get inter\n");
346 var eline = (int)diag.range.start.line - offset;
347 var eline_to = (int)diag.range.end.line - offset;
348 //var eline = diag.range.end_line - offset;
349 //GLib.debug("GOT ERROR on line %d -- converted to %d (offset = %d)",
350 // err.line ,eline, offset);
353 if (eline > tlines || eline < 0) {
357 buf.get_iter_at_line( out iter, eline);
358 var msg = "Line: %d %s : %s".printf(eline+1, diag.category, diag.message);
359 buf.create_source_mark( msg, diag.category, iter);
361 var spos = (int)diag.range.start.character - hoffset;
362 if (spos < 0) { spos =0 ; }
363 if (spos > iter.get_chars_in_line()) {
364 spos = iter.get_chars_in_line();
366 buf.get_iter_at_line( out iter, eline_to);
367 var epos = (int)diag.range.end.character - hoffset;
368 if (epos < 0) { epos =0 ; }
369 if (epos > iter.get_chars_in_line()) {
370 epos = iter.get_chars_in_line();
374 buf.get_iter_at_line_offset( out start, eline, spos);
376 buf.get_iter_at_line_offset( out end, eline_to,epos);
378 buf.apply_tag_by_name(diag.category, start, end);
380 // GLib.debug("set line %d to %s", eline, msg);
381 //this.marks.set(eline, msg);
383 this.last_error_counter = file.error_counter ;
390 public void scroll_to_line (int line) {
392 GLib.Timeout.add(500, () => {
394 var buf = this.view.el.get_buffer();
396 var sbuf = (GtkSource.Buffer) buf;
400 sbuf.get_iter_at_line(out iter, line);
401 this.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
405 public class Xcls_paned : Object
408 private Editor _this;
414 public Xcls_paned(Editor _owner )
418 this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL );
422 // set gobject values
423 this.el.resize_start_child = false;
424 this.el.shrink_end_child = false;
425 this.el.resize_end_child = false;
426 this.el.shrink_start_child = false;
427 var child_1 = new Xcls_Box2( _this );
429 this.el.start_child = child_1.el;
430 new Xcls_navigation_holder( _this );
431 this.el.end_child = _this.navigation_holder.el;
434 // user defined functions
436 public class Xcls_Box2 : Object
439 private Editor _this;
445 public Xcls_Box2(Editor _owner )
448 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
452 // set gobject values
453 this.el.hexpand = true;
454 var child_1 = new Xcls_Box3( _this );
456 this.el.append( child_1.el );
457 new Xcls_RightEditor( _this );
458 this.el.append( _this.RightEditor.el );
459 var child_3 = new Xcls_Box15( _this );
461 this.el.append ( child_3.el );
464 // user defined functions
466 public class Xcls_Box3 : Object
469 private Editor _this;
475 public Xcls_Box3(Editor _owner )
478 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
482 // set gobject values
483 this.el.homogeneous = false;
484 this.el.hexpand = false;
485 this.el.vexpand = false;
486 new Xcls_save_button( _this );
487 this.el.append( _this.save_button.el );
488 new Xcls_helper( _this );
489 this.el.append( _this.helper.el );
490 var child_3 = new Xcls_Scale6( _this );
492 this.el.append( child_3.el );
493 new Xcls_close_btn( _this );
494 this.el.append( _this.close_btn.el );
497 // user defined functions
499 public class Xcls_save_button : Object
501 public Gtk.Button el;
502 private Editor _this;
508 public Xcls_save_button(Editor _owner )
511 _this.save_button = this;
512 this.el = new Gtk.Button();
516 // set gobject values
517 this.el.vexpand = true;
518 this.el.label = "Save";
521 this.el.clicked.connect( () => {
522 _this.saveContents();
526 // user defined functions
529 public class Xcls_helper : Object
532 private Editor _this;
538 public Xcls_helper(Editor _owner )
542 this.el = new Gtk.Label( null );
546 // set gobject values
547 this.el.margin_end = 4;
548 this.el.margin_start = 4;
549 this.el.justify = Gtk.Justification.LEFT;
550 this.el.hexpand = true;
554 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
560 // user defined functions
561 public void setHelp (Lsp.Hover? help) {
562 if (help == null || help.contents == null
563 || help.contents.size < 1) {
564 this.el.set_text("");
567 var sig = help.contents.get(0).value.split(" ");
569 for(var i =0; i < sig.length; i++) {
588 str += ("<span underline=\"single\" color=\"blue\" >" +
589 GLib.Markup.escape_text(sig[i])
594 if (help.contents.size > 1) {
595 this.el.tooltip_markup = GLib.Markup.escape_text(help.contents.get(1).value);
598 this.el.set_markup(string.joinv(" ",str));
603 public class Xcls_Scale6 : Object
606 private Editor _this;
612 public Xcls_Scale6(Editor _owner )
615 this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1);
619 // set gobject values
620 this.el.width_request = 150;
621 this.el.has_origin = true;
622 this.el.halign = Gtk.Align.END;
623 this.el.draw_value = false;
625 this.el.sensitive = true;
630 //this.el.set_range(6,30);
631 this.el.set_value ( BuilderApplication.settings.editor_font_size);
632 BuilderApplication.settings.editor_font_size_updated.connect(
634 BuilderApplication.settings.editor_font_size_inchange = true;
635 // GLib.debug("update range");
636 this.el.set_value (BuilderApplication.settings.editor_font_size);
637 BuilderApplication.settings.editor_font_size_inchange = false;
645 this.el.change_value.connect( (st, val ) => {
646 if (BuilderApplication.settings.editor_font_size_inchange) {
649 BuilderApplication.settings.editor_font_size = val;
654 // user defined functions
657 public class Xcls_close_btn : Object
659 public Gtk.Button el;
660 private Editor _this;
666 public Xcls_close_btn(Editor _owner )
669 _this.close_btn = this;
670 this.el = new Gtk.Button();
674 // set gobject values
675 this.el.icon_name = "window-close";
676 this.el.halign = Gtk.Align.END;
677 var child_1 = new Xcls_Image8( _this );
679 this.el.child = child_1.el;
682 this.el.clicked.connect( () => {
683 _this.saveContents();
684 _this.window.windowstate.switchState(WindowState.State.PREVIEW);
688 // user defined functions
690 public class Xcls_Image8 : Object
693 private Editor _this;
699 public Xcls_Image8(Editor _owner )
702 this.el = new Gtk.Image();
706 // set gobject values
707 this.el.icon_name = "window-close";
708 this.el.icon_size = Gtk.IconSize.NORMAL;
711 // user defined functions
716 public class Xcls_RightEditor : Object
718 public Gtk.ScrolledWindow el;
719 private Editor _this;
725 public Xcls_RightEditor(Editor _owner )
728 _this.RightEditor = this;
729 this.el = new Gtk.ScrolledWindow();
733 // set gobject values
734 this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
735 this.el.vexpand = true;
736 this.el.overlay_scrolling = false;
737 this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
738 new Xcls_view( _this );
739 this.el.child = _this.view.el;
742 // user defined functions
744 public class Xcls_view : Object
746 public GtkSource.View el;
747 private Editor _this;
751 public Gtk.CssProvider css;
754 public Xcls_view(Editor _owner )
758 this.el = new GtkSource.View();
763 // set gobject values
764 this.el.auto_indent = true;
765 this.el.indent_width = 4;
766 this.el.name = "editor-view";
767 this.el.show_line_marks = true;
768 this.el.insert_spaces_instead_of_tabs = true;
769 this.el.show_line_numbers = true;
770 this.el.hexpand = true;
771 this.el.vexpand = true;
772 this.el.has_tooltip = true;
773 this.el.css_classes = { "code-editor" };
774 this.el.tab_width = 4;
775 this.el.highlight_current_line = true;
776 new Xcls_buffer( _this );
777 this.el.buffer = _this.buffer.el;
778 new Xcls_keystate( _this );
779 this.el.add_controller( _this.keystate.el );
780 var child_3 = new Xcls_EventControllerScroll13( _this );
782 this.el.add_controller( child_3.el );
783 var child_4 = new Xcls_GestureClick14( _this );
785 this.el.add_controller( child_4.el );
789 this.el.completion.add_provider(
790 new Palete.CompletionProvider(_this)
793 // hover seems pretty useless.. - ??
794 //var hover = this.el.get_hover();
795 //hover.add_provider(new Palete.HoverProvider(_this));
797 //this.el.completion.unblock_interactive();
798 this.el.completion.select_on_show = true; // select
799 //this.el.completion.remember_info_visibility = true;
802 var attrs = new GtkSource.MarkAttributes();
804 attrs.set_icon_name ( "process-stop");
805 attrs.query_tooltip_text.connect(( mark) => {
806 GLib.debug("tooltip query? %s", mark.name);
807 return strdup( mark.name);
809 attrs.query_tooltip_markup.connect(( mark) => {
810 GLib.debug("tooltip query? %s", mark.name);
811 return strdup( mark.name);
813 this.el.set_mark_attributes ("ERR", attrs, 1);
817 var wattrs = new GtkSource.MarkAttributes();
818 wattrs.set_icon_name ( "process-stop");
819 wattrs.query_tooltip_text.connect(( mark) => {
820 GLib.debug("tooltip query? %s", mark.name);
821 return strdup(mark.name);
823 wattrs.query_tooltip_markup.connect(( mark) => {
824 GLib.debug("tooltip query? %s", mark.name);
825 return strdup(mark.name);
827 this.el.set_mark_attributes ("WARN", wattrs, 1);
831 var dattrs = new GtkSource.MarkAttributes();
833 dattrs.set_icon_name ( "process-stop");
835 dattrs.query_tooltip_text.connect(( mark) => {
836 GLib.debug("tooltip query? %s", mark.name);
837 return strdup(mark.name);
839 //dattrs.query_tooltip_markup.connect(( mark) => {
840 // GLib.debug("tooltip query? %s", mark.name);
841 // return strdup(mark.name);
843 this.el.set_mark_attributes ("DEPR", dattrs, 1);
846 this.el.get_space_drawer().set_matrix(null);
847 this.el.get_space_drawer().set_types_for_locations(
848 GtkSource.SpaceLocationFlags.ALL,
849 GtkSource.SpaceTypeFlags.ALL
851 this.el.get_space_drawer().set_enable_matrix(true);
854 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
856 //GLib.debug("query tooltip");
860 var yoff = (int) _this.RightEditor.el.vadjustment.value;
862 // I think this is problematic - if it's compliing / updating at same time as query.
864 //if (_this.window.statusbar_compile_spinner.el.spinning) {
868 this.el.get_iter_at_position (out iter, out trailing, x, y + yoff);
870 var l = iter.get_line();
874 // GLib.debug("query tooltip line %d", (int) l);
880 if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {
881 GLib.debug("line %d setting tip to %s", l, _this.buffer.marks.get(l));
882 tooltip.set_text(_this.buffer.marks.get(l).dup());
890 // this crashes?? - not sure why.
891 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
892 if (marks.is_empty()) {
893 marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
895 if (marks.is_empty()) {
896 marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
899 // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length());
901 marks.@foreach((m) => {
902 //GLib.debug("got mark %s", m.name);
903 str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name;
905 // true if there is a mark..
906 if (str.length > 0 ) {
907 tooltip.set_text( str );
909 return str.length > 0 ? true : false;
914 // user defined functions
915 public void load (string str) {
917 // show the help page for the active node..
918 //this.get('/Help').show();
920 // this.get('/BottomPane').el.set_current_page(0);
921 GLib.debug("load called - Reset undo buffer");
923 var buf = (GtkSource.Buffer)this.el.get_buffer();
924 buf.begin_irreversible_action();
925 buf.set_text(str, str.length);
926 buf.end_irreversible_action();
928 var lm = GtkSource.LanguageManager.get_default();
930 if (_this.file != null) {
931 lang = _this.file.language;
933 print("lang=%s, content_type = %s\n", lang, _this.file.content_type);
934 var lg = _this.file.content_type.length > 0 ?
935 lm.guess_language(_this.file.path, _this.file.content_type) :
936 lm.get_language(lang);
939 ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg);
941 this.el.insert_spaces_instead_of_tabs = true;
943 print("sourcelanguage = %s\n", lg.name);
944 if (lg.name == "Vala") {
945 this.el.insert_spaces_instead_of_tabs = false;
949 this.el.grab_focus();
950 _this.save_button.el.sensitive = false;
951 _this.last_error_counter = -1;
954 public class Xcls_buffer : Object
956 public GtkSource.Buffer el;
957 private Editor _this;
961 public int error_line;
962 public Gee.HashMap<int,string>? xmarks;
963 public bool check_queued;
966 public Xcls_buffer(Editor _owner )
970 this.el = new GtkSource.Buffer( null );
973 this.error_line = -1;
975 this.check_queued = false;
977 // set gobject values
978 this.el.highlight_syntax = true;
979 this.el.highlight_matching_brackets = true;
980 this.el.enable_undo = true;
985 buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
986 buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
987 buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
988 buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
989 buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
990 buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
991 buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
992 buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
995 buf.create_tag ("ERR", "weight", Pango.Weight.BOLD, "background", "pink");
996 buf.create_tag ("WARN", "weight", Pango.Weight.BOLD, "background", "#ABF4EB");
997 buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
1000 this.el.cursor_moved.connect( ( ) => {
1003 this.el.get_iter_at_offset (
1004 out iter, this.el.cursor_position);
1006 _this.navigation.updateSelectedLine(
1007 (uint)iter.get_line(),
1008 (uint)iter.get_line_offset()
1010 this.showHelp(iter);
1013 this.el.changed.connect( () => {
1016 _this.save_button.el.sensitive = true;
1017 print("EDITOR CHANGED");
1022 // this.get('/LeftPanel.model').changed( str , false);
1027 // user defined functions
1028 public bool OLDhighlightErrorsJson (string type, Json.Object obj) {
1031 this.el.get_bounds (out start, out end);
1033 this.el.remove_source_marks (start, end, type);
1034 GLib.debug("highlight errors");
1036 // we should highlight other types of errors..
1038 if (!obj.has_member(type)) {
1039 GLib.debug("Return has no errors\n");
1043 if (_this.window.windowstate.state != WindowState.State.CODEONLY
1045 _this.window.windowstate.state != WindowState.State.CODE
1047 GLib.debug("windowstate != CODEONLY?");
1052 //this.marks = new Gee.HashMap<int,string>();
1053 var err = obj.get_object_member(type);
1055 if (_this.file == null) {
1056 GLib.debug("file is null?");
1060 var valafn = _this.file.path;
1062 if (_this.file.xtype != "PlainFile") {
1066 var regex = new Regex("\\.bjs$");
1067 // should not happen
1068 valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
1069 } catch (GLib.RegexError e) {
1076 if (!err.has_member(valafn)) {
1077 GLib.debug("File path has no errors");
1081 var lines = err.get_object_member(valafn);
1084 if (obj.has_member("line_offset")) { // ?? why??
1085 offset = (int)obj.get_int_member("line_offset") + 1;
1089 var tlines = this.el.get_line_count () +1;
1091 if (_this.prop != null) {
1093 tlines = _this.prop.end_line + 1;
1094 offset = _this.prop.start_line + 1;
1100 lines.foreach_member((obj, line, node) => {
1103 // print("get inter\n");
1104 var eline = int.parse(line) - offset;
1105 GLib.debug("GOT ERROR on line %s -- converted to %d (offset = %d)\n", line,eline, offset);
1108 if (eline > tlines || eline < 0) {
1113 this.el.get_iter_at_line( out iter, eline);
1114 //print("mark line\n");
1116 var ar = lines.get_array_member(line);
1117 for (var i = 0 ; i < ar.get_length(); i++) {
1118 if (ar.get_string_element(i) == "Success") {
1121 msg += (msg.length > 0) ? "\n" : "";
1122 msg += ar.get_string_element(i);
1127 msg = "Line: %d".printf(eline+1) + " " + msg;
1128 this.el.create_source_mark(msg, type, iter);
1129 GLib.debug("set line %d to %m", eline, msg);
1130 // this.marks.set(eline, msg);
1139 public bool checkSyntax () {
1142 var str = this.toString();
1145 if (this.error_line > 0) {
1148 this.el.get_bounds (out start, out end);
1150 this.el.remove_source_marks (start, end, null);
1152 if (str.length < 1) {
1153 print("checkSyntax - empty string?\n");
1158 if (_this.file.xtype == "PlainFile") {
1160 // assume it's gtk...
1161 var oldcode =_this.file.toSource();
1162 _this.file.setSource(str);
1163 BuilderApplication.showSpinner("appointment soon","document change pending");
1164 _this.file.getLanguageServer().document_change(_this.file);
1165 _this.file.getLanguageServer().queueDocumentSymbols(_this.file);
1166 _this.file.setSource(oldcode);
1172 if (_this.file == null) {
1180 GLib.debug("calling validate");
1181 // clear the buttons.
1182 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
1185 var oldcode = _this.prop.val;
1187 _this.prop.val = str;
1188 _this.node.updated_count++;
1189 _this.file.getLanguageServer().document_change(_this.file);
1190 _this.node.updated_count++;
1191 _this.prop.val = oldcode;
1194 //print("done mark line\n");
1196 return true; // at present allow saving - even if it's invalid..
1198 public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
1200 this.error_line = validate_res.size;
1202 if (this.error_line < 1) {
1205 var tlines = this.el.get_line_count ();
1207 var valiter = validate_res.map_iterator();
1208 while (valiter.next()) {
1210 // print("get inter\n");
1211 var eline = valiter.get_key();
1212 if (eline > tlines) {
1215 this.el.get_iter_at_line( out iter, eline);
1216 //print("mark line\n");
1217 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
1221 public string toString () {
1225 this.el.get_start_iter(out s);
1226 this.el.get_end_iter(out e);
1227 var ret = this.el.get_text(s,e,true);
1228 //print("TO STRING? " + ret);
1231 public void showHelp (Gtk.TextIter iter) {
1232 var back = iter.copy();
1233 back.backward_char();
1235 var forward = iter.copy();
1236 forward.forward_char();
1238 // what's the character at the iter?
1239 var str = back.get_text(iter);
1240 str += iter.get_text(forward);
1241 if (str.strip().length < 1) {
1244 var offset = iter.get_line_offset();
1245 var line = iter.get_line();
1246 if (_this.prop != null) {
1248 line += _this.prop.start_line ;
1249 // this is based on Gtk using tabs (hence 1/2 chars);
1250 offset += _this.node.node_pad.length;
1251 // javascript listeners are indented 2 more spaces.
1252 if (_this.prop.ptype == JsRender.NodePropType.LISTENER) {
1257 var ls = _this.file.getLanguageServer();
1259 _this.file, line, offset,
1262 var res = ls.hover.end(o );
1264 _this.helper.setHelp(res);
1265 } catch (GLib.Error e) {
1272 public class Xcls_keystate : Object
1274 public Gtk.EventControllerKey el;
1275 private Editor _this;
1279 public bool is_control;
1282 public Xcls_keystate(Editor _owner )
1285 _this.keystate = this;
1286 this.el = new Gtk.EventControllerKey();
1289 this.is_control = false;
1291 // set gobject values
1294 this.el.key_released.connect( (keyval, keycode, state) => {
1296 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1297 this.is_control = false;
1299 if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1300 GLib.debug("SAVE: ctrl-S pressed");
1301 _this.saveContents();
1305 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1306 GLib.debug("SAVE: ctrl-g pressed");
1307 _this.forwardSearch(true);
1310 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1311 GLib.debug("SAVE: ctrl-f pressed");
1312 _this.search_entry.el.grab_focus();
1313 _this.search_entry.el.select_region(0,-1);
1316 if (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1317 _this.view.el.show_completion();
1321 _this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);
1322 var line = iter.get_line();
1323 var offset = iter.get_line_offset();
1324 GLib.debug("line %d off %d", line ,offset);
1325 if (_this.prop != null) {
1326 line += _this.prop.start_line + 1; // i think..
1327 offset += 12; // should probably be 8 without namespaced
1328 GLib.debug("guess line %d off %d", line ,offset);
1330 //_this.view.el.show_completion();
1331 // print(event.key.keyval)
1338 this.el.key_pressed.connect( (keyval, keycode, state) => {
1340 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1341 this.is_control = true;
1347 // user defined functions
1350 public class Xcls_EventControllerScroll13 : Object
1352 public Gtk.EventControllerScroll el;
1353 private Editor _this;
1357 public double distance;
1360 public Xcls_EventControllerScroll13(Editor _owner )
1363 this.el = new Gtk.EventControllerScroll( Gtk.EventControllerScrollFlags.VERTICAL );
1366 this.distance = 0.0f;
1368 // set gobject values
1371 this.el.scroll.connect( (dx, dy) => {
1372 if (!_this.keystate.is_control) {
1375 //GLib.debug("scroll %f", dy);
1377 this.distance += dy;
1379 //GLib.debug("scroll %f / %f", dy, this.distance);
1381 if (this.distance < -1) {
1383 BuilderApplication.settings.editor_font_size ++;
1386 if (this.distance > 1) {
1387 BuilderApplication.settings.editor_font_size --;
1395 // user defined functions
1398 public class Xcls_GestureClick14 : Object
1400 public Gtk.GestureClick el;
1401 private Editor _this;
1407 public Xcls_GestureClick14(Editor _owner )
1410 this.el = new Gtk.GestureClick();
1414 // set gobject values
1417 this.el.pressed.connect( (n_press, x, y) => {
1419 int buffer_x, buffer_y;
1420 var gut = _this.view.el.get_gutter(Gtk.TextWindowType.LEFT);
1422 _this.view.el.window_to_buffer_coords (Gtk.TextWindowType.TEXT,
1423 (int)x - gut.get_width(), (int)y,
1424 out buffer_x, out buffer_y);
1425 _this.view.el.get_iter_at_location (out iter,
1426 buffer_x, buffer_y);;
1429 if (_this.buffer.el.iter_has_context_class(iter, "comment") ||
1430 _this.buffer.el.iter_has_context_class(iter, "string")
1434 _this.buffer.showHelp(iter);
1441 // user defined functions
1446 public class Xcls_Box15 : Object
1449 private Editor _this;
1455 public Xcls_Box15(Editor _owner )
1458 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1462 // set gobject values
1463 this.el.homogeneous = false;
1464 this.el.vexpand = false;
1465 new Xcls_search_entry( _this );
1466 this.el.append( _this.search_entry.el );
1467 new Xcls_search_results( _this );
1468 this.el.append( _this.search_results.el );
1469 new Xcls_nextBtn( _this );
1470 this.el.append( _this.nextBtn.el );
1471 new Xcls_backBtn( _this );
1472 this.el.append( _this.backBtn.el );
1473 var child_5 = new Xcls_MenuButton21( _this );
1475 this.el.append( child_5.el );
1478 // user defined functions
1480 public class Xcls_search_entry : Object
1482 public Gtk.SearchEntry el;
1483 private Editor _this;
1487 public Gtk.CssProvider css;
1490 public Xcls_search_entry(Editor _owner )
1493 _this.search_entry = this;
1494 this.el = new Gtk.SearchEntry();
1498 // set gobject values
1499 this.el.name = "editor-search-entry";
1500 this.el.hexpand = true;
1501 this.el.placeholder_text = "Press enter to search";
1502 this.el.search_delay = 3;
1503 var child_1 = new Xcls_EventControllerKey17( _this );
1505 this.el.add_controller( child_1.el );
1508 this.el.search_changed.connect( ( ) => {
1510 _this.search(_this.search_entry.el.text);
1511 _this.search_results.updateResults();
1513 GLib.Timeout.add_seconds(1,() => {
1514 _this.search_results.updateResults();
1520 // user defined functions
1521 public void forwardSearch (bool change_focus) {
1524 _this.forwardSearch(change_focus);
1528 switch(_this.windowstate.state) {
1529 case WindowState.State.CODEONLY:
1530 //case WindowState.State.CODE:
1531 // search the code being edited..
1532 _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1535 case WindowState.State.PREVIEW:
1536 if (_this.windowstate.file.xtype == "Gtk") {
1537 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1539 _this.windowstate.window_rooview.forwardSearch(change_focus);
1548 public class Xcls_EventControllerKey17 : Object
1550 public Gtk.EventControllerKey el;
1551 private Editor _this;
1557 public Xcls_EventControllerKey17(Editor _owner )
1560 this.el = new Gtk.EventControllerKey();
1564 // set gobject values
1567 this.el.key_pressed.connect( (keyval, keycode, state) => {
1569 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1570 GLib.debug("SAVE: ctrl-g pressed");
1571 _this.forwardSearch(true);
1576 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1577 _this.forwardSearch(true);
1583 // print(event.key.keyval)
1589 // user defined functions
1593 public class Xcls_search_results : Object
1595 public Gtk.Label el;
1596 private Editor _this;
1602 public Xcls_search_results(Editor _owner )
1605 _this.search_results = this;
1606 this.el = new Gtk.Label( "No Results" );
1610 // set gobject values
1611 this.el.margin_end = 4;
1612 this.el.margin_start = 4;
1615 // user defined functions
1616 public void updateResults () {
1617 this.el.visible = true;
1619 var res = _this.searchcontext.get_occurrences_count();
1621 _this.search_results.el.label = "??? Matches";
1625 _this.nextBtn.el.sensitive = false;
1626 _this.backBtn.el.sensitive = false;
1629 _this.search_results.el.label = "%d Matches".printf(res);
1630 _this.nextBtn.el.sensitive = true;
1631 _this.backBtn.el.sensitive = true;
1634 _this.search_results.el.label = "No Matches";
1639 public class Xcls_nextBtn : Object
1641 public Gtk.Button el;
1642 private Editor _this;
1646 public bool always_show_image;
1649 public Xcls_nextBtn(Editor _owner )
1652 _this.nextBtn = this;
1653 this.el = new Gtk.Button();
1656 this.always_show_image = true;
1658 // set gobject values
1659 this.el.icon_name = "go-down";
1660 this.el.sensitive = false;
1663 this.el.clicked.connect( (event) => {
1665 _this.forwardSearch(true);
1671 // user defined functions
1674 public class Xcls_backBtn : Object
1676 public Gtk.Button el;
1677 private Editor _this;
1681 public bool always_show_image;
1684 public Xcls_backBtn(Editor _owner )
1687 _this.backBtn = this;
1688 this.el = new Gtk.Button();
1691 this.always_show_image = true;
1693 // set gobject values
1694 this.el.icon_name = "go-up";
1695 this.el.sensitive = false;
1698 this.el.clicked.connect( (event) => {
1700 _this.backSearch(true);
1705 // user defined functions
1708 public class Xcls_MenuButton21 : Object
1710 public Gtk.MenuButton el;
1711 private Editor _this;
1715 public bool always_show_image;
1718 public Xcls_MenuButton21(Editor _owner )
1721 this.el = new Gtk.MenuButton();
1724 this.always_show_image = true;
1726 // set gobject values
1727 this.el.icon_name = "emblem-system";
1728 this.el.always_show_arrow = true;
1729 new Xcls_search_settings( _this );
1730 this.el.popover = _this.search_settings.el;
1733 // user defined functions
1735 public class Xcls_search_settings : Object
1737 public Gtk.Popover el;
1738 private Editor _this;
1744 public Xcls_search_settings(Editor _owner )
1747 _this.search_settings = this;
1748 this.el = new Gtk.Popover();
1752 // set gobject values
1753 var child_1 = new Xcls_Box23( _this );
1755 this.el.child = child_1.el;
1758 // user defined functions
1760 public class Xcls_Box23 : Object
1763 private Editor _this;
1769 public Xcls_Box23(Editor _owner )
1772 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1776 // set gobject values
1777 new Xcls_case_sensitive( _this );
1778 this.el.append( _this.case_sensitive.el );
1779 new Xcls_regex( _this );
1780 this.el.append( _this.regex.el );
1781 new Xcls_multiline( _this );
1782 this.el.append( _this.multiline.el );
1785 // user defined functions
1787 public class Xcls_case_sensitive : Object
1789 public Gtk.CheckButton el;
1790 private Editor _this;
1796 public Xcls_case_sensitive(Editor _owner )
1799 _this.case_sensitive = this;
1800 this.el = new Gtk.CheckButton();
1804 // set gobject values
1805 this.el.label = "Case Sensitive";
1814 // user defined functions
1817 public class Xcls_regex : Object
1819 public Gtk.CheckButton el;
1820 private Editor _this;
1826 public Xcls_regex(Editor _owner )
1830 this.el = new Gtk.CheckButton();
1834 // set gobject values
1835 this.el.label = "Regex";
1844 // user defined functions
1847 public class Xcls_multiline : Object
1849 public Gtk.CheckButton el;
1850 private Editor _this;
1856 public Xcls_multiline(Editor _owner )
1859 _this.multiline = this;
1860 this.el = new Gtk.CheckButton();
1864 // set gobject values
1865 this.el.label = "Multi-line (add \\n)";
1868 // user defined functions
1876 public class Xcls_navigation_holder : Object
1879 private Editor _this;
1885 public Xcls_navigation_holder(Editor _owner )
1888 _this.navigation_holder = this;
1889 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1893 // set gobject values
1894 this.el.width_request = 120;
1895 this.el.hexpand = true;
1896 this.el.vexpand = true;
1897 this.el.visible = false;
1898 var child_1 = new Xcls_Box28( _this );
1900 this.el.append( child_1.el );
1901 new Xcls_navigationwindow( _this );
1902 this.el.append( _this.navigationwindow.el );
1905 // user defined functions
1907 public class Xcls_Box28 : Object
1910 private Editor _this;
1916 public Xcls_Box28(Editor _owner )
1919 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1923 // set gobject values
1926 // user defined functions
1929 public class Xcls_navigationwindow : Object
1931 public Gtk.ScrolledWindow el;
1932 private Editor _this;
1938 public Xcls_navigationwindow(Editor _owner )
1941 _this.navigationwindow = this;
1942 this.el = new Gtk.ScrolledWindow();
1946 // set gobject values
1947 this.el.hexpand = true;
1948 this.el.vexpand = true;
1949 this.el.visible = true;
1950 new Xcls_navigation( _this );
1951 this.el.child = _this.navigation.el;
1954 // user defined functions
1956 public class Xcls_navigation : Object
1958 public Gtk.ColumnView el;
1959 private Editor _this;
1963 public int last_selected_line;
1964 public Gtk.Widget? selected_row;
1967 public Xcls_navigation(Editor _owner )
1970 _this.navigation = this;
1971 new Xcls_navigationselmodel( _this );
1972 this.el = new Gtk.ColumnView( _this.navigationselmodel.el );
1975 this.last_selected_line = -1;
1976 this.selected_row = null;
1978 // set gobject values
1979 this.el.name = "editor-navigation";
1980 var child_2 = new Xcls_ColumnViewColumn31( _this );
1982 this.el.append_column( child_2.el );
1983 var child_3 = new Xcls_GestureClick40( _this );
1985 this.el.add_controller( child_3.el );
1988 // user defined functions
1989 public Gtk.Widget? getRowWidgetAt (double x, double y, out string pos) {
1992 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
1993 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
1998 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
2003 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2007 //GLib.debug("row number is %d", rn);
2008 //GLib.debug("click %d, %d", (int)x, (int)y);
2010 Graphene.Rect bounds;
2011 row.compute_bounds(this.el, out bounds);
2012 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2013 // (int)bounds.get_x(), (int)bounds.get_y(),
2014 // (int)bounds.get_width(), (int)bounds.get_height()
2016 var ypos = y - bounds.get_y();
2017 //GLib.debug("rel ypos = %d", (int)ypos);
2018 var rpos = 100.0 * (ypos / bounds.get_height());
2019 //GLib.debug("rel pos = %d %%", (int)rpos);
2024 } else if (rpos < 20) {
2029 public void show (Gee.ArrayList<Lsp.DocumentSymbol> syms) {
2031 if (!_this.navigation_holder.el.visible) {
2032 _this.navigation_holder.el.show();
2033 _this.paned.el.position =
2034 _this.paned.el.get_width() - 200;
2036 //_this.navliststore.el.remove_all();
2039 var ls = new GLib.ListStore(typeof(Lsp.DocumentSymbol));
2041 foreach(var sym in syms) {
2044 Lsp.DocumentSymbol.copyList(ls, _this.navliststore.el);
2045 //_this.navliststore.el.append(sym);
2046 this.last_selected_line = -1;
2047 GLib.Idle.add(() => {
2048 _this.navigationsort.collapseOnLoad();
2050 _this.buffer.el.get_iter_at_offset (
2051 out iter, _this.buffer.el.cursor_position);
2053 GLib.debug("idle update scroll %d, %d", iter.get_line(),
2054 iter.get_line_offset());
2055 this.updateSelectedLine(
2056 (uint)iter.get_line(),
2057 (uint)iter.get_line_offset()
2063 public int getRowAt (double x, double y, out string pos) {
2066 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
2067 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
2072 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
2077 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2082 while (cr.get_prev_sibling() != null) {
2084 cr = cr.get_prev_sibling();
2087 //GLib.debug("row number is %d", rn);
2088 //GLib.debug("click %d, %d", (int)x, (int)y);
2090 Graphene.Rect bounds;
2091 row.compute_bounds(this.el, out bounds);
2092 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2093 // (int)bounds.get_x(), (int)bounds.get_y(),
2094 // (int)bounds.get_width(), (int)bounds.get_height()
2096 var ypos = y - bounds.get_y();
2097 //GLib.debug("rel ypos = %d", (int)ypos);
2098 var rpos = 100.0 * (ypos / bounds.get_height());
2099 //GLib.debug("rel pos = %d %%", (int)rpos);
2104 } else if (rpos < 20) {
2109 public void updateSelectedLine (uint line, uint chr) {
2110 if (line == this.last_selected_line) {
2113 GLib.debug("select line %d", (int)line);
2114 this.last_selected_line = (int)line;
2118 var sym = _this.navliststore.symbolAtLine(line, chr);
2120 new_row = _this.navigationsort.getRowFromSymbol(sym);
2121 GLib.debug("select line %d - row found %d", (int)line, new_row);
2123 GLib.debug(" no symbol found at line %d", (int)line);
2126 if (this.selected_row != null) {
2127 GLib.debug(" remove selected row");
2128 this.selected_row.remove_css_class("selected-row");
2130 this.selected_row = null;
2132 this.el.scroll_to(new_row,null,Gtk.ListScrollFlags.NONE, null);
2133 var row = sym.get_data<Gtk.Widget>("widget");
2135 GLib.debug(" Add selected row");
2137 row.add_css_class("selected-row");
2138 this.selected_row = row;
2142 GLib.debug("could not find widget on row %d", new_row);
2150 public class Xcls_ColumnViewColumn31 : Object
2152 public Gtk.ColumnViewColumn el;
2153 private Editor _this;
2159 public Xcls_ColumnViewColumn31(Editor _owner )
2162 var child_1 = new Xcls_SignalListItemFactory32( _this );
2164 this.el = new Gtk.ColumnViewColumn( "Code Navigation", child_1.el );
2168 // set gobject values
2169 this.el.expand = true;
2172 // user defined functions
2174 public class Xcls_SignalListItemFactory32 : Object
2176 public Gtk.SignalListItemFactory el;
2177 private Editor _this;
2183 public Xcls_SignalListItemFactory32(Editor _owner )
2186 this.el = new Gtk.SignalListItemFactory();
2190 // set gobject values
2193 this.el.setup.connect( (listitem) => {
2195 var expand = new Gtk.TreeExpander();
2197 expand.set_indent_for_depth(true);
2198 expand.set_indent_for_icon(true);
2199 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2200 var icon = new Gtk.Image();
2201 var lbl = new Gtk.Label("");
2202 lbl.use_markup = true;
2203 lbl.ellipsize = Pango.EllipsizeMode.END;
2205 icon.margin_end = 4;
2206 lbl.justify = Gtk.Justification.LEFT;
2209 // listitem.activatable = true; ??
2213 expand.set_child(hbox);
2214 ((Gtk.ListItem)listitem).set_child(expand);
2217 this.el.bind.connect( (listitem) => {
2219 // GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name());
2221 //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2222 var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2225 var hbox = (Gtk.Box) expand.child;
2228 var img = (Gtk.Image) hbox.get_first_child();
2229 var lbl = (Gtk.Label) img.get_next_sibling();
2231 var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();
2232 var sym = (Lsp.DocumentSymbol) lr.get_item();
2234 sym.set_data<Gtk.Widget>("widget", expand.get_parent());
2235 expand.get_parent().get_parent().set_data<Lsp.DocumentSymbol>("symbol", sym);
2237 //GLib.debug("save sym on %s", expand.get_parent().get_parent().get_type().name());
2239 //GLib.debug("got %d children for %s" , (int)sym.children.get_n_items(), sym.name);
2241 expand.set_hide_expander( sym.children.get_n_items() < 1);
2242 expand.set_list_row(lr);
2243 //this.in_bind = true;
2244 // default is to expand
2246 //this.in_bind = false;
2248 sym.bind_property("symbol_icon",
2250 GLib.BindingFlags.SYNC_CREATE);
2252 hbox.css_classes = { sym.symbol_icon };
2254 sym.bind_property("name",
2256 GLib.BindingFlags.SYNC_CREATE);
2257 // should be better?- --line no?
2258 sym.bind_property("tooltip",
2259 lbl, "tooltip_markup",
2260 GLib.BindingFlags.SYNC_CREATE);
2266 // user defined functions
2270 public class Xcls_navigationselmodel : Object
2272 public Gtk.NoSelection el;
2273 private Editor _this;
2279 public Xcls_navigationselmodel(Editor _owner )
2282 _this.navigationselmodel = this;
2283 new Xcls_navigationsort( _this );
2284 this.el = new Gtk.NoSelection( _this.navigationsort.el );
2288 // set gobject values
2291 // user defined functions
2293 public class Xcls_navigationsort : Object
2295 public Gtk.SortListModel el;
2296 private Editor _this;
2302 public Xcls_navigationsort(Editor _owner )
2305 _this.navigationsort = this;
2306 var child_1 = new Xcls_TreeListModel35( _this );
2308 var child_2 = new Xcls_TreeListRowSorter37( _this );
2310 this.el = new Gtk.SortListModel( child_1.el, child_2.el );
2314 // set gobject values
2317 // user defined functions
2318 public void collapseOnLoad () {
2319 for (var i=0;i < this.el.get_n_items(); i++) {
2320 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2321 var sym = (Lsp.DocumentSymbol)tr.get_item();
2323 case Lsp.SymbolKind.Enum:
2324 tr.expanded = false;
2327 //tr.expanded = true;
2336 public int getRowFromSymbol (Lsp.DocumentSymbol sym) {
2338 for (var i=0;i < this.el.get_n_items(); i++) {
2339 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2341 if (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {
2347 public Lsp.DocumentSymbol? getSymbolAt (uint row) {
2349 var tr = (Gtk.TreeListRow)this.el.get_item(row);
2351 var a = tr.get_item();;
2352 GLib.debug("get_item (2) = %s", a.get_type().name());
2355 return (Lsp.DocumentSymbol)tr.get_item();
2359 public class Xcls_TreeListModel35 : Object
2361 public Gtk.TreeListModel el;
2362 private Editor _this;
2368 public Xcls_TreeListModel35(Editor _owner )
2371 new Xcls_navliststore( _this );
2372 this.el = new Gtk.TreeListModel( _this.navliststore.el, false, true, (item) => {
2374 return ((Lsp.DocumentSymbol)item).children;
2380 // set gobject values
2383 this.el.items_changed.connect( (position, removed, added) => {
2384 GLib.debug("tree item changed %d , %d , %d",(int) position, (int)removed, (int) added);
2388 //var sym = (Lsp.DocumentSymbol) this.el.get_item(position);
2389 var row = this.el.get_row(position);
2391 GLib.debug("got %s", row.get_item().get_type().name());
2397 // user defined functions
2399 public class Xcls_navliststore : Object
2401 public GLib.ListStore el;
2402 private Editor _this;
2408 public Xcls_navliststore(Editor _owner )
2411 _this.navliststore = this;
2412 this.el = new GLib.ListStore( typeof(Lsp.DocumentSymbol) );
2416 // set gobject values
2419 // user defined functions
2420 public Lsp.DocumentSymbol? symbolAtLine (uint line, uint chr) {
2423 for(var i = 0; i < this.el.get_n_items();i++) {
2424 var el = (Lsp.DocumentSymbol)this.el.get_item(i);
2425 //GLib.debug("Check sym %s : %d-%d",
2426 // el.name , (int)el.range.start.line,
2427 // (int)el.range.end.line
2429 var ret = el.containsLine(line,chr);
2441 public class Xcls_TreeListRowSorter37 : Object
2443 public Gtk.TreeListRowSorter el;
2444 private Editor _this;
2450 public Xcls_TreeListRowSorter37(Editor _owner )
2453 var child_1 = new Xcls_StringSorter38( _this );
2455 this.el = new Gtk.TreeListRowSorter( child_1.el );
2459 // set gobject values
2462 // user defined functions
2464 public class Xcls_StringSorter38 : Object
2466 public Gtk.StringSorter el;
2467 private Editor _this;
2473 public Xcls_StringSorter38(Editor _owner )
2476 var child_1 = new Xcls_PropertyExpression39( _this );
2478 this.el = new Gtk.StringSorter( child_1.el );
2482 // set gobject values
2485 // user defined functions
2487 public class Xcls_PropertyExpression39 : Object
2489 public Gtk.PropertyExpression el;
2490 private Editor _this;
2496 public Xcls_PropertyExpression39(Editor _owner )
2499 this.el = new Gtk.PropertyExpression( typeof(Lsp.DocumentSymbol), null, "sort_key" );
2503 // set gobject values
2506 // user defined functions
2513 public class Xcls_GestureClick40 : Object
2515 public Gtk.GestureClick el;
2516 private Editor _this;
2522 public Xcls_GestureClick40(Editor _owner )
2525 this.el = new Gtk.GestureClick();
2529 // set gobject values
2532 this.el.pressed.connect( (n_press, x, y) => {
2534 var row = _this.navigation.getRowWidgetAt(x,y, out pos );
2537 GLib.debug("no row selected items");
2540 GLib.debug("got click on %s", row.get_type().name());
2541 //Lsp.DocumentSymbol
2542 var sym = row.get_data<Lsp.DocumentSymbol>("symbol");
2558 GLib.debug("goto line %d", (int)sym.range.start.line);
2559 _this.scroll_to_line((int)sym.range.start.line);
2561 _this.buffer.el.get_iter_at_line_offset(out iter,
2562 (int)sym.range.start.line,
2563 (int)sym.range.start.character
2565 _this.buffer.el.place_cursor(iter);
2570 // user defined functions