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);
562 this.el.activate_link.connect( (uri) => {
563 GLib.debug("got uri %s", uri);
568 // user defined functions
569 public void setHelp (Lsp.Hover? help) {
570 if (help == null || help.contents == null
571 || help.contents.size < 1) {
572 this.el.set_text("");
575 var sig = help.contents.get(0).value.split(" ");
577 for(var i =0; i < sig.length; i++) {
596 str += ("<a href=\"" + GLib.Markup.escape_text(sig[i]) + "\">" +
597 GLib.Markup.escape_text(sig[i])
602 if (help.contents.size > 1) {
603 this.el.tooltip_markup = GLib.Markup.escape_text(help.contents.get(1).value);
605 this.el.tooltip_markup = GLib.Markup.escape_text(help.contents.get(0).value);
607 this.el.set_markup(string.joinv(" ",str));
612 public class Xcls_Scale6 : Object
615 private Editor _this;
621 public Xcls_Scale6(Editor _owner )
624 this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1);
628 // set gobject values
629 this.el.width_request = 150;
630 this.el.has_origin = true;
631 this.el.halign = Gtk.Align.END;
632 this.el.draw_value = false;
634 this.el.sensitive = true;
639 //this.el.set_range(6,30);
640 this.el.set_value ( BuilderApplication.settings.editor_font_size);
641 BuilderApplication.settings.editor_font_size_updated.connect(
643 BuilderApplication.settings.editor_font_size_inchange = true;
644 // GLib.debug("update range");
645 this.el.set_value (BuilderApplication.settings.editor_font_size);
646 BuilderApplication.settings.editor_font_size_inchange = false;
654 this.el.change_value.connect( (st, val ) => {
655 if (BuilderApplication.settings.editor_font_size_inchange) {
658 BuilderApplication.settings.editor_font_size = val;
663 // user defined functions
666 public class Xcls_close_btn : Object
668 public Gtk.Button el;
669 private Editor _this;
675 public Xcls_close_btn(Editor _owner )
678 _this.close_btn = this;
679 this.el = new Gtk.Button();
683 // set gobject values
684 this.el.icon_name = "window-close";
685 this.el.halign = Gtk.Align.END;
686 var child_1 = new Xcls_Image8( _this );
688 this.el.child = child_1.el;
691 this.el.clicked.connect( () => {
692 _this.saveContents();
693 _this.window.windowstate.switchState(WindowState.State.PREVIEW);
697 // user defined functions
699 public class Xcls_Image8 : Object
702 private Editor _this;
708 public Xcls_Image8(Editor _owner )
711 this.el = new Gtk.Image();
715 // set gobject values
716 this.el.icon_name = "window-close";
717 this.el.icon_size = Gtk.IconSize.NORMAL;
720 // user defined functions
725 public class Xcls_RightEditor : Object
727 public Gtk.ScrolledWindow el;
728 private Editor _this;
734 public Xcls_RightEditor(Editor _owner )
737 _this.RightEditor = this;
738 this.el = new Gtk.ScrolledWindow();
742 // set gobject values
743 this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
744 this.el.vexpand = true;
745 this.el.overlay_scrolling = false;
746 this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
747 new Xcls_view( _this );
748 this.el.child = _this.view.el;
751 // user defined functions
753 public class Xcls_view : Object
755 public GtkSource.View el;
756 private Editor _this;
760 public Gtk.CssProvider css;
763 public Xcls_view(Editor _owner )
767 this.el = new GtkSource.View();
772 // set gobject values
773 this.el.auto_indent = true;
774 this.el.indent_width = 4;
775 this.el.name = "editor-view";
776 this.el.show_line_marks = true;
777 this.el.insert_spaces_instead_of_tabs = true;
778 this.el.show_line_numbers = true;
779 this.el.hexpand = true;
780 this.el.vexpand = true;
781 this.el.has_tooltip = true;
782 this.el.css_classes = { "code-editor" };
783 this.el.tab_width = 4;
784 this.el.highlight_current_line = true;
785 new Xcls_buffer( _this );
786 this.el.buffer = _this.buffer.el;
787 new Xcls_keystate( _this );
788 this.el.add_controller( _this.keystate.el );
789 var child_3 = new Xcls_EventControllerScroll13( _this );
791 this.el.add_controller( child_3.el );
792 var child_4 = new Xcls_GestureClick14( _this );
794 this.el.add_controller( child_4.el );
798 this.el.completion.add_provider(
799 new Palete.CompletionProvider(_this)
802 // hover seems pretty useless.. - ??
803 //var hover = this.el.get_hover();
804 //hover.add_provider(new Palete.HoverProvider(_this));
806 //this.el.completion.unblock_interactive();
807 this.el.completion.select_on_show = true; // select
808 //this.el.completion.remember_info_visibility = true;
811 var attrs = new GtkSource.MarkAttributes();
813 attrs.set_icon_name ( "process-stop");
814 attrs.query_tooltip_text.connect(( mark) => {
815 GLib.debug("tooltip query? %s", mark.name);
816 return strdup( mark.name);
818 attrs.query_tooltip_markup.connect(( mark) => {
819 GLib.debug("tooltip query? %s", mark.name);
820 return strdup( mark.name);
822 this.el.set_mark_attributes ("ERR", attrs, 1);
826 var wattrs = new GtkSource.MarkAttributes();
827 wattrs.set_icon_name ( "process-stop");
828 wattrs.query_tooltip_text.connect(( mark) => {
829 GLib.debug("tooltip query? %s", mark.name);
830 return strdup(mark.name);
832 wattrs.query_tooltip_markup.connect(( mark) => {
833 GLib.debug("tooltip query? %s", mark.name);
834 return strdup(mark.name);
836 this.el.set_mark_attributes ("WARN", wattrs, 1);
840 var dattrs = new GtkSource.MarkAttributes();
842 dattrs.set_icon_name ( "process-stop");
844 dattrs.query_tooltip_text.connect(( mark) => {
845 GLib.debug("tooltip query? %s", mark.name);
846 return strdup(mark.name);
848 //dattrs.query_tooltip_markup.connect(( mark) => {
849 // GLib.debug("tooltip query? %s", mark.name);
850 // return strdup(mark.name);
852 this.el.set_mark_attributes ("DEPR", dattrs, 1);
855 this.el.get_space_drawer().set_matrix(null);
856 this.el.get_space_drawer().set_types_for_locations(
857 GtkSource.SpaceLocationFlags.ALL,
858 GtkSource.SpaceTypeFlags.ALL
860 this.el.get_space_drawer().set_enable_matrix(true);
863 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
865 //GLib.debug("query tooltip");
869 var yoff = (int) _this.RightEditor.el.vadjustment.value;
871 // I think this is problematic - if it's compliing / updating at same time as query.
873 //if (_this.window.statusbar_compile_spinner.el.spinning) {
877 this.el.get_iter_at_position (out iter, out trailing, x, y + yoff);
879 var l = iter.get_line();
883 // GLib.debug("query tooltip line %d", (int) l);
889 if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {
890 GLib.debug("line %d setting tip to %s", l, _this.buffer.marks.get(l));
891 tooltip.set_text(_this.buffer.marks.get(l).dup());
899 // this crashes?? - not sure why.
900 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
901 if (marks.is_empty()) {
902 marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
904 if (marks.is_empty()) {
905 marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
908 // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length());
910 marks.@foreach((m) => {
911 //GLib.debug("got mark %s", m.name);
912 str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name;
914 // true if there is a mark..
915 if (str.length > 0 ) {
916 tooltip.set_text( str );
918 return str.length > 0 ? true : false;
923 // user defined functions
924 public void load (string str) {
926 // show the help page for the active node..
927 //this.get('/Help').show();
929 // this.get('/BottomPane').el.set_current_page(0);
930 GLib.debug("load called - Reset undo buffer");
932 var buf = (GtkSource.Buffer)this.el.get_buffer();
933 buf.begin_irreversible_action();
934 buf.set_text(str, str.length);
935 buf.end_irreversible_action();
937 var lm = GtkSource.LanguageManager.get_default();
939 if (_this.file != null) {
940 lang = _this.file.language;
942 print("lang=%s, content_type = %s\n", lang, _this.file.content_type);
943 var lg = _this.file.content_type.length > 0 ?
944 lm.guess_language(_this.file.path, _this.file.content_type) :
945 lm.get_language(lang);
948 ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg);
950 this.el.insert_spaces_instead_of_tabs = true;
952 print("sourcelanguage = %s\n", lg.name);
953 if (lg.name == "Vala") {
954 this.el.insert_spaces_instead_of_tabs = false;
958 this.el.grab_focus();
959 _this.save_button.el.sensitive = false;
960 _this.last_error_counter = -1;
963 public class Xcls_buffer : Object
965 public GtkSource.Buffer el;
966 private Editor _this;
970 public int error_line;
971 public Gee.HashMap<int,string>? xmarks;
972 public bool check_queued;
975 public Xcls_buffer(Editor _owner )
979 this.el = new GtkSource.Buffer( null );
982 this.error_line = -1;
984 this.check_queued = false;
986 // set gobject values
987 this.el.highlight_syntax = true;
988 this.el.highlight_matching_brackets = true;
989 this.el.enable_undo = true;
994 buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
995 buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
996 buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
997 buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
998 buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
999 buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
1000 buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
1001 buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
1004 buf.create_tag ("ERR", "weight", Pango.Weight.BOLD, "background", "pink");
1005 buf.create_tag ("WARN", "weight", Pango.Weight.BOLD, "background", "#ABF4EB");
1006 buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
1009 this.el.cursor_moved.connect( ( ) => {
1012 this.el.get_iter_at_offset (
1013 out iter, this.el.cursor_position);
1015 _this.navigation.updateSelectedLine(
1016 (uint)iter.get_line(),
1017 (uint)iter.get_line_offset()
1019 this.showHelp(iter);
1022 this.el.changed.connect( () => {
1025 _this.save_button.el.sensitive = true;
1026 print("EDITOR CHANGED");
1031 // this.get('/LeftPanel.model').changed( str , false);
1036 // user defined functions
1037 public bool OLDhighlightErrorsJson (string type, Json.Object obj) {
1040 this.el.get_bounds (out start, out end);
1042 this.el.remove_source_marks (start, end, type);
1043 GLib.debug("highlight errors");
1045 // we should highlight other types of errors..
1047 if (!obj.has_member(type)) {
1048 GLib.debug("Return has no errors\n");
1052 if (_this.window.windowstate.state != WindowState.State.CODEONLY
1054 _this.window.windowstate.state != WindowState.State.CODE
1056 GLib.debug("windowstate != CODEONLY?");
1061 //this.marks = new Gee.HashMap<int,string>();
1062 var err = obj.get_object_member(type);
1064 if (_this.file == null) {
1065 GLib.debug("file is null?");
1069 var valafn = _this.file.path;
1071 if (_this.file.xtype != "PlainFile") {
1075 var regex = new Regex("\\.bjs$");
1076 // should not happen
1077 valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
1078 } catch (GLib.RegexError e) {
1085 if (!err.has_member(valafn)) {
1086 GLib.debug("File path has no errors");
1090 var lines = err.get_object_member(valafn);
1093 if (obj.has_member("line_offset")) { // ?? why??
1094 offset = (int)obj.get_int_member("line_offset") + 1;
1098 var tlines = this.el.get_line_count () +1;
1100 if (_this.prop != null) {
1102 tlines = _this.prop.end_line + 1;
1103 offset = _this.prop.start_line + 1;
1109 lines.foreach_member((obj, line, node) => {
1112 // print("get inter\n");
1113 var eline = int.parse(line) - offset;
1114 GLib.debug("GOT ERROR on line %s -- converted to %d (offset = %d)\n", line,eline, offset);
1117 if (eline > tlines || eline < 0) {
1122 this.el.get_iter_at_line( out iter, eline);
1123 //print("mark line\n");
1125 var ar = lines.get_array_member(line);
1126 for (var i = 0 ; i < ar.get_length(); i++) {
1127 if (ar.get_string_element(i) == "Success") {
1130 msg += (msg.length > 0) ? "\n" : "";
1131 msg += ar.get_string_element(i);
1136 msg = "Line: %d".printf(eline+1) + " " + msg;
1137 this.el.create_source_mark(msg, type, iter);
1138 GLib.debug("set line %d to %m", eline, msg);
1139 // this.marks.set(eline, msg);
1148 public bool checkSyntax () {
1151 var str = this.toString();
1154 if (this.error_line > 0) {
1157 this.el.get_bounds (out start, out end);
1159 this.el.remove_source_marks (start, end, null);
1161 if (str.length < 1) {
1162 print("checkSyntax - empty string?\n");
1167 if (_this.file.xtype == "PlainFile") {
1169 // assume it's gtk...
1170 var oldcode =_this.file.toSource();
1171 _this.file.setSource(str);
1172 BuilderApplication.showSpinner("appointment soon","document change pending");
1173 _this.file.getLanguageServer().document_change(_this.file);
1174 _this.file.getLanguageServer().queueDocumentSymbols(_this.file);
1175 _this.file.setSource(oldcode);
1181 if (_this.file == null) {
1189 GLib.debug("calling validate");
1190 // clear the buttons.
1191 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
1194 var oldcode = _this.prop.val;
1196 _this.prop.val = str;
1197 _this.node.updated_count++;
1198 _this.file.getLanguageServer().document_change(_this.file);
1199 _this.node.updated_count++;
1200 _this.prop.val = oldcode;
1203 //print("done mark line\n");
1205 return true; // at present allow saving - even if it's invalid..
1207 public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
1209 this.error_line = validate_res.size;
1211 if (this.error_line < 1) {
1214 var tlines = this.el.get_line_count ();
1216 var valiter = validate_res.map_iterator();
1217 while (valiter.next()) {
1219 // print("get inter\n");
1220 var eline = valiter.get_key();
1221 if (eline > tlines) {
1224 this.el.get_iter_at_line( out iter, eline);
1225 //print("mark line\n");
1226 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
1230 public string toString () {
1234 this.el.get_start_iter(out s);
1235 this.el.get_end_iter(out e);
1236 var ret = this.el.get_text(s,e,true);
1237 //print("TO STRING? " + ret);
1240 public void showHelp (Gtk.TextIter iter) {
1241 var back = iter.copy();
1242 back.backward_char();
1244 var forward = iter.copy();
1245 forward.forward_char();
1247 // what's the character at the iter?
1248 var str = back.get_text(iter);
1249 str += iter.get_text(forward);
1250 if (str.strip().length < 1) {
1253 var offset = iter.get_line_offset();
1254 var line = iter.get_line();
1255 if (_this.prop != null) {
1257 line += _this.prop.start_line ;
1258 // this is based on Gtk using tabs (hence 1/2 chars);
1259 offset += _this.node.node_pad.length;
1260 // javascript listeners are indented 2 more spaces.
1261 if (_this.prop.ptype == JsRender.NodePropType.LISTENER) {
1266 var ls = _this.file.getLanguageServer();
1268 _this.file, line, offset,
1271 var res = ls.hover.end(o );
1273 _this.helper.setHelp(res);
1274 } catch (GLib.Error e) {
1281 public class Xcls_keystate : Object
1283 public Gtk.EventControllerKey el;
1284 private Editor _this;
1288 public bool is_control;
1291 public Xcls_keystate(Editor _owner )
1294 _this.keystate = this;
1295 this.el = new Gtk.EventControllerKey();
1298 this.is_control = false;
1300 // set gobject values
1303 this.el.key_released.connect( (keyval, keycode, state) => {
1305 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1306 this.is_control = false;
1308 if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1309 GLib.debug("SAVE: ctrl-S pressed");
1310 _this.saveContents();
1314 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1315 GLib.debug("SAVE: ctrl-g pressed");
1316 _this.forwardSearch(true);
1319 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1320 GLib.debug("SAVE: ctrl-f pressed");
1321 _this.search_entry.el.grab_focus();
1322 _this.search_entry.el.select_region(0,-1);
1325 if (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1326 _this.view.el.show_completion();
1330 _this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);
1331 var line = iter.get_line();
1332 var offset = iter.get_line_offset();
1333 GLib.debug("line %d off %d", line ,offset);
1334 if (_this.prop != null) {
1335 line += _this.prop.start_line + 1; // i think..
1336 offset += 12; // should probably be 8 without namespaced
1337 GLib.debug("guess line %d off %d", line ,offset);
1339 //_this.view.el.show_completion();
1340 // print(event.key.keyval)
1347 this.el.key_pressed.connect( (keyval, keycode, state) => {
1349 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1350 this.is_control = true;
1356 // user defined functions
1359 public class Xcls_EventControllerScroll13 : Object
1361 public Gtk.EventControllerScroll el;
1362 private Editor _this;
1366 public double distance;
1369 public Xcls_EventControllerScroll13(Editor _owner )
1372 this.el = new Gtk.EventControllerScroll( Gtk.EventControllerScrollFlags.VERTICAL );
1375 this.distance = 0.0f;
1377 // set gobject values
1380 this.el.scroll.connect( (dx, dy) => {
1381 if (!_this.keystate.is_control) {
1384 //GLib.debug("scroll %f", dy);
1386 this.distance += dy;
1388 //GLib.debug("scroll %f / %f", dy, this.distance);
1390 if (this.distance < -1) {
1392 BuilderApplication.settings.editor_font_size ++;
1395 if (this.distance > 1) {
1396 BuilderApplication.settings.editor_font_size --;
1404 // user defined functions
1407 public class Xcls_GestureClick14 : Object
1409 public Gtk.GestureClick el;
1410 private Editor _this;
1416 public Xcls_GestureClick14(Editor _owner )
1419 this.el = new Gtk.GestureClick();
1423 // set gobject values
1426 this.el.pressed.connect( (n_press, x, y) => {
1428 int buffer_x, buffer_y;
1429 var gut = _this.view.el.get_gutter(Gtk.TextWindowType.LEFT);
1431 _this.view.el.window_to_buffer_coords (Gtk.TextWindowType.TEXT,
1432 (int)x - gut.get_width(), (int)y,
1433 out buffer_x, out buffer_y);
1434 _this.view.el.get_iter_at_location (out iter,
1435 buffer_x, buffer_y);;
1438 if (_this.buffer.el.iter_has_context_class(iter, "comment") ||
1439 _this.buffer.el.iter_has_context_class(iter, "string")
1443 _this.buffer.showHelp(iter);
1450 // user defined functions
1455 public class Xcls_Box15 : Object
1458 private Editor _this;
1464 public Xcls_Box15(Editor _owner )
1467 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1471 // set gobject values
1472 this.el.homogeneous = false;
1473 this.el.vexpand = false;
1474 new Xcls_search_entry( _this );
1475 this.el.append( _this.search_entry.el );
1476 new Xcls_search_results( _this );
1477 this.el.append( _this.search_results.el );
1478 new Xcls_nextBtn( _this );
1479 this.el.append( _this.nextBtn.el );
1480 new Xcls_backBtn( _this );
1481 this.el.append( _this.backBtn.el );
1482 var child_5 = new Xcls_MenuButton21( _this );
1484 this.el.append( child_5.el );
1487 // user defined functions
1489 public class Xcls_search_entry : Object
1491 public Gtk.SearchEntry el;
1492 private Editor _this;
1496 public Gtk.CssProvider css;
1499 public Xcls_search_entry(Editor _owner )
1502 _this.search_entry = this;
1503 this.el = new Gtk.SearchEntry();
1507 // set gobject values
1508 this.el.name = "editor-search-entry";
1509 this.el.hexpand = true;
1510 this.el.placeholder_text = "Press enter to search";
1511 this.el.search_delay = 3;
1512 var child_1 = new Xcls_EventControllerKey17( _this );
1514 this.el.add_controller( child_1.el );
1517 this.el.search_changed.connect( ( ) => {
1519 _this.search(_this.search_entry.el.text);
1520 _this.search_results.updateResults();
1522 GLib.Timeout.add_seconds(1,() => {
1523 _this.search_results.updateResults();
1529 // user defined functions
1530 public void forwardSearch (bool change_focus) {
1533 _this.forwardSearch(change_focus);
1537 switch(_this.windowstate.state) {
1538 case WindowState.State.CODEONLY:
1539 //case WindowState.State.CODE:
1540 // search the code being edited..
1541 _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1544 case WindowState.State.PREVIEW:
1545 if (_this.windowstate.file.xtype == "Gtk") {
1546 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1548 _this.windowstate.window_rooview.forwardSearch(change_focus);
1557 public class Xcls_EventControllerKey17 : Object
1559 public Gtk.EventControllerKey el;
1560 private Editor _this;
1566 public Xcls_EventControllerKey17(Editor _owner )
1569 this.el = new Gtk.EventControllerKey();
1573 // set gobject values
1576 this.el.key_pressed.connect( (keyval, keycode, state) => {
1578 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1579 GLib.debug("SAVE: ctrl-g pressed");
1580 _this.forwardSearch(true);
1585 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1586 _this.forwardSearch(true);
1592 // print(event.key.keyval)
1598 // user defined functions
1602 public class Xcls_search_results : Object
1604 public Gtk.Label el;
1605 private Editor _this;
1611 public Xcls_search_results(Editor _owner )
1614 _this.search_results = this;
1615 this.el = new Gtk.Label( "No Results" );
1619 // set gobject values
1620 this.el.margin_end = 4;
1621 this.el.margin_start = 4;
1624 // user defined functions
1625 public void updateResults () {
1626 this.el.visible = true;
1628 var res = _this.searchcontext.get_occurrences_count();
1630 _this.search_results.el.label = "??? Matches";
1634 _this.nextBtn.el.sensitive = false;
1635 _this.backBtn.el.sensitive = false;
1638 _this.search_results.el.label = "%d Matches".printf(res);
1639 _this.nextBtn.el.sensitive = true;
1640 _this.backBtn.el.sensitive = true;
1643 _this.search_results.el.label = "No Matches";
1648 public class Xcls_nextBtn : Object
1650 public Gtk.Button el;
1651 private Editor _this;
1655 public bool always_show_image;
1658 public Xcls_nextBtn(Editor _owner )
1661 _this.nextBtn = this;
1662 this.el = new Gtk.Button();
1665 this.always_show_image = true;
1667 // set gobject values
1668 this.el.icon_name = "go-down";
1669 this.el.sensitive = false;
1672 this.el.clicked.connect( (event) => {
1674 _this.forwardSearch(true);
1680 // user defined functions
1683 public class Xcls_backBtn : Object
1685 public Gtk.Button el;
1686 private Editor _this;
1690 public bool always_show_image;
1693 public Xcls_backBtn(Editor _owner )
1696 _this.backBtn = this;
1697 this.el = new Gtk.Button();
1700 this.always_show_image = true;
1702 // set gobject values
1703 this.el.icon_name = "go-up";
1704 this.el.sensitive = false;
1707 this.el.clicked.connect( (event) => {
1709 _this.backSearch(true);
1714 // user defined functions
1717 public class Xcls_MenuButton21 : Object
1719 public Gtk.MenuButton el;
1720 private Editor _this;
1724 public bool always_show_image;
1727 public Xcls_MenuButton21(Editor _owner )
1730 this.el = new Gtk.MenuButton();
1733 this.always_show_image = true;
1735 // set gobject values
1736 this.el.icon_name = "emblem-system";
1737 this.el.always_show_arrow = true;
1738 new Xcls_search_settings( _this );
1739 this.el.popover = _this.search_settings.el;
1742 // user defined functions
1744 public class Xcls_search_settings : Object
1746 public Gtk.Popover el;
1747 private Editor _this;
1753 public Xcls_search_settings(Editor _owner )
1756 _this.search_settings = this;
1757 this.el = new Gtk.Popover();
1761 // set gobject values
1762 var child_1 = new Xcls_Box23( _this );
1764 this.el.child = child_1.el;
1767 // user defined functions
1769 public class Xcls_Box23 : Object
1772 private Editor _this;
1778 public Xcls_Box23(Editor _owner )
1781 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1785 // set gobject values
1786 new Xcls_case_sensitive( _this );
1787 this.el.append( _this.case_sensitive.el );
1788 new Xcls_regex( _this );
1789 this.el.append( _this.regex.el );
1790 new Xcls_multiline( _this );
1791 this.el.append( _this.multiline.el );
1794 // user defined functions
1796 public class Xcls_case_sensitive : Object
1798 public Gtk.CheckButton el;
1799 private Editor _this;
1805 public Xcls_case_sensitive(Editor _owner )
1808 _this.case_sensitive = this;
1809 this.el = new Gtk.CheckButton();
1813 // set gobject values
1814 this.el.label = "Case Sensitive";
1823 // user defined functions
1826 public class Xcls_regex : Object
1828 public Gtk.CheckButton el;
1829 private Editor _this;
1835 public Xcls_regex(Editor _owner )
1839 this.el = new Gtk.CheckButton();
1843 // set gobject values
1844 this.el.label = "Regex";
1853 // user defined functions
1856 public class Xcls_multiline : Object
1858 public Gtk.CheckButton el;
1859 private Editor _this;
1865 public Xcls_multiline(Editor _owner )
1868 _this.multiline = this;
1869 this.el = new Gtk.CheckButton();
1873 // set gobject values
1874 this.el.label = "Multi-line (add \\n)";
1877 // user defined functions
1885 public class Xcls_navigation_holder : Object
1888 private Editor _this;
1894 public Xcls_navigation_holder(Editor _owner )
1897 _this.navigation_holder = this;
1898 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1902 // set gobject values
1903 this.el.width_request = 120;
1904 this.el.hexpand = true;
1905 this.el.vexpand = true;
1906 this.el.visible = false;
1907 var child_1 = new Xcls_Box28( _this );
1909 this.el.append( child_1.el );
1910 new Xcls_navigationwindow( _this );
1911 this.el.append( _this.navigationwindow.el );
1914 // user defined functions
1916 public class Xcls_Box28 : Object
1919 private Editor _this;
1925 public Xcls_Box28(Editor _owner )
1928 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1932 // set gobject values
1935 // user defined functions
1938 public class Xcls_navigationwindow : Object
1940 public Gtk.ScrolledWindow el;
1941 private Editor _this;
1947 public Xcls_navigationwindow(Editor _owner )
1950 _this.navigationwindow = this;
1951 this.el = new Gtk.ScrolledWindow();
1955 // set gobject values
1956 this.el.hexpand = true;
1957 this.el.vexpand = true;
1958 this.el.visible = true;
1959 new Xcls_navigation( _this );
1960 this.el.child = _this.navigation.el;
1963 // user defined functions
1965 public class Xcls_navigation : Object
1967 public Gtk.ColumnView el;
1968 private Editor _this;
1972 public int last_selected_line;
1973 public Gtk.Widget? selected_row;
1976 public Xcls_navigation(Editor _owner )
1979 _this.navigation = this;
1980 new Xcls_navigationselmodel( _this );
1981 this.el = new Gtk.ColumnView( _this.navigationselmodel.el );
1984 this.last_selected_line = -1;
1985 this.selected_row = null;
1987 // set gobject values
1988 this.el.name = "editor-navigation";
1989 var child_2 = new Xcls_ColumnViewColumn31( _this );
1991 this.el.append_column( child_2.el );
1992 var child_3 = new Xcls_GestureClick40( _this );
1994 this.el.add_controller( child_3.el );
1997 // user defined functions
1998 public Gtk.Widget? getRowWidgetAt (double x, double y, out string pos) {
2001 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
2002 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
2007 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
2012 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2016 //GLib.debug("row number is %d", rn);
2017 //GLib.debug("click %d, %d", (int)x, (int)y);
2019 Graphene.Rect bounds;
2020 row.compute_bounds(this.el, out bounds);
2021 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2022 // (int)bounds.get_x(), (int)bounds.get_y(),
2023 // (int)bounds.get_width(), (int)bounds.get_height()
2025 var ypos = y - bounds.get_y();
2026 //GLib.debug("rel ypos = %d", (int)ypos);
2027 var rpos = 100.0 * (ypos / bounds.get_height());
2028 //GLib.debug("rel pos = %d %%", (int)rpos);
2033 } else if (rpos < 20) {
2038 public void show (Gee.ArrayList<Lsp.DocumentSymbol> syms) {
2040 if (!_this.navigation_holder.el.visible) {
2041 _this.navigation_holder.el.show();
2042 _this.paned.el.position =
2043 _this.paned.el.get_width() - 200;
2045 //_this.navliststore.el.remove_all();
2048 var ls = new GLib.ListStore(typeof(Lsp.DocumentSymbol));
2050 foreach(var sym in syms) {
2053 Lsp.DocumentSymbol.copyList(ls, _this.navliststore.el);
2054 //_this.navliststore.el.append(sym);
2055 this.last_selected_line = -1;
2056 GLib.Idle.add(() => {
2057 _this.navigationsort.collapseOnLoad();
2059 _this.buffer.el.get_iter_at_offset (
2060 out iter, _this.buffer.el.cursor_position);
2062 GLib.debug("idle update scroll %d, %d", iter.get_line(),
2063 iter.get_line_offset());
2064 this.updateSelectedLine(
2065 (uint)iter.get_line(),
2066 (uint)iter.get_line_offset()
2072 public int getRowAt (double x, double y, out string pos) {
2075 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
2076 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
2081 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
2086 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2091 while (cr.get_prev_sibling() != null) {
2093 cr = cr.get_prev_sibling();
2096 //GLib.debug("row number is %d", rn);
2097 //GLib.debug("click %d, %d", (int)x, (int)y);
2099 Graphene.Rect bounds;
2100 row.compute_bounds(this.el, out bounds);
2101 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2102 // (int)bounds.get_x(), (int)bounds.get_y(),
2103 // (int)bounds.get_width(), (int)bounds.get_height()
2105 var ypos = y - bounds.get_y();
2106 //GLib.debug("rel ypos = %d", (int)ypos);
2107 var rpos = 100.0 * (ypos / bounds.get_height());
2108 //GLib.debug("rel pos = %d %%", (int)rpos);
2113 } else if (rpos < 20) {
2118 public void updateSelectedLine (uint line, uint chr) {
2119 if (line == this.last_selected_line) {
2122 GLib.debug("select line %d", (int)line);
2123 this.last_selected_line = (int)line;
2127 var sym = _this.navliststore.symbolAtLine(line, chr);
2129 new_row = _this.navigationsort.getRowFromSymbol(sym);
2130 GLib.debug("select line %d - row found %d", (int)line, new_row);
2132 GLib.debug(" no symbol found at line %d", (int)line);
2135 if (this.selected_row != null) {
2136 GLib.debug(" remove selected row");
2137 this.selected_row.remove_css_class("selected-row");
2139 this.selected_row = null;
2141 this.el.scroll_to(new_row,null,Gtk.ListScrollFlags.NONE, null);
2142 var row = sym.get_data<Gtk.Widget>("widget");
2144 GLib.debug(" Add selected row");
2146 row.add_css_class("selected-row");
2147 this.selected_row = row;
2151 GLib.debug("could not find widget on row %d", new_row);
2159 public class Xcls_ColumnViewColumn31 : Object
2161 public Gtk.ColumnViewColumn el;
2162 private Editor _this;
2168 public Xcls_ColumnViewColumn31(Editor _owner )
2171 var child_1 = new Xcls_SignalListItemFactory32( _this );
2173 this.el = new Gtk.ColumnViewColumn( "Code Navigation", child_1.el );
2177 // set gobject values
2178 this.el.expand = true;
2181 // user defined functions
2183 public class Xcls_SignalListItemFactory32 : Object
2185 public Gtk.SignalListItemFactory el;
2186 private Editor _this;
2192 public Xcls_SignalListItemFactory32(Editor _owner )
2195 this.el = new Gtk.SignalListItemFactory();
2199 // set gobject values
2202 this.el.setup.connect( (listitem) => {
2204 var expand = new Gtk.TreeExpander();
2206 expand.set_indent_for_depth(true);
2207 expand.set_indent_for_icon(true);
2208 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2209 var icon = new Gtk.Image();
2210 var lbl = new Gtk.Label("");
2211 lbl.use_markup = true;
2212 lbl.ellipsize = Pango.EllipsizeMode.END;
2214 icon.margin_end = 4;
2215 lbl.justify = Gtk.Justification.LEFT;
2218 // listitem.activatable = true; ??
2222 expand.set_child(hbox);
2223 ((Gtk.ListItem)listitem).set_child(expand);
2226 this.el.bind.connect( (listitem) => {
2228 // GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name());
2230 //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2231 var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2234 var hbox = (Gtk.Box) expand.child;
2237 var img = (Gtk.Image) hbox.get_first_child();
2238 var lbl = (Gtk.Label) img.get_next_sibling();
2240 var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();
2241 var sym = (Lsp.DocumentSymbol) lr.get_item();
2243 sym.set_data<Gtk.Widget>("widget", expand.get_parent());
2244 expand.get_parent().get_parent().set_data<Lsp.DocumentSymbol>("symbol", sym);
2246 //GLib.debug("save sym on %s", expand.get_parent().get_parent().get_type().name());
2248 //GLib.debug("got %d children for %s" , (int)sym.children.get_n_items(), sym.name);
2250 expand.set_hide_expander( sym.children.get_n_items() < 1);
2251 expand.set_list_row(lr);
2252 //this.in_bind = true;
2253 // default is to expand
2255 //this.in_bind = false;
2257 sym.bind_property("symbol_icon",
2259 GLib.BindingFlags.SYNC_CREATE);
2261 hbox.css_classes = { sym.symbol_icon };
2263 sym.bind_property("name",
2265 GLib.BindingFlags.SYNC_CREATE);
2266 // should be better?- --line no?
2267 sym.bind_property("tooltip",
2268 lbl, "tooltip_markup",
2269 GLib.BindingFlags.SYNC_CREATE);
2275 // user defined functions
2279 public class Xcls_navigationselmodel : Object
2281 public Gtk.NoSelection el;
2282 private Editor _this;
2288 public Xcls_navigationselmodel(Editor _owner )
2291 _this.navigationselmodel = this;
2292 new Xcls_navigationsort( _this );
2293 this.el = new Gtk.NoSelection( _this.navigationsort.el );
2297 // set gobject values
2300 // user defined functions
2302 public class Xcls_navigationsort : Object
2304 public Gtk.SortListModel el;
2305 private Editor _this;
2311 public Xcls_navigationsort(Editor _owner )
2314 _this.navigationsort = this;
2315 var child_1 = new Xcls_TreeListModel35( _this );
2317 var child_2 = new Xcls_TreeListRowSorter37( _this );
2319 this.el = new Gtk.SortListModel( child_1.el, child_2.el );
2323 // set gobject values
2326 // user defined functions
2327 public void collapseOnLoad () {
2328 for (var i=0;i < this.el.get_n_items(); i++) {
2329 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2330 var sym = (Lsp.DocumentSymbol)tr.get_item();
2332 case Lsp.SymbolKind.Enum:
2333 tr.expanded = false;
2336 //tr.expanded = true;
2345 public int getRowFromSymbol (Lsp.DocumentSymbol sym) {
2347 for (var i=0;i < this.el.get_n_items(); i++) {
2348 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2350 if (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {
2356 public Lsp.DocumentSymbol? getSymbolAt (uint row) {
2358 var tr = (Gtk.TreeListRow)this.el.get_item(row);
2360 var a = tr.get_item();;
2361 GLib.debug("get_item (2) = %s", a.get_type().name());
2364 return (Lsp.DocumentSymbol)tr.get_item();
2368 public class Xcls_TreeListModel35 : Object
2370 public Gtk.TreeListModel el;
2371 private Editor _this;
2377 public Xcls_TreeListModel35(Editor _owner )
2380 new Xcls_navliststore( _this );
2381 this.el = new Gtk.TreeListModel( _this.navliststore.el, false, true, (item) => {
2383 return ((Lsp.DocumentSymbol)item).children;
2389 // set gobject values
2392 this.el.items_changed.connect( (position, removed, added) => {
2393 GLib.debug("tree item changed %d , %d , %d",(int) position, (int)removed, (int) added);
2397 //var sym = (Lsp.DocumentSymbol) this.el.get_item(position);
2398 var row = this.el.get_row(position);
2400 GLib.debug("got %s", row.get_item().get_type().name());
2406 // user defined functions
2408 public class Xcls_navliststore : Object
2410 public GLib.ListStore el;
2411 private Editor _this;
2417 public Xcls_navliststore(Editor _owner )
2420 _this.navliststore = this;
2421 this.el = new GLib.ListStore( typeof(Lsp.DocumentSymbol) );
2425 // set gobject values
2428 // user defined functions
2429 public Lsp.DocumentSymbol? symbolAtLine (uint line, uint chr) {
2432 for(var i = 0; i < this.el.get_n_items();i++) {
2433 var el = (Lsp.DocumentSymbol)this.el.get_item(i);
2434 //GLib.debug("Check sym %s : %d-%d",
2435 // el.name , (int)el.range.start.line,
2436 // (int)el.range.end.line
2438 var ret = el.containsLine(line,chr);
2450 public class Xcls_TreeListRowSorter37 : Object
2452 public Gtk.TreeListRowSorter el;
2453 private Editor _this;
2459 public Xcls_TreeListRowSorter37(Editor _owner )
2462 var child_1 = new Xcls_StringSorter38( _this );
2464 this.el = new Gtk.TreeListRowSorter( child_1.el );
2468 // set gobject values
2471 // user defined functions
2473 public class Xcls_StringSorter38 : Object
2475 public Gtk.StringSorter el;
2476 private Editor _this;
2482 public Xcls_StringSorter38(Editor _owner )
2485 var child_1 = new Xcls_PropertyExpression39( _this );
2487 this.el = new Gtk.StringSorter( child_1.el );
2491 // set gobject values
2494 // user defined functions
2496 public class Xcls_PropertyExpression39 : Object
2498 public Gtk.PropertyExpression el;
2499 private Editor _this;
2505 public Xcls_PropertyExpression39(Editor _owner )
2508 this.el = new Gtk.PropertyExpression( typeof(Lsp.DocumentSymbol), null, "sort_key" );
2512 // set gobject values
2515 // user defined functions
2522 public class Xcls_GestureClick40 : Object
2524 public Gtk.GestureClick el;
2525 private Editor _this;
2531 public Xcls_GestureClick40(Editor _owner )
2534 this.el = new Gtk.GestureClick();
2538 // set gobject values
2541 this.el.pressed.connect( (n_press, x, y) => {
2543 var row = _this.navigation.getRowWidgetAt(x,y, out pos );
2546 GLib.debug("no row selected items");
2549 GLib.debug("got click on %s", row.get_type().name());
2550 //Lsp.DocumentSymbol
2551 var sym = row.get_data<Lsp.DocumentSymbol>("symbol");
2567 GLib.debug("goto line %d", (int)sym.range.start.line);
2568 _this.scroll_to_line((int)sym.range.start.line);
2570 _this.buffer.el.get_iter_at_line_offset(out iter,
2571 (int)sym.range.start.line,
2572 (int)sym.range.start.character
2574 _this.buffer.el.place_cursor(iter);
2579 // user defined functions