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_navigation_holder navigation_holder;
31 public Xcls_navigationwindow navigationwindow;
32 public Xcls_navigation navigation;
33 public Xcls_navigationselmodel navigationselmodel;
34 public Xcls_navigationsort navigationsort;
35 public Xcls_navliststore navliststore;
38 public int pos_root_x;
39 public Xcls_MainWindow window;
41 public int pos_root_y;
43 public int last_error_counter;
44 public GtkSource.SearchContext searchcontext;
45 public int last_search_end;
46 public signal void save ();
47 public JsRender.JsRender? file;
48 public JsRender.Node node;
49 public JsRender.NodeProp? prop;
50 public string activeEditor;
56 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
62 this.last_error_counter = 0;
63 this.searchcontext = null;
64 this.last_search_end = 0;
68 this.activeEditor = "\"\"";
71 this.el.homogeneous = false;
72 this.el.hexpand = true;
73 this.el.vexpand = true;
74 var child_1 = new Xcls_Paned1( _this );
76 this.el.append( child_1.el );
79 // user defined functions
80 public bool saveContents () {
83 if (_this.file == null) {
89 var str = _this.buffer.toString();
91 _this.buffer.checkSyntax();
95 // LeftPanel.model.changed( str , false);
97 _this.save_button.el.sensitive = false;
99 // find the text for the node..
100 if (_this.file.xtype != "PlainFile") {
101 // in theory these properties have to exist!?!
103 //this.window.windowstate.left_props.reload();
105 _this.file.setSource( str );
114 public void forwardSearch (bool change_focus) {
116 if (this.searchcontext == null) {
120 Gtk.TextIter beg, st,en;
121 bool has_wrapped_around;
122 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end);
123 if (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {
125 this.last_search_end = 0; // not sure if this should happen
127 if (has_wrapped_around) {
131 this.last_search_end = en.get_offset();
133 this.view.el.grab_focus();
135 this.buffer.el.place_cursor(st);
136 this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);
140 public void show (JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)
143 if (this.file != null) {
144 this.file.navigation_tree_updated.disconnect(
145 _this.navigation.show
149 this.file.navigation_tree_updated.connect(
150 _this.navigation.show
152 if (file.xtype != "PlainFile") {
156 // find the text for the node..
157 this.view.load( prop.val );
158 this.updateErrorMarks();
162 this.close_btn.el.show();
165 this.view.load( file.toSource() );
166 this.updateErrorMarks();
167 this.close_btn.el.hide();
168 var ls = file.getLanguageServer();
169 ls.queueDocumentSymbols(file);
170 ////ls.documentSymbols.begin(file, (a,o) => {
171 // _this.navigation.show(ls.documentSymbols.end(o));
178 public void backSearch (bool change_focus) {
180 if (this.searchcontext == null) {
184 Gtk.TextIter beg, st,en;
185 bool has_wrapped_around;
186 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );
188 if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {
189 this.last_search_end = 0;
191 this.last_search_end = en.get_offset();
193 this.view.el.grab_focus();
195 this.buffer.el.place_cursor(st);
196 this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);
200 public string tempFileContents () {
203 if (_this.file == null) {
206 var str= this.buffer.toString();
207 if (_this.file.xtype == "PlainFile") {
215 GLib.debug("calling validate");
216 // clear the buttons.
217 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
218 return this.file.toSource(); ;
221 var oldcode = _this.prop.val;
222 _this.prop.val = str;
223 var ret = _this.file.toSource();
224 _this.prop.val = oldcode;
228 public void reset () {
233 this.searchcontext = null;
236 public int search (string in_txt) {
238 var s = new GtkSource.SearchSettings();
239 s.case_sensitive = _this.case_sensitive.el.active;
240 s.regex_enabled = _this.regex.el.active;
241 s.wrap_around = false;
243 this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);
244 this.searchcontext.set_highlight(true);
247 if (_this.multiline.el.active) {
248 txt = in_txt.replace("\\n", "\n");
251 s.set_search_text(txt);
252 Gtk.TextIter beg, st,en;
254 this.buffer.el.get_start_iter(out beg);
255 bool has_wrapped_around;
256 this.searchcontext.forward(beg, out st, out en, out has_wrapped_around);
257 this.last_search_end = 0;
259 return this.searchcontext.get_occurrences_count();
265 public void updateErrorMarks () {
269 var buf = _this.buffer.el;
272 buf.get_bounds (out start, out end);
277 //GLib.debug("highlight errors");
279 // we should highlight other types of errors..
281 if (_this.window.windowstate.state != WindowState.State.CODEONLY
283 _this.window.windowstate.state != WindowState.State.CODE
285 //GLib.debug("windowstate != CODEONLY?");
291 if (_this.file == null) {
292 GLib.debug("file is null?");
296 var ar = this.file.getErrors();
298 buf.remove_source_marks (start, end, "ERR");
299 buf.remove_source_marks (start, end, "WARN");
300 buf.remove_source_marks (start, end, "DEPR");
301 buf.remove_tag_by_name ("ERR", start, end);
302 buf.remove_tag_by_name ("WARN", start, end);
303 buf.remove_tag_by_name ("DEPR", start, end);
304 this.last_error_counter = file.error_counter ;
305 //GLib.debug("highlight %s : %s has no errors", this.file.relpath, category);
310 // basicaly check if there is no change, then we do not do any update..
311 // we can do this by just using an error counter?
312 // if that's changed then we will do an update, otherwise dont bother.
318 var tlines = buf.get_line_count () +1;
320 if (_this.prop != null) {
321 // this still seems flaky...
323 tlines = _this.prop.end_line;
324 offset = _this.prop.start_line;
325 hoffset = _this.node.node_pad.length + 2; //shift it left by 2 ? ..
330 if (this.last_error_counter == file.error_counter) {
336 buf.remove_source_marks (start, end, "ERR");
337 buf.remove_source_marks (start, end, "WARN");
338 buf.remove_source_marks (start, end, "DEPR");
339 buf.remove_tag_by_name ("ERR", start, end);
340 buf.remove_tag_by_name ("WARN", start, end);
341 buf.remove_tag_by_name ("DEPR", start, end);
343 foreach(var diag in ar) {
345 // print("get inter\n");
346 var eline = (int)diag.range.start.line - offset;
347 var eline_to = (int)diag.range.end.line - offset;
348 //var eline = diag.range.end_line - offset;
349 //GLib.debug("GOT ERROR on line %d -- converted to %d (offset = %d)",
350 // err.line ,eline, offset);
353 if (eline > tlines || eline < 0) {
357 buf.get_iter_at_line( out iter, eline);
358 var msg = "Line: %d %s : %s".printf(eline+1, diag.category, diag.message);
359 buf.create_source_mark( msg, diag.category, iter);
361 var spos = (int)diag.range.start.character - hoffset;
362 if (spos < 0) { spos =0 ; }
363 if (spos > iter.get_chars_in_line()) {
364 spos = iter.get_chars_in_line();
366 buf.get_iter_at_line( out iter, eline_to);
367 var epos = (int)diag.range.end.character - hoffset;
368 if (epos < 0) { epos =0 ; }
369 if (epos > iter.get_chars_in_line()) {
370 epos = iter.get_chars_in_line();
374 buf.get_iter_at_line_offset( out start, eline, spos);
376 buf.get_iter_at_line_offset( out end, eline_to,epos);
378 buf.apply_tag_by_name(diag.category, start, end);
380 // GLib.debug("set line %d to %s", eline, msg);
381 //this.marks.set(eline, msg);
383 this.last_error_counter = file.error_counter ;
390 public void scroll_to_line (int line) {
392 GLib.Timeout.add(500, () => {
394 var buf = this.view.el.get_buffer();
396 var sbuf = (GtkSource.Buffer) buf;
400 sbuf.get_iter_at_line(out iter, line);
401 this.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
405 public class Xcls_Paned1 : Object
408 private Editor _this;
414 public Xcls_Paned1(Editor _owner )
417 this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL );
421 // set gobject values
422 this.el.resize_start_child = false;
423 this.el.shrink_end_child = false;
424 this.el.resize_end_child = false;
425 this.el.shrink_start_child = false;
426 var child_1 = new Xcls_Box2( _this );
428 this.el.start_child = child_1.el;
429 new Xcls_navigation_holder( _this );
430 this.el.end_child = _this.navigation_holder.el;
433 // user defined functions
435 public class Xcls_Box2 : Object
438 private Editor _this;
444 public Xcls_Box2(Editor _owner )
447 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
451 // set gobject values
452 this.el.hexpand = true;
453 var child_1 = new Xcls_Box3( _this );
455 this.el.append( child_1.el );
456 new Xcls_RightEditor( _this );
457 this.el.append( _this.RightEditor.el );
458 var child_3 = new Xcls_Box15( _this );
460 this.el.append ( child_3.el );
463 // user defined functions
465 public class Xcls_Box3 : Object
468 private Editor _this;
474 public Xcls_Box3(Editor _owner )
477 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
481 // set gobject values
482 this.el.homogeneous = false;
483 this.el.hexpand = false;
484 this.el.vexpand = false;
485 new Xcls_save_button( _this );
486 this.el.append( _this.save_button.el );
487 new Xcls_helper( _this );
488 this.el.append( _this.helper.el );
489 var child_3 = new Xcls_Scale6( _this );
491 this.el.append( child_3.el );
492 new Xcls_close_btn( _this );
493 this.el.append( _this.close_btn.el );
496 // user defined functions
498 public class Xcls_save_button : Object
500 public Gtk.Button el;
501 private Editor _this;
507 public Xcls_save_button(Editor _owner )
510 _this.save_button = this;
511 this.el = new Gtk.Button();
515 // set gobject values
516 this.el.vexpand = true;
517 this.el.label = "Save";
520 this.el.clicked.connect( () => {
521 _this.saveContents();
525 // user defined functions
528 public class Xcls_helper : Object
531 private Editor _this;
537 public Xcls_helper(Editor _owner )
541 this.el = new Gtk.Label( null );
545 // set gobject values
546 this.el.margin_end = 4;
547 this.el.margin_start = 4;
548 this.el.justify = Gtk.Justification.LEFT;
549 this.el.hexpand = true;
553 // user defined functions
554 public void setHelp (Lsp.Hover? help) {
555 if (help == null || help.contents == null
556 || help.contents.size < 1) {
557 this.el.set_text("");
560 var sig = help.contents.get(0).value.split(" ");
562 for(var i =0; i < sig.length; i++) {
581 str += ("<span underline=\"single\" color=\"blue\" >" +
582 GLib.Markup.escape_text(sig[i])
587 if (help.contents.size > 1) {
588 sig += ("\n\n" + help.contents[1].value);
591 this.el.set_markup(string.joinv(" ",str));
596 public class Xcls_Scale6 : Object
599 private Editor _this;
605 public Xcls_Scale6(Editor _owner )
608 this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1);
612 // set gobject values
613 this.el.width_request = 150;
614 this.el.has_origin = true;
615 this.el.halign = Gtk.Align.END;
616 this.el.draw_value = false;
618 this.el.sensitive = true;
623 //this.el.set_range(6,30);
624 this.el.set_value ( BuilderApplication.settings.editor_font_size);
625 BuilderApplication.settings.editor_font_size_updated.connect(
627 BuilderApplication.settings.editor_font_size_inchange = true;
628 // GLib.debug("update range");
629 this.el.set_value (BuilderApplication.settings.editor_font_size);
630 BuilderApplication.settings.editor_font_size_inchange = false;
638 this.el.change_value.connect( (st, val ) => {
639 if (BuilderApplication.settings.editor_font_size_inchange) {
642 BuilderApplication.settings.editor_font_size = val;
647 // user defined functions
650 public class Xcls_close_btn : Object
652 public Gtk.Button el;
653 private Editor _this;
659 public Xcls_close_btn(Editor _owner )
662 _this.close_btn = this;
663 this.el = new Gtk.Button();
667 // set gobject values
668 this.el.icon_name = "window-close";
669 this.el.halign = Gtk.Align.END;
670 var child_1 = new Xcls_Image8( _this );
672 this.el.child = child_1.el;
675 this.el.clicked.connect( () => {
676 _this.saveContents();
677 _this.window.windowstate.switchState(WindowState.State.PREVIEW);
681 // user defined functions
683 public class Xcls_Image8 : Object
686 private Editor _this;
692 public Xcls_Image8(Editor _owner )
695 this.el = new Gtk.Image();
699 // set gobject values
700 this.el.icon_name = "window-close";
701 this.el.icon_size = Gtk.IconSize.NORMAL;
704 // user defined functions
709 public class Xcls_RightEditor : Object
711 public Gtk.ScrolledWindow el;
712 private Editor _this;
718 public Xcls_RightEditor(Editor _owner )
721 _this.RightEditor = this;
722 this.el = new Gtk.ScrolledWindow();
726 // set gobject values
727 this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
728 this.el.vexpand = true;
729 this.el.overlay_scrolling = false;
730 this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
731 new Xcls_view( _this );
732 this.el.child = _this.view.el;
735 // user defined functions
737 public class Xcls_view : Object
739 public GtkSource.View el;
740 private Editor _this;
744 public Gtk.CssProvider css;
747 public Xcls_view(Editor _owner )
751 this.el = new GtkSource.View();
756 // set gobject values
757 this.el.auto_indent = true;
758 this.el.indent_width = 4;
759 this.el.name = "editor-view";
760 this.el.show_line_marks = true;
761 this.el.insert_spaces_instead_of_tabs = true;
762 this.el.show_line_numbers = true;
763 this.el.hexpand = true;
764 this.el.vexpand = true;
765 this.el.has_tooltip = true;
766 this.el.css_classes = { "code-editor" };
767 this.el.tab_width = 4;
768 this.el.highlight_current_line = true;
769 new Xcls_buffer( _this );
770 this.el.buffer = _this.buffer.el;
771 new Xcls_keystate( _this );
772 this.el.add_controller( _this.keystate.el );
773 var child_3 = new Xcls_EventControllerScroll13( _this );
775 this.el.add_controller( child_3.el );
776 var child_4 = new Xcls_GestureClick14( _this );
778 this.el.add_controller( child_4.el );
782 this.el.completion.add_provider(
783 new Palete.CompletionProvider(_this)
786 // hover seems pretty useless.. - ??
787 //var hover = this.el.get_hover();
788 //hover.add_provider(new Palete.HoverProvider(_this));
790 //this.el.completion.unblock_interactive();
791 this.el.completion.select_on_show = true; // select
792 //this.el.completion.remember_info_visibility = true;
795 var attrs = new GtkSource.MarkAttributes();
797 attrs.set_icon_name ( "process-stop");
798 attrs.query_tooltip_text.connect(( mark) => {
799 GLib.debug("tooltip query? %s", mark.name);
800 return strdup( mark.name);
802 attrs.query_tooltip_markup.connect(( mark) => {
803 GLib.debug("tooltip query? %s", mark.name);
804 return strdup( mark.name);
806 this.el.set_mark_attributes ("ERR", attrs, 1);
810 var wattrs = new GtkSource.MarkAttributes();
811 wattrs.set_icon_name ( "process-stop");
812 wattrs.query_tooltip_text.connect(( mark) => {
813 GLib.debug("tooltip query? %s", mark.name);
814 return strdup(mark.name);
816 wattrs.query_tooltip_markup.connect(( mark) => {
817 GLib.debug("tooltip query? %s", mark.name);
818 return strdup(mark.name);
820 this.el.set_mark_attributes ("WARN", wattrs, 1);
824 var dattrs = new GtkSource.MarkAttributes();
826 dattrs.set_icon_name ( "process-stop");
828 dattrs.query_tooltip_text.connect(( mark) => {
829 GLib.debug("tooltip query? %s", mark.name);
830 return strdup(mark.name);
832 //dattrs.query_tooltip_markup.connect(( mark) => {
833 // GLib.debug("tooltip query? %s", mark.name);
834 // return strdup(mark.name);
836 this.el.set_mark_attributes ("DEPR", dattrs, 1);
839 this.el.get_space_drawer().set_matrix(null);
840 this.el.get_space_drawer().set_types_for_locations(
841 GtkSource.SpaceLocationFlags.ALL,
842 GtkSource.SpaceTypeFlags.ALL
844 this.el.get_space_drawer().set_enable_matrix(true);
847 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
849 //GLib.debug("query tooltip");
853 var yoff = (int) _this.RightEditor.el.vadjustment.value;
855 // I think this is problematic - if it's compliing / updating at same time as query.
857 //if (_this.window.statusbar_compile_spinner.el.spinning) {
861 this.el.get_iter_at_position (out iter, out trailing, x, y + yoff);
863 var l = iter.get_line();
867 // GLib.debug("query tooltip line %d", (int) l);
873 if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {
874 GLib.debug("line %d setting tip to %s", l, _this.buffer.marks.get(l));
875 tooltip.set_text(_this.buffer.marks.get(l).dup());
883 // this crashes?? - not sure why.
884 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
885 if (marks.is_empty()) {
886 marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
888 if (marks.is_empty()) {
889 marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
892 // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length());
894 marks.@foreach((m) => {
895 //GLib.debug("got mark %s", m.name);
896 str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name;
898 // true if there is a mark..
899 if (str.length > 0 ) {
900 tooltip.set_text( str );
902 return str.length > 0 ? true : false;
907 // user defined functions
908 public void load (string str) {
910 // show the help page for the active node..
911 //this.get('/Help').show();
913 // this.get('/BottomPane').el.set_current_page(0);
914 GLib.debug("load called - Reset undo buffer");
916 var buf = (GtkSource.Buffer)this.el.get_buffer();
917 buf.begin_irreversible_action();
918 buf.set_text(str, str.length);
919 buf.end_irreversible_action();
921 var lm = GtkSource.LanguageManager.get_default();
923 if (_this.file != null) {
924 lang = _this.file.language;
926 print("lang=%s, content_type = %s\n", lang, _this.file.content_type);
927 var lg = _this.file.content_type.length > 0 ?
928 lm.guess_language(_this.file.path, _this.file.content_type) :
929 lm.get_language(lang);
932 ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg);
934 this.el.insert_spaces_instead_of_tabs = true;
936 print("sourcelanguage = %s\n", lg.name);
937 if (lg.name == "Vala") {
938 this.el.insert_spaces_instead_of_tabs = false;
942 this.el.grab_focus();
943 _this.save_button.el.sensitive = false;
944 _this.last_error_counter = -1;
947 public class Xcls_buffer : Object
949 public GtkSource.Buffer el;
950 private Editor _this;
954 public int error_line;
955 public Gee.HashMap<int,string>? xmarks;
956 public bool check_queued;
959 public Xcls_buffer(Editor _owner )
963 this.el = new GtkSource.Buffer( null );
966 this.error_line = -1;
968 this.check_queued = false;
970 // set gobject values
971 this.el.highlight_syntax = true;
972 this.el.highlight_matching_brackets = true;
973 this.el.enable_undo = true;
978 buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
979 buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
980 buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
981 buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
982 buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
983 buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
984 buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
985 buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
988 buf.create_tag ("ERR", "weight", Pango.Weight.BOLD, "background", "pink");
989 buf.create_tag ("WARN", "weight", Pango.Weight.BOLD, "background", "#ABF4EB");
990 buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
993 this.el.cursor_moved.connect( ( ) => {
996 this.el.get_iter_at_offset (
997 out iter, this.el.cursor_position);
999 _this.navigation.updateSelectedLine(
1000 (uint)iter.get_line(),
1001 (uint)iter.get_line_offset()
1003 this.showHelp(iter);
1006 this.el.changed.connect( () => {
1009 _this.save_button.el.sensitive = true;
1010 print("EDITOR CHANGED");
1015 // this.get('/LeftPanel.model').changed( str , false);
1020 // user defined functions
1021 public bool OLDhighlightErrorsJson (string type, Json.Object obj) {
1024 this.el.get_bounds (out start, out end);
1026 this.el.remove_source_marks (start, end, type);
1027 GLib.debug("highlight errors");
1029 // we should highlight other types of errors..
1031 if (!obj.has_member(type)) {
1032 GLib.debug("Return has no errors\n");
1036 if (_this.window.windowstate.state != WindowState.State.CODEONLY
1038 _this.window.windowstate.state != WindowState.State.CODE
1040 GLib.debug("windowstate != CODEONLY?");
1045 //this.marks = new Gee.HashMap<int,string>();
1046 var err = obj.get_object_member(type);
1048 if (_this.file == null) {
1049 GLib.debug("file is null?");
1053 var valafn = _this.file.path;
1055 if (_this.file.xtype != "PlainFile") {
1059 var regex = new Regex("\\.bjs$");
1060 // should not happen
1061 valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
1062 } catch (GLib.RegexError e) {
1069 if (!err.has_member(valafn)) {
1070 GLib.debug("File path has no errors");
1074 var lines = err.get_object_member(valafn);
1077 if (obj.has_member("line_offset")) { // ?? why??
1078 offset = (int)obj.get_int_member("line_offset") + 1;
1082 var tlines = this.el.get_line_count () +1;
1084 if (_this.prop != null) {
1086 tlines = _this.prop.end_line + 1;
1087 offset = _this.prop.start_line + 1;
1093 lines.foreach_member((obj, line, node) => {
1096 // print("get inter\n");
1097 var eline = int.parse(line) - offset;
1098 GLib.debug("GOT ERROR on line %s -- converted to %d (offset = %d)\n", line,eline, offset);
1101 if (eline > tlines || eline < 0) {
1106 this.el.get_iter_at_line( out iter, eline);
1107 //print("mark line\n");
1109 var ar = lines.get_array_member(line);
1110 for (var i = 0 ; i < ar.get_length(); i++) {
1111 if (ar.get_string_element(i) == "Success") {
1114 msg += (msg.length > 0) ? "\n" : "";
1115 msg += ar.get_string_element(i);
1120 msg = "Line: %d".printf(eline+1) + " " + msg;
1121 this.el.create_source_mark(msg, type, iter);
1122 GLib.debug("set line %d to %m", eline, msg);
1123 // this.marks.set(eline, msg);
1132 public bool checkSyntax () {
1135 var str = this.toString();
1138 if (this.error_line > 0) {
1141 this.el.get_bounds (out start, out end);
1143 this.el.remove_source_marks (start, end, null);
1145 if (str.length < 1) {
1146 print("checkSyntax - empty string?\n");
1151 if (_this.file.xtype == "PlainFile") {
1153 // assume it's gtk...
1154 var oldcode =_this.file.toSource();
1155 _this.file.setSource(str);
1156 BuilderApplication.showSpinner("appointment soon","document change pending");
1157 _this.file.getLanguageServer().document_change(_this.file);
1158 _this.file.getLanguageServer().queueDocumentSymbols(_this.file);
1159 _this.file.setSource(oldcode);
1165 if (_this.file == null) {
1173 GLib.debug("calling validate");
1174 // clear the buttons.
1175 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
1178 var oldcode = _this.prop.val;
1180 _this.prop.val = str;
1181 _this.node.updated_count++;
1182 _this.file.getLanguageServer().document_change(_this.file);
1183 _this.node.updated_count++;
1184 _this.prop.val = oldcode;
1187 //print("done mark line\n");
1189 return true; // at present allow saving - even if it's invalid..
1191 public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
1193 this.error_line = validate_res.size;
1195 if (this.error_line < 1) {
1198 var tlines = this.el.get_line_count ();
1200 var valiter = validate_res.map_iterator();
1201 while (valiter.next()) {
1203 // print("get inter\n");
1204 var eline = valiter.get_key();
1205 if (eline > tlines) {
1208 this.el.get_iter_at_line( out iter, eline);
1209 //print("mark line\n");
1210 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
1214 public string toString () {
1218 this.el.get_start_iter(out s);
1219 this.el.get_end_iter(out e);
1220 var ret = this.el.get_text(s,e,true);
1221 //print("TO STRING? " + ret);
1224 public void showHelp (Gtk.TextIter iter) {
1225 var back = iter.copy();
1226 back.backward_char();
1228 var forward = iter.copy();
1229 forward.forward_char();
1231 // what's the character at the iter?
1232 var str = back.get_text(iter);
1233 str += iter.get_text(forward);
1234 if (str.strip().length < 1) {
1237 var offset = iter.get_line_offset();
1238 var line = iter.get_line();
1239 if (_this.prop != null) {
1241 line += _this.prop.start_line ;
1242 // this is based on Gtk using tabs (hence 1/2 chars);
1243 offset += _this.node.node_pad.length;
1244 // javascript listeners are indented 2 more spaces.
1245 if (_this.prop.ptype == JsRender.NodePropType.LISTENER) {
1250 var ls = _this.file.getLanguageServer();
1252 _this.file, line, offset,
1255 var res = ls.hover.end(o );
1257 _this.helper.setHelp(res);
1258 } catch (GLib.Error e) {
1265 public class Xcls_keystate : Object
1267 public Gtk.EventControllerKey el;
1268 private Editor _this;
1272 public bool is_control;
1275 public Xcls_keystate(Editor _owner )
1278 _this.keystate = this;
1279 this.el = new Gtk.EventControllerKey();
1282 this.is_control = false;
1284 // set gobject values
1287 this.el.key_released.connect( (keyval, keycode, state) => {
1289 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1290 this.is_control = false;
1292 if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1293 GLib.debug("SAVE: ctrl-S pressed");
1294 _this.saveContents();
1298 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1299 GLib.debug("SAVE: ctrl-g pressed");
1300 _this.forwardSearch(true);
1303 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1304 GLib.debug("SAVE: ctrl-f pressed");
1305 _this.search_entry.el.grab_focus();
1306 _this.search_entry.el.select_region(0,-1);
1309 if (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1310 _this.view.el.show_completion();
1314 _this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);
1315 var line = iter.get_line();
1316 var offset = iter.get_line_offset();
1317 GLib.debug("line %d off %d", line ,offset);
1318 if (_this.prop != null) {
1319 line += _this.prop.start_line + 1; // i think..
1320 offset += 12; // should probably be 8 without namespaced
1321 GLib.debug("guess line %d off %d", line ,offset);
1323 //_this.view.el.show_completion();
1324 // print(event.key.keyval)
1331 this.el.key_pressed.connect( (keyval, keycode, state) => {
1333 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1334 this.is_control = true;
1340 // user defined functions
1343 public class Xcls_EventControllerScroll13 : Object
1345 public Gtk.EventControllerScroll el;
1346 private Editor _this;
1350 public double distance;
1353 public Xcls_EventControllerScroll13(Editor _owner )
1356 this.el = new Gtk.EventControllerScroll( Gtk.EventControllerScrollFlags.VERTICAL );
1359 this.distance = 0.0f;
1361 // set gobject values
1364 this.el.scroll.connect( (dx, dy) => {
1365 if (!_this.keystate.is_control) {
1368 //GLib.debug("scroll %f", dy);
1370 this.distance += dy;
1372 //GLib.debug("scroll %f / %f", dy, this.distance);
1374 if (this.distance < -1) {
1376 BuilderApplication.settings.editor_font_size ++;
1379 if (this.distance > 1) {
1380 BuilderApplication.settings.editor_font_size --;
1388 // user defined functions
1391 public class Xcls_GestureClick14 : Object
1393 public Gtk.GestureClick el;
1394 private Editor _this;
1400 public Xcls_GestureClick14(Editor _owner )
1403 this.el = new Gtk.GestureClick();
1407 // set gobject values
1410 this.el.pressed.connect( (n_press, x, y) => {
1412 int buffer_x, buffer_y;
1413 var gut = _this.view.el.get_gutter(Gtk.TextWindowType.LEFT);
1415 _this.view.el.window_to_buffer_coords (Gtk.TextWindowType.TEXT,
1416 (int)x - gut.get_width(), (int)y,
1417 out buffer_x, out buffer_y);
1418 _this.view.el.get_iter_at_location (out iter,
1419 buffer_x, buffer_y);;
1422 if (_this.buffer.el.iter_has_context_class(iter, "comment") ||
1423 _this.buffer.el.iter_has_context_class(iter, "string")
1427 _this.buffer.showHelp(iter);
1434 // user defined functions
1439 public class Xcls_Box15 : Object
1442 private Editor _this;
1448 public Xcls_Box15(Editor _owner )
1451 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1455 // set gobject values
1456 this.el.homogeneous = false;
1457 this.el.vexpand = false;
1458 new Xcls_search_entry( _this );
1459 this.el.append( _this.search_entry.el );
1460 new Xcls_search_results( _this );
1461 this.el.append( _this.search_results.el );
1462 new Xcls_nextBtn( _this );
1463 this.el.append( _this.nextBtn.el );
1464 new Xcls_backBtn( _this );
1465 this.el.append( _this.backBtn.el );
1466 var child_5 = new Xcls_MenuButton21( _this );
1468 this.el.append( child_5.el );
1471 // user defined functions
1473 public class Xcls_search_entry : Object
1475 public Gtk.SearchEntry el;
1476 private Editor _this;
1480 public Gtk.CssProvider css;
1483 public Xcls_search_entry(Editor _owner )
1486 _this.search_entry = this;
1487 this.el = new Gtk.SearchEntry();
1491 // set gobject values
1492 this.el.name = "editor-search-entry";
1493 this.el.hexpand = true;
1494 this.el.placeholder_text = "Press enter to search";
1495 this.el.search_delay = 3;
1496 var child_1 = new Xcls_EventControllerKey17( _this );
1498 this.el.add_controller( child_1.el );
1501 this.el.search_changed.connect( ( ) => {
1503 _this.search(_this.search_entry.el.text);
1504 _this.search_results.updateResults();
1506 GLib.Timeout.add_seconds(1,() => {
1507 _this.search_results.updateResults();
1513 // user defined functions
1514 public void forwardSearch (bool change_focus) {
1517 _this.forwardSearch(change_focus);
1521 switch(_this.windowstate.state) {
1522 case WindowState.State.CODEONLY:
1523 //case WindowState.State.CODE:
1524 // search the code being edited..
1525 _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1528 case WindowState.State.PREVIEW:
1529 if (_this.windowstate.file.xtype == "Gtk") {
1530 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1532 _this.windowstate.window_rooview.forwardSearch(change_focus);
1541 public class Xcls_EventControllerKey17 : Object
1543 public Gtk.EventControllerKey el;
1544 private Editor _this;
1550 public Xcls_EventControllerKey17(Editor _owner )
1553 this.el = new Gtk.EventControllerKey();
1557 // set gobject values
1560 this.el.key_pressed.connect( (keyval, keycode, state) => {
1562 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1563 GLib.debug("SAVE: ctrl-g pressed");
1564 _this.forwardSearch(true);
1569 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1570 _this.forwardSearch(true);
1576 // print(event.key.keyval)
1582 // user defined functions
1586 public class Xcls_search_results : Object
1588 public Gtk.Label el;
1589 private Editor _this;
1595 public Xcls_search_results(Editor _owner )
1598 _this.search_results = this;
1599 this.el = new Gtk.Label( "No Results" );
1603 // set gobject values
1604 this.el.margin_end = 4;
1605 this.el.margin_start = 4;
1608 // user defined functions
1609 public void updateResults () {
1610 this.el.visible = true;
1612 var res = _this.searchcontext.get_occurrences_count();
1614 _this.search_results.el.label = "??? Matches";
1618 _this.nextBtn.el.sensitive = false;
1619 _this.backBtn.el.sensitive = false;
1622 _this.search_results.el.label = "%d Matches".printf(res);
1623 _this.nextBtn.el.sensitive = true;
1624 _this.backBtn.el.sensitive = true;
1627 _this.search_results.el.label = "No Matches";
1632 public class Xcls_nextBtn : Object
1634 public Gtk.Button el;
1635 private Editor _this;
1639 public bool always_show_image;
1642 public Xcls_nextBtn(Editor _owner )
1645 _this.nextBtn = this;
1646 this.el = new Gtk.Button();
1649 this.always_show_image = true;
1651 // set gobject values
1652 this.el.icon_name = "go-down";
1653 this.el.sensitive = false;
1656 this.el.clicked.connect( (event) => {
1658 _this.forwardSearch(true);
1664 // user defined functions
1667 public class Xcls_backBtn : Object
1669 public Gtk.Button el;
1670 private Editor _this;
1674 public bool always_show_image;
1677 public Xcls_backBtn(Editor _owner )
1680 _this.backBtn = this;
1681 this.el = new Gtk.Button();
1684 this.always_show_image = true;
1686 // set gobject values
1687 this.el.icon_name = "go-up";
1688 this.el.sensitive = false;
1691 this.el.clicked.connect( (event) => {
1693 _this.backSearch(true);
1698 // user defined functions
1701 public class Xcls_MenuButton21 : Object
1703 public Gtk.MenuButton el;
1704 private Editor _this;
1708 public bool always_show_image;
1711 public Xcls_MenuButton21(Editor _owner )
1714 this.el = new Gtk.MenuButton();
1717 this.always_show_image = true;
1719 // set gobject values
1720 this.el.icon_name = "emblem-system";
1721 this.el.always_show_arrow = true;
1722 new Xcls_search_settings( _this );
1723 this.el.popover = _this.search_settings.el;
1726 // user defined functions
1728 public class Xcls_search_settings : Object
1730 public Gtk.Popover el;
1731 private Editor _this;
1737 public Xcls_search_settings(Editor _owner )
1740 _this.search_settings = this;
1741 this.el = new Gtk.Popover();
1745 // set gobject values
1746 var child_1 = new Xcls_Box23( _this );
1748 this.el.child = child_1.el;
1751 // user defined functions
1753 public class Xcls_Box23 : Object
1756 private Editor _this;
1762 public Xcls_Box23(Editor _owner )
1765 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1769 // set gobject values
1770 new Xcls_case_sensitive( _this );
1771 this.el.append( _this.case_sensitive.el );
1772 new Xcls_regex( _this );
1773 this.el.append( _this.regex.el );
1774 new Xcls_multiline( _this );
1775 this.el.append( _this.multiline.el );
1778 // user defined functions
1780 public class Xcls_case_sensitive : Object
1782 public Gtk.CheckButton el;
1783 private Editor _this;
1789 public Xcls_case_sensitive(Editor _owner )
1792 _this.case_sensitive = this;
1793 this.el = new Gtk.CheckButton();
1797 // set gobject values
1798 this.el.label = "Case Sensitive";
1807 // user defined functions
1810 public class Xcls_regex : Object
1812 public Gtk.CheckButton el;
1813 private Editor _this;
1819 public Xcls_regex(Editor _owner )
1823 this.el = new Gtk.CheckButton();
1827 // set gobject values
1828 this.el.label = "Regex";
1837 // user defined functions
1840 public class Xcls_multiline : Object
1842 public Gtk.CheckButton el;
1843 private Editor _this;
1849 public Xcls_multiline(Editor _owner )
1852 _this.multiline = this;
1853 this.el = new Gtk.CheckButton();
1857 // set gobject values
1858 this.el.label = "Multi-line (add \\n)";
1861 // user defined functions
1869 public class Xcls_navigation_holder : Object
1872 private Editor _this;
1878 public Xcls_navigation_holder(Editor _owner )
1881 _this.navigation_holder = this;
1882 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1886 // set gobject values
1887 this.el.width_request = 120;
1888 this.el.hexpand = true;
1889 this.el.vexpand = true;
1890 this.el.visible = false;
1891 var child_1 = new Xcls_Box28( _this );
1893 this.el.append( child_1.el );
1894 new Xcls_navigationwindow( _this );
1895 this.el.append( _this.navigationwindow.el );
1898 // user defined functions
1900 public class Xcls_Box28 : Object
1903 private Editor _this;
1909 public Xcls_Box28(Editor _owner )
1912 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1916 // set gobject values
1919 // user defined functions
1922 public class Xcls_navigationwindow : Object
1924 public Gtk.ScrolledWindow el;
1925 private Editor _this;
1931 public Xcls_navigationwindow(Editor _owner )
1934 _this.navigationwindow = this;
1935 this.el = new Gtk.ScrolledWindow();
1939 // set gobject values
1940 this.el.hexpand = true;
1941 this.el.vexpand = true;
1942 this.el.visible = true;
1943 new Xcls_navigation( _this );
1944 this.el.child = _this.navigation.el;
1947 // user defined functions
1949 public class Xcls_navigation : Object
1951 public Gtk.ColumnView el;
1952 private Editor _this;
1956 public int last_selected_line;
1957 public Gtk.Widget? selected_row;
1960 public Xcls_navigation(Editor _owner )
1963 _this.navigation = this;
1964 new Xcls_navigationselmodel( _this );
1965 this.el = new Gtk.ColumnView( _this.navigationselmodel.el );
1968 this.last_selected_line = -1;
1969 this.selected_row = null;
1971 // set gobject values
1972 this.el.name = "editor-navigation";
1973 var child_2 = new Xcls_ColumnViewColumn31( _this );
1975 this.el.append_column( child_2.el );
1976 var child_3 = new Xcls_GestureClick40( _this );
1978 this.el.add_controller( child_3.el );
1981 // user defined functions
1982 public Gtk.Widget? getRowWidgetAt (double x, double y, out string pos) {
1985 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
1986 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
1991 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
1996 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2000 //GLib.debug("row number is %d", rn);
2001 //GLib.debug("click %d, %d", (int)x, (int)y);
2003 Graphene.Rect bounds;
2004 row.compute_bounds(this.el, out bounds);
2005 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2006 // (int)bounds.get_x(), (int)bounds.get_y(),
2007 // (int)bounds.get_width(), (int)bounds.get_height()
2009 var ypos = y - bounds.get_y();
2010 //GLib.debug("rel ypos = %d", (int)ypos);
2011 var rpos = 100.0 * (ypos / bounds.get_height());
2012 //GLib.debug("rel pos = %d %%", (int)rpos);
2017 } else if (rpos < 20) {
2022 public void show (Gee.ArrayList<Lsp.DocumentSymbol> syms) {
2023 _this.navigation_holder.el.show();
2025 //_this.navliststore.el.remove_all();
2028 var ls = new GLib.ListStore(typeof(Lsp.DocumentSymbol));
2030 foreach(var sym in syms) {
2033 Lsp.DocumentSymbol.copyList(ls, _this.navliststore.el);
2034 //_this.navliststore.el.append(sym);
2035 this.last_selected_line = -1;
2036 GLib.Idle.add(() => {
2037 _this.navigationsort.collapseOnLoad();
2039 _this.buffer.el.get_iter_at_offset (
2040 out iter, _this.buffer.el.cursor_position);
2042 GLib.debug("idle update scroll %d, %d", iter.get_line(),
2043 iter.get_line_offset());
2044 this.updateSelectedLine(
2045 (uint)iter.get_line(),
2046 (uint)iter.get_line_offset()
2052 public int getRowAt (double x, double y, out string pos) {
2055 var w = this.el.pick(x, y, Gtk.PickFlags.DEFAULT);
2056 //GLib.debug("got widget %s", w == null ? "nothing" : w.get_type().name());
2061 var row= w.get_ancestor(GLib.Type.from_name("GtkColumnViewRowWidget"));
2066 //GLib.debug("got colview %s", row == null ? "nothing" : row.get_type().name());
2071 while (cr.get_prev_sibling() != null) {
2073 cr = cr.get_prev_sibling();
2076 //GLib.debug("row number is %d", rn);
2077 //GLib.debug("click %d, %d", (int)x, (int)y);
2079 Graphene.Rect bounds;
2080 row.compute_bounds(this.el, out bounds);
2081 //GLib.debug("click x=%d, y=%d, w=%d, h=%d",
2082 // (int)bounds.get_x(), (int)bounds.get_y(),
2083 // (int)bounds.get_width(), (int)bounds.get_height()
2085 var ypos = y - bounds.get_y();
2086 //GLib.debug("rel ypos = %d", (int)ypos);
2087 var rpos = 100.0 * (ypos / bounds.get_height());
2088 //GLib.debug("rel pos = %d %%", (int)rpos);
2093 } else if (rpos < 20) {
2098 public void updateSelectedLine (uint line, uint chr) {
2099 if (line == this.last_selected_line) {
2102 GLib.debug("select line %d", (int)line);
2103 this.last_selected_line = (int)line;
2107 var sym = _this.navliststore.symbolAtLine(line, chr);
2109 new_row = _this.navigationsort.getRowFromSymbol(sym);
2110 GLib.debug("select line %d - row found %d", (int)line, new_row);
2112 GLib.debug(" no symbol found at line %d", (int)line);
2115 if (this.selected_row != null) {
2116 GLib.debug(" remove selected row");
2117 this.selected_row.remove_css_class("selected-row");
2119 this.selected_row = null;
2121 this.el.scroll_to(new_row,null,Gtk.ListScrollFlags.NONE, null);
2122 var row = sym.get_data<Gtk.Widget>("widget");
2124 GLib.debug(" Add selected row");
2126 row.add_css_class("selected-row");
2127 this.selected_row = row;
2131 GLib.debug("could not find widget on row %d", new_row);
2139 public class Xcls_ColumnViewColumn31 : Object
2141 public Gtk.ColumnViewColumn el;
2142 private Editor _this;
2148 public Xcls_ColumnViewColumn31(Editor _owner )
2151 var child_1 = new Xcls_SignalListItemFactory32( _this );
2153 this.el = new Gtk.ColumnViewColumn( "Code Navigation", child_1.el );
2157 // set gobject values
2158 this.el.expand = true;
2161 // user defined functions
2163 public class Xcls_SignalListItemFactory32 : Object
2165 public Gtk.SignalListItemFactory el;
2166 private Editor _this;
2172 public Xcls_SignalListItemFactory32(Editor _owner )
2175 this.el = new Gtk.SignalListItemFactory();
2179 // set gobject values
2182 this.el.setup.connect( (listitem) => {
2184 var expand = new Gtk.TreeExpander();
2186 expand.set_indent_for_depth(true);
2187 expand.set_indent_for_icon(true);
2188 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
2189 var icon = new Gtk.Image();
2190 var lbl = new Gtk.Label("");
2191 lbl.use_markup = true;
2192 lbl.ellipsize = Pango.EllipsizeMode.END;
2194 icon.margin_end = 4;
2195 lbl.justify = Gtk.Justification.LEFT;
2198 // listitem.activatable = true; ??
2202 expand.set_child(hbox);
2203 ((Gtk.ListItem)listitem).set_child(expand);
2206 this.el.bind.connect( (listitem) => {
2208 // GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name());
2210 //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2211 var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
2214 var hbox = (Gtk.Box) expand.child;
2217 var img = (Gtk.Image) hbox.get_first_child();
2218 var lbl = (Gtk.Label) img.get_next_sibling();
2220 var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();
2221 var sym = (Lsp.DocumentSymbol) lr.get_item();
2223 sym.set_data<Gtk.Widget>("widget", expand.get_parent());
2224 expand.get_parent().get_parent().set_data<Lsp.DocumentSymbol>("symbol", sym);
2226 //GLib.debug("save sym on %s", expand.get_parent().get_parent().get_type().name());
2228 //GLib.debug("got %d children for %s" , (int)sym.children.get_n_items(), sym.name);
2230 expand.set_hide_expander( sym.children.get_n_items() < 1);
2231 expand.set_list_row(lr);
2232 //this.in_bind = true;
2233 // default is to expand
2235 //this.in_bind = false;
2237 sym.bind_property("symbol_icon",
2239 GLib.BindingFlags.SYNC_CREATE);
2241 hbox.css_classes = { sym.symbol_icon };
2243 sym.bind_property("name",
2245 GLib.BindingFlags.SYNC_CREATE);
2246 // should be better?- --line no?
2247 sym.bind_property("tooltip",
2248 lbl, "tooltip_markup",
2249 GLib.BindingFlags.SYNC_CREATE);
2255 // user defined functions
2259 public class Xcls_navigationselmodel : Object
2261 public Gtk.NoSelection el;
2262 private Editor _this;
2268 public Xcls_navigationselmodel(Editor _owner )
2271 _this.navigationselmodel = this;
2272 new Xcls_navigationsort( _this );
2273 this.el = new Gtk.NoSelection( _this.navigationsort.el );
2277 // set gobject values
2280 // user defined functions
2282 public class Xcls_navigationsort : Object
2284 public Gtk.SortListModel el;
2285 private Editor _this;
2291 public Xcls_navigationsort(Editor _owner )
2294 _this.navigationsort = this;
2295 var child_1 = new Xcls_TreeListModel35( _this );
2297 var child_2 = new Xcls_TreeListRowSorter37( _this );
2299 this.el = new Gtk.SortListModel( child_1.el, child_2.el );
2303 // set gobject values
2306 // user defined functions
2307 public void collapseOnLoad () {
2308 for (var i=0;i < this.el.get_n_items(); i++) {
2309 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2310 var sym = (Lsp.DocumentSymbol)tr.get_item();
2312 case Lsp.SymbolKind.Enum:
2313 tr.expanded = false;
2316 //tr.expanded = true;
2325 public int getRowFromSymbol (Lsp.DocumentSymbol sym) {
2327 for (var i=0;i < this.el.get_n_items(); i++) {
2328 var tr = (Gtk.TreeListRow)this.el.get_item(i);
2330 if (sym.equals( (Lsp.DocumentSymbol)tr.get_item())) {
2336 public Lsp.DocumentSymbol? getSymbolAt (uint row) {
2338 var tr = (Gtk.TreeListRow)this.el.get_item(row);
2340 var a = tr.get_item();;
2341 GLib.debug("get_item (2) = %s", a.get_type().name());
2344 return (Lsp.DocumentSymbol)tr.get_item();
2348 public class Xcls_TreeListModel35 : Object
2350 public Gtk.TreeListModel el;
2351 private Editor _this;
2357 public Xcls_TreeListModel35(Editor _owner )
2360 new Xcls_navliststore( _this );
2361 this.el = new Gtk.TreeListModel( _this.navliststore.el, false, true, (item) => {
2363 return ((Lsp.DocumentSymbol)item).children;
2369 // set gobject values
2372 this.el.items_changed.connect( (position, removed, added) => {
2373 GLib.debug("tree item changed %d , %d , %d",(int) position, (int)removed, (int) added);
2377 //var sym = (Lsp.DocumentSymbol) this.el.get_item(position);
2378 var row = this.el.get_row(position);
2380 GLib.debug("got %s", row.get_item().get_type().name());
2386 // user defined functions
2388 public class Xcls_navliststore : Object
2390 public GLib.ListStore el;
2391 private Editor _this;
2397 public Xcls_navliststore(Editor _owner )
2400 _this.navliststore = this;
2401 this.el = new GLib.ListStore( typeof(Lsp.DocumentSymbol) );
2405 // set gobject values
2408 // user defined functions
2409 public Lsp.DocumentSymbol? symbolAtLine (uint line, uint chr) {
2412 for(var i = 0; i < this.el.get_n_items();i++) {
2413 var el = (Lsp.DocumentSymbol)this.el.get_item(i);
2414 //GLib.debug("Check sym %s : %d-%d",
2415 // el.name , (int)el.range.start.line,
2416 // (int)el.range.end.line
2418 var ret = el.containsLine(line,chr);
2430 public class Xcls_TreeListRowSorter37 : Object
2432 public Gtk.TreeListRowSorter el;
2433 private Editor _this;
2439 public Xcls_TreeListRowSorter37(Editor _owner )
2442 var child_1 = new Xcls_StringSorter38( _this );
2444 this.el = new Gtk.TreeListRowSorter( child_1.el );
2448 // set gobject values
2451 // user defined functions
2453 public class Xcls_StringSorter38 : Object
2455 public Gtk.StringSorter el;
2456 private Editor _this;
2462 public Xcls_StringSorter38(Editor _owner )
2465 var child_1 = new Xcls_PropertyExpression39( _this );
2467 this.el = new Gtk.StringSorter( child_1.el );
2471 // set gobject values
2474 // user defined functions
2476 public class Xcls_PropertyExpression39 : Object
2478 public Gtk.PropertyExpression el;
2479 private Editor _this;
2485 public Xcls_PropertyExpression39(Editor _owner )
2488 this.el = new Gtk.PropertyExpression( typeof(Lsp.DocumentSymbol), null, "sort_key" );
2492 // set gobject values
2495 // user defined functions
2502 public class Xcls_GestureClick40 : Object
2504 public Gtk.GestureClick el;
2505 private Editor _this;
2511 public Xcls_GestureClick40(Editor _owner )
2514 this.el = new Gtk.GestureClick();
2518 // set gobject values
2521 this.el.pressed.connect( (n_press, x, y) => {
2523 var row = _this.navigation.getRowWidgetAt(x,y, out pos );
2526 GLib.debug("no row selected items");
2529 GLib.debug("got click on %s", row.get_type().name());
2530 //Lsp.DocumentSymbol
2531 var sym = row.get_data<Lsp.DocumentSymbol>("symbol");
2547 GLib.debug("goto line %d", (int)sym.range.start.line);
2548 _this.scroll_to_line((int)sym.range.start.line);
2550 _this.buffer.el.get_iter_at_line_offset(out iter,
2551 (int)sym.range.start.line,
2552 (int)sym.range.start.character
2554 _this.buffer.el.place_cursor(iter);
2559 // user defined functions