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 GtkSource.SearchContext searchcontext;
36 public int last_search_end;
37 public signal void save ();
38 public JsRender.JsRender? file;
39 public JsRender.Node node;
40 public JsRender.NodeProp? prop;
41 public string activeEditor;
47 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
53 this.searchcontext = null;
54 this.last_search_end = 0;
58 this.activeEditor = "";
61 this.el.homogeneous = false;
62 this.el.hexpand = true;
63 this.el.vexpand = true;
64 var child_1 = new Xcls_Box2( _this );
66 this.el.append( child_1.el );
67 new Xcls_RightEditor( _this );
68 this.el.append( _this.RightEditor.el );
69 var child_3 = new Xcls_Box12( _this );
71 this.el.append ( child_3.el );
74 // user defined functions
75 public bool saveContents () {
78 if (_this.file == null) {
84 var str = _this.buffer.toString();
86 _this.buffer.checkSyntax();
90 // LeftPanel.model.changed( str , false);
92 _this.save_button.el.sensitive = false;
94 // find the text for the node..
95 if (_this.file.xtype != "PlainFile") {
96 // in theory these properties have to exist!?!
98 //this.window.windowstate.left_props.reload();
100 _this.file.setSource( str );
109 public void forwardSearch (bool change_focus) {
111 if (this.searchcontext == null) {
115 Gtk.TextIter beg, st,en;
116 bool has_wrapped_around;
117 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end);
118 if (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {
120 this.last_search_end = 0; // not sure if this should happen
122 if (has_wrapped_around) {
126 this.last_search_end = en.get_offset();
128 this.view.el.grab_focus();
130 this.buffer.el.place_cursor(st);
131 this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);
135 public void show (JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)
140 if (file.xtype != "PlainFile") {
144 // find the text for the node..
145 this.view.load( prop.val );
148 this.close_btn.el.show();
151 this.view.load( file.toSource() );
152 this.close_btn.el.hide();
156 public void backSearch (bool change_focus) {
158 if (this.searchcontext == null) {
162 Gtk.TextIter beg, st,en;
163 bool has_wrapped_around;
164 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );
166 if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {
167 this.last_search_end = 0;
169 this.last_search_end = en.get_offset();
171 this.view.el.grab_focus();
173 this.buffer.el.place_cursor(st);
174 this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);
178 public string tempFileContents () {
181 if (_this.file == null) {
184 var str= this.buffer.toString();
185 if (_this.file.xtype == "PlainFile") {
193 GLib.debug("calling validate");
194 // clear the buttons.
195 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
196 return this.file.toSource(); ;
199 var oldcode = _this.prop.val;
200 _this.prop.val = str;
201 var ret = _this.file.toSource();
202 _this.prop.val = oldcode;
206 public void reset () {
211 this.searchcontext = null;
214 public int search (string in_txt) {
216 var s = new GtkSource.SearchSettings();
217 s.case_sensitive = _this.case_sensitive.el.active;
218 s.regex_enabled = _this.regex.el.active;
219 s.wrap_around = false;
221 this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);
222 this.searchcontext.set_highlight(true);
225 if (_this.multiline.el.active) {
226 txt = in_txt.replace("\\n", "\n");
229 s.set_search_text(txt);
230 Gtk.TextIter beg, st,en;
232 this.buffer.el.get_start_iter(out beg);
233 bool has_wrapped_around;
234 this.searchcontext.forward(beg, out st, out en, out has_wrapped_around);
235 this.last_search_end = 0;
237 return this.searchcontext.get_occurrences_count();
243 public void updateErrorMarks (string category) {
247 var buf = _this.buffer.el;
250 buf.get_bounds (out start, out end);
252 buf.remove_source_marks (start, end, category);
254 //GLib.debug("highlight errors");
256 // we should highlight other types of errors..
258 if (_this.window.windowstate.state != WindowState.State.CODEONLY
260 _this.window.windowstate.state != WindowState.State.CODE
262 //GLib.debug("windowstate != CODEONLY?");
268 if (_this.file == null) {
269 GLib.debug("file is null?");
273 var ar = this.file.getErrors(category);
274 if (ar == null || ar.get_n_items() < 1) {
275 //GLib.debug("highlight %s : %s has no errors", this.file.relpath, category);
285 var tlines = buf.get_line_count () +1;
287 if (_this.prop != null) {
288 // this still seems flaky...
290 tlines = _this.prop.end_line;
291 offset = _this.prop.start_line;
295 for (var i = 0; i < ar.get_n_items();i++) {
296 var err = (Palete.CompileError) ar.get_item(i);
299 // print("get inter\n");
300 var eline = err.line - offset;
301 //GLib.debug("GOT ERROR on line %d -- converted to %d (offset = %d)",
302 // err.line ,eline, offset);
305 if (eline > tlines || eline < 0) {
310 buf.get_iter_at_line( out iter, eline);
313 var msg = "Line: %d %s : %s".printf(eline+1, err.category, err.msg);
314 buf.create_source_mark( msg, err.category, iter);
315 // GLib.debug("set line %d to %s", eline, msg);
316 //this.marks.set(eline, msg);
325 public void scroll_to_line (int line) {
327 GLib.Timeout.add(500, () => {
329 var buf = this.view.el.get_buffer();
331 var sbuf = (GtkSource.Buffer) buf;
335 sbuf.get_iter_at_line(out iter, line);
336 this.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
340 public class Xcls_Box2 : Object
343 private Editor _this;
349 public Xcls_Box2(Editor _owner )
352 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
356 // set gobject values
357 this.el.homogeneous = false;
358 this.el.hexpand = true;
359 new Xcls_save_button( _this );
360 this.el.append( _this.save_button.el );
361 var child_2 = new Xcls_Label4( _this );
363 this.el.append( child_2.el );
364 var child_3 = new Xcls_Scale5( _this );
366 this.el.append( child_3.el );
367 new Xcls_close_btn( _this );
368 this.el.append( _this.close_btn.el );
371 // user defined functions
373 public class Xcls_save_button : Object
375 public Gtk.Button el;
376 private Editor _this;
382 public Xcls_save_button(Editor _owner )
385 _this.save_button = this;
386 this.el = new Gtk.Button();
390 // set gobject values
391 this.el.label = "Save";
394 this.el.clicked.connect( () => {
395 _this.saveContents();
399 // user defined functions
402 public class Xcls_Label4 : Object
405 private Editor _this;
411 public Xcls_Label4(Editor _owner )
414 this.el = new Gtk.Label( null );
418 // set gobject values
419 this.el.hexpand = true;
422 // user defined functions
425 public class Xcls_Scale5 : Object
428 private Editor _this;
434 public Xcls_Scale5(Editor _owner )
437 this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1);
441 // set gobject values
442 this.el.width_request = 200;
443 this.el.has_origin = true;
444 this.el.draw_value = false;
446 this.el.sensitive = true;
451 this.el.set_range(6,30);
452 this.el.set_value(8);
456 this.el.change_value.connect( (st, val ) => {
459 _this.view.css.load_from_string(
460 "#editor-view { font: %dpx monospace; }".printf((int)val)
467 // user defined functions
470 public class Xcls_close_btn : Object
472 public Gtk.Button el;
473 private Editor _this;
479 public Xcls_close_btn(Editor _owner )
482 _this.close_btn = this;
483 this.el = new Gtk.Button();
487 // set gobject values
488 this.el.icon_name = "window-close";
489 var child_1 = new Xcls_Image7( _this );
490 this.el.child = child_1.el;
493 this.el.clicked.connect( () => {
494 _this.saveContents();
495 _this.window.windowstate.switchState(WindowState.State.PREVIEW);
499 // user defined functions
501 public class Xcls_Image7 : Object
504 private Editor _this;
510 public Xcls_Image7(Editor _owner )
513 this.el = new Gtk.Image();
517 // set gobject values
518 this.el.icon_name = "window-close";
519 this.el.icon_size = Gtk.IconSize.NORMAL;
522 // user defined functions
527 public class Xcls_RightEditor : Object
529 public Gtk.ScrolledWindow el;
530 private Editor _this;
536 public Xcls_RightEditor(Editor _owner )
539 _this.RightEditor = this;
540 this.el = new Gtk.ScrolledWindow();
544 // set gobject values
545 this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
546 this.el.vexpand = true;
547 this.el.overlay_scrolling = false;
548 this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
549 new Xcls_view( _this );
550 this.el.child = _this.view.el;
553 // user defined functions
555 public class Xcls_view : Object
557 public GtkSource.View el;
558 private Editor _this;
562 public Gtk.CssProvider css;
565 public Xcls_view(Editor _owner )
569 this.el = new GtkSource.View();
574 // set gobject values
575 this.el.auto_indent = true;
576 this.el.indent_width = 4;
577 this.el.name = "editor-view";
578 this.el.show_line_marks = true;
579 this.el.insert_spaces_instead_of_tabs = true;
580 this.el.show_line_numbers = true;
581 this.el.hexpand = true;
582 this.el.vexpand = true;
583 this.el.has_tooltip = true;
584 this.el.tab_width = 4;
585 this.el.highlight_current_line = true;
586 new Xcls_buffer( _this );
587 this.el.buffer = _this.buffer.el;
588 var child_2 = new Xcls_EventControllerKey11( _this );
590 this.el.add_controller( child_2.el );
594 this.css = new Gtk.CssProvider();
596 this.css.load_from_string(
597 "#editor-view { font: 12px monospace;}"
600 Gtk.StyleContext.add_provider_for_display(
601 this.el.get_display(),
603 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
609 this is pretty flakey - triggers Gtk with < 0 d
610 var cp = new GtkSource.CompletionWords("test");
611 cp.minimum_word_size = 3;
612 //cp.priority = 100; //?? does this do anything
613 cp.proposals_batch_size = 10;
614 cp.scan_batch_size = 1000;
616 cp.register(_this.buffer.el);
617 this.el.completion.add_provider(cp);
619 this.el.completion.add_provider(new Palete.CompletionProvider(_this));
621 //this.el.completion.unblock_interactive();
622 this.el.completion.select_on_show = true; // select
623 //this.el.completion.remember_info_visibility = true;
626 var attrs = new GtkSource.MarkAttributes();
627 var pink = Gdk.RGBA();
628 pink.parse ( "pink");
629 attrs.set_background ( pink);
630 attrs.set_icon_name ( "process-stop");
631 attrs.query_tooltip_text.connect(( mark) => {
632 GLib.debug("tooltip query? %s", mark.name);
633 return strdup( mark.name);
635 attrs.query_tooltip_markup.connect(( mark) => {
636 GLib.debug("tooltip query? %s", mark.name);
637 return strdup( mark.name);
639 this.el.set_mark_attributes ("ERR", attrs, 1);
641 var wattrs = new GtkSource.MarkAttributes();
642 var blue = Gdk.RGBA();
643 blue.parse ( "#ABF4EB");
644 wattrs.set_background ( blue);
645 wattrs.set_icon_name ( "process-stop");
646 wattrs.query_tooltip_text.connect(( mark) => {
647 GLib.debug("tooltip query? %s", mark.name);
648 return strdup(mark.name);
650 wattrs.query_tooltip_markup.connect(( mark) => {
651 GLib.debug("tooltip query? %s", mark.name);
652 return strdup(mark.name);
654 this.el.set_mark_attributes ("WARN", wattrs, 1);
658 var dattrs = new GtkSource.MarkAttributes();
659 var purple = Gdk.RGBA();
660 purple.parse ( "#EEA9FF");
661 dattrs.set_background ( purple);
662 dattrs.set_icon_name ( "process-stop");
663 dattrs.query_tooltip_text.connect(( mark) => {
664 GLib.debug("tooltip query? %s", mark.name);
665 return strdup(mark.name);
667 dattrs.query_tooltip_markup.connect(( mark) => {
668 GLib.debug("tooltip query? %s", mark.name);
669 return strdup(mark.name);
671 this.el.set_mark_attributes ("DEPR", dattrs, 1);
674 this.el.get_space_drawer().set_matrix(null);
675 this.el.get_space_drawer().set_types_for_locations(
676 GtkSource.SpaceLocationFlags.ALL,
677 GtkSource.SpaceTypeFlags.ALL
679 this.el.get_space_drawer().set_enable_matrix(true);
682 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
684 //GLib.debug("query tooltip");
688 var yoff = (int) _this.RightEditor.el.vadjustment.value;
690 // I think this is problematic - if it's compliing / updating at same time as query.
692 //if (_this.window.statusbar_compile_spinner.el.spinning) {
696 this.el.get_iter_at_position (out iter, out trailing, x, y + yoff);
698 var l = iter.get_line();
702 // GLib.debug("query tooltip line %d", (int) l);
708 if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {
709 GLib.debug("line %d setting tip to %s", l, _this.buffer.marks.get(l));
710 tooltip.set_text(_this.buffer.marks.get(l).dup());
718 // this crashes?? - not sure why.
719 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
720 if (marks.is_empty()) {
721 marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
723 if (marks.is_empty()) {
724 marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
727 // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length());
729 marks.@foreach((m) => {
730 //GLib.debug("got mark %s", m.name);
731 str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name;
733 // true if there is a mark..
734 if (str.length > 0 ) {
735 tooltip.set_text( str );
737 return str.length > 0 ? true : false;
742 // user defined functions
743 public void load (string str) {
745 // show the help page for the active node..
746 //this.get('/Help').show();
748 // this.get('/BottomPane').el.set_current_page(0);
749 GLib.debug("load called - Reset undo buffer");
751 var buf = (GtkSource.Buffer)this.el.get_buffer();
752 buf.begin_irreversible_action();
753 buf.set_text(str, str.length);
754 buf.end_irreversible_action();
756 var lm = GtkSource.LanguageManager.get_default();
758 if (_this.file != null) {
759 lang = _this.file.language;
761 print("lang=%s, content_type = %s\n", lang, _this.file.content_type);
762 var lg = _this.file.content_type.length > 0 ?
763 lm.guess_language(_this.file.path, _this.file.content_type) :
764 lm.get_language(lang);
767 ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg);
769 this.el.insert_spaces_instead_of_tabs = true;
771 print("sourcelanguage = %s\n", lg.name);
772 if (lg.name == "Vala") {
773 this.el.insert_spaces_instead_of_tabs = false;
777 this.el.grab_focus();
778 _this.save_button.el.sensitive = false;
781 public class Xcls_buffer : Object
783 public GtkSource.Buffer el;
784 private Editor _this;
788 public int error_line;
789 public Gee.HashMap<int,string>? xmarks;
790 public bool check_queued;
793 public Xcls_buffer(Editor _owner )
797 this.el = new GtkSource.Buffer( null );
800 this.error_line = -1;
802 this.check_queued = false;
804 // set gobject values
805 this.el.highlight_syntax = true;
806 this.el.highlight_matching_brackets = true;
807 this.el.enable_undo = true;
813 buf.create_tag ("bold", "weight", Pango.Weight.BOLD);
814 buf.create_tag ("type", "weight", Pango.Weight.BOLD, "foreground", "#204a87");
815 buf.create_tag ("keyword", "weight", Pango.Weight.BOLD, "foreground", "#a40000");
816 buf.create_tag ("text", "weight", Pango.Weight.NORMAL, "foreground", "#729fcf");
817 buf.create_tag ("number", "weight", Pango.Weight.BOLD, "foreground", "#ad7fa8");
818 buf.create_tag ("method", "weight", Pango.Weight.BOLD, "foreground", "#729fcf");
819 buf.create_tag ("property", "weight", Pango.Weight.BOLD, "foreground", "#BC1F51");
820 buf.create_tag ("variable", "weight", Pango.Weight.BOLD, "foreground", "#A518B5");
825 this.el.changed.connect( () => {
828 _this.save_button.el.sensitive = true;
829 print("EDITOR CHANGED");
834 // this.get('/LeftPanel.model').changed( str , false);
839 // user defined functions
840 public bool checkSyntax () {
843 var str = this.toString();
846 if (this.error_line > 0) {
849 this.el.get_bounds (out start, out end);
851 this.el.remove_source_marks (start, end, null);
853 if (str.length < 1) {
854 print("checkSyntax - empty string?\n");
859 if (_this.file.xtype == "PlainFile") {
861 // assume it's gtk...
862 var oldcode =_this.file.toSource();
863 _this.file.setSource(str);
864 _this.file.getLanguageServer().document_change(_this.file);
865 BuilderApplication.showSpinner("appointment soon","document change pending");
866 _this.file.setSource(oldcode);
872 if (_this.file == null) {
880 GLib.debug("calling validate");
881 // clear the buttons.
882 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
885 var oldcode = _this.prop.val;
887 _this.prop.val = str;
888 _this.node.updated_count++;
889 _this.file.getLanguageServer().document_change(_this.file);
890 _this.node.updated_count++;
891 _this.prop.val = oldcode;
894 //print("done mark line\n");
896 return true; // at present allow saving - even if it's invalid..
898 public bool highlightErrorsJson (string type, Json.Object obj) {
901 this.el.get_bounds (out start, out end);
903 this.el.remove_source_marks (start, end, type);
904 GLib.debug("highlight errors");
906 // we should highlight other types of errors..
908 if (!obj.has_member(type)) {
909 GLib.debug("Return has no errors\n");
913 if (_this.window.windowstate.state != WindowState.State.CODEONLY
915 _this.window.windowstate.state != WindowState.State.CODE
917 GLib.debug("windowstate != CODEONLY?");
922 //this.marks = new Gee.HashMap<int,string>();
923 var err = obj.get_object_member(type);
925 if (_this.file == null) {
926 GLib.debug("file is null?");
930 var valafn = _this.file.path;
932 if (_this.file.xtype != "PlainFile") {
936 var regex = new Regex("\\.bjs$");
938 valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
939 } catch (GLib.RegexError e) {
946 if (!err.has_member(valafn)) {
947 GLib.debug("File path has no errors");
951 var lines = err.get_object_member(valafn);
954 if (obj.has_member("line_offset")) { // ?? why??
955 offset = (int)obj.get_int_member("line_offset") + 1;
959 var tlines = this.el.get_line_count () +1;
961 if (_this.prop != null) {
963 tlines = _this.prop.end_line + 1;
964 offset = _this.prop.start_line + 1;
970 lines.foreach_member((obj, line, node) => {
973 // print("get inter\n");
974 var eline = int.parse(line) - offset;
975 GLib.debug("GOT ERROR on line %s -- converted to %d (offset = %d)\n", line,eline, offset);
978 if (eline > tlines || eline < 0) {
983 this.el.get_iter_at_line( out iter, eline);
984 //print("mark line\n");
986 var ar = lines.get_array_member(line);
987 for (var i = 0 ; i < ar.get_length(); i++) {
988 if (ar.get_string_element(i) == "Success") {
991 msg += (msg.length > 0) ? "\n" : "";
992 msg += ar.get_string_element(i);
997 msg = "Line: %d".printf(eline+1) + " " + msg;
998 this.el.create_source_mark(msg, type, iter);
999 GLib.debug("set line %d to %m", eline, msg);
1000 // this.marks.set(eline, msg);
1009 public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
1011 this.error_line = validate_res.size;
1013 if (this.error_line < 1) {
1016 var tlines = this.el.get_line_count ();
1018 var valiter = validate_res.map_iterator();
1019 while (valiter.next()) {
1021 // print("get inter\n");
1022 var eline = valiter.get_key();
1023 if (eline > tlines) {
1026 this.el.get_iter_at_line( out iter, eline);
1027 //print("mark line\n");
1028 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
1032 public string toString () {
1036 this.el.get_start_iter(out s);
1037 this.el.get_end_iter(out e);
1038 var ret = this.el.get_text(s,e,true);
1039 //print("TO STRING? " + ret);
1044 public class Xcls_EventControllerKey11 : Object
1046 public Gtk.EventControllerKey el;
1047 private Editor _this;
1053 public Xcls_EventControllerKey11(Editor _owner )
1056 this.el = new Gtk.EventControllerKey();
1060 // set gobject values
1063 this.el.key_released.connect( (keyval, keycode, state) => {
1066 if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1067 GLib.debug("SAVE: ctrl-S pressed");
1068 _this.saveContents();
1072 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1073 GLib.debug("SAVE: ctrl-g pressed");
1074 _this.forwardSearch(true);
1077 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1078 GLib.debug("SAVE: ctrl-f pressed");
1079 _this.search_entry.el.grab_focus();
1080 _this.search_entry.el.select_region(0,-1);
1083 if (keyval == Gdk.Key.space && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1084 _this.view.el.show_completion();
1088 _this.buffer.el.get_iter_at_offset( out iter, _this.buffer.el.cursor_position);
1089 var line = iter.get_line();
1090 var offset = iter.get_line_offset();
1091 GLib.debug("line %d off %d", line ,offset);
1092 if (_this.prop != null) {
1093 line += _this.prop.start_line + 1; // i think..
1094 offset += 12; // should probably be 8 without namespaced
1095 GLib.debug("guess line %d off %d", line ,offset);
1097 //_this.view.el.show_completion();
1098 // print(event.key.keyval)
1109 // user defined functions
1114 public class Xcls_Box12 : Object
1117 private Editor _this;
1123 public Xcls_Box12(Editor _owner )
1126 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1130 // set gobject values
1131 this.el.homogeneous = false;
1132 this.el.vexpand = false;
1133 new Xcls_search_entry( _this );
1134 this.el.append( _this.search_entry.el );
1135 new Xcls_search_results( _this );
1136 this.el.append( _this.search_results.el );
1137 new Xcls_nextBtn( _this );
1138 this.el.append( _this.nextBtn.el );
1139 new Xcls_backBtn( _this );
1140 this.el.append( _this.backBtn.el );
1141 var child_5 = new Xcls_MenuButton18( _this );
1143 this.el.append( child_5.el );
1146 // user defined functions
1148 public class Xcls_search_entry : Object
1150 public Gtk.SearchEntry el;
1151 private Editor _this;
1155 public Gtk.CssProvider css;
1158 public Xcls_search_entry(Editor _owner )
1161 _this.search_entry = this;
1162 this.el = new Gtk.SearchEntry();
1166 // set gobject values
1167 this.el.name = "editor-search-entry";
1168 this.el.hexpand = true;
1169 this.el.placeholder_text = "Press enter to search";
1170 this.el.search_delay = 3;
1171 var child_1 = new Xcls_EventControllerKey14( _this );
1173 this.el.add_controller( child_1.el );
1176 this.el.search_changed.connect( ( ) => {
1178 _this.search(_this.search_entry.el.text);
1179 _this.search_results.updateResults();
1181 GLib.Timeout.add_seconds(1,() => {
1182 _this.search_results.updateResults();
1188 // user defined functions
1189 public void forwardSearch (bool change_focus) {
1192 _this.forwardSearch(change_focus);
1196 switch(_this.windowstate.state) {
1197 case WindowState.State.CODEONLY:
1198 //case WindowState.State.CODE:
1199 // search the code being edited..
1200 _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1203 case WindowState.State.PREVIEW:
1204 if (_this.windowstate.file.xtype == "Gtk") {
1205 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1207 _this.windowstate.window_rooview.forwardSearch(change_focus);
1216 public class Xcls_EventControllerKey14 : Object
1218 public Gtk.EventControllerKey el;
1219 private Editor _this;
1225 public Xcls_EventControllerKey14(Editor _owner )
1228 this.el = new Gtk.EventControllerKey();
1232 // set gobject values
1235 this.el.key_pressed.connect( (keyval, keycode, state) => {
1237 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1238 GLib.debug("SAVE: ctrl-g pressed");
1239 _this.forwardSearch(true);
1244 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1245 _this.forwardSearch(true);
1251 // print(event.key.keyval)
1257 // user defined functions
1261 public class Xcls_search_results : Object
1263 public Gtk.Label el;
1264 private Editor _this;
1270 public Xcls_search_results(Editor _owner )
1273 _this.search_results = this;
1274 this.el = new Gtk.Label( "No Results" );
1278 // set gobject values
1279 this.el.margin_end = 4;
1280 this.el.margin_start = 4;
1283 // user defined functions
1284 public void updateResults () {
1285 this.el.visible = true;
1287 var res = _this.searchcontext.get_occurrences_count();
1289 _this.search_results.el.label = "??? Matches";
1293 _this.nextBtn.el.sensitive = false;
1294 _this.backBtn.el.sensitive = false;
1297 _this.search_results.el.label = "%d Matches".printf(res);
1298 _this.nextBtn.el.sensitive = true;
1299 _this.backBtn.el.sensitive = true;
1302 _this.search_results.el.label = "No Matches";
1307 public class Xcls_nextBtn : Object
1309 public Gtk.Button el;
1310 private Editor _this;
1314 public bool always_show_image;
1317 public Xcls_nextBtn(Editor _owner )
1320 _this.nextBtn = this;
1321 this.el = new Gtk.Button();
1324 this.always_show_image = true;
1326 // set gobject values
1327 this.el.icon_name = "go-down";
1328 this.el.sensitive = false;
1331 this.el.clicked.connect( (event) => {
1333 _this.forwardSearch(true);
1339 // user defined functions
1342 public class Xcls_backBtn : Object
1344 public Gtk.Button el;
1345 private Editor _this;
1349 public bool always_show_image;
1352 public Xcls_backBtn(Editor _owner )
1355 _this.backBtn = this;
1356 this.el = new Gtk.Button();
1359 this.always_show_image = true;
1361 // set gobject values
1362 this.el.icon_name = "go-up";
1363 this.el.sensitive = false;
1366 this.el.clicked.connect( (event) => {
1368 _this.backSearch(true);
1373 // user defined functions
1376 public class Xcls_MenuButton18 : Object
1378 public Gtk.MenuButton el;
1379 private Editor _this;
1383 public bool always_show_image;
1386 public Xcls_MenuButton18(Editor _owner )
1389 this.el = new Gtk.MenuButton();
1392 this.always_show_image = true;
1394 // set gobject values
1395 this.el.icon_name = "emblem-system";
1396 this.el.always_show_arrow = true;
1397 new Xcls_search_settings( _this );
1398 this.el.popover = _this.search_settings.el;
1401 // user defined functions
1403 public class Xcls_search_settings : Object
1405 public Gtk.Popover el;
1406 private Editor _this;
1412 public Xcls_search_settings(Editor _owner )
1415 _this.search_settings = this;
1416 this.el = new Gtk.Popover();
1420 // set gobject values
1421 var child_1 = new Xcls_Box20( _this );
1422 this.el.child = child_1.el;
1425 // user defined functions
1427 public class Xcls_Box20 : Object
1430 private Editor _this;
1436 public Xcls_Box20(Editor _owner )
1439 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1443 // set gobject values
1444 new Xcls_case_sensitive( _this );
1445 this.el.append( _this.case_sensitive.el );
1446 new Xcls_regex( _this );
1447 this.el.append( _this.regex.el );
1448 new Xcls_multiline( _this );
1449 this.el.append( _this.multiline.el );
1452 // user defined functions
1454 public class Xcls_case_sensitive : Object
1456 public Gtk.CheckButton el;
1457 private Editor _this;
1463 public Xcls_case_sensitive(Editor _owner )
1466 _this.case_sensitive = this;
1467 this.el = new Gtk.CheckButton();
1471 // set gobject values
1472 this.el.label = "Case Sensitive";
1481 // user defined functions
1484 public class Xcls_regex : Object
1486 public Gtk.CheckButton el;
1487 private Editor _this;
1493 public Xcls_regex(Editor _owner )
1497 this.el = new Gtk.CheckButton();
1501 // set gobject values
1502 this.el.label = "Regex";
1511 // user defined functions
1514 public class Xcls_multiline : Object
1516 public Gtk.CheckButton el;
1517 private Editor _this;
1523 public Xcls_multiline(Editor _owner )
1526 _this.multiline = this;
1527 this.el = new Gtk.CheckButton();
1531 // set gobject values
1532 this.el.label = "Multi-line (add \\n)";
1535 // user defined functions