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.width_request = 200;
422 this.el.shrink_end_child = false;
423 var child_1 = new Xcls_Box2( _this );
425 this.el.start_child = child_1.el;
426 var child_2 = new Xcls_Box27( _this );
428 this.el.end_child = child_2.el;
431 // user defined functions
433 public class Xcls_Box2 : Object
436 private Editor _this;
442 public Xcls_Box2(Editor _owner )
445 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
449 // set gobject values
450 var child_1 = new Xcls_Box3( _this );
452 this.el.append( child_1.el );
453 new Xcls_RightEditor( _this );
454 this.el.append( _this.RightEditor.el );
455 var child_3 = new Xcls_Box15( _this );
457 this.el.append ( child_3.el );
460 // user defined functions
462 public class Xcls_Box3 : Object
465 private Editor _this;
471 public Xcls_Box3(Editor _owner )
474 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
478 // set gobject values
479 this.el.homogeneous = false;
480 this.el.hexpand = true;
481 this.el.vexpand = false;
482 new Xcls_save_button( _this );
483 this.el.append( _this.save_button.el );
484 new Xcls_helper( _this );
485 this.el.append( _this.helper.el );
486 var child_3 = new Xcls_Scale6( _this );
488 this.el.append( child_3.el );
489 new Xcls_close_btn( _this );
490 this.el.append( _this.close_btn.el );
493 // user defined functions
495 public class Xcls_save_button : Object
497 public Gtk.Button el;
498 private Editor _this;
504 public Xcls_save_button(Editor _owner )
507 _this.save_button = this;
508 this.el = new Gtk.Button();
512 // set gobject values
513 this.el.vexpand = true;
514 this.el.label = "Save";
517 this.el.clicked.connect( () => {
518 _this.saveContents();
522 // user defined functions
525 public class Xcls_helper : Object
528 private Editor _this;
534 public Xcls_helper(Editor _owner )
538 this.el = new Gtk.Label( null );
542 // set gobject values
543 this.el.margin_end = 4;
544 this.el.margin_start = 4;
545 this.el.justify = Gtk.Justification.LEFT;
546 this.el.hexpand = true;
549 // user defined functions
550 public void setHelp (Lsp.Hover? help) {
551 if (help == null || help.contents == null
552 || help.contents.size < 1) {
553 this.el.set_text("");
556 var sig = help.contents.get(0).value.split(" ");
558 for(var i =0; i < sig.length; i++) {
577 str += ("<span underline=\"single\" color=\"blue\" >" +
578 GLib.Markup.escape_text(sig[i])
583 if (help.contents.size > 1) {
584 sig += ("\n\n" + help.contents[1].value);
587 this.el.set_markup(string.joinv(" ",str));
592 public class Xcls_Scale6 : Object
595 private Editor _this;
601 public Xcls_Scale6(Editor _owner )
604 this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1);
608 // set gobject values
609 this.el.width_request = 200;
610 this.el.has_origin = true;
611 this.el.draw_value = false;
613 this.el.sensitive = true;
618 //this.el.set_range(6,30);
619 this.el.set_value ( BuilderApplication.settings.editor_font_size);
620 BuilderApplication.settings.editor_font_size_updated.connect(
622 BuilderApplication.settings.editor_font_size_inchange = true;
623 // GLib.debug("update range");
624 this.el.set_value (BuilderApplication.settings.editor_font_size);
625 BuilderApplication.settings.editor_font_size_inchange = false;
633 this.el.change_value.connect( (st, val ) => {
634 if (BuilderApplication.settings.editor_font_size_inchange) {
637 BuilderApplication.settings.editor_font_size = val;
642 // user defined functions
645 public class Xcls_close_btn : Object
647 public Gtk.Button el;
648 private Editor _this;
654 public Xcls_close_btn(Editor _owner )
657 _this.close_btn = this;
658 this.el = new Gtk.Button();
662 // set gobject values
663 this.el.icon_name = "window-close";
664 var child_1 = new Xcls_Image8( _this );
666 this.el.child = child_1.el;
669 this.el.clicked.connect( () => {
670 _this.saveContents();
671 _this.window.windowstate.switchState(WindowState.State.PREVIEW);
675 // user defined functions
677 public class Xcls_Image8 : Object
680 private Editor _this;
686 public Xcls_Image8(Editor _owner )
689 this.el = new Gtk.Image();
693 // set gobject values
694 this.el.icon_name = "window-close";
695 this.el.icon_size = Gtk.IconSize.NORMAL;
698 // user defined functions
703 public class Xcls_RightEditor : Object
705 public Gtk.ScrolledWindow el;
706 private Editor _this;
712 public Xcls_RightEditor(Editor _owner )
715 _this.RightEditor = this;
716 this.el = new Gtk.ScrolledWindow();
720 // set gobject values
721 this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
722 this.el.vexpand = true;
723 this.el.overlay_scrolling = false;
724 this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
725 new Xcls_view( _this );
726 this.el.child = _this.view.el;
729 // user defined functions
731 public class Xcls_view : Object
733 public GtkSource.View el;
734 private Editor _this;
738 public Gtk.CssProvider css;
741 public Xcls_view(Editor _owner )
745 this.el = new GtkSource.View();
750 // set gobject values
751 this.el.auto_indent = true;
752 this.el.indent_width = 4;
753 this.el.name = "editor-view";
754 this.el.show_line_marks = true;
755 this.el.insert_spaces_instead_of_tabs = true;
756 this.el.show_line_numbers = true;
757 this.el.hexpand = true;
758 this.el.vexpand = true;
759 this.el.has_tooltip = true;
760 this.el.css_classes = { "code-editor" };
761 this.el.tab_width = 4;
762 this.el.highlight_current_line = true;
763 new Xcls_buffer( _this );
764 this.el.buffer = _this.buffer.el;
765 new Xcls_keystate( _this );
766 this.el.add_controller( _this.keystate.el );
767 var child_3 = new Xcls_EventControllerScroll13( _this );
769 this.el.add_controller( child_3.el );
770 var child_4 = new Xcls_GestureClick14( _this );
772 this.el.add_controller( child_4.el );
776 this.el.completion.add_provider(
777 new Palete.CompletionProvider(_this)
780 // hover seems pretty useless.. - ??
781 //var hover = this.el.get_hover();
782 //hover.add_provider(new Palete.HoverProvider(_this));
784 //this.el.completion.unblock_interactive();
785 this.el.completion.select_on_show = true; // select
786 //this.el.completion.remember_info_visibility = true;
789 var attrs = new GtkSource.MarkAttributes();
791 attrs.set_icon_name ( "process-stop");
792 attrs.query_tooltip_text.connect(( mark) => {
793 GLib.debug("tooltip query? %s", mark.name);
794 return strdup( mark.name);
796 attrs.query_tooltip_markup.connect(( mark) => {
797 GLib.debug("tooltip query? %s", mark.name);
798 return strdup( mark.name);
800 this.el.set_mark_attributes ("ERR", attrs, 1);
804 var wattrs = new GtkSource.MarkAttributes();
805 wattrs.set_icon_name ( "process-stop");
806 wattrs.query_tooltip_text.connect(( mark) => {
807 GLib.debug("tooltip query? %s", mark.name);
808 return strdup(mark.name);
810 wattrs.query_tooltip_markup.connect(( mark) => {
811 GLib.debug("tooltip query? %s", mark.name);
812 return strdup(mark.name);
814 this.el.set_mark_attributes ("WARN", wattrs, 1);
818 var dattrs = new GtkSource.MarkAttributes();
820 dattrs.set_icon_name ( "process-stop");
822 dattrs.query_tooltip_text.connect(( mark) => {
823 GLib.debug("tooltip query? %s", mark.name);
824 return strdup(mark.name);
826 //dattrs.query_tooltip_markup.connect(( mark) => {
827 // GLib.debug("tooltip query? %s", mark.name);
828 // return strdup(mark.name);
830 this.el.set_mark_attributes ("DEPR", dattrs, 1);
833 this.el.get_space_drawer().set_matrix(null);
834 this.el.get_space_drawer().set_types_for_locations(
835 GtkSource.SpaceLocationFlags.ALL,
836 GtkSource.SpaceTypeFlags.ALL
838 this.el.get_space_drawer().set_enable_matrix(true);
841 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
843 //GLib.debug("query tooltip");
847 var yoff = (int) _this.RightEditor.el.vadjustment.value;
849 // I think this is problematic - if it's compliing / updating at same time as query.
851 //if (_this.window.statusbar_compile_spinner.el.spinning) {
855 this.el.get_iter_at_position (out iter, out trailing, x, y + yoff);
857 var l = iter.get_line();
861 // GLib.debug("query tooltip line %d", (int) l);
867 if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {
868 GLib.debug("line %d setting tip to %s", l, _this.buffer.marks.get(l));
869 tooltip.set_text(_this.buffer.marks.get(l).dup());
877 // this crashes?? - not sure why.
878 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
879 if (marks.is_empty()) {
880 marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
882 if (marks.is_empty()) {
883 marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
886 // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length());
888 marks.@foreach((m) => {
889 //GLib.debug("got mark %s", m.name);
890 str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name;
892 // true if there is a mark..
893 if (str.length > 0 ) {
894 tooltip.set_text( str );
896 return str.length > 0 ? true : false;
901 // user defined functions
902 public void load (string str) {
904 // show the help page for the active node..
905 //this.get('/Help').show();
907 // this.get('/BottomPane').el.set_current_page(0);
908 GLib.debug("load called - Reset undo buffer");
910 var buf = (GtkSource.Buffer)this.el.get_buffer();
911 buf.begin_irreversible_action();
912 buf.set_text(str, str.length);
913 buf.end_irreversible_action();
915 var lm = GtkSource.LanguageManager.get_default();
917 if (_this.file != null) {
918 lang = _this.file.language;
920 print("lang=%s, content_type = %s\n", lang, _this.file.content_type);
921 var lg = _this.file.content_type.length > 0 ?
922 lm.guess_language(_this.file.path, _this.file.content_type) :
923 lm.get_language(lang);
926 ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg);
928 this.el.insert_spaces_instead_of_tabs = true;
930 print("sourcelanguage = %s\n", lg.name);
931 if (lg.name == "Vala") {
932 this.el.insert_spaces_instead_of_tabs = false;
936 this.el.grab_focus();
937 _this.save_button.el.sensitive = false;
938 _this.last_error_counter = -1;
941 public class Xcls_buffer : Object
943 public GtkSource.Buffer el;
944 private Editor _this;
948 public int error_line;
949 public Gee.HashMap<int,string>? xmarks;
950 public bool check_queued;
953 public Xcls_buffer(Editor _owner )
957 this.el = new GtkSource.Buffer( null );
960 this.error_line = -1;
962 this.check_queued = false;
964 // set gobject values
965 this.el.highlight_syntax = true;
966 this.el.highlight_matching_brackets = true;
967 this.el.enable_undo = true;
972 buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
973 buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
974 buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
975 buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
976 buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
977 buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
978 buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
979 buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
982 buf.create_tag ("ERR", "weight", Pango.Weight.BOLD, "background", "pink");
983 buf.create_tag ("WARN", "weight", Pango.Weight.BOLD, "background", "#ABF4EB");
984 buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
987 this.el.cursor_moved.connect( ( ) => {
990 this.el.get_iter_at_offset (
991 out iter, this.el.cursor_position);
993 _this.navigation.updateSelectedLine(
994 (uint)iter.get_line(),
995 (uint)iter.get_line_offset()
1000 this.el.changed.connect( () => {
1003 _this.save_button.el.sensitive = true;
1004 print("EDITOR CHANGED");
1009 // this.get('/LeftPanel.model').changed( str , false);
1014 // user defined functions
1015 public bool OLDhighlightErrorsJson (string type, Json.Object obj) {
1018 this.el.get_bounds (out start, out end);
1020 this.el.remove_source_marks (start, end, type);
1021 GLib.debug("highlight errors");
1023 // we should highlight other types of errors..
1025 if (!obj.has_member(type)) {
1026 GLib.debug("Return has no errors\n");
1030 if (_this.window.windowstate.state != WindowState.State.CODEONLY
1032 _this.window.windowstate.state != WindowState.State.CODE
1034 GLib.debug("windowstate != CODEONLY?");
1039 //this.marks = new Gee.HashMap<int,string>();
1040 var err = obj.get_object_member(type);
1042 if (_this.file == null) {
1043 GLib.debug("file is null?");
1047 var valafn = _this.file.path;
1049 if (_this.file.xtype != "PlainFile") {
1053 var regex = new Regex("\\.bjs$");
1054 // should not happen
1055 valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
1056 } catch (GLib.RegexError e) {
1063 if (!err.has_member(valafn)) {
1064 GLib.debug("File path has no errors");
1068 var lines = err.get_object_member(valafn);
1071 if (obj.has_member("line_offset")) { // ?? why??
1072 offset = (int)obj.get_int_member("line_offset") + 1;
1076 var tlines = this.el.get_line_count () +1;
1078 if (_this.prop != null) {
1080 tlines = _this.prop.end_line + 1;
1081 offset = _this.prop.start_line + 1;
1087 lines.foreach_member((obj, line, node) => {
1090 // print("get inter\n");
1091 var eline = int.parse(line) - offset;
1092 GLib.debug("GOT ERROR on line %s -- converted to %d (offset = %d)\n", line,eline, offset);
1095 if (eline > tlines || eline < 0) {
1100 this.el.get_iter_at_line( out iter, eline);
1101 //print("mark line\n");
1103 var ar = lines.get_array_member(line);
1104 for (var i = 0 ; i < ar.get_length(); i++) {
1105 if (ar.get_string_element(i) == "Success") {
1108 msg += (msg.length > 0) ? "\n" : "";
1109 msg += ar.get_string_element(i);
1114 msg = "Line: %d".printf(eline+1) + " " + msg;
1115 this.el.create_source_mark(msg, type, iter);
1116 GLib.debug("set line %d to %m", eline, msg);
1117 // this.marks.set(eline, msg);
1126 public bool checkSyntax () {
1129 var str = this.toString();
1132 if (this.error_line > 0) {
1135 this.el.get_bounds (out start, out end);
1137 this.el.remove_source_marks (start, end, null);
1139 if (str.length < 1) {
1140 print("checkSyntax - empty string?\n");
1145 if (_this.file.xtype == "PlainFile") {
1147 // assume it's gtk...
1148 var oldcode =_this.file.toSource();
1149 _this.file.setSource(str);
1150 BuilderApplication.showSpinner("appointment soon","document change pending");
1151 _this.file.getLanguageServer().document_change(_this.file);
1152 _this.file.getLanguageServer().queueDocumentSymbols(_this.file);
1153 _this.file.setSource(oldcode);
1159 if (_this.file == null) {
1167 GLib.debug("calling validate");
1168 // clear the buttons.
1169 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
1172 var oldcode = _this.prop.val;
1174 _this.prop.val = str;
1175 _this.node.updated_count++;
1176 _this.file.getLanguageServer().document_change(_this.file);
1177 _this.node.updated_count++;
1178 _this.prop.val = oldcode;
1181 //print("done mark line\n");
1183 return true; // at present allow saving - even if it's invalid..
1185 public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
1187 this.error_line = validate_res.size;
1189 if (this.error_line < 1) {
1192 var tlines = this.el.get_line_count ();
1194 var valiter = validate_res.map_iterator();
1195 while (valiter.next()) {
1197 // print("get inter\n");
1198 var eline = valiter.get_key();
1199 if (eline > tlines) {
1202 this.el.get_iter_at_line( out iter, eline);
1203 //print("mark line\n");
1204 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
1208 public string toString () {
1212 this.el.get_start_iter(out s);
1213 this.el.get_end_iter(out e);
1214 var ret = this.el.get_text(s,e,true);
1215 //print("TO STRING? " + ret);
1220 public class Xcls_keystate : Object
1222 public Gtk.EventControllerKey el;
1223 private Editor _this;
1227 public bool is_control;
1230 public Xcls_keystate(Editor _owner )
1233 _this.keystate = this;
1234 this.el = new Gtk.EventControllerKey();
1237 this.is_control = false;
1239 // set gobject values
1242 this.el.key_released.connect( (keyval, keycode, state) => {
1244 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1245 this.is_control = false;
1247 if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1248 GLib.debug("SAVE: ctrl-S pressed");
1249 _this.saveContents();
1253 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1254 GLib.debug("SAVE: ctrl-g pressed");
1255 _this.forwardSearch(true);
1258 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1259 GLib.debug("SAVE: ctrl-f pressed");
1260 _this.search_entry.el.grab_focus();
1261 _this.search_entry.el.select_region(0,-1);
1264 if (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1265 _this.view.el.show_completion();
1269 _this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);
1270 var line = iter.get_line();
1271 var offset = iter.get_line_offset();
1272 GLib.debug("line %d off %d", line ,offset);
1273 if (_this.prop != null) {
1274 line += _this.prop.start_line + 1; // i think..
1275 offset += 12; // should probably be 8 without namespaced
1276 GLib.debug("guess line %d off %d", line ,offset);
1278 //_this.view.el.show_completion();
1279 // print(event.key.keyval)
1286 this.el.key_pressed.connect( (keyval, keycode, state) => {
1288 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1289 this.is_control = true;
1295 // user defined functions
1298 public class Xcls_EventControllerScroll13 : Object
1300 public Gtk.EventControllerScroll el;
1301 private Editor _this;
1305 public double distance;
1308 public Xcls_EventControllerScroll13(Editor _owner )
1311 this.el = new Gtk.EventControllerScroll( Gtk.EventControllerScrollFlags.VERTICAL );
1314 this.distance = 0.0f;
1316 // set gobject values
1319 this.el.scroll.connect( (dx, dy) => {
1320 if (!_this.keystate.is_control) {
1323 //GLib.debug("scroll %f", dy);
1325 this.distance += dy;
1327 //GLib.debug("scroll %f / %f", dy, this.distance);
1329 if (this.distance < -1) {
1331 BuilderApplication.settings.editor_font_size ++;
1334 if (this.distance > 1) {
1335 BuilderApplication.settings.editor_font_size --;
1343 // user defined functions
1346 public class Xcls_GestureClick14 : Object
1348 public Gtk.GestureClick el;
1349 private Editor _this;
1355 public Xcls_GestureClick14(Editor _owner )
1358 this.el = new Gtk.GestureClick();
1362 // set gobject values
1365 this.el.pressed.connect( (n_press, x, y) => {
1367 int buffer_x, buffer_y;
1368 var gut = _this.view.el.get_gutter(Gtk.TextWindowType.LEFT);
1370 _this.view.el.window_to_buffer_coords (Gtk.TextWindowType.TEXT,
1371 (int)x - gut.get_width(), (int)y,
1372 out buffer_x, out buffer_y);
1373 _this.view.el.get_iter_at_location (out iter,
1374 buffer_x, buffer_y);;
1377 if (_this.buffer.el.iter_has_context_class(iter, "comment") ||
1378 _this.buffer.el.iter_has_context_class(iter, "string")
1382 var back = iter.copy();
1383 back.backward_char();
1385 var forward = iter.copy();
1386 forward.forward_char();
1388 // what's the character at the iter?
1389 var str = back.get_text(iter);
1390 str += iter.get_text(forward);
1391 if (str.strip().length < 1) {
1394 var offset = iter.get_line_offset();
1395 var line = iter.get_line();
1396 if (_this.prop != null) {
1398 line += _this.prop.start_line ;
1399 // this is based on Gtk using tabs (hence 1/2 chars);
1400 offset += _this.node.node_pad.length;
1401 // javascript listeners are indented 2 more spaces.
1402 if (_this.prop.ptype == JsRender.NodePropType.LISTENER) {
1407 var ls = _this.file.getLanguageServer();
1409 _this.file, line, offset,
1411 var res = ls.hover.end(o );
1412 _this.helper.setHelp(res);
1416 things that can ber returned..
1420 Jsrennder.jsrender Editor.file
1421 Palete.LanguageClient? JsRender.JsRender.getLanguageServer ()
1422 Palete.LanguageClient? ls = _this.file.getLanguageServer()
1423 async Lsp.Hover Palete.LanguageClient.hover (JsRender.JsRender file, int line, int offset) throws GLib.Error
1424 .string JsRender.Node.node_pad = \"\"
1427 string Gtk.TextIter.get_text (Gtk.TextIter end)
1432 // could never get this to work anywhere..
1433 // looks like its probably for calling stuff..
1434 // but always returns null..
1436 ls.signatureHelp.begin(
1437 _this.file, iter.get_line(), iter.get_line_offset(),
1439 var res = ls.signatureHelp.end(o );
1447 // user defined functions
1452 public class Xcls_Box15 : Object
1455 private Editor _this;
1461 public Xcls_Box15(Editor _owner )
1464 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1468 // set gobject values
1469 this.el.homogeneous = false;
1470 this.el.vexpand = false;
1471 new Xcls_search_entry( _this );
1472 this.el.append( _this.search_entry.el );
1473 new Xcls_search_results( _this );
1474 this.el.append( _this.search_results.el );
1475 new Xcls_nextBtn( _this );
1476 this.el.append( _this.nextBtn.el );
1477 new Xcls_backBtn( _this );
1478 this.el.append( _this.backBtn.el );
1479 var child_5 = new Xcls_MenuButton21( _this );
1481 this.el.append( child_5.el );
1484 // user defined functions
1486 public class Xcls_search_entry : Object
1488 public Gtk.SearchEntry el;
1489 private Editor _this;
1493 public Gtk.CssProvider css;
1496 public Xcls_search_entry(Editor _owner )
1499 _this.search_entry = this;
1500 this.el = new Gtk.SearchEntry();
1504 // set gobject values
1505 this.el.name = "editor-search-entry";
1506 this.el.hexpand = true;
1507 this.el.placeholder_text = "Press enter to search";
1508 this.el.search_delay = 3;
1509 var child_1 = new Xcls_EventControllerKey17( _this );
1511 this.el.add_controller( child_1.el );
1514 this.el.search_changed.connect( ( ) => {
1516 _this.search(_this.search_entry.el.text);
1517 _this.search_results.updateResults();
1519 GLib.Timeout.add_seconds(1,() => {
1520 _this.search_results.updateResults();
1526 // user defined functions
1527 public void forwardSearch (bool change_focus) {
1530 _this.forwardSearch(change_focus);
1534 switch(_this.windowstate.state) {
1535 case WindowState.State.CODEONLY:
1536 //case WindowState.State.CODE:
1537 // search the code being edited..
1538 _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1541 case WindowState.State.PREVIEW:
1542 if (_this.windowstate.file.xtype == "Gtk") {
1543 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1545 _this.windowstate.window_rooview.forwardSearch(change_focus);
1554 public class Xcls_EventControllerKey17 : Object
1556 public Gtk.EventControllerKey el;
1557 private Editor _this;
1563 public Xcls_EventControllerKey17(Editor _owner )
1566 this.el = new Gtk.EventControllerKey();
1570 // set gobject values
1573 this.el.key_pressed.connect( (keyval, keycode, state) => {
1575 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1576 GLib.debug("SAVE: ctrl-g pressed");
1577 _this.forwardSearch(true);
1582 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1583 _this.forwardSearch(true);
1589 // print(event.key.keyval)
1595 // user defined functions
1599 public class Xcls_search_results : Object
1601 public Gtk.Label el;
1602 private Editor _this;
1608 public Xcls_search_results(Editor _owner )
1611 _this.search_results = this;
1612 this.el = new Gtk.Label( "No Results" );
1616 // set gobject values
1617 this.el.margin_end = 4;
1618 this.el.margin_start = 4;
1621 // user defined functions
1622 public void updateResults () {
1623 this.el.visible = true;
1625 var res = _this.searchcontext.get_occurrences_count();
1627 _this.search_results.el.label = "??? Matches";
1631 _this.nextBtn.el.sensitive = false;
1632 _this.backBtn.el.sensitive = false;
1635 _this.search_results.el.label = "%d Matches".printf(res);
1636 _this.nextBtn.el.sensitive = true;
1637 _this.backBtn.el.sensitive = true;
1640 _this.search_results.el.label = "No Matches";
1645 public class Xcls_nextBtn : Object
1647 public Gtk.Button el;
1648 private Editor _this;
1652 public bool always_show_image;
1655 public Xcls_nextBtn(Editor _owner )
1658 _this.nextBtn = this;
1659 this.el = new Gtk.Button();
1662 this.always_show_image = true;
1664 // set gobject values
1665 this.el.icon_name = "go-down";
1666 this.el.sensitive = false;
1669 this.el.clicked.connect( (event) => {
1671 _this.forwardSearch(true);
1677 // user defined functions
1680 public class Xcls_backBtn : Object
1682 public Gtk.Button el;
1683 private Editor _this;
1687 public bool always_show_image;
1690 public Xcls_backBtn(Editor _owner )
1693 _this.backBtn = this;
1694 this.el = new Gtk.Button();
1697 this.always_show_image = true;
1699 // set gobject values
1700 this.el.icon_name = "go-up";
1701 this.el.sensitive = false;
1704 this.el.clicked.connect( (event) => {
1706 _this.backSearch(true);
1711 // user defined functions
1714 public class Xcls_MenuButton21 : Object
1716 public Gtk.MenuButton el;
1717 private Editor _this;
1721 public bool always_show_image;
1724 public Xcls_MenuButton21(Editor _owner )
1727 this.el = new Gtk.MenuButton();
1730 this.always_show_image = true;
1732 // set gobject values
1733 this.el.icon_name = "emblem-system";
1734 this.el.always_show_arrow = true;
1735 new Xcls_search_settings( _this );
1736 this.el.popover = _this.search_settings.el;
1739 // user defined functions
1741 public class Xcls_search_settings : Object
1743 public Gtk.Popover el;
1744 private Editor _this;
1750 public Xcls_search_settings(Editor _owner )
1753 _this.search_settings = this;
1754 this.el = new Gtk.Popover();
1758 // set gobject values
1759 var child_1 = new Xcls_Box23( _this );
1761 this.el.child = child_1.el;
1764 // user defined functions
1766 public class Xcls_Box23 : Object
1769 private Editor _this;
1775 public Xcls_Box23(Editor _owner )
1778 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1782 // set gobject values
1783 new Xcls_case_sensitive( _this );
1784 this.el.append( _this.case_sensitive.el );
1785 new Xcls_regex( _this );
1786 this.el.append( _this.regex.el );
1787 new Xcls_multiline( _this );
1788 this.el.append( _this.multiline.el );
1791 // user defined functions
1793 public class Xcls_case_sensitive : Object
1795 public Gtk.CheckButton el;
1796 private Editor _this;
1802 public Xcls_case_sensitive(Editor _owner )
1805 _this.case_sensitive = this;
1806 this.el = new Gtk.CheckButton();
1810 // set gobject values
1811 this.el.label = "Case Sensitive";
1820 // user defined functions
1823 public class Xcls_regex : Object
1825 public Gtk.CheckButton el;
1826 private Editor _this;
1832 public Xcls_regex(Editor _owner )
1836 this.el = new Gtk.CheckButton();
1840 // set gobject values
1841 this.el.label = "Regex";
1850 // user defined functions
1853 public class Xcls_multiline : Object
1855 public Gtk.CheckButton el;
1856 private Editor _this;
1862 public Xcls_multiline(Editor _owner )
1865 _this.multiline = this;
1866 this.el = new Gtk.CheckButton();
1870 // set gobject values
1871 this.el.label = "Multi-line (add \\n)";
1874 // user defined functions
1882 public class Xcls_Box27 : Object
1885 private Editor _this;
1891 public Xcls_Box27(Editor _owner )
1894 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1898 // set gobject values
1899 this.el.hexpand = true;
1900 this.el.vexpand = true;
1901 var child_1 = new Xcls_Box28( _this );
1903 this.el.append( child_1.el );
1904 new Xcls_navigationwindow( _this );
1905 this.el.append( _this.navigationwindow.el );
1908 // user defined functions
1910 public class Xcls_Box28 : Object
1913 private Editor _this;
1919 public Xcls_Box28(Editor _owner )
1922 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1926 // set gobject values
1929 // user defined functions
1932 public class Xcls_navigationwindow : Object
1934 public Gtk.ScrolledWindow el;
1935 private Editor _this;
1941 public Xcls_navigationwindow(Editor _owner )
1944 _this.navigationwindow = this;
1945 this.el = new Gtk.ScrolledWindow();
1949 // set gobject values
1950 this.el.hexpand = true;
1951 this.el.vexpand = true;
1952 this.el.visible = false;
1953 new Xcls_navigation( _this );
1954 this.el.child = _this.navigation.el;
1957 // user defined functions
1959 public class Xcls_navigation : Object
1961 public Gtk.ColumnView el;
1962 private Editor _this;
1966 public int last_selected_line;
1967 public Gtk.Widget? selected_row;
1970 public Xcls_navigation(Editor _owner )
1973 _this.navigation = this;
1974 new Xcls_navigationselmodel( _this );
1975 this.el = new Gtk.ColumnView( _this.navigationselmodel.el );
1978 this.last_selected_line = -1;
1979 this.selected_row = null;
1981 // set gobject values
1982 this.el.name = "editor-navigation";
1983 var child_2 = new Xcls_ColumnViewColumn31( _this );
1985 this.el.append_column( child_2.el );
1986 var child_3 = new Xcls_GestureClick40( _this );
1988 this.el.add_controller( child_3.el );
1991 // user defined functions
1992 public Gtk.Widget? getRowWidgetAt (double x, double y, out string pos) {
1995 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
1996 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
2001 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
2006 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2010 //GLib.debug("row number is %d", rn);
2011 //GLib.debug("click %d, %d", (int)x, (int)y);
2013 Graphene.Rect bounds;
2014 row.compute_bounds(this.el, out bounds);
2015 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2016 // (int)bounds.get_x(), (int)bounds.get_y(),
2017 // (int)bounds.get_width(), (int)bounds.get_height()
2019 var ypos = y - bounds.get_y();
2020 //GLib.debug("rel ypos = %d", (int)ypos);
2021 var rpos = 100.0 * (ypos / bounds.get_height());
2022 //GLib.debug("rel pos = %d %%", (int)rpos);
2027 } else if (rpos < 20) {
2032 public void show (Gee.ArrayList<Lsp.DocumentSymbol> syms) {
2033 _this.navigationwindow.el.show();
2034 //_this.navliststore.el.remove_all();
2037 var ls = new GLib.ListStore(typeof(Lsp.DocumentSymbol));
2039 foreach(var sym in syms) {
2042 Lsp.DocumentSymbol.copyList(ls, _this.navliststore.el);
2043 //_this.navliststore.el.append(sym);
2044 this.last_selected_line = -1;
2045 GLib.Idle.add(() => {
2046 _this.navigationsort.collapseOnLoad();
2048 _this.buffer.el.get_iter_at_offset (
2049 out iter, _this.buffer.el.cursor_position);
2051 GLib.debug("idle update scroll %d, %d", iter.get_line(),
2052 iter.get_line_offset());
2053 this.updateSelectedLine(
2054 (uint)iter.get_line(),
2055 (uint)iter.get_line_offset()
2061 public int getRowAt (double x, double y, out string pos) {
2064 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
2065 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
2070 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
2075 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2080 while (cr.get_prev_sibling() != null) {
2082 cr = cr.get_prev_sibling();
2085 //GLib.debug("row number is %d", rn);
2086 //GLib.debug("click %d, %d", (int)x, (int)y);
2088 Graphene.Rect bounds;
2089 row.compute_bounds(this.el, out bounds);
2090 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2091 // (int)bounds.get_x(), (int)bounds.get_y(),
2092 // (int)bounds.get_width(), (int)bounds.get_height()
2094 var ypos = y - bounds.get_y();
2095 //GLib.debug("rel ypos = %d", (int)ypos);
2096 var rpos = 100.0 * (ypos / bounds.get_height());
2097 //GLib.debug("rel pos = %d %%", (int)rpos);
2102 } else if (rpos < 20) {
2107 public void updateSelectedLine (uint line, uint chr) {
2108 if (line == this.last_selected_line) {
2111 GLib.debug("select line %d", (int)line);
2112 this.last_selected_line = (int)line;
2116 var sym = _this.navliststore.symbolAtLine(line, chr);
2118 new_row = _this.navigationsort.getRowFromSymbol(sym);
2119 GLib.debug("select line %d - row found %d", (int)line, new_row);
2121 GLib.debug(" no symbol found at line %d", (int)line);
2124 if (this.selected_row != null) {
2125 GLib.debug(" remove selected row");
2126 this.selected_row.remove_css_class("selected-row");
2128 this.selected_row = null;
2130 this.el.scroll_to(new_row,null,Gtk.ListScrollFlags.NONE, null);
2131 var row = sym.get_data<Gtk.Widget>("widget");
2133 GLib.debug(" Add selected row");
2135 row.add_css_class("selected-row");
2136 this.selected_row = row;
2140 GLib.debug("could not find widget on row %d", new_row);
2148 public class Xcls_ColumnViewColumn31 : Object
2150 public Gtk.ColumnViewColumn el;
2151 private Editor _this;
2157 public Xcls_ColumnViewColumn31(Editor _owner )
2160 var child_1 = new Xcls_SignalListItemFactory32( _this );
2162 this.el = new Gtk.ColumnViewColumn( "Code Navigation", child_1.el );
2166 // set gobject values
2167 this.el.expand = true;
2170 // user defined functions
2172 public class Xcls_SignalListItemFactory32 : Object
2174 public Gtk.SignalListItemFactory el;
2175 private Editor _this;
2181 public Xcls_SignalListItemFactory32(Editor _owner )
2184 this.el = new Gtk.SignalListItemFactory();
2188 // set gobject values
2191 this.el.setup.connect( (listitem) => {
2193 var expand = new Gtk.TreeExpander();
2195 expand.set_indent_for_depth(true);
2196 expand.set_indent_for_icon(true);
2197 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2198 var icon = new Gtk.Image();
2199 var lbl = new Gtk.Label("");
2200 lbl.use_markup = true;
2201 lbl.ellipsize = Pango.EllipsizeMode.END;
2203 icon.margin_end = 4;
2204 lbl.justify = Gtk.Justification.LEFT;
2207 // listitem.activatable = true; ??
2211 expand.set_child(hbox);
2212 ((Gtk.ListItem)listitem).set_child(expand);
2215 this.el.bind.connect( (listitem) => {
2217 // GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name());
2219 //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2220 var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2223 var hbox = (Gtk.Box) expand.child;
2226 var img = (Gtk.Image) hbox.get_first_child();
2227 var lbl = (Gtk.Label) img.get_next_sibling();
2229 var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();
2230 var sym = (Lsp.DocumentSymbol) lr.get_item();
2232 sym.set_data<Gtk.Widget>("widget", expand.get_parent());
2233 expand.get_parent().get_parent().set_data<Lsp.DocumentSymbol>("symbol", sym);
2235 //GLib.debug("save sym on %s", expand.get_parent().get_parent().get_type().name());
2237 //GLib.debug("got %d children for %s" , (int)sym.children.get_n_items(), sym.name);
2239 expand.set_hide_expander( sym.children.get_n_items() < 1);
2240 expand.set_list_row(lr);
2241 //this.in_bind = true;
2242 // default is to expand
2244 //this.in_bind = false;
2246 sym.bind_property("symbol_icon",
2248 GLib.BindingFlags.SYNC_CREATE);
2250 hbox.css_classes = { sym.symbol_icon };
2252 sym.bind_property("name",
2254 GLib.BindingFlags.SYNC_CREATE);
2255 // should be better?- --line no?
2256 sym.bind_property("tooltip",
2257 lbl, "tooltip_markup",
2258 GLib.BindingFlags.SYNC_CREATE);
2264 // user defined functions
2268 public class Xcls_navigationselmodel : Object
2270 public Gtk.NoSelection el;
2271 private Editor _this;
2277 public Xcls_navigationselmodel(Editor _owner )
2280 _this.navigationselmodel = this;
2281 new Xcls_navigationsort( _this );
2282 this.el = new Gtk.NoSelection( _this.navigationsort.el );
2286 // set gobject values
2289 // user defined functions
2291 public class Xcls_navigationsort : Object
2293 public Gtk.SortListModel el;
2294 private Editor _this;
2300 public Xcls_navigationsort(Editor _owner )
2303 _this.navigationsort = this;
2304 var child_1 = new Xcls_TreeListModel35( _this );
2306 var child_2 = new Xcls_TreeListRowSorter37( _this );
2308 this.el = new Gtk.SortListModel( child_1.el, child_2.el );
2312 // set gobject values
2315 // user defined functions
2316 public void collapseOnLoad () {
2317 for (var i=0;i < this.el.get_n_items(); i++) {
2318 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2319 var sym = (Lsp.DocumentSymbol)tr.get_item();
2321 case Lsp.SymbolKind.Enum:
2322 tr.expanded = false;
2325 //tr.expanded = true;
2334 public int getRowFromSymbol (Lsp.DocumentSymbol sym) {
2336 for (var i=0;i < this.el.get_n_items(); i++) {
2337 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2339 if (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {
2345 public Lsp.DocumentSymbol? getSymbolAt (uint row) {
2347 var tr = (Gtk.TreeListRow)this.el.get_item(row);
2349 var a = tr.get_item();;
2350 GLib.debug("get_item (2) = %s", a.get_type().name());
2353 return (Lsp.DocumentSymbol)tr.get_item();
2357 public class Xcls_TreeListModel35 : Object
2359 public Gtk.TreeListModel el;
2360 private Editor _this;
2366 public Xcls_TreeListModel35(Editor _owner )
2369 new Xcls_navliststore( _this );
2370 this.el = new Gtk.TreeListModel( _this.navliststore.el, false, true, (item) => {
2372 return ((Lsp.DocumentSymbol)item).children;
2378 // set gobject values
2381 this.el.items_changed.connect( (position, removed, added) => {
2382 GLib.debug("tree item changed %d , %d , %d",(int) position, (int)removed, (int) added);
2386 //var sym = (Lsp.DocumentSymbol) this.el.get_item(position);
2387 var row = this.el.get_row(position);
2389 GLib.debug("got %s", row.get_item().get_type().name());
2395 // user defined functions
2397 public class Xcls_navliststore : Object
2399 public GLib.ListStore el;
2400 private Editor _this;
2406 public Xcls_navliststore(Editor _owner )
2409 _this.navliststore = this;
2410 this.el = new GLib.ListStore( typeof(Lsp.DocumentSymbol) );
2414 // set gobject values
2417 // user defined functions
2418 public Lsp.DocumentSymbol? symbolAtLine (uint line, uint chr) {
2421 for(var i = 0; i < this.el.get_n_items();i++) {
2422 var el = (Lsp.DocumentSymbol)this.el.get_item(i);
2423 //GLib.debug("Check sym %s : %d-%d",
2424 // el.name , (int)el.range.start.line,
2425 // (int)el.range.end.line
2427 var ret = el.containsLine(line,chr);
2439 public class Xcls_TreeListRowSorter37 : Object
2441 public Gtk.TreeListRowSorter el;
2442 private Editor _this;
2448 public Xcls_TreeListRowSorter37(Editor _owner )
2451 var child_1 = new Xcls_StringSorter38( _this );
2453 this.el = new Gtk.TreeListRowSorter( child_1.el );
2457 // set gobject values
2460 // user defined functions
2462 public class Xcls_StringSorter38 : Object
2464 public Gtk.StringSorter el;
2465 private Editor _this;
2471 public Xcls_StringSorter38(Editor _owner )
2474 var child_1 = new Xcls_PropertyExpression39( _this );
2476 this.el = new Gtk.StringSorter( child_1.el );
2480 // set gobject values
2483 // user defined functions
2485 public class Xcls_PropertyExpression39 : Object
2487 public Gtk.PropertyExpression el;
2488 private Editor _this;
2494 public Xcls_PropertyExpression39(Editor _owner )
2497 this.el = new Gtk.PropertyExpression( typeof(Lsp.DocumentSymbol), null, "sort_key" );
2501 // set gobject values
2504 // user defined functions
2511 public class Xcls_GestureClick40 : Object
2513 public Gtk.GestureClick el;
2514 private Editor _this;
2520 public Xcls_GestureClick40(Editor _owner )
2523 this.el = new Gtk.GestureClick();
2527 // set gobject values
2530 this.el.pressed.connect( (n_press, x, y) => {
2532 var row = _this.navigation.getRowWidgetAt(x,y, out pos );
2535 GLib.debug("no row selected items");
2538 GLib.debug("got click on %s", row.get_type().name());
2539 //Lsp.DocumentSymbol
2540 var sym = row.get_data<Lsp.DocumentSymbol>("symbol");
2556 GLib.debug("goto line %d", (int)sym.range.start.line);
2557 _this.scroll_to_line((int)sym.range.start.line);
2559 _this.buffer.el.get_iter_at_line_offset(out iter,
2560 (int)sym.range.start.line,
2561 (int)sym.range.start.character
2563 _this.buffer.el.place_cursor(iter);
2568 // user defined functions