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) => {
555 GLib.debug("using quiery tooltip?");
556 var lbl = new Gtk.Label(this.el.tooltip_markup);
557 lbl.width_request = 500;
558 tooltip.set_custom(lbl);
564 // user defined functions
565 public void setHelp (Lsp.Hover? help) {
566 if (help == null || help.contents == null
567 || help.contents.size < 1) {
568 this.el.set_text("");
571 var sig = help.contents.get(0).value.split(" ");
573 for(var i =0; i < sig.length; i++) {
592 str += ("<span underline=\"single\" color=\"blue\" >" +
593 GLib.Markup.escape_text(sig[i])
598 if (help.contents.size > 1) {
599 this.el.tooltip_markup = GLib.Markup.escape_text(help.contents.get(1).value);
602 this.el.set_markup(string.joinv(" ",str));
607 public class Xcls_Scale6 : Object
610 private Editor _this;
616 public Xcls_Scale6(Editor _owner )
619 this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1);
623 // set gobject values
624 this.el.width_request = 150;
625 this.el.has_origin = true;
626 this.el.halign = Gtk.Align.END;
627 this.el.draw_value = false;
629 this.el.sensitive = true;
634 //this.el.set_range(6,30);
635 this.el.set_value ( BuilderApplication.settings.editor_font_size);
636 BuilderApplication.settings.editor_font_size_updated.connect(
638 BuilderApplication.settings.editor_font_size_inchange = true;
639 // GLib.debug("update range");
640 this.el.set_value (BuilderApplication.settings.editor_font_size);
641 BuilderApplication.settings.editor_font_size_inchange = false;
649 this.el.change_value.connect( (st, val ) => {
650 if (BuilderApplication.settings.editor_font_size_inchange) {
653 BuilderApplication.settings.editor_font_size = val;
658 // user defined functions
661 public class Xcls_close_btn : Object
663 public Gtk.Button el;
664 private Editor _this;
670 public Xcls_close_btn(Editor _owner )
673 _this.close_btn = this;
674 this.el = new Gtk.Button();
678 // set gobject values
679 this.el.icon_name = "window-close";
680 this.el.halign = Gtk.Align.END;
681 var child_1 = new Xcls_Image8( _this );
683 this.el.child = child_1.el;
686 this.el.clicked.connect( () => {
687 _this.saveContents();
688 _this.window.windowstate.switchState(WindowState.State.PREVIEW);
692 // user defined functions
694 public class Xcls_Image8 : Object
697 private Editor _this;
703 public Xcls_Image8(Editor _owner )
706 this.el = new Gtk.Image();
710 // set gobject values
711 this.el.icon_name = "window-close";
712 this.el.icon_size = Gtk.IconSize.NORMAL;
715 // user defined functions
720 public class Xcls_RightEditor : Object
722 public Gtk.ScrolledWindow el;
723 private Editor _this;
729 public Xcls_RightEditor(Editor _owner )
732 _this.RightEditor = this;
733 this.el = new Gtk.ScrolledWindow();
737 // set gobject values
738 this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
739 this.el.vexpand = true;
740 this.el.overlay_scrolling = false;
741 this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
742 new Xcls_view( _this );
743 this.el.child = _this.view.el;
746 // user defined functions
748 public class Xcls_view : Object
750 public GtkSource.View el;
751 private Editor _this;
755 public Gtk.CssProvider css;
758 public Xcls_view(Editor _owner )
762 this.el = new GtkSource.View();
767 // set gobject values
768 this.el.auto_indent = true;
769 this.el.indent_width = 4;
770 this.el.name = "editor-view";
771 this.el.show_line_marks = true;
772 this.el.insert_spaces_instead_of_tabs = true;
773 this.el.show_line_numbers = true;
774 this.el.hexpand = true;
775 this.el.vexpand = true;
776 this.el.has_tooltip = true;
777 this.el.css_classes = { "code-editor" };
778 this.el.tab_width = 4;
779 this.el.highlight_current_line = true;
780 new Xcls_buffer( _this );
781 this.el.buffer = _this.buffer.el;
782 new Xcls_keystate( _this );
783 this.el.add_controller( _this.keystate.el );
784 var child_3 = new Xcls_EventControllerScroll13( _this );
786 this.el.add_controller( child_3.el );
787 var child_4 = new Xcls_GestureClick14( _this );
789 this.el.add_controller( child_4.el );
793 this.el.completion.add_provider(
794 new Palete.CompletionProvider(_this)
797 // hover seems pretty useless.. - ??
798 //var hover = this.el.get_hover();
799 //hover.add_provider(new Palete.HoverProvider(_this));
801 //this.el.completion.unblock_interactive();
802 this.el.completion.select_on_show = true; // select
803 //this.el.completion.remember_info_visibility = true;
806 var attrs = new GtkSource.MarkAttributes();
808 attrs.set_icon_name ( "process-stop");
809 attrs.query_tooltip_text.connect(( mark) => {
810 GLib.debug("tooltip query? %s", mark.name);
811 return strdup( mark.name);
813 attrs.query_tooltip_markup.connect(( mark) => {
814 GLib.debug("tooltip query? %s", mark.name);
815 return strdup( mark.name);
817 this.el.set_mark_attributes ("ERR", attrs, 1);
821 var wattrs = new GtkSource.MarkAttributes();
822 wattrs.set_icon_name ( "process-stop");
823 wattrs.query_tooltip_text.connect(( mark) => {
824 GLib.debug("tooltip query? %s", mark.name);
825 return strdup(mark.name);
827 wattrs.query_tooltip_markup.connect(( mark) => {
828 GLib.debug("tooltip query? %s", mark.name);
829 return strdup(mark.name);
831 this.el.set_mark_attributes ("WARN", wattrs, 1);
835 var dattrs = new GtkSource.MarkAttributes();
837 dattrs.set_icon_name ( "process-stop");
839 dattrs.query_tooltip_text.connect(( mark) => {
840 GLib.debug("tooltip query? %s", mark.name);
841 return strdup(mark.name);
843 //dattrs.query_tooltip_markup.connect(( mark) => {
844 // GLib.debug("tooltip query? %s", mark.name);
845 // return strdup(mark.name);
847 this.el.set_mark_attributes ("DEPR", dattrs, 1);
850 this.el.get_space_drawer().set_matrix(null);
851 this.el.get_space_drawer().set_types_for_locations(
852 GtkSource.SpaceLocationFlags.ALL,
853 GtkSource.SpaceTypeFlags.ALL
855 this.el.get_space_drawer().set_enable_matrix(true);
858 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
860 //GLib.debug("query tooltip");
864 var yoff = (int) _this.RightEditor.el.vadjustment.value;
866 // I think this is problematic - if it's compliing / updating at same time as query.
868 //if (_this.window.statusbar_compile_spinner.el.spinning) {
872 this.el.get_iter_at_position (out iter, out trailing, x, y + yoff);
874 var l = iter.get_line();
878 // GLib.debug("query tooltip line %d", (int) l);
884 if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {
885 GLib.debug("line %d setting tip to %s", l, _this.buffer.marks.get(l));
886 tooltip.set_text(_this.buffer.marks.get(l).dup());
894 // this crashes?? - not sure why.
895 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
896 if (marks.is_empty()) {
897 marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
899 if (marks.is_empty()) {
900 marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
903 // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length());
905 marks.@foreach((m) => {
906 //GLib.debug("got mark %s", m.name);
907 str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name;
909 // true if there is a mark..
910 if (str.length > 0 ) {
911 tooltip.set_text( str );
913 return str.length > 0 ? true : false;
918 // user defined functions
919 public void load (string str) {
921 // show the help page for the active node..
922 //this.get('/Help').show();
924 // this.get('/BottomPane').el.set_current_page(0);
925 GLib.debug("load called - Reset undo buffer");
927 var buf = (GtkSource.Buffer)this.el.get_buffer();
928 buf.begin_irreversible_action();
929 buf.set_text(str, str.length);
930 buf.end_irreversible_action();
932 var lm = GtkSource.LanguageManager.get_default();
934 if (_this.file != null) {
935 lang = _this.file.language;
937 print("lang=%s, content_type = %s\n", lang, _this.file.content_type);
938 var lg = _this.file.content_type.length > 0 ?
939 lm.guess_language(_this.file.path, _this.file.content_type) :
940 lm.get_language(lang);
943 ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg);
945 this.el.insert_spaces_instead_of_tabs = true;
947 print("sourcelanguage = %s\n", lg.name);
948 if (lg.name == "Vala") {
949 this.el.insert_spaces_instead_of_tabs = false;
953 this.el.grab_focus();
954 _this.save_button.el.sensitive = false;
955 _this.last_error_counter = -1;
958 public class Xcls_buffer : Object
960 public GtkSource.Buffer el;
961 private Editor _this;
965 public int error_line;
966 public Gee.HashMap<int,string>? xmarks;
967 public bool check_queued;
970 public Xcls_buffer(Editor _owner )
974 this.el = new GtkSource.Buffer( null );
977 this.error_line = -1;
979 this.check_queued = false;
981 // set gobject values
982 this.el.highlight_syntax = true;
983 this.el.highlight_matching_brackets = true;
984 this.el.enable_undo = true;
989 buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
990 buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
991 buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
992 buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
993 buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
994 buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
995 buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
996 buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
999 buf.create_tag ("ERR", "weight", Pango.Weight.BOLD, "background", "pink");
1000 buf.create_tag ("WARN", "weight", Pango.Weight.BOLD, "background", "#ABF4EB");
1001 buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
1004 this.el.cursor_moved.connect( ( ) => {
1007 this.el.get_iter_at_offset (
1008 out iter, this.el.cursor_position);
1010 _this.navigation.updateSelectedLine(
1011 (uint)iter.get_line(),
1012 (uint)iter.get_line_offset()
1014 this.showHelp(iter);
1017 this.el.changed.connect( () => {
1020 _this.save_button.el.sensitive = true;
1021 print("EDITOR CHANGED");
1026 // this.get('/LeftPanel.model').changed( str , false);
1031 // user defined functions
1032 public bool OLDhighlightErrorsJson (string type, Json.Object obj) {
1035 this.el.get_bounds (out start, out end);
1037 this.el.remove_source_marks (start, end, type);
1038 GLib.debug("highlight errors");
1040 // we should highlight other types of errors..
1042 if (!obj.has_member(type)) {
1043 GLib.debug("Return has no errors\n");
1047 if (_this.window.windowstate.state != WindowState.State.CODEONLY
1049 _this.window.windowstate.state != WindowState.State.CODE
1051 GLib.debug("windowstate != CODEONLY?");
1056 //this.marks = new Gee.HashMap<int,string>();
1057 var err = obj.get_object_member(type);
1059 if (_this.file == null) {
1060 GLib.debug("file is null?");
1064 var valafn = _this.file.path;
1066 if (_this.file.xtype != "PlainFile") {
1070 var regex = new Regex("\\.bjs$");
1071 // should not happen
1072 valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
1073 } catch (GLib.RegexError e) {
1080 if (!err.has_member(valafn)) {
1081 GLib.debug("File path has no errors");
1085 var lines = err.get_object_member(valafn);
1088 if (obj.has_member("line_offset")) { // ?? why??
1089 offset = (int)obj.get_int_member("line_offset") + 1;
1093 var tlines = this.el.get_line_count () +1;
1095 if (_this.prop != null) {
1097 tlines = _this.prop.end_line + 1;
1098 offset = _this.prop.start_line + 1;
1104 lines.foreach_member((obj, line, node) => {
1107 // print("get inter\n");
1108 var eline = int.parse(line) - offset;
1109 GLib.debug("GOT ERROR on line %s -- converted to %d (offset = %d)\n", line,eline, offset);
1112 if (eline > tlines || eline < 0) {
1117 this.el.get_iter_at_line( out iter, eline);
1118 //print("mark line\n");
1120 var ar = lines.get_array_member(line);
1121 for (var i = 0 ; i < ar.get_length(); i++) {
1122 if (ar.get_string_element(i) == "Success") {
1125 msg += (msg.length > 0) ? "\n" : "";
1126 msg += ar.get_string_element(i);
1131 msg = "Line: %d".printf(eline+1) + " " + msg;
1132 this.el.create_source_mark(msg, type, iter);
1133 GLib.debug("set line %d to %m", eline, msg);
1134 // this.marks.set(eline, msg);
1143 public bool checkSyntax () {
1146 var str = this.toString();
1149 if (this.error_line > 0) {
1152 this.el.get_bounds (out start, out end);
1154 this.el.remove_source_marks (start, end, null);
1156 if (str.length < 1) {
1157 print("checkSyntax - empty string?\n");
1162 if (_this.file.xtype == "PlainFile") {
1164 // assume it's gtk...
1165 var oldcode =_this.file.toSource();
1166 _this.file.setSource(str);
1167 BuilderApplication.showSpinner("appointment soon","document change pending");
1168 _this.file.getLanguageServer().document_change(_this.file);
1169 _this.file.getLanguageServer().queueDocumentSymbols(_this.file);
1170 _this.file.setSource(oldcode);
1176 if (_this.file == null) {
1184 GLib.debug("calling validate");
1185 // clear the buttons.
1186 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
1189 var oldcode = _this.prop.val;
1191 _this.prop.val = str;
1192 _this.node.updated_count++;
1193 _this.file.getLanguageServer().document_change(_this.file);
1194 _this.node.updated_count++;
1195 _this.prop.val = oldcode;
1198 //print("done mark line\n");
1200 return true; // at present allow saving - even if it's invalid..
1202 public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
1204 this.error_line = validate_res.size;
1206 if (this.error_line < 1) {
1209 var tlines = this.el.get_line_count ();
1211 var valiter = validate_res.map_iterator();
1212 while (valiter.next()) {
1214 // print("get inter\n");
1215 var eline = valiter.get_key();
1216 if (eline > tlines) {
1219 this.el.get_iter_at_line( out iter, eline);
1220 //print("mark line\n");
1221 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
1225 public string toString () {
1229 this.el.get_start_iter(out s);
1230 this.el.get_end_iter(out e);
1231 var ret = this.el.get_text(s,e,true);
1232 //print("TO STRING? " + ret);
1235 public void showHelp (Gtk.TextIter iter) {
1236 var back = iter.copy();
1237 back.backward_char();
1239 var forward = iter.copy();
1240 forward.forward_char();
1242 // what's the character at the iter?
1243 var str = back.get_text(iter);
1244 str += iter.get_text(forward);
1245 if (str.strip().length < 1) {
1248 var offset = iter.get_line_offset();
1249 var line = iter.get_line();
1250 if (_this.prop != null) {
1252 line += _this.prop.start_line ;
1253 // this is based on Gtk using tabs (hence 1/2 chars);
1254 offset += _this.node.node_pad.length;
1255 // javascript listeners are indented 2 more spaces.
1256 if (_this.prop.ptype == JsRender.NodePropType.LISTENER) {
1261 var ls = _this.file.getLanguageServer();
1263 _this.file, line, offset,
1266 var res = ls.hover.end(o );
1268 _this.helper.setHelp(res);
1269 } catch (GLib.Error e) {
1276 public class Xcls_keystate : Object
1278 public Gtk.EventControllerKey el;
1279 private Editor _this;
1283 public bool is_control;
1286 public Xcls_keystate(Editor _owner )
1289 _this.keystate = this;
1290 this.el = new Gtk.EventControllerKey();
1293 this.is_control = false;
1295 // set gobject values
1298 this.el.key_released.connect( (keyval, keycode, state) => {
1300 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1301 this.is_control = false;
1303 if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1304 GLib.debug("SAVE: ctrl-S pressed");
1305 _this.saveContents();
1309 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1310 GLib.debug("SAVE: ctrl-g pressed");
1311 _this.forwardSearch(true);
1314 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1315 GLib.debug("SAVE: ctrl-f pressed");
1316 _this.search_entry.el.grab_focus();
1317 _this.search_entry.el.select_region(0,-1);
1320 if (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1321 _this.view.el.show_completion();
1325 _this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);
1326 var line = iter.get_line();
1327 var offset = iter.get_line_offset();
1328 GLib.debug("line %d off %d", line ,offset);
1329 if (_this.prop != null) {
1330 line += _this.prop.start_line + 1; // i think..
1331 offset += 12; // should probably be 8 without namespaced
1332 GLib.debug("guess line %d off %d", line ,offset);
1334 //_this.view.el.show_completion();
1335 // print(event.key.keyval)
1342 this.el.key_pressed.connect( (keyval, keycode, state) => {
1344 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1345 this.is_control = true;
1351 // user defined functions
1354 public class Xcls_EventControllerScroll13 : Object
1356 public Gtk.EventControllerScroll el;
1357 private Editor _this;
1361 public double distance;
1364 public Xcls_EventControllerScroll13(Editor _owner )
1367 this.el = new Gtk.EventControllerScroll( Gtk.EventControllerScrollFlags.VERTICAL );
1370 this.distance = 0.0f;
1372 // set gobject values
1375 this.el.scroll.connect( (dx, dy) => {
1376 if (!_this.keystate.is_control) {
1379 //GLib.debug("scroll %f", dy);
1381 this.distance += dy;
1383 //GLib.debug("scroll %f / %f", dy, this.distance);
1385 if (this.distance < -1) {
1387 BuilderApplication.settings.editor_font_size ++;
1390 if (this.distance > 1) {
1391 BuilderApplication.settings.editor_font_size --;
1399 // user defined functions
1402 public class Xcls_GestureClick14 : Object
1404 public Gtk.GestureClick el;
1405 private Editor _this;
1411 public Xcls_GestureClick14(Editor _owner )
1414 this.el = new Gtk.GestureClick();
1418 // set gobject values
1421 this.el.pressed.connect( (n_press, x, y) => {
1423 int buffer_x, buffer_y;
1424 var gut = _this.view.el.get_gutter(Gtk.TextWindowType.LEFT);
1426 _this.view.el.window_to_buffer_coords (Gtk.TextWindowType.TEXT,
1427 (int)x - gut.get_width(), (int)y,
1428 out buffer_x, out buffer_y);
1429 _this.view.el.get_iter_at_location (out iter,
1430 buffer_x, buffer_y);;
1433 if (_this.buffer.el.iter_has_context_class(iter, "comment") ||
1434 _this.buffer.el.iter_has_context_class(iter, "string")
1438 _this.buffer.showHelp(iter);
1445 // user defined functions
1450 public class Xcls_Box15 : Object
1453 private Editor _this;
1459 public Xcls_Box15(Editor _owner )
1462 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1466 // set gobject values
1467 this.el.homogeneous = false;
1468 this.el.vexpand = false;
1469 new Xcls_search_entry( _this );
1470 this.el.append( _this.search_entry.el );
1471 new Xcls_search_results( _this );
1472 this.el.append( _this.search_results.el );
1473 new Xcls_nextBtn( _this );
1474 this.el.append( _this.nextBtn.el );
1475 new Xcls_backBtn( _this );
1476 this.el.append( _this.backBtn.el );
1477 var child_5 = new Xcls_MenuButton21( _this );
1479 this.el.append( child_5.el );
1482 // user defined functions
1484 public class Xcls_search_entry : Object
1486 public Gtk.SearchEntry el;
1487 private Editor _this;
1491 public Gtk.CssProvider css;
1494 public Xcls_search_entry(Editor _owner )
1497 _this.search_entry = this;
1498 this.el = new Gtk.SearchEntry();
1502 // set gobject values
1503 this.el.name = "editor-search-entry";
1504 this.el.hexpand = true;
1505 this.el.placeholder_text = "Press enter to search";
1506 this.el.search_delay = 3;
1507 var child_1 = new Xcls_EventControllerKey17( _this );
1509 this.el.add_controller( child_1.el );
1512 this.el.search_changed.connect( ( ) => {
1514 _this.search(_this.search_entry.el.text);
1515 _this.search_results.updateResults();
1517 GLib.Timeout.add_seconds(1,() => {
1518 _this.search_results.updateResults();
1524 // user defined functions
1525 public void forwardSearch (bool change_focus) {
1528 _this.forwardSearch(change_focus);
1532 switch(_this.windowstate.state) {
1533 case WindowState.State.CODEONLY:
1534 //case WindowState.State.CODE:
1535 // search the code being edited..
1536 _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1539 case WindowState.State.PREVIEW:
1540 if (_this.windowstate.file.xtype == "Gtk") {
1541 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1543 _this.windowstate.window_rooview.forwardSearch(change_focus);
1552 public class Xcls_EventControllerKey17 : Object
1554 public Gtk.EventControllerKey el;
1555 private Editor _this;
1561 public Xcls_EventControllerKey17(Editor _owner )
1564 this.el = new Gtk.EventControllerKey();
1568 // set gobject values
1571 this.el.key_pressed.connect( (keyval, keycode, state) => {
1573 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1574 GLib.debug("SAVE: ctrl-g pressed");
1575 _this.forwardSearch(true);
1580 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1581 _this.forwardSearch(true);
1587 // print(event.key.keyval)
1593 // user defined functions
1597 public class Xcls_search_results : Object
1599 public Gtk.Label el;
1600 private Editor _this;
1606 public Xcls_search_results(Editor _owner )
1609 _this.search_results = this;
1610 this.el = new Gtk.Label( "No Results" );
1614 // set gobject values
1615 this.el.margin_end = 4;
1616 this.el.margin_start = 4;
1619 // user defined functions
1620 public void updateResults () {
1621 this.el.visible = true;
1623 var res = _this.searchcontext.get_occurrences_count();
1625 _this.search_results.el.label = "??? Matches";
1629 _this.nextBtn.el.sensitive = false;
1630 _this.backBtn.el.sensitive = false;
1633 _this.search_results.el.label = "%d Matches".printf(res);
1634 _this.nextBtn.el.sensitive = true;
1635 _this.backBtn.el.sensitive = true;
1638 _this.search_results.el.label = "No Matches";
1643 public class Xcls_nextBtn : Object
1645 public Gtk.Button el;
1646 private Editor _this;
1650 public bool always_show_image;
1653 public Xcls_nextBtn(Editor _owner )
1656 _this.nextBtn = this;
1657 this.el = new Gtk.Button();
1660 this.always_show_image = true;
1662 // set gobject values
1663 this.el.icon_name = "go-down";
1664 this.el.sensitive = false;
1667 this.el.clicked.connect( (event) => {
1669 _this.forwardSearch(true);
1675 // user defined functions
1678 public class Xcls_backBtn : Object
1680 public Gtk.Button el;
1681 private Editor _this;
1685 public bool always_show_image;
1688 public Xcls_backBtn(Editor _owner )
1691 _this.backBtn = this;
1692 this.el = new Gtk.Button();
1695 this.always_show_image = true;
1697 // set gobject values
1698 this.el.icon_name = "go-up";
1699 this.el.sensitive = false;
1702 this.el.clicked.connect( (event) => {
1704 _this.backSearch(true);
1709 // user defined functions
1712 public class Xcls_MenuButton21 : Object
1714 public Gtk.MenuButton el;
1715 private Editor _this;
1719 public bool always_show_image;
1722 public Xcls_MenuButton21(Editor _owner )
1725 this.el = new Gtk.MenuButton();
1728 this.always_show_image = true;
1730 // set gobject values
1731 this.el.icon_name = "emblem-system";
1732 this.el.always_show_arrow = true;
1733 new Xcls_search_settings( _this );
1734 this.el.popover = _this.search_settings.el;
1737 // user defined functions
1739 public class Xcls_search_settings : Object
1741 public Gtk.Popover el;
1742 private Editor _this;
1748 public Xcls_search_settings(Editor _owner )
1751 _this.search_settings = this;
1752 this.el = new Gtk.Popover();
1756 // set gobject values
1757 var child_1 = new Xcls_Box23( _this );
1759 this.el.child = child_1.el;
1762 // user defined functions
1764 public class Xcls_Box23 : Object
1767 private Editor _this;
1773 public Xcls_Box23(Editor _owner )
1776 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1780 // set gobject values
1781 new Xcls_case_sensitive( _this );
1782 this.el.append( _this.case_sensitive.el );
1783 new Xcls_regex( _this );
1784 this.el.append( _this.regex.el );
1785 new Xcls_multiline( _this );
1786 this.el.append( _this.multiline.el );
1789 // user defined functions
1791 public class Xcls_case_sensitive : Object
1793 public Gtk.CheckButton el;
1794 private Editor _this;
1800 public Xcls_case_sensitive(Editor _owner )
1803 _this.case_sensitive = this;
1804 this.el = new Gtk.CheckButton();
1808 // set gobject values
1809 this.el.label = "Case Sensitive";
1818 // user defined functions
1821 public class Xcls_regex : Object
1823 public Gtk.CheckButton el;
1824 private Editor _this;
1830 public Xcls_regex(Editor _owner )
1834 this.el = new Gtk.CheckButton();
1838 // set gobject values
1839 this.el.label = "Regex";
1848 // user defined functions
1851 public class Xcls_multiline : Object
1853 public Gtk.CheckButton el;
1854 private Editor _this;
1860 public Xcls_multiline(Editor _owner )
1863 _this.multiline = this;
1864 this.el = new Gtk.CheckButton();
1868 // set gobject values
1869 this.el.label = "Multi-line (add \\n)";
1872 // user defined functions
1880 public class Xcls_navigation_holder : Object
1883 private Editor _this;
1889 public Xcls_navigation_holder(Editor _owner )
1892 _this.navigation_holder = this;
1893 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1897 // set gobject values
1898 this.el.width_request = 120;
1899 this.el.hexpand = true;
1900 this.el.vexpand = true;
1901 this.el.visible = false;
1902 var child_1 = new Xcls_Box28( _this );
1904 this.el.append( child_1.el );
1905 new Xcls_navigationwindow( _this );
1906 this.el.append( _this.navigationwindow.el );
1909 // user defined functions
1911 public class Xcls_Box28 : Object
1914 private Editor _this;
1920 public Xcls_Box28(Editor _owner )
1923 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1927 // set gobject values
1930 // user defined functions
1933 public class Xcls_navigationwindow : Object
1935 public Gtk.ScrolledWindow el;
1936 private Editor _this;
1942 public Xcls_navigationwindow(Editor _owner )
1945 _this.navigationwindow = this;
1946 this.el = new Gtk.ScrolledWindow();
1950 // set gobject values
1951 this.el.hexpand = true;
1952 this.el.vexpand = true;
1953 this.el.visible = true;
1954 new Xcls_navigation( _this );
1955 this.el.child = _this.navigation.el;
1958 // user defined functions
1960 public class Xcls_navigation : Object
1962 public Gtk.ColumnView el;
1963 private Editor _this;
1967 public int last_selected_line;
1968 public Gtk.Widget? selected_row;
1971 public Xcls_navigation(Editor _owner )
1974 _this.navigation = this;
1975 new Xcls_navigationselmodel( _this );
1976 this.el = new Gtk.ColumnView( _this.navigationselmodel.el );
1979 this.last_selected_line = -1;
1980 this.selected_row = null;
1982 // set gobject values
1983 this.el.name = "editor-navigation";
1984 var child_2 = new Xcls_ColumnViewColumn31( _this );
1986 this.el.append_column( child_2.el );
1987 var child_3 = new Xcls_GestureClick40( _this );
1989 this.el.add_controller( child_3.el );
1992 // user defined functions
1993 public Gtk.Widget? getRowWidgetAt (double x, double y, out string pos) {
1996 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
1997 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
2002 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
2007 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2011 //GLib.debug("row number is %d", rn);
2012 //GLib.debug("click %d, %d", (int)x, (int)y);
2014 Graphene.Rect bounds;
2015 row.compute_bounds(this.el, out bounds);
2016 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2017 // (int)bounds.get_x(), (int)bounds.get_y(),
2018 // (int)bounds.get_width(), (int)bounds.get_height()
2020 var ypos = y - bounds.get_y();
2021 //GLib.debug("rel ypos = %d", (int)ypos);
2022 var rpos = 100.0 * (ypos / bounds.get_height());
2023 //GLib.debug("rel pos = %d %%", (int)rpos);
2028 } else if (rpos < 20) {
2033 public void show (Gee.ArrayList<Lsp.DocumentSymbol> syms) {
2035 if (!_this.navigation_holder.el.visible) {
2036 _this.navigation_holder.el.show();
2037 _this.paned.el.position =
2038 _this.paned.el.get_width() - 200;
2040 //_this.navliststore.el.remove_all();
2043 var ls = new GLib.ListStore(typeof(Lsp.DocumentSymbol));
2045 foreach(var sym in syms) {
2048 Lsp.DocumentSymbol.copyList(ls, _this.navliststore.el);
2049 //_this.navliststore.el.append(sym);
2050 this.last_selected_line = -1;
2051 GLib.Idle.add(() => {
2052 _this.navigationsort.collapseOnLoad();
2054 _this.buffer.el.get_iter_at_offset (
2055 out iter, _this.buffer.el.cursor_position);
2057 GLib.debug("idle update scroll %d, %d", iter.get_line(),
2058 iter.get_line_offset());
2059 this.updateSelectedLine(
2060 (uint)iter.get_line(),
2061 (uint)iter.get_line_offset()
2067 public int getRowAt (double x, double y, out string pos) {
2070 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
2071 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
2076 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
2081 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2086 while (cr.get_prev_sibling() != null) {
2088 cr = cr.get_prev_sibling();
2091 //GLib.debug("row number is %d", rn);
2092 //GLib.debug("click %d, %d", (int)x, (int)y);
2094 Graphene.Rect bounds;
2095 row.compute_bounds(this.el, out bounds);
2096 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2097 // (int)bounds.get_x(), (int)bounds.get_y(),
2098 // (int)bounds.get_width(), (int)bounds.get_height()
2100 var ypos = y - bounds.get_y();
2101 //GLib.debug("rel ypos = %d", (int)ypos);
2102 var rpos = 100.0 * (ypos / bounds.get_height());
2103 //GLib.debug("rel pos = %d %%", (int)rpos);
2108 } else if (rpos < 20) {
2113 public void updateSelectedLine (uint line, uint chr) {
2114 if (line == this.last_selected_line) {
2117 GLib.debug("select line %d", (int)line);
2118 this.last_selected_line = (int)line;
2122 var sym = _this.navliststore.symbolAtLine(line, chr);
2124 new_row = _this.navigationsort.getRowFromSymbol(sym);
2125 GLib.debug("select line %d - row found %d", (int)line, new_row);
2127 GLib.debug(" no symbol found at line %d", (int)line);
2130 if (this.selected_row != null) {
2131 GLib.debug(" remove selected row");
2132 this.selected_row.remove_css_class("selected-row");
2134 this.selected_row = null;
2136 this.el.scroll_to(new_row,null,Gtk.ListScrollFlags.NONE, null);
2137 var row = sym.get_data<Gtk.Widget>("widget");
2139 GLib.debug(" Add selected row");
2141 row.add_css_class("selected-row");
2142 this.selected_row = row;
2146 GLib.debug("could not find widget on row %d", new_row);
2154 public class Xcls_ColumnViewColumn31 : Object
2156 public Gtk.ColumnViewColumn el;
2157 private Editor _this;
2163 public Xcls_ColumnViewColumn31(Editor _owner )
2166 var child_1 = new Xcls_SignalListItemFactory32( _this );
2168 this.el = new Gtk.ColumnViewColumn( "Code Navigation", child_1.el );
2172 // set gobject values
2173 this.el.expand = true;
2176 // user defined functions
2178 public class Xcls_SignalListItemFactory32 : Object
2180 public Gtk.SignalListItemFactory el;
2181 private Editor _this;
2187 public Xcls_SignalListItemFactory32(Editor _owner )
2190 this.el = new Gtk.SignalListItemFactory();
2194 // set gobject values
2197 this.el.setup.connect( (listitem) => {
2199 var expand = new Gtk.TreeExpander();
2201 expand.set_indent_for_depth(true);
2202 expand.set_indent_for_icon(true);
2203 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2204 var icon = new Gtk.Image();
2205 var lbl = new Gtk.Label("");
2206 lbl.use_markup = true;
2207 lbl.ellipsize = Pango.EllipsizeMode.END;
2209 icon.margin_end = 4;
2210 lbl.justify = Gtk.Justification.LEFT;
2213 // listitem.activatable = true; ??
2217 expand.set_child(hbox);
2218 ((Gtk.ListItem)listitem).set_child(expand);
2221 this.el.bind.connect( (listitem) => {
2223 // GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name());
2225 //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2226 var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2229 var hbox = (Gtk.Box) expand.child;
2232 var img = (Gtk.Image) hbox.get_first_child();
2233 var lbl = (Gtk.Label) img.get_next_sibling();
2235 var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();
2236 var sym = (Lsp.DocumentSymbol) lr.get_item();
2238 sym.set_data<Gtk.Widget>("widget", expand.get_parent());
2239 expand.get_parent().get_parent().set_data<Lsp.DocumentSymbol>("symbol", sym);
2241 //GLib.debug("save sym on %s", expand.get_parent().get_parent().get_type().name());
2243 //GLib.debug("got %d children for %s" , (int)sym.children.get_n_items(), sym.name);
2245 expand.set_hide_expander( sym.children.get_n_items() < 1);
2246 expand.set_list_row(lr);
2247 //this.in_bind = true;
2248 // default is to expand
2250 //this.in_bind = false;
2252 sym.bind_property("symbol_icon",
2254 GLib.BindingFlags.SYNC_CREATE);
2256 hbox.css_classes = { sym.symbol_icon };
2258 sym.bind_property("name",
2260 GLib.BindingFlags.SYNC_CREATE);
2261 // should be better?- --line no?
2262 sym.bind_property("tooltip",
2263 lbl, "tooltip_markup",
2264 GLib.BindingFlags.SYNC_CREATE);
2270 // user defined functions
2274 public class Xcls_navigationselmodel : Object
2276 public Gtk.NoSelection el;
2277 private Editor _this;
2283 public Xcls_navigationselmodel(Editor _owner )
2286 _this.navigationselmodel = this;
2287 new Xcls_navigationsort( _this );
2288 this.el = new Gtk.NoSelection( _this.navigationsort.el );
2292 // set gobject values
2295 // user defined functions
2297 public class Xcls_navigationsort : Object
2299 public Gtk.SortListModel el;
2300 private Editor _this;
2306 public Xcls_navigationsort(Editor _owner )
2309 _this.navigationsort = this;
2310 var child_1 = new Xcls_TreeListModel35( _this );
2312 var child_2 = new Xcls_TreeListRowSorter37( _this );
2314 this.el = new Gtk.SortListModel( child_1.el, child_2.el );
2318 // set gobject values
2321 // user defined functions
2322 public void collapseOnLoad () {
2323 for (var i=0;i < this.el.get_n_items(); i++) {
2324 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2325 var sym = (Lsp.DocumentSymbol)tr.get_item();
2327 case Lsp.SymbolKind.Enum:
2328 tr.expanded = false;
2331 //tr.expanded = true;
2340 public int getRowFromSymbol (Lsp.DocumentSymbol sym) {
2342 for (var i=0;i < this.el.get_n_items(); i++) {
2343 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2345 if (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {
2351 public Lsp.DocumentSymbol? getSymbolAt (uint row) {
2353 var tr = (Gtk.TreeListRow)this.el.get_item(row);
2355 var a = tr.get_item();;
2356 GLib.debug("get_item (2) = %s", a.get_type().name());
2359 return (Lsp.DocumentSymbol)tr.get_item();
2363 public class Xcls_TreeListModel35 : Object
2365 public Gtk.TreeListModel el;
2366 private Editor _this;
2372 public Xcls_TreeListModel35(Editor _owner )
2375 new Xcls_navliststore( _this );
2376 this.el = new Gtk.TreeListModel( _this.navliststore.el, false, true, (item) => {
2378 return ((Lsp.DocumentSymbol)item).children;
2384 // set gobject values
2387 this.el.items_changed.connect( (position, removed, added) => {
2388 GLib.debug("tree item changed %d , %d , %d",(int) position, (int)removed, (int) added);
2392 //var sym = (Lsp.DocumentSymbol) this.el.get_item(position);
2393 var row = this.el.get_row(position);
2395 GLib.debug("got %s", row.get_item().get_type().name());
2401 // user defined functions
2403 public class Xcls_navliststore : Object
2405 public GLib.ListStore el;
2406 private Editor _this;
2412 public Xcls_navliststore(Editor _owner )
2415 _this.navliststore = this;
2416 this.el = new GLib.ListStore( typeof(Lsp.DocumentSymbol) );
2420 // set gobject values
2423 // user defined functions
2424 public Lsp.DocumentSymbol? symbolAtLine (uint line, uint chr) {
2427 for(var i = 0; i < this.el.get_n_items();i++) {
2428 var el = (Lsp.DocumentSymbol)this.el.get_item(i);
2429 //GLib.debug("Check sym %s : %d-%d",
2430 // el.name , (int)el.range.start.line,
2431 // (int)el.range.end.line
2433 var ret = el.containsLine(line,chr);
2445 public class Xcls_TreeListRowSorter37 : Object
2447 public Gtk.TreeListRowSorter el;
2448 private Editor _this;
2454 public Xcls_TreeListRowSorter37(Editor _owner )
2457 var child_1 = new Xcls_StringSorter38( _this );
2459 this.el = new Gtk.TreeListRowSorter( child_1.el );
2463 // set gobject values
2466 // user defined functions
2468 public class Xcls_StringSorter38 : Object
2470 public Gtk.StringSorter el;
2471 private Editor _this;
2477 public Xcls_StringSorter38(Editor _owner )
2480 var child_1 = new Xcls_PropertyExpression39( _this );
2482 this.el = new Gtk.StringSorter( child_1.el );
2486 // set gobject values
2489 // user defined functions
2491 public class Xcls_PropertyExpression39 : Object
2493 public Gtk.PropertyExpression el;
2494 private Editor _this;
2500 public Xcls_PropertyExpression39(Editor _owner )
2503 this.el = new Gtk.PropertyExpression( typeof(Lsp.DocumentSymbol), null, "sort_key" );
2507 // set gobject values
2510 // user defined functions
2517 public class Xcls_GestureClick40 : Object
2519 public Gtk.GestureClick el;
2520 private Editor _this;
2526 public Xcls_GestureClick40(Editor _owner )
2529 this.el = new Gtk.GestureClick();
2533 // set gobject values
2536 this.el.pressed.connect( (n_press, x, y) => {
2538 var row = _this.navigation.getRowWidgetAt(x,y, out pos );
2541 GLib.debug("no row selected items");
2544 GLib.debug("got click on %s", row.get_type().name());
2545 //Lsp.DocumentSymbol
2546 var sym = row.get_data<Lsp.DocumentSymbol>("symbol");
2562 GLib.debug("goto line %d", (int)sym.range.start.line);
2563 _this.scroll_to_line((int)sym.range.start.line);
2565 _this.buffer.el.get_iter_at_line_offset(out iter,
2566 (int)sym.range.start.line,
2567 (int)sym.range.start.character
2569 _this.buffer.el.place_cursor(iter);
2574 // user defined functions