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,
595 "bool in_cursor_change" : false,
597 "int error_line" : "-1",
598 "int last_line" : "-1",
603 " // check syntax??",
605 " // _this.save_button.el.sensitive = true;",
606 " ///?? has changed occured during loading?",
608 " // only trigger this if ",
613 " if (_this.sourceview.loading) {",
619 " print(\"- PREVIEW EDITOR CHANGED--\");",
621 " this.dirty = true; ",
622 " // this.checkSyntax(); // this calls backs and highlights errors.. in theory... ",
626 "\tif (!_this.sourceview.button_is_pressed && !_this.sourceview.key_is_pressed) {",
627 "\t\tprint(\"button or key not pressed to generate change?!\\n\");",
632 "\t// what are we editing??",
633 "\tif (null == _this.sourceview.node_selected || _this.sourceview.prop_selected.length < 1) {",
637 "\t// find the colon on the first line...",
639 "\tif (_this.sourceview.editable_start_pos > -1) {",
641 "\t\tvar buf = (GtkSource.Buffer)_this.sourceview.el.get_buffer();",
643 " //print(\"cursor changed : %d\\n\", buf.cursor_position);",
644 " Gtk.TextIter spos,epos;",
645 " buf.get_iter_at_offset(out spos, _this.sourceview.editable_start_pos);",
646 " buf.get_iter_at_offset(out epos, _this.sourceview.editable_start_pos); // initialize epos..",
648 " var gotit= false;",
649 " var line = spos.get_line();",
650 " var endline = buf.get_line_count();",
651 " while (line < endline) {",
653 "\t buf.get_iter_at_line(out epos, line);",
654 "\t if (buf.get_source_marks_at_line(line, \"grey\").length() > 0) {",
655 "\t\t buf.get_iter_at_line(out epos, line);\t \t\t",
656 "\t \t\tgotit=true;",
662 "\t \t\tprint(\"End Offset = %d/%d\\n\", epos.get_line(), epos.get_offset());",
663 "\t\t\t// get the pos...",
664 "\t\t\t// in theory the last char will be '}' or '},' .. or ','",
665 "\t\t\t// we should chop the ',' of the end...",
666 "\t\t\tvar str = buf.get_text(spos, epos, false);",
667 "\t\t\tprint(\"got string\\n%s\\n\", str);",
679 "GLib.debug(\"cursor moved called\");",
682 " \tif (this.in_cursor_change ) {",
683 " GLib.debug(\"cursor changed : %d [ignoring nested call)\", this.el.cursor_position);",
687 " GLib.debug(\"cursor changed : %d\", this.el.cursor_position);",
688 " Gtk.TextIter cpos;",
689 " this.el.get_iter_at_offset(out cpos, this.el.cursor_position);",
691 " var ln = cpos.get_line();",
692 " if (this.last_line == ln ){",
695 "\tthis.last_line = ln;",
696 " var node = _this.file.lineToNode(ln);",
698 " if (node == null) {",
699 " print(\"can not find node\\n\");",
702 " this.in_cursor_change = true;",
703 " var ltree = _this.main_window.windowstate.left_tree;",
704 " ltree.model.selectNode(node);",
705 " this.in_cursor_change = false;",
711 "| bool highlightErrors" : [
712 "( Gee.HashMap<int,string> validate_res) {",
714 " this.error_line = validate_res.size;",
716 " if (this.error_line < 1) {",
719 " var tlines = this.el.get_line_count ();",
720 " Gtk.TextIter iter;",
721 " var valiter = validate_res.map_iterator();",
722 " while (valiter.next()) {",
724 "// print(\"get inter\\n\");",
725 " var eline = valiter.get_key();",
726 " if (eline > tlines) {",
729 " this.el.get_iter_at_line( out iter, eline);",
730 " //print(\"mark line\\n\");",
731 " this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
736 "| string toString" : [
741 " this.el.get_start_iter(out s);",
742 " this.el.get_end_iter(out e);",
743 " var ret = this.el.get_text(s,e,true);",
744 " //print(\"TO STRING? \" + ret);",
752 "* pack" : "add_controller",
755 "(keyval, keycode, state) => {",
759 " \tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
760 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
761 "\t\t_this.forwardSearch(true);",
764 "\tif (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
765 "\t GLib.debug(\"SAVE: ctrl-f pressed\");",
766 "\t\t_this.search_entry.el.grab_focus();",
770 "\t//this.button_is_pressed = true;",
772 " // print(event.key.keyval)",
781 "xtype" : "EventControllerKey"
786 "(x, y, keyboard_tooltip, tooltip) => {",
788 "\t//GLib.debug(\"query tooltip\");",
789 "\tGtk.TextIter iter;",
792 "\tvar yoff = (int) _this.sourceviewscroll.el.vadjustment.value;",
794 "\tthis.el.get_iter_at_position (out iter, out trailing, x, y + yoff);",
796 "\tvar l = iter.get_line();",
797 "\t//GLib.debug(\"query tooltip line %d\", (int) l);",
798 "\tvar marks = _this.buffer.el.get_source_marks_at_line(l, null);",
799 "\t//GLib.debug(\"query tooltip line marks %d\", (int) marks.length());",
801 "\tmarks.@foreach((m) => { ",
802 "\t\t//GLib.debug(\"got mark %s\", m.name);",
803 "\t\tstr += (str.length > 0 ? \"\\n\" : \"\") + m.name;",
805 "\t// true if there is a mark..",
806 "\tif (str.length > 0 ) {",
807 "\t\t\ttooltip.set_text( str);",
809 "\treturn str.length > 0 ? true : false;",
814 "string name" : "roo-view",
816 "| string toString" : [
820 " this.el.get_buffer().get_start_iter(out s);",
821 " this.el.get_buffer().get_end_iter(out e);",
822 " var ret = this.el.get_buffer().get_text(s,e,true);",
823 " //print(\"TO STRING? \" + ret);",
828 "| void clearGreySelection" : [
830 " // clear all the marks..",
831 " var sbuf = (GtkSource.Buffer)this.el.buffer;",
833 " Gtk.TextIter start;",
834 " Gtk.TextIter end; ",
836 " sbuf.get_bounds (out start, out end);",
837 " sbuf.remove_source_marks (start, end, \"grey\");",
843 "| void highlightErrorsJson" : [
844 " (string type, Json.Object obj) {",
845 " // this is a hook for the vala code - it has no value in javascript ",
846 " // as we only have one error ususally....",
854 "| void loadFile" : [
856 " this.loading = true;",
859 " // get the cursor and scroll position....",
860 " var buf = this.el.get_buffer();",
861 "\tvar cpos = buf.cursor_position;",
863 " print(\"BEFORE LOAD cursor = %d\\n\", cpos);",
865 " var vadj_pos = this.el.get_vadjustment().get_value();",
869 " buf.set_text(\"\",0);",
870 " var sbuf = (GtkSource.Buffer) buf;",
874 " if (_this.file == null || _this.file.xtype != \"Roo\") {",
875 " print(\"xtype != Roo\");",
876 " this.loading = false;",
880 " // get the string from the rendered tree...",
882 " var str = _this.file.toSource();",
884 "// print(\"setting str %d\\n\", str.length);",
885 " buf.set_text(str, str.length);",
886 " var lm = GtkSource.LanguageManager.get_default();",
888 " //?? is javascript going to work as js?",
890 " ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language));",
893 " _this.main_window.windowstate.updateErrorMarksAll();",
895 " // restore the cursor position?",
896 " // after reloading the contents.",
897 " GLib.Timeout.add(500, () => {",
898 "\t\t_this.buffer.in_cursor_change = true;",
899 " print(\"RESORTING cursor to = %d\\n\", cpos);",
900 "\t\tGtk.TextIter cpos_iter;",
901 "\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);",
902 "\t\tbuf.place_cursor(cpos_iter); ",
904 "\t\tthis.el.get_vadjustment().set_value(vadj_pos);;",
905 "\t\t_this.buffer.in_cursor_change = false;",
909 "\t\t//_this.buffer.checkSyntax();",
913 " this.loading = false; ",
914 " _this.buffer.dirty = false;",
918 "| void nodeSelected" : [
919 "(JsRender.Node? sel, bool scroll) {",
922 " if (this.loading) {",
925 " // this is connected in widnowstate",
926 " print(\"Roo-view - node selected\\n\");",
927 " var buf = this.el.get_buffer();",
929 " var sbuf = (GtkSource.Buffer) buf;",
934 " // clear all the marks..",
935 " Gtk.TextIter start;",
936 " Gtk.TextIter end; ",
938 " sbuf.get_bounds (out start, out end);",
939 " sbuf.remove_source_marks (start, end, \"grey\");",
941 " this.node_selected = sel;",
942 " if (sel == null) {",
943 " // no highlighting..",
946 " Gtk.TextIter iter; ",
947 " sbuf.get_iter_at_line(out iter, sel.line_start);",
950 " Gtk.TextIter cur_iter;",
951 " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
953 " //var cur_line = cur_iter.get_line();",
954 " //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
957 " if (! _this.buffer.in_cursor_change) {",
958 " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
963 " for (var i = 0; i < buf.get_line_count();i++) {",
964 " if (i < sel.line_start || i > sel.line_end) {",
966 " sbuf.get_iter_at_line(out iter, i);",
967 " sbuf.create_source_mark(null, \"grey\", iter);",
977 "| void updateGreySelection" : [
979 "\tvar sel = this.node_selected;",
980 "\tprint(\"node selected\\n\");",
981 " var buf = this.el.get_buffer();",
982 " var sbuf = (GtkSource.Buffer) buf;",
985 " this.clearGreySelection();",
989 " if (sel == null) {",
990 "\t print(\"no selected node\\n\");",
991 " // no highlighting..",
995 " print(\"highlight region %d to %d\\n\", sel.line_start,sel.line_end);",
996 " Gtk.TextIter iter; ",
997 " sbuf.get_iter_at_line(out iter, sel.line_start);",
1000 " Gtk.TextIter cur_iter;",
1001 " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
1003 " var cursor_at_line = cur_iter.get_line();",
1006 " //var cur_line = cur_iter.get_line();",
1007 " //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
1011 "\t\tprint(\"scrolling to node -- should occur on node picking.\\n\");",
1012 " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
1015 " var start_line = sel.line_start;",
1016 " var end_line = sel.line_end;",
1019 " this.el.editable = false;",
1021 " //var colon_pos = 0;",
1023 " this.editable_start_pos = -1;",
1025 " // now if we have selected a property...",
1026 " if (this.prop_selected.length> 0 ) {",
1028 "\t\tint nstart, nend;",
1029 "\t\tif (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) {",
1030 "\t\t\tstart_line = nstart;",
1031 "\t\t\tend_line = nend;",
1032 "\t\t\t// this.el.editable = true; << cant do this!!?",
1033 "\t\t\tprint(\"start line = %d, end line = %d\\n\", start_line, end_line);",
1035 "\t\t\t\t// see if we are 'right of ':'",
1036 "\t\t\t\t// get an iter for the start of the line.",
1037 "\t\t\tGtk.TextIter start_first_line_iter,end_first_line_iter;",
1038 "\t\t\tthis.el.buffer.get_iter_at_line(out start_first_line_iter, start_line -1);",
1039 "\t\t\tthis.el.buffer.get_iter_at_line(out end_first_line_iter, start_line -1);",
1044 "\t\t\tif (end_first_line_iter.forward_to_line_end()) {",
1045 "\t\t\t\tvar first_line = this.el.buffer.get_text(start_first_line_iter, end_first_line_iter, false);",
1047 "\t\t\t\tprint(\"first line = %s\\n\", first_line);",
1048 "\t\t\t\tif (first_line.contains(\":\")) {",
1049 "\t\t\t\t\tthis.editable_start_pos = start_first_line_iter.get_offset() + first_line.index_of(\":\") + 1;",
1050 "\t\t\t\t\tprint(\"colon_pos = %d\\n\", this.editable_start_pos);",
1054 "\t\t\t\t//Gtk.TextIter colon_iter;",
1055 "\t\t\t\t//sbuf.get_iter_at_offset (out colon_iter, colon_pos);",
1056 "\t\t\t\t//sbuf.create_source_mark(null, \"active_text\", colon_iter);",
1061 "\t\t\t//print(\"is cursor at line? %d ?= %d\\n\", start_line -1 , cursor_at_line);",
1062 "\t\t\t//if (start_line - 1 == cursor_at_line) {",
1063 "\t\t\t// should be ok - current_posssion can not be less than '-1'...",
1064 "\t\t\tif (sbuf.cursor_position < this.editable_start_pos) {",
1066 "\t\t\t\tprint(\"cursor is before start pos.. - turn off editable...\\n\");",
1067 "\t\t\t\t//var before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false);",
1068 "\t\t\t\t//print(\"before cursor string = %s\\n\", before_cursor_string);",
1069 "\t\t\t\t//if (!before_cursor_string.contains(\":\")) {",
1070 "\t\t\t\t\tthis.el.editable = false;",
1079 "\t\tprint(\"propSelected = %s range %d -> %d\\n\", this.prop_selected, start_line, end_line);\t\t",
1084 "\tprint(\"checking selection\\n\");",
1087 " // check selection - if it's out of 'bounds'",
1088 " if (this.el.editable && sbuf.get_has_selection()) {",
1089 "\t\tGtk.TextIter sel_start_iter, sel_end_iter;",
1090 "\t\tsbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter);",
1092 "\t\tif (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line ||",
1093 "\t\t\tsel_start_iter.get_line() > end_line || sel_end_iter.get_line() < start_line\t\t\t) {",
1095 "\t\t\tthis.el.editable = false;",
1097 "\t\tif (this.editable_start_pos > 0 &&",
1098 "\t\t\t(sel_start_iter.get_offset() < this.editable_start_pos || sel_end_iter.get_offset() < this.editable_start_pos)",
1101 "\t\t\tthis.el.editable = false;",
1111 " for (var i = 0; i < buf.get_line_count();i++) {",
1112 " if (i < (start_line -1) || i > (end_line -1)) {",
1114 " sbuf.get_iter_at_line(out iter, i);",
1115 " sbuf.create_source_mark(null, \"grey\", iter);",
1120 " if (scroll && (cursor_at_line > end_line || cursor_at_line < start_line)) {",
1121 "\t Gtk.TextIter cpos_iter;",
1122 "\t\tbuf.get_iter_at_line(out cpos_iter, start_line);",
1124 "\t\tbuf.place_cursor(cpos_iter); ",
1132 "xtype" : "ScrolledWindow"
1136 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
1137 "bool homogeneous" : false,
1138 "bool vexpand" : false,
1144 "this.css = new Gtk.CssProvider();",
1146 "this.css.load_from_string(",
1147 "\t\"#roo-search-entry { background-color: #ccc; }\"",
1150 "Gtk.StyleContext.add_provider_for_display(",
1151 "\tthis.el.get_display(),",
1153 "\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
1160 "Gtk.CssProvider css" : "",
1161 "bool hexpand" : true,
1162 "id" : "search_entry",
1168 "(keyval, keycode, state) => {",
1170 "\tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
1171 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
1172 "\t\t_this.forwardSearch(true);",
1177 " \tif (keyval == Gdk.Key.Return) {",
1178 "\t\t_this.forwardSearch(true);",
1184 " // print(event.key.keyval)",
1191 "xtype" : "EventControllerKey"
1195 "search_changed" : [
1198 "_this.search(_this.search_entry.el.text);",
1199 "\t _this.search_results.updateResults();",
1201 "\tGLib.Timeout.add_seconds(1,() => {",
1202 "\t\t _this.search_results.updateResults();",
1203 "\t\t return false;",
1209 "string name" : "roo-search-entry",
1210 "string placeholder_text" : "Press enter to search",
1211 "xtype" : "SearchEntry",
1212 "| void forwardSearch" : [
1213 "(bool change_focus) {",
1216 "\t_this.forwardSearch(change_focus);",
1220 "\tswitch(_this.windowstate.state) {",
1221 "\t\tcase WindowState.State.CODEONLY:",
1222 "\t\t//case WindowState.State.CODE:",
1223 "\t\t\t// search the code being edited..",
1224 "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
1227 "\t\tcase WindowState.State.PREVIEW:",
1228 "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
1229 "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
1231 "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
1244 "id" : "search_results",
1245 "int margin_end" : 4,
1246 "int margin_start" : 4,
1247 "string label" : "No Results",
1249 "| void updateResults" : [
1251 "\tthis.el.visible = true;",
1253 "\tvar res = _this.searchcontext.get_occurrences_count();",
1255 "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
1259 "\t_this.nextBtn.el.sensitive = false;",
1260 "\t_this.backBtn.el.sensitive = false;\t",
1263 "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
1264 "\t\t_this.nextBtn.el.sensitive = true;",
1265 "\t\t_this.backBtn.el.sensitive = true;",
1268 "\t_this.search_results.el.label = \"No Matches\";",
1275 "bool always_show_image" : true,
1276 "bool sensitive" : false,
1282 "\t_this.forwardSearch(true);",
1288 "string icon_name" : "go-down",
1293 "bool always_show_image" : true,
1294 "bool sensitive" : false,
1300 "\t_this.backSearch(true);",
1307 "string icon_name" : "go-up",
1312 "bool always_show_image" : true,
1317 "* prop" : "popover",
1318 "id" : "search_settings",
1323 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1330 "\tthis.el.show();",
1334 "id" : "case_sensitive",
1335 "string label" : "Case Sensitive",
1336 "xtype" : "CheckButton"
1342 "\tthis.el.show();",
1347 "string label" : "Regex",
1348 "xtype" : "CheckButton"
1354 "\tthis.el.show();",
1359 "string label" : "Multi-line (add \\n)",
1360 "xtype" : "CheckButton"
1369 "string icon_name" : "emblem-system",
1370 "xtype" : "MenuButton"
1379 "xtype" : "Notebook"
1384 "(string in_txt) {",
1385 "\tthis.notebook.el.page = 1;",
1389 "\tvar s = new GtkSource.SearchSettings();",
1390 "\ts.case_sensitive = _this.case_sensitive.el.active;",
1391 "\ts.regex_enabled = _this.regex.el.active;\t",
1392 "\ts.wrap_around = false;",
1394 "\tthis.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);",
1395 "\tthis.searchcontext.set_highlight(true);",
1396 "\tvar txt = in_txt;",
1398 "\tif (_this.multiline.el.active) {",
1399 "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
1402 "\ts.set_search_text(txt);",
1403 "\tGtk.TextIter beg, st,en;",
1404 "\tbool has_wrapped_around;",
1405 "\tthis.buffer.el.get_start_iter(out beg);",
1406 "\tthis.searchcontext.forward(beg, out st, out en, out has_wrapped_around);",
1407 "\tthis.last_search_end = 0;",
1409 "\treturn this.searchcontext.get_occurrences_count();",
1417 "| void backSearch" : [
1418 "(bool change_focus) {",
1420 "\tif (this.searchcontext == null) {",
1424 "\tGtk.TextIter beg, st,en;",
1425 "\tbool has_wrapped_around;",
1426 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
1428 "\tif (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {",
1430 "\t\tthis.last_search_end = 0;",
1433 "\tthis.last_search_end = en.get_offset();",
1434 "\tif (change_focus) {",
1435 "\t\tthis.sourceview.el.grab_focus();",
1437 "\tthis.buffer.el.place_cursor(st);",
1438 "\tthis.sourceview.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
1439 "\tvar ln = st.get_line();",
1440 "\tthis.highlightNodeAtLine(ln);",
1446 "| void createThumb" : [
1450 " if (this.file == null) {",
1454 "\tif (this.notebook.el.page > 0 ) {",
1458 " \tthis.file.widgetToIcon(this.view.el); ",
1467 "| void forwardSearch" : [
1468 "(bool change_focus) {",
1470 "\tif (this.searchcontext == null) {",
1473 "\tthis.notebook.el.page = 1;",
1474 "\tGtk.TextIter beg, st,en;",
1475 "\tbool has_wrapped_around;",
1476 "\tvar buf = this.sourceview.el.get_buffer();",
1477 "\tbuf.get_iter_at_offset(out beg, this.last_search_end);",
1478 "\tif (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {",
1479 "\t\tthis.last_search_end = 0;",
1482 "\tthis.last_search_end = en.get_offset();",
1483 "\tif (change_focus) {",
1484 "\t\tthis.sourceview.el.grab_focus();",
1486 "\tbuf.place_cursor(st);",
1490 "\tthis.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f);",
1493 "\tvar ln = st.get_line();",
1495 "\tthis.highlightNodeAtLine(ln);",
1499 "| void highlightNodeAtLine" : [
1504 "\t// highlight node...",
1507 " var node = _this.file.lineToNode(ln+1);",
1509 " if (node == null) {",
1510 " //print(\"can not find node\\n\");",
1513 " var prop = node.lineToProp(ln+1);",
1514 " print(\"prop : %s\", prop == null ? \"???\" : prop.name);",
1517 " // ---------- this selects the tree's node...",
1519 " var ltree = _this.main_window.windowstate.left_tree;",
1520 " ltree.model.selectNode(node);",
1522 " //_this.sourceview.allow_node_scroll = false; /// block node scrolling..",
1525 " //print(\"changing cursor on tree..\\n\");",
1529 " // let's try allowing editing on the methods.",
1530 " // a little klunky at present..",
1531 "\t_this.sourceview.prop_selected = \"\";",
1533 " if (prop != null) {",
1534 "\t\t//see if we can find it..",
1535 "\t\tvar kv = prop.split(\":\");",
1536 "\t\tif (kv[0] == \"p\") {",
1538 " \t\t//var k = prop.get_key(kv[1]);",
1539 " \t\t// fixme -- need to determine if it's an editable property...",
1540 " \t\t_this.sourceview.prop_selected = prop;",
1542 "\t\t} else if (kv[0] == \"l\") {",
1543 "\t\t\t _this.sourceview.prop_selected = prop;",
1548 " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
1549 " _this.sourceview.nodeSelected(node,false);",
1551 " // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
1552 " // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
1553 "\t // this.allow_node_scroll = true;",
1554 "\t // return false;",
1571 "| void loadFile" : [
1573 "(JsRender.JsRender file)",
1575 " this.file = file;",
1576 " this.view.renderJS(true);",
1577 " this.notebook.el.page = 0;// gtk preview ",
1578 " this.sourceview.loadFile(); ",
1583 "| void requestRedraw" : [
1585 " this.view.renderJS(false);",
1586 " this.sourceview.loadFile(); ",
1589 "| void scroll_to_line" : [
1591 " // code preview...",
1593 " GLib.Timeout.add(100, () => {",
1595 "\t\tthis.notebook.el.set_current_page( 1 );",
1598 "\t\t var buf = this.sourceview.el.get_buffer();",
1600 "\t\tvar sbuf = (GtkSource.Buffer) buf;",
1603 "\t\tGtk.TextIter iter; ",
1604 "\t\tsbuf.get_iter_at_line(out iter, line);",
1605 "\t\tthis.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
1606 "\t\treturn false;",
1613 "| void updateErrorMarks" : [
1614 "(string category) {",
1618 "\tvar buf = _this.buffer.el;",
1619 "\tGtk.TextIter start;",
1620 "\tGtk.TextIter end; ",
1621 "\tbuf.get_bounds (out start, out end);",
1623 "\tbuf.remove_source_marks (start, end, category);",
1625 "\tGLib.debug(\"highlight errors\");\t\t ",
1627 "\t // we should highlight other types of errors..",
1632 "\tif (_this.file == null) {",
1633 "\t\tGLib.debug(\"file is null?\");",
1637 "\tvar ar = this.file.getErrors(category);",
1638 "\tif (ar == null || ar.get_n_items() < 1) {",
1639 "\t\tGLib.debug(\"higjlight %s has no errors\", category);",
1646 "\tvar offset = 0;",
1649 "\tvar tlines = buf.get_line_count () +1;",
1653 "\tfor (var i = 0; i < ar.get_n_items();i++) {",
1654 "\t\tvar err = (Palete.CompileError) ar.get_item(i);",
1656 "\t Gtk.TextIter iter;",
1657 "// print(\"get inter\\n\");",
1658 "\t var eline = err.line - offset;",
1659 "\t GLib.debug(\"GOT ERROR on line %d -- converted to %d (offset = %d)\",",
1660 "\t \terr.line ,eline, offset);",
1663 "\t if (eline > tlines || eline < 0) {",
1668 "\t buf.get_iter_at_line( out iter, eline);",
1671 "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, err.category, err.msg);",
1672 "\t buf.create_source_mark( msg, err.category, iter);",
1673 "\t GLib.debug(\"set line %d to %s\", eline, msg);",
1674 "\t //this.marks.set(eline, msg);",
1686 "name" : "WindowRooView"