Fix #8044 - fixing varous crashes, correct tree drop location and empty nodes after...
[roobuilder] / src / Builder4 / WindowRooView.bjs
index 506da32..497caf2 100644 (file)
@@ -12,6 +12,7 @@
    "bool hexpand" : true,
    "bool vexpand" : true,
    "id" : "WindowRooView",
+   "int last_error_counter" : 0,
    "int last_search_end" : 0,
    "items" : [
     {
              ""
             ],
             "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" : [
-            "{",
-            "   ",
-            "   this.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{",
+            "",
             "\t ",
-            "    ",
-            "    this.loading = true;",
-            "    //var buf = this.el.get_buffer();",
-            "    //buf.notify.connect(this.onCursorChanged);",
-            "  ",
-            "  ",
-            "    var attrs = new GtkSource.MarkAttributes();",
-            "    var  pink =   Gdk.RGBA();",
-            "    pink.parse ( \"pink\");",
-            "    attrs.set_background ( pink);",
-            "    attrs.set_icon_name ( \"process-stop\");    ",
-            "    attrs.query_tooltip_text.connect(( mark) => {",
-            "        //print(\"tooltip query? %s\\n\", mark.name);",
-            "        return mark.name;",
-            "    });",
-            "    ",
-            "    this.el.set_mark_attributes (\"ERR\", attrs, 1);",
-            "    ",
-            "     var wattrs = new GtkSource.MarkAttributes();",
-            "    var  blue =   Gdk.RGBA();",
-            "    blue.parse ( \"#ABF4EB\");",
-            "    wattrs.set_background ( blue);",
-            "    wattrs.set_icon_name ( \"process-stop\");    ",
-            "    wattrs.query_tooltip_text.connect(( mark) => {",
-            "        //print(\"tooltip query? %s\\n\", mark.name);",
-            "        return mark.name;",
-            "    });",
-            "    ",
-            "    this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
-            "    ",
-            " ",
-            "    ",
-            "     var dattrs = new GtkSource.MarkAttributes();",
-            "    var  purple =   Gdk.RGBA();",
-            "    purple.parse ( \"#EEA9FF\");",
-            "    dattrs.set_background ( purple);",
-            "    dattrs.set_icon_name ( \"process-stop\");    ",
-            "    dattrs.query_tooltip_text.connect(( mark) => {",
-            "        //print(\"tooltip query? %s\\n\", mark.name);",
-            "        return mark.name;",
-            "    });",
-            "    ",
-            "    this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
-            "    ",
-            "    ",
-            "    var gattrs = new GtkSource.MarkAttributes();",
-            "    var  grey =   Gdk.RGBA();",
-            "    grey.parse ( \"#ccc\");",
-            "    gattrs.set_background ( grey);",
+            "",
+            "\tthis.loading = true;",
+            "\t//var buf = this.el.get_buffer();",
+            "\t//buf.notify.connect(this.onCursorChanged);",
+            "",
+            "",
+            "\tvar attrs = new GtkSource.MarkAttributes();",
+            "\tattrs.set_icon_name ( \"process-stop\");    ",
+            "\tattrs.query_tooltip_text.connect(( mark) => {",
+            "\t\t//print(\"tooltip query? %s\\n\", mark.name);",
+            "\t\treturn mark.name;",
+            "\t});",
+            "",
+            "\tthis.el.set_mark_attributes (\"ERR\", attrs, 1);",
+            "",
+            "\t var wattrs = new GtkSource.MarkAttributes();",
+            "\twattrs.set_icon_name ( \"process-stop\");    ",
+            "\twattrs.query_tooltip_text.connect(( mark) => {",
+            "\t\t//print(\"tooltip query? %s\\n\", mark.name);",
+            "\t\treturn mark.name;",
+            "\t});",
+            "",
+            "\tthis.el.set_mark_attributes (\"WARN\", wattrs, 1);",
+            "",
+            "",
+            "",
+            "\t var dattrs = new GtkSource.MarkAttributes();",
+            "\tdattrs.set_icon_name ( \"process-stop\");    ",
+            "\tdattrs.query_tooltip_text.connect(( mark) => {",
+            "\t\t//print(\"tooltip query? %s\\n\", mark.name);",
+            "\t\treturn mark.name;",
+            "\t});",
+            "",
+            "\tthis.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
+            "",
+            "",
+            "\tvar gattrs = new GtkSource.MarkAttributes();",
+            "\tvar  grey =   Gdk.RGBA();",
+            "\tgrey.parse ( \"#ccc\");",
+            "\tgattrs.set_background ( grey);",
+            "",
+            "",
+            "\tthis.el.set_mark_attributes (\"grey\", gattrs, 1);",
+            "",
+            "",
             " ",
-            "    ",
-            "    this.el.set_mark_attributes (\"grey\", gattrs, 1);",
-            "    ",
-            "    ",
-            "    ",
-            "    ",
-            "    ",
-            "    ",
-            "}",
-            " "
+            "",
+            "",
+            "\t}",
+            ""
            ],
            "* 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",
+             "* init" : [
+              "{",
+              "\tvar buf = this.el;",
+              "\tbuf.create_tag (\"bold\", \"weight\", Pango.Weight.BOLD);",
+              "\tbuf.create_tag (\"type\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#204a87\");",
+              "\tbuf.create_tag (\"keyword\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#a40000\");",
+              "\tbuf.create_tag (\"text\", \"weight\", Pango.Weight.NORMAL, \"foreground\", \"#729fcf\");",
+              "\tbuf.create_tag (\"number\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#ad7fa8\");",
+              "\tbuf.create_tag (\"method\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#729fcf\");",
+              "\tbuf.create_tag (\"property\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#BC1F51\");",
+              "\tbuf.create_tag (\"variable\", \"weight\", Pango.Weight.BOLD, \"foreground\", \"#A518B5\");",
+              "",
+              "",
+              "\tbuf.create_tag (\"ERR\", \"weight\", Pango.Weight.BOLD, \"background\", \"pink\");",
+              "\tbuf.create_tag (\"WARN\", \"weight\", Pango.Weight.BOLD, \"background\", \"#ABF4EB\");",
+              "\tbuf.create_tag (\"DEPR\", \"weight\", Pango.Weight.BOLD, \"background\", \"#EEA9FF\");",
+              "}",
+              "",
+              ""
+             ],
              "* pack" : "set_buffer",
              "bool dirty" : false,
+             "bool in_cursor_change" : false,
              "id" : "buffer",
              "int error_line" : "-1",
+             "int last_line" : "-1",
              "listeners" : {
               "changed" : [
                " () => {",
                "",
                " ",
                ""
+              ],
+              "cursor_moved" : [
+               "( ) => {",
+               "GLib.debug(\"cursor moved called\");",
+               "",
+               "",
+               " \tif (this.in_cursor_change ) {",
+               "        GLib.debug(\"cursor changed : %d [ignoring nested call)\", this.el.cursor_position);",
+               "        return;",
+               "    }",
+               "   ",
+               "    GLib.debug(\"cursor changed : %d\", this.el.cursor_position);",
+               "    Gtk.TextIter cpos;",
+               "    this.el.get_iter_at_offset(out cpos, this.el.cursor_position);",
+               "    ",
+               "    var ln = cpos.get_line();",
+               "    if (this.last_line == ln ){",
+               "    \treturn;",
+               "\t}",
+               "\tthis.last_line = ln;",
+               "    var node = _this.file.lineToNode(ln);",
+               "",
+               "    if (node == null) {",
+               "        print(\"can not find node\\n\");",
+               "        return;",
+               "    }",
+               "    this.in_cursor_change  = true;",
+               "    var ltree = _this.main_window.windowstate.left_tree;",
+               "    ltree.model.selectNode(node);",
+               "    this.in_cursor_change  = false;",
+               "}",
+               ""
               ]
              },
              "xtype" : "Buffer",
-             "| bool highlightErrors" : [
-              "( Gee.HashMap<int,string> validate_res) {",
-              "         ",
-              "    this.error_line = validate_res.size;",
-              "\t",
-              "    if (this.error_line < 1) {",
-              "          return true;",
-              "    }",
-              "    var tlines = this.el.get_line_count ();",
-              "    Gtk.TextIter iter;",
-              "    var valiter = validate_res.map_iterator();",
-              "    while (valiter.next()) {",
-              "    ",
-              "//        print(\"get inter\\n\");",
-              "        var eline = valiter.get_key();",
-              "        if (eline > tlines) {",
-              "            continue;",
-              "        }",
-              "        this.el.get_iter_at_line( out iter, eline);",
-              "        //print(\"mark line\\n\");",
-              "        this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
-              "    }   ",
-              "    return false;",
-              "}"
-             ],
              "| string toString" : [
               "  () {",
               "    ",
              ]
             },
             {
+             "# 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" : {
-              "released" : [
-               "(n_press, x, y) => {",
+              "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}",
                "",
-               "\tprint(\"BUTTON RELEASE EVENT\\n\");",
-               "\t_this.sourceview.onCursorChanged();",
-               "\t//this.button_is_pressed = false;",
-               "\t ",
+               "\treturn true;",
                "}",
                ""
               ]
              },
-             "xtype" : "GestureClick"
+             "xtype" : "EventControllerScroll"
             }
            ],
            "listeners" : {
             "}",
             ""
            ],
