2 "build_module" : "builder",
5 "# Gtk.Widget lastObj" : "null",
6 "# JsRender.JsRender file" : "null",
7 "# Xcls_MainWindow main_window" : "",
9 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
10 "Gtk.SourceSearchContext searchcontext" : "",
11 "bool hexpand" : true,
12 "bool vexpand" : true,
13 "id" : "WindowRooView",
14 "int last_search_end" : 0,
18 "* pack" : "pack_start,true,true,0",
24 "id" : "label_preview",
25 "utf8 label" : "Preview",
32 "utf8 label" : "Preview Generated Code",
37 "* pack" : "append_page,_this.label_preview.el",
38 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
42 "$ homogeneous" : false,
44 "* pack" : "pack1,true,true",
45 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
49 "$ height_request" : 20,
50 "$ homogeneous" : true,
53 "* pack" : "pack_start,false,true,0",
54 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
58 "* pack" : "pack_start,false,false,0",
63 " _this.view.renderJS( true);",
72 "* pack" : "pack_start,false,false,0",
74 "label" : "Auto Redraw On",
78 " this.el.set_label(this.el.active ? \"Auto Redraw On\" : \"Auto Redraw Off\");",
82 "xtype" : "CheckButton"
86 "* pack" : "pack_start,false,false,0",
87 "label" : "Full Redraw",
91 " _this.view.redraws = 99;",
92 " _this.view.el.web_context.clear_cache(); ",
93 " //_this.view.renderJS(true);",
94 " FakeServerCache.clear();",
95 " _this.view.reInit();",
106 "$ shadow_type" : "Gtk.ShadowType.IN",
109 " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
113 "* pack" : "pack_end,true,true,0",
114 "id" : "viewcontainer",
117 "# GLib.DateTime lastRedraw" : "null",
118 "# WebKit.WebInspector inspector" : "",
119 "# bool pendingRedraw" : false,
120 "# bool refreshRequired" : false,
122 "# string renderedData" : "\"\"",
123 "# string runhtml" : "\"\"",
124 "# string runjs" : "\"\"",
128 " // this may not work!?",
129 " var settings = this.el.get_settings();",
130 " settings.enable_developer_extras = true;",
133 " var fs= new FakeServer(this.el);",
135 " // this was an attempt to change the url perms.. did not work..",
136 " // settings.enable_file_access_from_file_uris = true;",
137 " // settings.enable_offline_web_application_cache - true;",
138 " // settings.enable_universal_access_from_file_uris = true;",
145 " // FIXME - base url of script..",
146 " // we need it so some of the database features work.",
147 " this.el.load_html( \"Render not ready\" , ",
148 " //fixme - should be a config option!",
149 " // or should we catch stuff and fix it up..",
150 " \"http://localhost/app.Builder/\"",
154 " //this.el.open('file:///' + __script_path__ + '/../builder.html');",
156 " Gtk.drag_dest_set",
159 " Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,",
160 " null, // list of targets",
161 " Gdk.DragAction.COPY // what to do with data after dropped ",
164 " // print(\"RB: TARGETS : \" + LeftTree.atoms[\"STRING\"]);",
165 " Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);",
167 " GLib.Timeout.add_seconds(1, () =>{",
168 " //print(\"run refresh?\");",
169 " if (this.el == null) {",
172 " this.runRefresh(); ",
184 " ( ctx, x, y,time, ud) => {",
187 "\tprint(\"TARGET: drag-drop\");",
188 " var is_valid_drop_site = true;",
191 " Gtk.drag_get_data",
193 " w, // will receive 'drag-data-received' signal ",
194 " ctx, /* represents the current state of the DnD ",
195 " this.get('/Window').atoms[\"STRING\"], /* the target type we want ",
196 " time /* time stamp ",
200 " /* No target offered by source => error ",
203 "\treturn is_valid_drop_site;",
209 " if (le != WebKit.LoadEvent.FINISHED) {",
212 " if (this.runjs.length < 1) {",
215 " // this.el.run_javascript(this.runjs, null);",
216 " FakeServerCache.remove( this.runjs);",
217 " this.runjs = \"\";",
224 " if (this.el == null) {",
228 " var msg = dialog.get_message();",
229 " if (msg.length < 4) {",
232 " if (msg.substring(0,4) != \"IPC:\") {",
235 " var ar = msg.split(\":\", 3);",
236 " if (ar.length < 3) {",
241 " case \"SAVEHTML\":",
242 "\t print(\"GOT saveHTML %d?\\n\", ar[2].length);",
243 " _this.file.saveHTML(ar[2]);",
253 " this.initInspector();;",
258 "| void initInspector" : [
261 " /* if (this.inspector == this.el.get_inspector()) {",
262 " this.inspector.show();",
263 " this.inspector.open_window(); ",
264 " print(\"init inspecter called, and inspector is the same as existing\\n\");",
267 " print(\"new inspector?\\n\");",
269 " this.inspector = this.el.get_inspector();",
270 " this.inspector.ref();",
272 " // got a new inspector...",
274 " this.inspector.open_window.connect(() => {",
275 " this.inspector = this.el.get_inspector();",
276 " print(\"inspector attach\\n\");",
277 " var wv = this.inspector.get_web_view();",
278 " if (wv != null) {",
279 " print(\"got inspector web view\\n\");",
281 " var cn = _this.inspectorcontainer.el.get_child();",
282 " if (cn != null) {",
283 " _this.inspectorcontainer.el.remove(cn);",
286 " _this.inspectorcontainer.el.add(wv);",
289 " //this.inspector.close();",
291 " //this.inspector = null;",
299 " this.inspector.closed.connect(() => {",
300 " print(\"inspector closed?!?\");",
301 " // if this happens destroy the webkit..",
303 " this.el.stop_loading();",
305 " if (_this.viewbox.el.get_parent() == null) {",
310 " _this.viewbox.el.remove(_this.viewcontainer.el);",
311 " _this.el.remove(_this.inspectorcontainer.el); ",
313 " // destory seems to cause problems.",
314 " //this.el.destroy();",
315 " //_this.viewcontainer.el.destroy();",
316 " //_this.inspectorcontainer.el.destroy();",
319 " var nv =new Xcls_viewcontainer(_this);",
321 " _this.viewbox.el.pack_end(nv.el,true,true,0);",
323 " var inv =new Xcls_inspectorcontainer(_this);",
325 " _this.el.pack2(inv.el,true,true);",
327 " inv.el.show_all();",
328 " nv.el.show_all();",
329 " //while(Gtk.events_pending ()) Gtk.main_iteration ();",
330 " //_this.view.renderJS(true); ",
331 " _this.view.refreshRequired = true;",
336 " this.inspector.show();",
342 " print(\"reInit?\");",
343 " // if this happens destroy the webkit..",
345 " this.el.stop_loading();",
347 " if (_this.viewbox.el.get_parent() == null) {",
352 " _this.viewbox.el.remove(_this.viewcontainer.el);",
353 " _this.paned.el.remove(_this.inspectorcontainer.el); ",
355 " // destory seems to cause problems.",
356 " //this.el.destroy();",
357 " //_this.viewcontainer.el.destroy();",
358 " //_this.inspectorcontainer.el.destroy();",
359 " var inv =new Xcls_inspectorcontainer(_this);",
361 " _this.paned.el.pack2(inv.el,true,true);",
365 " var nv =new Xcls_viewcontainer(_this);",
367 " _this.viewbox.el.pack_end(nv.el,true,true,0);",
370 " inv.el.show_all();",
371 " nv.el.show_all();",
372 " //while(Gtk.events_pending ()) Gtk.main_iteration ();",
373 " //_this.view.renderJS(true); ",
374 " _this.view.refreshRequired = true;",
378 "| void renderJS" : [
381 " // this is the public redraw call..",
382 " // we refresh in a loop privately..",
383 " var autodraw = _this.AutoRedraw.el.active;",
384 " if (!autodraw && !force) {",
385 " print(\"Skipping redraw - no force, and autodraw off\");",
389 " this.refreshRequired = true;",
393 "| void runRefresh" : [
396 " // this is run every 2 seconds from the init..",
400 " if (!this.refreshRequired) {",
401 " // print(\"no refresh required\");",
405 " if (this.lastRedraw != null) {",
406 " // do not redraw if last redraw was less that 5 seconds ago.",
407 " if ((int64)(new DateTime.now_local()).difference(this.lastRedraw) < 5000 ) {",
412 " if (_this.file == null) {",
417 " this.refreshRequired = false;",
418 " // print(\"HTML RENDERING\");",
421 " //this.get('/BottomPane').el.show();",
422 " //this.get('/BottomPane').el.set_current_page(2);// webkit inspector",
423 " _this.file.webkit_page_id = this.el.get_page_id();",
425 " var js = _this.file.toSourcePreview();",
427 " if (js.length < 1) {",
428 " print(\"no data\");",
431 "// var data = js[0];",
434 " var project = _this.file.project; ",
436 " //print (project.fn);",
437 " // set it to non-empty.",
439 "// runhtml = runhtml.length ? runhtml : '<script type=\"text/javascript\"></script>'; ",
442 "// this.runhtml = this.runhtml || '';",
445 " // then we need to reload the browser using",
446 " // load_html_string..",
448 " // then trigger a redraw once it's loaded..",
449 " this.pendingRedraw = true;",
451 " var runhtml = \"<script type=\\\"text/javascript\\\">\\n\" ;",
452 " string builderhtml;",
455 " GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + \"/resources/roo.builder.js\", out builderhtml);",
456 " } catch (Error e) {",
457 " builderhtml = \"\";",
460 " runhtml += builderhtml + \"\\n\";",
461 " runhtml += \"</script>\\n\" ;",
463 " // fix to make sure they are the same..",
464 " this.runhtml = project.runhtml;",
465 " // need to modify paths",
468 " var base_template = _this.file.project.base_template;",
470 " if (base_template.length > 0 && !FileUtils.test(",
471 " BuilderApplication.configDirectory() + \"/resources/\" + base_template, FileTest.EXISTS) ",
473 " print(\"invalid base_template name - using default: %s\\n\", base_template);",
474 " base_template = \"\";",
478 " GLib.FileUtils.get_contents(",
479 " BuilderApplication.configDirectory() + \"/resources/\" + ",
480 " (base_template.length > 0 ? base_template : \"roo.builder.html\")",
483 " } catch (Error e) {",
486 " this.renderedData = js;",
489 " string js_src = js + \"\\n\" +",
490 "\t\"Roo.onReady(function() {\\n\" +",
491 "\t\"if (\" + _this.file.name +\".show) \" + _this.file.name +\".show({});\\n\" +",
492 "\t\"Roo.XComponent.build();\\n\" +",
495 " // print(\"render js: \" + js);",
496 " //if (!this.ready) {",
497 " // console.log('not loaded yet');",
499 " this.lastRedraw = new DateTime.now_local();",
502 " //this.runjs = js_src;",
503 " var fc = FakeServerCache.factory_with_data(js_src);",
504 " this.runjs = fc.fname;",
506 " var html = inhtml.replace(\"</head>\", runhtml + this.runhtml + ",
507 " \"<script type=\\\"text/javascript\\\" src=\\\"xhttp://localhost\" + fc.fname + \"\\\"></script>\" + ",
508 " // \"<script type=\\\"text/javascript\\\">\\n\" +",
509 " // js_src + \"\\n\" + ",
510 " // \"</script>\" + ",
513 " //print(\"LOAD HTML \" + html);",
515 " var rootURL = _this.file.project.rootURL;",
519 " this.el.load_html( html , ",
520 " //fixme - should be a config option!",
521 " (rootURL.length > 0 ? rootURL : \"xhttp://localhost/roobuilder/\")",
524 " // force the inspector... ",
525 " // this.initInspector();",
527 " // - no need for this, the builder javascript will call it when build is complete",
528 " //GLib.Timeout.add_seconds(1, () => {",
529 " // this.el.run_javascript(\"Builder.saveHTML()\",null);",
532 "// print( \"before render\" + this.lastRedraw);",
533 "// print( \"after render\" + (new Date()));",
540 "xtype" : "ScrolledWindow"
546 "$ shadow_type" : "Gtk.ShadowType.IN",
549 " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
553 "* pack" : "pack2,true,true",
554 "id" : "inspectorcontainer",
555 "xtype" : "ScrolledWindow"
562 "* pack" : "append_page,_this.label_code.el",
563 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
568 "bool vexpand" : true,
571 "# JsRender.Node? node_selected" : "null",
572 "# bool button_is_pressed" : false,
573 "# bool key_is_pressed" : false,
574 "# bool loading" : true,
575 "# int editable_start_pos" : "-1",
576 "# string prop_selected" : "\"\"",
582 " var description = Pango.FontDescription.from_string(\"monospace\");",
583 " description.set_size(8000);",
584 " this.el.override_font(description);",
586 " this.loading = true;",
587 " //var buf = this.el.get_buffer();",
588 " //buf.notify.connect(this.onCursorChanged);",
591 " var attrs = new Gtk.SourceMarkAttributes();",
592 " var pink = Gdk.RGBA();",
593 " pink.parse ( \"pink\");",
594 " attrs.set_background ( pink);",
595 " attrs.set_icon_name ( \"process-stop\"); ",
596 " attrs.query_tooltip_text.connect(( mark) => {",
597 " //print(\"tooltip query? %s\\n\", mark.name);",
598 " return mark.name;",
601 " this.el.set_mark_attributes (\"ERR\", attrs, 1);",
603 " var wattrs = new Gtk.SourceMarkAttributes();",
604 " var blue = Gdk.RGBA();",
605 " blue.parse ( \"#ABF4EB\");",
606 " wattrs.set_background ( blue);",
607 " wattrs.set_icon_name ( \"process-stop\"); ",
608 " wattrs.query_tooltip_text.connect(( mark) => {",
609 " //print(\"tooltip query? %s\\n\", mark.name);",
610 " return mark.name;",
613 " this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
617 " var dattrs = new Gtk.SourceMarkAttributes();",
618 " var purple = Gdk.RGBA();",
619 " purple.parse ( \"#EEA9FF\");",
620 " dattrs.set_background ( purple);",
621 " dattrs.set_icon_name ( \"process-stop\"); ",
622 " dattrs.query_tooltip_text.connect(( mark) => {",
623 " //print(\"tooltip query? %s\\n\", mark.name);",
624 " return mark.name;",
627 " this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
630 " var gattrs = new Gtk.SourceMarkAttributes();",
631 " var grey = Gdk.RGBA();",
632 " grey.parse ( \"#ccc\");",
633 " gattrs.set_background ( grey);",
636 " this.el.set_mark_attributes (\"grey\", gattrs, 1);",
647 "gboolean editable" : false,
648 "gboolean show_line_marks" : true,
649 "gboolean show_line_numbers" : true,
654 "* pack" : "set_buffer",
655 "bool dirty" : false,
657 "int error_line" : "-1",
663 " // check syntax??",
665 " // _this.save_button.el.sensitive = true;",
666 " ///?? has changed occured during loading?",
668 " // only trigger this if ",
673 " if (_this.sourceview.loading) {",
679 " print(\"- PREVIEW EDITOR CHANGED--\");",
681 " this.dirty = true; ",
682 " this.checkSyntax(); // this calls backs and highlights errors.. in theory... ",
686 "\tif (!_this.sourceview.button_is_pressed && !_this.sourceview.key_is_pressed) {",
687 "\t\tprint(\"button or key not pressed to generate change?!\\n\");",
692 "\t// what are we editing??",
693 "\tif (null == _this.sourceview.node_selected || _this.sourceview.prop_selected.length < 1) {",
697 "\t// find the colon on the first line...",
699 "\tif (_this.sourceview.editable_start_pos > -1) {",
701 "\t\tvar buf = (Gtk.SourceBuffer)_this.sourceview.el.get_buffer();",
703 " //print(\"cursor changed : %d\\n\", buf.cursor_position);",
704 " Gtk.TextIter spos,epos;",
705 " buf.get_iter_at_offset(out spos, _this.sourceview.editable_start_pos);",
706 " buf.get_iter_at_offset(out epos, _this.sourceview.editable_start_pos); // initialize epos..",
708 " var gotit= false;",
709 " var line = spos.get_line();",
710 " var endline = buf.get_line_count();",
711 " while (line < endline) {",
713 "\t buf.get_iter_at_line(out epos, line);",
714 "\t if (buf.get_source_marks_at_line(line, \"grey\").length() > 0) {",
715 "\t\t buf.get_iter_at_line(out epos, line);\t \t\t",
716 "\t \t\tgotit=true;",
722 "\t \t\tprint(\"End Offset = %d/%d\\n\", epos.get_line(), epos.get_offset());",
723 "\t\t\t// get the pos...",
724 "\t\t\t// in theory the last char will be '}' or '},' .. or ','",
725 "\t\t\t// we should chop the ',' of the end...",
726 "\t\t\tvar str = buf.get_text(spos, epos, false);",
727 "\t\t\tprint(\"got string\\n%s\\n\", str);",
738 "xtype" : "SourceBuffer",
739 "| bool checkSyntax" : [
743 " var str = this.toString();",
746 " if (this.error_line > 0) {",
747 " Gtk.TextIter start;",
748 " Gtk.TextIter end; ",
749 " this.el.get_bounds (out start, out end);",
751 " this.el.remove_source_marks (start, end, \"WARN\");",
752 " this.el.remove_source_marks (start, end, \"ERR\"); ",
756 " if (str.length < 1) {",
757 " print(\"checkSyntax - empty string?\\n\");",
761 " if (_this.file == null) {",
764 " var p = _this.file.project.palete;",
767 " if (_this.file.language != \"js\") {",
768 "\t\treturn false; // fake syntax error.",
771 " //Gee.HashMap<int,string> ret_x;",
773 "\treturn p.javascriptHasErrors(",
774 "\t\t_this.main_window.windowstate,",
776 " null, // prop - not relivant.",
784 "| bool highlightErrors" : [
785 "( Gee.HashMap<int,string> validate_res) {",
787 " this.error_line = validate_res.size;",
789 " if (this.error_line < 1) {",
792 " var tlines = this.el.get_line_count ();",
793 " Gtk.TextIter iter;",
794 " var valiter = validate_res.map_iterator();",
795 " while (valiter.next()) {",
797 "// print(\"get inter\\n\");",
798 " var eline = valiter.get_key();",
799 " if (eline > tlines) {",
802 " this.el.get_iter_at_line( out iter, eline);",
803 " //print(\"mark line\\n\");",
804 " this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
809 "| string toString" : [
814 " this.el.get_start_iter(out s);",
815 " this.el.get_end_iter(out e);",
816 " var ret = this.el.get_text(s,e,true);",
817 " //print(\"TO STRING? \" + ret);",
825 "button_press_event" : [
828 "\tthis.button_is_pressed = true;",
833 "button_release_event" : [
836 "\tprint(\"BUTTON RELEASE EVENT\\n\");",
837 "\tthis.onCursorChanged();",
838 "\tthis.button_is_pressed = false;",
842 "key_press_event" : [
845 "\tif (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
846 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
847 "\t\t_this.forwardSearch(true);",
850 "\tif (event.keyval == Gdk.Key.f && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
851 "\t GLib.debug(\"SAVE: ctrl-f pressed\");",
852 "\t\t_this.search_entry.el.grab_focus();",
856 "\tthis.button_is_pressed = true;",
861 "key_release_event" : [
863 "\tthis.key_is_pressed = false;",
869 "xtype" : "SourceView",
870 "| string toString" : [
874 " this.el.get_buffer().get_start_iter(out s);",
875 " this.el.get_buffer().get_end_iter(out e);",
876 " var ret = this.el.get_buffer().get_text(s,e,true);",
877 " //print(\"TO STRING? \" + ret);",
882 "| void clearGreySelection" : [
884 " // clear all the marks..",
885 " var sbuf = (Gtk.SourceBuffer)this.el.buffer;",
887 " Gtk.TextIter start;",
888 " Gtk.TextIter end; ",
890 " sbuf.get_bounds (out start, out end);",
891 " sbuf.remove_source_marks (start, end, \"grey\");",
897 "| void highlightErrorsJson" : [
898 " (string type, Json.Object obj) {",
899 " // this is a hook for the vala code - it has no value in javascript ",
900 " // as we only have one error ususally....",
908 "| void loadFile" : [
910 " this.loading = true;",
913 " // get the cursor and scroll position....",
914 " var buf = this.el.get_buffer();",
915 "\tvar cpos = buf.cursor_position;",
917 " print(\"BEFORE LOAD cursor = %d\\n\", cpos);",
919 " var vadj_pos = this.el.get_vadjustment().get_value();",
923 " buf.set_text(\"\",0);",
924 " var sbuf = (Gtk.SourceBuffer) buf;",
928 " if (_this.file == null || _this.file.xtype != \"Roo\") {",
929 " print(\"xtype != Roo\");",
930 " this.loading = false;",
934 " // get the string from the rendered tree...",
936 " var str = _this.file.toSource();",
938 "// print(\"setting str %d\\n\", str.length);",
939 " buf.set_text(str, str.length);",
940 " var lm = Gtk.SourceLanguageManager.get_default();",
942 " //?? is javascript going to work as js?",
944 " ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));",
947 " Gtk.TextIter start;",
948 " Gtk.TextIter end; ",
950 " sbuf.get_bounds (out start, out end);",
951 " sbuf.remove_source_marks (start, end, null); // remove all marks..",
953 " GLib.Timeout.add(500, () => {",
955 " print(\"RESORTING cursor to = %d\\n\", cpos);",
956 "\t\tGtk.TextIter cpos_iter;",
957 "\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);",
958 "\t\tbuf.place_cursor(cpos_iter); ",
960 "\t\tthis.el.get_vadjustment().set_value(vadj_pos);;",
963 "\t\tthis.onCursorChanged();",
966 "\t\t_this.buffer.checkSyntax();",
970 " this.loading = false; ",
971 " _this.buffer.dirty = false;",
975 "| void nodeSelected" : [
976 "(JsRender.Node? sel, bool scroll ) {",
980 " // this is connected in widnowstate",
983 "\t// not sure why.... ",
984 " while(Gtk.events_pending()) {",
985 " Gtk.main_iteration();",
988 " this.node_selected = sel;",
990 " this.updateGreySelection(scroll);",
999 "| void onCursorChanged" : [
1000 "(/*ParamSpec ps*/) {",
1002 "\t\tif (!this.key_is_pressed && !this.button_is_pressed) {",
1006 "\t if (this.loading) {",
1009 " // if (ps.name != \"cursor-position\") {",
1013 " var buf = this.el.get_buffer();",
1014 " //print(\"cursor changed : %d\\n\", buf.cursor_position);",
1015 " Gtk.TextIter cpos;",
1016 " buf.get_iter_at_offset(out cpos, buf.cursor_position);",
1018 " var ln = cpos.get_line();",
1021 " // --- select node at line....",
1023 " var node = _this.file.lineToNode(ln+1);",
1025 " if (node == null) {",
1026 " print(\"can not find node\\n\");",
1029 " var prop = node.lineToProp(ln+1);",
1030 " print(\"prop : %s\", prop == null ? \"???\" : prop);",
1033 " // ---------- this selects the tree's node...",
1035 " var ltree = _this.main_window.windowstate.left_tree;",
1036 " var tp = ltree.model.treePathFromNode(node);",
1037 " print(\"got tree path %s\\n\", tp);",
1038 " if (tp != \"\") {",
1041 "\t //print(\"changing cursor on tree..\\n\");",
1045 " // let's try allowing editing on the methods.",
1046 " // a little klunky at present..",
1047 " this.prop_selected = \"\";",
1048 " if (prop != null) {",
1049 " \t\t//see if we can find it..",
1050 " \t\tvar kv = prop.split(\":\");",
1051 " \t\tif (kv[0] == \"p\") {",
1053 "\t \t\t//var k = prop.get_key(kv[1]);",
1054 "\t \t\t// fixme -- need to determine if it's an editable property...",
1055 "\t \t\tthis.prop_selected = prop;",
1057 " \t\t} else if (kv[0] == \"l\") {",
1058 " \t\t\t this.prop_selected = prop;",
1062 " ltree.view.setCursor(tp, \"editor\");",
1063 " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
1064 " this.nodeSelected(node,false);",
1066 " // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
1070 " // highlight the node..",
1074 "| void updateGreySelection" : [
1076 "\tvar sel = this.node_selected;",
1077 "\tprint(\"node selected\\n\");",
1078 " var buf = this.el.get_buffer();",
1079 " var sbuf = (Gtk.SourceBuffer) buf;",
1082 " this.clearGreySelection();",
1086 " if (sel == null) {",
1087 "\t print(\"no selected node\\n\");",
1088 " // no highlighting..",
1092 " print(\"highlight region %d to %d\\n\", sel.line_start,sel.line_end);",
1093 " Gtk.TextIter iter; ",
1094 " sbuf.get_iter_at_line(out iter, sel.line_start);",
1097 " Gtk.TextIter cur_iter;",
1098 " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
1100 " var cursor_at_line = cur_iter.get_line();",
1103 " //var cur_line = cur_iter.get_line();",
1104 " //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
1108 "\t\tprint(\"scrolling to node -- should occur on node picking.\\n\");",
1109 " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
1112 " var start_line = sel.line_start;",
1113 " var end_line = sel.line_end;",
1116 " this.el.editable = false;",
1118 " //var colon_pos = 0;",
1120 " this.editable_start_pos = -1;",
1122 " // now if we have selected a property...",
1123 " if (this.prop_selected.length> 0 ) {",
1125 "\t\tint nstart, nend;",
1126 "\t\tif (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) {",
1127 "\t\t\tstart_line = nstart;",
1128 "\t\t\tend_line = nend;",
1129 "\t\t\t// this.el.editable = true; << cant do this!!?",
1130 "\t\t\tprint(\"start line = %d, end line = %d\\n\", start_line, end_line);",
1132 "\t\t\t\t// see if we are 'right of ':'",
1133 "\t\t\t\t// get an iter for the start of the line.",
1134 "\t\t\tGtk.TextIter start_first_line_iter,end_first_line_iter;",
1135 "\t\t\tthis.el.buffer.get_iter_at_line(out start_first_line_iter, start_line -1);",
1136 "\t\t\tthis.el.buffer.get_iter_at_line(out end_first_line_iter, start_line -1);",
1141 "\t\t\tif (end_first_line_iter.forward_to_line_end()) {",
1142 "\t\t\t\tvar first_line = this.el.buffer.get_text(start_first_line_iter, end_first_line_iter, false);",
1144 "\t\t\t\tprint(\"first line = %s\\n\", first_line);",
1145 "\t\t\t\tif (first_line.contains(\":\")) {",
1146 "\t\t\t\t\tthis.editable_start_pos = start_first_line_iter.get_offset() + first_line.index_of(\":\") + 1;",
1147 "\t\t\t\t\tprint(\"colon_pos = %d\\n\", this.editable_start_pos);",
1151 "\t\t\t\t//Gtk.TextIter colon_iter;",
1152 "\t\t\t\t//sbuf.get_iter_at_offset (out colon_iter, colon_pos);",
1153 "\t\t\t\t//sbuf.create_source_mark(null, \"active_text\", colon_iter);",
1158 "\t\t\t//print(\"is cursor at line? %d ?= %d\\n\", start_line -1 , cursor_at_line);",
1159 "\t\t\t//if (start_line - 1 == cursor_at_line) {",
1160 "\t\t\t// should be ok - current_posssion can not be less than '-1'...",
1161 "\t\t\tif (sbuf.cursor_position < this.editable_start_pos) {",
1163 "\t\t\t\tprint(\"cursor is before start pos.. - turn off editable...\\n\");",
1164 "\t\t\t\t//var before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false);",
1165 "\t\t\t\t//print(\"before cursor string = %s\\n\", before_cursor_string);",
1166 "\t\t\t\t//if (!before_cursor_string.contains(\":\")) {",
1167 "\t\t\t\t\tthis.el.editable = false;",
1176 "\t\tprint(\"propSelected = %s range %d -> %d\\n\", this.prop_selected, start_line, end_line);\t\t",
1181 "\tprint(\"checking selection\\n\");",
1184 " // check selection - if it's out of 'bounds'",
1185 " if (this.el.editable && sbuf.get_has_selection()) {",
1186 "\t\tGtk.TextIter sel_start_iter, sel_end_iter;",
1187 "\t\tsbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter);",
1189 "\t\tif (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line ||",
1190 "\t\t\tsel_start_iter.get_line() > end_line || sel_end_iter.get_line() < start_line\t\t\t) {",
1192 "\t\t\tthis.el.editable = false;",
1194 "\t\tif (this.editable_start_pos > 0 &&",
1195 "\t\t\t(sel_start_iter.get_offset() < this.editable_start_pos || sel_end_iter.get_offset() < this.editable_start_pos)",
1198 "\t\t\tthis.el.editable = false;",
1208 " for (var i = 0; i < buf.get_line_count();i++) {",
1209 " if (i < (start_line -1) || i > (end_line -1)) {",
1211 " sbuf.get_iter_at_line(out iter, i);",
1212 " sbuf.create_source_mark(null, \"grey\", iter);",
1217 " if (scroll && (cursor_at_line > end_line || cursor_at_line < start_line)) {",
1218 "\t Gtk.TextIter cpos_iter;",
1219 "\t\tbuf.get_iter_at_line(out cpos_iter, start_line);",
1221 "\t\tbuf.place_cursor(cpos_iter); ",
1229 "xtype" : "ScrolledWindow"
1233 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
1234 "bool homogeneous" : false,
1235 "bool vexpand" : false,
1241 "var description = Pango.FontDescription.from_string(\"monospace\");",
1242 "\tdescription.set_size(8000);",
1243 "\t this.el.override_font(description);",
1247 "bool hexpand" : true,
1248 "id" : "search_entry",
1249 "int width_request" : 300,
1254 "\tif (this.el.text == \"\") {",
1255 "\t\t_this.search_results.el.hide();",
1259 "\tswitch(_this.windowstate.state) {",
1260 "\t\tcase WindowState.State.CODEONLY:",
1261 "\t\t///case WindowState.State.CODE:",
1262 "\t\t\t// search the code being edited..",
1263 "\t\t\tres = _this.windowstate.code_editor_tab.search(this.el.text);",
1266 "\t\tcase WindowState.State.PREVIEW:",
1267 "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
1268 "\t\t\t\t res = _this.windowstate.window_gladeview.search(this.el.text);",
1270 "\t\t\t\t res = _this.windowstate.window_rooview.search(this.el.text);\t\t\t",
1276 "\t_this.search_results.el.show();",
1278 "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
1280 "\t\t_this.search_results.el.label = \"No Matches\";",
1288 "key_press_event" : [
1290 " if (event.keyval == Gdk.Key.g && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
1291 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
1292 "\t\t_this.forwardSearch(true);",
1297 " \tif (event.keyval == Gdk.Key.Return && this.el.text.length > 0) {",
1298 "\t\tvar res = _this.search(this.el.text);",
1299 "\t\t _this.search_results.updateResults();",
1301 "\t\tGLib.Timeout.add_seconds(2,() => {",
1302 "\t\t\t _this.search_results.updateResults();",
1303 "\t\t\t return false;",
1310 " // print(event.key.keyval)",
1317 "string placeholder_text" : "Press enter to search",
1318 "xtype" : "SearchEntry",
1319 "| void forwardSearch" : [
1320 "(bool change_focus) {",
1323 "\t_this.forwardSearch(change_focus);",
1327 "\tswitch(_this.windowstate.state) {",
1328 "\t\tcase WindowState.State.CODEONLY:",
1329 "\t\t//case WindowState.State.CODE:",
1330 "\t\t\t// search the code being edited..",
1331 "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
1334 "\t\tcase WindowState.State.PREVIEW:",
1335 "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
1336 "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
1338 "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
1356 "bool always_show_image" : true,
1357 "bool visible" : false,
1358 "id" : "search_results",
1360 "button_press_event" : [
1363 " if (this.popup == null) {",
1364 " this.popup = new Xcls_ValaCompileErrors();",
1365 " this.popup.window = _this;",
1369 " this.popup.show(this.notices, this.el);",
1375 "xtype" : "ImageMenuItem",
1376 "| void updateResults" : [
1378 "\tthis.el.visible = true;",
1380 "\tvar res = _this.searchcontext.get_occurrences_count();",
1382 "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
1386 "\t_this.nextBtn.el.sensitive = false;",
1387 "\t_this.backBtn.el.sensitive = false;\t",
1390 "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
1391 "\t\t_this.nextBtn.el.sensitive = true;",
1392 "\t\t_this.backBtn.el.sensitive = true;",
1395 "\t_this.search_results.el.label = \"No Matches\";",
1405 "bool always_show_image" : true,
1406 "bool sensitive" : false,
1412 "string icon_name" : "go-down",
1417 "button_press_event" : [
1420 "\t_this.forwardSearch(true);",
1427 "string label" : "Next",
1432 "bool always_show_image" : true,
1433 "bool sensitive" : false,
1439 "string icon_name" : "go-up",
1444 "button_press_event" : [
1447 "\t_this.backSearch(true);",
1454 "string label" : "Previous",
1459 "bool always_show_image" : true,
1464 "string icon_name" : "emblem-system",
1470 "id" : "search_settings",
1476 "\tthis.el.show();",
1480 "id" : "case_sensitive",
1481 "string label" : "Case Sensitive",
1482 "xtype" : "CheckMenuItem"
1488 "\tthis.el.show();",
1493 "string label" : "Regex",
1494 "xtype" : "CheckMenuItem"
1500 "\tthis.el.show();",
1505 "string label" : "Multi-line (add \\n)",
1506 "xtype" : "CheckMenuItem"
1512 "string label" : "Settings",
1513 "xtype" : "MenuButton"
1522 "xtype" : "Notebook"
1527 "(string in_txt) {",
1528 "\tthis.notebook.el.page = 1;",
1532 "\tvar s = new Gtk.SourceSearchSettings();",
1533 "\ts.case_sensitive = _this.case_sensitive.el.active;",
1534 "\ts.regex_enabled = _this.regex.el.active;\t",
1535 "\ts.wrap_around = false;",
1537 "\tthis.searchcontext = new Gtk.SourceSearchContext(this.buffer.el,s);",
1538 "\tthis.searchcontext.set_highlight(true);",
1539 "\tvar txt = in_txt;",
1541 "\tif (_this.multiline.el.active) {",
1542 "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
1545 "\ts.set_search_text(txt);",
1546 "\tGtk.TextIter beg, st,en;",
1548 "\tthis.buffer.el.get_start_iter(out beg);",
1549 "\tthis.searchcontext.forward(beg, out st, out en);",
1550 "\tthis.last_search_end = 0;",
1552 "\treturn this.searchcontext.get_occurrences_count();",
1560 "| void backSearch" : [
1561 "(bool change_focus) {",
1563 "\tif (this.searchcontext == null) {",
1567 "\tGtk.TextIter beg, st,en;",
1568 "\tbool has_wrapped_around;",
1569 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
1571 "\tif (!this.searchcontext.backward2(beg, out st, out en, out has_wrapped_around)) {",
1573 "\t\tthis.last_search_end = 0;",
1576 "\tthis.last_search_end = en.get_offset();",
1577 "\tif (change_focus) {",
1578 "\t\tthis.sourceview.el.grab_focus();",
1580 "\tthis.buffer.el.place_cursor(st);",
1581 "\tthis.sourceview.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
1582 "\tvar ln = st.get_line();",
1583 "\tthis.highlightNodeAtLine(ln);",
1589 "| void createThumb" : [
1593 " if (this.file == null) {",
1596 "\tif (this.notebook.el.page > 0 ) {",
1600 " var filename = this.file.getIconFileName(false);",
1602 " var win = this.el.get_parent_window();",
1603 " var width = win.get_width();",
1604 " // var height = win.get_height();",
1606 " Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, this.paned.el.position);",
1607 " screenshot.save(filename,\"png\");",
1608 " } catch(Error e) {",
1619 "| void forwardSearch" : [
1620 "(bool change_focus) {",
1622 "\tif (this.searchcontext == null) {",
1625 "\tthis.notebook.el.page = 1;",
1626 "\tGtk.TextIter beg, st,en, stl;",
1628 "\tvar buf = this.sourceview.el.get_buffer();",
1629 "\tbuf.get_iter_at_offset(out beg, this.last_search_end);",
1630 "\tif (!this.searchcontext.forward(beg, out st, out en)) {",
1631 "\t\tthis.last_search_end = 0;",
1634 "\tthis.last_search_end = en.get_offset();",
1635 "\tif (change_focus) {",
1636 "\t\tthis.sourceview.el.grab_focus();",
1638 "\tbuf.place_cursor(st);",
1642 "\tthis.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f);",
1645 "\tvar ln = st.get_line();",
1647 "\tthis.highlightNodeAtLine(ln);",
1651 "| void highlightNodeAtLine" : [
1656 "\t// highlight node...",
1659 " var node = _this.file.lineToNode(ln+1);",
1661 " if (node == null) {",
1662 " //print(\"can not find node\\n\");",
1665 " var prop = node.lineToProp(ln+1);",
1666 " print(\"prop : %s\", prop == null ? \"???\" : prop);",
1669 " // ---------- this selects the tree's node...",
1671 " var ltree = _this.main_window.windowstate.left_tree;",
1672 " var tp = ltree.model.treePathFromNode(node);",
1673 " print(\"got tree path %s\\n\", tp);",
1674 " if (tp == \"\") {",
1677 " //_this.sourceview.allow_node_scroll = false; /// block node scrolling..",
1680 " //print(\"changing cursor on tree..\\n\");",
1684 " // let's try allowing editing on the methods.",
1685 " // a little klunky at present..",
1686 "\t_this.sourceview.prop_selected = \"\";",
1687 " if (prop != null) {",
1688 "\t\t//see if we can find it..",
1689 "\t\tvar kv = prop.split(\":\");",
1690 "\t\tif (kv[0] == \"p\") {",
1692 " \t\t//var k = prop.get_key(kv[1]);",
1693 " \t\t// fixme -- need to determine if it's an editable property...",
1694 " \t\t_this.sourceview.prop_selected = prop;",
1696 "\t\t} else if (kv[0] == \"l\") {",
1697 "\t\t\t _this.sourceview.prop_selected = prop;",
1701 " ltree.view.setCursor(tp, \"editor\");",
1702 " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
1703 " _this.sourceview.nodeSelected(node,false);",
1705 " // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
1706 " // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
1707 "\t // this.allow_node_scroll = true;",
1708 "\t // return false;",
1725 "| void loadFile" : [
1727 "(JsRender.JsRender file)",
1729 " this.file = file;",
1730 " this.view.renderJS(true);",
1731 " this.notebook.el.page = 0;// gtk preview ",
1732 " this.sourceview.loadFile(); ",
1738 "| void requestRedraw" : [
1740 " this.view.renderJS(false);",
1741 " this.sourceview.loadFile(); ",
1744 "| void scroll_to_line" : [
1746 " this.notebook.el.page = 1;// code preview...",
1748 " GLib.Timeout.add(500, () => {",
1753 "\t\t var buf = this.sourceview.el.get_buffer();",
1755 "\t\tvar sbuf = (Gtk.SourceBuffer) buf;",
1758 "\t\tGtk.TextIter iter; ",
1759 "\t\tsbuf.get_iter_at_line(out iter, line);",
1760 "\t\tthis.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
1761 "\t\treturn false;",
1771 "name" : "WindowRooView",
1773 "path" : "/home/alan/gitlive/roobuilder/src/Builder4/WindowRooView.bjs",