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 // user defined functions
555 public void setHelp (Lsp.Hover? help) {
556 if (help == null || help.contents == null
557 || help.contents.size < 1) {
558 this.el.set_text("");
561 var sig = help.contents.get(0).value.split(" ");
563 for(var i =0; i < sig.length; i++) {
582 str += ("<span underline=\"single\" color=\"blue\" >" +
583 GLib.Markup.escape_text(sig[i])
588 if (help.contents.size > 1) {
589 sig += ("\n\n" + help.contents[1].value);
592 this.el.set_markup(string.joinv(" ",str));
597 public class Xcls_Scale6 : Object
600 private Editor _this;
606 public Xcls_Scale6(Editor _owner )
609 this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1);
613 // set gobject values
614 this.el.width_request = 150;
615 this.el.has_origin = true;
616 this.el.halign = Gtk.Align.END;
617 this.el.draw_value = false;
619 this.el.sensitive = true;
624 //this.el.set_range(6,30);
625 this.el.set_value ( BuilderApplication.settings.editor_font_size);
626 BuilderApplication.settings.editor_font_size_updated.connect(
628 BuilderApplication.settings.editor_font_size_inchange = true;
629 // GLib.debug("update range");
630 this.el.set_value (BuilderApplication.settings.editor_font_size);
631 BuilderApplication.settings.editor_font_size_inchange = false;
639 this.el.change_value.connect( (st, val ) => {
640 if (BuilderApplication.settings.editor_font_size_inchange) {
643 BuilderApplication.settings.editor_font_size = val;
648 // user defined functions
651 public class Xcls_close_btn : Object
653 public Gtk.Button el;
654 private Editor _this;
660 public Xcls_close_btn(Editor _owner )
663 _this.close_btn = this;
664 this.el = new Gtk.Button();
668 // set gobject values
669 this.el.icon_name = "window-close";
670 this.el.halign = Gtk.Align.END;
671 var child_1 = new Xcls_Image8( _this );
673 this.el.child = child_1.el;
676 this.el.clicked.connect( () => {
677 _this.saveContents();
678 _this.window.windowstate.switchState(WindowState.State.PREVIEW);
682 // user defined functions
684 public class Xcls_Image8 : Object
687 private Editor _this;
693 public Xcls_Image8(Editor _owner )
696 this.el = new Gtk.Image();
700 // set gobject values
701 this.el.icon_name = "window-close";
702 this.el.icon_size = Gtk.IconSize.NORMAL;
705 // user defined functions
710 public class Xcls_RightEditor : Object
712 public Gtk.ScrolledWindow el;
713 private Editor _this;
719 public Xcls_RightEditor(Editor _owner )
722 _this.RightEditor = this;
723 this.el = new Gtk.ScrolledWindow();
727 // set gobject values
728 this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
729 this.el.vexpand = true;
730 this.el.overlay_scrolling = false;
731 this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
732 new Xcls_view( _this );
733 this.el.child = _this.view.el;
736 // user defined functions
738 public class Xcls_view : Object
740 public GtkSource.View el;
741 private Editor _this;
745 public Gtk.CssProvider css;
748 public Xcls_view(Editor _owner )
752 this.el = new GtkSource.View();
757 // set gobject values
758 this.el.auto_indent = true;
759 this.el.indent_width = 4;
760 this.el.name = "editor-view";
761 this.el.show_line_marks = true;
762 this.el.insert_spaces_instead_of_tabs = true;
763 this.el.show_line_numbers = true;
764 this.el.hexpand = true;
765 this.el.vexpand = true;
766 this.el.has_tooltip = true;
767 this.el.css_classes = { "code-editor" };
768 this.el.tab_width = 4;
769 this.el.highlight_current_line = true;
770 new Xcls_buffer( _this );
771 this.el.buffer = _this.buffer.el;
772 new Xcls_keystate( _this );
773 this.el.add_controller( _this.keystate.el );
774 var child_3 = new Xcls_EventControllerScroll13( _this );
776 this.el.add_controller( child_3.el );
777 var child_4 = new Xcls_GestureClick14( _this );
779 this.el.add_controller( child_4.el );
783 this.el.completion.add_provider(
784 new Palete.CompletionProvider(_this)
787 // hover seems pretty useless.. - ??
788 //var hover = this.el.get_hover();
789 //hover.add_provider(new Palete.HoverProvider(_this));
791 //this.el.completion.unblock_interactive();
792 this.el.completion.select_on_show = true; // select
793 //this.el.completion.remember_info_visibility = true;
796 var attrs = new GtkSource.MarkAttributes();
798 attrs.set_icon_name ( "process-stop");
799 attrs.query_tooltip_text.connect(( mark) => {
800 GLib.debug("tooltip query? %s", mark.name);
801 return strdup( mark.name);
803 attrs.query_tooltip_markup.connect(( mark) => {
804 GLib.debug("tooltip query? %s", mark.name);
805 return strdup( mark.name);
807 this.el.set_mark_attributes ("ERR", attrs, 1);
811 var wattrs = new GtkSource.MarkAttributes();
812 wattrs.set_icon_name ( "process-stop");
813 wattrs.query_tooltip_text.connect(( mark) => {
814 GLib.debug("tooltip query? %s", mark.name);
815 return strdup(mark.name);
817 wattrs.query_tooltip_markup.connect(( mark) => {
818 GLib.debug("tooltip query? %s", mark.name);
819 return strdup(mark.name);
821 this.el.set_mark_attributes ("WARN", wattrs, 1);
825 var dattrs = new GtkSource.MarkAttributes();
827 dattrs.set_icon_name ( "process-stop");
829 dattrs.query_tooltip_text.connect(( mark) => {
830 GLib.debug("tooltip query? %s", mark.name);
831 return strdup(mark.name);
833 //dattrs.query_tooltip_markup.connect(( mark) => {
834 // GLib.debug("tooltip query? %s", mark.name);
835 // return strdup(mark.name);
837 this.el.set_mark_attributes ("DEPR", dattrs, 1);
840 this.el.get_space_drawer().set_matrix(null);
841 this.el.get_space_drawer().set_types_for_locations(
842 GtkSource.SpaceLocationFlags.ALL,
843 GtkSource.SpaceTypeFlags.ALL
845 this.el.get_space_drawer().set_enable_matrix(true);
848 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
850 //GLib.debug("query tooltip");
854 var yoff = (int) _this.RightEditor.el.vadjustment.value;
856 // I think this is problematic - if it's compliing / updating at same time as query.
858 //if (_this.window.statusbar_compile_spinner.el.spinning) {
862 this.el.get_iter_at_position (out iter, out trailing, x, y + yoff);
864 var l = iter.get_line();
868 // GLib.debug("query tooltip line %d", (int) l);
874 if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {
875 GLib.debug("line %d setting tip to %s", l, _this.buffer.marks.get(l));
876 tooltip.set_text(_this.buffer.marks.get(l).dup());
884 // this crashes?? - not sure why.
885 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
886 if (marks.is_empty()) {
887 marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
889 if (marks.is_empty()) {
890 marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
893 // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length());
895 marks.@foreach((m) => {
896 //GLib.debug("got mark %s", m.name);
897 str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name;
899 // true if there is a mark..
900 if (str.length > 0 ) {
901 tooltip.set_text( str );
903 return str.length > 0 ? true : false;
908 // user defined functions
909 public void load (string str) {
911 // show the help page for the active node..
912 //this.get('/Help').show();
914 // this.get('/BottomPane').el.set_current_page(0);
915 GLib.debug("load called - Reset undo buffer");
917 var buf = (GtkSource.Buffer)this.el.get_buffer();
918 buf.begin_irreversible_action();
919 buf.set_text(str, str.length);
920 buf.end_irreversible_action();
922 var lm = GtkSource.LanguageManager.get_default();
924 if (_this.file != null) {
925 lang = _this.file.language;
927 print("lang=%s, content_type = %s\n", lang, _this.file.content_type);
928 var lg = _this.file.content_type.length > 0 ?
929 lm.guess_language(_this.file.path, _this.file.content_type) :
930 lm.get_language(lang);
933 ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg);
935 this.el.insert_spaces_instead_of_tabs = true;
937 print("sourcelanguage = %s\n", lg.name);
938 if (lg.name == "Vala") {
939 this.el.insert_spaces_instead_of_tabs = false;
943 this.el.grab_focus();
944 _this.save_button.el.sensitive = false;
945 _this.last_error_counter = -1;
948 public class Xcls_buffer : Object
950 public GtkSource.Buffer el;
951 private Editor _this;
955 public int error_line;
956 public Gee.HashMap<int,string>? xmarks;
957 public bool check_queued;
960 public Xcls_buffer(Editor _owner )
964 this.el = new GtkSource.Buffer( null );
967 this.error_line = -1;
969 this.check_queued = false;
971 // set gobject values
972 this.el.highlight_syntax = true;
973 this.el.highlight_matching_brackets = true;
974 this.el.enable_undo = true;
979 buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
980 buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
981 buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
982 buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
983 buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
984 buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
985 buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
986 buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
989 buf.create_tag ("ERR", "weight", Pango.Weight.BOLD, "background", "pink");
990 buf.create_tag ("WARN", "weight", Pango.Weight.BOLD, "background", "#ABF4EB");
991 buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
994 this.el.cursor_moved.connect( ( ) => {
997 this.el.get_iter_at_offset (
998 out iter, this.el.cursor_position);
1000 _this.navigation.updateSelectedLine(
1001 (uint)iter.get_line(),
1002 (uint)iter.get_line_offset()
1004 this.showHelp(iter);
1007 this.el.changed.connect( () => {
1010 _this.save_button.el.sensitive = true;
1011 print("EDITOR CHANGED");
1016 // this.get('/LeftPanel.model').changed( str , false);
1021 // user defined functions
1022 public bool OLDhighlightErrorsJson (string type, Json.Object obj) {
1025 this.el.get_bounds (out start, out end);
1027 this.el.remove_source_marks (start, end, type);
1028 GLib.debug("highlight errors");
1030 // we should highlight other types of errors..
1032 if (!obj.has_member(type)) {
1033 GLib.debug("Return has no errors\n");
1037 if (_this.window.windowstate.state != WindowState.State.CODEONLY
1039 _this.window.windowstate.state != WindowState.State.CODE
1041 GLib.debug("windowstate != CODEONLY?");
1046 //this.marks = new Gee.HashMap<int,string>();
1047 var err = obj.get_object_member(type);
1049 if (_this.file == null) {
1050 GLib.debug("file is null?");
1054 var valafn = _this.file.path;
1056 if (_this.file.xtype != "PlainFile") {
1060 var regex = new Regex("\\.bjs$");
1061 // should not happen
1062 valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
1063 } catch (GLib.RegexError e) {
1070 if (!err.has_member(valafn)) {
1071 GLib.debug("File path has no errors");
1075 var lines = err.get_object_member(valafn);
1078 if (obj.has_member("line_offset")) { // ?? why??
1079 offset = (int)obj.get_int_member("line_offset") + 1;
1083 var tlines = this.el.get_line_count () +1;
1085 if (_this.prop != null) {
1087 tlines = _this.prop.end_line + 1;
1088 offset = _this.prop.start_line + 1;
1094 lines.foreach_member((obj, line, node) => {
1097 // print("get inter\n");
1098 var eline = int.parse(line) - offset;
1099 GLib.debug("GOT ERROR on line %s -- converted to %d (offset = %d)\n", line,eline, offset);
1102 if (eline > tlines || eline < 0) {
1107 this.el.get_iter_at_line( out iter, eline);
1108 //print("mark line\n");
1110 var ar = lines.get_array_member(line);
1111 for (var i = 0 ; i < ar.get_length(); i++) {
1112 if (ar.get_string_element(i) == "Success") {
1115 msg += (msg.length > 0) ? "\n" : "";
1116 msg += ar.get_string_element(i);
1121 msg = "Line: %d".printf(eline+1) + " " + msg;
1122 this.el.create_source_mark(msg, type, iter);
1123 GLib.debug("set line %d to %m", eline, msg);
1124 // this.marks.set(eline, msg);
1133 public bool checkSyntax () {
1136 var str = this.toString();
1139 if (this.error_line > 0) {
1142 this.el.get_bounds (out start, out end);
1144 this.el.remove_source_marks (start, end, null);
1146 if (str.length < 1) {
1147 print("checkSyntax - empty string?\n");
1152 if (_this.file.xtype == "PlainFile") {
1154 // assume it's gtk...
1155 var oldcode =_this.file.toSource();
1156 _this.file.setSource(str);
1157 BuilderApplication.showSpinner("appointment soon","document change pending");
1158 _this.file.getLanguageServer().document_change(_this.file);
1159 _this.file.getLanguageServer().queueDocumentSymbols(_this.file);
1160 _this.file.setSource(oldcode);
1166 if (_this.file == null) {
1174 GLib.debug("calling validate");
1175 // clear the buttons.
1176 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
1179 var oldcode = _this.prop.val;
1181 _this.prop.val = str;
1182 _this.node.updated_count++;
1183 _this.file.getLanguageServer().document_change(_this.file);
1184 _this.node.updated_count++;
1185 _this.prop.val = oldcode;
1188 //print("done mark line\n");
1190 return true; // at present allow saving - even if it's invalid..
1192 public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
1194 this.error_line = validate_res.size;
1196 if (this.error_line < 1) {
1199 var tlines = this.el.get_line_count ();
1201 var valiter = validate_res.map_iterator();
1202 while (valiter.next()) {
1204 // print("get inter\n");
1205 var eline = valiter.get_key();
1206 if (eline > tlines) {
1209 this.el.get_iter_at_line( out iter, eline);
1210 //print("mark line\n");
1211 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
1215 public string toString () {
1219 this.el.get_start_iter(out s);
1220 this.el.get_end_iter(out e);
1221 var ret = this.el.get_text(s,e,true);
1222 //print("TO STRING? " + ret);
1225 public void showHelp (Gtk.TextIter iter) {
1226 var back = iter.copy();
1227 back.backward_char();
1229 var forward = iter.copy();
1230 forward.forward_char();
1232 // what's the character at the iter?
1233 var str = back.get_text(iter);
1234 str += iter.get_text(forward);
1235 if (str.strip().length < 1) {
1238 var offset = iter.get_line_offset();
1239 var line = iter.get_line();
1240 if (_this.prop != null) {
1242 line += _this.prop.start_line ;
1243 // this is based on Gtk using tabs (hence 1/2 chars);
1244 offset += _this.node.node_pad.length;
1245 // javascript listeners are indented 2 more spaces.
1246 if (_this.prop.ptype == JsRender.NodePropType.LISTENER) {
1251 var ls = _this.file.getLanguageServer();
1253 _this.file, line, offset,
1256 var res = ls.hover.end(o );
1258 _this.helper.setHelp(res);
1259 } catch (GLib.Error e) {
1266 public class Xcls_keystate : Object
1268 public Gtk.EventControllerKey el;
1269 private Editor _this;
1273 public bool is_control;
1276 public Xcls_keystate(Editor _owner )
1279 _this.keystate = this;
1280 this.el = new Gtk.EventControllerKey();
1283 this.is_control = false;
1285 // set gobject values
1288 this.el.key_released.connect( (keyval, keycode, state) => {
1290 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1291 this.is_control = false;
1293 if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1294 GLib.debug("SAVE: ctrl-S pressed");
1295 _this.saveContents();
1299 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1300 GLib.debug("SAVE: ctrl-g pressed");
1301 _this.forwardSearch(true);
1304 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1305 GLib.debug("SAVE: ctrl-f pressed");
1306 _this.search_entry.el.grab_focus();
1307 _this.search_entry.el.select_region(0,-1);
1310 if (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1311 _this.view.el.show_completion();
1315 _this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);
1316 var line = iter.get_line();
1317 var offset = iter.get_line_offset();
1318 GLib.debug("line %d off %d", line ,offset);
1319 if (_this.prop != null) {
1320 line += _this.prop.start_line + 1; // i think..
1321 offset += 12; // should probably be 8 without namespaced
1322 GLib.debug("guess line %d off %d", line ,offset);
1324 //_this.view.el.show_completion();
1325 // print(event.key.keyval)
1332 this.el.key_pressed.connect( (keyval, keycode, state) => {
1334 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1335 this.is_control = true;
1341 // user defined functions
1344 public class Xcls_EventControllerScroll13 : Object
1346 public Gtk.EventControllerScroll el;
1347 private Editor _this;
1351 public double distance;
1354 public Xcls_EventControllerScroll13(Editor _owner )
1357 this.el = new Gtk.EventControllerScroll( Gtk.EventControllerScrollFlags.VERTICAL );
1360 this.distance = 0.0f;
1362 // set gobject values
1365 this.el.scroll.connect( (dx, dy) => {
1366 if (!_this.keystate.is_control) {
1369 //GLib.debug("scroll %f", dy);
1371 this.distance += dy;
1373 //GLib.debug("scroll %f / %f", dy, this.distance);
1375 if (this.distance < -1) {
1377 BuilderApplication.settings.editor_font_size ++;
1380 if (this.distance > 1) {
1381 BuilderApplication.settings.editor_font_size --;
1389 // user defined functions
1392 public class Xcls_GestureClick14 : Object
1394 public Gtk.GestureClick el;
1395 private Editor _this;
1401 public Xcls_GestureClick14(Editor _owner )
1404 this.el = new Gtk.GestureClick();
1408 // set gobject values
1411 this.el.pressed.connect( (n_press, x, y) => {
1413 int buffer_x, buffer_y;
1414 var gut = _this.view.el.get_gutter(Gtk.TextWindowType.LEFT);
1416 _this.view.el.window_to_buffer_coords (Gtk.TextWindowType.TEXT,
1417 (int)x - gut.get_width(), (int)y,
1418 out buffer_x, out buffer_y);
1419 _this.view.el.get_iter_at_location (out iter,
1420 buffer_x, buffer_y);;
1423 if (_this.buffer.el.iter_has_context_class(iter, "comment") ||
1424 _this.buffer.el.iter_has_context_class(iter, "string")
1428 _this.buffer.showHelp(iter);
1435 // user defined functions
1440 public class Xcls_Box15 : Object
1443 private Editor _this;
1449 public Xcls_Box15(Editor _owner )
1452 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1456 // set gobject values
1457 this.el.homogeneous = false;
1458 this.el.vexpand = false;
1459 new Xcls_search_entry( _this );
1460 this.el.append( _this.search_entry.el );
1461 new Xcls_search_results( _this );
1462 this.el.append( _this.search_results.el );
1463 new Xcls_nextBtn( _this );
1464 this.el.append( _this.nextBtn.el );
1465 new Xcls_backBtn( _this );
1466 this.el.append( _this.backBtn.el );
1467 var child_5 = new Xcls_MenuButton21( _this );
1469 this.el.append( child_5.el );
1472 // user defined functions
1474 public class Xcls_search_entry : Object
1476 public Gtk.SearchEntry el;
1477 private Editor _this;
1481 public Gtk.CssProvider css;
1484 public Xcls_search_entry(Editor _owner )
1487 _this.search_entry = this;
1488 this.el = new Gtk.SearchEntry();
1492 // set gobject values
1493 this.el.name = "editor-search-entry";
1494 this.el.hexpand = true;
1495 this.el.placeholder_text = "Press enter to search";
1496 this.el.search_delay = 3;
1497 var child_1 = new Xcls_EventControllerKey17( _this );
1499 this.el.add_controller( child_1.el );
1502 this.el.search_changed.connect( ( ) => {
1504 _this.search(_this.search_entry.el.text);
1505 _this.search_results.updateResults();
1507 GLib.Timeout.add_seconds(1,() => {
1508 _this.search_results.updateResults();
1514 // user defined functions
1515 public void forwardSearch (bool change_focus) {
1518 _this.forwardSearch(change_focus);
1522 switch(_this.windowstate.state) {
1523 case WindowState.State.CODEONLY:
1524 //case WindowState.State.CODE:
1525 // search the code being edited..
1526 _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1529 case WindowState.State.PREVIEW:
1530 if (_this.windowstate.file.xtype == "Gtk") {
1531 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1533 _this.windowstate.window_rooview.forwardSearch(change_focus);
1542 public class Xcls_EventControllerKey17 : Object
1544 public Gtk.EventControllerKey el;
1545 private Editor _this;
1551 public Xcls_EventControllerKey17(Editor _owner )
1554 this.el = new Gtk.EventControllerKey();
1558 // set gobject values
1561 this.el.key_pressed.connect( (keyval, keycode, state) => {
1563 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1564 GLib.debug("SAVE: ctrl-g pressed");
1565 _this.forwardSearch(true);
1570 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1571 _this.forwardSearch(true);
1577 // print(event.key.keyval)
1583 // user defined functions
1587 public class Xcls_search_results : Object
1589 public Gtk.Label el;
1590 private Editor _this;
1596 public Xcls_search_results(Editor _owner )
1599 _this.search_results = this;
1600 this.el = new Gtk.Label( "No Results" );
1604 // set gobject values
1605 this.el.margin_end = 4;
1606 this.el.margin_start = 4;
1609 // user defined functions
1610 public void updateResults () {
1611 this.el.visible = true;
1613 var res = _this.searchcontext.get_occurrences_count();
1615 _this.search_results.el.label = "??? Matches";
1619 _this.nextBtn.el.sensitive = false;
1620 _this.backBtn.el.sensitive = false;
1623 _this.search_results.el.label = "%d Matches".printf(res);
1624 _this.nextBtn.el.sensitive = true;
1625 _this.backBtn.el.sensitive = true;
1628 _this.search_results.el.label = "No Matches";
1633 public class Xcls_nextBtn : Object
1635 public Gtk.Button el;
1636 private Editor _this;
1640 public bool always_show_image;
1643 public Xcls_nextBtn(Editor _owner )
1646 _this.nextBtn = this;
1647 this.el = new Gtk.Button();
1650 this.always_show_image = true;
1652 // set gobject values
1653 this.el.icon_name = "go-down";
1654 this.el.sensitive = false;
1657 this.el.clicked.connect( (event) => {
1659 _this.forwardSearch(true);
1665 // user defined functions
1668 public class Xcls_backBtn : Object
1670 public Gtk.Button el;
1671 private Editor _this;
1675 public bool always_show_image;
1678 public Xcls_backBtn(Editor _owner )
1681 _this.backBtn = this;
1682 this.el = new Gtk.Button();
1685 this.always_show_image = true;
1687 // set gobject values
1688 this.el.icon_name = "go-up";
1689 this.el.sensitive = false;
1692 this.el.clicked.connect( (event) => {
1694 _this.backSearch(true);
1699 // user defined functions
1702 public class Xcls_MenuButton21 : Object
1704 public Gtk.MenuButton el;
1705 private Editor _this;
1709 public bool always_show_image;
1712 public Xcls_MenuButton21(Editor _owner )
1715 this.el = new Gtk.MenuButton();
1718 this.always_show_image = true;
1720 // set gobject values
1721 this.el.icon_name = "emblem-system";
1722 this.el.always_show_arrow = true;
1723 new Xcls_search_settings( _this );
1724 this.el.popover = _this.search_settings.el;
1727 // user defined functions
1729 public class Xcls_search_settings : Object
1731 public Gtk.Popover el;
1732 private Editor _this;
1738 public Xcls_search_settings(Editor _owner )
1741 _this.search_settings = this;
1742 this.el = new Gtk.Popover();
1746 // set gobject values
1747 var child_1 = new Xcls_Box23( _this );
1749 this.el.child = child_1.el;
1752 // user defined functions
1754 public class Xcls_Box23 : Object
1757 private Editor _this;
1763 public Xcls_Box23(Editor _owner )
1766 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1770 // set gobject values
1771 new Xcls_case_sensitive( _this );
1772 this.el.append( _this.case_sensitive.el );
1773 new Xcls_regex( _this );
1774 this.el.append( _this.regex.el );
1775 new Xcls_multiline( _this );
1776 this.el.append( _this.multiline.el );
1779 // user defined functions
1781 public class Xcls_case_sensitive : Object
1783 public Gtk.CheckButton el;
1784 private Editor _this;
1790 public Xcls_case_sensitive(Editor _owner )
1793 _this.case_sensitive = this;
1794 this.el = new Gtk.CheckButton();
1798 // set gobject values
1799 this.el.label = "Case Sensitive";
1808 // user defined functions
1811 public class Xcls_regex : Object
1813 public Gtk.CheckButton el;
1814 private Editor _this;
1820 public Xcls_regex(Editor _owner )
1824 this.el = new Gtk.CheckButton();
1828 // set gobject values
1829 this.el.label = "Regex";
1838 // user defined functions
1841 public class Xcls_multiline : Object
1843 public Gtk.CheckButton el;
1844 private Editor _this;
1850 public Xcls_multiline(Editor _owner )
1853 _this.multiline = this;
1854 this.el = new Gtk.CheckButton();
1858 // set gobject values
1859 this.el.label = "Multi-line (add \\n)";
1862 // user defined functions
1870 public class Xcls_navigation_holder : Object
1873 private Editor _this;
1879 public Xcls_navigation_holder(Editor _owner )
1882 _this.navigation_holder = this;
1883 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1887 // set gobject values
1888 this.el.width_request = 120;
1889 this.el.hexpand = true;
1890 this.el.vexpand = true;
1891 this.el.visible = false;
1892 var child_1 = new Xcls_Box28( _this );
1894 this.el.append( child_1.el );
1895 new Xcls_navigationwindow( _this );
1896 this.el.append( _this.navigationwindow.el );
1899 // user defined functions
1901 public class Xcls_Box28 : Object
1904 private Editor _this;
1910 public Xcls_Box28(Editor _owner )
1913 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1917 // set gobject values
1920 // user defined functions
1923 public class Xcls_navigationwindow : Object
1925 public Gtk.ScrolledWindow el;
1926 private Editor _this;
1932 public Xcls_navigationwindow(Editor _owner )
1935 _this.navigationwindow = this;
1936 this.el = new Gtk.ScrolledWindow();
1940 // set gobject values
1941 this.el.hexpand = true;
1942 this.el.vexpand = true;
1943 this.el.visible = true;
1944 new Xcls_navigation( _this );
1945 this.el.child = _this.navigation.el;
1948 // user defined functions
1950 public class Xcls_navigation : Object
1952 public Gtk.ColumnView el;
1953 private Editor _this;
1957 public int last_selected_line;
1958 public Gtk.Widget? selected_row;
1961 public Xcls_navigation(Editor _owner )
1964 _this.navigation = this;
1965 new Xcls_navigationselmodel( _this );
1966 this.el = new Gtk.ColumnView( _this.navigationselmodel.el );
1969 this.last_selected_line = -1;
1970 this.selected_row = null;
1972 // set gobject values
1973 this.el.name = "editor-navigation";
1974 var child_2 = new Xcls_ColumnViewColumn31( _this );
1976 this.el.append_column( child_2.el );
1977 var child_3 = new Xcls_GestureClick40( _this );
1979 this.el.add_controller( child_3.el );
1982 // user defined functions
1983 public Gtk.Widget? getRowWidgetAt (double x, double y, out string pos) {
1986 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
1987 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
1992 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
1997 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2001 //GLib.debug("row number is %d", rn);
2002 //GLib.debug("click %d, %d", (int)x, (int)y);
2004 Graphene.Rect bounds;
2005 row.compute_bounds(this.el, out bounds);
2006 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2007 // (int)bounds.get_x(), (int)bounds.get_y(),
2008 // (int)bounds.get_width(), (int)bounds.get_height()
2010 var ypos = y - bounds.get_y();
2011 //GLib.debug("rel ypos = %d", (int)ypos);
2012 var rpos = 100.0 * (ypos / bounds.get_height());
2013 //GLib.debug("rel pos = %d %%", (int)rpos);
2018 } else if (rpos < 20) {
2023 public void show (Gee.ArrayList<Lsp.DocumentSymbol> syms) {
2025 if (!_this.navigation_holder.el.visible) {
2026 _this.navigation_holder.el.show();
2027 _this.paned.el.position =
2028 _this.paned.el.get_width() - 200;
2030 //_this.navliststore.el.remove_all();
2033 var ls = new GLib.ListStore(typeof(Lsp.DocumentSymbol));
2035 foreach(var sym in syms) {
2038 Lsp.DocumentSymbol.copyList(ls, _this.navliststore.el);
2039 //_this.navliststore.el.append(sym);
2040 this.last_selected_line = -1;
2041 GLib.Idle.add(() => {
2042 _this.navigationsort.collapseOnLoad();
2044 _this.buffer.el.get_iter_at_offset (
2045 out iter, _this.buffer.el.cursor_position);
2047 GLib.debug("idle update scroll %d, %d", iter.get_line(),
2048 iter.get_line_offset());
2049 this.updateSelectedLine(
2050 (uint)iter.get_line(),
2051 (uint)iter.get_line_offset()
2057 public int getRowAt (double x, double y, out string pos) {
2060 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
2061 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
2066 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
2071 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2076 while (cr.get_prev_sibling() != null) {
2078 cr = cr.get_prev_sibling();
2081 //GLib.debug("row number is %d", rn);
2082 //GLib.debug("click %d, %d", (int)x, (int)y);
2084 Graphene.Rect bounds;
2085 row.compute_bounds(this.el, out bounds);
2086 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2087 // (int)bounds.get_x(), (int)bounds.get_y(),
2088 // (int)bounds.get_width(), (int)bounds.get_height()
2090 var ypos = y - bounds.get_y();
2091 //GLib.debug("rel ypos = %d", (int)ypos);
2092 var rpos = 100.0 * (ypos / bounds.get_height());
2093 //GLib.debug("rel pos = %d %%", (int)rpos);
2098 } else if (rpos < 20) {
2103 public void updateSelectedLine (uint line, uint chr) {
2104 if (line == this.last_selected_line) {
2107 GLib.debug("select line %d", (int)line);
2108 this.last_selected_line = (int)line;
2112 var sym = _this.navliststore.symbolAtLine(line, chr);
2114 new_row = _this.navigationsort.getRowFromSymbol(sym);
2115 GLib.debug("select line %d - row found %d", (int)line, new_row);
2117 GLib.debug(" no symbol found at line %d", (int)line);
2120 if (this.selected_row != null) {
2121 GLib.debug(" remove selected row");
2122 this.selected_row.remove_css_class("selected-row");
2124 this.selected_row = null;
2126 this.el.scroll_to(new_row,null,Gtk.ListScrollFlags.NONE, null);
2127 var row = sym.get_data<Gtk.Widget>("widget");
2129 GLib.debug(" Add selected row");
2131 row.add_css_class("selected-row");
2132 this.selected_row = row;
2136 GLib.debug("could not find widget on row %d", new_row);
2144 public class Xcls_ColumnViewColumn31 : Object
2146 public Gtk.ColumnViewColumn el;
2147 private Editor _this;
2153 public Xcls_ColumnViewColumn31(Editor _owner )
2156 var child_1 = new Xcls_SignalListItemFactory32( _this );
2158 this.el = new Gtk.ColumnViewColumn( "Code Navigation", child_1.el );
2162 // set gobject values
2163 this.el.expand = true;
2166 // user defined functions
2168 public class Xcls_SignalListItemFactory32 : Object
2170 public Gtk.SignalListItemFactory el;
2171 private Editor _this;
2177 public Xcls_SignalListItemFactory32(Editor _owner )
2180 this.el = new Gtk.SignalListItemFactory();
2184 // set gobject values
2187 this.el.setup.connect( (listitem) => {
2189 var expand = new Gtk.TreeExpander();
2191 expand.set_indent_for_depth(true);
2192 expand.set_indent_for_icon(true);
2193 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2194 var icon = new Gtk.Image();
2195 var lbl = new Gtk.Label("");
2196 lbl.use_markup = true;
2197 lbl.ellipsize = Pango.EllipsizeMode.END;
2199 icon.margin_end = 4;
2200 lbl.justify = Gtk.Justification.LEFT;
2203 // listitem.activatable = true; ??
2207 expand.set_child(hbox);
2208 ((Gtk.ListItem)listitem).set_child(expand);
2211 this.el.bind.connect( (listitem) => {
2213 // GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name());
2215 //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2216 var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2219 var hbox = (Gtk.Box) expand.child;
2222 var img = (Gtk.Image) hbox.get_first_child();
2223 var lbl = (Gtk.Label) img.get_next_sibling();
2225 var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();
2226 var sym = (Lsp.DocumentSymbol) lr.get_item();
2228 sym.set_data<Gtk.Widget>("widget", expand.get_parent());
2229 expand.get_parent().get_parent().set_data<Lsp.DocumentSymbol>("symbol", sym);
2231 //GLib.debug("save sym on %s", expand.get_parent().get_parent().get_type().name());
2233 //GLib.debug("got %d children for %s" , (int)sym.children.get_n_items(), sym.name);
2235 expand.set_hide_expander( sym.children.get_n_items() < 1);
2236 expand.set_list_row(lr);
2237 //this.in_bind = true;
2238 // default is to expand
2240 //this.in_bind = false;
2242 sym.bind_property("symbol_icon",
2244 GLib.BindingFlags.SYNC_CREATE);
2246 hbox.css_classes = { sym.symbol_icon };
2248 sym.bind_property("name",
2250 GLib.BindingFlags.SYNC_CREATE);
2251 // should be better?- --line no?
2252 sym.bind_property("tooltip",
2253 lbl, "tooltip_markup",
2254 GLib.BindingFlags.SYNC_CREATE);
2260 // user defined functions
2264 public class Xcls_navigationselmodel : Object
2266 public Gtk.NoSelection el;
2267 private Editor _this;
2273 public Xcls_navigationselmodel(Editor _owner )
2276 _this.navigationselmodel = this;
2277 new Xcls_navigationsort( _this );
2278 this.el = new Gtk.NoSelection( _this.navigationsort.el );
2282 // set gobject values
2285 // user defined functions
2287 public class Xcls_navigationsort : Object
2289 public Gtk.SortListModel el;
2290 private Editor _this;
2296 public Xcls_navigationsort(Editor _owner )
2299 _this.navigationsort = this;
2300 var child_1 = new Xcls_TreeListModel35( _this );
2302 var child_2 = new Xcls_TreeListRowSorter37( _this );
2304 this.el = new Gtk.SortListModel( child_1.el, child_2.el );
2308 // set gobject values
2311 // user defined functions
2312 public void collapseOnLoad () {
2313 for (var i=0;i < this.el.get_n_items(); i++) {
2314 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2315 var sym = (Lsp.DocumentSymbol)tr.get_item();
2317 case Lsp.SymbolKind.Enum:
2318 tr.expanded = false;
2321 //tr.expanded = true;
2330 public int getRowFromSymbol (Lsp.DocumentSymbol sym) {
2332 for (var i=0;i < this.el.get_n_items(); i++) {
2333 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2335 if (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {
2341 public Lsp.DocumentSymbol? getSymbolAt (uint row) {
2343 var tr = (Gtk.TreeListRow)this.el.get_item(row);
2345 var a = tr.get_item();;
2346 GLib.debug("get_item (2) = %s", a.get_type().name());
2349 return (Lsp.DocumentSymbol)tr.get_item();
2353 public class Xcls_TreeListModel35 : Object
2355 public Gtk.TreeListModel el;
2356 private Editor _this;
2362 public Xcls_TreeListModel35(Editor _owner )
2365 new Xcls_navliststore( _this );
2366 this.el = new Gtk.TreeListModel( _this.navliststore.el, false, true, (item) => {
2368 return ((Lsp.DocumentSymbol)item).children;
2374 // set gobject values
2377 this.el.items_changed.connect( (position, removed, added) => {
2378 GLib.debug("tree item changed %d , %d , %d",(int) position, (int)removed, (int) added);
2382 //var sym = (Lsp.DocumentSymbol) this.el.get_item(position);
2383 var row = this.el.get_row(position);
2385 GLib.debug("got %s", row.get_item().get_type().name());
2391 // user defined functions
2393 public class Xcls_navliststore : Object
2395 public GLib.ListStore el;
2396 private Editor _this;
2402 public Xcls_navliststore(Editor _owner )
2405 _this.navliststore = this;
2406 this.el = new GLib.ListStore( typeof(Lsp.DocumentSymbol) );
2410 // set gobject values
2413 // user defined functions
2414 public Lsp.DocumentSymbol? symbolAtLine (uint line, uint chr) {
2417 for(var i = 0; i < this.el.get_n_items();i++) {
2418 var el = (Lsp.DocumentSymbol)this.el.get_item(i);
2419 //GLib.debug("Check sym %s : %d-%d",
2420 // el.name , (int)el.range.start.line,
2421 // (int)el.range.end.line
2423 var ret = el.containsLine(line,chr);
2435 public class Xcls_TreeListRowSorter37 : Object
2437 public Gtk.TreeListRowSorter el;
2438 private Editor _this;
2444 public Xcls_TreeListRowSorter37(Editor _owner )
2447 var child_1 = new Xcls_StringSorter38( _this );
2449 this.el = new Gtk.TreeListRowSorter( child_1.el );
2453 // set gobject values
2456 // user defined functions
2458 public class Xcls_StringSorter38 : Object
2460 public Gtk.StringSorter el;
2461 private Editor _this;
2467 public Xcls_StringSorter38(Editor _owner )
2470 var child_1 = new Xcls_PropertyExpression39( _this );
2472 this.el = new Gtk.StringSorter( child_1.el );
2476 // set gobject values
2479 // user defined functions
2481 public class Xcls_PropertyExpression39 : Object
2483 public Gtk.PropertyExpression el;
2484 private Editor _this;
2490 public Xcls_PropertyExpression39(Editor _owner )
2493 this.el = new Gtk.PropertyExpression( typeof(Lsp.DocumentSymbol), null, "sort_key" );
2497 // set gobject values
2500 // user defined functions
2507 public class Xcls_GestureClick40 : Object
2509 public Gtk.GestureClick el;
2510 private Editor _this;
2516 public Xcls_GestureClick40(Editor _owner )
2519 this.el = new Gtk.GestureClick();
2523 // set gobject values
2526 this.el.pressed.connect( (n_press, x, y) => {
2528 var row = _this.navigation.getRowWidgetAt(x,y, out pos );
2531 GLib.debug("no row selected items");
2534 GLib.debug("got click on %s", row.get_type().name());
2535 //Lsp.DocumentSymbol
2536 var sym = row.get_data<Lsp.DocumentSymbol>("symbol");
2552 GLib.debug("goto line %d", (int)sym.range.start.line);
2553 _this.scroll_to_line((int)sym.range.start.line);
2555 _this.buffer.el.get_iter_at_line_offset(out iter,
2556 (int)sym.range.start.line,
2557 (int)sym.range.start.character
2559 _this.buffer.el.place_cursor(iter);
2564 // user defined functions