-           "| void highlightErrorsJson" : [
-            " (string type, Json.Object obj) {",
-            "       // this is a hook for the vala code - it has no value in javascript ",
-            "       // as we only have one error ususally....",
-            "        return  ;",
-            "    ",
-            " ",
-            "",
-            "",
-            "}"
-           ],
            "| void loadFile" : [
             "( ) {",
             "    this.loading = true;",
             "    ",
             " ",
             "    buf.set_text(\"\",0);",
-            "    var sbuf = (GtkSource.Buffer) buf;",
+            " ",
             "",
             "    ",
             "",
             "    ",
             "    _this.main_window.windowstate.updateErrorMarksAll();",
             "    ",
-            "    // what does this do?",
+            "    //  restore the cursor position?",
+            "    // after reloading the contents.",
             "     GLib.Timeout.add(500, () => {",
-            "",
+            "\t\t_this.buffer.in_cursor_change = true;",
             "        print(\"RESORTING cursor to = %d\\n\", cpos);",
             "\t\tGtk.TextIter cpos_iter;",
             "\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);",
             "\t\tbuf.place_cursor(cpos_iter); ",
             "\t\t",
             "\t\tthis.el.get_vadjustment().set_value(vadj_pos);;",
-            "\t\t",
-            "",
-            "\t\tthis.onCursorChanged();",
+            "\t\t_this.buffer.in_cursor_change = false;",
+            " ",
             "\t\t",
             "\t\t",
             "\t\t//_this.buffer.checkSyntax();",
             ""
            ],
            "| void nodeSelected" : [
-            "(JsRender.Node? sel, bool scroll ) {",
+            "(JsRender.Node? sel, bool scroll) {",
             "  ",
             "    ",
-            "\t",
+            "    if (this.loading) {",
+            "    \treturn;",
+            "\t}",
             "    // this is connected in widnowstate",
+            "    print(\"Roo-view - node selected\\n\");",
+            "    var buf = this.el.get_buffer();",
+            " ",
+            "    var sbuf = (GtkSource.Buffer) buf;",
             "",
-            "",
-            "\t// not sure why....   ",
-            "  //  while(Gtk.events_pending()) {",
-            "   //     Gtk.main_iteration();",
-            " //   }",
             "    ",
-            "    this.node_selected = sel;",
             "    ",
-            "   // this.updateGreySelection(scroll);",
+            "   ",
+            "    // clear all the marks..",
+            "     Gtk.TextIter start;",
+            "    Gtk.TextIter end;     ",
+            "        ",
+            "    sbuf.get_bounds (out start, out end);",
+            "    sbuf.remove_source_marks (start, end, \"grey\");",
             "    ",
+            "        this.node_selected = sel;",
+            "     if (sel == null) {",
+            "        // no highlighting..",
+            "        return;",
+            "    }",
+            "    Gtk.TextIter iter;   ",
+            "    sbuf.get_iter_at_line(out iter,  sel.line_start);",
             "    ",
             "    ",
-            "}",
-            "",
-            "   ",
-            ""
-           ],
-           "| void onCursorChanged" : [
-            "(/*ParamSpec ps*/) {",
-            "",
-            "\t\tif (!this.key_is_pressed && !this.button_is_pressed) {",
-            "\t\t\treturn;",
-            "\t\t}",
-            "",
-            "\t   if (this.loading) {",
-            "            return;",
-            "        }",
-            "       // if (ps.name != \"cursor-position\") {",
-            "       //     return;",
-            "       // }",
-            "",
-            "        var buf = this.el.get_buffer();",
-            "        //print(\"cursor changed : %d\\n\", buf.cursor_position);",
-            "        Gtk.TextIter cpos;",
-            "        buf.get_iter_at_offset(out cpos, buf.cursor_position);",
-            "        ",
-            "        var ln = cpos.get_line();",
-            "        ",
-            "        ",
-            "        // --- select node at line....",
-            "        ",
-            "        var node = _this.file.lineToNode(ln+1);",
-            " ",
-            "        if (node == null) {",
-            "            print(\"can not find node\\n\");",
-            "            return;",
+            "    Gtk.TextIter cur_iter;",
+            "    sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
+            "    ",
+            "    //var cur_line = cur_iter.get_line();",
+            "    //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
+            "    ",
+            "    //} else {",
+            "    if (! _this.buffer.in_cursor_change) {",
+            "    \tthis.el.scroll_to_iter(iter,  0.1f, true, 0.0f, 0.5f);",
+            "\t}",
+            "    ",
+            "     ",
+            "    ",
+            "    for (var i = 0; i < buf.get_line_count();i++) {",
+            "        if (i < sel.line_start || i > sel.line_end) {",
+            "           ",
+            "            sbuf.get_iter_at_line(out iter, i);",
+            "            sbuf.create_source_mark(null, \"grey\", iter);",
+            "            ",
             "        }",
-            "        var prop = node.lineToProp(ln+1);",
-            "        print(\"prop : %s\", prop == null ? \"???\" : prop.name);",
-            "        ",
-            "        ",
-            "        // ---------- this selects the tree's node...",
-            "        ",
-            "        var ltree = _this.main_window.windowstate.left_tree;",
-            "         ltree.model.selectNode(node);",
-            "        ",
-            "\t       ",
-            "        //print(\"changing cursor on tree..\\n\");",
-            "       ",
+            "    ",
+            "    }",
+            "    ",
             "",
-            "        ",
-            "        // let's try allowing editing on the methods.",
-            "        // a little klunky at present..",
-            "        this.prop_selected = \"\";",
-            "        /*",
-            "        if (prop != null) {",
-            "    \t\t//see if we can find it..",
-            "    \t\tvar kv = prop.split(\":\");",
-            "    \t\tif (kv[0] == \"p\") {",
-            "    \t\t",
-            "        \t\t//var k = prop.get_key(kv[1]);",
-            "        \t\t// fixme -- need to determine if it's an editable property...",
-            "        \t\tthis.prop_selected = prop;",
-            "        \t\t",
-            "    \t\t} else if (kv[0] == \"l\") {",
-            "    \t\t\t this.prop_selected = prop;",
-            "    \t\t\t",
-            "    \t\t}",
-            "        }",
-            "       */",
-            "           // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
-            "           //this.nodeSelected(node,false);",
-            "            ",
-            "            // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
-            "           ",
-            "        ",
-            "        // highlight the node..",
             "}",
-            " "
+            ""
            ],
            "| void updateGreySelection" : [
             "(bool scroll) { ",
          "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" : [
     "    this.view.renderJS(true);",
     "    this.notebook.el.page = 0;// gtk preview ",
     "    this.sourceview.loadFile();   ",
+    "    this.last_error_counter = -1;",
+    "    this.updateErrorMarks();",
     "}",
     " ",
     " "
     ""
    ],
    "| void updateErrorMarks" : [
-    "(string category) {",
+    "() {",
     "\t",
     " ",
     "",
     "\tGtk.TextIter end;     ",
     "\tbuf.get_bounds (out start, out end);",
     "",
-    "\tbuf.remove_source_marks (start, end, category);",
+    "",
     " ",
     "\tGLib.debug(\"highlight errors\");\t\t ",
     "",
     "\t\treturn;",
     "",
     "\t}",
-    "\tvar ar = this.file.getErrors(category);",
-    "\tif (ar == null || ar.get_n_items() < 1) {",
-    "\t\tGLib.debug(\"higjlight %s has no errors\", category);",
+    "\tvar ar = this.file.getErrors();",
+    "\tif (ar.size < 1) {",
+    "\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, \"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}",
+    " \tif (this.last_error_counter == file.error_counter) {",
     "\t\treturn;",
     "\t}",
-    " ",
-    "",
-    " ",
-    "\t",
-    "\tvar offset = 0;",
-    "\t ",
     "",
     "\tvar tlines = buf.get_line_count () +1;",
     "\t",
     " ",
     "\t ",
-    "\tfor (var i = 0; i < ar.get_n_items();i++) {",
-    "\t\tvar err = (Palete.CompileError) ar.get_item(i);",
+    "\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);",
+    "\tforeach(var diag in ar) { ",
+    "\t",
     "\t\t",
     "\t     Gtk.TextIter iter;",
     "//        print(\"get inter\\n\");",
-    "\t    var eline = err.line - offset;",
-    "\t    GLib.debug(\"GOT ERROR on line %d -- converted to %d  (offset = %d)\",",
-    "\t    \terr.line ,eline, offset);",
-    "\t    ",
-    "\t    ",
+    "\t    var eline = (int)diag.range.start.line ;",
+    "\t    var eline_to = (int)diag.range.end.line;",
     "\t    if (eline > tlines || eline < 0) {",
     "\t        return;",
     "\t    }",
     "\t    ",
     "\t    buf.get_iter_at_line( out iter, eline);",
     "\t   ",
+    "\t  \t buf.get_iter_at_line_offset( out start, ",
+    " \t    \teline, (int)diag.range.start.character); ",
+    " \t    buf.get_iter_at_line_offset( out end, ",
+    " \t    \teline_to, (int)diag.range.end.character); ",
+    " \t    \t",
+    "\t    buf.apply_tag_by_name(diag.category, start, end);",
+    "\t   ",
     "\t   ",
-    "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, err.category, err.msg);",
-    "\t    buf.create_source_mark( msg, err.category, iter);",
+    "\t\tvar msg = \"Line: %d %s : %s\".printf(eline+1, diag.category, diag.message);",
+    "\t    buf.create_source_mark( msg, diag.category, iter);",
     "\t    GLib.debug(\"set line %d to %s\", eline, msg);",
     "\t    //this.marks.set(eline, msg);",
     "\t}",
-    "\treturn ;",
+    "\tthis.last_error_counter = file.error_counter ;",
     "",
     "",
     "",