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 new Xcls_save_button( _this );
480 this.el.append( _this.save_button.el );
481 new Xcls_helper( _this );
482 this.el.append( _this.helper.el );
483 var child_3 = new Xcls_Scale6( _this );
485 this.el.append( child_3.el );
486 new Xcls_close_btn( _this );
487 this.el.append( _this.close_btn.el );
490 // user defined functions
492 public class Xcls_save_button : Object
494 public Gtk.Button el;
495 private Editor _this;
501 public Xcls_save_button(Editor _owner )
504 _this.save_button = this;
505 this.el = new Gtk.Button();
509 // set gobject values
510 this.el.vexpand = true;
511 this.el.label = "Save";
514 this.el.clicked.connect( () => {
515 _this.saveContents();
519 // user defined functions
522 public class Xcls_helper : Object
525 private Editor _this;
531 public Xcls_helper(Editor _owner )
535 this.el = new Gtk.Label( null );
539 // set gobject values
540 this.el.margin_end = 4;
541 this.el.margin_start = 4;
542 this.el.hexpand = true;
545 // user defined functions
548 public class Xcls_Scale6 : Object
551 private Editor _this;
557 public Xcls_Scale6(Editor _owner )
560 this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1);
564 // set gobject values
565 this.el.width_request = 200;
566 this.el.has_origin = true;
567 this.el.draw_value = false;
569 this.el.sensitive = true;
574 //this.el.set_range(6,30);
575 this.el.set_value ( BuilderApplication.settings.editor_font_size);
576 BuilderApplication.settings.editor_font_size_updated.connect(
578 BuilderApplication.settings.editor_font_size_inchange = true;
579 // GLib.debug("update range");
580 this.el.set_value (BuilderApplication.settings.editor_font_size);
581 BuilderApplication.settings.editor_font_size_inchange = false;
589 this.el.change_value.connect( (st, val ) => {
590 if (BuilderApplication.settings.editor_font_size_inchange) {
593 BuilderApplication.settings.editor_font_size = val;
598 // user defined functions
601 public class Xcls_close_btn : Object
603 public Gtk.Button el;
604 private Editor _this;
610 public Xcls_close_btn(Editor _owner )
613 _this.close_btn = this;
614 this.el = new Gtk.Button();
618 // set gobject values
619 this.el.icon_name = "window-close";
620 var child_1 = new Xcls_Image8( _this );
622 this.el.child = child_1.el;
625 this.el.clicked.connect( () => {
626 _this.saveContents();
627 _this.window.windowstate.switchState(WindowState.State.PREVIEW);
631 // user defined functions
633 public class Xcls_Image8 : Object
636 private Editor _this;
642 public Xcls_Image8(Editor _owner )
645 this.el = new Gtk.Image();
649 // set gobject values
650 this.el.icon_name = "window-close";
651 this.el.icon_size = Gtk.IconSize.NORMAL;
654 // user defined functions
659 public class Xcls_RightEditor : Object
661 public Gtk.ScrolledWindow el;
662 private Editor _this;
668 public Xcls_RightEditor(Editor _owner )
671 _this.RightEditor = this;
672 this.el = new Gtk.ScrolledWindow();
676 // set gobject values
677 this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
678 this.el.vexpand = true;
679 this.el.overlay_scrolling = false;
680 this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
681 new Xcls_view( _this );
682 this.el.child = _this.view.el;
685 // user defined functions
687 public class Xcls_view : Object
689 public GtkSource.View el;
690 private Editor _this;
694 public Gtk.CssProvider css;
697 public Xcls_view(Editor _owner )
701 this.el = new GtkSource.View();
706 // set gobject values
707 this.el.auto_indent = true;
708 this.el.indent_width = 4;
709 this.el.name = "editor-view";
710 this.el.show_line_marks = true;
711 this.el.insert_spaces_instead_of_tabs = true;
712 this.el.show_line_numbers = true;
713 this.el.hexpand = true;
714 this.el.vexpand = true;
715 this.el.has_tooltip = true;
716 this.el.css_classes = { "code-editor" };
717 this.el.tab_width = 4;
718 this.el.highlight_current_line = true;
719 new Xcls_buffer( _this );
720 this.el.buffer = _this.buffer.el;
721 new Xcls_keystate( _this );
722 this.el.add_controller( _this.keystate.el );
723 var child_3 = new Xcls_EventControllerScroll13( _this );
725 this.el.add_controller( child_3.el );
726 var child_4 = new Xcls_GestureClick14( _this );
728 this.el.add_controller( child_4.el );
732 this.el.completion.add_provider(
733 new Palete.CompletionProvider(_this)
736 // hover seems pretty useless.. - ??
737 //var hover = this.el.get_hover();
738 //hover.add_provider(new Palete.HoverProvider(_this));
740 //this.el.completion.unblock_interactive();
741 this.el.completion.select_on_show = true; // select
742 //this.el.completion.remember_info_visibility = true;
745 var attrs = new GtkSource.MarkAttributes();
747 attrs.set_icon_name ( "process-stop");
748 attrs.query_tooltip_text.connect(( mark) => {
749 GLib.debug("tooltip query? %s", mark.name);
750 return strdup( mark.name);
752 attrs.query_tooltip_markup.connect(( mark) => {
753 GLib.debug("tooltip query? %s", mark.name);
754 return strdup( mark.name);
756 this.el.set_mark_attributes ("ERR", attrs, 1);
760 var wattrs = new GtkSource.MarkAttributes();
761 wattrs.set_icon_name ( "process-stop");
762 wattrs.query_tooltip_text.connect(( mark) => {
763 GLib.debug("tooltip query? %s", mark.name);
764 return strdup(mark.name);
766 wattrs.query_tooltip_markup.connect(( mark) => {
767 GLib.debug("tooltip query? %s", mark.name);
768 return strdup(mark.name);
770 this.el.set_mark_attributes ("WARN", wattrs, 1);
774 var dattrs = new GtkSource.MarkAttributes();
776 dattrs.set_icon_name ( "process-stop");
778 dattrs.query_tooltip_text.connect(( mark) => {
779 GLib.debug("tooltip query? %s", mark.name);
780 return strdup(mark.name);
782 //dattrs.query_tooltip_markup.connect(( mark) => {
783 // GLib.debug("tooltip query? %s", mark.name);
784 // return strdup(mark.name);
786 this.el.set_mark_attributes ("DEPR", dattrs, 1);
789 this.el.get_space_drawer().set_matrix(null);
790 this.el.get_space_drawer().set_types_for_locations(
791 GtkSource.SpaceLocationFlags.ALL,
792 GtkSource.SpaceTypeFlags.ALL
794 this.el.get_space_drawer().set_enable_matrix(true);
797 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
799 //GLib.debug("query tooltip");
803 var yoff = (int) _this.RightEditor.el.vadjustment.value;
805 // I think this is problematic - if it's compliing / updating at same time as query.
807 //if (_this.window.statusbar_compile_spinner.el.spinning) {
811 this.el.get_iter_at_position (out iter, out trailing, x, y + yoff);
813 var l = iter.get_line();
817 // GLib.debug("query tooltip line %d", (int) l);
823 if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {
824 GLib.debug("line %d setting tip to %s", l, _this.buffer.marks.get(l));
825 tooltip.set_text(_this.buffer.marks.get(l).dup());
833 // this crashes?? - not sure why.
834 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
835 if (marks.is_empty()) {
836 marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
838 if (marks.is_empty()) {
839 marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
842 // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length());
844 marks.@foreach((m) => {
845 //GLib.debug("got mark %s", m.name);
846 str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name;
848 // true if there is a mark..
849 if (str.length > 0 ) {
850 tooltip.set_text( str );
852 return str.length > 0 ? true : false;
857 // user defined functions
858 public void load (string str) {
860 // show the help page for the active node..
861 //this.get('/Help').show();
863 // this.get('/BottomPane').el.set_current_page(0);
864 GLib.debug("load called - Reset undo buffer");
866 var buf = (GtkSource.Buffer)this.el.get_buffer();
867 buf.begin_irreversible_action();
868 buf.set_text(str, str.length);
869 buf.end_irreversible_action();
871 var lm = GtkSource.LanguageManager.get_default();
873 if (_this.file != null) {
874 lang = _this.file.language;
876 print("lang=%s, content_type = %s\n", lang, _this.file.content_type);
877 var lg = _this.file.content_type.length > 0 ?
878 lm.guess_language(_this.file.path, _this.file.content_type) :
879 lm.get_language(lang);
882 ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg);
884 this.el.insert_spaces_instead_of_tabs = true;
886 print("sourcelanguage = %s\n", lg.name);
887 if (lg.name == "Vala") {
888 this.el.insert_spaces_instead_of_tabs = false;
892 this.el.grab_focus();
893 _this.save_button.el.sensitive = false;
894 _this.last_error_counter = -1;
897 public class Xcls_buffer : Object
899 public GtkSource.Buffer el;
900 private Editor _this;
904 public int error_line;
905 public Gee.HashMap<int,string>? xmarks;
906 public bool check_queued;
909 public Xcls_buffer(Editor _owner )
913 this.el = new GtkSource.Buffer( null );
916 this.error_line = -1;
918 this.check_queued = false;
920 // set gobject values
921 this.el.highlight_syntax = true;
922 this.el.highlight_matching_brackets = true;
923 this.el.enable_undo = true;
928 buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
929 buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
930 buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
931 buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
932 buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
933 buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
934 buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
935 buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
938 buf.create_tag ("ERR", "weight", Pango.Weight.BOLD, "background", "pink");
939 buf.create_tag ("WARN", "weight", Pango.Weight.BOLD, "background", "#ABF4EB");
940 buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
943 this.el.cursor_moved.connect( ( ) => {
946 this.el.get_iter_at_offset (
947 out iter, this.el.cursor_position);
949 _this.navigation.updateSelectedLine(
950 (uint)iter.get_line(),
951 (uint)iter.get_line_offset()
956 this.el.changed.connect( () => {
959 _this.save_button.el.sensitive = true;
960 print("EDITOR CHANGED");
965 // this.get('/LeftPanel.model').changed( str , false);
970 // user defined functions
971 public bool OLDhighlightErrorsJson (string type, Json.Object obj) {
974 this.el.get_bounds (out start, out end);
976 this.el.remove_source_marks (start, end, type);
977 GLib.debug("highlight errors");
979 // we should highlight other types of errors..
981 if (!obj.has_member(type)) {
982 GLib.debug("Return has no errors\n");
986 if (_this.window.windowstate.state != WindowState.State.CODEONLY
988 _this.window.windowstate.state != WindowState.State.CODE
990 GLib.debug("windowstate != CODEONLY?");
995 //this.marks = new Gee.HashMap<int,string>();
996 var err = obj.get_object_member(type);
998 if (_this.file == null) {
999 GLib.debug("file is null?");
1003 var valafn = _this.file.path;
1005 if (_this.file.xtype != "PlainFile") {
1009 var regex = new Regex("\\.bjs$");
1010 // should not happen
1011 valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
1012 } catch (GLib.RegexError e) {
1019 if (!err.has_member(valafn)) {
1020 GLib.debug("File path has no errors");
1024 var lines = err.get_object_member(valafn);
1027 if (obj.has_member("line_offset")) { // ?? why??
1028 offset = (int)obj.get_int_member("line_offset") + 1;
1032 var tlines = this.el.get_line_count () +1;
1034 if (_this.prop != null) {
1036 tlines = _this.prop.end_line + 1;
1037 offset = _this.prop.start_line + 1;
1043 lines.foreach_member((obj, line, node) => {
1046 // print("get inter\n");
1047 var eline = int.parse(line) - offset;
1048 GLib.debug("GOT ERROR on line %s -- converted to %d (offset = %d)\n", line,eline, offset);
1051 if (eline > tlines || eline < 0) {
1056 this.el.get_iter_at_line( out iter, eline);
1057 //print("mark line\n");
1059 var ar = lines.get_array_member(line);
1060 for (var i = 0 ; i < ar.get_length(); i++) {
1061 if (ar.get_string_element(i) == "Success") {
1064 msg += (msg.length > 0) ? "\n" : "";
1065 msg += ar.get_string_element(i);
1070 msg = "Line: %d".printf(eline+1) + " " + msg;
1071 this.el.create_source_mark(msg, type, iter);
1072 GLib.debug("set line %d to %m", eline, msg);
1073 // this.marks.set(eline, msg);
1082 public bool checkSyntax () {
1085 var str = this.toString();
1088 if (this.error_line > 0) {
1091 this.el.get_bounds (out start, out end);
1093 this.el.remove_source_marks (start, end, null);
1095 if (str.length < 1) {
1096 print("checkSyntax - empty string?\n");
1101 if (_this.file.xtype == "PlainFile") {
1103 // assume it's gtk...
1104 var oldcode =_this.file.toSource();
1105 _this.file.setSource(str);
1106 BuilderApplication.showSpinner("appointment soon","document change pending");
1107 _this.file.getLanguageServer().document_change(_this.file);
1108 _this.file.getLanguageServer().queueDocumentSymbols(_this.file);
1109 _this.file.setSource(oldcode);
1115 if (_this.file == null) {
1123 GLib.debug("calling validate");
1124 // clear the buttons.
1125 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
1128 var oldcode = _this.prop.val;
1130 _this.prop.val = str;
1131 _this.node.updated_count++;
1132 _this.file.getLanguageServer().document_change(_this.file);
1133 _this.node.updated_count++;
1134 _this.prop.val = oldcode;
1137 //print("done mark line\n");
1139 return true; // at present allow saving - even if it's invalid..
1141 public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
1143 this.error_line = validate_res.size;
1145 if (this.error_line < 1) {
1148 var tlines = this.el.get_line_count ();
1150 var valiter = validate_res.map_iterator();
1151 while (valiter.next()) {
1153 // print("get inter\n");
1154 var eline = valiter.get_key();
1155 if (eline > tlines) {
1158 this.el.get_iter_at_line( out iter, eline);
1159 //print("mark line\n");
1160 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
1164 public string toString () {
1168 this.el.get_start_iter(out s);
1169 this.el.get_end_iter(out e);
1170 var ret = this.el.get_text(s,e,true);
1171 //print("TO STRING? " + ret);
1176 public class Xcls_keystate : Object
1178 public Gtk.EventControllerKey el;
1179 private Editor _this;
1183 public bool is_control;
1186 public Xcls_keystate(Editor _owner )
1189 _this.keystate = this;
1190 this.el = new Gtk.EventControllerKey();
1193 this.is_control = false;
1195 // set gobject values
1198 this.el.key_released.connect( (keyval, keycode, state) => {
1200 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1201 this.is_control = false;
1203 if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1204 GLib.debug("SAVE: ctrl-S pressed");
1205 _this.saveContents();
1209 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1210 GLib.debug("SAVE: ctrl-g pressed");
1211 _this.forwardSearch(true);
1214 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1215 GLib.debug("SAVE: ctrl-f pressed");
1216 _this.search_entry.el.grab_focus();
1217 _this.search_entry.el.select_region(0,-1);
1220 if (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1221 _this.view.el.show_completion();
1225 _this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);
1226 var line = iter.get_line();
1227 var offset = iter.get_line_offset();
1228 GLib.debug("line %d off %d", line ,offset);
1229 if (_this.prop != null) {
1230 line += _this.prop.start_line + 1; // i think..
1231 offset += 12; // should probably be 8 without namespaced
1232 GLib.debug("guess line %d off %d", line ,offset);
1234 //_this.view.el.show_completion();
1235 // print(event.key.keyval)
1242 this.el.key_pressed.connect( (keyval, keycode, state) => {
1244 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1245 this.is_control = true;
1251 // user defined functions
1254 public class Xcls_EventControllerScroll13 : Object
1256 public Gtk.EventControllerScroll el;
1257 private Editor _this;
1261 public double distance;
1264 public Xcls_EventControllerScroll13(Editor _owner )
1267 this.el = new Gtk.EventControllerScroll( Gtk.EventControllerScrollFlags.VERTICAL );
1270 this.distance = 0.0f;
1272 // set gobject values
1275 this.el.scroll.connect( (dx, dy) => {
1276 if (!_this.keystate.is_control) {
1279 //GLib.debug("scroll %f", dy);
1281 this.distance += dy;
1283 //GLib.debug("scroll %f / %f", dy, this.distance);
1285 if (this.distance < -1) {
1287 BuilderApplication.settings.editor_font_size ++;
1290 if (this.distance > 1) {
1291 BuilderApplication.settings.editor_font_size --;
1299 // user defined functions
1302 public class Xcls_GestureClick14 : Object
1304 public Gtk.GestureClick el;
1305 private Editor _this;
1311 public Xcls_GestureClick14(Editor _owner )
1314 this.el = new Gtk.GestureClick();
1318 // set gobject values
1321 this.el.pressed.connect( (n_press, x, y) => {
1323 int buffer_x, buffer_y;
1324 var gut = _this.view.el.get_gutter(Gtk.TextWindowType.LEFT);
1326 _this.view.el.window_to_buffer_coords (Gtk.TextWindowType.TEXT,
1327 (int)x - gut.get_width(), (int)y,
1328 out buffer_x, out buffer_y);
1329 _this.view.el.get_iter_at_location (out iter,
1330 buffer_x, buffer_y);;
1333 if (_this.buffer.el.iter_has_context_class(iter, "comment") ||
1334 _this.buffer.el.iter_has_context_class(iter, "string")
1338 var back = iter.copy();
1339 back.backward_char();
1341 var forward = iter.copy();
1342 forward.forward_char();
1344 // what's the character at the iter?
1345 var str = back.get_text(iter);
1346 str += iter.get_text(forward);
1347 if (str.strip().length < 1) {
1350 var offset = iter.get_line_offset();
1351 var line = iter.get_line();
1352 if (_this.prop != null) {
1354 line += _this.prop.start_line ;
1355 // this is based on Gtk using tabs (hence 1/2 chars);
1356 offset += _this.node.node_pad.length;
1357 // javascript listeners are indented 2 more spaces.
1358 if (_this.prop.ptype == JsRender.NodePropType.LISTENER) {
1363 var ls = _this.file.getLanguageServer();
1365 _this.file, line, offset,
1367 var res = ls.hover.end(o );
1372 things that can ber returned..
1376 Jsrennder.jsrender Editor.file
1377 Palete.LanguageClient? JsRender.JsRender.getLanguageServer ()
1378 Palete.LanguageClient? ls = _this.file.getLanguageServer()
1379 async Lsp.Hover Palete.LanguageClient.hover (JsRender.JsRender file, int line, int offset) throws GLib.Error
1380 .string JsRender.Node.node_pad = \"\"
1383 string Gtk.TextIter.get_text (Gtk.TextIter end)
1388 // could never get this to work anywhere..
1389 // looks like its probably for calling stuff..
1390 // but always returns null..
1392 ls.signatureHelp.begin(
1393 _this.file, iter.get_line(), iter.get_line_offset(),
1395 var res = ls.signatureHelp.end(o );
1403 // user defined functions
1408 public class Xcls_Box15 : Object
1411 private Editor _this;
1417 public Xcls_Box15(Editor _owner )
1420 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1424 // set gobject values
1425 this.el.homogeneous = false;
1426 this.el.vexpand = false;
1427 new Xcls_search_entry( _this );
1428 this.el.append( _this.search_entry.el );
1429 new Xcls_search_results( _this );
1430 this.el.append( _this.search_results.el );
1431 new Xcls_nextBtn( _this );
1432 this.el.append( _this.nextBtn.el );
1433 new Xcls_backBtn( _this );
1434 this.el.append( _this.backBtn.el );
1435 var child_5 = new Xcls_MenuButton21( _this );
1437 this.el.append( child_5.el );
1440 // user defined functions
1442 public class Xcls_search_entry : Object
1444 public Gtk.SearchEntry el;
1445 private Editor _this;
1449 public Gtk.CssProvider css;
1452 public Xcls_search_entry(Editor _owner )
1455 _this.search_entry = this;
1456 this.el = new Gtk.SearchEntry();
1460 // set gobject values
1461 this.el.name = "editor-search-entry";
1462 this.el.hexpand = true;
1463 this.el.placeholder_text = "Press enter to search";
1464 this.el.search_delay = 3;
1465 var child_1 = new Xcls_EventControllerKey17( _this );
1467 this.el.add_controller( child_1.el );
1470 this.el.search_changed.connect( ( ) => {
1472 _this.search(_this.search_entry.el.text);
1473 _this.search_results.updateResults();
1475 GLib.Timeout.add_seconds(1,() => {
1476 _this.search_results.updateResults();
1482 // user defined functions
1483 public void forwardSearch (bool change_focus) {
1486 _this.forwardSearch(change_focus);
1490 switch(_this.windowstate.state) {
1491 case WindowState.State.CODEONLY:
1492 //case WindowState.State.CODE:
1493 // search the code being edited..
1494 _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1497 case WindowState.State.PREVIEW:
1498 if (_this.windowstate.file.xtype == "Gtk") {
1499 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1501 _this.windowstate.window_rooview.forwardSearch(change_focus);
1510 public class Xcls_EventControllerKey17 : Object
1512 public Gtk.EventControllerKey el;
1513 private Editor _this;
1519 public Xcls_EventControllerKey17(Editor _owner )
1522 this.el = new Gtk.EventControllerKey();
1526 // set gobject values
1529 this.el.key_pressed.connect( (keyval, keycode, state) => {
1531 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1532 GLib.debug("SAVE: ctrl-g pressed");
1533 _this.forwardSearch(true);
1538 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1539 _this.forwardSearch(true);
1545 // print(event.key.keyval)
1551 // user defined functions
1555 public class Xcls_search_results : Object
1557 public Gtk.Label el;
1558 private Editor _this;
1564 public Xcls_search_results(Editor _owner )
1567 _this.search_results = this;
1568 this.el = new Gtk.Label( "No Results" );
1572 // set gobject values
1573 this.el.margin_end = 4;
1574 this.el.margin_start = 4;
1577 // user defined functions
1578 public void updateResults () {
1579 this.el.visible = true;
1581 var res = _this.searchcontext.get_occurrences_count();
1583 _this.search_results.el.label = "??? Matches";
1587 _this.nextBtn.el.sensitive = false;
1588 _this.backBtn.el.sensitive = false;
1591 _this.search_results.el.label = "%d Matches".printf(res);
1592 _this.nextBtn.el.sensitive = true;
1593 _this.backBtn.el.sensitive = true;
1596 _this.search_results.el.label = "No Matches";
1601 public class Xcls_nextBtn : Object
1603 public Gtk.Button el;
1604 private Editor _this;
1608 public bool always_show_image;
1611 public Xcls_nextBtn(Editor _owner )
1614 _this.nextBtn = this;
1615 this.el = new Gtk.Button();
1618 this.always_show_image = true;
1620 // set gobject values
1621 this.el.icon_name = "go-down";
1622 this.el.sensitive = false;
1625 this.el.clicked.connect( (event) => {
1627 _this.forwardSearch(true);
1633 // user defined functions
1636 public class Xcls_backBtn : Object
1638 public Gtk.Button el;
1639 private Editor _this;
1643 public bool always_show_image;
1646 public Xcls_backBtn(Editor _owner )
1649 _this.backBtn = this;
1650 this.el = new Gtk.Button();
1653 this.always_show_image = true;
1655 // set gobject values
1656 this.el.icon_name = "go-up";
1657 this.el.sensitive = false;
1660 this.el.clicked.connect( (event) => {
1662 _this.backSearch(true);
1667 // user defined functions
1670 public class Xcls_MenuButton21 : Object
1672 public Gtk.MenuButton el;
1673 private Editor _this;
1677 public bool always_show_image;
1680 public Xcls_MenuButton21(Editor _owner )
1683 this.el = new Gtk.MenuButton();
1686 this.always_show_image = true;
1688 // set gobject values
1689 this.el.icon_name = "emblem-system";
1690 this.el.always_show_arrow = true;
1691 new Xcls_search_settings( _this );
1692 this.el.popover = _this.search_settings.el;
1695 // user defined functions
1697 public class Xcls_search_settings : Object
1699 public Gtk.Popover el;
1700 private Editor _this;
1706 public Xcls_search_settings(Editor _owner )
1709 _this.search_settings = this;
1710 this.el = new Gtk.Popover();
1714 // set gobject values
1715 var child_1 = new Xcls_Box23( _this );
1717 this.el.child = child_1.el;
1720 // user defined functions
1722 public class Xcls_Box23 : Object
1725 private Editor _this;
1731 public Xcls_Box23(Editor _owner )
1734 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1738 // set gobject values
1739 new Xcls_case_sensitive( _this );
1740 this.el.append( _this.case_sensitive.el );
1741 new Xcls_regex( _this );
1742 this.el.append( _this.regex.el );
1743 new Xcls_multiline( _this );
1744 this.el.append( _this.multiline.el );
1747 // user defined functions
1749 public class Xcls_case_sensitive : Object
1751 public Gtk.CheckButton el;
1752 private Editor _this;
1758 public Xcls_case_sensitive(Editor _owner )
1761 _this.case_sensitive = this;
1762 this.el = new Gtk.CheckButton();
1766 // set gobject values
1767 this.el.label = "Case Sensitive";
1776 // user defined functions
1779 public class Xcls_regex : Object
1781 public Gtk.CheckButton el;
1782 private Editor _this;
1788 public Xcls_regex(Editor _owner )
1792 this.el = new Gtk.CheckButton();
1796 // set gobject values
1797 this.el.label = "Regex";
1806 // user defined functions
1809 public class Xcls_multiline : Object
1811 public Gtk.CheckButton el;
1812 private Editor _this;
1818 public Xcls_multiline(Editor _owner )
1821 _this.multiline = this;
1822 this.el = new Gtk.CheckButton();
1826 // set gobject values
1827 this.el.label = "Multi-line (add \\n)";
1830 // user defined functions
1838 public class Xcls_Box27 : Object
1841 private Editor _this;
1847 public Xcls_Box27(Editor _owner )
1850 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1854 // set gobject values
1855 this.el.hexpand = true;
1856 this.el.vexpand = true;
1857 var child_1 = new Xcls_Box28( _this );
1859 this.el.append( child_1.el );
1860 new Xcls_navigationwindow( _this );
1861 this.el.append( _this.navigationwindow.el );
1864 // user defined functions
1866 public class Xcls_Box28 : Object
1869 private Editor _this;
1875 public Xcls_Box28(Editor _owner )
1878 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1882 // set gobject values
1885 // user defined functions
1888 public class Xcls_navigationwindow : Object
1890 public Gtk.ScrolledWindow el;
1891 private Editor _this;
1897 public Xcls_navigationwindow(Editor _owner )
1900 _this.navigationwindow = this;
1901 this.el = new Gtk.ScrolledWindow();
1905 // set gobject values
1906 this.el.hexpand = true;
1907 this.el.vexpand = true;
1908 this.el.visible = false;
1909 new Xcls_navigation( _this );
1910 this.el.child = _this.navigation.el;
1913 // user defined functions
1915 public class Xcls_navigation : Object
1917 public Gtk.ColumnView el;
1918 private Editor _this;
1922 public int last_selected_line;
1923 public Gtk.Widget? selected_row;
1926 public Xcls_navigation(Editor _owner )
1929 _this.navigation = this;
1930 new Xcls_navigationselmodel( _this );
1931 this.el = new Gtk.ColumnView( _this.navigationselmodel.el );
1934 this.last_selected_line = -1;
1935 this.selected_row = null;
1937 // set gobject values
1938 this.el.name = "editor-navigation";
1939 var child_2 = new Xcls_ColumnViewColumn31( _this );
1941 this.el.append_column( child_2.el );
1942 var child_3 = new Xcls_GestureClick40( _this );
1944 this.el.add_controller( child_3.el );
1947 // user defined functions
1948 public Gtk.Widget? getRowWidgetAt (double x, double y, out string pos) {
1951 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
1952 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
1957 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
1962 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
1966 //GLib.debug("row number is %d", rn);
1967 //GLib.debug("click %d, %d", (int)x, (int)y);
1969 Graphene.Rect bounds;
1970 row.compute_bounds(this.el, out bounds);
1971 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
1972 // (int)bounds.get_x(), (int)bounds.get_y(),
1973 // (int)bounds.get_width(), (int)bounds.get_height()
1975 var ypos = y - bounds.get_y();
1976 //GLib.debug("rel ypos = %d", (int)ypos);
1977 var rpos = 100.0 * (ypos / bounds.get_height());
1978 //GLib.debug("rel pos = %d %%", (int)rpos);
1983 } else if (rpos < 20) {
1988 public void show (Gee.ArrayList<Lsp.DocumentSymbol> syms) {
1989 _this.navigationwindow.el.show();
1990 //_this.navliststore.el.remove_all();
1993 var ls = new GLib.ListStore(typeof(Lsp.DocumentSymbol));
1995 foreach(var sym in syms) {
1998 Lsp.DocumentSymbol.copyList(ls, _this.navliststore.el);
1999 //_this.navliststore.el.append(sym);
2000 this.last_selected_line = -1;
2001 GLib.Idle.add(() => {
2002 _this.navigationsort.collapseOnLoad();
2004 _this.buffer.el.get_iter_at_offset (
2005 out iter, _this.buffer.el.cursor_position);
2007 GLib.debug("idle update scroll %d, %d", iter.get_line(),
2008 iter.get_line_offset());
2009 this.updateSelectedLine(
2010 (uint)iter.get_line(),
2011 (uint)iter.get_line_offset()
2017 public int getRowAt (double x, double y, out string pos) {
2020 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
2021 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
2026 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
2031 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2036 while (cr.get_prev_sibling() != null) {
2038 cr = cr.get_prev_sibling();
2041 //GLib.debug("row number is %d", rn);
2042 //GLib.debug("click %d, %d", (int)x, (int)y);
2044 Graphene.Rect bounds;
2045 row.compute_bounds(this.el, out bounds);
2046 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2047 // (int)bounds.get_x(), (int)bounds.get_y(),
2048 // (int)bounds.get_width(), (int)bounds.get_height()
2050 var ypos = y - bounds.get_y();
2051 //GLib.debug("rel ypos = %d", (int)ypos);
2052 var rpos = 100.0 * (ypos / bounds.get_height());
2053 //GLib.debug("rel pos = %d %%", (int)rpos);
2058 } else if (rpos < 20) {
2063 public void updateSelectedLine (uint line, uint chr) {
2064 if (line == this.last_selected_line) {
2067 GLib.debug("select line %d", (int)line);
2068 this.last_selected_line = (int)line;
2072 var sym = _this.navliststore.symbolAtLine(line, chr);
2074 new_row = _this.navigationsort.getRowFromSymbol(sym);
2075 GLib.debug("select line %d - row found %d", (int)line, new_row);
2077 GLib.debug(" no symbol found at line %d", (int)line);
2080 if (this.selected_row != null) {
2081 GLib.debug(" remove selected row");
2082 this.selected_row.remove_css_class("selected-row");
2084 this.selected_row = null;
2086 this.el.scroll_to(new_row,null,Gtk.ListScrollFlags.NONE, null);
2087 var row = sym.get_data<Gtk.Widget>("widget");
2089 GLib.debug(" Add selected row");
2091 row.add_css_class("selected-row");
2092 this.selected_row = row;
2096 GLib.debug("could not find widget on row %d", new_row);
2104 public class Xcls_ColumnViewColumn31 : Object
2106 public Gtk.ColumnViewColumn el;
2107 private Editor _this;
2113 public Xcls_ColumnViewColumn31(Editor _owner )
2116 var child_1 = new Xcls_SignalListItemFactory32( _this );
2118 this.el = new Gtk.ColumnViewColumn( "Code Navigation", child_1.el );
2122 // set gobject values
2123 this.el.expand = true;
2126 // user defined functions
2128 public class Xcls_SignalListItemFactory32 : Object
2130 public Gtk.SignalListItemFactory el;
2131 private Editor _this;
2137 public Xcls_SignalListItemFactory32(Editor _owner )
2140 this.el = new Gtk.SignalListItemFactory();
2144 // set gobject values
2147 this.el.setup.connect( (listitem) => {
2149 var expand = new Gtk.TreeExpander();
2151 expand.set_indent_for_depth(true);
2152 expand.set_indent_for_icon(true);
2153 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2154 var icon = new Gtk.Image();
2155 var lbl = new Gtk.Label("");
2156 lbl.use_markup = true;
2157 lbl.ellipsize = Pango.EllipsizeMode.END;
2159 icon.margin_end = 4;
2160 lbl.justify = Gtk.Justification.LEFT;
2163 // listitem.activatable = true; ??
2167 expand.set_child(hbox);
2168 ((Gtk.ListItem)listitem).set_child(expand);
2171 this.el.bind.connect( (listitem) => {
2173 // GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name());
2175 //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2176 var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2179 var hbox = (Gtk.Box) expand.child;
2182 var img = (Gtk.Image) hbox.get_first_child();
2183 var lbl = (Gtk.Label) img.get_next_sibling();
2185 var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();
2186 var sym = (Lsp.DocumentSymbol) lr.get_item();
2188 sym.set_data<Gtk.Widget>("widget", expand.get_parent());
2189 expand.get_parent().get_parent().set_data<Lsp.DocumentSymbol>("symbol", sym);
2191 //GLib.debug("save sym on %s", expand.get_parent().get_parent().get_type().name());
2193 //GLib.debug("got %d children for %s" , (int)sym.children.get_n_items(), sym.name);
2195 expand.set_hide_expander( sym.children.get_n_items() < 1);
2196 expand.set_list_row(lr);
2197 //this.in_bind = true;
2198 // default is to expand
2200 //this.in_bind = false;
2202 sym.bind_property("symbol_icon",
2204 GLib.BindingFlags.SYNC_CREATE);
2206 hbox.css_classes = { sym.symbol_icon };
2208 sym.bind_property("name",
2210 GLib.BindingFlags.SYNC_CREATE);
2211 // should be better?- --line no?
2212 sym.bind_property("tooltip",
2213 lbl, "tooltip_markup",
2214 GLib.BindingFlags.SYNC_CREATE);
2220 // user defined functions
2224 public class Xcls_navigationselmodel : Object
2226 public Gtk.NoSelection el;
2227 private Editor _this;
2233 public Xcls_navigationselmodel(Editor _owner )
2236 _this.navigationselmodel = this;
2237 new Xcls_navigationsort( _this );
2238 this.el = new Gtk.NoSelection( _this.navigationsort.el );
2242 // set gobject values
2245 // user defined functions
2247 public class Xcls_navigationsort : Object
2249 public Gtk.SortListModel el;
2250 private Editor _this;
2256 public Xcls_navigationsort(Editor _owner )
2259 _this.navigationsort = this;
2260 var child_1 = new Xcls_TreeListModel35( _this );
2262 var child_2 = new Xcls_TreeListRowSorter37( _this );
2264 this.el = new Gtk.SortListModel( child_1.el, child_2.el );
2268 // set gobject values
2271 // user defined functions
2272 public void collapseOnLoad () {
2273 for (var i=0;i < this.el.get_n_items(); i++) {
2274 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2275 var sym = (Lsp.DocumentSymbol)tr.get_item();
2277 case Lsp.SymbolKind.Enum:
2278 tr.expanded = false;
2281 //tr.expanded = true;
2290 public int getRowFromSymbol (Lsp.DocumentSymbol sym) {
2292 for (var i=0;i < this.el.get_n_items(); i++) {
2293 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2295 if (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {
2301 public Lsp.DocumentSymbol? getSymbolAt (uint row) {
2303 var tr = (Gtk.TreeListRow)this.el.get_item(row);
2305 var a = tr.get_item();;
2306 GLib.debug("get_item (2) = %s", a.get_type().name());
2309 return (Lsp.DocumentSymbol)tr.get_item();
2313 public class Xcls_TreeListModel35 : Object
2315 public Gtk.TreeListModel el;
2316 private Editor _this;
2322 public Xcls_TreeListModel35(Editor _owner )
2325 new Xcls_navliststore( _this );
2326 this.el = new Gtk.TreeListModel( _this.navliststore.el, false, true, (item) => {
2328 return ((Lsp.DocumentSymbol)item).children;
2334 // set gobject values
2337 this.el.items_changed.connect( (position, removed, added) => {
2338 GLib.debug("tree item changed %d , %d , %d",(int) position, (int)removed, (int) added);
2342 //var sym = (Lsp.DocumentSymbol) this.el.get_item(position);
2343 var row = this.el.get_row(position);
2345 GLib.debug("got %s", row.get_item().get_type().name());
2351 // user defined functions
2353 public class Xcls_navliststore : Object
2355 public GLib.ListStore el;
2356 private Editor _this;
2362 public Xcls_navliststore(Editor _owner )
2365 _this.navliststore = this;
2366 this.el = new GLib.ListStore( typeof(Lsp.DocumentSymbol) );
2370 // set gobject values
2373 // user defined functions
2374 public Lsp.DocumentSymbol? symbolAtLine (uint line, uint chr) {
2377 for(var i = 0; i < this.el.get_n_items();i++) {
2378 var el = (Lsp.DocumentSymbol)this.el.get_item(i);
2379 //GLib.debug("Check sym %s : %d-%d",
2380 // el.name , (int)el.range.start.line,
2381 // (int)el.range.end.line
2383 var ret = el.containsLine(line,chr);
2395 public class Xcls_TreeListRowSorter37 : Object
2397 public Gtk.TreeListRowSorter el;
2398 private Editor _this;
2404 public Xcls_TreeListRowSorter37(Editor _owner )
2407 var child_1 = new Xcls_StringSorter38( _this );
2409 this.el = new Gtk.TreeListRowSorter( child_1.el );
2413 // set gobject values
2416 // user defined functions
2418 public class Xcls_StringSorter38 : Object
2420 public Gtk.StringSorter el;
2421 private Editor _this;
2427 public Xcls_StringSorter38(Editor _owner )
2430 var child_1 = new Xcls_PropertyExpression39( _this );
2432 this.el = new Gtk.StringSorter( child_1.el );
2436 // set gobject values
2439 // user defined functions
2441 public class Xcls_PropertyExpression39 : Object
2443 public Gtk.PropertyExpression el;
2444 private Editor _this;
2450 public Xcls_PropertyExpression39(Editor _owner )
2453 this.el = new Gtk.PropertyExpression( typeof(Lsp.DocumentSymbol), null, "sort_key" );
2457 // set gobject values
2460 // user defined functions
2467 public class Xcls_GestureClick40 : Object
2469 public Gtk.GestureClick el;
2470 private Editor _this;
2476 public Xcls_GestureClick40(Editor _owner )
2479 this.el = new Gtk.GestureClick();
2483 // set gobject values
2486 this.el.pressed.connect( (n_press, x, y) => {
2488 var row = _this.navigation.getRowWidgetAt(x,y, out pos );
2491 GLib.debug("no row selected items");
2494 GLib.debug("got click on %s", row.get_type().name());
2495 //Lsp.DocumentSymbol
2496 var sym = row.get_data<Lsp.DocumentSymbol>("symbol");
2512 GLib.debug("goto line %d", (int)sym.range.start.line);
2513 _this.scroll_to_line((int)sym.range.start.line);
2515 _this.buffer.el.get_iter_at_line_offset(out iter,
2516 (int)sym.range.start.line,
2517 (int)sym.range.start.character
2519 _this.buffer.el.place_cursor(iter);
2524 // user defined functions