From 6dc1ae1309010b75d9ce02f114d9784d36d2747c Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Fri, 10 Jun 2016 13:30:56 +0800 Subject: [PATCH] src/Builder4/WindowRooView.bjs src/Builder4/WindowRooView.vala --- src/Builder4/WindowRooView.bjs | 30 +++++++------- src/Builder4/WindowRooView.vala | 71 +++++---------------------------- 2 files changed, 24 insertions(+), 77 deletions(-) diff --git a/src/Builder4/WindowRooView.bjs b/src/Builder4/WindowRooView.bjs index d42a97480..6cc0e49fa 100644 --- a/src/Builder4/WindowRooView.bjs +++ b/src/Builder4/WindowRooView.bjs @@ -29,43 +29,43 @@ "items" : [ { "id" : "notebook", - "xtype" : "Notebook", "* pack" : "pack_start,true,true,0", + "xtype" : "Notebook", "$ xns" : "Gtk", "items" : [ { "id" : "label_preview", - "xtype" : "Label", "* pack" : false, + "xtype" : "Label", "$ xns" : "Gtk", "utf8 label" : "Preview" }, { "id" : "label_code", - "* pack" : false, "xtype" : "Label", + "* pack" : false, "$ xns" : "Gtk", "utf8 label" : "Preview Generated Code" }, { "id" : "paned", - "xtype" : "Paned", "* pack" : "add", + "xtype" : "Paned", "$ xns" : "Gtk", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", "items" : [ { "id" : "viewbox", - "xtype" : "Box", "* pack" : "pack1,true,true", + "xtype" : "Box", "$ xns" : "Gtk", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", "$ homogeneous" : false, "items" : [ { "$ vexpand" : false, - "* pack" : "pack_start,false,true,0", "$ height_request" : 20, + "* pack" : "pack_start,false,true,0", "xtype" : "Box", "$ xns" : "Gtk", "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", @@ -76,8 +76,8 @@ "clicked" : "( ) => {\n _this.view.renderJS( true);\n}" }, "label" : "Redraw", - "* pack" : "pack_start,false,false,0", "xtype" : "Button", + "* pack" : "pack_start,false,false,0", "$ xns" : "Gtk" }, { @@ -96,16 +96,16 @@ "clicked" : " () => {\n _this.view.redraws = 99;\n _this.view.el.web_context.clear_cache(); \n //_this.view.renderJS(true);\n FakeServerCache.clear();\n _this.view.reInit();\n\n}" }, "label" : "Full Redraw", - "* pack" : "pack_start,false,false,0", "xtype" : "Button", + "* pack" : "pack_start,false,false,0", "$ xns" : "Gtk" } ] }, { "id" : "viewcontainer", - "$ shadow_type" : "Gtk.ShadowType.IN", "* init" : " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n", + "$ shadow_type" : "Gtk.ShadowType.IN", "* pack" : "pack_end,true,true,0", "xtype" : "ScrolledWindow", "$ xns" : "Gtk", @@ -142,8 +142,8 @@ }, { "id" : "inspectorcontainer", - "$ shadow_type" : "Gtk.ShadowType.IN", "* init" : " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n", + "$ shadow_type" : "Gtk.ShadowType.IN", "xtype" : "ScrolledWindow", "* pack" : "pack2,true,true", "$ xns" : "Gtk" @@ -161,20 +161,20 @@ "key_press_event" : "() => {\n\tthis.onCursorChanged();\n\treturn false; \n}" }, "gboolean show_line_marks" : true, - "| void onCursorChanged" : "(/*ParamSpec ps*/) {\n\t if (this.loading) {\n return;\n }\n // if (ps.name != \"cursor-position\") {\n // return;\n // }\n\n var buf = this.el.get_buffer();\n print(\"cursor changed : %d\\n\", buf.cursor_position);\n Gtk.TextIter cpos;\n buf.get_iter_at_offset(out cpos, buf.cursor_position);\n \n var ln = cpos.get_line();\n\t\tprint(\"cursor changed line : %d\\n\", ln);\n var node = _this.file.lineToNode(ln+1);\n \n if (node == null) {\n print(\"can not find node\\n\");\n return;\n }\n var prop = node.lineToProp(ln+1);\n print(\"prop : %s\", prop == null ? \"???\" : prop);\n \n \n \n \n // ---------- this selects the tree's node...\n \n var ltree = _this.main_window.windowstate.left_tree;\n var tp = ltree.model.treePathFromNode(node);\n print(\"got tree path %s\\n\", tp);\n if (tp != \"\") {\n\t this.allow_node_scroll = false; /// block node scrolling..\n\t \n\t \n\t //print(\"changing cursor on tree..\\n\");\n\t \n \n \n // let's try allowing editing on the methods.\n // a little klunky at present..\n this.prop_selected = \"\";\n if (prop != null) {\n \t\t//see if we can find it..\n \t\tvar kv = prop.split(\":\");\n \t\tif (kv[0] == \"p\") {\n \t\t\n\t \t\t//var k = prop.get_key(kv[1]);\n\t \t\t// fixme -- need to determine if it's an editable property...\n\t \t\tthis.prop_selected = prop;\n\t \t\t\n \t\t} else if (kv[0] == \"l\") {\n \t\t\t this.prop_selected = prop;\n \t\t\t\n \t\t}\n }\n ltree.view.setCursor(tp, \"editor\");\n // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); \n this.nodeSelected(node,false);\n \n // scrolling is disabled... as node selection calls scroll 10ms after it changes.\n GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {\n\t this.allow_node_scroll = true;\n\t return false;\n });\n }\n \n // highlight the node..\n}\n ", "id" : "sourceview", + "| void onCursorChanged" : "(/*ParamSpec ps*/) {\n\t if (this.loading) {\n return;\n }\n // if (ps.name != \"cursor-position\") {\n // return;\n // }\n\n var buf = this.el.get_buffer();\n print(\"cursor changed : %d\\n\", buf.cursor_position);\n Gtk.TextIter cpos;\n buf.get_iter_at_offset(out cpos, buf.cursor_position);\n \n var ln = cpos.get_line();\n\t\tprint(\"cursor changed line : %d\\n\", ln);\n var node = _this.file.lineToNode(ln+1);\n \n if (node == null) {\n print(\"can not find node\\n\");\n return;\n }\n var prop = node.lineToProp(ln+1);\n print(\"prop : %s\", prop == null ? \"???\" : prop);\n \n \n \n \n // ---------- this selects the tree's node...\n \n var ltree = _this.main_window.windowstate.left_tree;\n var tp = ltree.model.treePathFromNode(node);\n print(\"got tree path %s\\n\", tp);\n if (tp != \"\") {\n\t this.allow_node_scroll = false; /// block node scrolling..\n\t \n\t \n\t //print(\"changing cursor on tree..\\n\");\n\t \n \n \n // let's try allowing editing on the methods.\n // a little klunky at present..\n this.prop_selected = \"\";\n if (prop != null) {\n \t\t//see if we can find it..\n \t\tvar kv = prop.split(\":\");\n \t\tif (kv[0] == \"p\") {\n \t\t\n\t \t\t//var k = prop.get_key(kv[1]);\n\t \t\t// fixme -- need to determine if it's an editable property...\n\t \t\tthis.prop_selected = prop;\n\t \t\t\n \t\t} else if (kv[0] == \"l\") {\n \t\t\t this.prop_selected = prop;\n \t\t\t\n \t\t}\n }\n ltree.view.setCursor(tp, \"editor\");\n // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); \n this.nodeSelected(node,false);\n \n // scrolling is disabled... as node selection calls scroll 10ms after it changes.\n GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {\n\t this.allow_node_scroll = true;\n\t return false;\n });\n }\n \n // highlight the node..\n}\n ", "| void clearGreySelection" : "() {\n // clear all the marks..\n var sbuf = (Gtk.SourceBuffer)this.el.buffer;\n \n Gtk.TextIter start;\n Gtk.TextIter end; \n \n sbuf.get_bounds (out start, out end);\n sbuf.remove_source_marks (start, end, \"grey\");\n \n \n}\n", "* init" : "{\n \n var description = Pango.FontDescription.from_string(\"monospace\");\n description.set_size(8000);\n this.el.override_font(description);\n\n this.loading = true;\n //var buf = this.el.get_buffer();\n //buf.notify.connect(this.onCursorChanged);\n \n \n \n var attrs = new Gtk.SourceMarkAttributes();\n var pink = Gdk.RGBA();\n pink.parse ( \"pink\");\n attrs.set_background ( pink);\n attrs.set_icon_name ( \"process-stop\"); \n attrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"ERR\", attrs, 1);\n \n var wattrs = new Gtk.SourceMarkAttributes();\n var blue = Gdk.RGBA();\n blue.parse ( \"#ABF4EB\");\n wattrs.set_background ( blue);\n wattrs.set_icon_name ( \"process-stop\"); \n wattrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"WARN\", wattrs, 1);\n \n \n \n var dattrs = new Gtk.SourceMarkAttributes();\n var purple = Gdk.RGBA();\n purple.parse ( \"#EEA9FF\");\n dattrs.set_background ( purple);\n dattrs.set_icon_name ( \"process-stop\"); \n dattrs.query_tooltip_text.connect(( mark) => {\n //print(\"tooltip query? %s\\n\", mark.name);\n return mark.name;\n });\n \n this.el.set_mark_attributes (\"DEPR\", dattrs, 1);\n \n \n var gattrs = new Gtk.SourceMarkAttributes();\n var grey = Gdk.RGBA();\n grey.parse ( \"#ccc\");\n gattrs.set_background ( grey);\n \n \n this.el.set_mark_attributes (\"grey\", gattrs, 1);\n \n \n \n \n \n \n}\n ", "| void nodeSelected" : "(JsRender.Node? sel, bool scroll ) {\n \n \n\t\n // this is connected in widnowstate\n\n\n\t// not sure why.... \n while(Gtk.events_pending()) {\n Gtk.main_iteration();\n }\n \n this.node_selected = sel;\n \n this.updateGreySelection(scroll);\n}\n\n \n", "bool loading" : true, "| string toString" : "() {\n Gtk.TextIter s;\n Gtk.TextIter e;\n this.el.get_buffer().get_start_iter(out s);\n this.el.get_buffer().get_end_iter(out e);\n var ret = this.el.get_buffer().get_text(s,e,true);\n //print(\"TO STRING? \" + ret);\n return ret;\n}\n", - "| void loadFile" : "( ) {\n this.loading = true;\n \n \n // get the cursor and scroll position....\n var buf = this.el.get_buffer();\n\tvar cpos = buf.cursor_position;\n \n print(\"BEFORE LOAD cursor = %d\\n\", cpos);\n \n var vadj_pos = this.el.get_vadjustment().get_value();\n \n \n \n buf.set_text(\"\",0);\n var sbuf = (Gtk.SourceBuffer) buf;\n\n \n\n if (_this.file == null || _this.file.xtype != \"Roo\") {\n print(\"xtype != Roo\");\n this.loading = false;\n return;\n }\n \n // get the string from the rendered tree...\n \n var str = _this.file.toSource();\n \n// print(\"setting str %d\\n\", str.length);\n buf.set_text(str, str.length);\n var lm = Gtk.SourceLanguageManager.get_default();\n \n //?? is javascript going to work as js?\n \n ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));\n \n \n Gtk.TextIter start;\n Gtk.TextIter end; \n \n sbuf.get_bounds (out start, out end);\n sbuf.remove_source_marks (start, end, null); // remove all marks..\n \n GLib.Timeout.add(500, () => {\n \n print(\"RESORTING cursor to = %d\\n\", cpos);\n\t\tGtk.TextIter cpos_iter;\n\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);\n\t\tbuf.place_cursor(cpos_iter); \n\t\t\n\t\tthis.el.get_vadjustment().set_value(vadj_pos);;\n\t\tthis.onCursorChanged();\n\t\t_this.buffer.checkSyntax();\n\t\treturn false;\n\t});\n\t\t\n this.loading = false; \n _this.buffer.dirty = false;\n}\n", + "| void loadFile" : "( ) {\n this.loading = true;\n \n \n // get the cursor and scroll position....\n var buf = this.el.get_buffer();\n\tvar cpos = buf.cursor_position;\n \n print(\"BEFORE LOAD cursor = %d\\n\", cpos);\n \n var vadj_pos = this.el.get_vadjustment().get_value();\n \n \n \n buf.set_text(\"\",0);\n var sbuf = (Gtk.SourceBuffer) buf;\n\n \n\n if (_this.file == null || _this.file.xtype != \"Roo\") {\n print(\"xtype != Roo\");\n this.loading = false;\n return;\n }\n \n // get the string from the rendered tree...\n \n var str = _this.file.toSource();\n \n// print(\"setting str %d\\n\", str.length);\n buf.set_text(str, str.length);\n var lm = Gtk.SourceLanguageManager.get_default();\n \n //?? is javascript going to work as js?\n \n ((Gtk.SourceBuffer)(buf)) .set_language(lm.get_language(_this.file.language));\n \n \n Gtk.TextIter start;\n Gtk.TextIter end; \n \n sbuf.get_bounds (out start, out end);\n sbuf.remove_source_marks (start, end, null); // remove all marks..\n \n GLib.Timeout.add(500, () => {\n\n print(\"RESORTING cursor to = %d\\n\", cpos);\n\t\tGtk.TextIter cpos_iter;\n\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);\n\t\tbuf.place_cursor(cpos_iter); \n\t\t\n\t\tthis.el.get_vadjustment().set_value(vadj_pos);;\n\t\t\n\n\t\tthis.onCursorChanged();\n\t\t\n\t\t\n\t\t_this.buffer.checkSyntax();\n\t\treturn false;\n\t});\n\t\t\n this.loading = false; \n _this.buffer.dirty = false;\n}\n", "* pack" : "add", "xtype" : "SourceView", "bool allow_node_scroll" : true, "$ string prop_selected" : "\"\"", "| void updateGreySelection" : "(bool scroll) { \n\tvar sel = this.node_selected;\n\tprint(\"node selected\\n\");\n var buf = this.el.get_buffer();\n var sbuf = (Gtk.SourceBuffer) buf;\n\n \n this.clearGreySelection();\n \n \n \n if (sel == null) {\n\t print(\"no selected node\\n\");\n // no highlighting..\n return;\n }\n \n print(\"highlight region %d to %d\\n\", sel.line_start,sel.line_end);\n Gtk.TextIter iter; \n sbuf.get_iter_at_line(out iter, sel.line_start);\n \n \n Gtk.TextIter cur_iter;\n sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);\n \n var cursor_at_line = cur_iter.get_line();\n \n \n //var cur_line = cur_iter.get_line();\n //if (cur_line > sel.line_start && cur_line < sel.line_end) {\n \n //} else {\n if (scroll) {\n\t\tprint(\"scrolling to node -- should occur on node picking.\\n\");\n \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);\n\t}\n \n var start_line = sel.line_start;\n var end_line = sel.line_end;\n \n \n this.el.editable = false;\n \n var colon_pos = 0;\n \n // now if we have selected a property...\n if (this.prop_selected.length> 0 ) {\n\n\t\tint nstart, nend;\n\t\tif (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) {\n\t\t\tstart_line = nstart;\n\t\t\tend_line = nend;\n\t\t\tthis.el.editable = true;\n\t\t\tprint(\"start line = %d, end line = %d\\n\", start_line, end_line);\n\t\t\t\n\t\t\t\t// see if we are 'right of ':'\n\t\t\t\t// get an iter for the start of the line.\n\t\t\tGtk.TextIter start_line_iter,end_line_iter;\n\t\t\tthis.el.buffer.get_iter_at_line(out start_line_iter, start_line -1);\n\t\t\tthis.el.buffer.get_iter_at_line(out end_line_iter, start_line -1);\n\t\t\t \n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\tif (end_line_iter.forward_to_line_end()) {\n\t\t\t\tvar first_line = this.el.buffer.get_text(start_line_iter, end_line_iter, false);\n\t\t\t\tprint(\"first line = %s\\n\", first_line);\n\t\t\t\tif (first_line.contains(\":\")) {\n\t\t\t\t\tcolon_pos = start_line_iter.get_offset() + first_line.index_of(\":\") + 1;\n\t\t\t\t}\n\t\t\t\tprint(\"colon_pos = %d\\n\", colon_pos);\n\t\t\t}\n\t\t\tprint(\"is cursor at line? %d ?= %d\\n\", start_line -1 , cursor_at_line);\n\t\t\tif (start_line - 1 == cursor_at_line) {\n\t\t\t\tprint(\"cursor is on current line.\\n\");\n\t\t\t\tvar before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false);\n\t\t\t\tprint(\"before cursor string = %s\\n\", before_cursor_string);\n\t\t\t\tif (!before_cursor_string.contains(\":\")) {\n\t\t\t\t\tthis.el.editable = false;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t}\n\t\tprint(\"propSelected = %s range %d -> %d\\n\", this.prop_selected, start_line, end_line);\t\t\n\t\t\n\t\t\n }\n \n\tprint(\"checking selection\\n\");\n \n \n // check selection - if it's out of 'bounds'\n if (this.el.editable && sbuf.get_has_selection()) {\n\t\tGtk.TextIter sel_start_iter, sel_end_iter;\n\t\tsbuf.get_selection_bounds(out sel_start_iter, out sel_end_iter);\n\t\t\n\t\tif (sel_start_iter.get_line() < start_line || sel_end_iter.get_line() > end_line ||\n\t\t\tsel_start_iter.get_line() > end_line || sel_end_iter.get_line() < start_line\t\t\t) {\n\t\t\t// save?\n\t\t\tthis.el.editable = false;\n\t\t}\n\t\tif (colon_pos > 0 &&\n\t\t\t(sel_start_iter.get_offset() < colon_pos || sel_end_iter.get_offset() < colon_pos)\n\t\t\t\n\t\t) {\n\t\t\tthis.el.editable = false;\n\t\t}\n\t\t\n\t\t \n \n }\n \n \n \n \n for (var i = 0; i < buf.get_line_count();i++) {\n if (i < (start_line -1) || i > (end_line -1)) {\n \n sbuf.get_iter_at_line(out iter, i);\n sbuf.create_source_mark(null, \"grey\", iter);\n \n }\n \n }\n \n\n}", - "| void highlightErrorsJson" : " (string type, Json.Object obj) {\n Gtk.TextIter start;\n Gtk.TextIter end; \n \n var buf = this.el.get_buffer();\n var sbuf = (Gtk.SourceBuffer)buf;\n buf.get_bounds (out start, out end);\n \n sbuf.remove_source_marks (start, end, type);\n \n \n // we should highlight other types of errors..\n \n if (!obj.has_member(type)) {\n print(\"Return has no errors\\n\");\n return ;\n }\n var err = obj.get_object_member(type);\n \n if (_this.file == null) { \n return; // just in case the file has not loaded yet?\n }\n \n\n print(\"checking for errors in \" + _this.file.path);\n\n if (!err.has_member(_this.file.path)) {\n print(\"File path has no errors\\n\");\n return ;\n }\n var lines = err.get_object_member(_this.file.path);\n \n \n \n var tlines = buf.get_line_count () +1;\n \n lines.foreach_member((obj, line, node) => {\n \n Gtk.TextIter iter;\n // print(\"get inter\\n\");\n var eline = int.parse(line) -1 ;\n print(\"GOT ERROR on line %s -- converted to %d\\n\", line,eline);\n \n \n if (eline > tlines || eline < 0) {\n return;\n }\n sbuf.get_iter_at_line( out iter, eline);\n //print(\"mark line\\n\");\n var msg = type + \" on line: %d \".printf(eline+1 );\n var ar = lines.get_array_member(line);\n for (var i = 0 ; i < ar.get_length(); i++) {\n\t\t\t\tmsg += (msg.length > 0) ? \"\\n\" : \"\";\n\t\t\t\tmsg += ar.get_string_element(i);\n\t\t\t}\n \n \n sbuf.create_source_mark(msg, type, iter);\n } );\n return ;\n \n \n\n\n}", + "| void highlightErrorsJson" : " (string type, Json.Object obj) {\n // this is a hook for the vala code - it has no value in javascript \n // as we only have one error ususally....\n return ;\n \n \n\n\n}", "JsRender.Node? node_selected" : "null", "$ xns" : "Gtk", "gboolean show_line_numbers" : true, @@ -185,11 +185,11 @@ "changed" : " () => {\n // check syntax??\n // ??needed..??\n // _this.save_button.el.sensitive = true;\n ///?? has changed occured during loading?\n if (_this.sourceview.loading) {\n\t\treturn;\n\t}\n\t\n print(\"- PREVIEW EDITOR CHANGED--\");\n\n this.dirty = true; \n if (!this.checkSyntax()) {\n\t\treturn;\n\t}\t\t\n \n // what are we editing??\n \n\n\n\n\n return ;\n}\n\n \n" }, "bool dirty" : false, - "int error_line" : "-1", "id" : "buffer", + "int error_line" : "-1", "| bool highlightErrors" : "( Gee.HashMap validate_res) {\n \n this.error_line = validate_res.size;\n\t\n if (this.error_line < 1) {\n return true;\n }\n var tlines = this.el.get_line_count ();\n Gtk.TextIter iter;\n var valiter = validate_res.map_iterator();\n while (valiter.next()) {\n \n// print(\"get inter\\n\");\n var eline = valiter.get_key();\n if (eline > tlines) {\n continue;\n }\n this.el.get_iter_at_line( out iter, eline);\n //print(\"mark line\\n\");\n this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);\n } \n return false;\n}", "| string toString" : " () {\n \n Gtk.TextIter s;\n Gtk.TextIter e;\n this.el.get_start_iter(out s);\n this.el.get_end_iter(out e);\n var ret = this.el.get_text(s,e,true);\n //print(\"TO STRING? \" + ret);\n return ret;\n}\n ", - "| bool checkSyntax" : " () {\n \n \n var str = this.toString();\n \n // needed???\n if (this.error_line > 0) {\n Gtk.TextIter start;\n Gtk.TextIter end; \n this.el.get_bounds (out start, out end);\n\n this.el.remove_source_marks (start, end, null);\n }\n \n if (str.length < 1) {\n print(\"checkSyntax - empty string?\\n\");\n return false;\n }\n \n if (_this.file == null) {\n return false;\n }\n var p = Palete.factory(_this.file.xtype); // returns Roo | Gtk | PlainFile \n \n \n if (_this.file.language != \"js\") {\n\t\treturn false; // fake syntax error.\n\t}\n\t\n \n \n\treturn p.javascriptHasErrors(\n\t\t_this.main_window.windowstate,\n str, \n \"\", // _this.key, \n \"file\", //_this.ptype,\n _this.file,\n null,\n null\n ); \n \n}\n", + "| bool checkSyntax" : " () {\n \n \n var str = this.toString();\n \n // needed???\n if (this.error_line > 0) {\n Gtk.TextIter start;\n Gtk.TextIter end; \n this.el.get_bounds (out start, out end);\n\n this.el.remove_source_marks (start, end, null);\n }\n \n if (str.length < 1) {\n print(\"checkSyntax - empty string?\\n\");\n return false;\n }\n \n if (_this.file == null) {\n return false;\n }\n var p = Palete.factory(_this.file.xtype); // returns Roo | Gtk | PlainFile \n \n \n if (_this.file.language != \"js\") {\n\t\treturn false; // fake syntax error.\n\t}\n\t\n \n\n\treturn p.javascriptHasErrors(\n\t\t_this.main_window.windowstate,\n str, \n \"\", // _this.key, \n \"file\", //_this.ptype,\n _this.file,\n null\n ); \n \n}\n", "* pack" : "set_buffer", "xtype" : "SourceBuffer", "$ xns" : "Gtk" diff --git a/src/Builder4/WindowRooView.vala b/src/Builder4/WindowRooView.vala index c53d05ea2..f50a17d22 100644 --- a/src/Builder4/WindowRooView.vala +++ b/src/Builder4/WindowRooView.vala @@ -1190,14 +1190,18 @@ public class Xcls_WindowRooView : Object sbuf.remove_source_marks (start, end, null); // remove all marks.. GLib.Timeout.add(500, () => { - - print("RESORTING cursor to = %d\n", cpos); + + print("RESORTING cursor to = %d\n", cpos); Gtk.TextIter cpos_iter; buf.get_iter_at_offset(out cpos_iter, cpos); buf.place_cursor(cpos_iter); this.el.get_vadjustment().set_value(vadj_pos);; + + this.onCursorChanged(); + + _this.buffer.checkSyntax(); return false; }); @@ -1335,64 +1339,8 @@ public class Xcls_WindowRooView : Object } public void highlightErrorsJson (string type, Json.Object obj) { - Gtk.TextIter start; - Gtk.TextIter end; - - var buf = this.el.get_buffer(); - var sbuf = (Gtk.SourceBuffer)buf; - buf.get_bounds (out start, out end); - - sbuf.remove_source_marks (start, end, type); - - - // we should highlight other types of errors.. - - if (!obj.has_member(type)) { - print("Return has no errors\n"); - return ; - } - var err = obj.get_object_member(type); - - if (_this.file == null) { - return; // just in case the file has not loaded yet? - } - - - print("checking for errors in " + _this.file.path); - - if (!err.has_member(_this.file.path)) { - print("File path has no errors\n"); - return ; - } - var lines = err.get_object_member(_this.file.path); - - - - var tlines = buf.get_line_count () +1; - - lines.foreach_member((obj, line, node) => { - - Gtk.TextIter iter; - // print("get inter\n"); - var eline = int.parse(line) -1 ; - print("GOT ERROR on line %s -- converted to %d\n", line,eline); - - - if (eline > tlines || eline < 0) { - return; - } - sbuf.get_iter_at_line( out iter, eline); - //print("mark line\n"); - var msg = type + " on line: %d ".printf(eline+1 ); - var ar = lines.get_array_member(line); - for (var i = 0 ; i < ar.get_length(); i++) { - msg += (msg.length > 0) ? "\n" : ""; - msg += ar.get_string_element(i); - } - - - sbuf.create_source_mark(msg, type, iter); - } ); + // this is a hook for the vala code - it has no value in javascript + // as we only have one error ususally.... return ; @@ -1514,14 +1462,13 @@ public class Xcls_WindowRooView : Object } - + return p.javascriptHasErrors( _this.main_window.windowstate, str, "", // _this.key, "file", //_this.ptype, _this.file, - null, null ); -- 2.39.2