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 this.el.shrink_end_child = false;
422 var child_1 = new Xcls_Box2( _this );
424 this.el.start_child = child_1.el;
425 var child_2 = new Xcls_Box27( _this );
427 this.el.end_child = child_2.el;
430 // user defined functions
432 public class Xcls_Box2 : Object
435 private Editor _this;
441 public Xcls_Box2(Editor _owner )
444 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
448 // set gobject values
449 var child_1 = new Xcls_Box3( _this );
451 this.el.append( child_1.el );
452 new Xcls_RightEditor( _this );
453 this.el.append( _this.RightEditor.el );
454 var child_3 = new Xcls_Box15( _this );
456 this.el.append ( child_3.el );
459 // user defined functions
461 public class Xcls_Box3 : Object
464 private Editor _this;
470 public Xcls_Box3(Editor _owner )
473 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
477 // set gobject values
478 this.el.homogeneous = false;
479 this.el.hexpand = true;
480 this.el.vexpand = false;
481 new Xcls_save_button( _this );
482 this.el.append( _this.save_button.el );
483 new Xcls_helper( _this );
484 this.el.append( _this.helper.el );
485 var child_3 = new Xcls_Scale6( _this );
487 this.el.append( child_3.el );
488 new Xcls_close_btn( _this );
489 this.el.append( _this.close_btn.el );
492 // user defined functions
494 public class Xcls_save_button : Object
496 public Gtk.Button el;
497 private Editor _this;
503 public Xcls_save_button(Editor _owner )
506 _this.save_button = this;
507 this.el = new Gtk.Button();
511 // set gobject values
512 this.el.vexpand = true;
513 this.el.label = "Save";
516 this.el.clicked.connect( () => {
517 _this.saveContents();
521 // user defined functions
524 public class Xcls_helper : Object
527 private Editor _this;
533 public Xcls_helper(Editor _owner )
537 this.el = new Gtk.Label( null );
541 // set gobject values
542 this.el.margin_end = 4;
543 this.el.margin_start = 4;
544 this.el.justify = Gtk.Justification.LEFT;
545 this.el.hexpand = true;
548 // user defined functions
549 public void setHelp (Lsp.Hover? help) {
550 if (help == null || help.contents == null
551 || help.contents.size < 1) {
552 this.el.set_text("");
555 var sig = help.contents.get(0).value.split(" ");
557 for(var i =0; i < sig.length; i++) {
576 str += ("<span underline=\"single\" color=\"blue\" >" +
577 GLib.Markup.escape_text(sig[i])
582 if (help.contents.size > 1) {
583 sig += ("\n\n" + help.contents[1].value);
586 this.el.set_markup(string.joinv(" ",str));
591 public class Xcls_Scale6 : Object
594 private Editor _this;
600 public Xcls_Scale6(Editor _owner )
603 this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1);
607 // set gobject values
608 this.el.width_request = 200;
609 this.el.has_origin = true;
610 this.el.draw_value = false;
612 this.el.sensitive = true;
617 //this.el.set_range(6,30);
618 this.el.set_value ( BuilderApplication.settings.editor_font_size);
619 BuilderApplication.settings.editor_font_size_updated.connect(
621 BuilderApplication.settings.editor_font_size_inchange = true;
622 // GLib.debug("update range");
623 this.el.set_value (BuilderApplication.settings.editor_font_size);
624 BuilderApplication.settings.editor_font_size_inchange = false;
632 this.el.change_value.connect( (st, val ) => {
633 if (BuilderApplication.settings.editor_font_size_inchange) {
636 BuilderApplication.settings.editor_font_size = val;
641 // user defined functions
644 public class Xcls_close_btn : Object
646 public Gtk.Button el;
647 private Editor _this;
653 public Xcls_close_btn(Editor _owner )
656 _this.close_btn = this;
657 this.el = new Gtk.Button();
661 // set gobject values
662 this.el.icon_name = "window-close";
663 var child_1 = new Xcls_Image8( _this );
665 this.el.child = child_1.el;
668 this.el.clicked.connect( () => {
669 _this.saveContents();
670 _this.window.windowstate.switchState(WindowState.State.PREVIEW);
674 // user defined functions
676 public class Xcls_Image8 : Object
679 private Editor _this;
685 public Xcls_Image8(Editor _owner )
688 this.el = new Gtk.Image();
692 // set gobject values
693 this.el.icon_name = "window-close";
694 this.el.icon_size = Gtk.IconSize.NORMAL;
697 // user defined functions
702 public class Xcls_RightEditor : Object
704 public Gtk.ScrolledWindow el;
705 private Editor _this;
711 public Xcls_RightEditor(Editor _owner )
714 _this.RightEditor = this;
715 this.el = new Gtk.ScrolledWindow();
719 // set gobject values
720 this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
721 this.el.vexpand = true;
722 this.el.overlay_scrolling = false;
723 this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
724 new Xcls_view( _this );
725 this.el.child = _this.view.el;
728 // user defined functions
730 public class Xcls_view : Object
732 public GtkSource.View el;
733 private Editor _this;
737 public Gtk.CssProvider css;
740 public Xcls_view(Editor _owner )
744 this.el = new GtkSource.View();
749 // set gobject values
750 this.el.auto_indent = true;
751 this.el.indent_width = 4;
752 this.el.name = "editor-view";
753 this.el.show_line_marks = true;
754 this.el.insert_spaces_instead_of_tabs = true;
755 this.el.show_line_numbers = true;
756 this.el.hexpand = true;
757 this.el.vexpand = true;
758 this.el.has_tooltip = true;
759 this.el.css_classes = { "code-editor" };
760 this.el.tab_width = 4;
761 this.el.highlight_current_line = true;
762 new Xcls_buffer( _this );
763 this.el.buffer = _this.buffer.el;
764 new Xcls_keystate( _this );
765 this.el.add_controller( _this.keystate.el );
766 var child_3 = new Xcls_EventControllerScroll13( _this );
768 this.el.add_controller( child_3.el );
769 var child_4 = new Xcls_GestureClick14( _this );
771 this.el.add_controller( child_4.el );
775 this.el.completion.add_provider(
776 new Palete.CompletionProvider(_this)
779 // hover seems pretty useless.. - ??
780 //var hover = this.el.get_hover();
781 //hover.add_provider(new Palete.HoverProvider(_this));
783 //this.el.completion.unblock_interactive();
784 this.el.completion.select_on_show = true; // select
785 //this.el.completion.remember_info_visibility = true;
788 var attrs = new GtkSource.MarkAttributes();
790 attrs.set_icon_name ( "process-stop");
791 attrs.query_tooltip_text.connect(( mark) => {
792 GLib.debug("tooltip query? %s", mark.name);
793 return strdup( mark.name);
795 attrs.query_tooltip_markup.connect(( mark) => {
796 GLib.debug("tooltip query? %s", mark.name);
797 return strdup( mark.name);
799 this.el.set_mark_attributes ("ERR", attrs, 1);
803 var wattrs = new GtkSource.MarkAttributes();
804 wattrs.set_icon_name ( "process-stop");
805 wattrs.query_tooltip_text.connect(( mark) => {
806 GLib.debug("tooltip query? %s", mark.name);
807 return strdup(mark.name);
809 wattrs.query_tooltip_markup.connect(( mark) => {
810 GLib.debug("tooltip query? %s", mark.name);
811 return strdup(mark.name);
813 this.el.set_mark_attributes ("WARN", wattrs, 1);
817 var dattrs = new GtkSource.MarkAttributes();
819 dattrs.set_icon_name ( "process-stop");
821 dattrs.query_tooltip_text.connect(( mark) => {
822 GLib.debug("tooltip query? %s", mark.name);
823 return strdup(mark.name);
825 //dattrs.query_tooltip_markup.connect(( mark) => {
826 // GLib.debug("tooltip query? %s", mark.name);
827 // return strdup(mark.name);
829 this.el.set_mark_attributes ("DEPR", dattrs, 1);
832 this.el.get_space_drawer().set_matrix(null);
833 this.el.get_space_drawer().set_types_for_locations(
834 GtkSource.SpaceLocationFlags.ALL,
835 GtkSource.SpaceTypeFlags.ALL
837 this.el.get_space_drawer().set_enable_matrix(true);
840 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
842 //GLib.debug("query tooltip");
846 var yoff = (int) _this.RightEditor.el.vadjustment.value;
848 // I think this is problematic - if it's compliing / updating at same time as query.
850 //if (_this.window.statusbar_compile_spinner.el.spinning) {
854 this.el.get_iter_at_position (out iter, out trailing, x, y + yoff);
856 var l = iter.get_line();
860 // GLib.debug("query tooltip line %d", (int) l);
866 if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {
867 GLib.debug("line %d setting tip to %s", l, _this.buffer.marks.get(l));
868 tooltip.set_text(_this.buffer.marks.get(l).dup());
876 // this crashes?? - not sure why.
877 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
878 if (marks.is_empty()) {
879 marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
881 if (marks.is_empty()) {
882 marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
885 // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length());
887 marks.@foreach((m) => {
888 //GLib.debug("got mark %s", m.name);
889 str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name;
891 // true if there is a mark..
892 if (str.length > 0 ) {
893 tooltip.set_text( str );
895 return str.length > 0 ? true : false;
900 // user defined functions
901 public void load (string str) {
903 // show the help page for the active node..
904 //this.get('/Help').show();
906 // this.get('/BottomPane').el.set_current_page(0);
907 GLib.debug("load called - Reset undo buffer");
909 var buf = (GtkSource.Buffer)this.el.get_buffer();
910 buf.begin_irreversible_action();
911 buf.set_text(str, str.length);
912 buf.end_irreversible_action();
914 var lm = GtkSource.LanguageManager.get_default();
916 if (_this.file != null) {
917 lang = _this.file.language;
919 print("lang=%s, content_type = %s\n", lang, _this.file.content_type);
920 var lg = _this.file.content_type.length > 0 ?
921 lm.guess_language(_this.file.path, _this.file.content_type) :
922 lm.get_language(lang);
925 ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg);
927 this.el.insert_spaces_instead_of_tabs = true;
929 print("sourcelanguage = %s\n", lg.name);
930 if (lg.name == "Vala") {
931 this.el.insert_spaces_instead_of_tabs = false;
935 this.el.grab_focus();
936 _this.save_button.el.sensitive = false;
937 _this.last_error_counter = -1;
940 public class Xcls_buffer : Object
942 public GtkSource.Buffer el;
943 private Editor _this;
947 public int error_line;
948 public Gee.HashMap<int,string>? xmarks;
949 public bool check_queued;
952 public Xcls_buffer(Editor _owner )
956 this.el = new GtkSource.Buffer( null );
959 this.error_line = -1;
961 this.check_queued = false;
963 // set gobject values
964 this.el.highlight_syntax = true;
965 this.el.highlight_matching_brackets = true;
966 this.el.enable_undo = true;
971 buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
972 buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
973 buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
974 buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
975 buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
976 buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
977 buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
978 buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
981 buf.create_tag ("ERR", "weight", Pango.Weight.BOLD, "background", "pink");
982 buf.create_tag ("WARN", "weight", Pango.Weight.BOLD, "background", "#ABF4EB");
983 buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
986 this.el.cursor_moved.connect( ( ) => {
989 this.el.get_iter_at_offset (
990 out iter, this.el.cursor_position);
992 _this.navigation.updateSelectedLine(
993 (uint)iter.get_line(),
994 (uint)iter.get_line_offset()
999 this.el.changed.connect( () => {
1002 _this.save_button.el.sensitive = true;
1003 print("EDITOR CHANGED");
1008 // this.get('/LeftPanel.model').changed( str , false);
1013 // user defined functions
1014 public bool OLDhighlightErrorsJson (string type, Json.Object obj) {
1017 this.el.get_bounds (out start, out end);
1019 this.el.remove_source_marks (start, end, type);
1020 GLib.debug("highlight errors");
1022 // we should highlight other types of errors..
1024 if (!obj.has_member(type)) {
1025 GLib.debug("Return has no errors\n");
1029 if (_this.window.windowstate.state != WindowState.State.CODEONLY
1031 _this.window.windowstate.state != WindowState.State.CODE
1033 GLib.debug("windowstate != CODEONLY?");
1038 //this.marks = new Gee.HashMap<int,string>();
1039 var err = obj.get_object_member(type);
1041 if (_this.file == null) {
1042 GLib.debug("file is null?");
1046 var valafn = _this.file.path;
1048 if (_this.file.xtype != "PlainFile") {
1052 var regex = new Regex("\\.bjs$");
1053 // should not happen
1054 valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
1055 } catch (GLib.RegexError e) {
1062 if (!err.has_member(valafn)) {
1063 GLib.debug("File path has no errors");
1067 var lines = err.get_object_member(valafn);
1070 if (obj.has_member("line_offset")) { // ?? why??
1071 offset = (int)obj.get_int_member("line_offset") + 1;
1075 var tlines = this.el.get_line_count () +1;
1077 if (_this.prop != null) {
1079 tlines = _this.prop.end_line + 1;
1080 offset = _this.prop.start_line + 1;
1086 lines.foreach_member((obj, line, node) => {
1089 // print("get inter\n");
1090 var eline = int.parse(line) - offset;
1091 GLib.debug("GOT ERROR on line %s -- converted to %d (offset = %d)\n", line,eline, offset);
1094 if (eline > tlines || eline < 0) {
1099 this.el.get_iter_at_line( out iter, eline);
1100 //print("mark line\n");
1102 var ar = lines.get_array_member(line);
1103 for (var i = 0 ; i < ar.get_length(); i++) {
1104 if (ar.get_string_element(i) == "Success") {
1107 msg += (msg.length > 0) ? "\n" : "";
1108 msg += ar.get_string_element(i);
1113 msg = "Line: %d".printf(eline+1) + " " + msg;
1114 this.el.create_source_mark(msg, type, iter);
1115 GLib.debug("set line %d to %m", eline, msg);
1116 // this.marks.set(eline, msg);
1125 public bool checkSyntax () {
1128 var str = this.toString();
1131 if (this.error_line > 0) {
1134 this.el.get_bounds (out start, out end);
1136 this.el.remove_source_marks (start, end, null);
1138 if (str.length < 1) {
1139 print("checkSyntax - empty string?\n");
1144 if (_this.file.xtype == "PlainFile") {
1146 // assume it's gtk...
1147 var oldcode =_this.file.toSource();
1148 _this.file.setSource(str);
1149 BuilderApplication.showSpinner("appointment soon","document change pending");
1150 _this.file.getLanguageServer().document_change(_this.file);
1151 _this.file.getLanguageServer().queueDocumentSymbols(_this.file);
1152 _this.file.setSource(oldcode);
1158 if (_this.file == null) {
1166 GLib.debug("calling validate");
1167 // clear the buttons.
1168 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
1171 var oldcode = _this.prop.val;
1173 _this.prop.val = str;
1174 _this.node.updated_count++;
1175 _this.file.getLanguageServer().document_change(_this.file);
1176 _this.node.updated_count++;
1177 _this.prop.val = oldcode;
1180 //print("done mark line\n");
1182 return true; // at present allow saving - even if it's invalid..
1184 public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
1186 this.error_line = validate_res.size;
1188 if (this.error_line < 1) {
1191 var tlines = this.el.get_line_count ();
1193 var valiter = validate_res.map_iterator();
1194 while (valiter.next()) {
1196 // print("get inter\n");
1197 var eline = valiter.get_key();
1198 if (eline > tlines) {
1201 this.el.get_iter_at_line( out iter, eline);
1202 //print("mark line\n");
1203 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
1207 public string toString () {
1211 this.el.get_start_iter(out s);
1212 this.el.get_end_iter(out e);
1213 var ret = this.el.get_text(s,e,true);
1214 //print("TO STRING? " + ret);
1219 public class Xcls_keystate : Object
1221 public Gtk.EventControllerKey el;
1222 private Editor _this;
1226 public bool is_control;
1229 public Xcls_keystate(Editor _owner )
1232 _this.keystate = this;
1233 this.el = new Gtk.EventControllerKey();
1236 this.is_control = false;
1238 // set gobject values
1241 this.el.key_released.connect( (keyval, keycode, state) => {
1243 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1244 this.is_control = false;
1246 if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1247 GLib.debug("SAVE: ctrl-S pressed");
1248 _this.saveContents();
1252 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1253 GLib.debug("SAVE: ctrl-g pressed");
1254 _this.forwardSearch(true);
1257 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1258 GLib.debug("SAVE: ctrl-f pressed");
1259 _this.search_entry.el.grab_focus();
1260 _this.search_entry.el.select_region(0,-1);
1263 if (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1264 _this.view.el.show_completion();
1268 _this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);
1269 var line = iter.get_line();
1270 var offset = iter.get_line_offset();
1271 GLib.debug("line %d off %d", line ,offset);
1272 if (_this.prop != null) {
1273 line += _this.prop.start_line + 1; // i think..
1274 offset += 12; // should probably be 8 without namespaced
1275 GLib.debug("guess line %d off %d", line ,offset);
1277 //_this.view.el.show_completion();
1278 // print(event.key.keyval)
1285 this.el.key_pressed.connect( (keyval, keycode, state) => {
1287 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1288 this.is_control = true;
1294 // user defined functions
1297 public class Xcls_EventControllerScroll13 : Object
1299 public Gtk.EventControllerScroll el;
1300 private Editor _this;
1304 public double distance;
1307 public Xcls_EventControllerScroll13(Editor _owner )
1310 this.el = new Gtk.EventControllerScroll( Gtk.EventControllerScrollFlags.VERTICAL );
1313 this.distance = 0.0f;
1315 // set gobject values
1318 this.el.scroll.connect( (dx, dy) => {
1319 if (!_this.keystate.is_control) {
1322 //GLib.debug("scroll %f", dy);
1324 this.distance += dy;
1326 //GLib.debug("scroll %f / %f", dy, this.distance);
1328 if (this.distance < -1) {
1330 BuilderApplication.settings.editor_font_size ++;
1333 if (this.distance > 1) {
1334 BuilderApplication.settings.editor_font_size --;
1342 // user defined functions
1345 public class Xcls_GestureClick14 : Object
1347 public Gtk.GestureClick el;
1348 private Editor _this;
1354 public Xcls_GestureClick14(Editor _owner )
1357 this.el = new Gtk.GestureClick();
1361 // set gobject values
1364 this.el.pressed.connect( (n_press, x, y) => {
1366 int buffer_x, buffer_y;
1367 var gut = _this.view.el.get_gutter(Gtk.TextWindowType.LEFT);
1369 _this.view.el.window_to_buffer_coords (Gtk.TextWindowType.TEXT,
1370 (int)x - gut.get_width(), (int)y,
1371 out buffer_x, out buffer_y);
1372 _this.view.el.get_iter_at_location (out iter,
1373 buffer_x, buffer_y);;
1376 if (_this.buffer.el.iter_has_context_class(iter, "comment") ||
1377 _this.buffer.el.iter_has_context_class(iter, "string")
1381 var back = iter.copy();
1382 back.backward_char();
1384 var forward = iter.copy();
1385 forward.forward_char();
1387 // what's the character at the iter?
1388 var str = back.get_text(iter);
1389 str += iter.get_text(forward);
1390 if (str.strip().length < 1) {
1393 var offset = iter.get_line_offset();
1394 var line = iter.get_line();
1395 if (_this.prop != null) {
1397 line += _this.prop.start_line ;
1398 // this is based on Gtk using tabs (hence 1/2 chars);
1399 offset += _this.node.node_pad.length;
1400 // javascript listeners are indented 2 more spaces.
1401 if (_this.prop.ptype == JsRender.NodePropType.LISTENER) {
1406 var ls = _this.file.getLanguageServer();
1408 _this.file, line, offset,
1410 var res = ls.hover.end(o );
1411 _this.helper.setHelp(res);
1415 things that can ber returned..
1419 Jsrennder.jsrender Editor.file
1420 Palete.LanguageClient? JsRender.JsRender.getLanguageServer ()
1421 Palete.LanguageClient? ls = _this.file.getLanguageServer()
1422 async Lsp.Hover Palete.LanguageClient.hover (JsRender.JsRender file, int line, int offset) throws GLib.Error
1423 .string JsRender.Node.node_pad = \"\"
1426 string Gtk.TextIter.get_text (Gtk.TextIter end)
1431 // could never get this to work anywhere..
1432 // looks like its probably for calling stuff..
1433 // but always returns null..
1435 ls.signatureHelp.begin(
1436 _this.file, iter.get_line(), iter.get_line_offset(),
1438 var res = ls.signatureHelp.end(o );
1446 // user defined functions
1451 public class Xcls_Box15 : Object
1454 private Editor _this;
1460 public Xcls_Box15(Editor _owner )
1463 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1467 // set gobject values
1468 this.el.homogeneous = false;
1469 this.el.vexpand = false;
1470 new Xcls_search_entry( _this );
1471 this.el.append( _this.search_entry.el );
1472 new Xcls_search_results( _this );
1473 this.el.append( _this.search_results.el );
1474 new Xcls_nextBtn( _this );
1475 this.el.append( _this.nextBtn.el );
1476 new Xcls_backBtn( _this );
1477 this.el.append( _this.backBtn.el );
1478 var child_5 = new Xcls_MenuButton21( _this );
1480 this.el.append( child_5.el );
1483 // user defined functions
1485 public class Xcls_search_entry : Object
1487 public Gtk.SearchEntry el;
1488 private Editor _this;
1492 public Gtk.CssProvider css;
1495 public Xcls_search_entry(Editor _owner )
1498 _this.search_entry = this;
1499 this.el = new Gtk.SearchEntry();
1503 // set gobject values
1504 this.el.name = "editor-search-entry";
1505 this.el.hexpand = true;
1506 this.el.placeholder_text = "Press enter to search";
1507 this.el.search_delay = 3;
1508 var child_1 = new Xcls_EventControllerKey17( _this );
1510 this.el.add_controller( child_1.el );
1513 this.el.search_changed.connect( ( ) => {
1515 _this.search(_this.search_entry.el.text);
1516 _this.search_results.updateResults();
1518 GLib.Timeout.add_seconds(1,() => {
1519 _this.search_results.updateResults();
1525 // user defined functions
1526 public void forwardSearch (bool change_focus) {
1529 _this.forwardSearch(change_focus);
1533 switch(_this.windowstate.state) {
1534 case WindowState.State.CODEONLY:
1535 //case WindowState.State.CODE:
1536 // search the code being edited..
1537 _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1540 case WindowState.State.PREVIEW:
1541 if (_this.windowstate.file.xtype == "Gtk") {
1542 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1544 _this.windowstate.window_rooview.forwardSearch(change_focus);
1553 public class Xcls_EventControllerKey17 : Object
1555 public Gtk.EventControllerKey el;
1556 private Editor _this;
1562 public Xcls_EventControllerKey17(Editor _owner )
1565 this.el = new Gtk.EventControllerKey();
1569 // set gobject values
1572 this.el.key_pressed.connect( (keyval, keycode, state) => {
1574 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1575 GLib.debug("SAVE: ctrl-g pressed");
1576 _this.forwardSearch(true);
1581 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1582 _this.forwardSearch(true);
1588 // print(event.key.keyval)
1594 // user defined functions
1598 public class Xcls_search_results : Object
1600 public Gtk.Label el;
1601 private Editor _this;
1607 public Xcls_search_results(Editor _owner )
1610 _this.search_results = this;
1611 this.el = new Gtk.Label( "No Results" );
1615 // set gobject values
1616 this.el.margin_end = 4;
1617 this.el.margin_start = 4;
1620 // user defined functions
1621 public void updateResults () {
1622 this.el.visible = true;
1624 var res = _this.searchcontext.get_occurrences_count();
1626 _this.search_results.el.label = "??? Matches";
1630 _this.nextBtn.el.sensitive = false;
1631 _this.backBtn.el.sensitive = false;
1634 _this.search_results.el.label = "%d Matches".printf(res);
1635 _this.nextBtn.el.sensitive = true;
1636 _this.backBtn.el.sensitive = true;
1639 _this.search_results.el.label = "No Matches";
1644 public class Xcls_nextBtn : Object
1646 public Gtk.Button el;
1647 private Editor _this;
1651 public bool always_show_image;
1654 public Xcls_nextBtn(Editor _owner )
1657 _this.nextBtn = this;
1658 this.el = new Gtk.Button();
1661 this.always_show_image = true;
1663 // set gobject values
1664 this.el.icon_name = "go-down";
1665 this.el.sensitive = false;
1668 this.el.clicked.connect( (event) => {
1670 _this.forwardSearch(true);
1676 // user defined functions
1679 public class Xcls_backBtn : Object
1681 public Gtk.Button el;
1682 private Editor _this;
1686 public bool always_show_image;
1689 public Xcls_backBtn(Editor _owner )
1692 _this.backBtn = this;
1693 this.el = new Gtk.Button();
1696 this.always_show_image = true;
1698 // set gobject values
1699 this.el.icon_name = "go-up";
1700 this.el.sensitive = false;
1703 this.el.clicked.connect( (event) => {
1705 _this.backSearch(true);
1710 // user defined functions
1713 public class Xcls_MenuButton21 : Object
1715 public Gtk.MenuButton el;
1716 private Editor _this;
1720 public bool always_show_image;
1723 public Xcls_MenuButton21(Editor _owner )
1726 this.el = new Gtk.MenuButton();
1729 this.always_show_image = true;
1731 // set gobject values
1732 this.el.icon_name = "emblem-system";
1733 this.el.always_show_arrow = true;
1734 new Xcls_search_settings( _this );
1735 this.el.popover = _this.search_settings.el;
1738 // user defined functions
1740 public class Xcls_search_settings : Object
1742 public Gtk.Popover el;
1743 private Editor _this;
1749 public Xcls_search_settings(Editor _owner )
1752 _this.search_settings = this;
1753 this.el = new Gtk.Popover();
1757 // set gobject values
1758 var child_1 = new Xcls_Box23( _this );
1760 this.el.child = child_1.el;
1763 // user defined functions
1765 public class Xcls_Box23 : Object
1768 private Editor _this;
1774 public Xcls_Box23(Editor _owner )
1777 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1781 // set gobject values
1782 new Xcls_case_sensitive( _this );
1783 this.el.append( _this.case_sensitive.el );
1784 new Xcls_regex( _this );
1785 this.el.append( _this.regex.el );
1786 new Xcls_multiline( _this );
1787 this.el.append( _this.multiline.el );
1790 // user defined functions
1792 public class Xcls_case_sensitive : Object
1794 public Gtk.CheckButton el;
1795 private Editor _this;
1801 public Xcls_case_sensitive(Editor _owner )
1804 _this.case_sensitive = this;
1805 this.el = new Gtk.CheckButton();
1809 // set gobject values
1810 this.el.label = "Case Sensitive";
1819 // user defined functions
1822 public class Xcls_regex : Object
1824 public Gtk.CheckButton el;
1825 private Editor _this;
1831 public Xcls_regex(Editor _owner )
1835 this.el = new Gtk.CheckButton();
1839 // set gobject values
1840 this.el.label = "Regex";
1849 // user defined functions
1852 public class Xcls_multiline : Object
1854 public Gtk.CheckButton el;
1855 private Editor _this;
1861 public Xcls_multiline(Editor _owner )
1864 _this.multiline = this;
1865 this.el = new Gtk.CheckButton();
1869 // set gobject values
1870 this.el.label = "Multi-line (add \\n)";
1873 // user defined functions
1881 public class Xcls_Box27 : Object
1884 private Editor _this;
1890 public Xcls_Box27(Editor _owner )
1893 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1897 // set gobject values
1898 this.el.hexpand = true;
1899 this.el.vexpand = true;
1900 var child_1 = new Xcls_Box28( _this );
1902 this.el.append( child_1.el );
1903 new Xcls_navigationwindow( _this );
1904 this.el.append( _this.navigationwindow.el );
1907 // user defined functions
1909 public class Xcls_Box28 : Object
1912 private Editor _this;
1918 public Xcls_Box28(Editor _owner )
1921 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1925 // set gobject values
1928 // user defined functions
1931 public class Xcls_navigationwindow : Object
1933 public Gtk.ScrolledWindow el;
1934 private Editor _this;
1940 public Xcls_navigationwindow(Editor _owner )
1943 _this.navigationwindow = this;
1944 this.el = new Gtk.ScrolledWindow();
1948 // set gobject values
1949 this.el.hexpand = true;
1950 this.el.vexpand = true;
1951 this.el.visible = false;
1952 new Xcls_navigation( _this );
1953 this.el.child = _this.navigation.el;
1956 // user defined functions
1958 public class Xcls_navigation : Object
1960 public Gtk.ColumnView el;
1961 private Editor _this;
1965 public int last_selected_line;
1966 public Gtk.Widget? selected_row;
1969 public Xcls_navigation(Editor _owner )
1972 _this.navigation = this;
1973 new Xcls_navigationselmodel( _this );
1974 this.el = new Gtk.ColumnView( _this.navigationselmodel.el );
1977 this.last_selected_line = -1;
1978 this.selected_row = null;
1980 // set gobject values
1981 this.el.name = "editor-navigation";
1982 var child_2 = new Xcls_ColumnViewColumn31( _this );
1984 this.el.append_column( child_2.el );
1985 var child_3 = new Xcls_GestureClick40( _this );
1987 this.el.add_controller( child_3.el );
1990 // user defined functions
1991 public Gtk.Widget? getRowWidgetAt (double x, double y, out string pos) {
1994 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
1995 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
2000 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
2005 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2009 //GLib.debug("row number is %d", rn);
2010 //GLib.debug("click %d, %d", (int)x, (int)y);
2012 Graphene.Rect bounds;
2013 row.compute_bounds(this.el, out bounds);
2014 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2015 // (int)bounds.get_x(), (int)bounds.get_y(),
2016 // (int)bounds.get_width(), (int)bounds.get_height()
2018 var ypos = y - bounds.get_y();
2019 //GLib.debug("rel ypos = %d", (int)ypos);
2020 var rpos = 100.0 * (ypos / bounds.get_height());
2021 //GLib.debug("rel pos = %d %%", (int)rpos);
2026 } else if (rpos < 20) {
2031 public void show (Gee.ArrayList<Lsp.DocumentSymbol> syms) {
2032 _this.navigationwindow.el.show();
2033 //_this.navliststore.el.remove_all();
2036 var ls = new GLib.ListStore(typeof(Lsp.DocumentSymbol));
2038 foreach(var sym in syms) {
2041 Lsp.DocumentSymbol.copyList(ls, _this.navliststore.el);
2042 //_this.navliststore.el.append(sym);
2043 this.last_selected_line = -1;
2044 GLib.Idle.add(() => {
2045 _this.navigationsort.collapseOnLoad();
2047 _this.buffer.el.get_iter_at_offset (
2048 out iter, _this.buffer.el.cursor_position);
2050 GLib.debug("idle update scroll %d, %d", iter.get_line(),
2051 iter.get_line_offset());
2052 this.updateSelectedLine(
2053 (uint)iter.get_line(),
2054 (uint)iter.get_line_offset()
2060 public int getRowAt (double x, double y, out string pos) {
2063 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
2064 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
2069 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
2074 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2079 while (cr.get_prev_sibling() != null) {
2081 cr = cr.get_prev_sibling();
2084 //GLib.debug("row number is %d", rn);
2085 //GLib.debug("click %d, %d", (int)x, (int)y);
2087 Graphene.Rect bounds;
2088 row.compute_bounds(this.el, out bounds);
2089 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2090 // (int)bounds.get_x(), (int)bounds.get_y(),
2091 // (int)bounds.get_width(), (int)bounds.get_height()
2093 var ypos = y - bounds.get_y();
2094 //GLib.debug("rel ypos = %d", (int)ypos);
2095 var rpos = 100.0 * (ypos / bounds.get_height());
2096 //GLib.debug("rel pos = %d %%", (int)rpos);
2101 } else if (rpos < 20) {
2106 public void updateSelectedLine (uint line, uint chr) {
2107 if (line == this.last_selected_line) {
2110 GLib.debug("select line %d", (int)line);
2111 this.last_selected_line = (int)line;
2115 var sym = _this.navliststore.symbolAtLine(line, chr);
2117 new_row = _this.navigationsort.getRowFromSymbol(sym);
2118 GLib.debug("select line %d - row found %d", (int)line, new_row);
2120 GLib.debug(" no symbol found at line %d", (int)line);
2123 if (this.selected_row != null) {
2124 GLib.debug(" remove selected row");
2125 this.selected_row.remove_css_class("selected-row");
2127 this.selected_row = null;
2129 this.el.scroll_to(new_row,null,Gtk.ListScrollFlags.NONE, null);
2130 var row = sym.get_data<Gtk.Widget>("widget");
2132 GLib.debug(" Add selected row");
2134 row.add_css_class("selected-row");
2135 this.selected_row = row;
2139 GLib.debug("could not find widget on row %d", new_row);
2147 public class Xcls_ColumnViewColumn31 : Object
2149 public Gtk.ColumnViewColumn el;
2150 private Editor _this;
2156 public Xcls_ColumnViewColumn31(Editor _owner )
2159 var child_1 = new Xcls_SignalListItemFactory32( _this );
2161 this.el = new Gtk.ColumnViewColumn( "Code Navigation", child_1.el );
2165 // set gobject values
2166 this.el.expand = true;
2169 // user defined functions
2171 public class Xcls_SignalListItemFactory32 : Object
2173 public Gtk.SignalListItemFactory el;
2174 private Editor _this;
2180 public Xcls_SignalListItemFactory32(Editor _owner )
2183 this.el = new Gtk.SignalListItemFactory();
2187 // set gobject values
2190 this.el.setup.connect( (listitem) => {
2192 var expand = new Gtk.TreeExpander();
2194 expand.set_indent_for_depth(true);
2195 expand.set_indent_for_icon(true);
2196 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2197 var icon = new Gtk.Image();
2198 var lbl = new Gtk.Label("");
2199 lbl.use_markup = true;
2200 lbl.ellipsize = Pango.EllipsizeMode.END;
2202 icon.margin_end = 4;
2203 lbl.justify = Gtk.Justification.LEFT;
2206 // listitem.activatable = true; ??
2210 expand.set_child(hbox);
2211 ((Gtk.ListItem)listitem).set_child(expand);
2214 this.el.bind.connect( (listitem) => {
2216 // GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name());
2218 //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2219 var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2222 var hbox = (Gtk.Box) expand.child;
2225 var img = (Gtk.Image) hbox.get_first_child();
2226 var lbl = (Gtk.Label) img.get_next_sibling();
2228 var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();
2229 var sym = (Lsp.DocumentSymbol) lr.get_item();
2231 sym.set_data<Gtk.Widget>("widget", expand.get_parent());
2232 expand.get_parent().get_parent().set_data<Lsp.DocumentSymbol>("symbol", sym);
2234 //GLib.debug("save sym on %s", expand.get_parent().get_parent().get_type().name());
2236 //GLib.debug("got %d children for %s" , (int)sym.children.get_n_items(), sym.name);
2238 expand.set_hide_expander( sym.children.get_n_items() < 1);
2239 expand.set_list_row(lr);
2240 //this.in_bind = true;
2241 // default is to expand
2243 //this.in_bind = false;
2245 sym.bind_property("symbol_icon",
2247 GLib.BindingFlags.SYNC_CREATE);
2249 hbox.css_classes = { sym.symbol_icon };
2251 sym.bind_property("name",
2253 GLib.BindingFlags.SYNC_CREATE);
2254 // should be better?- --line no?
2255 sym.bind_property("tooltip",
2256 lbl, "tooltip_markup",
2257 GLib.BindingFlags.SYNC_CREATE);
2263 // user defined functions
2267 public class Xcls_navigationselmodel : Object
2269 public Gtk.NoSelection el;
2270 private Editor _this;
2276 public Xcls_navigationselmodel(Editor _owner )
2279 _this.navigationselmodel = this;
2280 new Xcls_navigationsort( _this );
2281 this.el = new Gtk.NoSelection( _this.navigationsort.el );
2285 // set gobject values
2288 // user defined functions
2290 public class Xcls_navigationsort : Object
2292 public Gtk.SortListModel el;
2293 private Editor _this;
2299 public Xcls_navigationsort(Editor _owner )
2302 _this.navigationsort = this;
2303 var child_1 = new Xcls_TreeListModel35( _this );
2305 var child_2 = new Xcls_TreeListRowSorter37( _this );
2307 this.el = new Gtk.SortListModel( child_1.el, child_2.el );
2311 // set gobject values
2314 // user defined functions
2315 public void collapseOnLoad () {
2316 for (var i=0;i < this.el.get_n_items(); i++) {
2317 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2318 var sym = (Lsp.DocumentSymbol)tr.get_item();
2320 case Lsp.SymbolKind.Enum:
2321 tr.expanded = false;
2324 //tr.expanded = true;
2333 public int getRowFromSymbol (Lsp.DocumentSymbol sym) {
2335 for (var i=0;i < this.el.get_n_items(); i++) {
2336 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2338 if (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {
2344 public Lsp.DocumentSymbol? getSymbolAt (uint row) {
2346 var tr = (Gtk.TreeListRow)this.el.get_item(row);
2348 var a = tr.get_item();;
2349 GLib.debug("get_item (2) = %s", a.get_type().name());
2352 return (Lsp.DocumentSymbol)tr.get_item();
2356 public class Xcls_TreeListModel35 : Object
2358 public Gtk.TreeListModel el;
2359 private Editor _this;
2365 public Xcls_TreeListModel35(Editor _owner )
2368 new Xcls_navliststore( _this );
2369 this.el = new Gtk.TreeListModel( _this.navliststore.el, false, true, (item) => {
2371 return ((Lsp.DocumentSymbol)item).children;
2377 // set gobject values
2380 this.el.items_changed.connect( (position, removed, added) => {
2381 GLib.debug("tree item changed %d , %d , %d",(int) position, (int)removed, (int) added);
2385 //var sym = (Lsp.DocumentSymbol) this.el.get_item(position);
2386 var row = this.el.get_row(position);
2388 GLib.debug("got %s", row.get_item().get_type().name());
2394 // user defined functions
2396 public class Xcls_navliststore : Object
2398 public GLib.ListStore el;
2399 private Editor _this;
2405 public Xcls_navliststore(Editor _owner )
2408 _this.navliststore = this;
2409 this.el = new GLib.ListStore( typeof(Lsp.DocumentSymbol) );
2413 // set gobject values
2416 // user defined functions
2417 public Lsp.DocumentSymbol? symbolAtLine (uint line, uint chr) {
2420 for(var i = 0; i < this.el.get_n_items();i++) {
2421 var el = (Lsp.DocumentSymbol)this.el.get_item(i);
2422 //GLib.debug("Check sym %s : %d-%d",
2423 // el.name , (int)el.range.start.line,
2424 // (int)el.range.end.line
2426 var ret = el.containsLine(line,chr);
2438 public class Xcls_TreeListRowSorter37 : Object
2440 public Gtk.TreeListRowSorter el;
2441 private Editor _this;
2447 public Xcls_TreeListRowSorter37(Editor _owner )
2450 var child_1 = new Xcls_StringSorter38( _this );
2452 this.el = new Gtk.TreeListRowSorter( child_1.el );
2456 // set gobject values
2459 // user defined functions
2461 public class Xcls_StringSorter38 : Object
2463 public Gtk.StringSorter el;
2464 private Editor _this;
2470 public Xcls_StringSorter38(Editor _owner )
2473 var child_1 = new Xcls_PropertyExpression39( _this );
2475 this.el = new Gtk.StringSorter( child_1.el );
2479 // set gobject values
2482 // user defined functions
2484 public class Xcls_PropertyExpression39 : Object
2486 public Gtk.PropertyExpression el;
2487 private Editor _this;
2493 public Xcls_PropertyExpression39(Editor _owner )
2496 this.el = new Gtk.PropertyExpression( typeof(Lsp.DocumentSymbol), null, "sort_key" );
2500 // set gobject values
2503 // user defined functions
2510 public class Xcls_GestureClick40 : Object
2512 public Gtk.GestureClick el;
2513 private Editor _this;
2519 public Xcls_GestureClick40(Editor _owner )
2522 this.el = new Gtk.GestureClick();
2526 // set gobject values
2529 this.el.pressed.connect( (n_press, x, y) => {
2531 var row = _this.navigation.getRowWidgetAt(x,y, out pos );
2534 GLib.debug("no row selected items");
2537 GLib.debug("got click on %s", row.get_type().name());
2538 //Lsp.DocumentSymbol
2539 var sym = row.get_data<Lsp.DocumentSymbol>("symbol");
2555 GLib.debug("goto line %d", (int)sym.range.start.line);
2556 _this.scroll_to_line((int)sym.range.start.line);
2558 _this.buffer.el.get_iter_at_line_offset(out iter,
2559 (int)sym.range.start.line,
2560 (int)sym.range.start.character
2562 _this.buffer.el.place_cursor(iter);
2567 // user defined functions