2 "build_module" : "builder",
5 "# JsRender.JsRender? file" : "null",
6 "# JsRender.Node node" : "null",
7 "# JsRender.NodeProp? prop" : "null",
8 "# Xcls_MainWindow window" : "null",
9 "# bool dirty" : false,
11 "# int pos_root_x" : "",
12 "# int pos_root_y" : "",
13 "# string activeEditor" : "\"\"",
14 "$ homogeneous" : false,
18 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
19 "Gtk.SourceSearchContext searchcontext" : "null",
20 "bool hexpand" : true,
21 "bool vexpand" : true,
22 "int last_search_end" : 0,
25 "$ homogeneous" : false,
27 "* pack" : "pack_start,false,true",
28 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
33 "bool always_show_image" : true,
39 "string icon_name" : "document-save",
47 " _this.saveContents();",
57 "bool hexpand" : true,
62 "* ctor" : "new Gtk.HScale.with_range (6, 30, 1)",
65 "\tthis.el.set_range(6,30);",
66 "\tthis.el.set_value(8);",
71 "bool draw_value" : true,
72 "bool has_origin" : true,
73 "bool sensitive" : true,
75 "int width_request" : 200,
80 "\t var description = Pango.FontDescription.from_string(\"monospace\");",
81 "\t print(\"resize to %d\", (int)val*1000);",
82 " description.set_size((int)val*1000);",
83 " _this.view.el.override_font(description);",
93 "bool always_show_image" : true,
99 "string icon_name" : "window-close",
106 " _this.saveContents();",
107 " _this.window.windowstate.switchState(WindowState.State.PREVIEW);",
120 "this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
123 "bool vexpand" : true,
124 "id" : "RightEditor",
127 "$ Gtk.SourceDrawSpacesFlags draw_spaces" : "Gtk.SourceDrawSpacesFlags.LEADING + Gtk.SourceDrawSpacesFlags.TRAILING + Gtk.SourceDrawSpacesFlags.TAB + Gtk.SourceDrawSpacesFlags.SPACE",
128 "$ gboolean auto_indent" : true,
129 "$ show_line_numbers" : true,
134 "\t\tvar description = Pango.FontDescription.from_string(\"monospace\");",
135 "\t\tdescription.set_size(8000);",
137 "\t\t this.el.override_font(description);",
140 "\t\tthis.el.completion.add_provider(new Palete.CompletionProvider(_this));",
141 " } catch (GLib.Error e) {}",
143 "\tthis.el.completion.unblock_interactive();",
144 "\tthis.el.completion.select_on_show\t\t\t= true; // select",
145 "\tthis.el.completion.show_headers\t\t\t= false;",
146 "\tthis.el.completion.remember_info_visibility\t\t= true;",
149 " var attrs = new Gtk.SourceMarkAttributes();",
150 " var pink = Gdk.RGBA();",
151 " pink.parse ( \"pink\");",
152 " attrs.set_background ( pink);",
153 " attrs.set_icon_name ( \"process-stop\"); ",
154 " attrs.query_tooltip_text.connect(( mark) => {",
155 " //print(\"tooltip query? %s\\n\", mark.name);",
156 " return mark.name;",
159 " this.el.set_mark_attributes (\"ERR\", attrs, 1);",
161 " var wattrs = new Gtk.SourceMarkAttributes();",
162 " var blue = Gdk.RGBA();",
163 " blue.parse ( \"#ABF4EB\");",
164 " wattrs.set_background ( blue);",
165 " wattrs.set_icon_name ( \"process-stop\"); ",
166 " wattrs.query_tooltip_text.connect(( mark) => {",
167 " //print(\"tooltip query? %s\\n\", mark.name);",
168 " return mark.name;",
171 " this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
175 " var dattrs = new Gtk.SourceMarkAttributes();",
176 " var purple = Gdk.RGBA();",
177 " purple.parse ( \"#EEA9FF\");",
178 " dattrs.set_background ( purple);",
179 " dattrs.set_icon_name ( \"process-stop\"); ",
180 " dattrs.query_tooltip_text.connect(( mark) => {",
181 " //print(\"tooltip query? %s\\n\", mark.name);",
182 " return mark.name;",
185 " this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
190 "bool insert_spaces_instead_of_tabs" : true,
191 "gboolean highlight_current_line" : true,
192 "gboolean show_line_marks" : true,
198 "* pack" : "set_buffer",
199 "bool check_queued" : false,
200 "bool check_running" : false,
202 "int error_line" : "-1",
206 " // check syntax??",
208 " _this.save_button.el.sensitive = true;",
209 " print(\"EDITOR CHANGED\");",
210 " this.checkSyntax();",
212 " _this.dirty = true;",
214 " // this.get('/LeftPanel.model').changed( str , false);",
222 "xtype" : "SourceBuffer",
223 "| bool checkSyntax" : [
226 " if (this.check_running) {",
227 " print(\"Check is running\\n\");",
228 " if (this.check_queued) { ",
229 " print(\"Check is already queued\");",
232 " this.check_queued = true;",
233 " print(\"Adding queued Check \");",
234 " GLib.Timeout.add_seconds(1, () => {",
235 " this.check_queued = false;",
237 " this.checkSyntax();",
244 " var str = this.toString();",
247 " if (this.error_line > 0) {",
248 " Gtk.TextIter start;",
249 " Gtk.TextIter end; ",
250 " this.el.get_bounds (out start, out end);",
252 " this.el.remove_source_marks (start, end, null);",
254 " if (str.length < 1) {",
255 " print(\"checkSyntax - empty string?\\n\");",
259 " if (_this.file.xtype == \"PlainFile\") {",
261 " // assume it's gtk...",
262 " this.check_running = true;",
264 " if (!BuilderApplication.valasource.checkPlainFileSpawn(",
268 " this.check_running = false;",
274 " if (_this.file == null) {",
277 " var p = _this.file.project.palete;",
281 " this.check_running = true;",
284 " if (_this.file.language == \"js\") {",
285 " this.check_running = false;",
286 " print(\"calling validate javascript\\n\"); ",
287 " Gee.HashMap<int,string> errors;",
288 " p.javascriptHasErrors(",
289 " \t\t_this.window.windowstate,",
292 " _this.file, // no reference not node?",
295 " return this.highlightErrors(errors); ",
300 " print(\"calling validate vala\\n\"); ",
301 " // clear the buttons.",
304 " if (! BuilderApplication.valasource.checkFileWithNodePropChange(",
310 " this.check_running = false;",
315 " //print(\"done mark line\\n\");",
317 " return true; // at present allow saving - even if it's invalid..",
321 "| bool highlightErrors" : [
322 "( Gee.HashMap<int,string> validate_res) {",
324 " this.error_line = validate_res.size;",
326 " if (this.error_line < 1) {",
329 " var tlines = this.el.get_line_count ();",
330 " Gtk.TextIter iter;",
331 " var valiter = validate_res.map_iterator();",
332 " while (valiter.next()) {",
334 " // print(\"get inter\\n\");",
335 " var eline = valiter.get_key();",
336 " if (eline > tlines) {",
339 " this.el.get_iter_at_line( out iter, eline);",
340 " //print(\"mark line\\n\");",
341 " this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
346 "| bool highlightErrorsJson" : [
347 "(string type, Json.Object obj) {",
348 " Gtk.TextIter start;",
349 " Gtk.TextIter end; ",
350 " this.el.get_bounds (out start, out end);",
352 " this.el.remove_source_marks (start, end, type);",
355 " // we should highlight other types of errors..",
357 " if (!obj.has_member(type)) {",
358 " print(\"Return has no errors\\n\");",
362 " if (_this.window.windowstate.state != WindowState.State.CODEONLY ",
369 " var err = obj.get_object_member(type);",
372 " if (_this.file == null) {",
376 " var valafn = _this.file.path;",
378 " if (_this.file.xtype != \"PlainFile\") {",
385 " var regex = new Regex(\"\\\\.bjs$\");",
386 " // should not happen",
389 " valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
390 " } catch (GLib.RegexError e) {",
397 " if (!err.has_member(valafn)) {",
398 " print(\"File path has no errors\\n\");",
402 " var lines = err.get_object_member(valafn);",
405 " if (obj.has_member(\"line_offset\")) {",
406 " offset = (int)obj.get_int_member(\"line_offset\") + 1;",
412 " var tlines = this.el.get_line_count () +1;",
414 " lines.foreach_member((obj, line, node) => {",
416 " Gtk.TextIter iter;",
417 " // print(\"get inter\\n\");",
418 " var eline = int.parse(line) - offset;",
419 " print(\"GOT ERROR on line %s -- converted to %d\\n\", line,eline);",
422 " if (eline > tlines || eline < 0) {",
425 " this.el.get_iter_at_line( out iter, eline);",
426 " //print(\"mark line\\n\");",
427 " var msg = \"Line: %d\".printf(eline+1);",
428 " var ar = lines.get_array_member(line);",
429 " for (var i = 0 ; i < ar.get_length(); i++) {",
430 "\t\t msg += (msg.length > 0) ? \"\\n\" : \"\";",
431 "\t\t msg += ar.get_string_element(i);",
435 " this.el.create_source_mark(msg, type, iter);",
446 "| string toString" : [
451 " this.el.get_start_iter(out s);",
452 " this.el.get_end_iter(out e);",
453 " var ret = this.el.get_text(s,e,true);",
454 " //print(\"TO STRING? \" + ret);",
462 "key_release_event" : [
465 " if (event.keyval == Gdk.Key.s && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
466 " GLib.debug(\"SAVE: ctrl-S pressed\");",
467 " _this.saveContents();",
471 " if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
472 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
473 "\t\t_this.forwardSearch(true);",
476 "\tif (event.keyval == Gdk.Key.f && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
477 "\t GLib.debug(\"SAVE: ctrl-f pressed\");",
478 "\t\t_this.search_entry.el.grab_focus();",
482 " // print(event.key.keyval)",
491 "uint tab_width" : 4,
492 "xtype" : "SourceView",
496 "// show the help page for the active node..",
497 " //this.get('/Help').show();",
500 " // this.get('/BottomPane').el.set_current_page(0);",
501 " var buf = (Gtk.SourceBuffer)this.el.get_buffer();",
502 " buf.set_text(str, str.length);",
503 " buf.set_undo_manager(null);",
505 " var lm = Gtk.SourceLanguageManager.get_default();",
506 " var lang = \"vala\";",
507 " if (_this.file != null) {",
508 " lang = _this.file.language;",
510 " print(\"lang=%s, content_type = %s\\n\", lang, _this.file.content_type);",
511 " var lg = _this.file.content_type.length > 0 ?",
512 " lm.guess_language(_this.file.path, _this.file.content_type) :",
513 " lm.get_language(lang);",
516 " ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lg); ",
518 " this.el.insert_spaces_instead_of_tabs = true;",
519 " if (lg != null) {",
520 "\t\tprint(\"sourcelanguage = %s\\n\", lg.name);",
521 "\t\tif (lg.name == \"Vala\") {",
522 "\t\t this.el.insert_spaces_instead_of_tabs = false;",
525 " _this.dirty = false;",
526 " this.el.grab_focus();",
527 " _this.save_button.el.sensitive = false;",
532 "xtype" : "ScrolledWindow"
536 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
537 "bool homogeneous" : false,
538 "bool vexpand" : false,
544 "var description = Pango.FontDescription.from_string(\"monospace\");",
545 "\tdescription.set_size(8000);",
546 "\t this.el.override_font(description);",
550 "bool hexpand" : true,
551 "id" : "search_entry",
552 "int width_request" : 300,
557 "\tif (this.el.text == \"\") {",
558 "\t\t_this.search_results.el.hide();",
562 "\tswitch(_this.windowstate.state) {",
563 "\t\tcase WindowState.State.CODEONLY:",
564 "\t\t///case WindowState.State.CODE:",
565 "\t\t\t// search the code being edited..",
566 "\t\t\tres = _this.windowstate.code_editor_tab.search(this.el.text);",
569 "\t\tcase WindowState.State.PREVIEW:",
570 "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
571 "\t\t\t\t res = _this.windowstate.window_gladeview.search(this.el.text);",
573 "\t\t\t\t res = _this.windowstate.window_rooview.search(this.el.text);\t\t\t",
579 "\t_this.search_results.el.show();",
581 "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
583 "\t\t_this.search_results.el.label = \"No Matches\";",
591 "key_press_event" : [
593 " if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
594 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
595 "\t\t_this.forwardSearch(true);",
600 " \tif (event.keyval == Gdk.Key.Return && this.el.text.length > 0) {",
601 "\t\tvar res = _this.search(this.el.text);",
602 "\t\t _this.search_results.updateResults();",
604 "\t\tGLib.Timeout.add_seconds(2,() => {",
605 "\t\t\t _this.search_results.updateResults();",
606 "\t\t\t return false;",
613 " // print(event.key.keyval)",
620 "string placeholder_text" : "Press enter to search",
621 "xtype" : "SearchEntry",
622 "| void forwardSearch" : [
623 "(bool change_focus) {",
626 "\t_this.forwardSearch(change_focus);",
630 "\tswitch(_this.windowstate.state) {",
631 "\t\tcase WindowState.State.CODEONLY:",
632 "\t\t//case WindowState.State.CODE:",
633 "\t\t\t// search the code being edited..",
634 "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
637 "\t\tcase WindowState.State.PREVIEW:",
638 "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
639 "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
641 "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
659 "bool always_show_image" : true,
660 "bool visible" : false,
661 "id" : "search_results",
663 "button_press_event" : [
666 " if (this.popup == null) {",
667 " this.popup = new Xcls_ValaCompileErrors();",
668 " this.popup.window = _this;",
672 " this.popup.show(this.notices, this.el);",
678 "xtype" : "ImageMenuItem",
679 "| void updateResults" : [
681 "\tthis.el.visible = true;",
683 "\tvar res = _this.searchcontext.get_occurrences_count();",
685 "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
689 "\t_this.nextBtn.el.sensitive = false;",
690 "\t_this.backBtn.el.sensitive = false;\t",
693 "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
694 "\t\t_this.nextBtn.el.sensitive = true;",
695 "\t\t_this.backBtn.el.sensitive = true;",
698 "\t_this.search_results.el.label = \"No Matches\";",
708 "bool always_show_image" : true,
709 "bool sensitive" : false,
715 "string icon_name" : "go-down",
720 "button_press_event" : [
723 "\t_this.forwardSearch(true);",
730 "string label" : "Next",
735 "bool always_show_image" : true,
736 "bool sensitive" : false,
742 "string icon_name" : "go-up",
747 "button_press_event" : [
750 "\t_this.backSearch(true);",
757 "string label" : "Previous",
762 "bool always_show_image" : true,
767 "string icon_name" : "emblem-system",
773 "id" : "search_settings",
783 "id" : "case_sensitive",
784 "string label" : "Case Sensitive",
785 "xtype" : "CheckMenuItem"
796 "string label" : "Regex",
797 "xtype" : "CheckMenuItem"
808 "string label" : "Multi-line (add \\n)",
809 "xtype" : "CheckMenuItem"
815 "string label" : "Settings",
816 "xtype" : "MenuButton"
823 "| bool saveContents" : [
827 " if (_this.file == null) {",
833 " var str = _this.buffer.toString();",
835 " _this.buffer.checkSyntax();",
839 " // LeftPanel.model.changed( str , false);",
840 " _this.dirty = false;",
841 " _this.save_button.el.sensitive = false;",
843 " // find the text for the node..",
844 " if (_this.file.xtype != \"PlainFile\") {",
845 " // in theory these properties have to exist!?!",
846 " \tthis.prop.val = str;",
847 " this.window.windowstate.left_props.reload();",
849 " _this.file.setSource( str );",
852 " // call the signal..",
862 "\tvar s = new Gtk.SourceSearchSettings();",
863 "\ts.case_sensitive = _this.case_sensitive.el.active;",
864 "\ts.regex_enabled = _this.regex.el.active;\t",
865 "\ts.wrap_around = false;",
867 "\tthis.searchcontext = new Gtk.SourceSearchContext(this.buffer.el,s);",
868 "\tthis.searchcontext.set_highlight(true);",
869 "\tvar txt = in_txt;",
871 "\tif (_this.multiline.el.active) {",
872 "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
875 "\ts.set_search_text(txt);",
876 "\tGtk.TextIter beg, st,en;",
878 "\tthis.buffer.el.get_start_iter(out beg);",
879 "\tthis.searchcontext.forward(beg, out st, out en);",
880 "\tthis.last_search_end = 0;",
882 "\treturn this.searchcontext.get_occurrences_count();",
890 "| void backSearch" : [
891 "(bool change_focus) {",
893 "\tif (this.searchcontext == null) {",
897 "\tGtk.TextIter beg, st,en;",
898 "\tbool has_wrapped_around;",
899 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
901 "\tif (!this.searchcontext.backward2(beg, out st, out en, out has_wrapped_around)) {",
903 "\t\tthis.last_search_end = 0;",
905 "\t\tthis.last_search_end = en.get_offset();",
906 "\t\tif (change_focus) {",
907 "\t\t\tthis.view.el.grab_focus();",
909 "\t\tthis.buffer.el.place_cursor(st);",
910 "\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
916 "| void forwardSearch" : [
917 "(bool change_focus) {",
919 "\tif (this.searchcontext == null) {",
923 "\tGtk.TextIter beg, st,en;",
924 "\t bool has_wrapped_around;",
925 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end);",
926 "\tif (!this.searchcontext.forward2(beg, out st, out en, out has_wrapped_around)) {",
928 "\t\tthis.last_search_end = 0; // not sure if this should happen",
930 "\t\tif (has_wrapped_around) {",
934 "\t\tthis.last_search_end = en.get_offset();",
935 "\t\tif (change_focus) {",
936 "\t\t\tthis.view.el.grab_focus();",
938 "\t\tthis.buffer.el.place_cursor(st);",
939 "\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
947 "\t this.file = null; ",
949 " this.node = null;",
950 " this.prop = null;",
951 "\tthis.searchcontext = null;",
956 "| void scroll_to_line" : [
959 "\tGLib.Timeout.add(500, () => {",
961 "\t\tvar buf = this.view.el.get_buffer();",
963 "\t\tvar sbuf = (Gtk.SourceBuffer) buf;",
966 "\t\tGtk.TextIter iter; ",
967 "\t\tsbuf.get_iter_at_line(out iter, line);",
968 "\t\tthis.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
975 "(JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)",
978 " this.file = file; ",
980 " if (file.xtype != \"PlainFile\") {",
981 " \tthis.prop = prop;",
982 " this.node = node;",
984 " // find the text for the node..",
985 " this.view.load( prop.val );",
986 " this.close_btn.el.show(); ",
989 " this.view.load( file.toSource() );",
990 " this.close_btn.el.hide();",
1000 "path" : "/home/alan/gitlive/roobuilder/src/Builder4/Editor.bjs",