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.Scale.with_range (Gtk.Orientation.HORIZONTAL,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,
81 "\t _this.view.css.load_from_data(",
82 "\t \t\t\"#editor-view { font: %dpx Monospace; }\".printf((int)val)",
84 " } catch (Error e) {}",
94 "bool always_show_image" : true,
100 "string icon_name" : "window-close",
107 " _this.saveContents();",
108 " _this.window.windowstate.switchState(WindowState.State.PREVIEW);",
121 "this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
124 "bool vexpand" : true,
125 "id" : "RightEditor",
128 "$ gboolean auto_indent" : true,
129 "$ show_line_numbers" : true,
134 "\t\tthis.css = new Gtk.CssProvider();",
136 "\t\tthis.css.load_from_data(\"#editor-view { font: 10px Monospace;}\");",
137 "\t\t} catch (Error e) {}",
138 "\t\t this.el.get_style_context().add_provider(this.css,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);",
143 "\t\tthis.el.completion.add_provider(new Palete.CompletionProvider(_this));",
144 " } catch (GLib.Error e) {}",
146 "\tthis.el.completion.unblock_interactive();",
147 "\tthis.el.completion.select_on_show\t\t\t= true; // select",
148 "\tthis.el.completion.show_headers\t\t\t= false;",
149 "\tthis.el.completion.remember_info_visibility\t\t= true;",
152 " var attrs = new Gtk.SourceMarkAttributes();",
153 " var pink = Gdk.RGBA();",
154 " pink.parse ( \"pink\");",
155 " attrs.set_background ( pink);",
156 " attrs.set_icon_name ( \"process-stop\"); ",
157 " attrs.query_tooltip_text.connect(( mark) => {",
158 " //print(\"tooltip query? %s\\n\", mark.name);",
159 " return mark.name;",
162 " this.el.set_mark_attributes (\"ERR\", attrs, 1);",
164 " var wattrs = new Gtk.SourceMarkAttributes();",
165 " var blue = Gdk.RGBA();",
166 " blue.parse ( \"#ABF4EB\");",
167 " wattrs.set_background ( blue);",
168 " wattrs.set_icon_name ( \"process-stop\"); ",
169 " wattrs.query_tooltip_text.connect(( mark) => {",
170 " //print(\"tooltip query? %s\\n\", mark.name);",
171 " return mark.name;",
174 " this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
178 " var dattrs = new Gtk.SourceMarkAttributes();",
179 " var purple = Gdk.RGBA();",
180 " purple.parse ( \"#EEA9FF\");",
181 " dattrs.set_background ( purple);",
182 " dattrs.set_icon_name ( \"process-stop\"); ",
183 " dattrs.query_tooltip_text.connect(( mark) => {",
184 " //print(\"tooltip query? %s\\n\", mark.name);",
185 " return mark.name;",
188 " this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
191 " this.el.get_space_drawer().set_matrix(null);",
192 " this.el.get_space_drawer().set_types_for_locations( ",
193 "\t\tGtk.SourceSpaceLocationFlags.ALL,",
194 "\t\tGtk.SourceSpaceTypeFlags.ALL",
196 " this.el.get_space_drawer().set_enable_matrix(true);",
198 " Gtk.SourceDrawSpacesFlags.LEADING + ",
199 "Gtk.SourceDrawSpacesFlags.TRAILING + ",
200 "Gtk.SourceDrawSpacesFlags.TAB + ",
201 "Gtk.SourceDrawSpacesFlags.SPACE",
205 "Gtk.CssProvider css" : "null",
206 "bool insert_spaces_instead_of_tabs" : true,
207 "gboolean highlight_current_line" : true,
208 "gboolean show_line_marks" : true,
214 "* pack" : "set_buffer",
215 "bool check_queued" : false,
216 "bool check_running" : false,
218 "int error_line" : "-1",
222 " // check syntax??",
224 " _this.save_button.el.sensitive = true;",
225 " print(\"EDITOR CHANGED\");",
226 " this.checkSyntax();",
228 " _this.dirty = true;",
230 " // this.get('/LeftPanel.model').changed( str , false);",
238 "xtype" : "SourceBuffer",
239 "| bool checkSyntax" : [
242 " if (this.check_running) {",
243 " print(\"Check is running\\n\");",
244 " if (this.check_queued) { ",
245 " print(\"Check is already queued\");",
248 " this.check_queued = true;",
249 " print(\"Adding queued Check \");",
250 " GLib.Timeout.add_seconds(1, () => {",
251 " this.check_queued = false;",
253 " this.checkSyntax();",
260 " var str = this.toString();",
263 " if (this.error_line > 0) {",
264 " Gtk.TextIter start;",
265 " Gtk.TextIter end; ",
266 " this.el.get_bounds (out start, out end);",
268 " this.el.remove_source_marks (start, end, null);",
270 " if (str.length < 1) {",
271 " print(\"checkSyntax - empty string?\\n\");",
275 " if (_this.file.xtype == \"PlainFile\") {",
277 " // assume it's gtk...",
278 " this.check_running = true;",
280 " if (!BuilderApplication.valasource.checkPlainFileSpawn(",
284 " this.check_running = false;",
290 " if (_this.file == null) {",
293 " var p = _this.file.project.palete;",
297 " this.check_running = true;",
300 " if (_this.file.language == \"js\") {",
301 " this.check_running = false;",
302 " print(\"calling validate javascript\\n\"); ",
303 " Gee.HashMap<int,string> errors;",
304 " p.javascriptHasErrors(",
305 " \t\t_this.window.windowstate,",
308 " _this.file, // no reference not node?",
311 " return this.highlightErrors(errors); ",
316 " print(\"calling validate vala\\n\"); ",
317 " // clear the buttons.",
320 " if (! BuilderApplication.valasource.checkFileWithNodePropChange(",
326 " this.check_running = false;",
331 " //print(\"done mark line\\n\");",
333 " return true; // at present allow saving - even if it's invalid..",
337 "| bool highlightErrors" : [
338 "( Gee.HashMap<int,string> validate_res) {",
340 " this.error_line = validate_res.size;",
342 " if (this.error_line < 1) {",
345 " var tlines = this.el.get_line_count ();",
346 " Gtk.TextIter iter;",
347 " var valiter = validate_res.map_iterator();",
348 " while (valiter.next()) {",
350 " // print(\"get inter\\n\");",
351 " var eline = valiter.get_key();",
352 " if (eline > tlines) {",
355 " this.el.get_iter_at_line( out iter, eline);",
356 " //print(\"mark line\\n\");",
357 " this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
362 "| bool highlightErrorsJson" : [
363 "(string type, Json.Object obj) {",
364 " Gtk.TextIter start;",
365 " Gtk.TextIter end; ",
366 " this.el.get_bounds (out start, out end);",
368 " this.el.remove_source_marks (start, end, type);",
371 " // we should highlight other types of errors..",
373 " if (!obj.has_member(type)) {",
374 " print(\"Return has no errors\\n\");",
378 " if (_this.window.windowstate.state != WindowState.State.CODEONLY ",
385 " var err = obj.get_object_member(type);",
388 " if (_this.file == null) {",
392 " var valafn = _this.file.path;",
394 " if (_this.file.xtype != \"PlainFile\") {",
401 " var regex = new Regex(\"\\\\.bjs$\");",
402 " // should not happen",
405 " valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
406 " } catch (GLib.RegexError e) {",
413 " if (!err.has_member(valafn)) {",
414 " print(\"File path has no errors\\n\");",
418 " var lines = err.get_object_member(valafn);",
421 " if (obj.has_member(\"line_offset\")) {",
422 " offset = (int)obj.get_int_member(\"line_offset\") + 1;",
428 " var tlines = this.el.get_line_count () +1;",
430 " lines.foreach_member((obj, line, node) => {",
432 " Gtk.TextIter iter;",
433 " // print(\"get inter\\n\");",
434 " var eline = int.parse(line) - offset;",
435 " print(\"GOT ERROR on line %s -- converted to %d\\n\", line,eline);",
438 " if (eline > tlines || eline < 0) {",
441 " this.el.get_iter_at_line( out iter, eline);",
442 " //print(\"mark line\\n\");",
443 " var msg = \"Line: %d\".printf(eline+1);",
444 " var ar = lines.get_array_member(line);",
445 " for (var i = 0 ; i < ar.get_length(); i++) {",
446 "\t\t msg += (msg.length > 0) ? \"\\n\" : \"\";",
447 "\t\t msg += ar.get_string_element(i);",
451 " this.el.create_source_mark(msg, type, iter);",
462 "| string toString" : [
467 " this.el.get_start_iter(out s);",
468 " this.el.get_end_iter(out e);",
469 " var ret = this.el.get_text(s,e,true);",
470 " //print(\"TO STRING? \" + ret);",
478 "key_release_event" : [
481 " if (event.keyval == Gdk.Key.s && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
482 " GLib.debug(\"SAVE: ctrl-S pressed\");",
483 " _this.saveContents();",
487 " if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
488 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
489 "\t\t_this.forwardSearch(true);",
492 "\tif (event.keyval == Gdk.Key.f && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
493 "\t GLib.debug(\"SAVE: ctrl-f pressed\");",
494 "\t\t_this.search_entry.el.grab_focus();",
498 " // print(event.key.keyval)",
507 "string name" : "editor-view",
508 "uint tab_width" : 4,
509 "xtype" : "SourceView",
513 "// show the help page for the active node..",
514 " //this.get('/Help').show();",
517 " // this.get('/BottomPane').el.set_current_page(0);",
518 " var buf = (Gtk.SourceBuffer)this.el.get_buffer();",
519 " buf.set_text(str, str.length);",
520 " buf.set_undo_manager(null);",
522 " var lm = Gtk.SourceLanguageManager.get_default();",
523 " var lang = \"vala\";",
524 " if (_this.file != null) {",
525 " lang = _this.file.language;",
527 " print(\"lang=%s, content_type = %s\\n\", lang, _this.file.content_type);",
528 " var lg = _this.file.content_type.length > 0 ?",
529 " lm.guess_language(_this.file.path, _this.file.content_type) :",
530 " lm.get_language(lang);",
533 " ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lg); ",
535 " this.el.insert_spaces_instead_of_tabs = true;",
536 " if (lg != null) {",
537 "\t\tprint(\"sourcelanguage = %s\\n\", lg.name);",
538 "\t\tif (lg.name == \"Vala\") {",
539 "\t\t this.el.insert_spaces_instead_of_tabs = false;",
542 " _this.dirty = false;",
543 " this.el.grab_focus();",
544 " _this.save_button.el.sensitive = false;",
549 "xtype" : "ScrolledWindow"
553 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
554 "bool homogeneous" : false,
555 "bool vexpand" : false,
561 "var description = Pango.FontDescription.from_string(\"monospace\");",
562 "\tdescription.set_size(8000);",
563 "\t this.el.set_property(\"font-desc\",description);",
567 "bool hexpand" : true,
568 "id" : "search_entry",
569 "int width_request" : 300,
574 "\tif (this.el.text == \"\") {",
575 "\t\t_this.search_results.el.hide();",
579 "\tswitch(_this.windowstate.state) {",
580 "\t\tcase WindowState.State.CODEONLY:",
581 "\t\t///case WindowState.State.CODE:",
582 "\t\t\t// search the code being edited..",
583 "\t\t\tres = _this.windowstate.code_editor_tab.search(this.el.text);",
586 "\t\tcase WindowState.State.PREVIEW:",
587 "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
588 "\t\t\t\t res = _this.windowstate.window_gladeview.search(this.el.text);",
590 "\t\t\t\t res = _this.windowstate.window_rooview.search(this.el.text);\t\t\t",
596 "\t_this.search_results.el.show();",
598 "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
600 "\t\t_this.search_results.el.label = \"No Matches\";",
608 "key_press_event" : [
610 " if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
611 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
612 "\t\t_this.forwardSearch(true);",
617 " \tif (event.keyval == Gdk.Key.Return && this.el.text.length > 0) {",
619 "\t\t _this.search(this.el.text);",
620 "\t\t _this.search_results.updateResults();",
622 "\t\tGLib.Timeout.add_seconds(2,() => {",
623 "\t\t\t _this.search_results.updateResults();",
624 "\t\t\t return false;",
631 " // print(event.key.keyval)",
638 "string placeholder_text" : "Press enter to search",
639 "xtype" : "SearchEntry",
640 "| void forwardSearch" : [
641 "(bool change_focus) {",
644 "\t_this.forwardSearch(change_focus);",
648 "\tswitch(_this.windowstate.state) {",
649 "\t\tcase WindowState.State.CODEONLY:",
650 "\t\t//case WindowState.State.CODE:",
651 "\t\t\t// search the code being edited..",
652 "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
655 "\t\tcase WindowState.State.PREVIEW:",
656 "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
657 "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
659 "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
677 "bool always_show_image" : true,
678 "bool visible" : false,
679 "id" : "search_results",
681 "button_press_event" : [
684 " if (this.popup == null) {",
685 " this.popup = new Xcls_ValaCompileErrors();",
686 " this.popup.window = _this;",
690 " this.popup.show(this.notices, this.el);",
696 "xtype" : "MenuItem",
697 "| void updateResults" : [
699 "\tthis.el.visible = true;",
701 "\tvar res = _this.searchcontext.get_occurrences_count();",
703 "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
707 "\t_this.nextBtn.el.sensitive = false;",
708 "\t_this.backBtn.el.sensitive = false;\t",
711 "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
712 "\t\t_this.nextBtn.el.sensitive = true;",
713 "\t\t_this.backBtn.el.sensitive = true;",
716 "\t_this.search_results.el.label = \"No Matches\";",
726 "bool always_show_image" : true,
727 "bool sensitive" : false,
733 "string icon_name" : "go-down",
738 "button_press_event" : [
741 "\t_this.forwardSearch(true);",
748 "string label" : "Next",
753 "bool always_show_image" : true,
754 "bool sensitive" : false,
760 "string icon_name" : "go-up",
765 "button_press_event" : [
768 "\t_this.backSearch(true);",
775 "string label" : "Previous",
780 "bool always_show_image" : true,
785 "string icon_name" : "emblem-system",
791 "id" : "search_settings",
801 "id" : "case_sensitive",
802 "string label" : "Case Sensitive",
803 "xtype" : "CheckMenuItem"
814 "string label" : "Regex",
815 "xtype" : "CheckMenuItem"
826 "string label" : "Multi-line (add \\n)",
827 "xtype" : "CheckMenuItem"
833 "string label" : "Settings",
834 "xtype" : "MenuButton"
841 "| bool saveContents" : [
845 " if (_this.file == null) {",
851 " var str = _this.buffer.toString();",
853 " _this.buffer.checkSyntax();",
857 " // LeftPanel.model.changed( str , false);",
858 " _this.dirty = false;",
859 " _this.save_button.el.sensitive = false;",
861 " // find the text for the node..",
862 " if (_this.file.xtype != \"PlainFile\") {",
863 " // in theory these properties have to exist!?!",
864 " \tthis.prop.val = str;",
865 " this.window.windowstate.left_props.reload();",
867 " _this.file.setSource( str );",
870 " // call the signal..",
880 "\tvar s = new Gtk.SourceSearchSettings();",
881 "\ts.case_sensitive = _this.case_sensitive.el.active;",
882 "\ts.regex_enabled = _this.regex.el.active;\t",
883 "\ts.wrap_around = false;",
885 "\tthis.searchcontext = new Gtk.SourceSearchContext(this.buffer.el,s);",
886 "\tthis.searchcontext.set_highlight(true);",
887 "\tvar txt = in_txt;",
889 "\tif (_this.multiline.el.active) {",
890 "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
893 "\ts.set_search_text(txt);",
894 "\tGtk.TextIter beg, st,en;",
896 "\tthis.buffer.el.get_start_iter(out beg);",
897 "\tthis.searchcontext.forward(beg, out st, out en);",
898 "\tthis.last_search_end = 0;",
900 "\treturn this.searchcontext.get_occurrences_count();",
908 "| void backSearch" : [
909 "(bool change_focus) {",
911 "\tif (this.searchcontext == null) {",
915 "\tGtk.TextIter beg, st,en;",
916 "\tbool has_wrapped_around;",
917 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
919 "\tif (!this.searchcontext.backward2(beg, out st, out en, out has_wrapped_around)) {",
921 "\t\tthis.last_search_end = 0;",
923 "\t\tthis.last_search_end = en.get_offset();",
924 "\t\tif (change_focus) {",
925 "\t\t\tthis.view.el.grab_focus();",
927 "\t\tthis.buffer.el.place_cursor(st);",
928 "\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
934 "| void forwardSearch" : [
935 "(bool change_focus) {",
937 "\tif (this.searchcontext == null) {",
941 "\tGtk.TextIter beg, st,en;",
942 "\t bool has_wrapped_around;",
943 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end);",
944 "\tif (!this.searchcontext.forward2(beg, out st, out en, out has_wrapped_around)) {",
946 "\t\tthis.last_search_end = 0; // not sure if this should happen",
948 "\t\tif (has_wrapped_around) {",
952 "\t\tthis.last_search_end = en.get_offset();",
953 "\t\tif (change_focus) {",
954 "\t\t\tthis.view.el.grab_focus();",
956 "\t\tthis.buffer.el.place_cursor(st);",
957 "\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
965 "\t this.file = null; ",
967 " this.node = null;",
968 " this.prop = null;",
969 "\tthis.searchcontext = null;",
974 "| void scroll_to_line" : [
977 "\tGLib.Timeout.add(500, () => {",
979 "\t\tvar buf = this.view.el.get_buffer();",
981 "\t\tvar sbuf = (Gtk.SourceBuffer) buf;",
984 "\t\tGtk.TextIter iter; ",
985 "\t\tsbuf.get_iter_at_line(out iter, line);",
986 "\t\tthis.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
993 "(JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)",
996 " this.file = file; ",
998 " if (file.xtype != \"PlainFile\") {",
999 " \tthis.prop = prop;",
1000 " this.node = node;",
1002 " // find the text for the node..",
1003 " this.view.load( prop.val );",
1004 " this.close_btn.el.show(); ",
1007 " this.view.load( file.toSource() );",
1008 " this.close_btn.el.hide();",
1018 "path" : "/home/alan/gitlive/roobuilder/src/Builder4/Editor.bjs",