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();",
195 "\tif (this.el == null) {",
199 "\tvar msg = dialog.get_message();",
200 "\tif (msg.length < 4) {",
204 "\t //GLib.debug(\"script dialog got %s\", msg);",
206 "\tif (msg.substring(0,4) != \"IPC:\") {",
209 "\tvar ar = msg.split(\":\", 3);",
210 "\tif (ar.length < 3) {",
216 "\t\tcase \"SAVEHTML\":",
217 "\t\t // GLib.debug(\"GOT saveHTML %d\", ar[2].length);",
218 "\t\t _this.file.saveHTML(ar[2]);",
219 "\t\t _this.createThumb();",
223 "\t\t return false;",
230 "| void initInspector" : [
235 " // this.inspector.open_window.connect(() => {",
236 " this.inspector = this.el.get_inspector();",
238 " this.inspector.open_window.connect(() => {",
239 " print(\"inspector attach\\n\");",
240 " var wv = this.inspector.get_web_view();",
241 " if (wv != null) {",
242 " print(\"got inspector web view\\n\");",
244 " var cn = _this.inspectorcontainer.el.get_first_child();",
245 " if (cn != null) {",
246 " _this.inspectorcontainer.el.remove(cn);",
249 " _this.inspectorcontainer.el.append(wv);",
252 "\t print(\"got inspector web view FAILED\\n\");",
253 " //this.inspector.close();",
255 " //this.inspector = null;",
262 " this.inspector.show();",
271 " print(\"reInit?\");",
272 " // if this happens destroy the webkit..",
274 " this.el.stop_loading();",
276 " if (_this.viewbox.el.get_parent() == null) {",
281 " _this.viewbox.el.remove(_this.viewcontainer.el);",
282 " //_this.paned.el.remove(_this.inspectorcontainer.el); ",
284 " // destory seems to cause problems.",
285 " //this.el.destroy();",
286 " //_this.viewcontainer.el.destroy();",
287 " //_this.inspectorcontainer.el.destroy();",
288 " var inv =new Xcls_inspectorcontainer(_this);",
290 " _this.paned.el.set_end_child(inv.el);",
291 " _this.inspectorcontainer = inv;",
294 " var nv =new Xcls_viewcontainer(_this);",
296 " _this.viewbox.el.append(nv.el);",
298 " _this.viewcontainer = nv;",
301 " //while(Gtk.events_pending ()) Gtk.main_iteration ();",
302 " //_this.view.renderJS(true); ",
303 " _this.view.refreshRequired = true;",
309 "| void renderJS" : [
312 " // this is the public redraw call..",
313 " // we refresh in a loop privately..",
314 " var autodraw = _this.AutoRedraw.el.active;",
315 " if (!autodraw && !force) {",
316 " print(\"Skipping redraw - no force, and autodraw off\");",
320 " this.refreshRequired = true;",
325 "| void runRefresh" : [
328 " // this is run every 2 seconds from the init..",
331 " if (!this.refreshRequired) {",
332 " // print(\"no refresh required\");",
336 " if (this.lastRedraw != null) {",
337 " // do not redraw if last redraw was less that 5 seconds ago.",
338 " if ((int64)(new DateTime.now_local()).difference(this.lastRedraw) < 5000 ) {",
343 " if (_this.file == null) {",
348 " this.refreshRequired = false;",
349 " // print(\"HTML RENDERING\");",
352 " //this.get('/BottomPane').el.show();",
353 " //this.get('/BottomPane').el.set_current_page(2);// webkit inspector",
354 " _this.file.webkit_page_id = this.el.get_page_id();",
356 " var js = _this.file.toSourcePreview();",
358 " if (js.length < 1) {",
359 " print(\"no data\");",
362 "// var data = js[0];",
365 " var project = (Project.Roo) _this.file.project; ",
367 " //print (project.fn);",
368 " // set it to non-empty.",
370 "// runhtml = runhtml.length ? runhtml : '<script type=\"text/javascript\"></script>'; ",
373 "// this.runhtml = this.runhtml || '';",
376 " // then we need to reload the browser using",
377 " // load_html_string..",
379 " // then trigger a redraw once it's loaded..",
380 " this.pendingRedraw = true;",
382 " var runhtml = \"<script type=\\\"text/javascript\\\">\\n\" ;",
383 " uint8[] builderhtml;",
386 " GLib. File.new_for_uri(\"resource:///html/roo.builder.js\").load_contents(null, out builderhtml, null);",
387 " } catch (Error e) {",
388 " builderhtml = {};",
391 " runhtml += (string) builderhtml + \"\\n\";",
392 " runhtml += \"</script>\\n\" ;",
394 " // fix to make sure they are the same..",
395 " this.runhtml = project.runhtml;",
396 " // need to modify paths",
399 " var base_template = project.base_template;",
400 " var f = GLib. File.new_for_uri(\"resource:///html/\" + base_template);",
402 " if (base_template.length > 0 && !f.query_exists(null)) {",
404 " GLib.debug(\"invalid base_template name - using default: %s\", base_template);",
405 " f = GLib. File.new_for_uri(\"resource:///html/roo.builder.html\");",
409 "\t f.load_contents(null, out inhtml, null);",
412 " } catch (Error e) {",
415 " this.renderedData = js;",
418 " string js_src = js + \"",
419 "Roo.onReady(function() {",
420 "if (\" + _this.file.name +\".show) {",
421 "\t\t\" + _this.file.name +\".show({});",
422 "\t\t(function() { ",
423 "\t\t\tBuilder.saveHTML.defer(100, Builder);",
424 "\t\t}).defer(100);",
426 "Roo.XComponent.build();",
429 " // print(\"render js: \" + js);",
430 " //if (!this.ready) {",
431 " // console.log('not loaded yet');",
433 " this.lastRedraw = new DateTime.now_local();",
436 " //this.runjs = js_src;",
437 " var fc = FakeServerCache.factory_with_data(js_src);",
438 " this.runjs = fc.fname;",
439 " var html = (string) inhtml;",
440 "\thtml = html.replace(\"</head>\", runhtml + this.runhtml + ",
441 " \"<script type=\\\"text/javascript\\\" src=\\\"xhttp://localhost\" + fc.fname + \"\\\"></script>\" + ",
442 " // \"<script type=\\\"text/javascript\\\">\\n\" +",
443 " // js_src + \"\\n\" + ",
444 " // \"</script>\" + ",
447 " //print(\"LOAD HTML \" + html);",
449 " var rootURL = project.rootURL;",
453 " this.el.load_html( html , ",
454 " //fixme - should be a config option!",
455 " (rootURL.length > 0 ? rootURL : \"xhttp://localhost/roobuilder/\")",
457 " this.initInspector(); ",
458 " // force the inspector... ",
459 " // this.initInspector();",
461 " // - no need for this, the builder javascript will call it when build is complete",
462 " //GLib.Timeout.add_seconds(1, () => {",
463 " // this.el.run_javascript(\"Builder.saveHTML()\",null);",
466 "// print( \"before render\" + this.lastRedraw);",
467 "// print( \"after render\" + (new Date()));",
478 "* pack" : "set_end_child",
479 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
480 "bool vexpand" : true,
481 "id" : "inspectorcontainer",
489 "* pack" : "append_page,_this.label_code.el",
490 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
491 "bool vexpand" : true,
496 "bool vexpand" : true,
497 "id" : "sourceviewscroll",
500 "# Gtk.CssProvider? css" : "null",
501 "# JsRender.Node? node_selected" : "null",
502 "# bool button_is_pressed" : false,
503 "# bool key_is_pressed" : false,
504 "# bool loading" : true,
505 "# id" : "sourceview",
506 "# int editable_start_pos" : "-1",
507 "# string prop_selected" : "\"\"",
508 "$ xns" : "GtkSource",
514 "\tthis.loading = true;",
515 "\t//var buf = this.el.get_buffer();",
516 "\t//buf.notify.connect(this.onCursorChanged);",
519 "\tvar attrs = new GtkSource.MarkAttributes();",
520 "\tattrs.set_icon_name ( \"process-stop\"); ",
521 "\tattrs.query_tooltip_text.connect(( mark) => {",
522 "\t\t//print(\"tooltip query? %s\\n\", mark.name);",
523 "\t\treturn mark.name;",
526 "\tthis.el.set_mark_attributes (\"ERR\", attrs, 1);",
528 "\t var wattrs = new GtkSource.MarkAttributes();",
529 "\twattrs.set_icon_name ( \"process-stop\"); ",
530 "\twattrs.query_tooltip_text.connect(( mark) => {",
531 "\t\t//print(\"tooltip query? %s\\n\", mark.name);",
532 "\t\treturn mark.name;",
535 "\tthis.el.set_mark_attributes (\"WARN\", wattrs, 1);",
539 "\t var dattrs = new GtkSource.MarkAttributes();",
540 "\tdattrs.set_icon_name ( \"process-stop\"); ",
541 "\tdattrs.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 (\"DEPR\", dattrs, 1);",
549 "\tvar gattrs = new GtkSource.MarkAttributes();",
550 "\tvar grey = Gdk.RGBA();",
551 "\tgrey.parse ( \"#ccc\");",
552 "\tgattrs.set_background ( grey);",
555 "\tthis.el.set_mark_attributes (\"grey\", gattrs, 1);",
564 "* pack" : "set_child",
565 "bool editable" : false,
566 "bool show_line_marks" : true,
567 "bool show_line_numbers" : true,
568 "css_classes" : "{ \"code-editor\" }",
571 "$ xns" : "GtkSource",
574 "\tvar buf = this.el;",
575 "\tbuf.create_tag (\"bold\", \"weight\", Pango.Weight.BOLD);",
576 "\tbuf.create_tag (\"type\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#204a87\");",
577 "\tbuf.create_tag (\"keyword\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#a40000\");",
578 "\tbuf.create_tag (\"text\", \"weight\", Pango.Weight.NORMAL, \"foreground\", \"#729fcf\");",
579 "\tbuf.create_tag (\"number\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#ad7fa8\");",
580 "\tbuf.create_tag (\"method\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#729fcf\");",
581 "\tbuf.create_tag (\"property\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#BC1F51\");",
582 "\tbuf.create_tag (\"variable\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#A518B5\");",
585 "\tbuf.create_tag (\"ERR\", \"weight\", Pango.Weight.BOLD, \"background\", \"pink\");",
586 "\tbuf.create_tag (\"WARN\", \"weight\", Pango.Weight.BOLD, \"background\", \"#ABF4EB\");",
587 "\tbuf.create_tag (\"DEPR\", \"weight\", Pango.Weight.BOLD, \"background\", \"#EEA9FF\");",
592 "* pack" : "set_buffer",
593 "bool dirty" : false,
594 "bool in_cursor_change" : false,
596 "int error_line" : "-1",
597 "int last_line" : "-1",
602 " // check syntax??",
604 " // _this.save_button.el.sensitive = true;",
605 " ///?? has changed occured during loading?",
607 " // only trigger this if ",
612 " if (_this.sourceview.loading) {",
618 " print(\"- PREVIEW EDITOR CHANGED--\");",
620 " this.dirty = true; ",
621 " // this.checkSyntax(); // this calls backs and highlights errors.. in theory... ",
625 "\tif (!_this.sourceview.button_is_pressed && !_this.sourceview.key_is_pressed) {",
626 "\t\tprint(\"button or key not pressed to generate change?!\\n\");",
631 "\t// what are we editing??",
632 "\tif (null == _this.sourceview.node_selected || _this.sourceview.prop_selected.length < 1) {",
636 "\t// find the colon on the first line...",
638 "\tif (_this.sourceview.editable_start_pos > -1) {",
640 "\t\tvar buf = (GtkSource.Buffer)_this.sourceview.el.get_buffer();",
642 " //print(\"cursor changed : %d\\n\", buf.cursor_position);",
643 " Gtk.TextIter spos,epos;",
644 " buf.get_iter_at_offset(out spos, _this.sourceview.editable_start_pos);",
645 " buf.get_iter_at_offset(out epos, _this.sourceview.editable_start_pos); // initialize epos..",
647 " var gotit= false;",
648 " var line = spos.get_line();",
649 " var endline = buf.get_line_count();",
650 " while (line < endline) {",
652 "\t buf.get_iter_at_line(out epos, line);",
653 "\t if (buf.get_source_marks_at_line(line, \"grey\").length() > 0) {",
654 "\t\t buf.get_iter_at_line(out epos, line);\t \t\t",
655 "\t \t\tgotit=true;",
661 "\t \t\tprint(\"End Offset = %d/%d\\n\", epos.get_line(), epos.get_offset());",
662 "\t\t\t// get the pos...",
663 "\t\t\t// in theory the last char will be '}' or '},' .. or ','",
664 "\t\t\t// we should chop the ',' of the end...",
665 "\t\t\tvar str = buf.get_text(spos, epos, false);",
666 "\t\t\tprint(\"got string\\n%s\\n\", str);",
678 "GLib.debug(\"cursor moved called\");",
681 " \tif (this.in_cursor_change ) {",
682 " GLib.debug(\"cursor changed : %d [ignoring nested call)\", this.el.cursor_position);",
686 " GLib.debug(\"cursor changed : %d\", this.el.cursor_position);",
687 " Gtk.TextIter cpos;",
688 " this.el.get_iter_at_offset(out cpos, this.el.cursor_position);",
690 " var ln = cpos.get_line();",
691 " if (this.last_line == ln ){",
694 "\tthis.last_line = ln;",
695 " var node = _this.file.lineToNode(ln);",
697 " if (node == null) {",
698 " print(\"can not find node\\n\");",
701 " this.in_cursor_change = true;",
702 " var ltree = _this.main_window.windowstate.left_tree;",
703 " ltree.model.selectNode(node);",
704 " this.in_cursor_change = false;",
710 "| string toString" : [
715 " this.el.get_start_iter(out s);",
716 " this.el.get_end_iter(out e);",
717 " var ret = this.el.get_text(s,e,true);",
718 " //print(\"TO STRING? \" + ret);",
725 "# bool is_control" : false,
727 "* pack" : "add_controller",
731 "(keyval, keycode, state) => {",
733 " \tif (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
734 " \t\tthis.is_control = true;",
737 " \tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
738 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
739 "\t\t_this.forwardSearch(true);",
742 "\tif (keyval == Gdk.Key.f && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
743 "\t GLib.debug(\"SAVE: ctrl-f pressed\");",
744 "\t\t_this.search_entry.el.grab_focus();",
748 "\t//this.button_is_pressed = true;",
750 " // print(event.key.keyval)",
759 "(keyval, keycode, state) => {",
762 " \t if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
763 " \t\tthis.is_control = false;",
769 "xtype" : "EventControllerKey"
772 "# double distance" : "0.0f",
774 "Gtk.EventControllerScrollFlags flags" : "Gtk.EventControllerScrollFlags.VERTICAL",
778 "\tif (!_this.keystate.is_control) {",
781 "\t//GLib.debug(\"scroll %f\", dy);",
783 "\tthis.distance += dy;",
784 "\t if (this.distance < -1) {",
786 "\t\tBuilderApplication.settings.editor_font_size ++;",
787 "\t\tthis.distance = 0;",
789 "\tif (this.distance > 1) {",
790 "\t\tBuilderApplication.settings.editor_font_size --;",
791 "\t\tthis.distance = 0;",
799 "xtype" : "EventControllerScroll"
804 "(x, y, keyboard_tooltip, tooltip) => {",
806 "\t//GLib.debug(\"query tooltip\");",
807 "\tGtk.TextIter iter;",
810 "\tvar yoff = (int) _this.sourceviewscroll.el.vadjustment.value;",
812 "\tthis.el.get_iter_at_position (out iter, out trailing, x, y + yoff);",
814 "\tvar l = iter.get_line();",
815 "\t//GLib.debug(\"query tooltip line %d\", (int) l);",
816 "\tvar marks = _this.buffer.el.get_source_marks_at_line(l, null);",
817 "\t//GLib.debug(\"query tooltip line marks %d\", (int) marks.length());",
819 "\tmarks.@foreach((m) => { ",
820 "\t\t//GLib.debug(\"got mark %s\", m.name);",
821 "\t\tstr += (str.length > 0 ? \"\\n\" : \"\") + m.name;",
823 "\t// true if there is a mark..",
824 "\tif (str.length > 0 ) {",
825 "\t\t\ttooltip.set_text( str);",
827 "\treturn str.length > 0 ? true : false;",
832 "string name" : "roo-view",
834 "| string toString" : [
838 " this.el.get_buffer().get_start_iter(out s);",
839 " this.el.get_buffer().get_end_iter(out e);",
840 " var ret = this.el.get_buffer().get_text(s,e,true);",
841 " //print(\"TO STRING? \" + ret);",
846 "| void clearGreySelection" : [
848 " // clear all the marks..",
849 " var sbuf = (GtkSource.Buffer)this.el.buffer;",
851 " Gtk.TextIter start;",
852 " Gtk.TextIter end; ",
854 " sbuf.get_bounds (out start, out end);",
855 " sbuf.remove_source_marks (start, end, \"grey\");",
861 "| void loadFile" : [
863 " this.loading = true;",
866 " // get the cursor and scroll position....",
867 " var buf = this.el.get_buffer();",
868 "\tvar cpos = buf.cursor_position;",
870 " print(\"BEFORE LOAD cursor = %d\\n\", cpos);",
872 " var vadj_pos = this.el.get_vadjustment().get_value();",
876 " buf.set_text(\"\",0);",
881 " if (_this.file == null || _this.file.xtype != \"Roo\") {",
882 " print(\"xtype != Roo\");",
883 " this.loading = false;",
887 " // get the string from the rendered tree...",
889 " var str = _this.file.toSource();",
891 "// print(\"setting str %d\\n\", str.length);",
892 " buf.set_text(str, str.length);",
893 " var lm = GtkSource.LanguageManager.get_default();",
895 " //?? is javascript going to work as js?",
897 " ((GtkSource.Buffer)(buf)) .set_language(lm.get_language(_this.file.language));",
900 " _this.main_window.windowstate.updateErrorMarksAll();",
902 " // restore the cursor position?",
903 " // after reloading the contents.",
904 " GLib.Timeout.add(500, () => {",
905 "\t\t_this.buffer.in_cursor_change = true;",
906 " print(\"RESORTING cursor to = %d\\n\", cpos);",
907 "\t\tGtk.TextIter cpos_iter;",
908 "\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);",
909 "\t\tbuf.place_cursor(cpos_iter); ",
911 "\t\tthis.el.get_vadjustment().set_value(vadj_pos);;",
912 "\t\t_this.buffer.in_cursor_change = false;",
916 "\t\t//_this.buffer.checkSyntax();",
920 " this.loading = false; ",
921 " _this.buffer.dirty = false;",
925 "| void nodeSelected" : [
926 "(JsRender.Node? sel, bool scroll) {",
929 " if (this.loading) {",
932 " // this is connected in widnowstate",
933 " print(\"Roo-view - node selected\\n\");",
934 " var buf = this.el.get_buffer();",
936 " var sbuf = (GtkSource.Buffer) buf;",
941 " // clear all the marks..",
942 " Gtk.TextIter start;",
943 " Gtk.TextIter end; ",
945 " sbuf.get_bounds (out start, out end);",
946 " sbuf.remove_source_marks (start, end, \"grey\");",
948 " this.node_selected = sel;",
949 " if (sel == null) {",
950 " // no highlighting..",
953 " Gtk.TextIter iter; ",
954 " sbuf.get_iter_at_line(out iter, sel.line_start);",
957 " Gtk.TextIter cur_iter;",
958 " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
960 " //var cur_line = cur_iter.get_line();",
961 " //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
964 " if (! _this.buffer.in_cursor_change) {",
965 " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
970 " for (var i = 0; i < buf.get_line_count();i++) {",
971 " if (i < sel.line_start || i > sel.line_end) {",
973 " sbuf.get_iter_at_line(out iter, i);",
974 " sbuf.create_source_mark(null, \"grey\", iter);",
984 "| void updateGreySelection" : [
986 "\tvar sel = this.node_selected;",
987 "\tprint(\"node selected\\n\");",
988 " var buf = this.el.get_buffer();",
989 " var sbuf = (GtkSource.Buffer) buf;",
992 " this.clearGreySelection();",
996 " if (sel == null) {",
997 "\t print(\"no selected node\\n\");",
998 " // no highlighting..",
1002 " print(\"highlight region %d to %d\\n\", sel.line_start,sel.line_end);",
1003 " Gtk.TextIter iter; ",
1004 " sbuf.get_iter_at_line(out iter, sel.line_start);",
1007 " Gtk.TextIter cur_iter;",
1008 " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
1010 " var cursor_at_line = cur_iter.get_line();",
1013 " //var cur_line = cur_iter.get_line();",
1014 " //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
1018 "\t\tprint(\"scrolling to node -- should occur on node picking.\\n\");",
1019 " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
1022 " var start_line = sel.line_start;",
1023 " var end_line = sel.line_end;",
1026 " this.el.editable = false;",
1028 " //var colon_pos = 0;",
1030 " this.editable_start_pos = -1;",
1032 " // now if we have selected a property...",
1033 " if (this.prop_selected.length> 0 ) {",
1035 "\t\tint nstart, nend;",
1036 "\t\tif (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) {",
1037 "\t\t\tstart_line = nstart;",
1038 "\t\t\tend_line = nend;",
1039 "\t\t\t// this.el.editable = true; << cant do this!!?",
1040 "\t\t\tprint(\"start line = %d, end line = %d\\n\", start_line, end_line);",
1042 "\t\t\t\t// see if we are 'right of ':'",
1043 "\t\t\t\t// get an iter for the start of the line.",
1044 "\t\t\tGtk.TextIter start_first_line_iter,end_first_line_iter;",
1045 "\t\t\tthis.el.buffer.get_iter_at_line(out start_first_line_iter, start_line -1);",
1046 "\t\t\tthis.el.buffer.get_iter_at_line(out end_first_line_iter, start_line -1);",
1051 "\t\t\tif (end_first_line_iter.forward_to_line_end()) {",
1052 "\t\t\t\tvar first_line = this.el.buffer.get_text(start_first_line_iter, end_first_line_iter, false);",
1054 "\t\t\t\tprint(\"first line = %s\\n\", first_line);",
1055 "\t\t\t\tif (first_line.contains(\":\")) {",
1056 "\t\t\t\t\tthis.editable_start_pos = start_first_line_iter.get_offset() + first_line.index_of(\":\") + 1;",
1057 "\t\t\t\t\tprint(\"colon_pos = %d\\n\", this.editable_start_pos);",
1061 "\t\t\t\t//Gtk.TextIter colon_iter;",
1062 "\t\t\t\t//sbuf.get_iter_at_offset (out colon_iter, colon_pos);",
1063 "\t\t\t\t//sbuf.create_source_mark(null, \"active_text\", colon_iter);",
1068 "\t\t\t//print(\"is cursor at line? %d ?= %d\\n\", start_line -1 , cursor_at_line);",
1069 "\t\t\t//if (start_line - 1 == cursor_at_line) {",
1070 "\t\t\t// should be ok - current_posssion can not be less than '-1'...",
1071 "\t\t\tif (sbuf.cursor_position < this.editable_start_pos) {",
1073 "\t\t\t\tprint(\"cursor is before start pos.. - turn off editable...\\n\");",
1074 "\t\t\t\t//var before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false);",
1075 "\t\t\t\t//print(\"before cursor string = %s\\n\", before_cursor_string);",
1076 "\t\t\t\t//if (!before_cursor_string.contains(\":\")) {",
1077 "\t\t\t\t\tthis.el.editable = false;",
1086 "\t\tprint(\"propSelected = %s range %d -> %d\\n\", this.prop_selected, start_line, end_line);\t\t",
1091 "\tprint(\"checking selection\\n\");",
1094 " // check selection - if it's out of 'bounds'",
1095 " if (this.el.editable && sbuf.get_has_selection()) {",
1096 "\t\tGtk.TextIter sel_start_iter, sel_end_iter;",
1097 "\t\tsbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter);",
1099 "\t\tif (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line ||",
1100 "\t\t\tsel_start_iter.get_line() > end_line || sel_end_iter.get_line() < start_line\t\t\t) {",
1102 "\t\t\tthis.el.editable = false;",
1104 "\t\tif (this.editable_start_pos > 0 &&",
1105 "\t\t\t(sel_start_iter.get_offset() < this.editable_start_pos || sel_end_iter.get_offset() < this.editable_start_pos)",
1108 "\t\t\tthis.el.editable = false;",
1118 " for (var i = 0; i < buf.get_line_count();i++) {",
1119 " if (i < (start_line -1) || i > (end_line -1)) {",
1121 " sbuf.get_iter_at_line(out iter, i);",
1122 " sbuf.create_source_mark(null, \"grey\", iter);",
1127 " if (scroll && (cursor_at_line > end_line || cursor_at_line < start_line)) {",
1128 "\t Gtk.TextIter cpos_iter;",
1129 "\t\tbuf.get_iter_at_line(out cpos_iter, start_line);",
1131 "\t\tbuf.place_cursor(cpos_iter); ",
1139 "xtype" : "ScrolledWindow"
1143 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
1144 "bool homogeneous" : false,
1145 "bool vexpand" : false,
1150 "bool hexpand" : true,
1151 "id" : "search_entry",
1157 "(keyval, keycode, state) => {",
1159 "\tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
1160 "\t GLib.debug(\"SAVE: ctrl-g pressed\");",
1161 "\t\t_this.forwardSearch(true);",
1166 " \tif (keyval == Gdk.Key.Return) {",
1167 "\t\t_this.forwardSearch(true);",
1173 " // print(event.key.keyval)",
1180 "xtype" : "EventControllerKey"
1184 "search_changed" : [
1187 "_this.search(_this.search_entry.el.text);",
1188 "\t _this.search_results.updateResults();",
1190 "\tGLib.Timeout.add_seconds(1,() => {",
1191 "\t\t _this.search_results.updateResults();",
1192 "\t\t return false;",
1198 "string name" : "roo-search-entry",
1199 "string placeholder_text" : "Press enter to search",
1200 "xtype" : "SearchEntry",
1201 "| void forwardSearch" : [
1202 "(bool change_focus) {",
1205 "\t_this.forwardSearch(change_focus);",
1209 "\tswitch(_this.windowstate.state) {",
1210 "\t\tcase WindowState.State.CODEONLY:",
1211 "\t\t//case WindowState.State.CODE:",
1212 "\t\t\t// search the code being edited..",
1213 "\t\t\t_this.windowstate.code_editor_tab.forwardSearch(change_focus);",
1216 "\t\tcase WindowState.State.PREVIEW:",
1217 "\t\t\tif (_this.windowstate.file.xtype == \"Gtk\") {",
1218 "\t\t\t\t_this.windowstate.window_gladeview.forwardSearch(change_focus);",
1220 "\t\t\t\t _this.windowstate.window_rooview.forwardSearch(change_focus);",
1233 "id" : "search_results",
1234 "int margin_end" : 4,
1235 "int margin_start" : 4,
1236 "string label" : "No Results",
1238 "| void updateResults" : [
1240 "\tthis.el.visible = true;",
1242 "\tvar res = _this.searchcontext.get_occurrences_count();",
1244 "\t\t_this.search_results.el.label = \"??? Matches\";\t\t",
1248 "\t_this.nextBtn.el.sensitive = false;",
1249 "\t_this.backBtn.el.sensitive = false;\t",
1252 "\t\t_this.search_results.el.label = \"%d Matches\".printf(res);",
1253 "\t\t_this.nextBtn.el.sensitive = true;",
1254 "\t\t_this.backBtn.el.sensitive = true;",
1257 "\t_this.search_results.el.label = \"No Matches\";",
1264 "bool always_show_image" : true,
1265 "bool sensitive" : false,
1271 "\t_this.forwardSearch(true);",
1277 "string icon_name" : "go-down",
1282 "bool always_show_image" : true,
1283 "bool sensitive" : false,
1289 "\t_this.backSearch(true);",
1296 "string icon_name" : "go-up",
1301 "bool always_show_image" : true,
1306 "* prop" : "popover",
1307 "id" : "search_settings",
1312 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
1319 "\tthis.el.show();",
1323 "id" : "case_sensitive",
1324 "string label" : "Case Sensitive",
1325 "xtype" : "CheckButton"
1331 "\tthis.el.show();",
1336 "string label" : "Regex",
1337 "xtype" : "CheckButton"
1343 "\tthis.el.show();",
1348 "string label" : "Multi-line (add \\n)",
1349 "xtype" : "CheckButton"
1358 "string icon_name" : "emblem-system",
1359 "xtype" : "MenuButton"
1368 "xtype" : "Notebook"
1373 "(string in_txt) {",
1374 "\tthis.notebook.el.page = 1;",
1378 "\tvar s = new GtkSource.SearchSettings();",
1379 "\ts.case_sensitive = _this.case_sensitive.el.active;",
1380 "\ts.regex_enabled = _this.regex.el.active;\t",
1381 "\ts.wrap_around = false;",
1383 "\tthis.searchcontext = new GtkSource.SearchContext(this.buffer.el,s);",
1384 "\tthis.searchcontext.set_highlight(true);",
1385 "\tvar txt = in_txt;",
1387 "\tif (_this.multiline.el.active) {",
1388 "\t\ttxt = in_txt.replace(\"\\\\n\", \"\\n\");",
1391 "\ts.set_search_text(txt);",
1392 "\tGtk.TextIter beg, st,en;",
1393 "\tbool has_wrapped_around;",
1394 "\tthis.buffer.el.get_start_iter(out beg);",
1395 "\tthis.searchcontext.forward(beg, out st, out en, out has_wrapped_around);",
1396 "\tthis.last_search_end = 0;",
1398 "\treturn this.searchcontext.get_occurrences_count();",
1406 "| void backSearch" : [
1407 "(bool change_focus) {",
1409 "\tif (this.searchcontext == null) {",
1413 "\tGtk.TextIter beg, st,en;",
1414 "\tbool has_wrapped_around;",
1415 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end -1 );",
1417 "\tif (!this.searchcontext.backward(beg, out st, out en, out has_wrapped_around)) {",
1419 "\t\tthis.last_search_end = 0;",
1422 "\tthis.last_search_end = en.get_offset();",
1423 "\tif (change_focus) {",
1424 "\t\tthis.sourceview.el.grab_focus();",
1426 "\tthis.buffer.el.place_cursor(st);",
1427 "\tthis.sourceview.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
1428 "\tvar ln = st.get_line();",
1429 "\tthis.highlightNodeAtLine(ln);",
1435 "| void createThumb" : [
1439 " if (this.file == null) {",
1443 "\tif (this.notebook.el.page > 0 ) {",
1447 " \tthis.file.widgetToIcon(this.view.el); ",
1456 "| void forwardSearch" : [
1457 "(bool change_focus) {",
1459 "\tif (this.searchcontext == null) {",
1462 "\tthis.notebook.el.page = 1;",
1463 "\tGtk.TextIter beg, st,en;",
1464 "\tbool has_wrapped_around;",
1465 "\tvar buf = this.sourceview.el.get_buffer();",
1466 "\tbuf.get_iter_at_offset(out beg, this.last_search_end);",
1467 "\tif (!this.searchcontext.forward(beg, out st, out en, out has_wrapped_around)) {",
1468 "\t\tthis.last_search_end = 0;",
1471 "\tthis.last_search_end = en.get_offset();",
1472 "\tif (change_focus) {",
1473 "\t\tthis.sourceview.el.grab_focus();",
1475 "\tbuf.place_cursor(st);",
1479 "\tthis.sourceview.el.scroll_to_iter(st, 0.0f, true, 0.0f, 0.5f);",
1482 "\tvar ln = st.get_line();",
1484 "\tthis.highlightNodeAtLine(ln);",
1488 "| void highlightNodeAtLine" : [
1493 "\t// highlight node...",
1496 " var node = _this.file.lineToNode(ln+1);",
1498 " if (node == null) {",
1499 " //print(\"can not find node\\n\");",
1502 " var prop = node.lineToProp(ln+1);",
1503 " print(\"prop : %s\", prop == null ? \"???\" : prop.name);",
1506 " // ---------- this selects the tree's node...",
1508 " var ltree = _this.main_window.windowstate.left_tree;",
1509 " ltree.model.selectNode(node);",
1511 " //_this.sourceview.allow_node_scroll = false; /// block node scrolling..",
1514 " //print(\"changing cursor on tree..\\n\");",
1518 " // let's try allowing editing on the methods.",
1519 " // a little klunky at present..",
1520 "\t_this.sourceview.prop_selected = \"\";",
1522 " if (prop != null) {",
1523 "\t\t//see if we can find it..",
1524 "\t\tvar kv = prop.split(\":\");",
1525 "\t\tif (kv[0] == \"p\") {",
1527 " \t\t//var k = prop.get_key(kv[1]);",
1528 " \t\t// fixme -- need to determine if it's an editable property...",
1529 " \t\t_this.sourceview.prop_selected = prop;",
1531 "\t\t} else if (kv[0] == \"l\") {",
1532 "\t\t\t _this.sourceview.prop_selected = prop;",
1537 " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
1538 " _this.sourceview.nodeSelected(node,false);",
1540 " // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
1541 " // GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {",
1542 "\t // this.allow_node_scroll = true;",
1543 "\t // return false;",
1560 "| void loadFile" : [
1562 "(JsRender.JsRender file)",
1564 " this.file = file;",
1565 " this.view.renderJS(true);",
1566 " this.notebook.el.page = 0;// gtk preview ",
1567 " this.sourceview.loadFile(); ",
1568 " this.last_error_counter = -1;",
1569 " this.updateErrorMarks();",
1574 "| void requestRedraw" : [
1576 " this.view.renderJS(false);",
1577 " this.sourceview.loadFile(); ",
1580 "| void scroll_to_line" : [
1582 " // code preview...",
1584 " GLib.Timeout.add(100, () => {",
1586 "\t\tthis.notebook.el.set_current_page( 1 );",
1589 "\t\t var buf = this.sourceview.el.get_buffer();",
1591 "\t\tvar sbuf = (GtkSource.Buffer) buf;",
1594 "\t\tGtk.TextIter iter; ",
1595 "\t\tsbuf.get_iter_at_line(out iter, line);",
1596 "\t\tthis.sourceview.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
1597 "\t\treturn false;",
1604 "| void updateErrorMarks" : [
1609 "\tvar buf = _this.buffer.el;",
1610 "\tGtk.TextIter start;",
1611 "\tGtk.TextIter end; ",
1612 "\tbuf.get_bounds (out start, out end);",
1616 "\tGLib.debug(\"highlight errors\");\t\t ",
1618 "\t // we should highlight other types of errors..",
1623 "\tif (_this.file == null) {",
1624 "\t\tGLib.debug(\"file is null?\");",
1628 "\tvar ar = this.file.getErrors();",
1629 "\tif (ar.size < 1) {",
1630 "\t\tbuf.remove_tag_by_name (\"ERR\", start, end);",
1631 "\t\tbuf.remove_tag_by_name (\"WARN\", start, end);",
1632 "\t\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
1633 "\t\tbuf.remove_source_marks (start, end, \"ERR\");",
1634 "\t\tbuf.remove_source_marks (start, end, \"WARN\");",
1635 "\t\tbuf.remove_source_marks (start, end, \"DEPR\");",
1636 "\t\tthis.last_error_counter = file.error_counter ;",
1637 "\t\tGLib.debug(\"higjlight has no errors\");",
1640 " \tif (this.last_error_counter == file.error_counter) {",
1644 "\tvar tlines = buf.get_line_count () +1;",
1648 "\tbuf.remove_source_marks (start, end, \"ERR\");",
1649 "\tbuf.remove_source_marks (start, end, \"WARN\");",
1650 "\tbuf.remove_source_marks (start, end, \"DEPR\");",
1651 "\tbuf.remove_tag_by_name (\"ERR\", start, end);",
1652 "\tbuf.remove_tag_by_name (\"WARN\", start, end);",
1653 "\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
1654 "\tforeach(var diag in ar) { ",
1657 "\t Gtk.TextIter iter;",
1658 "// print(\"get inter\\n\");",
1659 "\t var eline = (int)diag.range.start.line ;",
1660 "\t var eline_to = (int)diag.range.end.line;",
1661 "\t if (eline > tlines || eline < 0) {",
1666 "\t buf.get_iter_at_line( out iter, eline);",
1668 "\t \t buf.get_iter_at_line_offset( out start, ",
1669 " \t \teline, (int)diag.range.start.character); ",
1670 " \t buf.get_iter_at_line_offset( out end, ",
1671 " \t \teline_to, (int)diag.range.end.character); ",
1673 "\t buf.apply_tag_by_name(diag.category, start, end);",
1676 "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, diag.category, diag.message);",
1677 "\t buf.create_source_mark( msg, diag.category, iter);",
1678 "\t GLib.debug(\"set line %d to %s\", eline, msg);",
1679 "\t //this.marks.set(eline, msg);",
1681 "\tthis.last_error_counter = file.error_counter ;",
1691 "name" : "WindowRooView"