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_search_entry search_entry;
21 public Xcls_search_results search_results;
22 public Xcls_nextBtn nextBtn;
23 public Xcls_backBtn backBtn;
24 public Xcls_search_settings search_settings;
25 public Xcls_case_sensitive case_sensitive;
26 public Xcls_regex regex;
27 public Xcls_multiline multiline;
30 public int pos_root_x;
31 public Xcls_MainWindow window;
33 public int pos_root_y;
35 public int last_error_counter;
36 public GtkSource.SearchContext searchcontext;
37 public int last_search_end;
38 public signal void save ();
39 public JsRender.JsRender? file;
40 public JsRender.Node node;
41 public JsRender.NodeProp? prop;
42 public string activeEditor;
48 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
54 this.last_error_counter = 0;
55 this.searchcontext = null;
56 this.last_search_end = 0;
60 this.activeEditor = "";
63 this.el.homogeneous = false;
64 this.el.hexpand = true;
65 this.el.vexpand = true;
66 var child_1 = new Xcls_Box1( _this );
69 this.el.append( child_1.el );
70 new Xcls_RightEditor( _this );
71 this.el.append( _this.RightEditor.el );
72 var child_3 = new Xcls_Box11( _this );
75 this.el.append ( child_3.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)
144 if (file.xtype != "PlainFile") {
148 // find the text for the node..
149 this.view.load( prop.val );
150 this.updateErrorMarks();
152 this.close_btn.el.show();
155 this.view.load( file.toSource() );
156 this.updateErrorMarks();
157 this.close_btn.el.hide();
162 public void backSearch (bool change_focus) {
164 if (this.searchcontext == null) {
168 Gtk.TextIter beg, st,en;
169 bool has_wrapped_around;
170 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );
172 if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {
173 this.last_search_end = 0;
175 this.last_search_end = en.get_offset();
177 this.view.el.grab_focus();
179 this.buffer.el.place_cursor(st);
180 this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);
184 public string tempFileContents () {
187 if (_this.file == null) {
190 var str= this.buffer.toString();
191 if (_this.file.xtype == "PlainFile") {
199 GLib.debug("calling validate");
200 // clear the buttons.
201 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
202 return this.file.toSource(); ;
205 var oldcode = _this.prop.val;
206 _this.prop.val = str;
207 var ret = _this.file.toSource();
208 _this.prop.val = oldcode;
212 public void reset () {
217 this.searchcontext = null;
220 public int search (string in_txt) {
222 var s = new GtkSource.SearchSettings();
223 s.case_sensitive = _this.case_sensitive.el.active;
224 s.regex_enabled = _this.regex.el.active;
225 s.wrap_around = false;
227 this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);
228 this.searchcontext.set_highlight(true);
231 if (_this.multiline.el.active) {
232 txt = in_txt.replace("\\n", "\n");
235 s.set_search_text(txt);
236 Gtk.TextIter beg, st,en;
238 this.buffer.el.get_start_iter(out beg);
239 bool has_wrapped_around;
240 this.searchcontext.forward(beg, out st, out en, out has_wrapped_around);
241 this.last_search_end = 0;
243 return this.searchcontext.get_occurrences_count();
249 public void updateErrorMarks () {
253 var buf = _this.buffer.el;
256 buf.get_bounds (out start, out end);
261 //GLib.debug("highlight errors");
263 // we should highlight other types of errors..
265 if (_this.window.windowstate.state != WindowState.State.CODEONLY
267 _this.window.windowstate.state != WindowState.State.CODE
269 //GLib.debug("windowstate != CODEONLY?");
275 if (_this.file == null) {
276 GLib.debug("file is null?");
280 var ar = this.file.getErrors();
282 buf.remove_source_marks (start, end, "ERR");
283 buf.remove_source_marks (start, end, "WARN");
284 buf.remove_source_marks (start, end, "DEPR");
285 buf.remove_tag_by_name ("ERR", start, end);
286 buf.remove_tag_by_name ("WARN", start, end);
287 buf.remove_tag_by_name ("DEPR", start, end);
288 this.last_error_counter = file.error_counter ;
289 //GLib.debug("highlight %s : %s has no errors", this.file.relpath, category);
294 // basicaly check if there is no change, then we do not do any update..
295 // we can do this by just using an error counter?
296 // if that's changed then we will do an update, otherwise dont bother.
302 var tlines = buf.get_line_count () +1;
304 if (_this.prop != null) {
305 // this still seems flaky...
307 tlines = _this.prop.end_line;
308 offset = _this.prop.start_line;
309 hoffset = _this.node.node_pad.length + 2; //shift it left by 2 ? ..
314 if (this.last_error_counter == file.error_counter) {
320 buf.remove_source_marks (start, end, "ERR");
321 buf.remove_source_marks (start, end, "WARN");
322 buf.remove_source_marks (start, end, "DEPR");
323 buf.remove_tag_by_name ("ERR", start, end);
324 buf.remove_tag_by_name ("WARN", start, end);
325 buf.remove_tag_by_name ("DEPR", start, end);
327 foreach(var diag in ar) {
329 // print("get inter\n");
330 var eline = (int)diag.range.start.line - offset;
331 var eline_to = (int)diag.range.end.line - offset;
332 //var eline = diag.range.end_line - offset;
333 //GLib.debug("GOT ERROR on line %d -- converted to %d (offset = %d)",
334 // err.line ,eline, offset);
337 if (eline > tlines || eline < 0) {
341 buf.get_iter_at_line( out iter, eline);
342 var msg = "Line: %d %s : %s".printf(eline+1, diag.category, diag.message);
343 buf.create_source_mark( msg, diag.category, iter);
345 var spos = (int)diag.range.start.character - hoffset;
346 if (spos < 0) { spos =0 ; }
347 if (spos > iter.get_chars_in_line()) {
348 spos = iter.get_chars_in_line();
350 buf.get_iter_at_line( out iter, eline_to);
351 var epos = (int)diag.range.end.character - hoffset;
352 if (epos < 0) { epos =0 ; }
353 if (epos > iter.get_chars_in_line()) {
354 epos = iter.get_chars_in_line();
358 buf.get_iter_at_line_offset( out start, eline, spos);
360 buf.get_iter_at_line_offset( out end, eline_to,epos);
362 buf.apply_tag_by_name(diag.category, start, end);
364 // GLib.debug("set line %d to %s", eline, msg);
365 //this.marks.set(eline, msg);
367 this.last_error_counter = file.error_counter ;
374 public void scroll_to_line (int line) {
376 GLib.Timeout.add(500, () => {
378 var buf = this.view.el.get_buffer();
380 var sbuf = (GtkSource.Buffer) buf;
384 sbuf.get_iter_at_line(out iter, line);
385 this.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
389 public class Xcls_Box1 : Object
392 private Editor _this;
398 public Xcls_Box1(Editor _owner )
401 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
405 // set gobject values
406 this.el.homogeneous = false;
407 this.el.hexpand = true;
408 new Xcls_save_button( _this );
409 this.el.append( _this.save_button.el );
410 var child_2 = new Xcls_Label3( _this );
413 this.el.append( child_2.el );
414 var child_3 = new Xcls_Scale4( _this );
417 this.el.append( child_3.el );
418 new Xcls_close_btn( _this );
419 this.el.append( _this.close_btn.el );
422 // user defined functions
424 public class Xcls_save_button : Object
426 public Gtk.Button el;
427 private Editor _this;
433 public Xcls_save_button(Editor _owner )
436 _this.save_button = this;
437 this.el = new Gtk.Button();
441 // set gobject values
442 this.el.label = "Save";
445 this.el.clicked.connect( () => {
446 _this.saveContents();
450 // user defined functions
453 public class Xcls_Label3 : Object
456 private Editor _this;
462 public Xcls_Label3(Editor _owner )
465 this.el = new Gtk.Label( null );
469 // set gobject values
470 this.el.hexpand = true;
473 // user defined functions
476 public class Xcls_Scale4 : Object
479 private Editor _this;
485 public Xcls_Scale4(Editor _owner )
488 this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1);
492 // set gobject values
493 this.el.width_request = 200;
494 this.el.has_origin = true;
495 this.el.draw_value = false;
497 this.el.sensitive = true;
502 //this.el.set_range(6,30);
503 this.el.set_value ( BuilderApplication.settings.editor_font_size);
504 BuilderApplication.settings.editor_font_size_updated.connect(
506 BuilderApplication.settings.editor_font_size_inchange = true;
507 GLib.debug("update range");
508 this.el.set_value (BuilderApplication.settings.editor_font_size);
509 BuilderApplication.settings.editor_font_size_inchange = false;
517 this.el.change_value.connect( (st, val ) => {
518 if (BuilderApplication.settings.editor_font_size_inchange) {
521 BuilderApplication.settings.editor_font_size = val;
526 // user defined functions
529 public class Xcls_close_btn : Object
531 public Gtk.Button el;
532 private Editor _this;
538 public Xcls_close_btn(Editor _owner )
541 _this.close_btn = this;
542 this.el = new Gtk.Button();
546 // set gobject values
547 this.el.icon_name = "window-close";
548 var child_1 = new Xcls_Image6( _this );
550 this.el.child = child_1.el;
553 this.el.clicked.connect( () => {
554 _this.saveContents();
555 _this.window.windowstate.switchState(WindowState.State.PREVIEW);
559 // user defined functions
561 public class Xcls_Image6 : Object
564 private Editor _this;
570 public Xcls_Image6(Editor _owner )
573 this.el = new Gtk.Image();
577 // set gobject values
578 this.el.icon_name = "window-close";
579 this.el.icon_size = Gtk.IconSize.NORMAL;
582 // user defined functions
587 public class Xcls_RightEditor : Object
589 public Gtk.ScrolledWindow el;
590 private Editor _this;
596 public Xcls_RightEditor(Editor _owner )
599 _this.RightEditor = this;
600 this.el = new Gtk.ScrolledWindow();
604 // set gobject values
605 this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
606 this.el.vexpand = true;
607 this.el.overlay_scrolling = false;
608 this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
609 new Xcls_view( _this );
610 this.el.child = _this.view.el;
613 // user defined functions
615 public class Xcls_view : Object
617 public GtkSource.View el;
618 private Editor _this;
622 public Gtk.CssProvider css;
625 public Xcls_view(Editor _owner )
629 this.el = new GtkSource.View();
634 // set gobject values
635 this.el.auto_indent = true;
636 this.el.indent_width = 4;
637 this.el.name = "editor-view";
638 this.el.show_line_marks = true;
639 this.el.insert_spaces_instead_of_tabs = true;
640 this.el.show_line_numbers = true;
641 this.el.hexpand = true;
642 this.el.vexpand = true;
643 this.el.has_tooltip = true;
644 this.el.css_classes = { "code-editor" };
645 this.el.tab_width = 4;
646 this.el.highlight_current_line = true;
647 new Xcls_buffer( _this );
648 this.el.buffer = _this.buffer.el;
649 var child_2 = new Xcls_EventControllerKey10( _this );
652 this.el.add_controller( child_2.el );
656 this.el.completion.add_provider(
657 new Palete.CompletionProvider(_this)
660 //this.el.completion.unblock_interactive();
661 this.el.completion.select_on_show = true; // select
662 //this.el.completion.remember_info_visibility = true;
665 var attrs = new GtkSource.MarkAttributes();
667 attrs.set_icon_name ( "process-stop");
668 attrs.query_tooltip_text.connect(( mark) => {
669 GLib.debug("tooltip query? %s", mark.name);
670 return strdup( mark.name);
672 attrs.query_tooltip_markup.connect(( mark) => {
673 GLib.debug("tooltip query? %s", mark.name);
674 return strdup( mark.name);
676 this.el.set_mark_attributes ("ERR", attrs, 1);
680 var wattrs = new GtkSource.MarkAttributes();
681 wattrs.set_icon_name ( "process-stop");
682 wattrs.query_tooltip_text.connect(( mark) => {
683 GLib.debug("tooltip query? %s", mark.name);
684 return strdup(mark.name);
686 wattrs.query_tooltip_markup.connect(( mark) => {
687 GLib.debug("tooltip query? %s", mark.name);
688 return strdup(mark.name);
690 this.el.set_mark_attributes ("WARN", wattrs, 1);
694 var dattrs = new GtkSource.MarkAttributes();
696 dattrs.set_icon_name ( "process-stop");
698 dattrs.query_tooltip_text.connect(( mark) => {
699 GLib.debug("tooltip query? %s", mark.name);
700 return strdup(mark.name);
702 //dattrs.query_tooltip_markup.connect(( mark) => {
703 // GLib.debug("tooltip query? %s", mark.name);
704 // return strdup(mark.name);
706 this.el.set_mark_attributes ("DEPR", dattrs, 1);
709 this.el.get_space_drawer().set_matrix(null);
710 this.el.get_space_drawer().set_types_for_locations(
711 GtkSource.SpaceLocationFlags.ALL,
712 GtkSource.SpaceTypeFlags.ALL
714 this.el.get_space_drawer().set_enable_matrix(true);
717 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
719 //GLib.debug("query tooltip");
723 var yoff = (int) _this.RightEditor.el.vadjustment.value;
725 // I think this is problematic - if it's compliing / updating at same time as query.
727 //if (_this.window.statusbar_compile_spinner.el.spinning) {
731 this.el.get_iter_at_position (out iter, out trailing, x, y + yoff);
733 var l = iter.get_line();
737 // GLib.debug("query tooltip line %d", (int) l);
743 if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {
744 GLib.debug("line %d setting tip to %s", l, _this.buffer.marks.get(l));
745 tooltip.set_text(_this.buffer.marks.get(l).dup());
753 // this crashes?? - not sure why.
754 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
755 if (marks.is_empty()) {
756 marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
758 if (marks.is_empty()) {
759 marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
762 // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length());
764 marks.@foreach((m) => {
765 //GLib.debug("got mark %s", m.name);
766 str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name;
768 // true if there is a mark..
769 if (str.length > 0 ) {
770 tooltip.set_text( str );
772 return str.length > 0 ? true : false;
777 // user defined functions
778 public void load (string str) {
780 // show the help page for the active node..
781 //this.get('/Help').show();
783 // this.get('/BottomPane').el.set_current_page(0);
784 GLib.debug("load called - Reset undo buffer");
786 var buf = (GtkSource.Buffer)this.el.get_buffer();
787 buf.begin_irreversible_action();
788 buf.set_text(str, str.length);
789 buf.end_irreversible_action();
791 var lm = GtkSource.LanguageManager.get_default();
793 if (_this.file != null) {
794 lang = _this.file.language;
796 print("lang=%s, content_type = %s\n", lang, _this.file.content_type);
797 var lg = _this.file.content_type.length > 0 ?
798 lm.guess_language(_this.file.path, _this.file.content_type) :
799 lm.get_language(lang);
802 ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg);
804 this.el.insert_spaces_instead_of_tabs = true;
806 print("sourcelanguage = %s\n", lg.name);
807 if (lg.name == "Vala") {
808 this.el.insert_spaces_instead_of_tabs = false;
812 this.el.grab_focus();
813 _this.save_button.el.sensitive = false;
814 _this.last_error_counter = -1;
817 public class Xcls_buffer : Object
819 public GtkSource.Buffer el;
820 private Editor _this;
824 public int error_line;
825 public Gee.HashMap<int,string>? xmarks;
826 public bool check_queued;
829 public Xcls_buffer(Editor _owner )
833 this.el = new GtkSource.Buffer( null );
836 this.error_line = -1;
838 this.check_queued = false;
840 // set gobject values
841 this.el.highlight_syntax = true;
842 this.el.highlight_matching_brackets = true;
843 this.el.enable_undo = true;
848 buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
849 buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
850 buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
851 buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
852 buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
853 buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
854 buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
855 buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
858 buf.create_tag ("ERR", "weight", Pango.Weight.BOLD, "background", "pink");
859 buf.create_tag ("WARN", "weight", Pango.Weight.BOLD, "background", "#ABF4EB");
860 buf.create_tag ("DEPR", "weight", Pango.Weight.BOLD, "background", "#EEA9FF");
863 this.el.changed.connect( () => {
866 _this.save_button.el.sensitive = true;
867 print("EDITOR CHANGED");
872 // this.get('/LeftPanel.model').changed( str , false);
877 // user defined functions
878 public bool OLDhighlightErrorsJson (string type, Json.Object obj) {
881 this.el.get_bounds (out start, out end);
883 this.el.remove_source_marks (start, end, type);
884 GLib.debug("highlight errors");
886 // we should highlight other types of errors..
888 if (!obj.has_member(type)) {
889 GLib.debug("Return has no errors\n");
893 if (_this.window.windowstate.state != WindowState.State.CODEONLY
895 _this.window.windowstate.state != WindowState.State.CODE
897 GLib.debug("windowstate != CODEONLY?");
902 //this.marks = new Gee.HashMap<int,string>();
903 var err = obj.get_object_member(type);
905 if (_this.file == null) {
906 GLib.debug("file is null?");
910 var valafn = _this.file.path;
912 if (_this.file.xtype != "PlainFile") {
916 var regex = new Regex("\\.bjs$");
918 valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
919 } catch (GLib.RegexError e) {
926 if (!err.has_member(valafn)) {
927 GLib.debug("File path has no errors");
931 var lines = err.get_object_member(valafn);
934 if (obj.has_member("line_offset")) { // ?? why??
935 offset = (int)obj.get_int_member("line_offset") + 1;
939 var tlines = this.el.get_line_count () +1;
941 if (_this.prop != null) {
943 tlines = _this.prop.end_line + 1;
944 offset = _this.prop.start_line + 1;
950 lines.foreach_member((obj, line, node) => {
953 // print("get inter\n");
954 var eline = int.parse(line) - offset;
955 GLib.debug("GOT ERROR on line %s -- converted to %d (offset = %d)\n", line,eline, offset);
958 if (eline > tlines || eline < 0) {
963 this.el.get_iter_at_line( out iter, eline);
964 //print("mark line\n");
966 var ar = lines.get_array_member(line);
967 for (var i = 0 ; i < ar.get_length(); i++) {
968 if (ar.get_string_element(i) == "Success") {
971 msg += (msg.length > 0) ? "\n" : "";
972 msg += ar.get_string_element(i);
977 msg = "Line: %d".printf(eline+1) + " " + msg;
978 this.el.create_source_mark(msg, type, iter);
979 GLib.debug("set line %d to %m", eline, msg);
980 // this.marks.set(eline, msg);
989 public bool checkSyntax () {
992 var str = this.toString();
995 if (this.error_line > 0) {
998 this.el.get_bounds (out start, out end);
1000 this.el.remove_source_marks (start, end, null);
1002 if (str.length < 1) {
1003 print("checkSyntax - empty string?\n");
1008 if (_this.file.xtype == "PlainFile") {
1010 // assume it's gtk...
1011 var oldcode =_this.file.toSource();
1012 _this.file.setSource(str);
1013 BuilderApplication.showSpinner("appointment soon","document change pending");
1014 _this.file.getLanguageServer().document_change(_this.file);
1016 _this.file.setSource(oldcode);
1022 if (_this.file == null) {
1030 GLib.debug("calling validate");
1031 // clear the buttons.
1032 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
1035 var oldcode = _this.prop.val;
1037 _this.prop.val = str;
1038 _this.node.updated_count++;
1039 _this.file.getLanguageServer().document_change(_this.file);
1040 _this.node.updated_count++;
1041 _this.prop.val = oldcode;
1044 //print("done mark line\n");
1046 return true; // at present allow saving - even if it's invalid..
1048 public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
1050 this.error_line = validate_res.size;
1052 if (this.error_line < 1) {
1055 var tlines = this.el.get_line_count ();
1057 var valiter = validate_res.map_iterator();
1058 while (valiter.next()) {
1060 // print("get inter\n");
1061 var eline = valiter.get_key();
1062 if (eline > tlines) {
1065 this.el.get_iter_at_line( out iter, eline);
1066 //print("mark line\n");
1067 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
1071 public string toString () {
1075 this.el.get_start_iter(out s);
1076 this.el.get_end_iter(out e);
1077 var ret = this.el.get_text(s,e,true);
1078 //print("TO STRING? " + ret);
1083 public class Xcls_EventControllerKey10 : Object
1085 public Gtk.EventControllerKey el;
1086 private Editor _this;
1092 public Xcls_EventControllerKey10(Editor _owner )
1095 this.el = new Gtk.EventControllerKey();
1099 // set gobject values
1102 this.el.key_released.connect( (keyval, keycode, state) => {
1105 if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1106 GLib.debug("SAVE: ctrl-S pressed");
1107 _this.saveContents();
1111 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1112 GLib.debug("SAVE: ctrl-g pressed");
1113 _this.forwardSearch(true);
1116 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1117 GLib.debug("SAVE: ctrl-f pressed");
1118 _this.search_entry.el.grab_focus();
1119 _this.search_entry.el.select_region(0,-1);
1122 if (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1123 _this.view.el.show_completion();
1127 _this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);
1128 var line = iter.get_line();
1129 var offset = iter.get_line_offset();
1130 GLib.debug("line %d off %d", line ,offset);
1131 if (_this.prop != null) {
1132 line += _this.prop.start_line + 1; // i think..
1133 offset += 12; // should probably be 8 without namespaced
1134 GLib.debug("guess line %d off %d", line ,offset);
1136 //_this.view.el.show_completion();
1137 // print(event.key.keyval)
1148 // user defined functions
1153 public class Xcls_Box11 : Object
1156 private Editor _this;
1162 public Xcls_Box11(Editor _owner )
1165 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1169 // set gobject values
1170 this.el.homogeneous = false;
1171 this.el.vexpand = false;
1172 new Xcls_search_entry( _this );
1173 this.el.append( _this.search_entry.el );
1174 new Xcls_search_results( _this );
1175 this.el.append( _this.search_results.el );
1176 new Xcls_nextBtn( _this );
1177 this.el.append( _this.nextBtn.el );
1178 new Xcls_backBtn( _this );
1179 this.el.append( _this.backBtn.el );
1180 var child_5 = new Xcls_MenuButton17( _this );
1183 this.el.append( child_5.el );
1186 // user defined functions
1188 public class Xcls_search_entry : Object
1190 public Gtk.SearchEntry el;
1191 private Editor _this;
1195 public Gtk.CssProvider css;
1198 public Xcls_search_entry(Editor _owner )
1201 _this.search_entry = this;
1202 this.el = new Gtk.SearchEntry();
1206 // set gobject values
1207 this.el.name = "editor-search-entry";
1208 this.el.hexpand = true;
1209 this.el.placeholder_text = "Press enter to search";
1210 this.el.search_delay = 3;
1211 var child_1 = new Xcls_EventControllerKey13( _this );
1214 this.el.add_controller( child_1.el );
1217 this.el.search_changed.connect( ( ) => {
1219 _this.search(_this.search_entry.el.text);
1220 _this.search_results.updateResults();
1222 GLib.Timeout.add_seconds(1,() => {
1223 _this.search_results.updateResults();
1229 // user defined functions
1230 public void forwardSearch (bool change_focus) {
1233 _this.forwardSearch(change_focus);
1237 switch(_this.windowstate.state) {
1238 case WindowState.State.CODEONLY:
1239 //case WindowState.State.CODE:
1240 // search the code being edited..
1241 _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1244 case WindowState.State.PREVIEW:
1245 if (_this.windowstate.file.xtype == "Gtk") {
1246 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1248 _this.windowstate.window_rooview.forwardSearch(change_focus);
1257 public class Xcls_EventControllerKey13 : Object
1259 public Gtk.EventControllerKey el;
1260 private Editor _this;
1266 public Xcls_EventControllerKey13(Editor _owner )
1269 this.el = new Gtk.EventControllerKey();
1273 // set gobject values
1276 this.el.key_pressed.connect( (keyval, keycode, state) => {
1278 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1279 GLib.debug("SAVE: ctrl-g pressed");
1280 _this.forwardSearch(true);
1285 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1286 _this.forwardSearch(true);
1292 // print(event.key.keyval)
1298 // user defined functions
1302 public class Xcls_search_results : Object
1304 public Gtk.Label el;
1305 private Editor _this;
1311 public Xcls_search_results(Editor _owner )
1314 _this.search_results = this;
1315 this.el = new Gtk.Label( "No Results" );
1319 // set gobject values
1320 this.el.margin_end = 4;
1321 this.el.margin_start = 4;
1324 // user defined functions
1325 public void updateResults () {
1326 this.el.visible = true;
1328 var res = _this.searchcontext.get_occurrences_count();
1330 _this.search_results.el.label = "??? Matches";
1334 _this.nextBtn.el.sensitive = false;
1335 _this.backBtn.el.sensitive = false;
1338 _this.search_results.el.label = "%d Matches".printf(res);
1339 _this.nextBtn.el.sensitive = true;
1340 _this.backBtn.el.sensitive = true;
1343 _this.search_results.el.label = "No Matches";
1348 public class Xcls_nextBtn : Object
1350 public Gtk.Button el;
1351 private Editor _this;
1355 public bool always_show_image;
1358 public Xcls_nextBtn(Editor _owner )
1361 _this.nextBtn = this;
1362 this.el = new Gtk.Button();
1365 this.always_show_image = true;
1367 // set gobject values
1368 this.el.icon_name = "go-down";
1369 this.el.sensitive = false;
1372 this.el.clicked.connect( (event) => {
1374 _this.forwardSearch(true);
1380 // user defined functions
1383 public class Xcls_backBtn : Object
1385 public Gtk.Button el;
1386 private Editor _this;
1390 public bool always_show_image;
1393 public Xcls_backBtn(Editor _owner )
1396 _this.backBtn = this;
1397 this.el = new Gtk.Button();
1400 this.always_show_image = true;
1402 // set gobject values
1403 this.el.icon_name = "go-up";
1404 this.el.sensitive = false;
1407 this.el.clicked.connect( (event) => {
1409 _this.backSearch(true);
1414 // user defined functions
1417 public class Xcls_MenuButton17 : Object
1419 public Gtk.MenuButton el;
1420 private Editor _this;
1424 public bool always_show_image;
1427 public Xcls_MenuButton17(Editor _owner )
1430 this.el = new Gtk.MenuButton();
1433 this.always_show_image = true;
1435 // set gobject values
1436 this.el.icon_name = "emblem-system";
1437 this.el.always_show_arrow = true;
1438 new Xcls_search_settings( _this );
1439 this.el.popover = _this.search_settings.el;
1442 // user defined functions
1444 public class Xcls_search_settings : Object
1446 public Gtk.Popover el;
1447 private Editor _this;
1453 public Xcls_search_settings(Editor _owner )
1456 _this.search_settings = this;
1457 this.el = new Gtk.Popover();
1461 // set gobject values
1462 var child_1 = new Xcls_Box19( _this );
1464 this.el.child = child_1.el;
1467 // user defined functions
1469 public class Xcls_Box19 : Object
1472 private Editor _this;
1478 public Xcls_Box19(Editor _owner )
1481 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1485 // set gobject values
1486 new Xcls_case_sensitive( _this );
1487 this.el.append( _this.case_sensitive.el );
1488 new Xcls_regex( _this );
1489 this.el.append( _this.regex.el );
1490 new Xcls_multiline( _this );
1491 this.el.append( _this.multiline.el );
1494 // user defined functions
1496 public class Xcls_case_sensitive : Object
1498 public Gtk.CheckButton el;
1499 private Editor _this;
1505 public Xcls_case_sensitive(Editor _owner )
1508 _this.case_sensitive = this;
1509 this.el = new Gtk.CheckButton();
1513 // set gobject values
1514 this.el.label = "Case Sensitive";
1523 // user defined functions
1526 public class Xcls_regex : Object
1528 public Gtk.CheckButton el;
1529 private Editor _this;
1535 public Xcls_regex(Editor _owner )
1539 this.el = new Gtk.CheckButton();
1543 // set gobject values
1544 this.el.label = "Regex";
1553 // user defined functions
1556 public class Xcls_multiline : Object
1558 public Gtk.CheckButton el;
1559 private Editor _this;
1565 public Xcls_multiline(Editor _owner )
1568 _this.multiline = this;
1569 this.el = new Gtk.CheckButton();
1573 // set gobject values
1574 this.el.label = "Multi-line (add \\n)";
1577 // user defined functions