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_close_btn close_btn;
17 public Xcls_RightEditor RightEditor;
18 public Xcls_view view;
19 public Xcls_buffer buffer;
20 public Xcls_keystate keystate;
21 public Xcls_search_entry search_entry;
22 public Xcls_search_results search_results;
23 public Xcls_nextBtn nextBtn;
24 public Xcls_backBtn backBtn;
25 public Xcls_search_settings search_settings;
26 public Xcls_case_sensitive case_sensitive;
27 public Xcls_regex regex;
28 public Xcls_multiline multiline;
29 public Xcls_navigationwindow navigationwindow;
30 public Xcls_navigation navigation;
31 public Xcls_navliststore navliststore;
34 public int pos_root_x;
35 public Xcls_MainWindow window;
37 public int pos_root_y;
39 public int last_error_counter;
40 public GtkSource.SearchContext searchcontext;
41 public int last_search_end;
42 public signal void save ();
43 public JsRender.JsRender? file;
44 public JsRender.Node node;
45 public JsRender.NodeProp? prop;
46 public string activeEditor;
52 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
58 this.last_error_counter = 0;
59 this.searchcontext = null;
60 this.last_search_end = 0;
64 this.activeEditor = "\"\"";
67 this.el.homogeneous = false;
68 this.el.hexpand = true;
69 this.el.vexpand = true;
70 var child_1 = new Xcls_Paned1( _this );
72 this.el.append( child_1.el );
75 // user defined functions
76 public bool saveContents () {
79 if (_this.file == null) {
85 var str = _this.buffer.toString();
87 _this.buffer.checkSyntax();
91 // LeftPanel.model.changed( str , false);
93 _this.save_button.el.sensitive = false;
95 // find the text for the node..
96 if (_this.file.xtype != "PlainFile") {
97 // in theory these properties have to exist!?!
99 //this.window.windowstate.left_props.reload();
101 _this.file.setSource( str );
110 public void forwardSearch (bool change_focus) {
112 if (this.searchcontext == null) {
116 Gtk.TextIter beg, st,en;
117 bool has_wrapped_around;
118 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end);
119 if (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {
121 this.last_search_end = 0; // not sure if this should happen
123 if (has_wrapped_around) {
127 this.last_search_end = en.get_offset();
129 this.view.el.grab_focus();
131 this.buffer.el.place_cursor(st);
132 this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);
136 public void show (JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)
141 if (file.xtype != "PlainFile") {
145 // find the text for the node..
146 this.view.load( prop.val );
147 this.updateErrorMarks();
151 this.close_btn.el.show();
154 this.view.load( file.toSource() );
155 this.updateErrorMarks();
156 this.close_btn.el.hide();
157 var ls = file.getLanguageServer();
158 ls.documentSymbols.begin(file, (a,o) => {
159 _this.navigation.show(ls.documentSymbols.end(o));
166 public void backSearch (bool change_focus) {
168 if (this.searchcontext == null) {
172 Gtk.TextIter beg, st,en;
173 bool has_wrapped_around;
174 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );
176 if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {
177 this.last_search_end = 0;
179 this.last_search_end = en.get_offset();
181 this.view.el.grab_focus();
183 this.buffer.el.place_cursor(st);
184 this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);
188 public string tempFileContents () {
191 if (_this.file == null) {
194 var str= this.buffer.toString();
195 if (_this.file.xtype == "PlainFile") {
203 GLib.debug("calling validate");
204 // clear the buttons.
205 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
206 return this.file.toSource(); ;
209 var oldcode = _this.prop.val;
210 _this.prop.val = str;
211 var ret = _this.file.toSource();
212 _this.prop.val = oldcode;
216 public void reset () {
221 this.searchcontext = null;
224 public int search (string in_txt) {
226 var s = new GtkSource.SearchSettings();
227 s.case_sensitive = _this.case_sensitive.el.active;
228 s.regex_enabled = _this.regex.el.active;
229 s.wrap_around = false;
231 this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);
232 this.searchcontext.set_highlight(true);
235 if (_this.multiline.el.active) {
236 txt = in_txt.replace("\\n", "\n");
239 s.set_search_text(txt);
240 Gtk.TextIter beg, st,en;
242 this.buffer.el.get_start_iter(out beg);
243 bool has_wrapped_around;
244 this.searchcontext.forward(beg, out st, out en, out has_wrapped_around);
245 this.last_search_end = 0;
247 return this.searchcontext.get_occurrences_count();
253 public void updateErrorMarks () {
257 var buf = _this.buffer.el;
260 buf.get_bounds (out start, out end);
265 //GLib.debug("highlight errors");
267 // we should highlight other types of errors..
269 if (_this.window.windowstate.state != WindowState.State.CODEONLY
271 _this.window.windowstate.state != WindowState.State.CODE
273 //GLib.debug("windowstate != CODEONLY?");
279 if (_this.file == null) {
280 GLib.debug("file is null?");
284 var ar = this.file.getErrors();
286 buf.remove_source_marks (start, end, "ERR");
287 buf.remove_source_marks (start, end, "WARN");
288 buf.remove_source_marks (start, end, "DEPR");
289 buf.remove_tag_by_name ("ERR", start, end);
290 buf.remove_tag_by_name ("WARN", start, end);
291 buf.remove_tag_by_name ("DEPR", start, end);
292 this.last_error_counter = file.error_counter ;
293 //GLib.debug("highlight %s : %s has no errors", this.file.relpath, category);
298 // basicaly check if there is no change, then we do not do any update..
299 // we can do this by just using an error counter?
300 // if that's changed then we will do an update, otherwise dont bother.
306 var tlines = buf.get_line_count () +1;
308 if (_this.prop != null) {
309 // this still seems flaky...
311 tlines = _this.prop.end_line;
312 offset = _this.prop.start_line;
313 hoffset = _this.node.node_pad.length + 2; //shift it left by 2 ? ..
318 if (this.last_error_counter == file.error_counter) {
324 buf.remove_source_marks (start, end, "ERR");
325 buf.remove_source_marks (start, end, "WARN");
326 buf.remove_source_marks (start, end, "DEPR");
327 buf.remove_tag_by_name ("ERR", start, end);
328 buf.remove_tag_by_name ("WARN", start, end);
329 buf.remove_tag_by_name ("DEPR", start, end);
331 foreach(var diag in ar) {
333 // print("get inter\n");
334 var eline = (int)diag.range.start.line - offset;
335 var eline_to = (int)diag.range.end.line - offset;
336 //var eline = diag.range.end_line - offset;
337 //GLib.debug("GOT ERROR on line %d -- converted to %d (offset = %d)",
338 // err.line ,eline, offset);
341 if (eline > tlines || eline < 0) {
345 buf.get_iter_at_line( out iter, eline);
346 var msg = "Line: %d %s : %s".printf(eline+1, diag.category, diag.message);
347 buf.create_source_mark( msg, diag.category, iter);
349 var spos = (int)diag.range.start.character - hoffset;
350 if (spos < 0) { spos =0 ; }
351 if (spos > iter.get_chars_in_line()) {
352 spos = iter.get_chars_in_line();
354 buf.get_iter_at_line( out iter, eline_to);
355 var epos = (int)diag.range.end.character - hoffset;
356 if (epos < 0) { epos =0 ; }
357 if (epos > iter.get_chars_in_line()) {
358 epos = iter.get_chars_in_line();
362 buf.get_iter_at_line_offset( out start, eline, spos);
364 buf.get_iter_at_line_offset( out end, eline_to,epos);
366 buf.apply_tag_by_name(diag.category, start, end);
368 // GLib.debug("set line %d to %s", eline, msg);
369 //this.marks.set(eline, msg);
371 this.last_error_counter = file.error_counter ;
378 public void scroll_to_line (int line) {
380 GLib.Timeout.add(500, () => {
382 var buf = this.view.el.get_buffer();
384 var sbuf = (GtkSource.Buffer) buf;
388 sbuf.get_iter_at_line(out iter, line);
389 this.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
393 public class Xcls_Paned1 : Object
396 private Editor _this;
402 public Xcls_Paned1(Editor _owner )
405 this.el = new Gtk.Paned( Gtk.Orientation.HORIZONTAL );
409 // set gobject values
410 var child_1 = new Xcls_Box2( _this );
412 this.el.start_child = child_1.el;
413 new Xcls_navigationwindow( _this );
414 this.el.end_child = _this.navigationwindow.el;
417 // user defined functions
419 public class Xcls_Box2 : Object
422 private Editor _this;
428 public Xcls_Box2(Editor _owner )
431 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
435 // set gobject values
436 var child_1 = new Xcls_Box3( _this );
438 this.el.append( child_1.el );
439 new Xcls_RightEditor( _this );
440 this.el.append( _this.RightEditor.el );
441 var child_3 = new Xcls_Box15( _this );
443 this.el.append ( child_3.el );
446 // user defined functions
448 public class Xcls_Box3 : Object
451 private Editor _this;
457 public Xcls_Box3(Editor _owner )
460 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
464 // set gobject values
465 this.el.homogeneous = false;
466 this.el.hexpand = true;
467 new Xcls_save_button( _this );
468 this.el.append( _this.save_button.el );
469 var child_2 = new Xcls_Label5( _this );
471 this.el.append( child_2.el );
472 var child_3 = new Xcls_Scale6( _this );
474 this.el.append( child_3.el );
475 new Xcls_close_btn( _this );
476 this.el.append( _this.close_btn.el );
479 // user defined functions
481 public class Xcls_save_button : Object
483 public Gtk.Button el;
484 private Editor _this;
490 public Xcls_save_button(Editor _owner )
493 _this.save_button = this;
494 this.el = new Gtk.Button();
498 // set gobject values
499 this.el.label = "Save";
502 this.el.clicked.connect( () => {
503 _this.saveContents();
507 // user defined functions
510 public class Xcls_Label5 : Object
513 private Editor _this;
519 public Xcls_Label5(Editor _owner )
522 this.el = new Gtk.Label( null );
526 // set gobject values
527 this.el.hexpand = true;
530 // user defined functions
533 public class Xcls_Scale6 : Object
536 private Editor _this;
542 public Xcls_Scale6(Editor _owner )
545 this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1);
549 // set gobject values
550 this.el.width_request = 200;
551 this.el.has_origin = true;
552 this.el.draw_value = false;
554 this.el.sensitive = true;
559 //this.el.set_range(6,30);
560 this.el.set_value ( BuilderApplication.settings.editor_font_size);
561 BuilderApplication.settings.editor_font_size_updated.connect(
563 BuilderApplication.settings.editor_font_size_inchange = true;
564 // GLib.debug("update range");
565 this.el.set_value (BuilderApplication.settings.editor_font_size);
566 BuilderApplication.settings.editor_font_size_inchange = false;
574 this.el.change_value.connect( (st, val ) => {
575 if (BuilderApplication.settings.editor_font_size_inchange) {
578 BuilderApplication.settings.editor_font_size = val;
583 // user defined functions
586 public class Xcls_close_btn : Object
588 public Gtk.Button el;
589 private Editor _this;
595 public Xcls_close_btn(Editor _owner )
598 _this.close_btn = this;
599 this.el = new Gtk.Button();
603 // set gobject values
604 this.el.icon_name = "window-close";
605 var child_1 = new Xcls_Image8( _this );
607 this.el.child = child_1.el;
610 this.el.clicked.connect( () => {
611 _this.saveContents();
612 _this.window.windowstate.switchState(WindowState.State.PREVIEW);
616 // user defined functions
618 public class Xcls_Image8 : Object
621 private Editor _this;
627 public Xcls_Image8(Editor _owner )
630 this.el = new Gtk.Image();
634 // set gobject values
635 this.el.icon_name = "window-close";
636 this.el.icon_size = Gtk.IconSize.NORMAL;
639 // user defined functions
644 public class Xcls_RightEditor : Object
646 public Gtk.ScrolledWindow el;
647 private Editor _this;
653 public Xcls_RightEditor(Editor _owner )
656 _this.RightEditor = this;
657 this.el = new Gtk.ScrolledWindow();
661 // set gobject values
662 this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
663 this.el.vexpand = true;
664 this.el.overlay_scrolling = false;
665 this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
666 new Xcls_view( _this );
667 this.el.child = _this.view.el;
670 // user defined functions
672 public class Xcls_view : Object
674 public GtkSource.View el;
675 private Editor _this;
679 public Gtk.CssProvider css;
682 public Xcls_view(Editor _owner )
686 this.el = new GtkSource.View();
691 // set gobject values
692 this.el.auto_indent = true;
693 this.el.indent_width = 4;
694 this.el.name = "editor-view";
695 this.el.show_line_marks = true;
696 this.el.insert_spaces_instead_of_tabs = true;
697 this.el.show_line_numbers = true;
698 this.el.hexpand = true;
699 this.el.vexpand = true;
700 this.el.has_tooltip = true;
701 this.el.css_classes = { "code-editor" };
702 this.el.tab_width = 4;
703 this.el.highlight_current_line = true;
704 new Xcls_buffer( _this );
705 this.el.buffer = _this.buffer.el;
706 new Xcls_keystate( _this );
707 this.el.add_controller( _this.keystate.el );
708 var child_3 = new Xcls_EventControllerScroll13( _this );
710 this.el.add_controller( child_3.el );
711 var child_4 = new Xcls_GestureClick14( _this );
713 this.el.add_controller( child_4.el );
717 this.el.completion.add_provider(
718 new Palete.CompletionProvider(_this)
721 // hover seems pretty useless.. - ??
722 //var hover = this.el.get_hover();
723 //hover.add_provider(new Palete.HoverProvider(_this));
725 //this.el.completion.unblock_interactive();
726 this.el.completion.select_on_show = true; // select
727 //this.el.completion.remember_info_visibility = true;
730 var attrs = new GtkSource.MarkAttributes();
732 attrs.set_icon_name ( "process-stop");
733 attrs.query_tooltip_text.connect(( mark) => {
734 GLib.debug("tooltip query? %s", mark.name);
735 return strdup( mark.name);
737 attrs.query_tooltip_markup.connect(( mark) => {
738 GLib.debug("tooltip query? %s", mark.name);
739 return strdup( mark.name);
741 this.el.set_mark_attributes ("ERR", attrs, 1);
745 var wattrs = new GtkSource.MarkAttributes();
746 wattrs.set_icon_name ( "process-stop");
747 wattrs.query_tooltip_text.connect(( mark) => {
748 GLib.debug("tooltip query? %s", mark.name);
749 return strdup(mark.name);
751 wattrs.query_tooltip_markup.connect(( mark) => {
752 GLib.debug("tooltip query? %s", mark.name);
753 return strdup(mark.name);
755 this.el.set_mark_attributes ("WARN", wattrs, 1);
759 var dattrs = new GtkSource.MarkAttributes();
761 dattrs.set_icon_name ( "process-stop");
763 dattrs.query_tooltip_text.connect(( mark) => {
764 GLib.debug("tooltip query? %s", mark.name);
765 return strdup(mark.name);
767 //dattrs.query_tooltip_markup.connect(( mark) => {
768 // GLib.debug("tooltip query? %s", mark.name);
769 // return strdup(mark.name);
771 this.el.set_mark_attributes ("DEPR", dattrs, 1);
774 this.el.get_space_drawer().set_matrix(null);
775 this.el.get_space_drawer().set_types_for_locations(
776 GtkSource.SpaceLocationFlags.ALL,
777 GtkSource.SpaceTypeFlags.ALL
779 this.el.get_space_drawer().set_enable_matrix(true);
782 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
784 //GLib.debug("query tooltip");
788 var yoff = (int) _this.RightEditor.el.vadjustment.value;
790 // I think this is problematic - if it's compliing / updating at same time as query.
792 //if (_this.window.statusbar_compile_spinner.el.spinning) {
796 this.el.get_iter_at_position (out iter, out trailing, x, y + yoff);
798 var l = iter.get_line();
802 // GLib.debug("query tooltip line %d", (int) l);
808 if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {
809 GLib.debug("line %d setting tip to %s", l, _this.buffer.marks.get(l));
810 tooltip.set_text(_this.buffer.marks.get(l).dup());
818 // this crashes?? - not sure why.
819 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
820 if (marks.is_empty()) {
821 marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
823 if (marks.is_empty()) {
824 marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
827 // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length());
829 marks.@foreach((m) => {
830 //GLib.debug("got mark %s", m.name);
831 str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name;
833 // true if there is a mark..
834 if (str.length > 0 ) {
835 tooltip.set_text( str );
837 return str.length > 0 ? true : false;
842 // user defined functions
843 public void load (string str) {
845 // show the help page for the active node..
846 //this.get('/Help').show();
848 // this.get('/BottomPane').el.set_current_page(0);
849 GLib.debug("load called - Reset undo buffer");
851 var buf = (GtkSource.Buffer)this.el.get_buffer();
852 buf.begin_irreversible_action();
853 buf.set_text(str, str.length);
854 buf.end_irreversible_action();
856 var lm = GtkSource.LanguageManager.get_default();
858 if (_this.file != null) {
859 lang = _this.file.language;
861 print("lang=%s, content_type = %s\n", lang, _this.file.content_type);
862 var lg = _this.file.content_type.length > 0 ?
863 lm.guess_language(_this.file.path, _this.file.content_type) :
864 lm.get_language(lang);
867 ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg);
869 this.el.insert_spaces_instead_of_tabs = true;
871 print("sourcelanguage = %s\n", lg.name);
872 if (lg.name == "Vala") {
873 this.el.insert_spaces_instead_of_tabs = false;
877 this.el.grab_focus();
878 _this.save_button.el.sensitive = false;
879 _this.last_error_counter = -1;
882 public class Xcls_buffer : Object
884 public GtkSource.Buffer el;
885 private Editor _this;
889 public int error_line;
890 public Gee.HashMap<int,string>? xmarks;
891 public bool check_queued;
894 public Xcls_buffer(Editor _owner )
898 this.el = new GtkSource.Buffer( null );
901 this.error_line = -1;
903 this.check_queued = false;
905 // set gobject values
906 this.el.highlight_syntax = true;
907 this.el.highlight_matching_brackets = true;
908 this.el.enable_undo = true;
913 buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
914 buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
915 buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
916 buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
917 buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
918 buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
919 buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
920 buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
923 buf.create_tag ("ERR", "weight", Pango.Weight.BOLD, "background", "pink");
924 buf.create_tag ("WARN", "weight", Pango.Weight.BOLD, "background", "#ABF4EB");
925 buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
928 this.el.changed.connect( () => {
931 _this.save_button.el.sensitive = true;
932 print("EDITOR CHANGED");
937 // this.get('/LeftPanel.model').changed( str , false);
942 // user defined functions
943 public bool OLDhighlightErrorsJson (string type, Json.Object obj) {
946 this.el.get_bounds (out start, out end);
948 this.el.remove_source_marks (start, end, type);
949 GLib.debug("highlight errors");
951 // we should highlight other types of errors..
953 if (!obj.has_member(type)) {
954 GLib.debug("Return has no errors\n");
958 if (_this.window.windowstate.state != WindowState.State.CODEONLY
960 _this.window.windowstate.state != WindowState.State.CODE
962 GLib.debug("windowstate != CODEONLY?");
967 //this.marks = new Gee.HashMap<int,string>();
968 var err = obj.get_object_member(type);
970 if (_this.file == null) {
971 GLib.debug("file is null?");
975 var valafn = _this.file.path;
977 if (_this.file.xtype != "PlainFile") {
981 var regex = new Regex("\\.bjs$");
983 valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
984 } catch (GLib.RegexError e) {
991 if (!err.has_member(valafn)) {
992 GLib.debug("File path has no errors");
996 var lines = err.get_object_member(valafn);
999 if (obj.has_member("line_offset")) { // ?? why??
1000 offset = (int)obj.get_int_member("line_offset") + 1;
1004 var tlines = this.el.get_line_count () +1;
1006 if (_this.prop != null) {
1008 tlines = _this.prop.end_line + 1;
1009 offset = _this.prop.start_line + 1;
1015 lines.foreach_member((obj, line, node) => {
1018 // print("get inter\n");
1019 var eline = int.parse(line) - offset;
1020 GLib.debug("GOT ERROR on line %s -- converted to %d (offset = %d)\n", line,eline, offset);
1023 if (eline > tlines || eline < 0) {
1028 this.el.get_iter_at_line( out iter, eline);
1029 //print("mark line\n");
1031 var ar = lines.get_array_member(line);
1032 for (var i = 0 ; i < ar.get_length(); i++) {
1033 if (ar.get_string_element(i) == "Success") {
1036 msg += (msg.length > 0) ? "\n" : "";
1037 msg += ar.get_string_element(i);
1042 msg = "Line: %d".printf(eline+1) + " " + msg;
1043 this.el.create_source_mark(msg, type, iter);
1044 GLib.debug("set line %d to %m", eline, msg);
1045 // this.marks.set(eline, msg);
1054 public bool checkSyntax () {
1057 var str = this.toString();
1060 if (this.error_line > 0) {
1063 this.el.get_bounds (out start, out end);
1065 this.el.remove_source_marks (start, end, null);
1067 if (str.length < 1) {
1068 print("checkSyntax - empty string?\n");
1073 if (_this.file.xtype == "PlainFile") {
1075 // assume it's gtk...
1076 var oldcode =_this.file.toSource();
1077 _this.file.setSource(str);
1078 BuilderApplication.showSpinner("appointment soon","document change pending");
1079 _this.file.getLanguageServer().document_change(_this.file);
1081 _this.file.setSource(oldcode);
1087 if (_this.file == null) {
1095 GLib.debug("calling validate");
1096 // clear the buttons.
1097 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
1100 var oldcode = _this.prop.val;
1102 _this.prop.val = str;
1103 _this.node.updated_count++;
1104 _this.file.getLanguageServer().document_change(_this.file);
1105 _this.node.updated_count++;
1106 _this.prop.val = oldcode;
1109 //print("done mark line\n");
1111 return true; // at present allow saving - even if it's invalid..
1113 public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
1115 this.error_line = validate_res.size;
1117 if (this.error_line < 1) {
1120 var tlines = this.el.get_line_count ();
1122 var valiter = validate_res.map_iterator();
1123 while (valiter.next()) {
1125 // print("get inter\n");
1126 var eline = valiter.get_key();
1127 if (eline > tlines) {
1130 this.el.get_iter_at_line( out iter, eline);
1131 //print("mark line\n");
1132 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
1136 public string toString () {
1140 this.el.get_start_iter(out s);
1141 this.el.get_end_iter(out e);
1142 var ret = this.el.get_text(s,e,true);
1143 //print("TO STRING? " + ret);
1148 public class Xcls_keystate : Object
1150 public Gtk.EventControllerKey el;
1151 private Editor _this;
1155 public bool is_control;
1158 public Xcls_keystate(Editor _owner )
1161 _this.keystate = this;
1162 this.el = new Gtk.EventControllerKey();
1165 this.is_control = false;
1167 // set gobject values
1170 this.el.key_released.connect( (keyval, keycode, state) => {
1172 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1173 this.is_control = false;
1175 if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1176 GLib.debug("SAVE: ctrl-S pressed");
1177 _this.saveContents();
1181 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1182 GLib.debug("SAVE: ctrl-g pressed");
1183 _this.forwardSearch(true);
1186 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1187 GLib.debug("SAVE: ctrl-f pressed");
1188 _this.search_entry.el.grab_focus();
1189 _this.search_entry.el.select_region(0,-1);
1192 if (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1193 _this.view.el.show_completion();
1197 _this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);
1198 var line = iter.get_line();
1199 var offset = iter.get_line_offset();
1200 GLib.debug("line %d off %d", line ,offset);
1201 if (_this.prop != null) {
1202 line += _this.prop.start_line + 1; // i think..
1203 offset += 12; // should probably be 8 without namespaced
1204 GLib.debug("guess line %d off %d", line ,offset);
1206 //_this.view.el.show_completion();
1207 // print(event.key.keyval)
1216 this.el.key_pressed.connect( (keyval, keycode, state) => {
1218 if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
1219 this.is_control = true;
1225 // user defined functions
1228 public class Xcls_EventControllerScroll13 : Object
1230 public Gtk.EventControllerScroll el;
1231 private Editor _this;
1235 public double distance;
1238 public Xcls_EventControllerScroll13(Editor _owner )
1241 this.el = new Gtk.EventControllerScroll( Gtk.EventControllerScrollFlags.VERTICAL );
1244 this.distance = 0.0f;
1246 // set gobject values
1249 this.el.scroll.connect( (dx, dy) => {
1250 if (!_this.keystate.is_control) {
1253 //GLib.debug("scroll %f", dy);
1255 this.distance += dy;
1257 //GLib.debug("scroll %f / %f", dy, this.distance);
1259 if (this.distance < -1) {
1261 BuilderApplication.settings.editor_font_size ++;
1264 if (this.distance > 1) {
1265 BuilderApplication.settings.editor_font_size --;
1273 // user defined functions
1276 public class Xcls_GestureClick14 : Object
1278 public Gtk.GestureClick el;
1279 private Editor _this;
1285 public Xcls_GestureClick14(Editor _owner )
1288 this.el = new Gtk.GestureClick();
1292 // set gobject values
1295 // user defined functions
1300 public class Xcls_Box15 : Object
1303 private Editor _this;
1309 public Xcls_Box15(Editor _owner )
1312 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1316 // set gobject values
1317 this.el.homogeneous = false;
1318 this.el.vexpand = false;
1319 new Xcls_search_entry( _this );
1320 this.el.append( _this.search_entry.el );
1321 new Xcls_search_results( _this );
1322 this.el.append( _this.search_results.el );
1323 new Xcls_nextBtn( _this );
1324 this.el.append( _this.nextBtn.el );
1325 new Xcls_backBtn( _this );
1326 this.el.append( _this.backBtn.el );
1327 var child_5 = new Xcls_MenuButton21( _this );
1329 this.el.append( child_5.el );
1332 // user defined functions
1334 public class Xcls_search_entry : Object
1336 public Gtk.SearchEntry el;
1337 private Editor _this;
1341 public Gtk.CssProvider css;
1344 public Xcls_search_entry(Editor _owner )
1347 _this.search_entry = this;
1348 this.el = new Gtk.SearchEntry();
1352 // set gobject values
1353 this.el.name = "editor-search-entry";
1354 this.el.hexpand = true;
1355 this.el.placeholder_text = "Press enter to search";
1356 this.el.search_delay = 3;
1357 var child_1 = new Xcls_EventControllerKey17( _this );
1359 this.el.add_controller( child_1.el );
1362 this.el.search_changed.connect( ( ) => {
1364 _this.search(_this.search_entry.el.text);
1365 _this.search_results.updateResults();
1367 GLib.Timeout.add_seconds(1,() => {
1368 _this.search_results.updateResults();
1374 // user defined functions
1375 public void forwardSearch (bool change_focus) {
1378 _this.forwardSearch(change_focus);
1382 switch(_this.windowstate.state) {
1383 case WindowState.State.CODEONLY:
1384 //case WindowState.State.CODE:
1385 // search the code being edited..
1386 _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1389 case WindowState.State.PREVIEW:
1390 if (_this.windowstate.file.xtype == "Gtk") {
1391 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1393 _this.windowstate.window_rooview.forwardSearch(change_focus);
1402 public class Xcls_EventControllerKey17 : Object
1404 public Gtk.EventControllerKey el;
1405 private Editor _this;
1411 public Xcls_EventControllerKey17(Editor _owner )
1414 this.el = new Gtk.EventControllerKey();
1418 // set gobject values
1421 this.el.key_pressed.connect( (keyval, keycode, state) => {
1423 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1424 GLib.debug("SAVE: ctrl-g pressed");
1425 _this.forwardSearch(true);
1430 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1431 _this.forwardSearch(true);
1437 // print(event.key.keyval)
1443 // user defined functions
1447 public class Xcls_search_results : Object
1449 public Gtk.Label el;
1450 private Editor _this;
1456 public Xcls_search_results(Editor _owner )
1459 _this.search_results = this;
1460 this.el = new Gtk.Label( "No Results" );
1464 // set gobject values
1465 this.el.margin_end = 4;
1466 this.el.margin_start = 4;
1469 // user defined functions
1470 public void updateResults () {
1471 this.el.visible = true;
1473 var res = _this.searchcontext.get_occurrences_count();
1475 _this.search_results.el.label = "??? Matches";
1479 _this.nextBtn.el.sensitive = false;
1480 _this.backBtn.el.sensitive = false;
1483 _this.search_results.el.label = "%d Matches".printf(res);
1484 _this.nextBtn.el.sensitive = true;
1485 _this.backBtn.el.sensitive = true;
1488 _this.search_results.el.label = "No Matches";
1493 public class Xcls_nextBtn : Object
1495 public Gtk.Button el;
1496 private Editor _this;
1500 public bool always_show_image;
1503 public Xcls_nextBtn(Editor _owner )
1506 _this.nextBtn = this;
1507 this.el = new Gtk.Button();
1510 this.always_show_image = true;
1512 // set gobject values
1513 this.el.icon_name = "go-down";
1514 this.el.sensitive = false;
1517 this.el.clicked.connect( (event) => {
1519 _this.forwardSearch(true);
1525 // user defined functions
1528 public class Xcls_backBtn : Object
1530 public Gtk.Button el;
1531 private Editor _this;
1535 public bool always_show_image;
1538 public Xcls_backBtn(Editor _owner )
1541 _this.backBtn = this;
1542 this.el = new Gtk.Button();
1545 this.always_show_image = true;
1547 // set gobject values
1548 this.el.icon_name = "go-up";
1549 this.el.sensitive = false;
1552 this.el.clicked.connect( (event) => {
1554 _this.backSearch(true);
1559 // user defined functions
1562 public class Xcls_MenuButton21 : Object
1564 public Gtk.MenuButton el;
1565 private Editor _this;
1569 public bool always_show_image;
1572 public Xcls_MenuButton21(Editor _owner )
1575 this.el = new Gtk.MenuButton();
1578 this.always_show_image = true;
1580 // set gobject values
1581 this.el.icon_name = "emblem-system";
1582 this.el.always_show_arrow = true;
1583 new Xcls_search_settings( _this );
1584 this.el.popover = _this.search_settings.el;
1587 // user defined functions
1589 public class Xcls_search_settings : Object
1591 public Gtk.Popover el;
1592 private Editor _this;
1598 public Xcls_search_settings(Editor _owner )
1601 _this.search_settings = this;
1602 this.el = new Gtk.Popover();
1606 // set gobject values
1607 var child_1 = new Xcls_Box23( _this );
1609 this.el.child = child_1.el;
1612 // user defined functions
1614 public class Xcls_Box23 : Object
1617 private Editor _this;
1623 public Xcls_Box23(Editor _owner )
1626 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1630 // set gobject values
1631 new Xcls_case_sensitive( _this );
1632 this.el.append( _this.case_sensitive.el );
1633 new Xcls_regex( _this );
1634 this.el.append( _this.regex.el );
1635 new Xcls_multiline( _this );
1636 this.el.append( _this.multiline.el );
1639 // user defined functions
1641 public class Xcls_case_sensitive : Object
1643 public Gtk.CheckButton el;
1644 private Editor _this;
1650 public Xcls_case_sensitive(Editor _owner )
1653 _this.case_sensitive = this;
1654 this.el = new Gtk.CheckButton();
1658 // set gobject values
1659 this.el.label = "Case Sensitive";
1668 // user defined functions
1671 public class Xcls_regex : Object
1673 public Gtk.CheckButton el;
1674 private Editor _this;
1680 public Xcls_regex(Editor _owner )
1684 this.el = new Gtk.CheckButton();
1688 // set gobject values
1689 this.el.label = "Regex";
1698 // user defined functions
1701 public class Xcls_multiline : Object
1703 public Gtk.CheckButton el;
1704 private Editor _this;
1710 public Xcls_multiline(Editor _owner )
1713 _this.multiline = this;
1714 this.el = new Gtk.CheckButton();
1718 // set gobject values
1719 this.el.label = "Multi-line (add \\n)";
1722 // user defined functions
1730 public class Xcls_navigationwindow : Object
1732 public Gtk.ScrolledWindow el;
1733 private Editor _this;
1739 public Xcls_navigationwindow(Editor _owner )
1742 _this.navigationwindow = this;
1743 this.el = new Gtk.ScrolledWindow();
1747 // set gobject values
1748 this.el.visible = false;
1749 new Xcls_navigation( _this );
1750 this.el.child = _this.navigation.el;
1753 // user defined functions
1755 public class Xcls_navigation : Object
1757 public Gtk.ColumnView el;
1758 private Editor _this;
1764 public Xcls_navigation(Editor _owner )
1767 _this.navigation = this;
1768 var child_1 = new Xcls_SingleSelection31( _this );
1770 this.el = new Gtk.ColumnView( child_1.el );
1774 // set gobject values
1775 var child_2 = new Xcls_ColumnViewColumn29( _this );
1777 this.el.append_column( child_2.el );
1780 // user defined functions
1781 public void show (Gee.ArrayList<Lsp.DocumentSymbol> syms) {
1782 _this.navigationwindow.el.show();
1783 _this.navliststore.el.remove_all();
1784 foreach(var sym in syms) {
1785 _this.navliststore.el.append(sym);
1791 public class Xcls_ColumnViewColumn29 : Object
1793 public Gtk.ColumnViewColumn el;
1794 private Editor _this;
1800 public Xcls_ColumnViewColumn29(Editor _owner )
1803 var child_1 = new Xcls_SignalListItemFactory30( _this );
1805 this.el = new Gtk.ColumnViewColumn( "Code Navigation", child_1.el );
1809 // set gobject values
1810 this.el.expand = true;
1813 // user defined functions
1815 public class Xcls_SignalListItemFactory30 : Object
1817 public Gtk.SignalListItemFactory el;
1818 private Editor _this;
1824 public Xcls_SignalListItemFactory30(Editor _owner )
1827 this.el = new Gtk.SignalListItemFactory();
1831 // set gobject values
1834 this.el.setup.connect( (listitem) => {
1836 var expand = new Gtk.TreeExpander();
1838 expand.set_indent_for_depth(true);
1839 expand.set_indent_for_icon(true);
1840 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,0);
1841 var icon = new Gtk.Image();
1842 var lbl = new Gtk.Label("");
1843 lbl.use_markup = true;
1844 lbl.ellipsize = Pango.EllipsizeMode.END;
1846 icon.margin_end = 4;
1847 lbl.justify = Gtk.Justification.LEFT;
1850 // listitem.activatable = true; ??
1854 expand.set_child(hbox);
1855 ((Gtk.ListItem)listitem).set_child(expand);
1858 this.el.bind.connect( (listitem) => {
1859 // GLib.debug("listitme is is %s", ((Gtk.ListItem)listitem).get_type().name());
1861 //var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
1862 var expand = (Gtk.TreeExpander) ((Gtk.ListItem)listitem).get_child();
1865 var hbox = (Gtk.Box) expand.child;
1868 var img = (Gtk.Image) hbox.get_first_child();
1869 var lbl = (Gtk.Label) img.get_next_sibling();
1871 var lr = (Gtk.TreeListRow)((Gtk.ListItem)listitem).get_item();
1872 var sym = (Lsp.DocumentSymbol) lr.get_item();
1875 expand.set_hide_expander( sym.children.get_n_items() < 1);
1876 expand.set_list_row(lr);
1878 //node.bind_property("iconResourceName",
1880 // GLib.BindingFlags.SYNC_CREATE);
1882 sym.bind_property("name",
1884 GLib.BindingFlags.SYNC_CREATE);
1885 // should be better?- --line no?
1886 sym.bind_property("detail",
1887 lbl, "tooltip_markup",
1888 GLib.BindingFlags.SYNC_CREATE);
1894 // user defined functions
1898 public class Xcls_SingleSelection31 : Object
1900 public Gtk.SingleSelection el;
1901 private Editor _this;
1907 public Xcls_SingleSelection31(Editor _owner )
1910 var child_1 = new Xcls_TreeListModel32( _this );
1912 this.el = new Gtk.SingleSelection( child_1.el );
1916 // set gobject values
1919 // user defined functions
1921 public class Xcls_TreeListModel32 : Object
1923 public Gtk.TreeListModel el;
1924 private Editor _this;
1930 public Xcls_TreeListModel32(Editor _owner )
1933 new Xcls_navliststore( _this );
1934 this.el = new Gtk.TreeListModel( _this.navliststore.el, false, true, (item) => {
1936 return ((Lsp.DocumentSymbol)item).children;
1942 // set gobject values
1945 // user defined functions
1947 public class Xcls_navliststore : Object
1949 public GLib.ListStore el;
1950 private Editor _this;
1956 public Xcls_navliststore(Editor _owner )
1959 _this.navliststore = this;
1960 this.el = new GLib.ListStore( typeof(Lsp.DocumentSymbol) );
1964 // set gobject values
1967 // user defined functions