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 var child_2 = new Xcls_RightEditor( _this );
69 this.el.append( child_2.el );
70 var child_3 = new Xcls_Box12( _this );
72 this.el.append ( child_3.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 );
149 this.close_btn.el.show();
152 this.view.load( file.toSource() );
153 this.close_btn.el.hide();
157 public void backSearch (bool change_focus) {
159 if (this.searchcontext == null) {
163 Gtk.TextIter beg, st,en;
164 bool has_wrapped_around;
165 this.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );
167 if (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {
168 this.last_search_end = 0;
170 this.last_search_end = en.get_offset();
172 this.view.el.grab_focus();
174 this.buffer.el.place_cursor(st);
175 this.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);
179 public void reset () {
184 this.searchcontext = null;
187 public int search (string in_txt) {
189 var s = new GtkSource.SearchSettings();
190 s.case_sensitive = _this.case_sensitive.el.active;
191 s.regex_enabled = _this.regex.el.active;
192 s.wrap_around = false;
194 this.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);
195 this.searchcontext.set_highlight(true);
198 if (_this.multiline.el.active) {
199 txt = in_txt.replace("\\n", "\n");
202 s.set_search_text(txt);
203 Gtk.TextIter beg, st,en;
205 this.buffer.el.get_start_iter(out beg);
206 bool has_wrapped_around;
207 this.searchcontext.forward(beg, out st, out en, out has_wrapped_around);
208 this.last_search_end = 0;
210 return this.searchcontext.get_occurrences_count();
216 public void updateErrorMarks (string category) {
220 var buf = _this.buffer.el;
223 buf.get_bounds (out start, out end);
225 buf.remove_source_marks (start, end, category);
227 GLib.debug("highlight errors");
229 // we should highlight other types of errors..
231 if (_this.window.windowstate.state != WindowState.State.CODEONLY
233 _this.window.windowstate.state != WindowState.State.CODE
235 GLib.debug("windowstate != CODEONLY?");
241 if (_this.file == null) {
242 GLib.debug("file is null?");
246 var ar = this.file.getErrors(category);
247 if (ar == null || ar.get_n_items() < 1) {
248 GLib.debug("highlight %s : %s has no errors", this.file.relpath, category);
258 var tlines = buf.get_line_count () +1;
260 if (_this.prop != null) {
262 tlines = _this.prop.end_line + 1;
263 offset = _this.prop.start_line + 1;
267 for (var i = 0; i < ar.get_n_items();i++) {
268 var err = (Palete.CompileError) ar.get_item(i);
271 // print("get inter\n");
272 var eline = err.line - offset;
273 GLib.debug("GOT ERROR on line %d -- converted to %d (offset = %d)",
274 err.line ,eline, offset);
277 if (eline > tlines || eline < 0) {
282 buf.get_iter_at_line( out iter, eline);
285 var msg = "Line: %d %s : %s".printf(eline+1, err.category, err.msg);
286 buf.create_source_mark( msg, err.category, iter);
287 GLib.debug("set line %d to %s", eline, msg);
288 //this.marks.set(eline, msg);
297 public void scroll_to_line (int line) {
299 GLib.Timeout.add(500, () => {
301 var buf = this.view.el.get_buffer();
303 var sbuf = (GtkSource.Buffer) buf;
307 sbuf.get_iter_at_line(out iter, line);
308 this.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
312 public class Xcls_Box2 : Object
315 private Editor _this;
321 public Xcls_Box2(Editor _owner )
324 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
328 // set gobject values
329 this.el.homogeneous = false;
330 this.el.hexpand = true;
331 var child_1 = new Xcls_save_button( _this );
333 this.el.append( child_1.el );
334 var child_2 = new Xcls_Label4( _this );
336 this.el.append( child_2.el );
337 var child_3 = new Xcls_Scale5( _this );
339 this.el.append( child_3.el );
340 var child_4 = new Xcls_close_btn( _this );
342 this.el.append( child_4.el );
345 // user defined functions
347 public class Xcls_save_button : Object
349 public Gtk.Button el;
350 private Editor _this;
356 public Xcls_save_button(Editor _owner )
359 _this.save_button = this;
360 this.el = new Gtk.Button();
364 // set gobject values
365 this.el.label = "Save";
368 this.el.clicked.connect( () => {
369 _this.saveContents();
373 // user defined functions
376 public class Xcls_Label4 : Object
379 private Editor _this;
385 public Xcls_Label4(Editor _owner )
388 this.el = new Gtk.Label( null );
392 // set gobject values
393 this.el.hexpand = true;
396 // user defined functions
399 public class Xcls_Scale5 : Object
402 private Editor _this;
408 public Xcls_Scale5(Editor _owner )
411 this.el = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL,6, 30, 1);
415 // set gobject values
416 this.el.width_request = 200;
417 this.el.has_origin = true;
418 this.el.draw_value = false;
420 this.el.sensitive = true;
425 this.el.set_range(6,30);
426 this.el.set_value(8);
430 this.el.change_value.connect( (st, val ) => {
433 _this.view.css.load_from_string(
434 "#editor-view { font: %dpx monospace; }".printf((int)val)
441 // user defined functions
444 public class Xcls_close_btn : Object
446 public Gtk.Button el;
447 private Editor _this;
453 public Xcls_close_btn(Editor _owner )
456 _this.close_btn = this;
457 this.el = new Gtk.Button();
461 // set gobject values
462 this.el.icon_name = "window-close";
463 var child_1 = new Xcls_Image7( _this );
465 this.el.child = child_1.el;
468 this.el.clicked.connect( () => {
469 _this.saveContents();
470 _this.window.windowstate.switchState(WindowState.State.PREVIEW);
474 // user defined functions
476 public class Xcls_Image7 : Object
479 private Editor _this;
485 public Xcls_Image7(Editor _owner )
488 this.el = new Gtk.Image();
492 // set gobject values
493 this.el.icon_name = "window-close";
494 this.el.icon_size = Gtk.IconSize.NORMAL;
497 // user defined functions
502 public class Xcls_RightEditor : Object
504 public Gtk.ScrolledWindow el;
505 private Editor _this;
511 public Xcls_RightEditor(Editor _owner )
514 _this.RightEditor = this;
515 this.el = new Gtk.ScrolledWindow();
519 // set gobject values
520 this.el.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
521 this.el.vexpand = true;
522 this.el.overlay_scrolling = false;
523 this.el.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
524 var child_1 = new Xcls_view( _this );
526 this.el.child = child_1.el;
529 // user defined functions
531 public class Xcls_view : Object
533 public GtkSource.View el;
534 private Editor _this;
538 public Gtk.CssProvider css;
541 public Xcls_view(Editor _owner )
545 this.el = new GtkSource.View();
550 // set gobject values
551 this.el.auto_indent = true;
552 this.el.indent_width = 4;
553 this.el.name = "editor-view";
554 this.el.show_line_marks = true;
555 this.el.insert_spaces_instead_of_tabs = true;
556 this.el.show_line_numbers = true;
557 this.el.hexpand = true;
558 this.el.vexpand = true;
559 this.el.has_tooltip = true;
560 this.el.tab_width = 4;
561 this.el.highlight_current_line = true;
562 var child_1 = new Xcls_buffer( _this );
564 this.el.buffer = child_1.el;
565 var child_2 = new Xcls_EventControllerKey11( _this );
567 this.el.add_controller( child_2.el );
571 this.css = new Gtk.CssProvider();
573 this.css.load_from_string(
574 "#editor-view { font: 12px monospace;}"
577 Gtk.StyleContext.add_provider_for_display(
578 this.el.get_display(),
580 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
586 this is pretty flakey - triggers Gtk with < 0 d
587 var cp = new GtkSource.CompletionWords("test");
588 cp.minimum_word_size = 3;
589 //cp.priority = 100; //?? does this do anything
590 cp.proposals_batch_size = 10;
591 cp.scan_batch_size = 1000;
593 cp.register(_this.buffer.el);
594 this.el.completion.add_provider(cp);
596 this.el.completion.add_provider(new Palete.CompletionProvider(_this));
598 //this.el.completion.unblock_interactive();
599 this.el.completion.select_on_show = true; // select
600 //this.el.completion.remember_info_visibility = true;
603 var attrs = new GtkSource.MarkAttributes();
604 var pink = Gdk.RGBA();
605 pink.parse ( "pink");
606 attrs.set_background ( pink);
607 attrs.set_icon_name ( "process-stop");
608 attrs.query_tooltip_text.connect(( mark) => {
609 GLib.debug("tooltip query? %s", mark.name);
610 return strdup( mark.name);
612 attrs.query_tooltip_markup.connect(( mark) => {
613 GLib.debug("tooltip query? %s", mark.name);
614 return strdup( mark.name);
616 this.el.set_mark_attributes ("ERR", attrs, 1);
618 var wattrs = new GtkSource.MarkAttributes();
619 var blue = Gdk.RGBA();
620 blue.parse ( "#ABF4EB");
621 wattrs.set_background ( blue);
622 wattrs.set_icon_name ( "process-stop");
623 wattrs.query_tooltip_text.connect(( mark) => {
624 GLib.debug("tooltip query? %s", mark.name);
625 return strdup(mark.name);
627 wattrs.query_tooltip_markup.connect(( mark) => {
628 GLib.debug("tooltip query? %s", mark.name);
629 return strdup(mark.name);
631 this.el.set_mark_attributes ("WARN", wattrs, 1);
635 var dattrs = new GtkSource.MarkAttributes();
636 var purple = Gdk.RGBA();
637 purple.parse ( "#EEA9FF");
638 dattrs.set_background ( purple);
639 dattrs.set_icon_name ( "process-stop");
640 dattrs.query_tooltip_text.connect(( mark) => {
641 GLib.debug("tooltip query? %s", mark.name);
642 return strdup(mark.name);
644 dattrs.query_tooltip_markup.connect(( mark) => {
645 GLib.debug("tooltip query? %s", mark.name);
646 return strdup(mark.name);
648 this.el.set_mark_attributes ("DEPR", dattrs, 1);
651 this.el.get_space_drawer().set_matrix(null);
652 this.el.get_space_drawer().set_types_for_locations(
653 GtkSource.SpaceLocationFlags.ALL,
654 GtkSource.SpaceTypeFlags.ALL
656 this.el.get_space_drawer().set_enable_matrix(true);
658 Gtk.SourceDrawSpacesFlags.LEADING +
659 Gtk.SourceDrawSpacesFlags.TRAILING +
660 Gtk.SourceDrawSpacesFlags.TAB +
661 Gtk.SourceDrawSpacesFlags.SPACE
665 this.el.query_tooltip.connect( (x, y, keyboard_tooltip, tooltip) => {
667 //GLib.debug("query tooltip");
671 var yoff = (int) _this.RightEditor.el.vadjustment.value;
673 // I think this is problematic - if it's compliing / updating at same time as query.
675 //if (_this.window.statusbar_compile_spinner.el.spinning) {
679 this.el.get_iter_at_position (out iter, out trailing, x, y + yoff);
681 var l = iter.get_line();
685 // GLib.debug("query tooltip line %d", (int) l);
691 if (_this.buffer.marks != null && _this.buffer.marks.has_key(l)) {
692 GLib.debug("line %d setting tip to %s", l, _this.buffer.marks.get(l));
693 tooltip.set_text(_this.buffer.marks.get(l).dup());
701 // this crashes?? - not sure why.
702 var marks = _this.buffer.el.get_source_marks_at_line(l, "ERR");
703 if (marks.is_empty()) {
704 marks = _this.buffer.el.get_source_marks_at_line(l, "WARN");
706 if (marks.is_empty()) {
707 marks = _this.buffer.el.get_source_marks_at_line(l, "DEPR");
710 // GLib.debug("query tooltip line %d marks %d", (int)l, (int) marks.length());
712 marks.@foreach((m) => {
713 //GLib.debug("got mark %s", m.name);
714 str += (str.length > 0 ? "\n" : "") + m.category + ": " + m.name;
716 // true if there is a mark..
717 if (str.length > 0 ) {
718 tooltip.set_text( str );
720 return str.length > 0 ? true : false;
725 // user defined functions
726 public void load (string str) {
728 // show the help page for the active node..
729 //this.get('/Help').show();
731 // this.get('/BottomPane').el.set_current_page(0);
732 GLib.debug("load called - Reset undo buffer");
734 var buf = (GtkSource.Buffer)this.el.get_buffer();
735 buf.begin_irreversible_action();
736 buf.set_text(str, str.length);
737 buf.end_irreversible_action();
739 var lm = GtkSource.LanguageManager.get_default();
741 if (_this.file != null) {
742 lang = _this.file.language;
744 print("lang=%s, content_type = %s\n", lang, _this.file.content_type);
745 var lg = _this.file.content_type.length > 0 ?
746 lm.guess_language(_this.file.path, _this.file.content_type) :
747 lm.get_language(lang);
750 ((GtkSource.Buffer)(this.el.get_buffer())) .set_language(lg);
752 this.el.insert_spaces_instead_of_tabs = true;
754 print("sourcelanguage = %s\n", lg.name);
755 if (lg.name == "Vala") {
756 this.el.insert_spaces_instead_of_tabs = false;
760 this.el.grab_focus();
761 _this.save_button.el.sensitive = false;
764 public class Xcls_buffer : Object
766 public GtkSource.Buffer el;
767 private Editor _this;
771 public int error_line;
772 public Gee.HashMap<int,string>? xmarks;
773 public bool check_queued;
776 public Xcls_buffer(Editor _owner )
780 this.el = new GtkSource.Buffer( null );
783 this.error_line = -1;
785 this.check_queued = false;
787 // set gobject values
788 this.el.enable_undo = true;
791 this.el.changed.connect( () => {
794 _this.save_button.el.sensitive = true;
795 print("EDITOR CHANGED");
800 // this.get('/LeftPanel.model').changed( str , false);
805 // user defined functions
806 public bool checkSyntax () {
809 var str = this.toString();
812 if (this.error_line > 0) {
815 this.el.get_bounds (out start, out end);
817 this.el.remove_source_marks (start, end, null);
819 if (str.length < 1) {
820 print("checkSyntax - empty string?\n");
825 if (_this.file.xtype == "PlainFile") {
827 // assume it's gtk...
828 var oldcode =_this.file.toSource();
829 _this.file.setSource(str);
830 _this.file.getLanguageServer().document_change(_this.file);
831 _this.file.setSource(oldcode);
837 if (_this.file == null) {
845 GLib.debug("calling validate");
846 // clear the buttons.
847 if (_this.prop.name == "xns" || _this.prop.name == "xtype") {
850 var oldcode = _this.prop.val;
852 _this.prop.val = str;
853 _this.file.getLanguageServer().document_change(_this.file);
854 _this.prop.val = oldcode;
857 //print("done mark line\n");
859 return true; // at present allow saving - even if it's invalid..
861 public bool highlightErrorsJson (string type, Json.Object obj) {
864 this.el.get_bounds (out start, out end);
866 this.el.remove_source_marks (start, end, type);
867 GLib.debug("highlight errors");
869 // we should highlight other types of errors..
871 if (!obj.has_member(type)) {
872 GLib.debug("Return has no errors\n");
876 if (_this.window.windowstate.state != WindowState.State.CODEONLY
878 _this.window.windowstate.state != WindowState.State.CODE
880 GLib.debug("windowstate != CODEONLY?");
885 //this.marks = new Gee.HashMap<int,string>();
886 var err = obj.get_object_member(type);
888 if (_this.file == null) {
889 GLib.debug("file is null?");
893 var valafn = _this.file.path;
895 if (_this.file.xtype != "PlainFile") {
899 var regex = new Regex("\\.bjs$");
901 valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
902 } catch (GLib.RegexError e) {
909 if (!err.has_member(valafn)) {
910 GLib.debug("File path has no errors");
914 var lines = err.get_object_member(valafn);
917 if (obj.has_member("line_offset")) { // ?? why??
918 offset = (int)obj.get_int_member("line_offset") + 1;
922 var tlines = this.el.get_line_count () +1;
924 if (_this.prop != null) {
926 tlines = _this.prop.end_line + 1;
927 offset = _this.prop.start_line + 1;
933 lines.foreach_member((obj, line, node) => {
936 // print("get inter\n");
937 var eline = int.parse(line) - offset;
938 GLib.debug("GOT ERROR on line %s -- converted to %d (offset = %d)\n", line,eline, offset);
941 if (eline > tlines || eline < 0) {
946 this.el.get_iter_at_line( out iter, eline);
947 //print("mark line\n");
949 var ar = lines.get_array_member(line);
950 for (var i = 0 ; i < ar.get_length(); i++) {
951 if (ar.get_string_element(i) == "Success") {
954 msg += (msg.length > 0) ? "\n" : "";
955 msg += ar.get_string_element(i);
960 msg = "Line: %d".printf(eline+1) + " " + msg;
961 this.el.create_source_mark(msg, type, iter);
962 GLib.debug("set line %d to %m", eline, msg);
963 // this.marks.set(eline, msg);
972 public bool highlightErrors ( Gee.HashMap<int,string> validate_res) {
974 this.error_line = validate_res.size;
976 if (this.error_line < 1) {
979 var tlines = this.el.get_line_count ();
981 var valiter = validate_res.map_iterator();
982 while (valiter.next()) {
984 // print("get inter\n");
985 var eline = valiter.get_key();
986 if (eline > tlines) {
989 this.el.get_iter_at_line( out iter, eline);
990 //print("mark line\n");
991 this.el.create_source_mark(valiter.get_value(), "ERR", iter);
995 public string toString () {
999 this.el.get_start_iter(out s);
1000 this.el.get_end_iter(out e);
1001 var ret = this.el.get_text(s,e,true);
1002 //print("TO STRING? " + ret);
1007 public class Xcls_EventControllerKey11 : Object
1009 public Gtk.EventControllerKey el;
1010 private Editor _this;
1016 public Xcls_EventControllerKey11(Editor _owner )
1019 this.el = new Gtk.EventControllerKey();
1023 // set gobject values
1026 this.el.key_released.connect( (keyval, keycode, state) => {
1029 if (keyval == Gdk.Key.s && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1030 GLib.debug("SAVE: ctrl-S pressed");
1031 _this.saveContents();
1035 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1036 GLib.debug("SAVE: ctrl-g pressed");
1037 _this.forwardSearch(true);
1040 if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1041 GLib.debug("SAVE: ctrl-f pressed");
1042 _this.search_entry.el.grab_focus();
1045 //_this.view.el.show_completion();
1046 // print(event.key.keyval)
1054 // user defined functions
1059 public class Xcls_Box12 : Object
1062 private Editor _this;
1068 public Xcls_Box12(Editor _owner )
1071 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1075 // set gobject values
1076 this.el.homogeneous = false;
1077 this.el.vexpand = false;
1078 var child_1 = new Xcls_search_entry( _this );
1080 this.el.append( child_1.el );
1081 var child_2 = new Xcls_search_results( _this );
1083 this.el.append( child_2.el );
1084 var child_3 = new Xcls_nextBtn( _this );
1086 this.el.append( child_3.el );
1087 var child_4 = new Xcls_backBtn( _this );
1089 this.el.append( child_4.el );
1090 var child_5 = new Xcls_MenuButton18( _this );
1092 this.el.append( child_5.el );
1095 // user defined functions
1097 public class Xcls_search_entry : Object
1099 public Gtk.SearchEntry el;
1100 private Editor _this;
1104 public Gtk.CssProvider css;
1107 public Xcls_search_entry(Editor _owner )
1110 _this.search_entry = this;
1111 this.el = new Gtk.SearchEntry();
1115 // set gobject values
1116 this.el.name = "editor-search-entry";
1117 this.el.hexpand = true;
1118 this.el.placeholder_text = "Press enter to search";
1119 this.el.search_delay = 3;
1120 var child_1 = new Xcls_EventControllerKey14( _this );
1122 this.el.add_controller( child_1.el );
1125 this.el.search_changed.connect( ( ) => {
1127 _this.search(_this.search_entry.el.text);
1128 _this.search_results.updateResults();
1130 GLib.Timeout.add_seconds(1,() => {
1131 _this.search_results.updateResults();
1137 // user defined functions
1138 public void forwardSearch (bool change_focus) {
1141 _this.forwardSearch(change_focus);
1145 switch(_this.windowstate.state) {
1146 case WindowState.State.CODEONLY:
1147 //case WindowState.State.CODE:
1148 // search the code being edited..
1149 _this.windowstate.code_editor_tab.forwardSearch(change_focus);
1152 case WindowState.State.PREVIEW:
1153 if (_this.windowstate.file.xtype == "Gtk") {
1154 _this.windowstate.window_gladeview.forwardSearch(change_focus);
1156 _this.windowstate.window_rooview.forwardSearch(change_focus);
1165 public class Xcls_EventControllerKey14 : Object
1167 public Gtk.EventControllerKey el;
1168 private Editor _this;
1174 public Xcls_EventControllerKey14(Editor _owner )
1177 this.el = new Gtk.EventControllerKey();
1181 // set gobject values
1184 this.el.key_pressed.connect( (keyval, keycode, state) => {
1186 if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
1187 GLib.debug("SAVE: ctrl-g pressed");
1188 _this.forwardSearch(true);
1193 if (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {
1194 _this.forwardSearch(true);
1200 // print(event.key.keyval)
1206 // user defined functions
1210 public class Xcls_search_results : Object
1212 public Gtk.Label el;
1213 private Editor _this;
1219 public Xcls_search_results(Editor _owner )
1222 _this.search_results = this;
1223 this.el = new Gtk.Label( "No Results" );
1227 // set gobject values
1228 this.el.margin_end = 4;
1229 this.el.margin_start = 4;
1232 // user defined functions
1233 public void updateResults () {
1234 this.el.visible = true;
1236 var res = _this.searchcontext.get_occurrences_count();
1238 _this.search_results.el.label = "??? Matches";
1242 _this.nextBtn.el.sensitive = false;
1243 _this.backBtn.el.sensitive = false;
1246 _this.search_results.el.label = "%d Matches".printf(res);
1247 _this.nextBtn.el.sensitive = true;
1248 _this.backBtn.el.sensitive = true;
1251 _this.search_results.el.label = "No Matches";
1256 public class Xcls_nextBtn : Object
1258 public Gtk.Button el;
1259 private Editor _this;
1263 public bool always_show_image;
1266 public Xcls_nextBtn(Editor _owner )
1269 _this.nextBtn = this;
1270 this.el = new Gtk.Button();
1273 this.always_show_image = true;
1275 // set gobject values
1276 this.el.icon_name = "go-down";
1277 this.el.sensitive = false;
1280 this.el.clicked.connect( (event) => {
1282 _this.forwardSearch(true);
1288 // user defined functions
1291 public class Xcls_backBtn : Object
1293 public Gtk.Button el;
1294 private Editor _this;
1298 public bool always_show_image;
1301 public Xcls_backBtn(Editor _owner )
1304 _this.backBtn = this;
1305 this.el = new Gtk.Button();
1308 this.always_show_image = true;
1310 // set gobject values
1311 this.el.icon_name = "go-up";
1312 this.el.sensitive = false;
1315 this.el.clicked.connect( (event) => {
1317 _this.backSearch(true);
1322 // user defined functions
1325 public class Xcls_MenuButton18 : Object
1327 public Gtk.MenuButton el;
1328 private Editor _this;
1332 public bool always_show_image;
1335 public Xcls_MenuButton18(Editor _owner )
1338 this.el = new Gtk.MenuButton();
1341 this.always_show_image = true;
1343 // set gobject values
1344 this.el.icon_name = "emblem-system";
1345 this.el.always_show_arrow = true;
1346 var child_1 = new Xcls_search_settings( _this );
1348 this.el.popover = child_1.el;
1351 // user defined functions
1353 public class Xcls_search_settings : Object
1355 public Gtk.Popover el;
1356 private Editor _this;
1362 public Xcls_search_settings(Editor _owner )
1365 _this.search_settings = this;
1366 this.el = new Gtk.Popover();
1370 // set gobject values
1371 var child_1 = new Xcls_Box20( _this );
1373 this.el.child = child_1.el;
1376 // user defined functions
1378 public class Xcls_Box20 : Object
1381 private Editor _this;
1387 public Xcls_Box20(Editor _owner )
1390 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
1394 // set gobject values
1395 var child_1 = new Xcls_case_sensitive( _this );
1397 this.el.append( child_1.el );
1398 var child_2 = new Xcls_regex( _this );
1400 this.el.append( child_2.el );
1401 var child_3 = new Xcls_multiline( _this );
1403 this.el.append( child_3.el );
1406 // user defined functions
1408 public class Xcls_case_sensitive : Object
1410 public Gtk.CheckButton el;
1411 private Editor _this;
1417 public Xcls_case_sensitive(Editor _owner )
1420 _this.case_sensitive = this;
1421 this.el = new Gtk.CheckButton();
1425 // set gobject values
1426 this.el.label = "Case Sensitive";
1435 // user defined functions
1438 public class Xcls_regex : Object
1440 public Gtk.CheckButton el;
1441 private Editor _this;
1447 public Xcls_regex(Editor _owner )
1451 this.el = new Gtk.CheckButton();
1455 // set gobject values
1456 this.el.label = "Regex";
1465 // user defined functions
1468 public class Xcls_multiline : Object
1470 public Gtk.CheckButton el;
1471 private Editor _this;
1477 public Xcls_multiline(Editor _owner )
1480 _this.multiline = this;
1481 this.el = new Gtk.CheckButton();
1485 // set gobject values
1486 this.el.label = "Multi-line (add \\n)";
1489 // user defined functions