2 "build_module" : "builder",
3 "gen_extended" : false,
6 "# Gtk.Widget lastObj" : "null",
7 "# GtkSource.SearchContext searchcontext" : "",
8 "# JsRender.JsRender file" : "null",
9 "# Xcls_MainWindow main_window" : "",
14 "\tthis.css = new Gtk.CssProvider();",
16 "\tthis.css.load_from_string(",
17 "\t\t\"#gtkview-view-layout { background-color: #ccc; }\"",
20 "\tGtk.StyleContext.add_provider_for_display(",
21 "\t\tthis.el.get_display(),",
23 "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
30 "Gtk.CssProvider css" : "",
31 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
32 "bool hexpand" : true,
33 "bool vexpand" : true,
35 "int last_error_counter" : 0,
36 "int last_search_end" : 0,
40 "Gtk.Overflow overflow" : "Gtk.Overflow.VISIBLE",
46 "id" : "label_preview",
47 "utf8 label" : "Preview",
54 "utf8 label" : "Preview Generated Code",
59 "* pack" : "append_page,_this.label_preview.el",
63 "* pack" : "set_child",
68 "* pack" : "put,10,10",
69 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
74 "string name" : "gtkview-view-layout",
78 "xtype" : "ScrolledWindow"
82 "* pack" : "append_page,_this.label_code.el",
83 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
88 "bool vexpand" : true,
89 "id" : "sourceviewscroll",
92 "# JsRender.Node? node_selected" : "",
93 "# string prop_selected" : "\"\"",
94 "$ xns" : "GtkSource",
99 " \tthis.css = new Gtk.CssProvider();",
101 "\tthis.css.load_from_string(\"#gtkview-view { font: 10px monospace ;}\");",
103 "\tGtk.StyleContext.add_provider_for_display(",
104 "\t\tthis.el.get_display(),",
106 "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
110 " this.loading = true;",
114 " var attrs = new GtkSource.MarkAttributes();",
115 " var pink = Gdk.RGBA();",
116 " pink.parse ( \"pink\");",
117 " attrs.set_background ( pink);",
118 " attrs.set_icon_name ( \"process-stop\"); ",
119 " attrs.query_tooltip_text.connect(( mark) => {",
120 " //print(\"tooltip query? %s\\n\", mark.name);",
121 " return mark.name;",
124 " this.el.set_mark_attributes (\"ERR\", attrs, 1);",
126 " var wattrs = new GtkSource.MarkAttributes();",
127 " var blue = Gdk.RGBA();",
128 " blue.parse ( \"#ABF4EB\");",
129 " wattrs.set_background ( blue);",
130 " wattrs.set_icon_name ( \"process-stop\"); ",
131 " wattrs.query_tooltip_text.connect(( mark) => {",
132 " //print(\"tooltip query? %s\\n\", mark.name);",
133 " return mark.name;",
136 " this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
140 " var dattrs = new GtkSource.MarkAttributes();",
141 " var purple = Gdk.RGBA();",
142 " purple.parse ( \"#EEA9FF\");",
143 " dattrs.set_background ( purple);",
144 " dattrs.set_icon_name ( \"process-stop\"); ",
145 " dattrs.query_tooltip_text.connect(( mark) => {",
146 " //print(\"tooltip query? %s\\n\", mark.name);",
147 " return mark.name;",
150 " this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
153 " var gattrs = new GtkSource.MarkAttributes();",
154 " var grey = Gdk.RGBA();",
155 " grey.parse ( \"#ccc\");",
156 " gattrs.set_background ( grey);",
159 " this.el.set_mark_attributes (\"grey\", gattrs, 1);",
169 "* pack" : "set_child",
170 "Gtk.CssProvider css" : "",
171 "bool loading" : false,
172 "bool zallow_node_scroll" : true,
173 "gboolean editable" : false,
174 "gboolean show_line_marks" : true,
175 "gboolean show_line_numbers" : true,
179 "$ xns" : "GtkSource",
180 "* pack" : "set_buffer",
181 "bool dirty" : false,
182 "bool in_cursor_change" : false,
184 "int error_line" : "-1",
185 "int last_line" : "-1",
189 "GLib.debug(\"cursor moved called\");",
192 " \tif (this.in_cursor_change ) {",
193 " GLib.debug(\"cursor changed : %d [ignoring nested call)\", this.el.cursor_position);",
197 " GLib.debug(\"cursor changed : %d\", this.el.cursor_position);",
198 " Gtk.TextIter cpos;",
199 " this.el.get_iter_at_offset(out cpos, this.el.cursor_position);",
201 " var ln = cpos.get_line();",
202 " if (this.last_line == ln ){",
205 "\tthis.last_line = ln;",
206 " var node = _this.file.lineToNode(ln);",
208 " if (node == null) {",
209 " print(\"can not find node\\n\");",
212 " this.in_cursor_change = true;",
213 " var ltree = _this.main_window.windowstate.left_tree;",
214 " ltree.model.selectNode(node);",
215 " this.in_cursor_change = false;",
226 "(keyval, keycode, state) => {",
230 "\t if (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
231 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
232 "\t\t_this.forwardSearch(true);",
235 " if (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
236 "\t GLib.debug(\"SAVE: ctrl-f pressed\");",
237 "\t\t_this.search_entry.el.grab_focus();",
246 "xtype" : "EventControllerKey"
251 "(x, y, keyboard_tooltip, tooltip) => {",
253 "\t//GLib.debug(\"query tooltip\");",
254 "\tGtk.TextIter iter;",
257 "\tvar yoff = (int) _this.sourceviewscroll.el.vadjustment.value;",
259 "\tthis.el.get_iter_at_position (out iter, out trailing, x, y + yoff);",
261 "\tvar l = iter.get_line();",
262 "\t// GLib.debug(\"query tooltip line %d\", (int) l);",
263 "\tvar marks = _this.buffer.el.get_source_marks_at_line(l, \"ERR\");",
264 "\tif (marks.is_empty()) {",
265 "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"WARN\");",
267 "\tif (marks.is_empty()) {",
268 "\t\tmarks = _this.buffer.el.get_source_marks_at_line(l, \"DEPR\");",
271 "\t// GLib.debug(\"query tooltip line marks %d\", (int) marks.length());",
273 "\tmarks.@foreach((m) => { ",
274 "\t\t//GLib.debug(\"got mark %s\", m.name);",
275 "\t\tstr += (str.length > 0 ? \"\\n\" : \"\") + m.name;",
278 "\t// true if there is a mark..",
279 "\ttooltip.set_text( str);",
280 "\treturn str.length > 0 ? true : false;",
286 "string name" : "gtkview-view",
287 "uint tab_width" : 4,
289 "| string toString" : [
293 " this.el.get_buffer().get_start_iter(out s);",
294 " this.el.get_buffer().get_end_iter(out e);",
295 " var ret = this.el.get_buffer().get_text(s,e,true);",
296 " //print(\"TO STRING? \" + ret);",
301 "| void loadFile" : [
303 " this.loading = true;",
304 " var buf = this.el.get_buffer();",
305 " buf.set_text(\"\",0);",
306 " var sbuf = (GtkSource.Buffer) buf;",
307 "\tvar cpos = buf.cursor_position;",
309 " \tprint(\"BEFORE LOAD cursor = %d\\n\", cpos);",
310 " var vadj_pos = this.el.get_vadjustment().get_value();",
312 " if (_this.file == null || _this.file.xtype != \"Gtk\") {",
313 " print(\"xtype != Gtk\");",
314 " this.loading = false;",
318 " var valafn = \"\";",
320 " var regex = new Regex(\"\\\\.bjs$\");",
323 " valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
324 " } catch (GLib.RegexError e) {",
325 " this.loading = false;",
330 " if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) {",
331 " print(\"File path has no errors\\n\");",
332 " this.loading = false;",
339 " GLib.FileUtils.get_contents (valafn, out str);",
340 " } catch (Error e) {",
341 " this.loading = false;",
345 " var str = _this.file.toSource();",
347 "// print(\"setting str %d\\n\", str.length);",
348 " buf.set_text(str, str.length);",
349 " var lm = GtkSource.LanguageManager.get_default();",
351 " //?? is javascript going to work as js?",
353 " ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language));",
356 " _this.main_window.windowstate.updateErrorMarksAll(); ",
357 " // restore the cursor position?",
358 " // after reloading the contents.",
359 " GLib.Timeout.add(500, () => {",
360 "\t\t_this.buffer.in_cursor_change = true;",
361 " print(\"RESORTING cursor to = %d\\n\", cpos);",
362 "\t\tGtk.TextIter cpos_iter;",
363 "\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);",
364 "\t\tbuf.place_cursor(cpos_iter); ",
366 "\t\tthis.el.get_vadjustment().set_value(vadj_pos);;",
367 "\t\t_this.buffer.in_cursor_change = false;",
371 "\t\t//_this.buffer.checkSyntax();",
376 " this.loading = false; ",
380 "| void nodeSelected" : [
381 "(JsRender.Node? sel, bool scroll) {",
384 " if (this.loading) {",
387 " // this is connected in widnowstate",
388 " print(\"Roo-view - node selected\\n\");",
389 " var buf = this.el.get_buffer();",
391 " var sbuf = (GtkSource.Buffer) buf;",
397 " // clear all the marks..",
398 " Gtk.TextIter start;",
399 " Gtk.TextIter end; ",
401 " sbuf.get_bounds (out start, out end);",
402 " sbuf.remove_source_marks (start, end, \"grey\");",
404 " this.node_selected = sel;",
405 " if (sel == null) {",
406 " // no highlighting..",
409 " Gtk.TextIter iter; ",
410 " sbuf.get_iter_at_line(out iter, sel.line_start);",
413 " Gtk.TextIter cur_iter;",
414 " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
417 " if (!_this.buffer.in_cursor_change) {",
419 " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
424 " for (var i = 0; i < buf.get_line_count();i++) {",
425 " if (i < sel.line_start || i > sel.line_end) {",
427 " sbuf.get_iter_at_line(out iter, i);",
428 " sbuf.create_source_mark(null, \"grey\", iter);",
440 "xtype" : "ScrolledWindow"
444 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
445 "bool homogeneous" : false,
446 "bool vexpand" : false,
453 "this.css = new Gtk.CssProvider();",
455 "this.css.load_from_string(\"",
456 "\t#gtkview-search-entry { font: 10px monospace ;}\"",
459 "Gtk.StyleContext.add_provider_for_display(",
460 "\tthis.el.get_display(),",
462 "\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
468 "Gtk.CssProvider css" : "",
469 "bool hexpand" : true,
470 "id" : "search_entry",
476 "(keyval, keycode, state) => {",
478 "\tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
479 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
480 "\t\t_this.forwardSearch(true);",
485 " \tif (keyval == Gdk.Key.Return && _this.search_entry.el.text.length > 0) {",
486 "\t\t_this.forwardSearch(true);",
492 " // print(event.key.keyval)",
499 "xtype" : "EventControllerKey"
506 "\t_this.search(_this.search_entry.el.text);",
507 "\t _this.search_results.updateResults();",
509 "\tGLib.Timeout.add_seconds(1,() => {",
510 "\t\t _this.search_results.updateResults();",
511 "\t\t return false;",
519 "string name" : "gtkview-search-entry",
520 "string placeholder_text" : "Press enter to search",
521 "uint search_delay" : 3,
522 "xtype" : "SearchEntry",
523 "| void forwardSearch" : [
524 "(bool change_focus) {",
527 "\t_this.forwardSearch(change_focus);",
531 "\tswitch(_this.windowstate.state) {",
532 "\t\tcase WindowState.State.CODEONLY:",
533 "\t\t//case WindowState.State.CODE:",
534 "\t\t\t// search the code being edited..",
535 "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
538 "\t\tcase WindowState.State.PREVIEW:",
539 "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
540 "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
542 "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
555 "id" : "search_results",
556 "int margin_end" : 4,
557 "int margin_start" : 4,
558 "string label" : "No Results",
560 "| void updateResults" : [
562 "\tthis.el.visible = true;",
564 "\tvar res = _this.searchcontext.get_occurrences_count();",
566 "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
570 "\t_this.nextBtn.el.sensitive = false;",
571 "\t_this.backBtn.el.sensitive = false;\t",
574 "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
575 "\t\t_this.nextBtn.el.sensitive = true;",
576 "\t\t_this.backBtn.el.sensitive = true;",
579 "\t_this.search_results.el.label = \"No Matches\";",
586 "bool always_show_image" : true,
587 "bool sensitive" : false,
592 "_this.forwardSearch(true);",
599 "string icon_name" : "go-down",
604 "bool always_show_image" : true,
605 "bool sensitive" : false,
611 "_this.backSearch(true);",
617 "string icon_name" : "go-up",
622 "bool always_show_arrow" : true,
623 "bool always_show_image" : true,
627 "* ctor" : "new Gtk.PopoverMenu.from_model(null)",
628 "* prop" : "popover",
629 "id" : "search_settings",
633 "* pack" : "set_child",
634 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
639 "id" : "case_sensitive",
640 "string label" : "Case Sensitive",
641 "xtype" : "CheckButton"
646 "string label" : "Regex",
647 "xtype" : "CheckButton"
652 "string label" : "Multi-line (add \\n)",
653 "xtype" : "CheckButton"
659 "xtype" : "PopoverMenu"
662 "string icon_name" : "emblem-system",
663 "xtype" : "MenuButton"
678 "\tthis.notebook.el.page = 1;",
682 "\tvar s = new GtkSource.SearchSettings();",
683 "\ts.case_sensitive = _this.case_sensitive.el.active;",
684 "\ts.regex_enabled = _this.regex.el.active;\t",
685 "\ts.wrap_around = false;",
687 "\tthis.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);",
688 "\tthis.searchcontext.set_highlight(true);",
689 "\tvar txt = in_txt;",
691 "\tif (_this.multiline.el.active) {",
692 "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
695 "\ts.set_search_text(txt);",
696 "\tGtk.TextIter beg, st,en;",
697 "\tbool has_wrapped_around;",
698 "\tthis.buffer.el.get_start_iter(out beg);",
699 "\tthis.searchcontext.forward(beg, out st, out en, out has_wrapped_around);",
700 "\tthis.last_search_end = 0;",
702 "\treturn this.searchcontext.get_occurrences_count();",
710 "| void backSearch" : [
711 "(bool change_focus) {",
713 "\tif (this.searchcontext == null) {",
717 "\tGtk.TextIter beg, st,en;",
718 "\tbool has_wrapped_around;",
719 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
721 "\tif (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {",
723 "\t\tthis.last_search_end = 0;",
726 "\tthis.last_search_end = en.get_offset();",
727 "\tif (change_focus) {",
728 "\t\tthis.sourceview.el.grab_focus();",
730 "\tthis.buffer.el.place_cursor(st);",
731 "\tthis.sourceview.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
732 "\tvar ln = st.get_line();",
733 "\tthis.highlightNodeAtLine(ln);",
738 "| void createThumb" : [
742 " if (this.file == null) {",
745 " // only screenshot the gtk preview..",
746 " if (this.notebook.el.page > 0 ) {",
751 " \tthis.file.widgetToIcon(this.container.el); ",
760 " // should we hold until it's printed...",
768 "| void forwardSearch" : [
769 "(bool change_focus) {",
771 "\tif (this.searchcontext == null) {",
774 "\tthis.notebook.el.page = 1;",
775 "\tGtk.TextIter beg, st,en;",
776 "\tbool has_wrapped_around;",
777 "\tvar buf = this.sourceview.el.get_buffer();",
778 "\tbuf.get_iter_at_offset(out beg, this.last_search_end);",
779 "\tif (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {",
780 "\t\tthis.last_search_end = 0;",
783 "\tthis.last_search_end = en.get_offset();",
784 "\tif (change_focus) {",
785 "\t\tthis.sourceview.el.grab_focus();",
787 "\tbuf.place_cursor(st);",
791 "\tthis.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f);",
794 "\tvar ln = st.get_line();",
796 "\tthis.highlightNodeAtLine(ln);",
800 "| void highlightNodeAtLine" : [
803 "\t// this is done from clicking on the editor..",
805 "\t// highlight node...",
808 " var node = _this.file.lineToNode(ln+1);",
810 " if (node == null) {",
811 " //print(\"can not find node\\n\");",
814 " var prop = node.lineToProp(ln+1);",
815 " print(\"prop : %s\", prop == null ? \"???\" : prop.name);",
818 " // ---------- this selects the tree's node...",
820 " var ltree = _this.main_window.windowstate.left_tree;",
821 " ltree.model.selectNode(node);",
822 " //var tp = ltree.model.treePathFromNode(node);",
824 " //print(\"got tree path %s\\n\", tp);",
825 " //if (tp == \"\") {",
828 " //_this.sourceview.allow_node_scroll = false; /// block node scrolling..",
831 " //print(\"changing cursor on tree..\\n\");",
835 " // let's try allowing editing on the methods.",
836 " // a little klunky at present..",
837 "\t_this.sourceview.prop_selected = \"\";",
839 " if (prop != null) {",
840 "\t\t//see if we can find it..",
841 "\t\tvar kv = prop.split(\":\");",
842 "\t\tif (kv[0] == \"p\") {",
844 " \t\t//var k = prop.get_key(kv[1]);",
845 " \t\t// fixme -- need to determine if it's an editable property...",
846 " \t\t_this.sourceview.prop_selected = prop;",
848 "\t\t} else if (kv[0] == \"l\") {",
849 "\t\t\t _this.sourceview.prop_selected = prop;",
854 " //ltree.view.setCursor(tp, \"editor\");",
855 " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
856 " _this.sourceview.nodeSelected(node,false);",
858 " // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
859 " // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
860 "\t // this.allow_node_scroll = true;",
861 "\t // return false;",
878 "| void loadFile" : [
879 "(JsRender.JsRender file) ",
881 " this.file = null;",
883 " if (file.tree == null) {",
886 " this.last_error_counter = -1;",
887 " this.notebook.el.page = 0;// gtk preview ",
891 " this.file = file; ",
892 " this.sourceview.loadFile();",
894 " this.searchcontext = null;",
895 " this.last_error_counter = -1;",
896 "\t\tthis.updateErrorMarks();",
897 " if (this.lastObj != null) {",
898 " this.container.el.remove(this.lastObj);",
901 " // hide the compile view at present..",
904 " var w = this.el.get_width();",
905 " var h = this.el.get_height();",
907 " print(\"ALLOC SET SIZES %d, %d\\n\", w,h); ",
909 " // set the container size min to 500/500 or 20 px less than max..",
910 " w = int.max (w-20, 500);",
911 " h = int.max (h-20, 500); ",
913 " print(\"SET SIZES %d, %d\\n\", w,h); ",
914 " _this.container.el.set_size_request(w,h);",
916 " _this.view_layout.el.set_size_request(w,h); ",
917 " // should be baded on calc.. -- see update_scrolled.",
919 " var fc = this.container.el.get_first_child();",
920 " if (fc != null) {",
921 " \t\tthis.container.el.remove(fc);",
924 " \t\tvar xmlstr = JsRender.NodeToGlade.mungeFile( file);",
925 " \t\tvar builder = new Gtk.Builder.from_string (xmlstr, xmlstr.length);",
926 " \t\tvar obj = (Gtk.Widget) builder.get_object(\"w\"+ file.tree.oid.to_string());",
927 " \t\t this.container.el.append(obj);",
929 " this.createThumb();",
937 "| void scroll_to_line" : [
939 " // code preview...",
941 " GLib.Timeout.add(100, () => {",
944 "\t this.notebook.el.set_current_page(1);",
946 "\t\t var buf = this.sourceview.el.get_buffer();",
948 "\t\tvar sbuf = (GtkSource.Buffer) buf;",
951 "\t\tGtk.TextIter iter; ",
952 "\t\tsbuf.get_iter_at_line(out iter, line);",
953 "\t\tthis.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
961 "| void updateErrorMarks" : [
966 "\tvar buf = _this.buffer.el;",
967 "\tGtk.TextIter start;",
968 "\tGtk.TextIter end; ",
969 "\tbuf.get_bounds (out start, out end);",
973 "\tGLib.debug(\"highlight errors\");\t\t ",
975 "\t // we should highlight other types of errors..",
980 "\tif (_this.file == null) {",
981 "\t\tGLib.debug(\"file is null?\");",
985 "\tvar ar = this.file.getErrors();",
986 "\tif (ar.size < 1) {",
987 "\t\tbuf.remove_source_marks (start, end, null);",
988 "\t\tthis.last_error_counter = file.error_counter ;",
989 "\t\tGLib.debug(\"higjlight has no errors\");",
992 " \tif (this.last_error_counter == file.error_counter) {",
1000 "\tvar tlines = buf.get_line_count () +1;",
1004 "\tbuf.remove_source_marks (start, end, null);",
1005 "\tforeach(var diag in ar) { ",
1008 "\t Gtk.TextIter iter;",
1009 "// print(\"get inter\\n\");",
1010 "\t var eline = (int)diag.range.start.line ;",
1012 "\t if (eline > tlines || eline < 0) {",
1017 "\t buf.get_iter_at_line( out iter, eline);",
1021 "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, diag.category, diag.message);",
1022 "\t buf.create_source_mark( msg, diag.category, iter);",
1023 "\t GLib.debug(\"set line %d to %s\", eline, msg);",
1024 "\t //this.marks.set(eline, msg);",
1026 "\tthis.last_error_counter = file.error_counter ;",