2 "build_module" : "builder",
3 "gen_extended" : false,
6 "# Gtk.Widget lastObj" : "null",
7 "# JsRender.JsRender file" : "null",
8 "# Xcls_MainWindow main_window" : "",
10 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
11 "GtkSource.SearchContext searchcontext" : "",
12 "bool hexpand" : true,
13 "bool vexpand" : true,
14 "id" : "WindowRooView",
15 "int last_search_end" : 0,
19 "bool vexpand" : true,
25 "id" : "label_preview",
26 "utf8 label" : "Preview",
33 "utf8 label" : "Preview Generated Code",
38 "* pack" : "append_page,_this.label_preview.el",
39 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
40 "bool vexpand" : true,
44 "$ homogeneous" : false,
46 "* pack" : "set_start_child",
47 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
48 "bool vexpand" : true,
52 "$ height_request" : 20,
53 "$ homogeneous" : true,
56 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
64 " _this.view.renderJS( true);",
74 "label" : "Auto Redraw On",
78 " this.el.set_label(this.el.active ? \"Auto Redraw On\" : \"Auto Redraw Off\");",
82 "xtype" : "CheckButton"
86 "label" : "Full Redraw",
90 " _this.view.redraws = 99;",
91 " // _this.view.el.web_context.clear_cache(); ",
92 " //_this.view.renderJS(true);",
93 " FakeServerCache.clear();",
94 " _this.view.reInit();",
105 "# GLib.DateTime lastRedraw" : "null",
106 "# WebKit.WebInspector inspector" : "",
107 "# bool pendingRedraw" : false,
108 "# bool refreshRequired" : false,
110 "# string renderedData" : "\"\"",
111 "# string runhtml" : "\"\"",
112 "# string runjs" : "\"\"",
116 " // this may not work!?",
117 " var settings = this.el.get_settings();",
118 " settings.enable_developer_extras = true;",
121 " var fs= new FakeServer(this.el);",
123 " // this was an attempt to change the url perms.. did not work..",
124 " // settings.enable_file_access_from_file_uris = true;",
125 " // settings.enable_offline_web_application_cache - true;",
126 " // settings.enable_universal_access_from_file_uris = true;",
133 " // FIXME - base url of script..",
134 " // we need it so some of the database features work.",
135 " this.el.load_html( \"Render not ready\" , ",
136 " //fixme - should be a config option!",
137 " // or should we catch stuff and fix it up..",
138 " \"http://localhost/app.Builder/\"",
142 " //this.el.open('file:///' + __script_path__ + '/../builder.html');",
144 " Gtk.drag_dest_set",
147 " Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,",
148 " null, // list of targets",
149 " Gdk.DragAction.COPY // what to do with data after dropped ",
152 " // print(\"RB: TARGETS : \" + LeftTree.atoms[\"STRING\"]);",
153 " Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);",
155 " GLib.Timeout.add_seconds(1, () =>{",
156 " //print(\"run refresh?\");",
157 " if (this.el == null) {",
160 " this.runRefresh(); ",
168 "bool vexpand" : true,
173 " if (le != WebKit.LoadEvent.FINISHED) {",
176 " if (this.runjs.length < 1) {",
179 " // this.el.run_javascript(this.runjs, null);",
180 " FakeServerCache.remove( this.runjs);",
181 " this.runjs = \"\";",
186 " this.initInspector();",
195 " if (this.el == null) {",
199 " var msg = dialog.get_message();",
200 " if (msg.length < 4) {",
204 " GLib.debug(\"script dialog got %s\", msg);",
206 " if (msg.substring(0,4) != \"IPC:\") {",
209 " var ar = msg.split(\":\", 3);",
210 " if (ar.length < 3) {",
215 " case \"SAVEHTML\":",
216 "\t GLib.debug(\"GOT saveHTML %d\", ar[2].length);",
217 " _this.file.saveHTML(ar[2]);",
218 " _this.createThumb();",
228 "| void initInspector" : [
233 " // this.inspector.open_window.connect(() => {",
234 " this.inspector = this.el.get_inspector();",
236 " this.inspector.open_window.connect(() => {",
237 " print(\"inspector attach\\n\");",
238 " var wv = this.inspector.get_web_view();",
239 " if (wv != null) {",
240 " print(\"got inspector web view\\n\");",
242 " var cn = _this.inspectorcontainer.el.get_first_child();",
243 " if (cn != null) {",
244 " _this.inspectorcontainer.el.remove(cn);",
247 " _this.inspectorcontainer.el.append(wv);",
250 "\t print(\"got inspector web view FAILED\\n\");",
251 " //this.inspector.close();",
253 " //this.inspector = null;",
260 " this.inspector.show();",
269 " print(\"reInit?\");",
270 " // if this happens destroy the webkit..",
272 " this.el.stop_loading();",
274 " if (_this.viewbox.el.get_parent() == null) {",
279 " _this.viewbox.el.remove(_this.viewcontainer.el);",
280 " //_this.paned.el.remove(_this.inspectorcontainer.el); ",
282 " // destory seems to cause problems.",
283 " //this.el.destroy();",
284 " //_this.viewcontainer.el.destroy();",
285 " //_this.inspectorcontainer.el.destroy();",
286 " var inv =new Xcls_inspectorcontainer(_this);",
288 " _this.paned.el.set_end_child(inv.el);",
289 " _this.inspectorcontainer = inv;",
292 " var nv =new Xcls_viewcontainer(_this);",
294 " _this.viewbox.el.append(nv.el);",
296 " _this.viewcontainer = nv;",
299 " //while(Gtk.events_pending ()) Gtk.main_iteration ();",
300 " //_this.view.renderJS(true); ",
301 " _this.view.refreshRequired = true;",
307 "| void renderJS" : [
310 " // this is the public redraw call..",
311 " // we refresh in a loop privately..",
312 " var autodraw = _this.AutoRedraw.el.active;",
313 " if (!autodraw && !force) {",
314 " print(\"Skipping redraw - no force, and autodraw off\");",
318 " this.refreshRequired = true;",
322 "| void runRefresh" : [
325 " // this is run every 2 seconds from the init..",
329 " if (!this.refreshRequired) {",
330 " // print(\"no refresh required\");",
334 " if (this.lastRedraw != null) {",
335 " // do not redraw if last redraw was less that 5 seconds ago.",
336 " if ((int64)(new DateTime.now_local()).difference(this.lastRedraw) < 5000 ) {",
341 " if (_this.file == null) {",
346 " this.refreshRequired = false;",
347 " // print(\"HTML RENDERING\");",
350 " //this.get('/BottomPane').el.show();",
351 " //this.get('/BottomPane').el.set_current_page(2);// webkit inspector",
352 " _this.file.webkit_page_id = this.el.get_page_id();",
354 " var js = _this.file.toSourcePreview();",
356 " if (js.length < 1) {",
357 " print(\"no data\");",
360 "// var data = js[0];",
363 " var project = (Project.Roo) _this.file.project; ",
365 " //print (project.fn);",
366 " // set it to non-empty.",
368 "// runhtml = runhtml.length ? runhtml : '<script type=\"text/javascript\"></script>'; ",
371 "// this.runhtml = this.runhtml || '';",
374 " // then we need to reload the browser using",
375 " // load_html_string..",
377 " // then trigger a redraw once it's loaded..",
378 " this.pendingRedraw = true;",
380 " var runhtml = \"<script type=\\\"text/javascript\\\">\\n\" ;",
381 " string builderhtml;",
384 " GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + \"/resources/roo.builder.js\", out builderhtml);",
385 " } catch (Error e) {",
386 " builderhtml = \"\";",
389 " runhtml += builderhtml + \"\\n\";",
390 " runhtml += \"</script>\\n\" ;",
392 " // fix to make sure they are the same..",
393 " this.runhtml = project.runhtml;",
394 " // need to modify paths",
397 " var base_template = project.base_template;",
399 " if (base_template.length > 0 && !FileUtils.test(",
400 " BuilderApplication.configDirectory() + \"/resources/\" + base_template, FileTest.EXISTS) ",
402 " print(\"invalid base_template name - using default: %s\\n\", base_template);",
403 " base_template = \"\";",
407 " GLib.FileUtils.get_contents(",
408 " BuilderApplication.configDirectory() + \"/resources/\" + ",
409 " (base_template.length > 0 ? base_template : \"roo.builder.html\")",
412 " } catch (Error e) {",
415 " this.renderedData = js;",
418 " string js_src = js + \"",
419 "Roo.onReady(function() {",
420 "if (\" + _this.file.name +\".show) {",
421 "\t\t\" + _this.file.name +\".show({});",
422 "\t\t(function() { ",
423 "\t\t\tBuilder.saveHTML.defer(100, Builder);",
424 "\t\t}).defer(100);",
426 "Roo.XComponent.build();",
429 " // print(\"render js: \" + js);",
430 " //if (!this.ready) {",
431 " // console.log('not loaded yet');",
433 " this.lastRedraw = new DateTime.now_local();",
436 " //this.runjs = js_src;",
437 " var fc = FakeServerCache.factory_with_data(js_src);",
438 " this.runjs = fc.fname;",
440 " var html = inhtml.replace(\"</head>\", runhtml + this.runhtml + ",
441 " \"<script type=\\\"text/javascript\\\" src=\\\"xhttp://localhost\" + fc.fname + \"\\\"></script>\" + ",
442 " // \"<script type=\\\"text/javascript\\\">\\n\" +",
443 " // js_src + \"\\n\" + ",
444 " // \"</script>\" + ",
447 " //print(\"LOAD HTML \" + html);",
449 " var rootURL = project.rootURL;",
453 " this.el.load_html( html , ",
454 " //fixme - should be a config option!",
455 " (rootURL.length > 0 ? rootURL : \"xhttp://localhost/roobuilder/\")",
457 " this.initInspector(); ",
458 " // force the inspector... ",
459 " // this.initInspector();",
461 " // - no need for this, the builder javascript will call it when build is complete",
462 " //GLib.Timeout.add_seconds(1, () => {",
463 " // this.el.run_javascript(\"Builder.saveHTML()\",null);",
466 "// print( \"before render\" + this.lastRedraw);",
467 "// print( \"after render\" + (new Date()));",
478 "* pack" : "set_end_child",
479 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
480 "bool vexpand" : true,
481 "id" : "inspectorcontainer",
489 "* pack" : "append_page,_this.label_code.el",
490 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
491 "bool vexpand" : true,
496 "bool vexpand" : true,
497 "id" : "sourceviewscroll",
500 "# JsRender.Node? node_selected" : "null",
501 "# bool button_is_pressed" : false,
502 "# bool key_is_pressed" : false,
503 "# bool loading" : true,
504 "# int editable_start_pos" : "-1",
505 "# string prop_selected" : "\"\"",
506 "$ xns" : "GtkSource",
510 " this.css = new Gtk.CssProvider();",
512 "\tthis.css.load_from_string(",
513 "\t\t\"#roo-view { font: 10px monospace; }\"",
516 "\tGtk.StyleContext.add_provider_for_display(",
517 "\t\tthis.el.get_display(),",
519 "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
524 " this.loading = true;",
525 " //var buf = this.el.get_buffer();",
526 " //buf.notify.connect(this.onCursorChanged);",
529 " var attrs = new GtkSource.MarkAttributes();",
530 " var pink = Gdk.RGBA();",
531 " pink.parse ( \"pink\");",
532 " attrs.set_background ( pink);",
533 " attrs.set_icon_name ( \"process-stop\"); ",
534 " attrs.query_tooltip_text.connect(( mark) => {",
535 " //print(\"tooltip query? %s\\n\", mark.name);",
536 " return mark.name;",
539 " this.el.set_mark_attributes (\"ERR\", attrs, 1);",
541 " var wattrs = new GtkSource.MarkAttributes();",
542 " var blue = Gdk.RGBA();",
543 " blue.parse ( \"#ABF4EB\");",
544 " wattrs.set_background ( blue);",
545 " wattrs.set_icon_name ( \"process-stop\"); ",
546 " wattrs.query_tooltip_text.connect(( mark) => {",
547 " //print(\"tooltip query? %s\\n\", mark.name);",
548 " return mark.name;",
551 " this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
555 " var dattrs = new GtkSource.MarkAttributes();",
556 " var purple = Gdk.RGBA();",
557 " purple.parse ( \"#EEA9FF\");",
558 " dattrs.set_background ( purple);",
559 " dattrs.set_icon_name ( \"process-stop\"); ",
560 " dattrs.query_tooltip_text.connect(( mark) => {",
561 " //print(\"tooltip query? %s\\n\", mark.name);",
562 " return mark.name;",
565 " this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
568 " var gattrs = new GtkSource.MarkAttributes();",
569 " var grey = Gdk.RGBA();",
570 " grey.parse ( \"#ccc\");",
571 " gattrs.set_background ( grey);",
574 " this.el.set_mark_attributes (\"grey\", gattrs, 1);",
584 "* pack" : "set_child",
585 "Gtk.CssProvider css" : "",
586 "gboolean editable" : false,
587 "gboolean show_line_marks" : true,
588 "gboolean show_line_numbers" : true,
592 "$ xns" : "GtkSource",
593 "* pack" : "set_buffer",
594 "bool dirty" : false,
596 "int error_line" : "-1",
601 " // check syntax??",
603 " // _this.save_button.el.sensitive = true;",
604 " ///?? has changed occured during loading?",
606 " // only trigger this if ",
611 " if (_this.sourceview.loading) {",
617 " print(\"- PREVIEW EDITOR CHANGED--\");",
619 " this.dirty = true; ",
620 " // this.checkSyntax(); // this calls backs and highlights errors.. in theory... ",
624 "\tif (!_this.sourceview.button_is_pressed && !_this.sourceview.key_is_pressed) {",
625 "\t\tprint(\"button or key not pressed to generate change?!\\n\");",
630 "\t// what are we editing??",
631 "\tif (null == _this.sourceview.node_selected || _this.sourceview.prop_selected.length < 1) {",
635 "\t// find the colon on the first line...",
637 "\tif (_this.sourceview.editable_start_pos > -1) {",
639 "\t\tvar buf = (GtkSource.Buffer)_this.sourceview.el.get_buffer();",
641 " //print(\"cursor changed : %d\\n\", buf.cursor_position);",
642 " Gtk.TextIter spos,epos;",
643 " buf.get_iter_at_offset(out spos, _this.sourceview.editable_start_pos);",
644 " buf.get_iter_at_offset(out epos, _this.sourceview.editable_start_pos); // initialize epos..",
646 " var gotit= false;",
647 " var line = spos.get_line();",
648 " var endline = buf.get_line_count();",
649 " while (line < endline) {",
651 "\t buf.get_iter_at_line(out epos, line);",
652 "\t if (buf.get_source_marks_at_line(line, \"grey\").length() > 0) {",
653 "\t\t buf.get_iter_at_line(out epos, line);\t \t\t",
654 "\t \t\tgotit=true;",
660 "\t \t\tprint(\"End Offset = %d/%d\\n\", epos.get_line(), epos.get_offset());",
661 "\t\t\t// get the pos...",
662 "\t\t\t// in theory the last char will be '}' or '},' .. or ','",
663 "\t\t\t// we should chop the ',' of the end...",
664 "\t\t\tvar str = buf.get_text(spos, epos, false);",
665 "\t\t\tprint(\"got string\\n%s\\n\", str);",
677 "| bool highlightErrors" : [
678 "( Gee.HashMap<int,string> validate_res) {",
680 " this.error_line = validate_res.size;",
682 " if (this.error_line < 1) {",
685 " var tlines = this.el.get_line_count ();",
686 " Gtk.TextIter iter;",
687 " var valiter = validate_res.map_iterator();",
688 " while (valiter.next()) {",
690 "// print(\"get inter\\n\");",
691 " var eline = valiter.get_key();",
692 " if (eline > tlines) {",
695 " this.el.get_iter_at_line( out iter, eline);",
696 " //print(\"mark line\\n\");",
697 " this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
702 "| string toString" : [
707 " this.el.get_start_iter(out s);",
708 " this.el.get_end_iter(out e);",
709 " var ret = this.el.get_text(s,e,true);",
710 " //print(\"TO STRING? \" + ret);",
718 "* pack" : "add_controller",
721 "(keyval, keycode, state) => {",
725 " \tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
726 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
727 "\t\t_this.forwardSearch(true);",
730 "\tif (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
731 "\t GLib.debug(\"SAVE: ctrl-f pressed\");",
732 "\t\t_this.search_entry.el.grab_focus();",
736 "\t//this.button_is_pressed = true;",
738 " // print(event.key.keyval)",
747 "xtype" : "EventControllerKey"
753 "(n_press, x, y) => {",
755 "\tprint(\"BUTTON RELEASE EVENT\\n\");",
756 "\t_this.sourceview.onCursorChanged();",
757 "\t//this.button_is_pressed = false;",
763 "xtype" : "GestureClick"
768 "(x, y, keyboard_tooltip, tooltip) => {",
770 "\t//GLib.debug(\"query tooltip\");",
771 "\tGtk.TextIter iter;",
774 "\tvar yoff = (int) _this.sourceviewscroll.el.vadjustment.value;",
776 "\tthis.el.get_iter_at_position (out iter, out trailing, x, y + yoff);",
778 "\tvar l = iter.get_line();",
779 "\t//GLib.debug(\"query tooltip line %d\", (int) l);",
780 "\tvar marks = _this.buffer.el.get_source_marks_at_line(l, null);",
781 "\t//GLib.debug(\"query tooltip line marks %d\", (int) marks.length());",
783 "\tmarks.@foreach((m) => { ",
784 "\t\t//GLib.debug(\"got mark %s\", m.name);",
785 "\t\tstr += (str.length > 0 ? \"\\n\" : \"\") + m.name;",
787 "\t// true if there is a mark..",
788 "\tif (str.length > 0 ) {",
789 "\t\t\ttooltip.set_text( str);",
791 "\treturn str.length > 0 ? true : false;",
796 "string name" : "roo-view",
798 "| string toString" : [
802 " this.el.get_buffer().get_start_iter(out s);",
803 " this.el.get_buffer().get_end_iter(out e);",
804 " var ret = this.el.get_buffer().get_text(s,e,true);",
805 " //print(\"TO STRING? \" + ret);",
810 "| void clearGreySelection" : [
812 " // clear all the marks..",
813 " var sbuf = (GtkSource.Buffer)this.el.buffer;",
815 " Gtk.TextIter start;",
816 " Gtk.TextIter end; ",
818 " sbuf.get_bounds (out start, out end);",
819 " sbuf.remove_source_marks (start, end, \"grey\");",
825 "| void highlightErrorsJson" : [
826 " (string type, Json.Object obj) {",
827 " // this is a hook for the vala code - it has no value in javascript ",
828 " // as we only have one error ususally....",
836 "| void loadFile" : [
838 " this.loading = true;",
841 " // get the cursor and scroll position....",
842 " var buf = this.el.get_buffer();",
843 "\tvar cpos = buf.cursor_position;",
845 " print(\"BEFORE LOAD cursor = %d\\n\", cpos);",
847 " var vadj_pos = this.el.get_vadjustment().get_value();",
851 " buf.set_text(\"\",0);",
852 " var sbuf = (GtkSource.Buffer) buf;",
856 " if (_this.file == null || _this.file.xtype != \"Roo\") {",
857 " print(\"xtype != Roo\");",
858 " this.loading = false;",
862 " // get the string from the rendered tree...",
864 " var str = _this.file.toSource();",
866 "// print(\"setting str %d\\n\", str.length);",
867 " buf.set_text(str, str.length);",
868 " var lm = GtkSource.LanguageManager.get_default();",
870 " //?? is javascript going to work as js?",
872 " ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language));",
875 " _this.main_window.windowstate.updateErrorMarksAll();",
877 " // what does this do?",
878 " GLib.Timeout.add(500, () => {",
880 " print(\"RESORTING cursor to = %d\\n\", cpos);",
881 "\t\tGtk.TextIter cpos_iter;",
882 "\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);",
883 "\t\tbuf.place_cursor(cpos_iter); ",
885 "\t\tthis.el.get_vadjustment().set_value(vadj_pos);;",
888 "\t\tthis.onCursorChanged();",
891 "\t\t//_this.buffer.checkSyntax();",
895 " this.loading = false; ",
896 " _this.buffer.dirty = false;",
900 "| void nodeSelected" : [
901 "(JsRender.Node? sel, bool scroll ) {",
905 " // this is connected in widnowstate",
908 "\t// not sure why.... ",
909 " // while(Gtk.events_pending()) {",
910 " // Gtk.main_iteration();",
913 " this.node_selected = sel;",
915 " // this.updateGreySelection(scroll);",
924 "| void onCursorChanged" : [
925 "(/*ParamSpec ps*/) {",
927 "\t\tif (!this.key_is_pressed && !this.button_is_pressed) {",
931 "\t if (this.loading) {",
934 " // if (ps.name != \"cursor-position\") {",
938 " var buf = this.el.get_buffer();",
939 " //print(\"cursor changed : %d\\n\", buf.cursor_position);",
940 " Gtk.TextIter cpos;",
941 " buf.get_iter_at_offset(out cpos, buf.cursor_position);",
943 " var ln = cpos.get_line();",
946 " // --- select node at line....",
948 " var node = _this.file.lineToNode(ln+1);",
950 " if (node == null) {",
951 " print(\"can not find node\\n\");",
954 " var prop = node.lineToProp(ln+1);",
955 " print(\"prop : %s\", prop == null ? \"???\" : prop.name);",
958 " // ---------- this selects the tree's node...",
960 " var ltree = _this.main_window.windowstate.left_tree;",
961 " ltree.model.selectNode(node);",
964 " //print(\"changing cursor on tree..\\n\");",
968 " // let's try allowing editing on the methods.",
969 " // a little klunky at present..",
970 " this.prop_selected = \"\";",
972 " if (prop != null) {",
973 " \t\t//see if we can find it..",
974 " \t\tvar kv = prop.split(\":\");",
975 " \t\tif (kv[0] == \"p\") {",
977 " \t\t//var k = prop.get_key(kv[1]);",
978 " \t\t// fixme -- need to determine if it's an editable property...",
979 " \t\tthis.prop_selected = prop;",
981 " \t\t} else if (kv[0] == \"l\") {",
982 " \t\t\t this.prop_selected = prop;",
987 " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
988 " //this.nodeSelected(node,false);",
990 " // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
993 " // highlight the node..",
997 "| void updateGreySelection" : [
999 "\tvar sel = this.node_selected;",
1000 "\tprint(\"node selected\\n\");",
1001 " var buf = this.el.get_buffer();",
1002 " var sbuf = (GtkSource.Buffer) buf;",
1005 " this.clearGreySelection();",
1009 " if (sel == null) {",
1010 "\t print(\"no selected node\\n\");",
1011 " // no highlighting..",
1015 " print(\"highlight region %d to %d\\n\", sel.line_start,sel.line_end);",
1016 " Gtk.TextIter iter; ",
1017 " sbuf.get_iter_at_line(out iter, sel.line_start);",
1020 " Gtk.TextIter cur_iter;",
1021 " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
1023 " var cursor_at_line = cur_iter.get_line();",
1026 " //var cur_line = cur_iter.get_line();",
1027 " //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
1031 "\t\tprint(\"scrolling to node -- should occur on node picking.\\n\");",
1032 " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
1035 " var start_line = sel.line_start;",
1036 " var end_line = sel.line_end;",
1039 " this.el.editable = false;",
1041 " //var colon_pos = 0;",
1043 " this.editable_start_pos = -1;",
1045 " // now if we have selected a property...",
1046 " if (this.prop_selected.length> 0 ) {",
1048 "\t\tint nstart, nend;",
1049 "\t\tif (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) {",
1050 "\t\t\tstart_line = nstart;",
1051 "\t\t\tend_line = nend;",
1052 "\t\t\t// this.el.editable = true; << cant do this!!?",
1053 "\t\t\tprint(\"start line = %d, end line = %d\\n\", start_line, end_line);",
1055 "\t\t\t\t// see if we are 'right of ':'",
1056 "\t\t\t\t// get an iter for the start of the line.",
1057 "\t\t\tGtk.TextIter start_first_line_iter,end_first_line_iter;",
1058 "\t\t\tthis.el.buffer.get_iter_at_line(out start_first_line_iter, start_line -1);",
1059 "\t\t\tthis.el.buffer.get_iter_at_line(out end_first_line_iter, start_line -1);",
1064 "\t\t\tif (end_first_line_iter.forward_to_line_end()) {",
1065 "\t\t\t\tvar first_line = this.el.buffer.get_text(start_first_line_iter, end_first_line_iter, false);",
1067 "\t\t\t\tprint(\"first line = %s\\n\", first_line);",
1068 "\t\t\t\tif (first_line.contains(\":\")) {",
1069 "\t\t\t\t\tthis.editable_start_pos = start_first_line_iter.get_offset() + first_line.index_of(\":\") + 1;",
1070 "\t\t\t\t\tprint(\"colon_pos = %d\\n\", this.editable_start_pos);",
1074 "\t\t\t\t//Gtk.TextIter colon_iter;",
1075 "\t\t\t\t//sbuf.get_iter_at_offset (out colon_iter, colon_pos);",
1076 "\t\t\t\t//sbuf.create_source_mark(null, \"active_text\", colon_iter);",
1081 "\t\t\t//print(\"is cursor at line? %d ?= %d\\n\", start_line -1 , cursor_at_line);",
1082 "\t\t\t//if (start_line - 1 == cursor_at_line) {",
1083 "\t\t\t// should be ok - current_posssion can not be less than '-1'...",
1084 "\t\t\tif (sbuf.cursor_position < this.editable_start_pos) {",
1086 "\t\t\t\tprint(\"cursor is before start pos.. - turn off editable...\\n\");",
1087 "\t\t\t\t//var before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false);",
1088 "\t\t\t\t//print(\"before cursor string = %s\\n\", before_cursor_string);",
1089 "\t\t\t\t//if (!before_cursor_string.contains(\":\")) {",
1090 "\t\t\t\t\tthis.el.editable = false;",
1099 "\t\tprint(\"propSelected = %s range %d -> %d\\n\", this.prop_selected, start_line, end_line);\t\t",
1104 "\tprint(\"checking selection\\n\");",
1107 " // check selection - if it's out of 'bounds'",
1108 " if (this.el.editable && sbuf.get_has_selection()) {",
1109 "\t\tGtk.TextIter sel_start_iter, sel_end_iter;",
1110 "\t\tsbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter);",
1112 "\t\tif (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line ||",
1113 "\t\t\tsel_start_iter.get_line() > end_line || sel_end_iter.get_line() < start_line\t\t\t) {",
1115 "\t\t\tthis.el.editable = false;",
1117 "\t\tif (this.editable_start_pos > 0 &&",
1118 "\t\t\t(sel_start_iter.get_offset() < this.editable_start_pos || sel_end_iter.get_offset() < this.editable_start_pos)",
1121 "\t\t\tthis.el.editable = false;",
1131 " for (var i = 0; i < buf.get_line_count();i++) {",
1132 " if (i < (start_line -1) || i > (end_line -1)) {",
1134 " sbuf.get_iter_at_line(out iter, i);",
1135 " sbuf.create_source_mark(null, \"grey\", iter);",
1140 " if (scroll && (cursor_at_line > end_line || cursor_at_line < start_line)) {",
1141 "\t Gtk.TextIter cpos_iter;",
1142 "\t\tbuf.get_iter_at_line(out cpos_iter, start_line);",
1144 "\t\tbuf.place_cursor(cpos_iter); ",
1152 "xtype" : "ScrolledWindow"
1156 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
1157 "bool homogeneous" : false,
1158 "bool vexpand" : false,
1164 "this.css = new Gtk.CssProvider();",
1166 "this.css.load_from_string(",
1167 "\t\"#roo-search-entry { background-color: #ccc; }\"",
1170 "Gtk.StyleContext.add_provider_for_display(",
1171 "\tthis.el.get_display(),",
1173 "\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
1180 "Gtk.CssProvider css" : "",
1181 "bool hexpand" : true,
1182 "id" : "search_entry",
1188 "(keyval, keycode, state) => {",
1190 "\tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
1191 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
1192 "\t\t_this.forwardSearch(true);",
1197 " \tif (keyval == Gdk.Key.Return) {",
1198 "\t\t_this.forwardSearch(true);",
1204 " // print(event.key.keyval)",
1211 "xtype" : "EventControllerKey"
1215 "search_changed" : [
1218 "_this.search(_this.search_entry.el.text);",
1219 "\t _this.search_results.updateResults();",
1221 "\tGLib.Timeout.add_seconds(1,() => {",
1222 "\t\t _this.search_results.updateResults();",
1223 "\t\t return false;",
1229 "string name" : "roo-search-entry",
1230 "string placeholder_text" : "Press enter to search",
1231 "xtype" : "SearchEntry",
1232 "| void forwardSearch" : [
1233 "(bool change_focus) {",
1236 "\t_this.forwardSearch(change_focus);",
1240 "\tswitch(_this.windowstate.state) {",
1241 "\t\tcase WindowState.State.CODEONLY:",
1242 "\t\t//case WindowState.State.CODE:",
1243 "\t\t\t// search the code being edited..",
1244 "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
1247 "\t\tcase WindowState.State.PREVIEW:",
1248 "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
1249 "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
1251 "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
1264 "id" : "search_results",
1265 "int margin_end" : 4,
1266 "int margin_start" : 4,
1267 "string label" : "No Results",
1269 "| void updateResults" : [
1271 "\tthis.el.visible = true;",
1273 "\tvar res = _this.searchcontext.get_occurrences_count();",
1275 "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
1279 "\t_this.nextBtn.el.sensitive = false;",
1280 "\t_this.backBtn.el.sensitive = false;\t",
1283 "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
1284 "\t\t_this.nextBtn.el.sensitive = true;",
1285 "\t\t_this.backBtn.el.sensitive = true;",
1288 "\t_this.search_results.el.label = \"No Matches\";",
1295 "bool always_show_image" : true,
1296 "bool sensitive" : false,
1302 "\t_this.forwardSearch(true);",
1308 "string icon_name" : "go-down",
1313 "bool always_show_image" : true,
1314 "bool sensitive" : false,
1320 "\t_this.backSearch(true);",
1327 "string icon_name" : "go-up",
1332 "bool always_show_image" : true,
1337 "* prop" : "popover",
1338 "id" : "search_settings",
1343 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1350 "\tthis.el.show();",
1354 "id" : "case_sensitive",
1355 "string label" : "Case Sensitive",
1356 "xtype" : "CheckButton"
1362 "\tthis.el.show();",
1367 "string label" : "Regex",
1368 "xtype" : "CheckButton"
1374 "\tthis.el.show();",
1379 "string label" : "Multi-line (add \\n)",
1380 "xtype" : "CheckButton"
1389 "string icon_name" : "emblem-system",
1390 "xtype" : "MenuButton"
1399 "xtype" : "Notebook"
1404 "(string in_txt) {",
1405 "\tthis.notebook.el.page = 1;",
1409 "\tvar s = new GtkSource.SearchSettings();",
1410 "\ts.case_sensitive = _this.case_sensitive.el.active;",
1411 "\ts.regex_enabled = _this.regex.el.active;\t",
1412 "\ts.wrap_around = false;",
1414 "\tthis.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);",
1415 "\tthis.searchcontext.set_highlight(true);",
1416 "\tvar txt = in_txt;",
1418 "\tif (_this.multiline.el.active) {",
1419 "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
1422 "\ts.set_search_text(txt);",
1423 "\tGtk.TextIter beg, st,en;",
1424 "\tbool has_wrapped_around;",
1425 "\tthis.buffer.el.get_start_iter(out beg);",
1426 "\tthis.searchcontext.forward(beg, out st, out en, out has_wrapped_around);",
1427 "\tthis.last_search_end = 0;",
1429 "\treturn this.searchcontext.get_occurrences_count();",
1437 "| void backSearch" : [
1438 "(bool change_focus) {",
1440 "\tif (this.searchcontext == null) {",
1444 "\tGtk.TextIter beg, st,en;",
1445 "\tbool has_wrapped_around;",
1446 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
1448 "\tif (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {",
1450 "\t\tthis.last_search_end = 0;",
1453 "\tthis.last_search_end = en.get_offset();",
1454 "\tif (change_focus) {",
1455 "\t\tthis.sourceview.el.grab_focus();",
1457 "\tthis.buffer.el.place_cursor(st);",
1458 "\tthis.sourceview.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
1459 "\tvar ln = st.get_line();",
1460 "\tthis.highlightNodeAtLine(ln);",
1466 "| void createThumb" : [
1470 " if (this.file == null) {",
1474 "\tif (this.notebook.el.page > 0 ) {",
1478 " \tthis.file.widgetToIcon(this.view.el); ",
1487 "| void forwardSearch" : [
1488 "(bool change_focus) {",
1490 "\tif (this.searchcontext == null) {",
1493 "\tthis.notebook.el.page = 1;",
1494 "\tGtk.TextIter beg, st,en;",
1495 "\tbool has_wrapped_around;",
1496 "\tvar buf = this.sourceview.el.get_buffer();",
1497 "\tbuf.get_iter_at_offset(out beg, this.last_search_end);",
1498 "\tif (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {",
1499 "\t\tthis.last_search_end = 0;",
1502 "\tthis.last_search_end = en.get_offset();",
1503 "\tif (change_focus) {",
1504 "\t\tthis.sourceview.el.grab_focus();",
1506 "\tbuf.place_cursor(st);",
1510 "\tthis.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f);",
1513 "\tvar ln = st.get_line();",
1515 "\tthis.highlightNodeAtLine(ln);",
1519 "| void highlightNodeAtLine" : [
1524 "\t// highlight node...",
1527 " var node = _this.file.lineToNode(ln+1);",
1529 " if (node == null) {",
1530 " //print(\"can not find node\\n\");",
1533 " var prop = node.lineToProp(ln+1);",
1534 " print(\"prop : %s\", prop == null ? \"???\" : prop.name);",
1537 " // ---------- this selects the tree's node...",
1539 " var ltree = _this.main_window.windowstate.left_tree;",
1540 " ltree.model.selectNode(node);",
1542 " //_this.sourceview.allow_node_scroll = false; /// block node scrolling..",
1545 " //print(\"changing cursor on tree..\\n\");",
1549 " // let's try allowing editing on the methods.",
1550 " // a little klunky at present..",
1551 "\t_this.sourceview.prop_selected = \"\";",
1553 " if (prop != null) {",
1554 "\t\t//see if we can find it..",
1555 "\t\tvar kv = prop.split(\":\");",
1556 "\t\tif (kv[0] == \"p\") {",
1558 " \t\t//var k = prop.get_key(kv[1]);",
1559 " \t\t// fixme -- need to determine if it's an editable property...",
1560 " \t\t_this.sourceview.prop_selected = prop;",
1562 "\t\t} else if (kv[0] == \"l\") {",
1563 "\t\t\t _this.sourceview.prop_selected = prop;",
1568 " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
1569 " _this.sourceview.nodeSelected(node,false);",
1571 " // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
1572 " // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
1573 "\t // this.allow_node_scroll = true;",
1574 "\t // return false;",
1591 "| void loadFile" : [
1593 "(JsRender.JsRender file)",
1595 " this.file = file;",
1596 " this.view.renderJS(true);",
1597 " this.notebook.el.page = 0;// gtk preview ",
1598 " this.sourceview.loadFile(); ",
1603 "| void requestRedraw" : [
1605 " this.view.renderJS(false);",
1606 " this.sourceview.loadFile(); ",
1609 "| void scroll_to_line" : [
1611 " // code preview...",
1613 " GLib.Timeout.add(100, () => {",
1615 "\t\tthis.notebook.el.set_current_page( 1 );",
1618 "\t\t var buf = this.sourceview.el.get_buffer();",
1620 "\t\tvar sbuf = (GtkSource.Buffer) buf;",
1623 "\t\tGtk.TextIter iter; ",
1624 "\t\tsbuf.get_iter_at_line(out iter, line);",
1625 "\t\tthis.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
1626 "\t\treturn false;",
1633 "| void updateErrorMarks" : [
1634 "(string category) {",
1638 "\tvar buf = _this.buffer.el;",
1639 "\tGtk.TextIter start;",
1640 "\tGtk.TextIter end; ",
1641 "\tbuf.get_bounds (out start, out end);",
1643 "\tbuf.remove_source_marks (start, end, category);",
1645 "\tGLib.debug(\"highlight errors\");\t\t ",
1647 "\t // we should highlight other types of errors..",
1652 "\tif (_this.file == null) {",
1653 "\t\tGLib.debug(\"file is null?\");",
1657 "\tvar ar = this.file.getErrors(category);",
1658 "\tif (ar == null || ar.get_n_items() < 1) {",
1659 "\t\tGLib.debug(\"higjlight %s has no errors\", category);",
1666 "\tvar offset = 0;",
1669 "\tvar tlines = buf.get_line_count () +1;",
1673 "\tfor (var i = 0; i < ar.get_n_items();i++) {",
1674 "\t\tvar err = (Palete.CompileError) ar.get_item(i);",
1676 "\t Gtk.TextIter iter;",
1677 "// print(\"get inter\\n\");",
1678 "\t var eline = err.line - offset;",
1679 "\t GLib.debug(\"GOT ERROR on line %d -- converted to %d (offset = %d)\",",
1680 "\t \terr.line ,eline, offset);",
1683 "\t if (eline > tlines || eline < 0) {",
1688 "\t buf.get_iter_at_line( out iter, eline);",
1691 "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, err.category, err.msg);",
1692 "\t buf.create_source_mark( msg, err.category, iter);",
1693 "\t GLib.debug(\"set line %d to %s\", eline, msg);",
1694 "\t //this.marks.set(eline, msg);",
1706 "name" : "WindowRooView"