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();;",
259 "| void initInspector" : [
262 " /* if (this.inspector == this.el.get_inspector()) {",
263 " this.inspector.show();",
264 " this.inspector.open_window(); ",
265 " print(\"init inspecter called, and inspector is the same as existing\\n\");",
268 " print(\"new inspector?\\n\");",
270 " this.inspector = this.el.get_inspector();",
271 " this.inspector.ref();",
273 " // got a new inspector...",
275 " this.inspector.open_window.connect(() => {",
276 " this.inspector = this.el.get_inspector();",
277 " print(\"inspector attach\\n\");",
278 " var wv = this.inspector.get_web_view();",
279 " if (wv != null) {",
280 " print(\"got inspector web view\\n\");",
282 " var cn = _this.inspectorcontainer.el.get_child();",
283 " if (cn != null) {",
284 " _this.inspectorcontainer.el.remove(cn);",
287 " _this.inspectorcontainer.el.add(wv);",
290 " //this.inspector.close();",
292 " //this.inspector = null;",
300 " this.inspector.closed.connect(() => {",
301 " print(\"inspector closed?!?\");",
302 " // if this happens destroy the webkit..",
304 " this.el.stop_loading();",
306 " if (_this.viewbox.el.get_parent() == null) {",
311 " _this.viewbox.el.remove(_this.viewcontainer.el);",
312 " _this.el.remove(_this.inspectorcontainer.el); ",
314 " // destory seems to cause problems.",
315 " //this.el.destroy();",
316 " //_this.viewcontainer.el.destroy();",
317 " //_this.inspectorcontainer.el.destroy();",
320 " var nv =new Xcls_viewcontainer(_this);",
322 " _this.viewbox.el.pack_end(nv.el,true,true,0);",
324 " var inv =new Xcls_inspectorcontainer(_this);",
326 " _this.el.pack2(inv.el,true,true);",
328 " inv.el.show_all();",
329 " nv.el.show_all();",
330 " //while(Gtk.events_pending ()) Gtk.main_iteration ();",
331 " //_this.view.renderJS(true); ",
332 " _this.view.refreshRequired = true;",
337 " this.inspector.show();",
343 " print(\"reInit?\");",
344 " // if this happens destroy the webkit..",
346 " this.el.stop_loading();",
348 " if (_this.viewbox.el.get_parent() == null) {",
353 " _this.viewbox.el.remove(_this.viewcontainer.el);",
354 " _this.paned.el.remove(_this.inspectorcontainer.el); ",
356 " // destory seems to cause problems.",
357 " //this.el.destroy();",
358 " //_this.viewcontainer.el.destroy();",
359 " //_this.inspectorcontainer.el.destroy();",
360 " var inv =new Xcls_inspectorcontainer(_this);",
362 " _this.paned.el.pack2(inv.el,true,true);",
366 " var nv =new Xcls_viewcontainer(_this);",
368 " _this.viewbox.el.pack_end(nv.el,true,true,0);",
371 " inv.el.show_all();",
372 " nv.el.show_all();",
373 " //while(Gtk.events_pending ()) Gtk.main_iteration ();",
374 " //_this.view.renderJS(true); ",
375 " _this.view.refreshRequired = true;",
379 "| void renderJS" : [
382 " // this is the public redraw call..",
383 " // we refresh in a loop privately..",
384 " var autodraw = _this.AutoRedraw.el.active;",
385 " if (!autodraw && !force) {",
386 " print(\"Skipping redraw - no force, and autodraw off\");",
390 " this.refreshRequired = true;",
394 "| void runRefresh" : [
397 " // this is run every 2 seconds from the init..",
401 " if (!this.refreshRequired) {",
402 " // print(\"no refresh required\");",
406 " if (this.lastRedraw != null) {",
407 " // do not redraw if last redraw was less that 5 seconds ago.",
408 " if ((int64)(new DateTime.now_local()).difference(this.lastRedraw) < 5000 ) {",
413 " if (_this.file == null) {",
418 " this.refreshRequired = false;",
419 " // print(\"HTML RENDERING\");",
422 " //this.get('/BottomPane').el.show();",
423 " //this.get('/BottomPane').el.set_current_page(2);// webkit inspector",
424 " _this.file.webkit_page_id = this.el.get_page_id();",
426 " var js = _this.file.toSourcePreview();",
428 " if (js.length < 1) {",
429 " print(\"no data\");",
432 "// var data = js[0];",
435 " var project = _this.file.project; ",
437 " //print (project.fn);",
438 " // set it to non-empty.",
440 "// runhtml = runhtml.length ? runhtml : '<script type=\"text/javascript\"></script>'; ",
443 "// this.runhtml = this.runhtml || '';",
446 " // then we need to reload the browser using",
447 " // load_html_string..",
449 " // then trigger a redraw once it's loaded..",
450 " this.pendingRedraw = true;",
452 " var runhtml = \"<script type=\\\"text/javascript\\\">\\n\" ;",
453 " string builderhtml;",
456 " GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + \"/resources/roo.builder.js\", out builderhtml);",
457 " } catch (Error e) {",
458 " builderhtml = \"\";",
461 " runhtml += builderhtml + \"\\n\";",
462 " runhtml += \"</script>\\n\" ;",
464 " // fix to make sure they are the same..",
465 " this.runhtml = project.runhtml;",
466 " // need to modify paths",
469 " var base_template = _this.file.project.base_template;",
471 " if (base_template.length > 0 && !FileUtils.test(",
472 " BuilderApplication.configDirectory() + \"/resources/\" + base_template, FileTest.EXISTS) ",
474 " print(\"invalid base_template name - using default: %s\\n\", base_template);",
475 " base_template = \"\";",
479 " GLib.FileUtils.get_contents(",
480 " BuilderApplication.configDirectory() + \"/resources/\" + ",
481 " (base_template.length > 0 ? base_template : \"roo.builder.html\")",
484 " } catch (Error e) {",
487 " this.renderedData = js;",
490 " string js_src = js + \"\\n\" +",
491 "\t\"Roo.onReady(function() {\\n\" +",
492 "\t\"if (\" + _this.file.name +\".show) \" + _this.file.name +\".show({});\\n\" +",
493 "\t\"Roo.XComponent.build();\\n\" +",
496 " // print(\"render js: \" + js);",
497 " //if (!this.ready) {",
498 " // console.log('not loaded yet');",
500 " this.lastRedraw = new DateTime.now_local();",
503 " //this.runjs = js_src;",
504 " var fc = FakeServerCache.factory_with_data(js_src);",
505 " this.runjs = fc.fname;",
507 " var html = inhtml.replace(\"</head>\", runhtml + this.runhtml + ",
508 " \"<script type=\\\"text/javascript\\\" src=\\\"xhttp://localhost\" + fc.fname + \"\\\"></script>\" + ",
509 " // \"<script type=\\\"text/javascript\\\">\\n\" +",
510 " // js_src + \"\\n\" + ",
511 " // \"</script>\" + ",
514 " //print(\"LOAD HTML \" + html);",
516 " var rootURL = _this.file.project.rootURL;",
520 " this.el.load_html( html , ",
521 " //fixme - should be a config option!",
522 " (rootURL.length > 0 ? rootURL : \"xhttp://localhost/roobuilder/\")",
525 " // force the inspector... ",
526 " // this.initInspector();",
528 " // - no need for this, the builder javascript will call it when build is complete",
529 " //GLib.Timeout.add_seconds(1, () => {",
530 " // this.el.run_javascript(\"Builder.saveHTML()\",null);",
533 "// print( \"before render\" + this.lastRedraw);",
534 "// print( \"after render\" + (new Date()));",
541 "xtype" : "ScrolledWindow"
547 "$ shadow_type" : "Gtk.ShadowType.IN",
550 " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
554 "* pack" : "pack2,true,true",
555 "id" : "inspectorcontainer",
556 "xtype" : "ScrolledWindow"
563 "* pack" : "append_page,_this.label_code.el",
566 "# JsRender.Node? node_selected" : "null",
567 "# bool button_is_pressed" : false,
568 "# bool key_is_pressed" : false,
569 "# bool loading" : true,
570 "# int editable_start_pos" : "-1",
571 "$ string prop_selected" : "\"\"",
577 " var description = Pango.FontDescription.from_string(\"monospace\");",
578 " description.set_size(8000);",
579 " this.el.override_font(description);",
581 " this.loading = true;",
582 " //var buf = this.el.get_buffer();",
583 " //buf.notify.connect(this.onCursorChanged);",
586 " var attrs = new Gtk.SourceMarkAttributes();",
587 " var pink = Gdk.RGBA();",
588 " pink.parse ( \"pink\");",
589 " attrs.set_background ( pink);",
590 " attrs.set_icon_name ( \"process-stop\"); ",
591 " attrs.query_tooltip_text.connect(( mark) => {",
592 " //print(\"tooltip query? %s\\n\", mark.name);",
593 " return mark.name;",
596 " this.el.set_mark_attributes (\"ERR\", attrs, 1);",
598 " var wattrs = new Gtk.SourceMarkAttributes();",
599 " var blue = Gdk.RGBA();",
600 " blue.parse ( \"#ABF4EB\");",
601 " wattrs.set_background ( blue);",
602 " wattrs.set_icon_name ( \"process-stop\"); ",
603 " wattrs.query_tooltip_text.connect(( mark) => {",
604 " //print(\"tooltip query? %s\\n\", mark.name);",
605 " return mark.name;",
608 " this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
612 " var dattrs = new Gtk.SourceMarkAttributes();",
613 " var purple = Gdk.RGBA();",
614 " purple.parse ( \"#EEA9FF\");",
615 " dattrs.set_background ( purple);",
616 " dattrs.set_icon_name ( \"process-stop\"); ",
617 " dattrs.query_tooltip_text.connect(( mark) => {",
618 " //print(\"tooltip query? %s\\n\", mark.name);",
619 " return mark.name;",
622 " this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
625 " var gattrs = new Gtk.SourceMarkAttributes();",
626 " var grey = Gdk.RGBA();",
627 " grey.parse ( \"#ccc\");",
628 " gattrs.set_background ( grey);",
631 " this.el.set_mark_attributes (\"grey\", gattrs, 1);",
642 "gboolean editable" : false,
643 "gboolean show_line_marks" : true,
644 "gboolean show_line_numbers" : true,
649 "* pack" : "set_buffer",
650 "bool dirty" : false,
652 "int error_line" : "-1",
658 " // check syntax??",
660 " // _this.save_button.el.sensitive = true;",
661 " ///?? has changed occured during loading?",
663 " // only trigger this if ",
668 " if (_this.sourceview.loading) {",
674 " print(\"- PREVIEW EDITOR CHANGED--\");",
676 " this.dirty = true; ",
677 " this.checkSyntax(); // this calls backs and highlights errors.. in theory... ",
681 "\tif (!_this.sourceview.button_is_pressed && !_this.sourceview.key_is_pressed) {",
682 "\t\tprint(\"button or key not pressed to generate change?!\\n\");",
687 "\t// what are we editing??",
688 "\tif (null == _this.sourceview.node_selected || _this.sourceview.prop_selected.length < 1) {",
692 "\t// find the colon on the first line...",
694 "\tif (_this.sourceview.editable_start_pos > -1) {",
696 "\t\tvar buf = (Gtk.SourceBuffer)_this.sourceview.el.get_buffer();",
698 " //print(\"cursor changed : %d\\n\", buf.cursor_position);",
699 " Gtk.TextIter spos,epos;",
700 " buf.get_iter_at_offset(out spos, _this.sourceview.editable_start_pos);",
701 " buf.get_iter_at_offset(out epos, _this.sourceview.editable_start_pos); // initialize epos..",
703 " var gotit= false;",
704 " var line = spos.get_line();",
705 " var endline = buf.get_line_count();",
706 " while (line < endline) {",
708 "\t buf.get_iter_at_line(out epos, line);",
709 "\t if (buf.get_source_marks_at_line(line, \"grey\").length() > 0) {",
710 "\t\t buf.get_iter_at_line(out epos, line);\t \t\t",
711 "\t \t\tgotit=true;",
717 "\t \t\tprint(\"End Offset = %d/%d\\n\", epos.get_line(), epos.get_offset());",
718 "\t\t\t// get the pos...",
719 "\t\t\t// in theory the last char will be '}' or '},' .. or ','",
720 "\t\t\t// we should chop the ',' of the end...",
721 "\t\t\tvar str = buf.get_text(spos, epos, false);",
722 "\t\t\tprint(\"got string\\n%s\\n\", str);",
733 "xtype" : "SourceBuffer",
734 "| bool checkSyntax" : [
738 " var str = this.toString();",
741 " if (this.error_line > 0) {",
742 " Gtk.TextIter start;",
743 " Gtk.TextIter end; ",
744 " this.el.get_bounds (out start, out end);",
746 " this.el.remove_source_marks (start, end, \"WARN\");",
747 " this.el.remove_source_marks (start, end, \"ERR\"); ",
751 " if (str.length < 1) {",
752 " print(\"checkSyntax - empty string?\\n\");",
756 " if (_this.file == null) {",
759 " var p = _this.file.project.palete;",
762 " if (_this.file.language != \"js\") {",
763 "\t\treturn false; // fake syntax error.",
766 " //Gee.HashMap<int,string> ret_x;",
768 "\treturn p.javascriptHasErrors(",
769 "\t\t_this.main_window.windowstate,",
771 " \"\", // _this.key, ",
772 " \"file\", //_this.ptype,",
780 "| string toString" : [
785 " this.el.get_start_iter(out s);",
786 " this.el.get_end_iter(out e);",
787 " var ret = this.el.get_text(s,e,true);",
788 " //print(\"TO STRING? \" + ret);",
793 "| bool highlightErrors" : [
794 "( Gee.HashMap<int,string> validate_res) {",
796 " this.error_line = validate_res.size;",
798 " if (this.error_line < 1) {",
801 " var tlines = this.el.get_line_count ();",
802 " Gtk.TextIter iter;",
803 " var valiter = validate_res.map_iterator();",
804 " while (valiter.next()) {",
806 "// print(\"get inter\\n\");",
807 " var eline = valiter.get_key();",
808 " if (eline > tlines) {",
811 " this.el.get_iter_at_line( out iter, eline);",
812 " //print(\"mark line\\n\");",
813 " this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
821 "button_press_event" : [
825 "\tthis.button_is_pressed = true;",
830 "button_release_event" : [
833 "\tprint(\"BUTTON RELEASE EVENT\\n\");",
834 "\tthis.onCursorChanged();",
835 "\tthis.button_is_pressed = false;",
839 "key_press_event" : [
841 "\tthis.key_is_pressed = true;",
842 "\t// is it ctrl-G -- find next?",
843 "\t// which will will still ignore..",
845 "\tif \t(key.str == \"g\" && key.state == Gdk.ModifierType.CONTROL_MASK) {",
846 "\t\tthis.key_is_pressed = false;",
849 "\t// if cursor postion is 'at start' of editing range, ",
850 "\t// and backspace is pressed...",
853 "\t var buf = this.el.get_buffer();",
854 " //print(\"cursor changed : %d\\n\", buf.cursor_position);",
856 "\tif (buf.cursor_position <= this.editable_start_pos && key.keyval == Gdk.Key.BackSpace) {",
857 "\t\treturn true; // block...",
859 "\t// what about 'last line of 'grey...'",
860 "\t// get the buffer - find the line, find the next line ?? see if it's grey?",
863 "\tprint(\"KEY PRESS EVENT \\n\");",
864 "\tthis.onCursorChanged();",
868 "key_release_event" : [
870 "\tthis.key_is_pressed = false;",
876 "xtype" : "SourceView",
877 "| string toString" : [
881 " this.el.get_buffer().get_start_iter(out s);",
882 " this.el.get_buffer().get_end_iter(out e);",
883 " var ret = this.el.get_buffer().get_text(s,e,true);",
884 " //print(\"TO STRING? \" + ret);",
889 "| void clearGreySelection" : [
891 " // clear all the marks..",
892 " var sbuf = (Gtk.SourceBuffer)this.el.buffer;",
894 " Gtk.TextIter start;",
895 " Gtk.TextIter end; ",
897 " sbuf.get_bounds (out start, out end);",
898 " sbuf.remove_source_marks (start, end, \"grey\");",
904 "| void highlightErrorsJson" : [
905 " (string type, Json.Object obj) {",
906 " // this is a hook for the vala code - it has no value in javascript ",
907 " // as we only have one error ususally....",
915 "| void loadFile" : [
917 " this.loading = true;",
920 " // get the cursor and scroll position....",
921 " var buf = this.el.get_buffer();",
922 "\tvar cpos = buf.cursor_position;",
924 " print(\"BEFORE LOAD cursor = %d\\n\", cpos);",
926 " var vadj_pos = this.el.get_vadjustment().get_value();",
930 " buf.set_text(\"\",0);",
931 " var sbuf = (Gtk.SourceBuffer) buf;",
935 " if (_this.file == null || _this.file.xtype != \"Roo\") {",
936 " print(\"xtype != Roo\");",
937 " this.loading = false;",
941 " // get the string from the rendered tree...",
943 " var str = _this.file.toSource();",
945 "// print(\"setting str %d\\n\", str.length);",
946 " buf.set_text(str, str.length);",
947 " var lm = Gtk.SourceLanguageManager.get_default();",
949 " //?? is javascript going to work as js?",
951 " ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));",
954 " Gtk.TextIter start;",
955 " Gtk.TextIter end; ",
957 " sbuf.get_bounds (out start, out end);",
958 " sbuf.remove_source_marks (start, end, null); // remove all marks..",
960 " GLib.Timeout.add(500, () => {",
962 " print(\"RESORTING cursor to = %d\\n\", cpos);",
963 "\t\tGtk.TextIter cpos_iter;",
964 "\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);",
965 "\t\tbuf.place_cursor(cpos_iter); ",
967 "\t\tthis.el.get_vadjustment().set_value(vadj_pos);;",
970 "\t\tthis.onCursorChanged();",
973 "\t\t_this.buffer.checkSyntax();",
977 " this.loading = false; ",
978 " _this.buffer.dirty = false;",
982 "| void nodeSelected" : [
983 "(JsRender.Node? sel, bool scroll ) {",
987 " // this is connected in widnowstate",
990 "\t// not sure why.... ",
991 " while(Gtk.events_pending()) {",
992 " Gtk.main_iteration();",
995 " this.node_selected = sel;",
997 " this.updateGreySelection(scroll);",
1006 "| void onCursorChanged" : [
1007 "(/*ParamSpec ps*/) {",
1009 "\t\tif (!this.key_is_pressed && !this.button_is_pressed) {",
1013 "\t if (this.loading) {",
1016 " // if (ps.name != \"cursor-position\") {",
1020 " var buf = this.el.get_buffer();",
1021 " //print(\"cursor changed : %d\\n\", buf.cursor_position);",
1022 " Gtk.TextIter cpos;",
1023 " buf.get_iter_at_offset(out cpos, buf.cursor_position);",
1025 " var ln = cpos.get_line();",
1028 " // --- select node at line....",
1030 " var node = _this.file.lineToNode(ln+1);",
1032 " if (node == null) {",
1033 " print(\"can not find node\\n\");",
1036 " var prop = node.lineToProp(ln+1);",
1037 " print(\"prop : %s\", prop == null ? \"???\" : prop);",
1040 " // ---------- this selects the tree's node...",
1042 " var ltree = _this.main_window.windowstate.left_tree;",
1043 " var tp = ltree.model.treePathFromNode(node);",
1044 " print(\"got tree path %s\\n\", tp);",
1045 " if (tp != \"\") {",
1048 "\t //print(\"changing cursor on tree..\\n\");",
1052 " // let's try allowing editing on the methods.",
1053 " // a little klunky at present..",
1054 " this.prop_selected = \"\";",
1055 " if (prop != null) {",
1056 " \t\t//see if we can find it..",
1057 " \t\tvar kv = prop.split(\":\");",
1058 " \t\tif (kv[0] == \"p\") {",
1060 "\t \t\t//var k = prop.get_key(kv[1]);",
1061 "\t \t\t// fixme -- need to determine if it's an editable property...",
1062 "\t \t\tthis.prop_selected = prop;",
1064 " \t\t} else if (kv[0] == \"l\") {",
1065 " \t\t\t this.prop_selected = prop;",
1069 " ltree.view.setCursor(tp, \"editor\");",
1070 " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
1071 " this.nodeSelected(node,false);",
1073 " // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
1077 " // highlight the node..",
1081 "| void updateGreySelection" : [
1083 "\tvar sel = this.node_selected;",
1084 "\tprint(\"node selected\\n\");",
1085 " var buf = this.el.get_buffer();",
1086 " var sbuf = (Gtk.SourceBuffer) buf;",
1089 " this.clearGreySelection();",
1093 " if (sel == null) {",
1094 "\t print(\"no selected node\\n\");",
1095 " // no highlighting..",
1099 " print(\"highlight region %d to %d\\n\", sel.line_start,sel.line_end);",
1100 " Gtk.TextIter iter; ",
1101 " sbuf.get_iter_at_line(out iter, sel.line_start);",
1104 " Gtk.TextIter cur_iter;",
1105 " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
1107 " var cursor_at_line = cur_iter.get_line();",
1110 " //var cur_line = cur_iter.get_line();",
1111 " //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
1115 "\t\tprint(\"scrolling to node -- should occur on node picking.\\n\");",
1116 " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
1119 " var start_line = sel.line_start;",
1120 " var end_line = sel.line_end;",
1123 " this.el.editable = false;",
1125 " //var colon_pos = 0;",
1127 " this.editable_start_pos = -1;",
1129 " // now if we have selected a property...",
1130 " if (this.prop_selected.length> 0 ) {",
1132 "\t\tint nstart, nend;",
1133 "\t\tif (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) {",
1134 "\t\t\tstart_line = nstart;",
1135 "\t\t\tend_line = nend;",
1136 "\t\t\tthis.el.editable = true;",
1137 "\t\t\tprint(\"start line = %d, end line = %d\\n\", start_line, end_line);",
1139 "\t\t\t\t// see if we are 'right of ':'",
1140 "\t\t\t\t// get an iter for the start of the line.",
1141 "\t\t\tGtk.TextIter start_first_line_iter,end_first_line_iter;",
1142 "\t\t\tthis.el.buffer.get_iter_at_line(out start_first_line_iter, start_line -1);",
1143 "\t\t\tthis.el.buffer.get_iter_at_line(out end_first_line_iter, start_line -1);",
1148 "\t\t\tif (end_first_line_iter.forward_to_line_end()) {",
1149 "\t\t\t\tvar first_line = this.el.buffer.get_text(start_first_line_iter, end_first_line_iter, false);",
1151 "\t\t\t\tprint(\"first line = %s\\n\", first_line);",
1152 "\t\t\t\tif (first_line.contains(\":\")) {",
1153 "\t\t\t\t\tthis.editable_start_pos = start_first_line_iter.get_offset() + first_line.index_of(\":\") + 1;",
1154 "\t\t\t\t\tprint(\"colon_pos = %d\\n\", this.editable_start_pos);",
1158 "\t\t\t\t//Gtk.TextIter colon_iter;",
1159 "\t\t\t\t//sbuf.get_iter_at_offset (out colon_iter, colon_pos);",
1160 "\t\t\t\t//sbuf.create_source_mark(null, \"active_text\", colon_iter);",
1165 "\t\t\t//print(\"is cursor at line? %d ?= %d\\n\", start_line -1 , cursor_at_line);",
1166 "\t\t\t//if (start_line - 1 == cursor_at_line) {",
1167 "\t\t\t// should be ok - current_posssion can not be less than '-1'...",
1168 "\t\t\tif (sbuf.cursor_position < this.editable_start_pos) {",
1170 "\t\t\t\tprint(\"cursor is before start pos.. - turn off editable...\\n\");",
1171 "\t\t\t\t//var before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false);",
1172 "\t\t\t\t//print(\"before cursor string = %s\\n\", before_cursor_string);",
1173 "\t\t\t\t//if (!before_cursor_string.contains(\":\")) {",
1174 "\t\t\t\t\tthis.el.editable = false;",
1183 "\t\tprint(\"propSelected = %s range %d -> %d\\n\", this.prop_selected, start_line, end_line);\t\t",
1188 "\tprint(\"checking selection\\n\");",
1191 " // check selection - if it's out of 'bounds'",
1192 " if (this.el.editable && sbuf.get_has_selection()) {",
1193 "\t\tGtk.TextIter sel_start_iter, sel_end_iter;",
1194 "\t\tsbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter);",
1196 "\t\tif (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line ||",
1197 "\t\t\tsel_start_iter.get_line() > end_line || sel_end_iter.get_line() < start_line\t\t\t) {",
1199 "\t\t\tthis.el.editable = false;",
1201 "\t\tif (this.editable_start_pos > 0 &&",
1202 "\t\t\t(sel_start_iter.get_offset() < this.editable_start_pos || sel_end_iter.get_offset() < this.editable_start_pos)",
1205 "\t\t\tthis.el.editable = false;",
1215 " for (var i = 0; i < buf.get_line_count();i++) {",
1216 " if (i < (start_line -1) || i > (end_line -1)) {",
1218 " sbuf.get_iter_at_line(out iter, i);",
1219 " sbuf.create_source_mark(null, \"grey\", iter);",
1224 " if (scroll && (cursor_at_line > end_line || cursor_at_line < start_line)) {",
1225 "\t Gtk.TextIter cpos_iter;",
1226 "\t\tbuf.get_iter_at_line(out cpos_iter, start_line);",
1228 "\t\tbuf.place_cursor(cpos_iter); ",
1236 "xtype" : "ScrolledWindow"
1239 "xtype" : "Notebook"
1245 "\tthis.notebook.el.page = 1;",
1246 " \tvar s = new Gtk.SourceSearchSettings();",
1247 "\tvar buf = (Gtk.SourceBuffer) this.sourceview.el.get_buffer();",
1248 "\tthis.searchcontext = new Gtk.SourceSearchContext(buf,s);",
1249 "\tthis.searchcontext.set_highlight(true);",
1250 "\ts.set_search_text(txt);",
1252 "\tGtk.TextIter beg, st,en;",
1254 "\tbuf.get_start_iter(out beg);",
1255 "\tthis.searchcontext.forward(beg, out st, out en);",
1256 "\tthis.last_search_end = 0;",
1257 "\treturn this.searchcontext.get_occurrences_count();",
1263 "| void createThumb" : [
1267 " if (this.file == null) {",
1270 "\tif (this.notebook.el.page > 0 ) {",
1274 " var filename = this.file.getIconFileName(false);",
1276 " var win = this.el.get_parent_window();",
1277 " var width = win.get_width();",
1278 " // var height = win.get_height();",
1280 " Gdk.Pixbuf screenshot = Gdk.pixbuf_get_from_window(win, 0, 0, width, this.paned.el.position);",
1281 " screenshot.save(filename,\"png\");",
1282 " } catch(Error e) {",
1293 "| void forwardSearch" : [
1294 "(bool change_focus) {",
1296 "\tif (this.searchcontext == null) {",
1299 "\tthis.notebook.el.page = 1;",
1300 "\tGtk.TextIter beg, st,en, stl;",
1302 "\tvar buf = this.sourceview.el.get_buffer();",
1303 "\tbuf.get_iter_at_offset(out beg, this.last_search_end);",
1304 "\tif (!this.searchcontext.forward(beg, out st, out en)) {",
1305 "\t\tthis.last_search_end = 0;",
1308 "\tthis.last_search_end = en.get_offset();",
1309 "\tif (change_focus) {",
1310 "\t\tthis.sourceview.el.grab_focus();",
1312 "\tbuf.place_cursor(st);",
1313 "\tvar ln = st.get_line();",
1314 "\tbuf.get_iter_at_line(out stl,ln);",
1316 "\tthis.sourceview.el.scroll_to_iter(stl, 0.0f, true, 0.0f, 0.5f);",
1318 "\t// highlight node...",
1321 " var node = _this.file.lineToNode(ln+1);",
1323 " if (node == null) {",
1324 " //print(\"can not find node\\n\");",
1327 " var prop = node.lineToProp(ln+1);",
1328 " print(\"prop : %s\", prop == null ? \"???\" : prop);",
1331 " // ---------- this selects the tree's node...",
1333 " var ltree = _this.main_window.windowstate.left_tree;",
1334 " var tp = ltree.model.treePathFromNode(node);",
1335 " print(\"got tree path %s\\n\", tp);",
1336 " if (tp == \"\") {",
1339 " //_this.sourceview.allow_node_scroll = false; /// block node scrolling..",
1342 " //print(\"changing cursor on tree..\\n\");",
1346 " // let's try allowing editing on the methods.",
1347 " // a little klunky at present..",
1348 "\t_this.sourceview.prop_selected = \"\";",
1349 " if (prop != null) {",
1350 "\t\t//see if we can find it..",
1351 "\t\tvar kv = prop.split(\":\");",
1352 "\t\tif (kv[0] == \"p\") {",
1354 " \t\t//var k = prop.get_key(kv[1]);",
1355 " \t\t// fixme -- need to determine if it's an editable property...",
1356 " \t\t_this.sourceview.prop_selected = prop;",
1358 "\t\t} else if (kv[0] == \"l\") {",
1359 "\t\t\t _this.sourceview.prop_selected = prop;",
1363 " ltree.view.setCursor(tp, \"editor\");",
1364 " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
1365 " _this.sourceview.nodeSelected(node,false);",
1367 " // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
1368 " // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
1369 "\t // this.allow_node_scroll = true;",
1370 "\t // return false;",
1387 "| void loadFile" : [
1389 "(JsRender.JsRender file)",
1391 " this.file = file;",
1392 " this.view.renderJS(true);",
1393 " this.notebook.el.page = 0;// gtk preview ",
1394 " this.sourceview.loadFile(); ",
1400 "| void requestRedraw" : [
1402 " this.view.renderJS(false);",
1403 " this.sourceview.loadFile(); ",
1406 "| void scroll_to_line" : [
1408 " this.notebook.el.page = 1;// code preview...",
1410 " GLib.Timeout.add(500, () => {",
1415 "\t\t var buf = this.sourceview.el.get_buffer();",
1417 "\t\tvar sbuf = (Gtk.SourceBuffer) buf;",
1420 "\t\tGtk.TextIter iter; ",
1421 "\t\tsbuf.get_iter_at_line(out iter, line);",
1422 "\t\tthis.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
1423 "\t\treturn false;",
1433 "name" : "WindowRooView",
1435 "path" : "/home/alan/gitlive/roobuilder/src/Builder4/WindowRooView.bjs",