3 public class Editor : Object
8 public static Editor singleton()
10 if (_Editor == null) {
11 _Editor= new Editor();
15 public Xcls_save_button save_button;
16 public Xcls_helper helper;
17 public Xcls_close_btn close_btn;
18 public Xcls_RightEditor RightEditor;
19 public Xcls_view view;
20 public Xcls_buffer buffer;
21 public Xcls_keystate keystate;
22 public Xcls_search_entry search_entry;
23 public Xcls_search_results search_results;
24 public Xcls_nextBtn nextBtn;
25 public Xcls_backBtn backBtn;
26 public Xcls_search_settings search_settings;
27 public Xcls_case_sensitive case_sensitive;
28 public Xcls_regex regex;
29 public Xcls_multiline multiline;
30 public Xcls_navigationwindow navigationwindow;
31 public Xcls_navigation navigation;
32 public Xcls_navigationselmodel navigationselmodel;
33 public Xcls_navigationsort navigationsort;
34 public Xcls_navliststore navliststore;
37 public int pos_root_x;
38 public Xcls_MainWindow window;
40 public int pos_root_y;
42 public int last_error_counter;
43 public GtkSource.SearchContext searchcontext;
44 public int last_search_end;
45 public signal void save ();
46 public JsRender.JsRender? file;
47 public JsRender.Node node;
48 public JsRender.NodeProp? prop;
49 public string activeEditor;
55 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
61 this.last_error_counter = 0;
62 this.searchcontext = null;
63 this.last_search_end = 0;
67 this.activeEditor = "\"\"";
70 this.el.homogeneous = false;
71 this.el.hexpand = true;
72 this.el.vexpand = true;
73 var child_1 = new Xcls_Paned1( _this );
75 this.el.append( child_1.el );
78 // user defined functions
79 public bool saveContents () {
82 if (_this.file == null) {
88 var str = _this.buffer.toString();
90 _this.buffer.checkSyntax();
94 // LeftPanel.model.changed( str , false);
96 _this.save_button.el.sensitive = false;
98 // find the text for the node..
99 if (_this.file.xtype != "PlainFile") {
100 // in theory these properties have to exist!?!
102 //this.window.windowstate.left_props.reload();
104 _this.file.setSource( str );
113 public void forwardSearch (bool change_focus) {
115 if (this.searchcontext == null) {
119 Gtk.TextIter beg, st,en;
120 bool has_wrapped_around;
121 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end);
122 if (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {
124 this.last_search_end = 0; // not sure if this should happen
126 if (has_wrapped_around) {
130 this.last_search_end = en.get_offset();
132 this.view.el.grab_focus();
134 this.buffer.el.place_cursor(st);
135 this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);
139 public void show (JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)
142 if (this.file != null) {
143 this.file.navigation_tree_updated.disconnect(
144 _this.navigation.show
148 this.file.navigation_tree_updated.connect(
149 _this.navigation.show
151 if (file.xtype != "PlainFile") {
155 // find the text for the node..
156 this.view.load( prop.val );
157 this.updateErrorMarks();
161 this.close_btn.el.show();
164 this.view.load( file.toSource() );
165 this.updateErrorMarks();
166 this.close_btn.el.hide();
167 var ls = file.getLanguageServer();
168 ls.queueDocumentSymbols(file);
169 ////ls.documentSymbols.begin(file, (a,o) => {
170 // _this.navigation.show(ls.documentSymbols.end(o));
177 public void backSearch (bool change_focus) {
179 if (this.searchcontext == null) {
183 Gtk.TextIter beg, st,en;
184 bool has_wrapped_around;
185 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );
187 if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {
188 this.last_search_end = 0;
190 this.last_search_end = en.get_offset();
192 this.view.el.grab_focus();
194 this.buffer.el.place_cursor(st);
195 this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);
199 public string tempFileContents () {
202 if (_this.file == null) {
205 var str= this.buffer.toString();
206 if (_this.file.xtype == "PlainFile") {
214 GLib.debug("calling validate");
215 // clear the buttons.
216 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
217 return this.file.toSource(); ;
220 var oldcode = _this.prop.val;
221 _this.prop.val = str;
222 var ret = _this.file.toSource();
223 _this.prop.val = oldcode;
227 public void reset () {
232 this.searchcontext = null;
235 public int search (string in_txt) {
237 var s = new GtkSource.SearchSettings();
238 s.case_sensitive = _this.case_sensitive.el.active;
239 s.regex_enabled = _this.regex.el.active;
240 s.wrap_around = false;
242 this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);
243 this.searchcontext.set_highlight(true);
246 if (_this.multiline.el.active) {
247 txt = in_txt.replace("\\n", "\n");
250 s.set_search_text(txt);
251 Gtk.TextIter beg, st,en;
253 this.buffer.el.get_start_iter(out beg);
254 bool has_wrapped_around;
255 this.searchcontext.forward(beg, out st, out en, out has_wrapped_around);
256 this.last_search_end = 0;
258 return this.searchcontext.get_occurrences_count();
264 public void updateErrorMarks () {
268 var buf = _this.buffer.el;
271 buf.get_bounds (out start, out end);
276 //GLib.debug("highlight errors");
278 // we should highlight other types of errors..
280 if (_this.window.windowstate.state != WindowState.State.CODEONLY
282 _this.window.windowstate.state != WindowState.State.CODE
284 //GLib.debug("windowstate != CODEONLY?");
290 if (_this.file == null) {
291 GLib.debug("file is null?");
295 var ar = this.file.getErrors();
297 buf.remove_source_marks (start, end, "ERR");
298 buf.remove_source_marks (start, end, "WARN");
299 buf.remove_source_marks (start, end, "DEPR");
300 buf.remove_tag_by_name ("ERR", start, end);
301 buf.remove_tag_by_name ("WARN", start, end);
302 buf.remove_tag_by_name ("DEPR", start, end);
303 this.last_error_counter = file.error_counter ;
304 //GLib.debug("highlight %s : %s has no errors", this.file.relpath, category);
309 // basicaly check if there is no change, then we do not do any update..
310 // we can do this by just using an error counter?
311 // if that's changed then we will do an update, otherwise dont bother.
317 var tlines = buf.get_line_count () +1;
319 if (_this.prop != null) {
320 // this still seems flaky...
322 tlines = _this.prop.end_line;
323 offset = _this.prop.start_line;
324 hoffset = _this.node.node_pad.length + 2; //shift it left by 2 ? ..
329 if (this.last_error_counter == file.error_counter) {
335 buf.remove_source_marks (start, end, "ERR");
336 buf.remove_source_marks (start, end, "WARN");
337 buf.remove_source_marks (start, end, "DEPR");
338 buf.remove_tag_by_name ("ERR", start, end);
339 buf.remove_tag_by_name ("WARN", start, end);
340 buf.remove_tag_by_name ("DEPR", start, end);
342 foreach(var diag in ar) {
344 // print("get inter\n");
345 var eline = (int)diag.range.start.line - offset;
346 var eline_to = (int)diag.range.end.line - offset;
347 //var eline = diag.range.end_line - offset;
348 //GLib.debug("GOT ERROR on line %d -- converted to %d (offset = %d)",
349 // err.line ,eline, offset);
352 if (eline > tlines || eline < 0) {
356 buf.get_iter_at_line( out iter, eline);
357 var msg = "Line: %d %s : %s".printf(eline+1, diag.category, diag.message);
358 buf.create_source_mark( msg, diag.category, iter);
360 var spos = (int)diag.range.start.character - hoffset;
361 if (spos < 0) { spos =0 ; }
362 if (spos > iter.get_chars_in_line()) {
363 spos = iter.get_chars_in_line();
365 buf.get_iter_at_line( out iter, eline_to);
366 var epos = (int)diag.range.end.character - hoffset;
367 if (epos < 0) { epos =0 ; }
368 if (epos > iter.get_chars_in_line()) {
369 epos = iter.get_chars_in_line();
373 buf.get_iter_at_line_offset( out start, eline, spos);
375 buf.get_iter_at_line_offset( out end, eline_to,epos);
377 buf.apply_tag_by_name(diag.category, start, end);
379 // GLib.debug("set line %d to %s", eline, msg);
380 //this.marks.set(eline, msg);
382 this.last_error_counter = file.error_counter ;
389 public void scroll_to_line (int line) {
391 GLib.Timeout.add(500, () => {
393 var buf = this.view.el.get_buffer();
395 var sbuf = (GtkSource.Buffer) buf;
399 sbuf.get_iter_at_line(out iter, line);
400 this.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
404 public class Xcls_Paned1 : Object
407 private Editor _this;
413 public Xcls_Paned1(Editor _owner )
416 this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL );
420 // set gobject values
421 var child_1 = new Xcls_Box2( _this );
423 this.el.start_child = child_1.el;
424 var child_2 = new Xcls_Box27( _this );
426 this.el.end_child = child_2.el;
429 // user defined functions
431 public class Xcls_Box2 : Object
434 private Editor _this;
440 public Xcls_Box2(Editor _owner )
443 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
447 // set gobject values
448 var child_1 = new Xcls_Box3( _this );
450 this.el.append( child_1.el );
451 new Xcls_RightEditor( _this );
452 this.el.append( _this.RightEditor.el );
453 var child_3 = new Xcls_Box15( _this );
455 this.el.append ( child_3.el );
458 // user defined functions
460 public class Xcls_Box3 : Object
463 private Editor _this;
469 public Xcls_Box3(Editor _owner )
472 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
476 // set gobject values
477 this.el.homogeneous = false;
478 this.el.hexpand = true;
479 this.el.vexpand = false;
480 new Xcls_save_button( _this );
481 this.el.append( _this.save_button.el );
482 new Xcls_helper( _this );
483 this.el.append( _this.helper.el );
484 var child_3 = new Xcls_Scale6( _this );
486 this.el.append( child_3.el );
487 new Xcls_close_btn( _this );
488 this.el.append( _this.close_btn.el );
491 // user defined functions
493 public class Xcls_save_button : Object
495 public Gtk.Button el;
496 private Editor _this;
502 public Xcls_save_button(Editor _owner )
505 _this.save_button = this;
506 this.el = new Gtk.Button();
510 // set gobject values
511 this.el.vexpand = true;
512 this.el.label = "Save";
515 this.el.clicked.connect( () => {
516 _this.saveContents();
520 // user defined functions
523 public class Xcls_helper : Object
526 private Editor _this;
532 public Xcls_helper(Editor _owner )
536 this.el = new Gtk.Label( null );
540 // set gobject values
541 this.el.margin_end = 4;
542 this.el.margin_start = 4;
543 this.el.hexpand = true;
546 // user defined functions
549 public class Xcls_Scale6 : Object
552 private Editor _this;
558 public Xcls_Scale6(Editor _owner )
561 this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1);
565 // set gobject values
566 this.el.width_request = 200;
567 this.el.has_origin = true;
568 this.el.draw_value = false;
570 this.el.sensitive = true;
575 //this.el.set_range(6,30);
576 this.el.set_value ( BuilderApplication.settings.editor_font_size);
577 BuilderApplication.settings.editor_font_size_updated.connect(
579 BuilderApplication.settings.editor_font_size_inchange = true;
580 // GLib.debug("update range");
581 this.el.set_value (BuilderApplication.settings.editor_font_size);
582 BuilderApplication.settings.editor_font_size_inchange = false;
590 this.el.change_value.connect( (st, val ) => {
591 if (BuilderApplication.settings.editor_font_size_inchange) {
594 BuilderApplication.settings.editor_font_size = val;
599 // user defined functions
602 public class Xcls_close_btn : Object
604 public Gtk.Button el;
605 private Editor _this;
611 public Xcls_close_btn(Editor _owner )
614 _this.close_btn = this;
615 this.el = new Gtk.Button();
619 // set gobject values
620 this.el.icon_name = "window-close";
621 var child_1 = new Xcls_Image8( _this );
623 this.el.child = child_1.el;
626 this.el.clicked.connect( () => {
627 _this.saveContents();
628 _this.window.windowstate.switchState(WindowState.State.PREVIEW);
632 // user defined functions
634 public class Xcls_Image8 : Object
637 private Editor _this;
643 public Xcls_Image8(Editor _owner )
646 this.el = new Gtk.Image();
650 // set gobject values
651 this.el.icon_name = "window-close";
652 this.el.icon_size = Gtk.IconSize.NORMAL;
655 // user defined functions
660 public class Xcls_RightEditor : Object
662 public Gtk.ScrolledWindow el;
663 private Editor _this;
669 public Xcls_RightEditor(Editor _owner )
672 _this.RightEditor = this;
673 this.el = new Gtk.ScrolledWindow();
677 // set gobject values
678 this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
679 this.el.vexpand = true;
680 this.el.overlay_scrolling = false;
681 this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
682 new Xcls_view( _this );
683 this.el.child = _this.view.el;
686 // user defined functions
688 public class Xcls_view : Object
690 public GtkSource.View el;
691 private Editor _this;
695 public Gtk.CssProvider css;
698 public Xcls_view(Editor _owner )
702 this.el = new GtkSource.View();
707 // set gobject values
708 this.el.auto_indent = true;
709 this.el.indent_width = 4;
710 this.el.name = "editor-view";
711 this.el.show_line_marks = true;
712 this.el.insert_spaces_instead_of_tabs = true;
713 this.el.show_line_numbers = true;
714 this.el.hexpand = true;
715 this.el.vexpand = true;
716 this.el.has_tooltip = true;
717 this.el.css_classes = { "code-editor" };
718 this.el.tab_width = 4;
719 this.el.highlight_current_line = true;
720 new Xcls_buffer( _this );
721 this.el.buffer = _this.buffer.el;
722 new Xcls_keystate( _this );
723 this.el.add_controller( _this.keystate.el );
724 var child_3 = new Xcls_EventControllerScroll13( _this );
726 this.el.add_controller( child_3.el );
727 var child_4 = new Xcls_GestureClick14( _this );
729 this.el.add_controller( child_4.el );
733 this.el.completion.add_provider(
734 new Palete.CompletionProvider(_this)
737 // hover seems pretty useless.. - ??
738 //var hover = this.el.get_hover();
739 //hover.add_provider(new Palete.HoverProvider(_this));
741 //this.el.completion.unblock_interactive();
742 this.el.completion.select_on_show = true; // select
743 //this.el.completion.remember_info_visibility = true;
746 var attrs = new GtkSource.MarkAttributes();
748 attrs.set_icon_name ( "process-stop");
749 attrs.query_tooltip_text.connect(( mark) => {
750 GLib.debug("tooltip query? %s", mark.name);
751 return strdup( mark.name);
753 attrs.query_tooltip_markup.connect(( mark) => {
754 GLib.debug("tooltip query? %s", mark.name);
755 return strdup( mark.name);
757 this.el.set_mark_attributes ("ERR", attrs, 1);
761 var wattrs = new GtkSource.MarkAttributes();
762 wattrs.set_icon_name ( "process-stop");
763 wattrs.query_tooltip_text.connect(( mark) => {
764 GLib.debug("tooltip query? %s", mark.name);
765 return strdup(mark.name);
767 wattrs.query_tooltip_markup.connect(( mark) => {
768 GLib.debug("tooltip query? %s", mark.name);
769 return strdup(mark.name);
771 this.el.set_mark_attributes ("WARN", wattrs, 1);
775 var dattrs = new GtkSource.MarkAttributes();
777 dattrs.set_icon_name ( "process-stop");
779 dattrs.query_tooltip_text.connect(( mark) => {
780 GLib.debug("tooltip query? %s", mark.name);
781 return strdup(mark.name);
783 //dattrs.query_tooltip_markup.connect(( mark) => {
784 // GLib.debug("tooltip query? %s", mark.name);
785 // return strdup(mark.name);
787 this.el.set_mark_attributes ("DEPR", dattrs, 1);
790 this.el.get_space_drawer().set_matrix(null);
791 this.el.get_space_drawer().set_types_for_locations(
792 GtkSource.SpaceLocationFlags.ALL,
793 GtkSource.SpaceTypeFlags.ALL
795 this.el.get_space_drawer().set_enable_matrix(true);
798 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
800 //GLib.debug("query tooltip");
804 var yoff = (int) _this.RightEditor.el.vadjustment.value;
806 // I think this is problematic - if it's compliing / updating at same time as query.
808 //if (_this.window.statusbar_compile_spinner.el.spinning) {
812 this.el.get_iter_at_position (out iter, out trailing, x, y + yoff);
814 var l = iter.get_line();
818 // GLib.debug("query tooltip line %d", (int) l);
824 if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {
825 GLib.debug("line %d setting tip to %s", l, _this.buffer.marks.get(l));
826 tooltip.set_text(_this.buffer.marks.get(l).dup());
834 // this crashes?? - not sure why.
835 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
836 if (marks.is_empty()) {
837 marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
839 if (marks.is_empty()) {
840 marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
843 // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length());
845 marks.@foreach((m) => {
846 //GLib.debug("got mark %s", m.name);
847 str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name;
849 // true if there is a mark..
850 if (str.length > 0 ) {
851 tooltip.set_text( str );
853 return str.length > 0 ? true : false;
858 // user defined functions
859 public void load (string str) {
861 // show the help page for the active node..
862 //this.get('/Help').show();
864 // this.get('/BottomPane').el.set_current_page(0);
865 GLib.debug("load called - Reset undo buffer");
867 var buf = (GtkSource.Buffer)this.el.get_buffer();
868 buf.begin_irreversible_action();
869 buf.set_text(str, str.length);
870 buf.end_irreversible_action();
872 var lm = GtkSource.LanguageManager.get_default();
874 if (_this.file != null) {
875 lang = _this.file.language;
877 print("lang=%s, content_type = %s\n", lang, _this.file.content_type);
878 var lg = _this.file.content_type.length > 0 ?
879 lm.guess_language(_this.file.path, _this.file.content_type) :
880 lm.get_language(lang);
883 ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg);
885 this.el.insert_spaces_instead_of_tabs = true;
887 print("sourcelanguage = %s\n", lg.name);
888 if (lg.name == "Vala") {
889 this.el.insert_spaces_instead_of_tabs = false;
893 this.el.grab_focus();
894 _this.save_button.el.sensitive = false;
895 _this.last_error_counter = -1;
898 public class Xcls_buffer : Object
900 public GtkSource.Buffer el;
901 private Editor _this;
905 public int error_line;
906 public Gee.HashMap<int,string>? xmarks;
907 public bool check_queued;
910 public Xcls_buffer(Editor _owner )
914 this.el = new GtkSource.Buffer( null );
917 this.error_line = -1;
919 this.check_queued = false;
921 // set gobject values
922 this.el.highlight_syntax = true;
923 this.el.highlight_matching_brackets = true;
924 this.el.enable_undo = true;
929 buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
930 buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
931 buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
932 buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
933 buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
934 buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
935 buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
936 buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
939 buf.create_tag ("ERR", "weight", Pango.Weight.BOLD, "background", "pink");
940 buf.create_tag ("WARN", "weight", Pango.Weight.BOLD, "background", "#ABF4EB");
941 buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
944 this.el.cursor_moved.connect( ( ) => {
947 this.el.get_iter_at_offset (
948 out iter, this.el.cursor_position);
950 _this.navigation.updateSelectedLine(
951 (uint)iter.get_line(),
952 (uint)iter.get_line_offset()
957 this.el.changed.connect( () => {
960 _this.save_button.el.sensitive = true;
961 print("EDITOR CHANGED");
966 // this.get('/LeftPanel.model').changed( str , false);
971 // user defined functions
972 public bool OLDhighlightErrorsJson (string type, Json.Object obj) {
975 this.el.get_bounds (out start, out end);
977 this.el.remove_source_marks (start, end, type);
978 GLib.debug("highlight errors");
980 // we should highlight other types of errors..
982 if (!obj.has_member(type)) {
983 GLib.debug("Return has no errors\n");
987 if (_this.window.windowstate.state != WindowState.State.CODEONLY
989 _this.window.windowstate.state != WindowState.State.CODE
991 GLib.debug("windowstate != CODEONLY?");
996 //this.marks = new Gee.HashMap<int,string>();
997 var err = obj.get_object_member(type);
999 if (_this.file == null) {
1000 GLib.debug("file is null?");
1004 var valafn = _this.file.path;
1006 if (_this.file.xtype != "PlainFile") {
1010 var regex = new Regex("\\.bjs$");
1011 // should not happen
1012 valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
1013 } catch (GLib.RegexError e) {
1020 if (!err.has_member(valafn)) {
1021 GLib.debug("File path has no errors");
1025 var lines = err.get_object_member(valafn);
1028 if (obj.has_member("line_offset")) { // ?? why??
1029 offset = (int)obj.get_int_member("line_offset") + 1;
1033 var tlines = this.el.get_line_count () +1;
1035 if (_this.prop != null) {
1037 tlines = _this.prop.end_line + 1;
1038 offset = _this.prop.start_line + 1;
1044 lines.foreach_member((obj, line, node) => {
1047 // print("get inter\n");
1048 var eline = int.parse(line) - offset;
1049 GLib.debug("GOT ERROR on line %s -- converted to %d (offset = %d)\n", line,eline, offset);
1052 if (eline > tlines || eline < 0) {
1057 this.el.get_iter_at_line( out iter, eline);
1058 //print("mark line\n");
1060 var ar = lines.get_array_member(line);
1061 for (var i = 0 ; i < ar.get_length(); i++) {
1062 if (ar.get_string_element(i) == "Success") {
1065 msg += (msg.length > 0) ? "\n" : "";
1066 msg += ar.get_string_element(i);
1071 msg = "Line: %d".printf(eline+1) + " " + msg;
1072 this.el.create_source_mark(msg, type, iter);
1073 GLib.debug("set line %d to %m", eline, msg);
1074 // this.marks.set(eline, msg);
1083 public bool checkSyntax () {
1086 var str = this.toString();
1089 if (this.error_line > 0) {
1092 this.el.get_bounds (out start, out end);
1094 this.el.remove_source_marks (start, end, null);
1096 if (str.length < 1) {
1097 print("checkSyntax - empty string?\n");
1102 if (_this.file.xtype == "PlainFile") {
1104 // assume it's gtk...
1105 var oldcode =_this.file.toSource();
1106 _this.file.setSource(str);
1107 BuilderApplication.showSpinner("appointment soon","document change pending");
1108 _this.file.getLanguageServer().document_change(_this.file);
1109 _this.file.getLanguageServer().queueDocumentSymbols(_this.file);
1110 _this.file.setSource(oldcode);
1116 if (_this.file == null) {
1124 GLib.debug("calling validate");
1125 // clear the buttons.
1126 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
1129 var oldcode = _this.prop.val;
1131 _this.prop.val = str;
1132 _this.node.updated_count++;
1133 _this.file.getLanguageServer().document_change(_this.file);
1134 _this.node.updated_count++;
1135 _this.prop.val = oldcode;
1138 //print("done mark line\n");
1140 return true; // at present allow saving - even if it's invalid..
1142 public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
1144 this.error_line = validate_res.size;
1146 if (this.error_line < 1) {
1149 var tlines = this.el.get_line_count ();
1151 var valiter = validate_res.map_iterator();
1152 while (valiter.next()) {
1154 // print("get inter\n");
1155 var eline = valiter.get_key();
1156 if (eline > tlines) {
1159 this.el.get_iter_at_line( out iter, eline);
1160 //print("mark line\n");
1161 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
1165 public string toString () {
1169 this.el.get_start_iter(out s);
1170 this.el.get_end_iter(out e);
1171 var ret = this.el.get_text(s,e,true);
1172 //print("TO STRING? " + ret);
1177 public class Xcls_keystate : Object
1179 public Gtk.EventControllerKey el;
1180 private Editor _this;
1184 public bool is_control;
1187 public Xcls_keystate(Editor _owner )
1190 _this.keystate = this;
1191 this.el = new Gtk.EventControllerKey();
1194 this.is_control = false;
1196 // set gobject values
1199 this.el.key_released.connect( (keyval, keycode, state) => {
1201 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1202 this.is_control = false;
1204 if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1205 GLib.debug("SAVE: ctrl-S pressed");
1206 _this.saveContents();
1210 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1211 GLib.debug("SAVE: ctrl-g pressed");
1212 _this.forwardSearch(true);
1215 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1216 GLib.debug("SAVE: ctrl-f pressed");
1217 _this.search_entry.el.grab_focus();
1218 _this.search_entry.el.select_region(0,-1);
1221 if (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1222 _this.view.el.show_completion();
1226 _this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);
1227 var line = iter.get_line();
1228 var offset = iter.get_line_offset();
1229 GLib.debug("line %d off %d", line ,offset);
1230 if (_this.prop != null) {
1231 line += _this.prop.start_line + 1; // i think..
1232 offset += 12; // should probably be 8 without namespaced
1233 GLib.debug("guess line %d off %d", line ,offset);
1235 //_this.view.el.show_completion();
1236 // print(event.key.keyval)
1243 this.el.key_pressed.connect( (keyval, keycode, state) => {
1245 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1246 this.is_control = true;
1252 // user defined functions
1255 public class Xcls_EventControllerScroll13 : Object
1257 public Gtk.EventControllerScroll el;
1258 private Editor _this;
1262 public double distance;
1265 public Xcls_EventControllerScroll13(Editor _owner )
1268 this.el = new Gtk.EventControllerScroll( Gtk.EventControllerScrollFlags.VERTICAL );
1271 this.distance = 0.0f;
1273 // set gobject values
1276 this.el.scroll.connect( (dx, dy) => {
1277 if (!_this.keystate.is_control) {
1280 //GLib.debug("scroll %f", dy);
1282 this.distance += dy;
1284 //GLib.debug("scroll %f / %f", dy, this.distance);
1286 if (this.distance < -1) {
1288 BuilderApplication.settings.editor_font_size ++;
1291 if (this.distance > 1) {
1292 BuilderApplication.settings.editor_font_size --;
1300 // user defined functions
1303 public class Xcls_GestureClick14 : Object
1305 public Gtk.GestureClick el;
1306 private Editor _this;
1312 public Xcls_GestureClick14(Editor _owner )
1315 this.el = new Gtk.GestureClick();
1319 // set gobject values
1322 this.el.pressed.connect( (n_press, x, y) => {
1324 int buffer_x, buffer_y;
1325 var gut = _this.view.el.get_gutter(Gtk.TextWindowType.LEFT);
1327 _this.view.el.window_to_buffer_coords (Gtk.TextWindowType.TEXT,
1328 (int)x - gut.get_width(), (int)y,
1329 out buffer_x, out buffer_y);
1330 _this.view.el.get_iter_at_location (out iter,
1331 buffer_x, buffer_y);;
1334 if (_this.buffer.el.iter_has_context_class(iter, "comment") ||
1335 _this.buffer.el.iter_has_context_class(iter, "string")
1339 var back = iter.copy();
1340 back.backward_char();
1342 var forward = iter.copy();
1343 forward.forward_char();
1345 // what's the character at the iter?
1346 var str = back.get_text(iter);
1347 str += iter.get_text(forward);
1348 if (str.strip().length < 1) {
1351 var offset = iter.get_line_offset();
1352 var line = iter.get_line();
1353 if (_this.prop != null) {
1355 line += _this.prop.start_line ;
1356 // this is based on Gtk using tabs (hence 1/2 chars);
1357 offset += _this.node.node_pad.length;
1358 // javascript listeners are indented 2 more spaces.
1359 if (_this.prop.ptype == JsRender.NodePropType.LISTENER) {
1364 var ls = _this.file.getLanguageServer();
1366 _this.file, line, offset,
1368 var res = ls.hover.end(o );
1369 _this.helper.setHelp(res);
1373 things that can ber returned..
1377 Jsrennder.jsrender Editor.file
1378 Palete.LanguageClient? JsRender.JsRender.getLanguageServer ()
1379 Palete.LanguageClient? ls = _this.file.getLanguageServer()
1380 async Lsp.Hover Palete.LanguageClient.hover (JsRender.JsRender file, int line, int offset) throws GLib.Error
1381 .string JsRender.Node.node_pad = \"\"
1384 string Gtk.TextIter.get_text (Gtk.TextIter end)
1389 // could never get this to work anywhere..
1390 // looks like its probably for calling stuff..
1391 // but always returns null..
1393 ls.signatureHelp.begin(
1394 _this.file, iter.get_line(), iter.get_line_offset(),
1396 var res = ls.signatureHelp.end(o );
1404 // user defined functions
1409 public class Xcls_Box15 : Object
1412 private Editor _this;
1418 public Xcls_Box15(Editor _owner )
1421 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1425 // set gobject values
1426 this.el.homogeneous = false;
1427 this.el.vexpand = false;
1428 new Xcls_search_entry( _this );
1429 this.el.append( _this.search_entry.el );
1430 new Xcls_search_results( _this );
1431 this.el.append( _this.search_results.el );
1432 new Xcls_nextBtn( _this );
1433 this.el.append( _this.nextBtn.el );
1434 new Xcls_backBtn( _this );
1435 this.el.append( _this.backBtn.el );
1436 var child_5 = new Xcls_MenuButton21( _this );
1438 this.el.append( child_5.el );
1441 // user defined functions
1443 public class Xcls_search_entry : Object
1445 public Gtk.SearchEntry el;
1446 private Editor _this;
1450 public Gtk.CssProvider css;
1453 public Xcls_search_entry(Editor _owner )
1456 _this.search_entry = this;
1457 this.el = new Gtk.SearchEntry();
1461 // set gobject values
1462 this.el.name = "editor-search-entry";
1463 this.el.hexpand = true;
1464 this.el.placeholder_text = "Press enter to search";
1465 this.el.search_delay = 3;
1466 var child_1 = new Xcls_EventControllerKey17( _this );
1468 this.el.add_controller( child_1.el );
1471 this.el.search_changed.connect( ( ) => {
1473 _this.search(_this.search_entry.el.text);
1474 _this.search_results.updateResults();
1476 GLib.Timeout.add_seconds(1,() => {
1477 _this.search_results.updateResults();
1483 // user defined functions
1484 public void forwardSearch (bool change_focus) {
1487 _this.forwardSearch(change_focus);
1491 switch(_this.windowstate.state) {
1492 case WindowState.State.CODEONLY:
1493 //case WindowState.State.CODE:
1494 // search the code being edited..
1495 _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1498 case WindowState.State.PREVIEW:
1499 if (_this.windowstate.file.xtype == "Gtk") {
1500 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1502 _this.windowstate.window_rooview.forwardSearch(change_focus);
1511 public class Xcls_EventControllerKey17 : Object
1513 public Gtk.EventControllerKey el;
1514 private Editor _this;
1520 public Xcls_EventControllerKey17(Editor _owner )
1523 this.el = new Gtk.EventControllerKey();
1527 // set gobject values
1530 this.el.key_pressed.connect( (keyval, keycode, state) => {
1532 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1533 GLib.debug("SAVE: ctrl-g pressed");
1534 _this.forwardSearch(true);
1539 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1540 _this.forwardSearch(true);
1546 // print(event.key.keyval)
1552 // user defined functions
1556 public class Xcls_search_results : Object
1558 public Gtk.Label el;
1559 private Editor _this;
1565 public Xcls_search_results(Editor _owner )
1568 _this.search_results = this;
1569 this.el = new Gtk.Label( "No Results" );
1573 // set gobject values
1574 this.el.margin_end = 4;
1575 this.el.margin_start = 4;
1578 // user defined functions
1579 public void updateResults () {
1580 this.el.visible = true;
1582 var res = _this.searchcontext.get_occurrences_count();
1584 _this.search_results.el.label = "??? Matches";
1588 _this.nextBtn.el.sensitive = false;
1589 _this.backBtn.el.sensitive = false;
1592 _this.search_results.el.label = "%d Matches".printf(res);
1593 _this.nextBtn.el.sensitive = true;
1594 _this.backBtn.el.sensitive = true;
1597 _this.search_results.el.label = "No Matches";
1602 public class Xcls_nextBtn : Object
1604 public Gtk.Button el;
1605 private Editor _this;
1609 public bool always_show_image;
1612 public Xcls_nextBtn(Editor _owner )
1615 _this.nextBtn = this;
1616 this.el = new Gtk.Button();
1619 this.always_show_image = true;
1621 // set gobject values
1622 this.el.icon_name = "go-down";
1623 this.el.sensitive = false;
1626 this.el.clicked.connect( (event) => {
1628 _this.forwardSearch(true);
1634 // user defined functions
1637 public class Xcls_backBtn : Object
1639 public Gtk.Button el;
1640 private Editor _this;
1644 public bool always_show_image;
1647 public Xcls_backBtn(Editor _owner )
1650 _this.backBtn = this;
1651 this.el = new Gtk.Button();
1654 this.always_show_image = true;
1656 // set gobject values
1657 this.el.icon_name = "go-up";
1658 this.el.sensitive = false;
1661 this.el.clicked.connect( (event) => {
1663 _this.backSearch(true);
1668 // user defined functions
1671 public class Xcls_MenuButton21 : Object
1673 public Gtk.MenuButton el;
1674 private Editor _this;
1678 public bool always_show_image;
1681 public Xcls_MenuButton21(Editor _owner )
1684 this.el = new Gtk.MenuButton();
1687 this.always_show_image = true;
1689 // set gobject values
1690 this.el.icon_name = "emblem-system";
1691 this.el.always_show_arrow = true;
1692 new Xcls_search_settings( _this );
1693 this.el.popover = _this.search_settings.el;
1696 // user defined functions
1698 public class Xcls_search_settings : Object
1700 public Gtk.Popover el;
1701 private Editor _this;
1707 public Xcls_search_settings(Editor _owner )
1710 _this.search_settings = this;
1711 this.el = new Gtk.Popover();
1715 // set gobject values
1716 var child_1 = new Xcls_Box23( _this );
1718 this.el.child = child_1.el;
1721 // user defined functions
1723 public class Xcls_Box23 : Object
1726 private Editor _this;
1732 public Xcls_Box23(Editor _owner )
1735 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1739 // set gobject values
1740 new Xcls_case_sensitive( _this );
1741 this.el.append( _this.case_sensitive.el );
1742 new Xcls_regex( _this );
1743 this.el.append( _this.regex.el );
1744 new Xcls_multiline( _this );
1745 this.el.append( _this.multiline.el );
1748 // user defined functions
1750 public class Xcls_case_sensitive : Object
1752 public Gtk.CheckButton el;
1753 private Editor _this;
1759 public Xcls_case_sensitive(Editor _owner )
1762 _this.case_sensitive = this;
1763 this.el = new Gtk.CheckButton();
1767 // set gobject values
1768 this.el.label = "Case Sensitive";
1777 // user defined functions
1780 public class Xcls_regex : Object
1782 public Gtk.CheckButton el;
1783 private Editor _this;
1789 public Xcls_regex(Editor _owner )
1793 this.el = new Gtk.CheckButton();
1797 // set gobject values
1798 this.el.label = "Regex";
1807 // user defined functions
1810 public class Xcls_multiline : Object
1812 public Gtk.CheckButton el;
1813 private Editor _this;
1819 public Xcls_multiline(Editor _owner )
1822 _this.multiline = this;
1823 this.el = new Gtk.CheckButton();
1827 // set gobject values
1828 this.el.label = "Multi-line (add \\n)";
1831 // user defined functions
1839 public class Xcls_Box27 : Object
1842 private Editor _this;
1848 public Xcls_Box27(Editor _owner )
1851 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1855 // set gobject values
1856 this.el.hexpand = true;
1857 this.el.vexpand = true;
1858 var child_1 = new Xcls_Box28( _this );
1860 this.el.append( child_1.el );
1861 new Xcls_navigationwindow( _this );
1862 this.el.append( _this.navigationwindow.el );
1865 // user defined functions
1867 public class Xcls_Box28 : Object
1870 private Editor _this;
1876 public Xcls_Box28(Editor _owner )
1879 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1883 // set gobject values
1886 // user defined functions
1889 public class Xcls_navigationwindow : Object
1891 public Gtk.ScrolledWindow el;
1892 private Editor _this;
1898 public Xcls_navigationwindow(Editor _owner )
1901 _this.navigationwindow = this;
1902 this.el = new Gtk.ScrolledWindow();
1906 // set gobject values
1907 this.el.hexpand = true;
1908 this.el.vexpand = true;
1909 this.el.visible = false;
1910 new Xcls_navigation( _this );
1911 this.el.child = _this.navigation.el;
1914 // user defined functions
1916 public class Xcls_navigation : Object
1918 public Gtk.ColumnView el;
1919 private Editor _this;
1923 public int last_selected_line;
1924 public Gtk.Widget? selected_row;
1927 public Xcls_navigation(Editor _owner )
1930 _this.navigation = this;
1931 new Xcls_navigationselmodel( _this );
1932 this.el = new Gtk.ColumnView( _this.navigationselmodel.el );
1935 this.last_selected_line = -1;
1936 this.selected_row = null;
1938 // set gobject values
1939 this.el.name = "editor-navigation";
1940 var child_2 = new Xcls_ColumnViewColumn31( _this );
1942 this.el.append_column( child_2.el );
1943 var child_3 = new Xcls_GestureClick40( _this );
1945 this.el.add_controller( child_3.el );
1948 // user defined functions
1949 public Gtk.Widget? getRowWidgetAt (double x, double y, out string pos) {
1952 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
1953 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
1958 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
1963 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
1967 //GLib.debug("row number is %d", rn);
1968 //GLib.debug("click %d, %d", (int)x, (int)y);
1970 Graphene.Rect bounds;
1971 row.compute_bounds(this.el, out bounds);
1972 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
1973 // (int)bounds.get_x(), (int)bounds.get_y(),
1974 // (int)bounds.get_width(), (int)bounds.get_height()
1976 var ypos = y - bounds.get_y();
1977 //GLib.debug("rel ypos = %d", (int)ypos);
1978 var rpos = 100.0 * (ypos / bounds.get_height());
1979 //GLib.debug("rel pos = %d %%", (int)rpos);
1984 } else if (rpos < 20) {
1989 public void show (Gee.ArrayList<Lsp.DocumentSymbol> syms) {
1990 _this.navigationwindow.el.show();
1991 //_this.navliststore.el.remove_all();
1994 var ls = new GLib.ListStore(typeof(Lsp.DocumentSymbol));
1996 foreach(var sym in syms) {
1999 Lsp.DocumentSymbol.copyList(ls, _this.navliststore.el);
2000 //_this.navliststore.el.append(sym);
2001 this.last_selected_line = -1;
2002 GLib.Idle.add(() => {
2003 _this.navigationsort.collapseOnLoad();
2005 _this.buffer.el.get_iter_at_offset (
2006 out iter, _this.buffer.el.cursor_position);
2008 GLib.debug("idle update scroll %d, %d", iter.get_line(),
2009 iter.get_line_offset());
2010 this.updateSelectedLine(
2011 (uint)iter.get_line(),
2012 (uint)iter.get_line_offset()
2018 public int getRowAt (double x, double y, out string pos) {
2021 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
2022 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
2027 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
2032 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2037 while (cr.get_prev_sibling() != null) {
2039 cr = cr.get_prev_sibling();
2042 //GLib.debug("row number is %d", rn);
2043 //GLib.debug("click %d, %d", (int)x, (int)y);
2045 Graphene.Rect bounds;
2046 row.compute_bounds(this.el, out bounds);
2047 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2048 // (int)bounds.get_x(), (int)bounds.get_y(),
2049 // (int)bounds.get_width(), (int)bounds.get_height()
2051 var ypos = y - bounds.get_y();
2052 //GLib.debug("rel ypos = %d", (int)ypos);
2053 var rpos = 100.0 * (ypos / bounds.get_height());
2054 //GLib.debug("rel pos = %d %%", (int)rpos);
2059 } else if (rpos < 20) {
2064 public void updateSelectedLine (uint line, uint chr) {
2065 if (line == this.last_selected_line) {
2068 GLib.debug("select line %d", (int)line);
2069 this.last_selected_line = (int)line;
2073 var sym = _this.navliststore.symbolAtLine(line, chr);
2075 new_row = _this.navigationsort.getRowFromSymbol(sym);
2076 GLib.debug("select line %d - row found %d", (int)line, new_row);
2078 GLib.debug(" no symbol found at line %d", (int)line);
2081 if (this.selected_row != null) {
2082 GLib.debug(" remove selected row");
2083 this.selected_row.remove_css_class("selected-row");
2085 this.selected_row = null;
2087 this.el.scroll_to(new_row,null,Gtk.ListScrollFlags.NONE, null);
2088 var row = sym.get_data<Gtk.Widget>("widget");
2090 GLib.debug(" Add selected row");
2092 row.add_css_class("selected-row");
2093 this.selected_row = row;
2097 GLib.debug("could not find widget on row %d", new_row);
2105 public class Xcls_ColumnViewColumn31 : Object
2107 public Gtk.ColumnViewColumn el;
2108 private Editor _this;
2114 public Xcls_ColumnViewColumn31(Editor _owner )
2117 var child_1 = new Xcls_SignalListItemFactory32( _this );
2119 this.el = new Gtk.ColumnViewColumn( "Code Navigation", child_1.el );
2123 // set gobject values
2124 this.el.expand = true;
2127 // user defined functions
2129 public class Xcls_SignalListItemFactory32 : Object
2131 public Gtk.SignalListItemFactory el;
2132 private Editor _this;
2138 public Xcls_SignalListItemFactory32(Editor _owner )
2141 this.el = new Gtk.SignalListItemFactory();
2145 // set gobject values
2148 this.el.setup.connect( (listitem) => {
2150 var expand = new Gtk.TreeExpander();
2152 expand.set_indent_for_depth(true);
2153 expand.set_indent_for_icon(true);
2154 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2155 var icon = new Gtk.Image();
2156 var lbl = new Gtk.Label("");
2157 lbl.use_markup = true;
2158 lbl.ellipsize = Pango.EllipsizeMode.END;
2160 icon.margin_end = 4;
2161 lbl.justify = Gtk.Justification.LEFT;
2164 // listitem.activatable = true; ??
2168 expand.set_child(hbox);
2169 ((Gtk.ListItem)listitem).set_child(expand);
2172 this.el.bind.connect( (listitem) => {
2174 // GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name());
2176 //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2177 var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2180 var hbox = (Gtk.Box) expand.child;
2183 var img = (Gtk.Image) hbox.get_first_child();
2184 var lbl = (Gtk.Label) img.get_next_sibling();
2186 var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();
2187 var sym = (Lsp.DocumentSymbol) lr.get_item();
2189 sym.set_data<Gtk.Widget>("widget", expand.get_parent());
2190 expand.get_parent().get_parent().set_data<Lsp.DocumentSymbol>("symbol", sym);
2192 //GLib.debug("save sym on %s", expand.get_parent().get_parent().get_type().name());
2194 //GLib.debug("got %d children for %s" , (int)sym.children.get_n_items(), sym.name);
2196 expand.set_hide_expander( sym.children.get_n_items() < 1);
2197 expand.set_list_row(lr);
2198 //this.in_bind = true;
2199 // default is to expand
2201 //this.in_bind = false;
2203 sym.bind_property("symbol_icon",
2205 GLib.BindingFlags.SYNC_CREATE);
2207 hbox.css_classes = { sym.symbol_icon };
2209 sym.bind_property("name",
2211 GLib.BindingFlags.SYNC_CREATE);
2212 // should be better?- --line no?
2213 sym.bind_property("tooltip",
2214 lbl, "tooltip_markup",
2215 GLib.BindingFlags.SYNC_CREATE);
2221 // user defined functions
2225 public class Xcls_navigationselmodel : Object
2227 public Gtk.NoSelection el;
2228 private Editor _this;
2234 public Xcls_navigationselmodel(Editor _owner )
2237 _this.navigationselmodel = this;
2238 new Xcls_navigationsort( _this );
2239 this.el = new Gtk.NoSelection( _this.navigationsort.el );
2243 // set gobject values
2246 // user defined functions
2248 public class Xcls_navigationsort : Object
2250 public Gtk.SortListModel el;
2251 private Editor _this;
2257 public Xcls_navigationsort(Editor _owner )
2260 _this.navigationsort = this;
2261 var child_1 = new Xcls_TreeListModel35( _this );
2263 var child_2 = new Xcls_TreeListRowSorter37( _this );
2265 this.el = new Gtk.SortListModel( child_1.el, child_2.el );
2269 // set gobject values
2272 // user defined functions
2273 public void collapseOnLoad () {
2274 for (var i=0;i < this.el.get_n_items(); i++) {
2275 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2276 var sym = (Lsp.DocumentSymbol)tr.get_item();
2278 case Lsp.SymbolKind.Enum:
2279 tr.expanded = false;
2282 //tr.expanded = true;
2291 public int getRowFromSymbol (Lsp.DocumentSymbol sym) {
2293 for (var i=0;i < this.el.get_n_items(); i++) {
2294 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2296 if (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {
2302 public Lsp.DocumentSymbol? getSymbolAt (uint row) {
2304 var tr = (Gtk.TreeListRow)this.el.get_item(row);
2306 var a = tr.get_item();;
2307 GLib.debug("get_item (2) = %s", a.get_type().name());
2310 return (Lsp.DocumentSymbol)tr.get_item();
2314 public class Xcls_TreeListModel35 : Object
2316 public Gtk.TreeListModel el;
2317 private Editor _this;
2323 public Xcls_TreeListModel35(Editor _owner )
2326 new Xcls_navliststore( _this );
2327 this.el = new Gtk.TreeListModel( _this.navliststore.el, false, true, (item) => {
2329 return ((Lsp.DocumentSymbol)item).children;
2335 // set gobject values
2338 this.el.items_changed.connect( (position, removed, added) => {
2339 GLib.debug("tree item changed %d , %d , %d",(int) position, (int)removed, (int) added);
2343 //var sym = (Lsp.DocumentSymbol) this.el.get_item(position);
2344 var row = this.el.get_row(position);
2346 GLib.debug("got %s", row.get_item().get_type().name());
2352 // user defined functions
2354 public class Xcls_navliststore : Object
2356 public GLib.ListStore el;
2357 private Editor _this;
2363 public Xcls_navliststore(Editor _owner )
2366 _this.navliststore = this;
2367 this.el = new GLib.ListStore( typeof(Lsp.DocumentSymbol) );
2371 // set gobject values
2374 // user defined functions
2375 public Lsp.DocumentSymbol? symbolAtLine (uint line, uint chr) {
2378 for(var i = 0; i < this.el.get_n_items();i++) {
2379 var el = (Lsp.DocumentSymbol)this.el.get_item(i);
2380 //GLib.debug("Check sym %s : %d-%d",
2381 // el.name , (int)el.range.start.line,
2382 // (int)el.range.end.line
2384 var ret = el.containsLine(line,chr);
2396 public class Xcls_TreeListRowSorter37 : Object
2398 public Gtk.TreeListRowSorter el;
2399 private Editor _this;
2405 public Xcls_TreeListRowSorter37(Editor _owner )
2408 var child_1 = new Xcls_StringSorter38( _this );
2410 this.el = new Gtk.TreeListRowSorter( child_1.el );
2414 // set gobject values
2417 // user defined functions
2419 public class Xcls_StringSorter38 : Object
2421 public Gtk.StringSorter el;
2422 private Editor _this;
2428 public Xcls_StringSorter38(Editor _owner )
2431 var child_1 = new Xcls_PropertyExpression39( _this );
2433 this.el = new Gtk.StringSorter( child_1.el );
2437 // set gobject values
2440 // user defined functions
2442 public class Xcls_PropertyExpression39 : Object
2444 public Gtk.PropertyExpression el;
2445 private Editor _this;
2451 public Xcls_PropertyExpression39(Editor _owner )
2454 this.el = new Gtk.PropertyExpression( typeof(Lsp.DocumentSymbol), null, "sort_key" );
2458 // set gobject values
2461 // user defined functions
2468 public class Xcls_GestureClick40 : Object
2470 public Gtk.GestureClick el;
2471 private Editor _this;
2477 public Xcls_GestureClick40(Editor _owner )
2480 this.el = new Gtk.GestureClick();
2484 // set gobject values
2487 this.el.pressed.connect( (n_press, x, y) => {
2489 var row = _this.navigation.getRowWidgetAt(x,y, out pos );
2492 GLib.debug("no row selected items");
2495 GLib.debug("got click on %s", row.get_type().name());
2496 //Lsp.DocumentSymbol
2497 var sym = row.get_data<Lsp.DocumentSymbol>("symbol");
2513 GLib.debug("goto line %d", (int)sym.range.start.line);
2514 _this.scroll_to_line((int)sym.range.start.line);
2516 _this.buffer.el.get_iter_at_line_offset(out iter,
2517 (int)sym.range.start.line,
2518 (int)sym.range.start.character
2520 _this.buffer.el.place_cursor(iter);
2525 // user defined functions