""
],
"script_dialog" : [
- " (dialog) => {",
- " ",
- " ",
- " if (this.el == null) {",
- " return true;",
- " }",
- " ",
- " var msg = dialog.get_message();",
- " if (msg.length < 4) {",
- " return false;",
- " }",
- " ",
- " GLib.debug(\"script dialog got %s\", msg);",
- " ",
- " if (msg.substring(0,4) != \"IPC:\") {",
- " return false;",
- " }",
- " var ar = msg.split(\":\", 3);",
- " if (ar.length < 3) {",
- " return false;",
- " }",
+ "(dialog) => {",
"",
- " switch(ar[1]) {",
- " case \"SAVEHTML\":",
- "\t GLib.debug(\"GOT saveHTML %d\", ar[2].length);",
- " _this.file.saveHTML(ar[2]);",
- " _this.createThumb();",
- " return true;",
- " default:",
- " return false;",
- " }",
+ "\tif (this.el == null) {",
+ "\t\treturn true;",
+ "\t}",
+ "",
+ "\tvar msg = dialog.get_message();",
+ "\tif (msg.length < 4) {",
+ "\t\treturn false;",
+ "\t}",
+ "\t ",
+ "\t //GLib.debug(\"script dialog got %s\", msg);",
+ "\t ",
+ "\tif (msg.substring(0,4) != \"IPC:\") {",
+ "\t\treturn false;",
+ "\t}",
+ "\tvar ar = msg.split(\":\", 3);",
+ "\tif (ar.length < 3) {",
+ "\t\treturn false;",
+ "\t}",
+ "",
+ "\tswitch(ar[1]) {",
+ "\t",
+ "\t\tcase \"SAVEHTML\":",
+ "\t\t // GLib.debug(\"GOT saveHTML %d\", ar[2].length);",
+ "\t\t _this.file.saveHTML(ar[2]);",
+ "\t\t _this.createThumb();",
+ "\t\t return true;",
+ "\t\t ",
+ "\t\tdefault:",
+ "\t\t return false;",
+ "\t}",
" ",
"}"
]
" }",
" ",
" this.refreshRequired = true;",
+ " ",
"}",
""
],
"| void runRefresh" : [
- " () ",
+ "() ",
"{",
" // this is run every 2 seconds from the init..",
"",
- " ",
- " ",
+ " ",
" if (!this.refreshRequired) {",
" // print(\"no refresh required\");",
" return;",
" this.pendingRedraw = true;",
"",
" var runhtml = \"<script type=\\\"text/javascript\\\">\\n\" ;",
- " string builderhtml;",
+ " uint8[] builderhtml;",
" ",
" try {",
- " GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + \"/resources/roo.builder.js\", out builderhtml);",
+ " GLib. File.new_for_uri(\"resource:///html/roo.builder.js\").load_contents(null, out builderhtml, null);",
" } catch (Error e) {",
- " builderhtml = \"\";",
+ " builderhtml = {};",
" }",
"",
- " runhtml += builderhtml + \"\\n\";",
+ " runhtml += (string) builderhtml + \"\\n\";",
" runhtml += \"</script>\\n\" ;",
"",
" // fix to make sure they are the same..",
" this.runhtml = project.runhtml;",
" // need to modify paths",
"",
- " string inhtml;",
+ " uint8[] inhtml;",
" var base_template = project.base_template;",
+ " var f = GLib. File.new_for_uri(\"resource:///html/\" + base_template);",
" ",
- " if (base_template.length > 0 && !FileUtils.test(",
- " BuilderApplication.configDirectory() + \"/resources/\" + base_template, FileTest.EXISTS) ",
- " ) {",
- " print(\"invalid base_template name - using default: %s\\n\", base_template);",
- " base_template = \"\";",
+ " if (base_template.length > 0 && !f.query_exists(null)) {",
+ " ",
+ " GLib.debug(\"invalid base_template name - using default: %s\", base_template);",
+ " f = GLib. File.new_for_uri(\"resource:///html/roo.builder.html\");",
" ",
" }",
" try {",
- " GLib.FileUtils.get_contents(",
- " BuilderApplication.configDirectory() + \"/resources/\" + ",
- " (base_template.length > 0 ? base_template : \"roo.builder.html\")",
- " , out inhtml);",
+ "\t f.load_contents(null, out inhtml, null);",
+ " ",
" ",
" } catch (Error e) {",
- " inhtml = \"\";",
+ " \tGLib.debug(\"error loading %s : %s\", f.get_uri(),e.message);",
+ " inhtml = {};",
" } ",
" this.renderedData = js;",
"",
" //this.runjs = js_src;",
" var fc = FakeServerCache.factory_with_data(js_src);",
" this.runjs = fc.fname;",
+ " var html = (string) inhtml;",
+ " html = html == null ? \"\" : html; // fix null?",
+ " ",
+ "\thtml = html.replace(\"</head>\", runhtml + this.runhtml + ",
+ " \"<script type=\\\"text/javascript\\\" src=\\\"xhttp://localhost\" + fc.fname + \"\\\"></script>\" + ",
+ " // \"<script type=\\\"text/javascript\\\">\\n\" +",
+ " // js_src + \"\\n\" + ",
+ " // \"</script>\" + ",
+ " ",
+ " \"</head>\");",
+ " //print(\"LOAD HTML \" + html);",
+ " ",
+ " var rootURL = project.rootURL;",
+ "",
" ",
- " var html = inhtml.replace(\"</head>\", runhtml + this.runhtml + ",
- " \"<script type=\\\"text/javascript\\\" src=\\\"xhttp://localhost\" + fc.fname + \"\\\"></script>\" + ",
- " // \"<script type=\\\"text/javascript\\\">\\n\" +",
- " // js_src + \"\\n\" + ",
- " // \"</script>\" + ",
- " ",
- " \"</head>\");",
- " //print(\"LOAD HTML \" + html);",
- " ",
- " var rootURL = project.rootURL;",
- " ",
- " ",
- " ",
- " this.el.load_html( html , ",
- " //fixme - should be a config option!",
- " (rootURL.length > 0 ? rootURL : \"xhttp://localhost/roobuilder/\")",
- " );",
- " this.initInspector(); ",
+ " ",
+ " this.el.load_html( html , ",
+ " //fixme - should be a config option!",
+ " (rootURL.length > 0 ? rootURL : \"xhttp://localhost/roobuilder/\")",
+ " );",
+ " this.initInspector(); ",
" // force the inspector... ",
" // this.initInspector();",
" ",
"id" : "sourceviewscroll",
"items" : [
{
+ "# Gtk.CssProvider? css" : "null",
"# JsRender.Node? node_selected" : "null",
"# bool button_is_pressed" : false,
"# bool key_is_pressed" : false,
"# bool loading" : true,
+ "# id" : "sourceview",
"# int editable_start_pos" : "-1",
"# string prop_selected" : "\"\"",
"$ xns" : "GtkSource",
"* init" : [
"\t{",
"",
- "\tthis.css = new Gtk.CssProvider();",
- "\t ",
- "\tthis.css.load_from_string(",
- "\t\t\"#roo-view { font: 10px monospace; }\"",
- "\t);",
- "",
- "\tGtk.StyleContext.add_provider_for_display(",
- "\t\tthis.el.get_display(),",
- "\t\tthis.css,",
- "\t\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
- "\t);",
- "\t\t",
"\t ",
"",
"\tthis.loading = true;",
""
],
"* pack" : "set_child",
- "Gtk.CssProvider css" : "",
- "gboolean editable" : false,
- "gboolean show_line_marks" : true,
- "gboolean show_line_numbers" : true,
- "id" : "sourceview",
+ "bool editable" : false,
+ "bool show_line_marks" : true,
+ "bool show_line_numbers" : true,
+ "css_classes" : "{ \"code-editor\" }",
"items" : [
{
"$ xns" : "GtkSource",
]
},
{
+ "# bool is_control" : false,
"$ xns" : "Gtk",
"* pack" : "add_controller",
+ "id" : "keystate",
"listeners" : {
"key_pressed" : [
"(keyval, keycode, state) => {",
"",
- " ",
+ " \tif (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
+ " \t\tthis.is_control = true;",
+ "\t}",
" ",
" \tif (keyval == Gdk.Key.g && (state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
"\t GLib.debug(\"SAVE: ctrl-g pressed\");",
" ",
"}",
""
+ ],
+ "key_released" : [
+ "(keyval, keycode, state) => {",
+ "",
+ "",
+ " \t if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {",
+ " \t\tthis.is_control = false;",
+ "\t}",
+ "}",
+ ""
]
},
"xtype" : "EventControllerKey"
+ },
+ {
+ "# double distance" : "0.0f",
+ "$ xns" : "Gtk",
+ "Gtk.EventControllerScrollFlags flags" : "Gtk.EventControllerScrollFlags.VERTICAL",
+ "listeners" : {
+ "scroll" : [
+ "(dx, dy) => {",
+ "\tif (!_this.keystate.is_control) {",
+ "\t\treturn false;",
+ "\t}",
+ "\t//GLib.debug(\"scroll %f\", dy);",
+ "\t",
+ "\tthis.distance += dy;",
+ "\t if (this.distance < -1) {",
+ " ",
+ "\t\tBuilderApplication.settings.editor_font_size ++;",
+ "\t\tthis.distance = 0;",
+ "\t}",
+ "\tif (this.distance > 1) {",
+ "\t\tBuilderApplication.settings.editor_font_size --;",
+ "\t\tthis.distance = 0;",
+ "\t}",
+ "",
+ "\treturn true;",
+ "}",
+ ""
+ ]
+ },
+ "xtype" : "EventControllerScroll"
}
],
"listeners" : {
" ",
" ",
" buf.set_text(\"\",0);",
- " var sbuf = (GtkSource.Buffer) buf;",
+ " ",
"",
" ",
"",
"items" : [
{
"$ xns" : "Gtk",
- "* init" : [
- "this.css = new Gtk.CssProvider();",
- " ",
- "this.css.load_from_string(",
- "\t\"#roo-search-entry { background-color: #ccc; }\"",
- ");",
- " ",
- "Gtk.StyleContext.add_provider_for_display(",
- "\tthis.el.get_display(),",
- "\tthis.css,",
- "\tGtk.STYLE_PROVIDER_PRIORITY_APPLICATION",
- ");",
- "\t\t",
- "\t ",
- " ",
- ""
- ],
- "Gtk.CssProvider css" : "",
"bool hexpand" : true,
"id" : "search_entry",
"items" : [
"\t\tbuf.remove_tag_by_name (\"ERR\", start, end);",
"\t\tbuf.remove_tag_by_name (\"WARN\", start, end);",
"\t\tbuf.remove_tag_by_name (\"DEPR\", start, end);",
- "\t\tbuf.remove_source_marks (start, end, null);",
+ "\t\tbuf.remove_source_marks (start, end, \"ERR\");",
+ "\t\tbuf.remove_source_marks (start, end, \"WARN\");",
+ "\t\tbuf.remove_source_marks (start, end, \"DEPR\");",
"\t\tthis.last_error_counter = file.error_counter ;",
"\t\tGLib.debug(\"higjlight has no errors\");",
"\t\treturn;",
"\t",
" ",
"\t ",
- "\tbuf.remove_source_marks (start, end, null);",
+ "\tbuf.remove_source_marks (start, end, \"ERR\");",
+ "\tbuf.remove_source_marks (start, end, \"WARN\");",
+ "\tbuf.remove_source_marks (start, end, \"DEPR\");",
"\tbuf.remove_tag_by_name (\"ERR\", start, end);",
"\tbuf.remove_tag_by_name (\"WARN\", start, end);",
"\tbuf.remove_tag_by_name (\"DEPR\", start, end);",