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_error_counter" : 0,
16 "int last_search_end" : 0,
20 "bool vexpand" : true,
26 "id" : "label_preview",
27 "utf8 label" : "Preview",
34 "utf8 label" : "Preview Generated Code",
39 "* pack" : "append_page,_this.label_preview.el",
40 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
41 "bool vexpand" : true,
45 "$ homogeneous" : false,
47 "* pack" : "set_start_child",
48 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
49 "bool vexpand" : true,
53 "$ height_request" : 20,
54 "$ homogeneous" : true,
57 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
65 " _this.view.renderJS( true);",
75 "label" : "Auto Redraw On",
79 " this.el.set_label(this.el.active ? \"Auto Redraw On\" : \"Auto Redraw Off\");",
83 "xtype" : "CheckButton"
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 "# GLib.DateTime lastRedraw" : "null",
107 "# WebKit.WebInspector inspector" : "",
108 "# bool pendingRedraw" : false,
109 "# bool refreshRequired" : false,
111 "# string renderedData" : "\"\"",
112 "# string runhtml" : "\"\"",
113 "# string runjs" : "\"\"",
117 " // this may not work!?",
118 " var settings = this.el.get_settings();",
119 " settings.enable_developer_extras = true;",
122 " var fs= new FakeServer(this.el);",
124 " // this was an attempt to change the url perms.. did not work..",
125 " // settings.enable_file_access_from_file_uris = true;",
126 " // settings.enable_offline_web_application_cache - true;",
127 " // settings.enable_universal_access_from_file_uris = true;",
134 " // FIXME - base url of script..",
135 " // we need it so some of the database features work.",
136 " this.el.load_html( \"Render not ready\" , ",
137 " //fixme - should be a config option!",
138 " // or should we catch stuff and fix it up..",
139 " \"http://localhost/app.Builder/\"",
143 " //this.el.open('file:///' + __script_path__ + '/../builder.html');",
145 " Gtk.drag_dest_set",
148 " Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,",
149 " null, // list of targets",
150 " Gdk.DragAction.COPY // what to do with data after dropped ",
153 " // print(\"RB: TARGETS : \" + LeftTree.atoms[\"STRING\"]);",
154 " Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);",
156 " GLib.Timeout.add_seconds(1, () =>{",
157 " //print(\"run refresh?\");",
158 " if (this.el == null) {",
161 " this.runRefresh(); ",
169 "bool vexpand" : true,
174 " if (le != WebKit.LoadEvent.FINISHED) {",
177 " if (this.runjs.length < 1) {",
180 " // this.el.run_javascript(this.runjs, null);",
181 " FakeServerCache.remove( this.runjs);",
182 " this.runjs = \"\";",
187 " this.initInspector();",
196 " if (this.el == null) {",
200 " var msg = dialog.get_message();",
201 " if (msg.length < 4) {",
205 " GLib.debug(\"script dialog got %s\", msg);",
207 " if (msg.substring(0,4) != \"IPC:\") {",
210 " var ar = msg.split(\":\", 3);",
211 " if (ar.length < 3) {",
216 " case \"SAVEHTML\":",
217 "\t GLib.debug(\"GOT saveHTML %d\", ar[2].length);",
218 " _this.file.saveHTML(ar[2]);",
219 " _this.createThumb();",
229 "| void initInspector" : [
234 " // this.inspector.open_window.connect(() => {",
235 " this.inspector = this.el.get_inspector();",
237 " this.inspector.open_window.connect(() => {",
238 " print(\"inspector attach\\n\");",
239 " var wv = this.inspector.get_web_view();",
240 " if (wv != null) {",
241 " print(\"got inspector web view\\n\");",
243 " var cn = _this.inspectorcontainer.el.get_first_child();",
244 " if (cn != null) {",
245 " _this.inspectorcontainer.el.remove(cn);",
248 " _this.inspectorcontainer.el.append(wv);",
251 "\t print(\"got inspector web view FAILED\\n\");",
252 " //this.inspector.close();",
254 " //this.inspector = null;",
261 " this.inspector.show();",
270 " print(\"reInit?\");",
271 " // if this happens destroy the webkit..",
273 " this.el.stop_loading();",
275 " if (_this.viewbox.el.get_parent() == null) {",
280 " _this.viewbox.el.remove(_this.viewcontainer.el);",
281 " //_this.paned.el.remove(_this.inspectorcontainer.el); ",
283 " // destory seems to cause problems.",
284 " //this.el.destroy();",
285 " //_this.viewcontainer.el.destroy();",
286 " //_this.inspectorcontainer.el.destroy();",
287 " var inv =new Xcls_inspectorcontainer(_this);",
289 " _this.paned.el.set_end_child(inv.el);",
290 " _this.inspectorcontainer = inv;",
293 " var nv =new Xcls_viewcontainer(_this);",
295 " _this.viewbox.el.append(nv.el);",
297 " _this.viewcontainer = nv;",
300 " //while(Gtk.events_pending ()) Gtk.main_iteration ();",
301 " //_this.view.renderJS(true); ",
302 " _this.view.refreshRequired = true;",
308 "| void renderJS" : [
311 " // this is the public redraw call..",
312 " // we refresh in a loop privately..",
313 " var autodraw = _this.AutoRedraw.el.active;",
314 " if (!autodraw && !force) {",
315 " print(\"Skipping redraw - no force, and autodraw off\");",
319 " this.refreshRequired = true;",
323 "| void runRefresh" : [
326 " // this is run every 2 seconds from the init..",
330 " if (!this.refreshRequired) {",
331 " // print(\"no refresh required\");",
335 " if (this.lastRedraw != null) {",
336 " // do not redraw if last redraw was less that 5 seconds ago.",
337 " if ((int64)(new DateTime.now_local()).difference(this.lastRedraw) < 5000 ) {",
342 " if (_this.file == null) {",
347 " this.refreshRequired = false;",
348 " // print(\"HTML RENDERING\");",
351 " //this.get('/BottomPane').el.show();",
352 " //this.get('/BottomPane').el.set_current_page(2);// webkit inspector",
353 " _this.file.webkit_page_id = this.el.get_page_id();",
355 " var js = _this.file.toSourcePreview();",
357 " if (js.length < 1) {",
358 " print(\"no data\");",
361 "// var data = js[0];",
364 " var project = (Project.Roo) _this.file.project; ",
366 " //print (project.fn);",
367 " // set it to non-empty.",
369 "// runhtml = runhtml.length ? runhtml : '<script type=\"text/javascript\"></script>'; ",
372 "// this.runhtml = this.runhtml || '';",
375 " // then we need to reload the browser using",
376 " // load_html_string..",
378 " // then trigger a redraw once it's loaded..",
379 " this.pendingRedraw = true;",
381 " var runhtml = \"<script type=\\\"text/javascript\\\">\\n\" ;",
382 " string builderhtml;",
385 " GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + \"/resources/roo.builder.js\", out builderhtml);",
386 " } catch (Error e) {",
387 " builderhtml = \"\";",
390 " runhtml += builderhtml + \"\\n\";",
391 " runhtml += \"</script>\\n\" ;",
393 " // fix to make sure they are the same..",
394 " this.runhtml = project.runhtml;",
395 " // need to modify paths",
398 " var base_template = project.base_template;",
400 " if (base_template.length > 0 && !FileUtils.test(",
401 " BuilderApplication.configDirectory() + \"/resources/\" + base_template, FileTest.EXISTS) ",
403 " print(\"invalid base_template name - using default: %s\\n\", base_template);",
404 " base_template = \"\";",
408 " GLib.FileUtils.get_contents(",
409 " BuilderApplication.configDirectory() + \"/resources/\" + ",
410 " (base_template.length > 0 ? base_template : \"roo.builder.html\")",
413 " } catch (Error e) {",
416 " this.renderedData = js;",
419 " string js_src = js + \"",
420 "Roo.onReady(function() {",
421 "if (\" + _this.file.name +\".show) {",
422 "\t\t\" + _this.file.name +\".show({});",
423 "\t\t(function() { ",
424 "\t\t\tBuilder.saveHTML.defer(100, Builder);",
425 "\t\t}).defer(100);",
427 "Roo.XComponent.build();",
430 " // print(\"render js: \" + js);",
431 " //if (!this.ready) {",
432 " // console.log('not loaded yet');",
434 " this.lastRedraw = new DateTime.now_local();",
437 " //this.runjs = js_src;",
438 " var fc = FakeServerCache.factory_with_data(js_src);",
439 " this.runjs = fc.fname;",
441 " var html = inhtml.replace(\"</head>\", runhtml + this.runhtml + ",
442 " \"<script type=\\\"text/javascript\\\" src=\\\"xhttp://localhost\" + fc.fname + \"\\\"></script>\" + ",
443 " // \"<script type=\\\"text/javascript\\\">\\n\" +",
444 " // js_src + \"\\n\" + ",
445 " // \"</script>\" + ",
448 " //print(\"LOAD HTML \" + html);",
450 " var rootURL = project.rootURL;",
454 " this.el.load_html( html , ",
455 " //fixme - should be a config option!",
456 " (rootURL.length > 0 ? rootURL : \"xhttp://localhost/roobuilder/\")",
458 " this.initInspector(); ",
459 " // force the inspector... ",
460 " // this.initInspector();",
462 " // - no need for this, the builder javascript will call it when build is complete",
463 " //GLib.Timeout.add_seconds(1, () => {",
464 " // this.el.run_javascript(\"Builder.saveHTML()\",null);",
467 "// print( \"before render\" + this.lastRedraw);",
468 "// print( \"after render\" + (new Date()));",
479 "* pack" : "set_end_child",
480 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
481 "bool vexpand" : true,
482 "id" : "inspectorcontainer",
490 "* pack" : "append_page,_this.label_code.el",
491 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
492 "bool vexpand" : true,
497 "bool vexpand" : true,
498 "id" : "sourceviewscroll",
501 "# JsRender.Node? node_selected" : "null",
502 "# bool button_is_pressed" : false,
503 "# bool key_is_pressed" : false,
504 "# bool loading" : true,
505 "# int editable_start_pos" : "-1",
506 "# string prop_selected" : "\"\"",
507 "$ xns" : "GtkSource",
511 "\tthis.css = new Gtk.CssProvider();",
513 "\tthis.css.load_from_string(",
514 "\t\t\"#roo-view { font: 10px monospace; }\"",
517 "\tGtk.StyleContext.add_provider_for_display(",
518 "\t\tthis.el.get_display(),",
520 "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
525 "\tthis.loading = true;",
526 "\t//var buf = this.el.get_buffer();",
527 "\t//buf.notify.connect(this.onCursorChanged);",
530 "\tvar attrs = new GtkSource.MarkAttributes();",
531 "\tattrs.set_icon_name ( \"process-stop\"); ",
532 "\tattrs.query_tooltip_text.connect(( mark) => {",
533 "\t\t//print(\"tooltip query? %s\\n\", mark.name);",
534 "\t\treturn mark.name;",
537 "\tthis.el.set_mark_attributes (\"ERR\", attrs, 1);",
539 "\t var wattrs = new GtkSource.MarkAttributes();",
540 "\twattrs.set_icon_name ( \"process-stop\"); ",
541 "\twattrs.query_tooltip_text.connect(( mark) => {",
542 "\t\t//print(\"tooltip query? %s\\n\", mark.name);",
543 "\t\treturn mark.name;",
546 "\tthis.el.set_mark_attributes (\"WARN\", wattrs, 1);",
550 "\t var dattrs = new GtkSource.MarkAttributes();",
551 "\tdattrs.set_icon_name ( \"process-stop\"); ",
552 "\tdattrs.query_tooltip_text.connect(( mark) => {",
553 "\t\t//print(\"tooltip query? %s\\n\", mark.name);",
554 "\t\treturn mark.name;",
557 "\tthis.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
560 "\tvar gattrs = new GtkSource.MarkAttributes();",
561 "\tvar grey = Gdk.RGBA();",
562 "\tgrey.parse ( \"#ccc\");",
563 "\tgattrs.set_background ( grey);",
566 "\tthis.el.set_mark_attributes (\"grey\", gattrs, 1);",
575 "* pack" : "set_child",
576 "Gtk.CssProvider css" : "",
577 "gboolean editable" : false,
578 "gboolean show_line_marks" : true,
579 "gboolean show_line_numbers" : true,
583 "$ xns" : "GtkSource",
586 "\tvar buf = this.el;",
587 "\tbuf.create_tag (\"bold\", \"weight\", Pango.Weight.BOLD);",
588 "\tbuf.create_tag (\"type\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#204a87\");",
589 "\tbuf.create_tag (\"keyword\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#a40000\");",
590 "\tbuf.create_tag (\"text\", \"weight\", Pango.Weight.NORMAL, \"foreground\", \"#729fcf\");",
591 "\tbuf.create_tag (\"number\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#ad7fa8\");",
592 "\tbuf.create_tag (\"method\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#729fcf\");",
593 "\tbuf.create_tag (\"property\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#BC1F51\");",
594 "\tbuf.create_tag (\"variable\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#A518B5\");",
597 "\tbuf.create_tag (\"ERR\", \"weight\", Pango.Weight.BOLD, \"background\", \"pink\");",
598 "\tbuf.create_tag (\"WARN\", \"weight\", Pango.Weight.BOLD, \"background\", \"#ABF4EB\");",
599 "\tbuf.create_tag (\"DEPR\", \"weight\", Pango.Weight.BOLD, \"background\", \"#EEA9FF\");",
604 "* pack" : "set_buffer",
605 "bool dirty" : false,
606 "bool in_cursor_change" : false,
608 "int error_line" : "-1",
609 "int last_line" : "-1",
614 " // check syntax??",
616 " // _this.save_button.el.sensitive = true;",
617 " ///?? has changed occured during loading?",
619 " // only trigger this if ",
624 " if (_this.sourceview.loading) {",
630 " print(\"- PREVIEW EDITOR CHANGED--\");",
632 " this.dirty = true; ",
633 " // this.checkSyntax(); // this calls backs and highlights errors.. in theory... ",
637 "\tif (!_this.sourceview.button_is_pressed && !_this.sourceview.key_is_pressed) {",
638 "\t\tprint(\"button or key not pressed to generate change?!\\n\");",
643 "\t// what are we editing??",
644 "\tif (null == _this.sourceview.node_selected || _this.sourceview.prop_selected.length < 1) {",
648 "\t// find the colon on the first line...",
650 "\tif (_this.sourceview.editable_start_pos > -1) {",
652 "\t\tvar buf = (GtkSource.Buffer)_this.sourceview.el.get_buffer();",
654 " //print(\"cursor changed : %d\\n\", buf.cursor_position);",
655 " Gtk.TextIter spos,epos;",
656 " buf.get_iter_at_offset(out spos, _this.sourceview.editable_start_pos);",
657 " buf.get_iter_at_offset(out epos, _this.sourceview.editable_start_pos); // initialize epos..",
659 " var gotit= false;",
660 " var line = spos.get_line();",
661 " var endline = buf.get_line_count();",
662 " while (line < endline) {",
664 "\t buf.get_iter_at_line(out epos, line);",
665 "\t if (buf.get_source_marks_at_line(line, \"grey\").length() > 0) {",
666 "\t\t buf.get_iter_at_line(out epos, line);\t \t\t",
667 "\t \t\tgotit=true;",
673 "\t \t\tprint(\"End Offset = %d/%d\\n\", epos.get_line(), epos.get_offset());",
674 "\t\t\t// get the pos...",
675 "\t\t\t// in theory the last char will be '}' or '},' .. or ','",
676 "\t\t\t// we should chop the ',' of the end...",
677 "\t\t\tvar str = buf.get_text(spos, epos, false);",
678 "\t\t\tprint(\"got string\\n%s\\n\", str);",
690 "GLib.debug(\"cursor moved called\");",
693 " \tif (this.in_cursor_change ) {",
694 " GLib.debug(\"cursor changed : %d [ignoring nested call)\", this.el.cursor_position);",
698 " GLib.debug(\"cursor changed : %d\", this.el.cursor_position);",
699 " Gtk.TextIter cpos;",
700 " this.el.get_iter_at_offset(out cpos, this.el.cursor_position);",
702 " var ln = cpos.get_line();",
703 " if (this.last_line == ln ){",
706 "\tthis.last_line = ln;",
707 " var node = _this.file.lineToNode(ln);",
709 " if (node == null) {",
710 " print(\"can not find node\\n\");",
713 " this.in_cursor_change = true;",
714 " var ltree = _this.main_window.windowstate.left_tree;",
715 " ltree.model.selectNode(node);",
716 " this.in_cursor_change = false;",
722 "| string toString" : [
727 " this.el.get_start_iter(out s);",
728 " this.el.get_end_iter(out e);",
729 " var ret = this.el.get_text(s,e,true);",
730 " //print(\"TO STRING? \" + ret);",
738 "* pack" : "add_controller",
741 "(keyval, keycode, state) => {",
745 " \tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
746 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
747 "\t\t_this.forwardSearch(true);",
750 "\tif (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
751 "\t GLib.debug(\"SAVE: ctrl-f pressed\");",
752 "\t\t_this.search_entry.el.grab_focus();",
756 "\t//this.button_is_pressed = true;",
758 " // print(event.key.keyval)",
767 "xtype" : "EventControllerKey"
772 "(x, y, keyboard_tooltip, tooltip) => {",
774 "\t//GLib.debug(\"query tooltip\");",
775 "\tGtk.TextIter iter;",
778 "\tvar yoff = (int) _this.sourceviewscroll.el.vadjustment.value;",
780 "\tthis.el.get_iter_at_position (out iter, out trailing, x, y + yoff);",
782 "\tvar l = iter.get_line();",
783 "\t//GLib.debug(\"query tooltip line %d\", (int) l);",
784 "\tvar marks = _this.buffer.el.get_source_marks_at_line(l, null);",
785 "\t//GLib.debug(\"query tooltip line marks %d\", (int) marks.length());",
787 "\tmarks.@foreach((m) => { ",
788 "\t\t//GLib.debug(\"got mark %s\", m.name);",
789 "\t\tstr += (str.length > 0 ? \"\\n\" : \"\") + m.name;",
791 "\t// true if there is a mark..",
792 "\tif (str.length > 0 ) {",
793 "\t\t\ttooltip.set_text( str);",
795 "\treturn str.length > 0 ? true : false;",
800 "string name" : "roo-view",
802 "| string toString" : [
806 " this.el.get_buffer().get_start_iter(out s);",
807 " this.el.get_buffer().get_end_iter(out e);",
808 " var ret = this.el.get_buffer().get_text(s,e,true);",
809 " //print(\"TO STRING? \" + ret);",
814 "| void clearGreySelection" : [
816 " // clear all the marks..",
817 " var sbuf = (GtkSource.Buffer)this.el.buffer;",
819 " Gtk.TextIter start;",
820 " Gtk.TextIter end; ",
822 " sbuf.get_bounds (out start, out end);",
823 " sbuf.remove_source_marks (start, end, \"grey\");",
829 "| void loadFile" : [
831 " this.loading = true;",
834 " // get the cursor and scroll position....",
835 " var buf = this.el.get_buffer();",
836 "\tvar cpos = buf.cursor_position;",
838 " print(\"BEFORE LOAD cursor = %d\\n\", cpos);",
840 " var vadj_pos = this.el.get_vadjustment().get_value();",
844 " buf.set_text(\"\",0);",
845 " var sbuf = (GtkSource.Buffer) buf;",
849 " if (_this.file == null || _this.file.xtype != \"Roo\") {",
850 " print(\"xtype != Roo\");",
851 " this.loading = false;",
855 " // get the string from the rendered tree...",
857 " var str = _this.file.toSource();",
859 "// print(\"setting str %d\\n\", str.length);",
860 " buf.set_text(str, str.length);",
861 " var lm = GtkSource.LanguageManager.get_default();",
863 " //?? is javascript going to work as js?",
865 " ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language));",
868 " _this.main_window.windowstate.updateErrorMarksAll();",
870 " // restore the cursor position?",
871 " // after reloading the contents.",
872 " GLib.Timeout.add(500, () => {",
873 "\t\t_this.buffer.in_cursor_change = true;",
874 " print(\"RESORTING cursor to = %d\\n\", cpos);",
875 "\t\tGtk.TextIter cpos_iter;",
876 "\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);",
877 "\t\tbuf.place_cursor(cpos_iter); ",
879 "\t\tthis.el.get_vadjustment().set_value(vadj_pos);;",
880 "\t\t_this.buffer.in_cursor_change = false;",
884 "\t\t//_this.buffer.checkSyntax();",
888 " this.loading = false; ",
889 " _this.buffer.dirty = false;",
893 "| void nodeSelected" : [
894 "(JsRender.Node? sel, bool scroll) {",
897 " if (this.loading) {",
900 " // this is connected in widnowstate",
901 " print(\"Roo-view - node selected\\n\");",
902 " var buf = this.el.get_buffer();",
904 " var sbuf = (GtkSource.Buffer) buf;",
909 " // clear all the marks..",
910 " Gtk.TextIter start;",
911 " Gtk.TextIter end; ",
913 " sbuf.get_bounds (out start, out end);",
914 " sbuf.remove_source_marks (start, end, \"grey\");",
916 " this.node_selected = sel;",
917 " if (sel == null) {",
918 " // no highlighting..",
921 " Gtk.TextIter iter; ",
922 " sbuf.get_iter_at_line(out iter, sel.line_start);",
925 " Gtk.TextIter cur_iter;",
926 " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
928 " //var cur_line = cur_iter.get_line();",
929 " //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
932 " if (! _this.buffer.in_cursor_change) {",
933 " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
938 " for (var i = 0; i < buf.get_line_count();i++) {",
939 " if (i < sel.line_start || i > sel.line_end) {",
941 " sbuf.get_iter_at_line(out iter, i);",
942 " sbuf.create_source_mark(null, \"grey\", iter);",
952 "| void updateGreySelection" : [
954 "\tvar sel = this.node_selected;",
955 "\tprint(\"node selected\\n\");",
956 " var buf = this.el.get_buffer();",
957 " var sbuf = (GtkSource.Buffer) buf;",
960 " this.clearGreySelection();",
964 " if (sel == null) {",
965 "\t print(\"no selected node\\n\");",
966 " // no highlighting..",
970 " print(\"highlight region %d to %d\\n\", sel.line_start,sel.line_end);",
971 " Gtk.TextIter iter; ",
972 " sbuf.get_iter_at_line(out iter, sel.line_start);",
975 " Gtk.TextIter cur_iter;",
976 " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
978 " var cursor_at_line = cur_iter.get_line();",
981 " //var cur_line = cur_iter.get_line();",
982 " //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
986 "\t\tprint(\"scrolling to node -- should occur on node picking.\\n\");",
987 " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
990 " var start_line = sel.line_start;",
991 " var end_line = sel.line_end;",
994 " this.el.editable = false;",
996 " //var colon_pos = 0;",
998 " this.editable_start_pos = -1;",
1000 " // now if we have selected a property...",
1001 " if (this.prop_selected.length> 0 ) {",
1003 "\t\tint nstart, nend;",
1004 "\t\tif (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) {",
1005 "\t\t\tstart_line = nstart;",
1006 "\t\t\tend_line = nend;",
1007 "\t\t\t// this.el.editable = true; << cant do this!!?",
1008 "\t\t\tprint(\"start line = %d, end line = %d\\n\", start_line, end_line);",
1010 "\t\t\t\t// see if we are 'right of ':'",
1011 "\t\t\t\t// get an iter for the start of the line.",
1012 "\t\t\tGtk.TextIter start_first_line_iter,end_first_line_iter;",
1013 "\t\t\tthis.el.buffer.get_iter_at_line(out start_first_line_iter, start_line -1);",
1014 "\t\t\tthis.el.buffer.get_iter_at_line(out end_first_line_iter, start_line -1);",
1019 "\t\t\tif (end_first_line_iter.forward_to_line_end()) {",
1020 "\t\t\t\tvar first_line = this.el.buffer.get_text(start_first_line_iter, end_first_line_iter, false);",
1022 "\t\t\t\tprint(\"first line = %s\\n\", first_line);",
1023 "\t\t\t\tif (first_line.contains(\":\")) {",
1024 "\t\t\t\t\tthis.editable_start_pos = start_first_line_iter.get_offset() + first_line.index_of(\":\") + 1;",
1025 "\t\t\t\t\tprint(\"colon_pos = %d\\n\", this.editable_start_pos);",
1029 "\t\t\t\t//Gtk.TextIter colon_iter;",
1030 "\t\t\t\t//sbuf.get_iter_at_offset (out colon_iter, colon_pos);",
1031 "\t\t\t\t//sbuf.create_source_mark(null, \"active_text\", colon_iter);",
1036 "\t\t\t//print(\"is cursor at line? %d ?= %d\\n\", start_line -1 , cursor_at_line);",
1037 "\t\t\t//if (start_line - 1 == cursor_at_line) {",
1038 "\t\t\t// should be ok - current_posssion can not be less than '-1'...",
1039 "\t\t\tif (sbuf.cursor_position < this.editable_start_pos) {",
1041 "\t\t\t\tprint(\"cursor is before start pos.. - turn off editable...\\n\");",
1042 "\t\t\t\t//var before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false);",
1043 "\t\t\t\t//print(\"before cursor string = %s\\n\", before_cursor_string);",
1044 "\t\t\t\t//if (!before_cursor_string.contains(\":\")) {",
1045 "\t\t\t\t\tthis.el.editable = false;",
1054 "\t\tprint(\"propSelected = %s range %d -> %d\\n\", this.prop_selected, start_line, end_line);\t\t",
1059 "\tprint(\"checking selection\\n\");",
1062 " // check selection - if it's out of 'bounds'",
1063 " if (this.el.editable && sbuf.get_has_selection()) {",
1064 "\t\tGtk.TextIter sel_start_iter, sel_end_iter;",
1065 "\t\tsbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter);",
1067 "\t\tif (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line ||",
1068 "\t\t\tsel_start_iter.get_line() > end_line || sel_end_iter.get_line() < start_line\t\t\t) {",
1070 "\t\t\tthis.el.editable = false;",
1072 "\t\tif (this.editable_start_pos > 0 &&",
1073 "\t\t\t(sel_start_iter.get_offset() < this.editable_start_pos || sel_end_iter.get_offset() < this.editable_start_pos)",
1076 "\t\t\tthis.el.editable = false;",
1086 " for (var i = 0; i < buf.get_line_count();i++) {",
1087 " if (i < (start_line -1) || i > (end_line -1)) {",
1089 " sbuf.get_iter_at_line(out iter, i);",
1090 " sbuf.create_source_mark(null, \"grey\", iter);",
1095 " if (scroll && (cursor_at_line > end_line || cursor_at_line < start_line)) {",
1096 "\t Gtk.TextIter cpos_iter;",
1097 "\t\tbuf.get_iter_at_line(out cpos_iter, start_line);",
1099 "\t\tbuf.place_cursor(cpos_iter); ",
1107 "xtype" : "ScrolledWindow"
1111 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
1112 "bool homogeneous" : false,
1113 "bool vexpand" : false,
1119 "this.css = new Gtk.CssProvider();",
1121 "this.css.load_from_string(",
1122 "\t\"#roo-search-entry { background-color: #ccc; }\"",
1125 "Gtk.StyleContext.add_provider_for_display(",
1126 "\tthis.el.get_display(),",
1128 "\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
1135 "Gtk.CssProvider css" : "",
1136 "bool hexpand" : true,
1137 "id" : "search_entry",
1143 "(keyval, keycode, state) => {",
1145 "\tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
1146 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
1147 "\t\t_this.forwardSearch(true);",
1152 " \tif (keyval == Gdk.Key.Return) {",
1153 "\t\t_this.forwardSearch(true);",
1159 " // print(event.key.keyval)",
1166 "xtype" : "EventControllerKey"
1170 "search_changed" : [
1173 "_this.search(_this.search_entry.el.text);",
1174 "\t _this.search_results.updateResults();",
1176 "\tGLib.Timeout.add_seconds(1,() => {",
1177 "\t\t _this.search_results.updateResults();",
1178 "\t\t return false;",
1184 "string name" : "roo-search-entry",
1185 "string placeholder_text" : "Press enter to search",
1186 "xtype" : "SearchEntry",
1187 "| void forwardSearch" : [
1188 "(bool change_focus) {",
1191 "\t_this.forwardSearch(change_focus);",
1195 "\tswitch(_this.windowstate.state) {",
1196 "\t\tcase WindowState.State.CODEONLY:",
1197 "\t\t//case WindowState.State.CODE:",
1198 "\t\t\t// search the code being edited..",
1199 "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
1202 "\t\tcase WindowState.State.PREVIEW:",
1203 "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
1204 "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
1206 "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
1219 "id" : "search_results",
1220 "int margin_end" : 4,
1221 "int margin_start" : 4,
1222 "string label" : "No Results",
1224 "| void updateResults" : [
1226 "\tthis.el.visible = true;",
1228 "\tvar res = _this.searchcontext.get_occurrences_count();",
1230 "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
1234 "\t_this.nextBtn.el.sensitive = false;",
1235 "\t_this.backBtn.el.sensitive = false;\t",
1238 "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
1239 "\t\t_this.nextBtn.el.sensitive = true;",
1240 "\t\t_this.backBtn.el.sensitive = true;",
1243 "\t_this.search_results.el.label = \"No Matches\";",
1250 "bool always_show_image" : true,
1251 "bool sensitive" : false,
1257 "\t_this.forwardSearch(true);",
1263 "string icon_name" : "go-down",
1268 "bool always_show_image" : true,
1269 "bool sensitive" : false,
1275 "\t_this.backSearch(true);",
1282 "string icon_name" : "go-up",
1287 "bool always_show_image" : true,
1292 "* prop" : "popover",
1293 "id" : "search_settings",
1298 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1305 "\tthis.el.show();",
1309 "id" : "case_sensitive",
1310 "string label" : "Case Sensitive",
1311 "xtype" : "CheckButton"
1317 "\tthis.el.show();",
1322 "string label" : "Regex",
1323 "xtype" : "CheckButton"
1329 "\tthis.el.show();",
1334 "string label" : "Multi-line (add \\n)",
1335 "xtype" : "CheckButton"
1344 "string icon_name" : "emblem-system",
1345 "xtype" : "MenuButton"
1354 "xtype" : "Notebook"
1359 "(string in_txt) {",
1360 "\tthis.notebook.el.page = 1;",
1364 "\tvar s = new GtkSource.SearchSettings();",
1365 "\ts.case_sensitive = _this.case_sensitive.el.active;",
1366 "\ts.regex_enabled = _this.regex.el.active;\t",
1367 "\ts.wrap_around = false;",
1369 "\tthis.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);",
1370 "\tthis.searchcontext.set_highlight(true);",
1371 "\tvar txt = in_txt;",
1373 "\tif (_this.multiline.el.active) {",
1374 "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
1377 "\ts.set_search_text(txt);",
1378 "\tGtk.TextIter beg, st,en;",
1379 "\tbool has_wrapped_around;",
1380 "\tthis.buffer.el.get_start_iter(out beg);",
1381 "\tthis.searchcontext.forward(beg, out st, out en, out has_wrapped_around);",
1382 "\tthis.last_search_end = 0;",
1384 "\treturn this.searchcontext.get_occurrences_count();",
1392 "| void backSearch" : [
1393 "(bool change_focus) {",
1395 "\tif (this.searchcontext == null) {",
1399 "\tGtk.TextIter beg, st,en;",
1400 "\tbool has_wrapped_around;",
1401 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
1403 "\tif (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {",
1405 "\t\tthis.last_search_end = 0;",
1408 "\tthis.last_search_end = en.get_offset();",
1409 "\tif (change_focus) {",
1410 "\t\tthis.sourceview.el.grab_focus();",
1412 "\tthis.buffer.el.place_cursor(st);",
1413 "\tthis.sourceview.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
1414 "\tvar ln = st.get_line();",
1415 "\tthis.highlightNodeAtLine(ln);",
1421 "| void createThumb" : [
1425 " if (this.file == null) {",
1429 "\tif (this.notebook.el.page > 0 ) {",
1433 " \tthis.file.widgetToIcon(this.view.el); ",
1442 "| void forwardSearch" : [
1443 "(bool change_focus) {",
1445 "\tif (this.searchcontext == null) {",
1448 "\tthis.notebook.el.page = 1;",
1449 "\tGtk.TextIter beg, st,en;",
1450 "\tbool has_wrapped_around;",
1451 "\tvar buf = this.sourceview.el.get_buffer();",
1452 "\tbuf.get_iter_at_offset(out beg, this.last_search_end);",
1453 "\tif (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {",
1454 "\t\tthis.last_search_end = 0;",
1457 "\tthis.last_search_end = en.get_offset();",
1458 "\tif (change_focus) {",
1459 "\t\tthis.sourceview.el.grab_focus();",
1461 "\tbuf.place_cursor(st);",
1465 "\tthis.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f);",
1468 "\tvar ln = st.get_line();",
1470 "\tthis.highlightNodeAtLine(ln);",
1474 "| void highlightNodeAtLine" : [
1479 "\t// highlight node...",
1482 " var node = _this.file.lineToNode(ln+1);",
1484 " if (node == null) {",
1485 " //print(\"can not find node\\n\");",
1488 " var prop = node.lineToProp(ln+1);",
1489 " print(\"prop : %s\", prop == null ? \"???\" : prop.name);",
1492 " // ---------- this selects the tree's node...",
1494 " var ltree = _this.main_window.windowstate.left_tree;",
1495 " ltree.model.selectNode(node);",
1497 " //_this.sourceview.allow_node_scroll = false; /// block node scrolling..",
1500 " //print(\"changing cursor on tree..\\n\");",
1504 " // let's try allowing editing on the methods.",
1505 " // a little klunky at present..",
1506 "\t_this.sourceview.prop_selected = \"\";",
1508 " if (prop != null) {",
1509 "\t\t//see if we can find it..",
1510 "\t\tvar kv = prop.split(\":\");",
1511 "\t\tif (kv[0] == \"p\") {",
1513 " \t\t//var k = prop.get_key(kv[1]);",
1514 " \t\t// fixme -- need to determine if it's an editable property...",
1515 " \t\t_this.sourceview.prop_selected = prop;",
1517 "\t\t} else if (kv[0] == \"l\") {",
1518 "\t\t\t _this.sourceview.prop_selected = prop;",
1523 " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
1524 " _this.sourceview.nodeSelected(node,false);",
1526 " // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
1527 " // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
1528 "\t // this.allow_node_scroll = true;",
1529 "\t // return false;",
1546 "| void loadFile" : [
1548 "(JsRender.JsRender file)",
1550 " this.file = file;",
1551 " this.view.renderJS(true);",
1552 " this.notebook.el.page = 0;// gtk preview ",
1553 " this.sourceview.loadFile(); ",
1554 " this.last_error_counter = -1;",
1555 " this.updateErrorMarks();",
1560 "| void requestRedraw" : [
1562 " this.view.renderJS(false);",
1563 " this.sourceview.loadFile(); ",
1566 "| void scroll_to_line" : [
1568 " // code preview...",
1570 " GLib.Timeout.add(100, () => {",
1572 "\t\tthis.notebook.el.set_current_page( 1 );",
1575 "\t\t var buf = this.sourceview.el.get_buffer();",
1577 "\t\tvar sbuf = (GtkSource.Buffer) buf;",
1580 "\t\tGtk.TextIter iter; ",
1581 "\t\tsbuf.get_iter_at_line(out iter, line);",
1582 "\t\tthis.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
1583 "\t\treturn false;",
1590 "| void updateErrorMarks" : [
1595 "\tvar buf = _this.buffer.el;",
1596 "\tGtk.TextIter start;",
1597 "\tGtk.TextIter end; ",
1598 "\tbuf.get_bounds (out start, out end);",
1602 "\tGLib.debug(\"highlight errors\");\t\t ",
1604 "\t // we should highlight other types of errors..",
1609 "\tif (_this.file == null) {",
1610 "\t\tGLib.debug(\"file is null?\");",
1614 "\tvar ar = this.file.getErrors();",
1615 "\tif (ar.size < 1) {",
1616 "\t\tbuf.remove_tag_by_name (\"ERR\", start, end);",
1617 "\t\tbuf.remove_tag_by_name (\"WARN\", start, end);",
1618 "\t\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
1619 "\t\tbuf.remove_source_marks (start, end, null);",
1620 "\t\tthis.last_error_counter = file.error_counter ;",
1621 "\t\tGLib.debug(\"higjlight has no errors\");",
1624 " \tif (this.last_error_counter == file.error_counter) {",
1628 "\tvar tlines = buf.get_line_count () +1;",
1632 "\tbuf.remove_source_marks (start, end, null);",
1633 "\tbuf.remove_tag_by_name (\"ERR\", start, end);",
1634 "\tbuf.remove_tag_by_name (\"WARN\", start, end);",
1635 "\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
1636 "\tforeach(var diag in ar) { ",
1639 "\t Gtk.TextIter iter;",
1640 "// print(\"get inter\\n\");",
1641 "\t var eline = (int)diag.range.start.line ;",
1642 "\t var eline_to = (int)diag.range.end.line;",
1643 "\t if (eline > tlines || eline < 0) {",
1648 "\t buf.get_iter_at_line( out iter, eline);",
1650 "\t \t buf.get_iter_at_line_offset( out start, ",
1651 " \t \teline, (int)diag.range.start.character); ",
1652 " \t buf.get_iter_at_line_offset( out end, ",
1653 " \t \teline_to, (int)diag.range.end.character); ",
1655 "\t buf.apply_tag_by_name(diag.category, start, end);",
1658 "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, diag.category, diag.message);",
1659 "\t buf.create_source_mark( msg, diag.category, iter);",
1660 "\t GLib.debug(\"set line %d to %s\", eline, msg);",
1661 "\t //this.marks.set(eline, msg);",
1663 "\tthis.last_error_counter = file.error_counter ;",
1673 "name" : "WindowRooView"