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 var lbl = new Gtk.Label(this.el.tooltip_markup);
556 lbl.width_request = 700;
557 tooltip.set_custom(lbl);
563 // user defined functions
564 public void setHelp (Lsp.Hover? help) {
565 if (help == null || help.contents == null
566 || help.contents.size < 1) {
567 this.el.set_text("");
570 var sig = help.contents.get(0).value.split(" ");
572 for(var i =0; i < sig.length; i++) {
591 str += ("<span underline=\"single\" color=\"blue\" >" +
592 GLib.Markup.escape_text(sig[i])
597 if (help.contents.size > 1) {
598 this.el.tooltip_markup = GLib.Markup.escape_text(help.contents.get(1).value);
601 this.el.set_markup(string.joinv(" ",str));
606 public class Xcls_Scale6 : Object
609 private Editor _this;
615 public Xcls_Scale6(Editor _owner )
618 this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1);
622 // set gobject values
623 this.el.width_request = 150;
624 this.el.has_origin = true;
625 this.el.halign = Gtk.Align.END;
626 this.el.draw_value = false;
628 this.el.sensitive = true;
633 //this.el.set_range(6,30);
634 this.el.set_value ( BuilderApplication.settings.editor_font_size);
635 BuilderApplication.settings.editor_font_size_updated.connect(
637 BuilderApplication.settings.editor_font_size_inchange = true;
638 // GLib.debug("update range");
639 this.el.set_value (BuilderApplication.settings.editor_font_size);
640 BuilderApplication.settings.editor_font_size_inchange = false;
648 this.el.change_value.connect( (st, val ) => {
649 if (BuilderApplication.settings.editor_font_size_inchange) {
652 BuilderApplication.settings.editor_font_size = val;
657 // user defined functions
660 public class Xcls_close_btn : Object
662 public Gtk.Button el;
663 private Editor _this;
669 public Xcls_close_btn(Editor _owner )
672 _this.close_btn = this;
673 this.el = new Gtk.Button();
677 // set gobject values
678 this.el.icon_name = "window-close";
679 this.el.halign = Gtk.Align.END;
680 var child_1 = new Xcls_Image8( _this );
682 this.el.child = child_1.el;
685 this.el.clicked.connect( () => {
686 _this.saveContents();
687 _this.window.windowstate.switchState(WindowState.State.PREVIEW);
691 // user defined functions
693 public class Xcls_Image8 : Object
696 private Editor _this;
702 public Xcls_Image8(Editor _owner )
705 this.el = new Gtk.Image();
709 // set gobject values
710 this.el.icon_name = "window-close";
711 this.el.icon_size = Gtk.IconSize.NORMAL;
714 // user defined functions
719 public class Xcls_RightEditor : Object
721 public Gtk.ScrolledWindow el;
722 private Editor _this;
728 public Xcls_RightEditor(Editor _owner )
731 _this.RightEditor = this;
732 this.el = new Gtk.ScrolledWindow();
736 // set gobject values
737 this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
738 this.el.vexpand = true;
739 this.el.overlay_scrolling = false;
740 this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
741 new Xcls_view( _this );
742 this.el.child = _this.view.el;
745 // user defined functions
747 public class Xcls_view : Object
749 public GtkSource.View el;
750 private Editor _this;
754 public Gtk.CssProvider css;
757 public Xcls_view(Editor _owner )
761 this.el = new GtkSource.View();
766 // set gobject values
767 this.el.auto_indent = true;
768 this.el.indent_width = 4;
769 this.el.name = "editor-view";
770 this.el.show_line_marks = true;
771 this.el.insert_spaces_instead_of_tabs = true;
772 this.el.show_line_numbers = true;
773 this.el.hexpand = true;
774 this.el.vexpand = true;
775 this.el.has_tooltip = true;
776 this.el.css_classes = { "code-editor" };
777 this.el.tab_width = 4;
778 this.el.highlight_current_line = true;
779 new Xcls_buffer( _this );
780 this.el.buffer = _this.buffer.el;
781 new Xcls_keystate( _this );
782 this.el.add_controller( _this.keystate.el );
783 var child_3 = new Xcls_EventControllerScroll13( _this );
785 this.el.add_controller( child_3.el );
786 var child_4 = new Xcls_GestureClick14( _this );
788 this.el.add_controller( child_4.el );
792 this.el.completion.add_provider(
793 new Palete.CompletionProvider(_this)
796 // hover seems pretty useless.. - ??
797 //var hover = this.el.get_hover();
798 //hover.add_provider(new Palete.HoverProvider(_this));
800 //this.el.completion.unblock_interactive();
801 this.el.completion.select_on_show = true; // select
802 //this.el.completion.remember_info_visibility = true;
805 var attrs = new GtkSource.MarkAttributes();
807 attrs.set_icon_name ( "process-stop");
808 attrs.query_tooltip_text.connect(( mark) => {
809 GLib.debug("tooltip query? %s", mark.name);
810 return strdup( mark.name);
812 attrs.query_tooltip_markup.connect(( mark) => {
813 GLib.debug("tooltip query? %s", mark.name);
814 return strdup( mark.name);
816 this.el.set_mark_attributes ("ERR", attrs, 1);
820 var wattrs = new GtkSource.MarkAttributes();
821 wattrs.set_icon_name ( "process-stop");
822 wattrs.query_tooltip_text.connect(( mark) => {
823 GLib.debug("tooltip query? %s", mark.name);
824 return strdup(mark.name);
826 wattrs.query_tooltip_markup.connect(( mark) => {
827 GLib.debug("tooltip query? %s", mark.name);
828 return strdup(mark.name);
830 this.el.set_mark_attributes ("WARN", wattrs, 1);
834 var dattrs = new GtkSource.MarkAttributes();
836 dattrs.set_icon_name ( "process-stop");
838 dattrs.query_tooltip_text.connect(( mark) => {
839 GLib.debug("tooltip query? %s", mark.name);
840 return strdup(mark.name);
842 //dattrs.query_tooltip_markup.connect(( mark) => {
843 // GLib.debug("tooltip query? %s", mark.name);
844 // return strdup(mark.name);
846 this.el.set_mark_attributes ("DEPR", dattrs, 1);
849 this.el.get_space_drawer().set_matrix(null);
850 this.el.get_space_drawer().set_types_for_locations(
851 GtkSource.SpaceLocationFlags.ALL,
852 GtkSource.SpaceTypeFlags.ALL
854 this.el.get_space_drawer().set_enable_matrix(true);
857 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
859 //GLib.debug("query tooltip");
863 var yoff = (int) _this.RightEditor.el.vadjustment.value;
865 // I think this is problematic - if it's compliing / updating at same time as query.
867 //if (_this.window.statusbar_compile_spinner.el.spinning) {
871 this.el.get_iter_at_position (out iter, out trailing, x, y + yoff);
873 var l = iter.get_line();
877 // GLib.debug("query tooltip line %d", (int) l);
883 if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {
884 GLib.debug("line %d setting tip to %s", l, _this.buffer.marks.get(l));
885 tooltip.set_text(_this.buffer.marks.get(l).dup());
893 // this crashes?? - not sure why.
894 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
895 if (marks.is_empty()) {
896 marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
898 if (marks.is_empty()) {
899 marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
902 // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length());
904 marks.@foreach((m) => {
905 //GLib.debug("got mark %s", m.name);
906 str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name;
908 // true if there is a mark..
909 if (str.length > 0 ) {
910 tooltip.set_text( str );
912 return str.length > 0 ? true : false;
917 // user defined functions
918 public void load (string str) {
920 // show the help page for the active node..
921 //this.get('/Help').show();
923 // this.get('/BottomPane').el.set_current_page(0);
924 GLib.debug("load called - Reset undo buffer");
926 var buf = (GtkSource.Buffer)this.el.get_buffer();
927 buf.begin_irreversible_action();
928 buf.set_text(str, str.length);
929 buf.end_irreversible_action();
931 var lm = GtkSource.LanguageManager.get_default();
933 if (_this.file != null) {
934 lang = _this.file.language;
936 print("lang=%s, content_type = %s\n", lang, _this.file.content_type);
937 var lg = _this.file.content_type.length > 0 ?
938 lm.guess_language(_this.file.path, _this.file.content_type) :
939 lm.get_language(lang);
942 ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg);
944 this.el.insert_spaces_instead_of_tabs = true;
946 print("sourcelanguage = %s\n", lg.name);
947 if (lg.name == "Vala") {
948 this.el.insert_spaces_instead_of_tabs = false;
952 this.el.grab_focus();
953 _this.save_button.el.sensitive = false;
954 _this.last_error_counter = -1;
957 public class Xcls_buffer : Object
959 public GtkSource.Buffer el;
960 private Editor _this;
964 public int error_line;
965 public Gee.HashMap<int,string>? xmarks;
966 public bool check_queued;
969 public Xcls_buffer(Editor _owner )
973 this.el = new GtkSource.Buffer( null );
976 this.error_line = -1;
978 this.check_queued = false;
980 // set gobject values
981 this.el.highlight_syntax = true;
982 this.el.highlight_matching_brackets = true;
983 this.el.enable_undo = true;
988 buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
989 buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
990 buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
991 buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
992 buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
993 buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
994 buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
995 buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
998 buf.create_tag ("ERR", "weight", Pango.Weight.BOLD, "background", "pink");
999 buf.create_tag ("WARN", "weight", Pango.Weight.BOLD, "background", "#ABF4EB");
1000 buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
1003 this.el.cursor_moved.connect( ( ) => {
1006 this.el.get_iter_at_offset (
1007 out iter, this.el.cursor_position);
1009 _this.navigation.updateSelectedLine(
1010 (uint)iter.get_line(),
1011 (uint)iter.get_line_offset()
1013 this.showHelp(iter);
1016 this.el.changed.connect( () => {
1019 _this.save_button.el.sensitive = true;
1020 print("EDITOR CHANGED");
1025 // this.get('/LeftPanel.model').changed( str , false);
1030 // user defined functions
1031 public bool OLDhighlightErrorsJson (string type, Json.Object obj) {
1034 this.el.get_bounds (out start, out end);
1036 this.el.remove_source_marks (start, end, type);
1037 GLib.debug("highlight errors");
1039 // we should highlight other types of errors..
1041 if (!obj.has_member(type)) {
1042 GLib.debug("Return has no errors\n");
1046 if (_this.window.windowstate.state != WindowState.State.CODEONLY
1048 _this.window.windowstate.state != WindowState.State.CODE
1050 GLib.debug("windowstate != CODEONLY?");
1055 //this.marks = new Gee.HashMap<int,string>();
1056 var err = obj.get_object_member(type);
1058 if (_this.file == null) {
1059 GLib.debug("file is null?");
1063 var valafn = _this.file.path;
1065 if (_this.file.xtype != "PlainFile") {
1069 var regex = new Regex("\\.bjs$");
1070 // should not happen
1071 valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
1072 } catch (GLib.RegexError e) {
1079 if (!err.has_member(valafn)) {
1080 GLib.debug("File path has no errors");
1084 var lines = err.get_object_member(valafn);
1087 if (obj.has_member("line_offset")) { // ?? why??
1088 offset = (int)obj.get_int_member("line_offset") + 1;
1092 var tlines = this.el.get_line_count () +1;
1094 if (_this.prop != null) {
1096 tlines = _this.prop.end_line + 1;
1097 offset = _this.prop.start_line + 1;
1103 lines.foreach_member((obj, line, node) => {
1106 // print("get inter\n");
1107 var eline = int.parse(line) - offset;
1108 GLib.debug("GOT ERROR on line %s -- converted to %d (offset = %d)\n", line,eline, offset);
1111 if (eline > tlines || eline < 0) {
1116 this.el.get_iter_at_line( out iter, eline);
1117 //print("mark line\n");
1119 var ar = lines.get_array_member(line);
1120 for (var i = 0 ; i < ar.get_length(); i++) {
1121 if (ar.get_string_element(i) == "Success") {
1124 msg += (msg.length > 0) ? "\n" : "";
1125 msg += ar.get_string_element(i);
1130 msg = "Line: %d".printf(eline+1) + " " + msg;
1131 this.el.create_source_mark(msg, type, iter);
1132 GLib.debug("set line %d to %m", eline, msg);
1133 // this.marks.set(eline, msg);
1142 public bool checkSyntax () {
1145 var str = this.toString();
1148 if (this.error_line > 0) {
1151 this.el.get_bounds (out start, out end);
1153 this.el.remove_source_marks (start, end, null);
1155 if (str.length < 1) {
1156 print("checkSyntax - empty string?\n");
1161 if (_this.file.xtype == "PlainFile") {
1163 // assume it's gtk...
1164 var oldcode =_this.file.toSource();
1165 _this.file.setSource(str);
1166 BuilderApplication.showSpinner("appointment soon","document change pending");
1167 _this.file.getLanguageServer().document_change(_this.file);
1168 _this.file.getLanguageServer().queueDocumentSymbols(_this.file);
1169 _this.file.setSource(oldcode);
1175 if (_this.file == null) {
1183 GLib.debug("calling validate");
1184 // clear the buttons.
1185 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
1188 var oldcode = _this.prop.val;
1190 _this.prop.val = str;
1191 _this.node.updated_count++;
1192 _this.file.getLanguageServer().document_change(_this.file);
1193 _this.node.updated_count++;
1194 _this.prop.val = oldcode;
1197 //print("done mark line\n");
1199 return true; // at present allow saving - even if it's invalid..
1201 public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
1203 this.error_line = validate_res.size;
1205 if (this.error_line < 1) {
1208 var tlines = this.el.get_line_count ();
1210 var valiter = validate_res.map_iterator();
1211 while (valiter.next()) {
1213 // print("get inter\n");
1214 var eline = valiter.get_key();
1215 if (eline > tlines) {
1218 this.el.get_iter_at_line( out iter, eline);
1219 //print("mark line\n");
1220 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
1224 public string toString () {
1228 this.el.get_start_iter(out s);
1229 this.el.get_end_iter(out e);
1230 var ret = this.el.get_text(s,e,true);
1231 //print("TO STRING? " + ret);
1234 public void showHelp (Gtk.TextIter iter) {
1235 var back = iter.copy();
1236 back.backward_char();
1238 var forward = iter.copy();
1239 forward.forward_char();
1241 // what's the character at the iter?
1242 var str = back.get_text(iter);
1243 str += iter.get_text(forward);
1244 if (str.strip().length < 1) {
1247 var offset = iter.get_line_offset();
1248 var line = iter.get_line();
1249 if (_this.prop != null) {
1251 line += _this.prop.start_line ;
1252 // this is based on Gtk using tabs (hence 1/2 chars);
1253 offset += _this.node.node_pad.length;
1254 // javascript listeners are indented 2 more spaces.
1255 if (_this.prop.ptype == JsRender.NodePropType.LISTENER) {
1260 var ls = _this.file.getLanguageServer();
1262 _this.file, line, offset,
1265 var res = ls.hover.end(o );
1267 _this.helper.setHelp(res);
1268 } catch (GLib.Error e) {
1275 public class Xcls_keystate : Object
1277 public Gtk.EventControllerKey el;
1278 private Editor _this;
1282 public bool is_control;
1285 public Xcls_keystate(Editor _owner )
1288 _this.keystate = this;
1289 this.el = new Gtk.EventControllerKey();
1292 this.is_control = false;
1294 // set gobject values
1297 this.el.key_released.connect( (keyval, keycode, state) => {
1299 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1300 this.is_control = false;
1302 if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1303 GLib.debug("SAVE: ctrl-S pressed");
1304 _this.saveContents();
1308 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1309 GLib.debug("SAVE: ctrl-g pressed");
1310 _this.forwardSearch(true);
1313 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1314 GLib.debug("SAVE: ctrl-f pressed");
1315 _this.search_entry.el.grab_focus();
1316 _this.search_entry.el.select_region(0,-1);
1319 if (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1320 _this.view.el.show_completion();
1324 _this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);
1325 var line = iter.get_line();
1326 var offset = iter.get_line_offset();
1327 GLib.debug("line %d off %d", line ,offset);
1328 if (_this.prop != null) {
1329 line += _this.prop.start_line + 1; // i think..
1330 offset += 12; // should probably be 8 without namespaced
1331 GLib.debug("guess line %d off %d", line ,offset);
1333 //_this.view.el.show_completion();
1334 // print(event.key.keyval)
1341 this.el.key_pressed.connect( (keyval, keycode, state) => {
1343 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1344 this.is_control = true;
1350 // user defined functions
1353 public class Xcls_EventControllerScroll13 : Object
1355 public Gtk.EventControllerScroll el;
1356 private Editor _this;
1360 public double distance;
1363 public Xcls_EventControllerScroll13(Editor _owner )
1366 this.el = new Gtk.EventControllerScroll( Gtk.EventControllerScrollFlags.VERTICAL );
1369 this.distance = 0.0f;
1371 // set gobject values
1374 this.el.scroll.connect( (dx, dy) => {
1375 if (!_this.keystate.is_control) {
1378 //GLib.debug("scroll %f", dy);
1380 this.distance += dy;
1382 //GLib.debug("scroll %f / %f", dy, this.distance);
1384 if (this.distance < -1) {
1386 BuilderApplication.settings.editor_font_size ++;
1389 if (this.distance > 1) {
1390 BuilderApplication.settings.editor_font_size --;
1398 // user defined functions
1401 public class Xcls_GestureClick14 : Object
1403 public Gtk.GestureClick el;
1404 private Editor _this;
1410 public Xcls_GestureClick14(Editor _owner )
1413 this.el = new Gtk.GestureClick();
1417 // set gobject values
1420 this.el.pressed.connect( (n_press, x, y) => {
1422 int buffer_x, buffer_y;
1423 var gut = _this.view.el.get_gutter(Gtk.TextWindowType.LEFT);
1425 _this.view.el.window_to_buffer_coords (Gtk.TextWindowType.TEXT,
1426 (int)x - gut.get_width(), (int)y,
1427 out buffer_x, out buffer_y);
1428 _this.view.el.get_iter_at_location (out iter,
1429 buffer_x, buffer_y);;
1432 if (_this.buffer.el.iter_has_context_class(iter, "comment") ||
1433 _this.buffer.el.iter_has_context_class(iter, "string")
1437 _this.buffer.showHelp(iter);
1444 // user defined functions
1449 public class Xcls_Box15 : Object
1452 private Editor _this;
1458 public Xcls_Box15(Editor _owner )
1461 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1465 // set gobject values
1466 this.el.homogeneous = false;
1467 this.el.vexpand = false;
1468 new Xcls_search_entry( _this );
1469 this.el.append( _this.search_entry.el );
1470 new Xcls_search_results( _this );
1471 this.el.append( _this.search_results.el );
1472 new Xcls_nextBtn( _this );
1473 this.el.append( _this.nextBtn.el );
1474 new Xcls_backBtn( _this );
1475 this.el.append( _this.backBtn.el );
1476 var child_5 = new Xcls_MenuButton21( _this );
1478 this.el.append( child_5.el );
1481 // user defined functions
1483 public class Xcls_search_entry : Object
1485 public Gtk.SearchEntry el;
1486 private Editor _this;
1490 public Gtk.CssProvider css;
1493 public Xcls_search_entry(Editor _owner )
1496 _this.search_entry = this;
1497 this.el = new Gtk.SearchEntry();
1501 // set gobject values
1502 this.el.name = "editor-search-entry";
1503 this.el.hexpand = true;
1504 this.el.placeholder_text = "Press enter to search";
1505 this.el.search_delay = 3;
1506 var child_1 = new Xcls_EventControllerKey17( _this );
1508 this.el.add_controller( child_1.el );
1511 this.el.search_changed.connect( ( ) => {
1513 _this.search(_this.search_entry.el.text);
1514 _this.search_results.updateResults();
1516 GLib.Timeout.add_seconds(1,() => {
1517 _this.search_results.updateResults();
1523 // user defined functions
1524 public void forwardSearch (bool change_focus) {
1527 _this.forwardSearch(change_focus);
1531 switch(_this.windowstate.state) {
1532 case WindowState.State.CODEONLY:
1533 //case WindowState.State.CODE:
1534 // search the code being edited..
1535 _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1538 case WindowState.State.PREVIEW:
1539 if (_this.windowstate.file.xtype == "Gtk") {
1540 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1542 _this.windowstate.window_rooview.forwardSearch(change_focus);
1551 public class Xcls_EventControllerKey17 : Object
1553 public Gtk.EventControllerKey el;
1554 private Editor _this;
1560 public Xcls_EventControllerKey17(Editor _owner )
1563 this.el = new Gtk.EventControllerKey();
1567 // set gobject values
1570 this.el.key_pressed.connect( (keyval, keycode, state) => {
1572 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1573 GLib.debug("SAVE: ctrl-g pressed");
1574 _this.forwardSearch(true);
1579 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1580 _this.forwardSearch(true);
1586 // print(event.key.keyval)
1592 // user defined functions
1596 public class Xcls_search_results : Object
1598 public Gtk.Label el;
1599 private Editor _this;
1605 public Xcls_search_results(Editor _owner )
1608 _this.search_results = this;
1609 this.el = new Gtk.Label( "No Results" );
1613 // set gobject values
1614 this.el.margin_end = 4;
1615 this.el.margin_start = 4;
1618 // user defined functions
1619 public void updateResults () {
1620 this.el.visible = true;
1622 var res = _this.searchcontext.get_occurrences_count();
1624 _this.search_results.el.label = "??? Matches";
1628 _this.nextBtn.el.sensitive = false;
1629 _this.backBtn.el.sensitive = false;
1632 _this.search_results.el.label = "%d Matches".printf(res);
1633 _this.nextBtn.el.sensitive = true;
1634 _this.backBtn.el.sensitive = true;
1637 _this.search_results.el.label = "No Matches";
1642 public class Xcls_nextBtn : Object
1644 public Gtk.Button el;
1645 private Editor _this;
1649 public bool always_show_image;
1652 public Xcls_nextBtn(Editor _owner )
1655 _this.nextBtn = this;
1656 this.el = new Gtk.Button();
1659 this.always_show_image = true;
1661 // set gobject values
1662 this.el.icon_name = "go-down";
1663 this.el.sensitive = false;
1666 this.el.clicked.connect( (event) => {
1668 _this.forwardSearch(true);
1674 // user defined functions
1677 public class Xcls_backBtn : Object
1679 public Gtk.Button el;
1680 private Editor _this;
1684 public bool always_show_image;
1687 public Xcls_backBtn(Editor _owner )
1690 _this.backBtn = this;
1691 this.el = new Gtk.Button();
1694 this.always_show_image = true;
1696 // set gobject values
1697 this.el.icon_name = "go-up";
1698 this.el.sensitive = false;
1701 this.el.clicked.connect( (event) => {
1703 _this.backSearch(true);
1708 // user defined functions
1711 public class Xcls_MenuButton21 : Object
1713 public Gtk.MenuButton el;
1714 private Editor _this;
1718 public bool always_show_image;
1721 public Xcls_MenuButton21(Editor _owner )
1724 this.el = new Gtk.MenuButton();
1727 this.always_show_image = true;
1729 // set gobject values
1730 this.el.icon_name = "emblem-system";
1731 this.el.always_show_arrow = true;
1732 new Xcls_search_settings( _this );
1733 this.el.popover = _this.search_settings.el;
1736 // user defined functions
1738 public class Xcls_search_settings : Object
1740 public Gtk.Popover el;
1741 private Editor _this;
1747 public Xcls_search_settings(Editor _owner )
1750 _this.search_settings = this;
1751 this.el = new Gtk.Popover();
1755 // set gobject values
1756 var child_1 = new Xcls_Box23( _this );
1758 this.el.child = child_1.el;
1761 // user defined functions
1763 public class Xcls_Box23 : Object
1766 private Editor _this;
1772 public Xcls_Box23(Editor _owner )
1775 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1779 // set gobject values
1780 new Xcls_case_sensitive( _this );
1781 this.el.append( _this.case_sensitive.el );
1782 new Xcls_regex( _this );
1783 this.el.append( _this.regex.el );
1784 new Xcls_multiline( _this );
1785 this.el.append( _this.multiline.el );
1788 // user defined functions
1790 public class Xcls_case_sensitive : Object
1792 public Gtk.CheckButton el;
1793 private Editor _this;
1799 public Xcls_case_sensitive(Editor _owner )
1802 _this.case_sensitive = this;
1803 this.el = new Gtk.CheckButton();
1807 // set gobject values
1808 this.el.label = "Case Sensitive";
1817 // user defined functions
1820 public class Xcls_regex : Object
1822 public Gtk.CheckButton el;
1823 private Editor _this;
1829 public Xcls_regex(Editor _owner )
1833 this.el = new Gtk.CheckButton();
1837 // set gobject values
1838 this.el.label = "Regex";
1847 // user defined functions
1850 public class Xcls_multiline : Object
1852 public Gtk.CheckButton el;
1853 private Editor _this;
1859 public Xcls_multiline(Editor _owner )
1862 _this.multiline = this;
1863 this.el = new Gtk.CheckButton();
1867 // set gobject values
1868 this.el.label = "Multi-line (add \\n)";
1871 // user defined functions
1879 public class Xcls_navigation_holder : Object
1882 private Editor _this;
1888 public Xcls_navigation_holder(Editor _owner )
1891 _this.navigation_holder = this;
1892 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1896 // set gobject values
1897 this.el.width_request = 120;
1898 this.el.hexpand = true;
1899 this.el.vexpand = true;
1900 this.el.visible = false;
1901 var child_1 = new Xcls_Box28( _this );
1903 this.el.append( child_1.el );
1904 new Xcls_navigationwindow( _this );
1905 this.el.append( _this.navigationwindow.el );
1908 // user defined functions
1910 public class Xcls_Box28 : Object
1913 private Editor _this;
1919 public Xcls_Box28(Editor _owner )
1922 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1926 // set gobject values
1929 // user defined functions
1932 public class Xcls_navigationwindow : Object
1934 public Gtk.ScrolledWindow el;
1935 private Editor _this;
1941 public Xcls_navigationwindow(Editor _owner )
1944 _this.navigationwindow = this;
1945 this.el = new Gtk.ScrolledWindow();
1949 // set gobject values
1950 this.el.hexpand = true;
1951 this.el.vexpand = true;
1952 this.el.visible = true;
1953 new Xcls_navigation( _this );
1954 this.el.child = _this.navigation.el;
1957 // user defined functions
1959 public class Xcls_navigation : Object
1961 public Gtk.ColumnView el;
1962 private Editor _this;
1966 public int last_selected_line;
1967 public Gtk.Widget? selected_row;
1970 public Xcls_navigation(Editor _owner )
1973 _this.navigation = this;
1974 new Xcls_navigationselmodel( _this );
1975 this.el = new Gtk.ColumnView( _this.navigationselmodel.el );
1978 this.last_selected_line = -1;
1979 this.selected_row = null;
1981 // set gobject values
1982 this.el.name = "editor-navigation";
1983 var child_2 = new Xcls_ColumnViewColumn31( _this );
1985 this.el.append_column( child_2.el );
1986 var child_3 = new Xcls_GestureClick40( _this );
1988 this.el.add_controller( child_3.el );
1991 // user defined functions
1992 public Gtk.Widget? getRowWidgetAt (double x, double y, out string pos) {
1995 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
1996 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
2001 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
2006 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2010 //GLib.debug("row number is %d", rn);
2011 //GLib.debug("click %d, %d", (int)x, (int)y);
2013 Graphene.Rect bounds;
2014 row.compute_bounds(this.el, out bounds);
2015 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2016 // (int)bounds.get_x(), (int)bounds.get_y(),
2017 // (int)bounds.get_width(), (int)bounds.get_height()
2019 var ypos = y - bounds.get_y();
2020 //GLib.debug("rel ypos = %d", (int)ypos);
2021 var rpos = 100.0 * (ypos / bounds.get_height());
2022 //GLib.debug("rel pos = %d %%", (int)rpos);
2027 } else if (rpos < 20) {
2032 public void show (Gee.ArrayList<Lsp.DocumentSymbol> syms) {
2034 if (!_this.navigation_holder.el.visible) {
2035 _this.navigation_holder.el.show();
2036 _this.paned.el.position =
2037 _this.paned.el.get_width() - 200;
2039 //_this.navliststore.el.remove_all();
2042 var ls = new GLib.ListStore(typeof(Lsp.DocumentSymbol));
2044 foreach(var sym in syms) {
2047 Lsp.DocumentSymbol.copyList(ls, _this.navliststore.el);
2048 //_this.navliststore.el.append(sym);
2049 this.last_selected_line = -1;
2050 GLib.Idle.add(() => {
2051 _this.navigationsort.collapseOnLoad();
2053 _this.buffer.el.get_iter_at_offset (
2054 out iter, _this.buffer.el.cursor_position);
2056 GLib.debug("idle update scroll %d, %d", iter.get_line(),
2057 iter.get_line_offset());
2058 this.updateSelectedLine(
2059 (uint)iter.get_line(),
2060 (uint)iter.get_line_offset()
2066 public int getRowAt (double x, double y, out string pos) {
2069 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
2070 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
2075 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
2080 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2085 while (cr.get_prev_sibling() != null) {
2087 cr = cr.get_prev_sibling();
2090 //GLib.debug("row number is %d", rn);
2091 //GLib.debug("click %d, %d", (int)x, (int)y);
2093 Graphene.Rect bounds;
2094 row.compute_bounds(this.el, out bounds);
2095 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2096 // (int)bounds.get_x(), (int)bounds.get_y(),
2097 // (int)bounds.get_width(), (int)bounds.get_height()
2099 var ypos = y - bounds.get_y();
2100 //GLib.debug("rel ypos = %d", (int)ypos);
2101 var rpos = 100.0 * (ypos / bounds.get_height());
2102 //GLib.debug("rel pos = %d %%", (int)rpos);
2107 } else if (rpos < 20) {
2112 public void updateSelectedLine (uint line, uint chr) {
2113 if (line == this.last_selected_line) {
2116 GLib.debug("select line %d", (int)line);
2117 this.last_selected_line = (int)line;
2121 var sym = _this.navliststore.symbolAtLine(line, chr);
2123 new_row = _this.navigationsort.getRowFromSymbol(sym);
2124 GLib.debug("select line %d - row found %d", (int)line, new_row);
2126 GLib.debug(" no symbol found at line %d", (int)line);
2129 if (this.selected_row != null) {
2130 GLib.debug(" remove selected row");
2131 this.selected_row.remove_css_class("selected-row");
2133 this.selected_row = null;
2135 this.el.scroll_to(new_row,null,Gtk.ListScrollFlags.NONE, null);
2136 var row = sym.get_data<Gtk.Widget>("widget");
2138 GLib.debug(" Add selected row");
2140 row.add_css_class("selected-row");
2141 this.selected_row = row;
2145 GLib.debug("could not find widget on row %d", new_row);
2153 public class Xcls_ColumnViewColumn31 : Object
2155 public Gtk.ColumnViewColumn el;
2156 private Editor _this;
2162 public Xcls_ColumnViewColumn31(Editor _owner )
2165 var child_1 = new Xcls_SignalListItemFactory32( _this );
2167 this.el = new Gtk.ColumnViewColumn( "Code Navigation", child_1.el );
2171 // set gobject values
2172 this.el.expand = true;
2175 // user defined functions
2177 public class Xcls_SignalListItemFactory32 : Object
2179 public Gtk.SignalListItemFactory el;
2180 private Editor _this;
2186 public Xcls_SignalListItemFactory32(Editor _owner )
2189 this.el = new Gtk.SignalListItemFactory();
2193 // set gobject values
2196 this.el.setup.connect( (listitem) => {
2198 var expand = new Gtk.TreeExpander();
2200 expand.set_indent_for_depth(true);
2201 expand.set_indent_for_icon(true);
2202 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2203 var icon = new Gtk.Image();
2204 var lbl = new Gtk.Label("");
2205 lbl.use_markup = true;
2206 lbl.ellipsize = Pango.EllipsizeMode.END;
2208 icon.margin_end = 4;
2209 lbl.justify = Gtk.Justification.LEFT;
2212 // listitem.activatable = true; ??
2216 expand.set_child(hbox);
2217 ((Gtk.ListItem)listitem).set_child(expand);
2220 this.el.bind.connect( (listitem) => {
2222 // GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name());
2224 //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2225 var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2228 var hbox = (Gtk.Box) expand.child;
2231 var img = (Gtk.Image) hbox.get_first_child();
2232 var lbl = (Gtk.Label) img.get_next_sibling();
2234 var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();
2235 var sym = (Lsp.DocumentSymbol) lr.get_item();
2237 sym.set_data<Gtk.Widget>("widget", expand.get_parent());
2238 expand.get_parent().get_parent().set_data<Lsp.DocumentSymbol>("symbol", sym);
2240 //GLib.debug("save sym on %s", expand.get_parent().get_parent().get_type().name());
2242 //GLib.debug("got %d children for %s" , (int)sym.children.get_n_items(), sym.name);
2244 expand.set_hide_expander( sym.children.get_n_items() < 1);
2245 expand.set_list_row(lr);
2246 //this.in_bind = true;
2247 // default is to expand
2249 //this.in_bind = false;
2251 sym.bind_property("symbol_icon",
2253 GLib.BindingFlags.SYNC_CREATE);
2255 hbox.css_classes = { sym.symbol_icon };
2257 sym.bind_property("name",
2259 GLib.BindingFlags.SYNC_CREATE);
2260 // should be better?- --line no?
2261 sym.bind_property("tooltip",
2262 lbl, "tooltip_markup",
2263 GLib.BindingFlags.SYNC_CREATE);
2269 // user defined functions
2273 public class Xcls_navigationselmodel : Object
2275 public Gtk.NoSelection el;
2276 private Editor _this;
2282 public Xcls_navigationselmodel(Editor _owner )
2285 _this.navigationselmodel = this;
2286 new Xcls_navigationsort( _this );
2287 this.el = new Gtk.NoSelection( _this.navigationsort.el );
2291 // set gobject values
2294 // user defined functions
2296 public class Xcls_navigationsort : Object
2298 public Gtk.SortListModel el;
2299 private Editor _this;
2305 public Xcls_navigationsort(Editor _owner )
2308 _this.navigationsort = this;
2309 var child_1 = new Xcls_TreeListModel35( _this );
2311 var child_2 = new Xcls_TreeListRowSorter37( _this );
2313 this.el = new Gtk.SortListModel( child_1.el, child_2.el );
2317 // set gobject values
2320 // user defined functions
2321 public void collapseOnLoad () {
2322 for (var i=0;i < this.el.get_n_items(); i++) {
2323 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2324 var sym = (Lsp.DocumentSymbol)tr.get_item();
2326 case Lsp.SymbolKind.Enum:
2327 tr.expanded = false;
2330 //tr.expanded = true;
2339 public int getRowFromSymbol (Lsp.DocumentSymbol sym) {
2341 for (var i=0;i < this.el.get_n_items(); i++) {
2342 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2344 if (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {
2350 public Lsp.DocumentSymbol? getSymbolAt (uint row) {
2352 var tr = (Gtk.TreeListRow)this.el.get_item(row);
2354 var a = tr.get_item();;
2355 GLib.debug("get_item (2) = %s", a.get_type().name());
2358 return (Lsp.DocumentSymbol)tr.get_item();
2362 public class Xcls_TreeListModel35 : Object
2364 public Gtk.TreeListModel el;
2365 private Editor _this;
2371 public Xcls_TreeListModel35(Editor _owner )
2374 new Xcls_navliststore( _this );
2375 this.el = new Gtk.TreeListModel( _this.navliststore.el, false, true, (item) => {
2377 return ((Lsp.DocumentSymbol)item).children;
2383 // set gobject values
2386 this.el.items_changed.connect( (position, removed, added) => {
2387 GLib.debug("tree item changed %d , %d , %d",(int) position, (int)removed, (int) added);
2391 //var sym = (Lsp.DocumentSymbol) this.el.get_item(position);
2392 var row = this.el.get_row(position);
2394 GLib.debug("got %s", row.get_item().get_type().name());
2400 // user defined functions
2402 public class Xcls_navliststore : Object
2404 public GLib.ListStore el;
2405 private Editor _this;
2411 public Xcls_navliststore(Editor _owner )
2414 _this.navliststore = this;
2415 this.el = new GLib.ListStore( typeof(Lsp.DocumentSymbol) );
2419 // set gobject values
2422 // user defined functions
2423 public Lsp.DocumentSymbol? symbolAtLine (uint line, uint chr) {
2426 for(var i = 0; i < this.el.get_n_items();i++) {
2427 var el = (Lsp.DocumentSymbol)this.el.get_item(i);
2428 //GLib.debug("Check sym %s : %d-%d",
2429 // el.name , (int)el.range.start.line,
2430 // (int)el.range.end.line
2432 var ret = el.containsLine(line,chr);
2444 public class Xcls_TreeListRowSorter37 : Object
2446 public Gtk.TreeListRowSorter el;
2447 private Editor _this;
2453 public Xcls_TreeListRowSorter37(Editor _owner )
2456 var child_1 = new Xcls_StringSorter38( _this );
2458 this.el = new Gtk.TreeListRowSorter( child_1.el );
2462 // set gobject values
2465 // user defined functions
2467 public class Xcls_StringSorter38 : Object
2469 public Gtk.StringSorter el;
2470 private Editor _this;
2476 public Xcls_StringSorter38(Editor _owner )
2479 var child_1 = new Xcls_PropertyExpression39( _this );
2481 this.el = new Gtk.StringSorter( child_1.el );
2485 // set gobject values
2488 // user defined functions
2490 public class Xcls_PropertyExpression39 : Object
2492 public Gtk.PropertyExpression el;
2493 private Editor _this;
2499 public Xcls_PropertyExpression39(Editor _owner )
2502 this.el = new Gtk.PropertyExpression( typeof(Lsp.DocumentSymbol), null, "sort_key" );
2506 // set gobject values
2509 // user defined functions
2516 public class Xcls_GestureClick40 : Object
2518 public Gtk.GestureClick el;
2519 private Editor _this;
2525 public Xcls_GestureClick40(Editor _owner )
2528 this.el = new Gtk.GestureClick();
2532 // set gobject values
2535 this.el.pressed.connect( (n_press, x, y) => {
2537 var row = _this.navigation.getRowWidgetAt(x,y, out pos );
2540 GLib.debug("no row selected items");
2543 GLib.debug("got click on %s", row.get_type().name());
2544 //Lsp.DocumentSymbol
2545 var sym = row.get_data<Lsp.DocumentSymbol>("symbol");
2561 GLib.debug("goto line %d", (int)sym.range.start.line);
2562 _this.scroll_to_line((int)sym.range.start.line);
2564 _this.buffer.el.get_iter_at_line_offset(out iter,
2565 (int)sym.range.start.line,
2566 (int)sym.range.start.character
2568 _this.buffer.el.place_cursor(iter);
2573 // user defined functions